easy_flow 0.48.0 → 0.49.1
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.
- checksums.yaml +4 -4
- data/app/assets/builds/easy_flow/canvas.js +3 -1
- data/app/controllers/concerns/easy_flow/manage/draws_canvas.rb +4 -3
- data/app/javascript/easy_flow/canvas/Canvas.jsx +33 -55
- data/app/javascript/easy_flow/canvas/Control.jsx +3 -2
- data/app/javascript/easy_flow/canvas/flowSender.js +12 -2
- data/app/javascript/easy_flow/canvas/reading.js +33 -18
- data/app/javascript/easy_flow/canvas/topBar.js +8 -0
- data/app/models/easy_flow/canvas.rb +16 -2
- data/app/models/easy_flow/document.rb +1 -0
- data/app/models/easy_flow/draft_status.rb +11 -2
- data/app/models/easy_flow/step_type.rb +1 -1
- data/app/views/easy_flow/manage/flows/_top_bar.html.erb +2 -2
- data/lib/easy_flow/engine.rb +1 -3
- data/lib/easy_flow/version.rb +1 -1
- data/the_local/agents/easy_flow-develop.md +2 -2
- data/the_local/agents/easy_flow-info.md +1 -1
- data/the_local/agents/easy_flow-install.md +2 -2
- metadata +22 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d1bc6c3021e5483a54e6b7437ccd1bfb77e1b6f55b756a297229001a23890344
|
|
4
|
+
data.tar.gz: 05f7f41e775e425c575d1674704a4b2d1d6027e36085a1da1126ac03ced0de98
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75709e2b24eb83d2d3864415a9986e15aa5b13c12d1edb722afaef188914640e5396d85897b2477b65d56c2635f1ec5dc2035348a4183aa3c319fb4612b5ae2c
|
|
7
|
+
data.tar.gz: a728dacda4be3a8d33fc93d45e5b4913703b21f3496a5f88a8ff74cd4aaecb5746a9794d8d42f2cd8d8f76130186f42cb5e47aac63a628b1720887b0e3ae7e42
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
(()=>{var jt=globalThis.ReactDOM;var{createPortal:Yr,createRoot:fe,flushSync:Xr,hydrateRoot:qr,preconnect:Jr,prefetchDNS:Kr,preinit:Zr,preinitModule:Qr,preload:Rr,preloadModule:es,requestFormReset:ts,unstable_batchedUpdates:os,useFormState:rs,useFormStatus:ss,version:ns}=jt;var ge=globalThis.React,t=ge,{Children:is,Component:ls,Fragment:ds,PureComponent:cs,StrictMode:ps,Suspense:ms,cloneElement:us,createContext:fs,createElement:gs,createRef:xs,forwardRef:hs,isValidElement:ys,lazy:bs,memo:vs,startTransition:ks,useCallback:ws,useContext:Ss,useDebugValue:Cs,useDeferredValue:Ns,useEffect:P,useId:_s,useImperativeHandle:zs,useLayoutEffect:xe,useMemo:j,useReducer:Es,useRef:ee,useState:w,useSyncExternalStore:Bs,useTransition:Ts}=ge;var he=new Map,F=new Map,te=(e,o)=>he.set(e,o),ye=()=>{F.forEach(e=>e.unmount()),F.clear()},be=(e,o)=>e.querySelectorAll("[data-react-ui]").forEach(s=>{if(F.has(s))return;let r=he.get(s.dataset.reactUi),n=o(s);F.set(s,n),n.render(t.createElement(r,JSON.parse(s.dataset.props)))});var ve=(e,o)=>{let s=()=>be(e,o);e.addEventListener("turbo:load",s),e.addEventListener("turbo:frame-load",s),e.addEventListener("turbo:before-cache",ye),e.readyState==="loading"?e.addEventListener("DOMContentLoaded",s):s()};var _=(...e)=>e.filter(Boolean).join(" ");var Ht={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},Wt={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Vt=({variant:e="primary",size:o="md",className:s,children:r,...n})=>{let i=n.href?"a":"button";return t.createElement(i,{...n,className:_("ks-button",Ht[e],Wt[o],s)},r)},v=Vt;var Ft="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Ut="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Gt="border border-accent-600 bg-accent-600 text-white",Yt=({name:e,connected:o,armed:s,onArm:r,connecting:n})=>t.createElement("button",{onClick:i=>{n||(i.stopPropagation(),r(i))},title:s?"Now choose a step to connect to":"Connect this branch",className:s?Gt:o?Ut:Ft,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},e||"next"),ke=Yt;var Xt={width:240,boxSizing:"border-box",borderRadius:8},qt={minWidth:120,boxSizing:"border-box",borderRadius:6},Jt={padding:"8px 14px",textAlign:"center",fontWeight:600},Kt={fontWeight:600,lineHeight:1.3},Zt={fontSize:12,fontWeight:500,lineHeight:1.3},Qt=(e,o,s)=>{let r=s?"ring-4 ring-accent-600/15":"shadow-sm";return e||s&&!o?`border-accent-600 ${r}`:o?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},Rt=(e,o)=>o&&e.label===e.id&&e.type_name||e.label,eo=(e,o,s)=>s?o===e.type_name?null:e.type_name:e.type,to=({node:e,selected:o,armed:s,connecting:r,onSelect:n,onOpen:i,onArm:d,onDragEnd:c,onDragStart:l,hideStepTypeCodes:h,branches:g=[],compact:u=!1,typeAbove:x=u})=>{let y=e.begins_here||e.ends_here,m=e.begins_here,S=e.ends_here?[]:e.ports,k=r&&!m,C=Rt(e,h),B=eo(e,C,h);return t.createElement("div",{ref:e.ref,"data-step":e.id,draggable:!m,onDragStart:b=>{b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("text/plain",e.id),l()},onDragEnd:c,onClick:e.opens&&!r?()=>i(e.opens):n,className:`bg-white ${u&&!o?"border":"border-2"} dark:bg-zinc-900 ${Qt(k,e.violations.length>0,o)}`,style:{...u?qt:Xt,padding:y?0:u?"8px 10px":"12px 14px",cursor:m?"default":r?"crosshair":"grab"}},!y&&x&&B&&t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},B),y&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:Jt},C),!y&&t.createElement("div",{style:u?Zt:Kt},C),e.violations.length>0&&t.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${e.violations.length} error${e.violations.length===1?"":"s"}`),!y&&e.summary&&e.violations.length===0&&t.createElement("div",{className:o?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},e.summary),!y&&!x&&B&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},B),e.picture_url&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),e.starts_a_flow&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),e.opens&&t.createElement(v,{variant:"secondary",size:"sm",className:"mt-2",onClick:b=>{b.stopPropagation(),n()}},"Settings"),g.map(b=>t.createElement("div",{key:b,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},b)),S.length>0&&t.createElement("div",{style:{padding:e.begins_here?"0 14px 8px":"10px 0 0"}},S.map(b=>t.createElement(ke,{key:b,name:b,connected:e.connected.includes(b),connecting:r,armed:s===b,onArm:f=>d(b,f)}))))},oe=to;var we={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},oo={...we,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},ro=({node:e,header:o,onSelect:s,compact:r=!1})=>t.createElement("div",{ref:e.ref,"data-group-header":e.id,onClick:s,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?oo:we,...s?{}:{cursor:"default"}}},o),U=ro;var so=({id:e,bounds:o,onDrop:s})=>t.createElement("div",{"data-group-box":e,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),s()},className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",zIndex:1,borderRadius:8,boxSizing:"border-box",...o}}),Se=so;var no=e=>e!=null&&e!==""&&typeof e!="object",ao=["integer","float"],io=(e,o,s)=>s&&o.labels?.[e]||e,G=(e,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>no(e.config[n])).map(n=>`${io(n,o,s)}${ao.includes(o.fields[n])?"":":"} ${e.config[n]}`);return[s&&e.type_name||e.type,...r].join(" \xB7 ")};var Ce=(e,o,s)=>{let r=Math.min(...e.map(c=>c.left))-o.left+s.scrollLeft-12,n=Math.min(...e.map(c=>c.top))-o.top+s.scrollTop-10,i=Math.max(...e.map(c=>c.left+c.width))-o.left+s.scrollLeft+12,d=Math.max(...e.map(c=>c.top+c.height))-o.top+s.scrollTop+10;return{left:r,top:n,width:i-r,height:d-n}},lo=({left:e,top:o,width:s,height:r},n)=>n.x>=e&&n.x<=e+s&&n.y>=o&&n.y<=o+r,Ne=(e,o)=>e.find(s=>lo(s.bounds,o))?.id||null,_e=(e,o)=>e.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),ze=(e,o)=>o.some(s=>s.holds?.includes(e.id)&&!s.loose&&s.row===e.row-1);var re=(e,o)=>e.includes(o)?e.filter(s=>s!==o):[...e,o],Ee=(e,o)=>({...o?.choices||{},...e?.choices||{}});var co=({as:e="input",disabled:o,className:s,...r})=>t.createElement(e,{...r,disabled:o,className:_("ks-input",o&&"ks-input-disabled",s)}),L=co;var po=e=>t.createElement(L,{...e,as:"select"}),Be=po;var mo=({className:e,...o})=>t.createElement("input",{type:"checkbox",...o,className:_("ks-checkbox",e)}),Y=mo;var uo=({name:e,value:o,label:s,hint:r,...n})=>t.createElement("label",{className:"inline-block cursor-pointer relative"},t.createElement("input",{type:"radio",name:e,value:o,...n,className:"peer sr-only"}),t.createElement("span",{className:"ks-radio-card inline-flex flex-col cursor-pointer transition ks-radio-card-highlight"},t.createElement("span",{className:"ks-radio-card-header flex items-start justify-between"},t.createElement("span",{className:"ks-radio-card-label block"},s)),r!=null&&t.createElement("span",{className:"ks-radio-card-hint block text-sm"},r))),Te=uo;var fo=({name:e,options:o,value:s,onChange:r})=>t.createElement("div",{className:"flex flex-wrap ks-grid-gap-sm"},o.map(n=>t.createElement(Te,{key:n.value,name:e,...n,checked:n.value===s,onChange:r}))),Ae=fo;var De=e=>(e||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),go=({name:e,type:o,value:s,choices:r,onChange:n,onSettle:i,onPick:d,pictureUrl:c})=>{if(o==="picture")return t.createElement("div",{className:"mb-3"},s&&c&&t.createElement("img",{src:c,alt:"The step's picture",style:{maxWidth:"100%"}}),s&&t.createElement("button",{type:"button","data-remove-picture":!0,className:"ks-button ks-button-secondary ks-button-sm",onClick:()=>i("")},"Remove picture"),t.createElement("input",{type:"file",accept:"image/*",onChange:l=>l.target.files[0]&&d(l.target.files[0])}));if(o==="boolean")return t.createElement(Y,{checked:!!s,onChange:l=>i(l.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return t.createElement(Be,{className:"mb-3",value:s??"",onChange:l=>i(l.target.value)},t.createElement("option",{value:""}),De(r).map(l=>t.createElement("option",{key:l.value,value:l.value},l.label)));if(o==="radio_cards")return t.createElement("div",{"data-radio-cards":!0,className:"mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full"},t.createElement(Ae,{name:e,value:s,options:r||[],onChange:l=>i(l.target.value)}));if(o==="multi_select"){let l=Array.isArray(s)?s:[],h=g=>i(re(l,g));return t.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(r||[]).map(g=>t.createElement("label",{key:g,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(Y,{checked:l.includes(g),onChange:()=>h(g)}),t.createElement("span",null,g))))}if(o==="flows"){let l=Array.isArray(s)?s:[];return t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},De(r).map(h=>t.createElement("label",{key:h.value,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(Y,{checked:l.includes(h.value),onChange:()=>i(re(l,h.value))}),t.createElement("span",null,h.label))))}return o==="integer"||o==="float"?t.createElement(L,{className:"mb-3",type:"number",step:o==="integer"?"1":"any",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>i(l.target.value)}):t.createElement(L,{className:"mb-3",type:"text",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>i(l.target.value)})},X=go;var Le=(e,o,s,r)=>e.map((n,i)=>i===o?{...n,[s]:r}:n);var xo=({text:e})=>t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},e),q=xo;var ho=(e,o,s,r)=>{let n=(e||{})[s],i=(o||{})[s];return i?(n||{})[r[i]]:n},yo=({holds:e,labels:o,explanations:s,rows:r,choices:n,outputsOf:i,onChange:d,onSettle:c})=>{let l=Array.isArray(r)?r:[],h=(g,u,x,y)=>{let m=Le(l,g,u,x);y?c(m):d(m)};return t.createElement("div",{style:{marginBottom:12}},l.map((g,u)=>t.createElement("div",{key:u,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(e).map(([x,y])=>t.createElement("label",{key:x,style:{display:"block"}},t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[x]||x),t.createElement(X,{type:y,value:g[x],choices:ho(n,i,x,g),onChange:m=>h(u,x,m,!1),onSettle:m=>h(u,x,m,!0)}),(s||{})[x]&&t.createElement(q,{text:s[x]}))),t.createElement(v,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>c(l.filter((x,y)=>y!==u))},"Remove"))),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>c([...l,{}])},"Add"))},Oe=yo;var bo={start:null,end:"ks-value-list-end"},vo="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",ko="flex flex-col min-w-0",wo="ks-value-list-label basis-auto text-xs",So=()=>t.createElement("svg",{"aria-label":"Right",role:"img",className:"ks-tone-success inline size-5 align-text-bottom",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},t.createElement("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z",clipRule:"evenodd"})),Co=({value:e,fallback:o})=>String(e??"")===""?o:e,No=({rows:e,align:o="start",columns:s=!1})=>t.createElement("dl",{className:_("ks-value-list",bo[o],s&&vo)},e.map((r,n)=>t.createElement("div",{key:n,className:_(s?ko:"ks-value-list-row",r.total&&"ks-value-list-total")},t.createElement("dt",{className:s?wo:"ks-value-list-label"},r.label,r.note!=null&&t.createElement(t.Fragment,null," ",t.createElement("span",{className:"ks-value-list-note"},r.note))),t.createElement("dd",{className:"ks-value-list-value"},Co(r),r.right&&t.createElement(t.Fragment,null," ",t.createElement(So,null)))))),$e=No;var _o=()=>t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})),zo=({summary:e,open:o=!1,children:s})=>t.createElement("details",{className:"ks-disclosure group",open:o},t.createElement("summary",{className:"ks-disclosure-summary flex cursor-pointer list-none items-center justify-between [&::-webkit-details-marker]:hidden"},t.createElement("span",null,e),t.createElement("span",{className:"ks-disclosure-icon h-4 w-4 shrink-0 transition-transform group-open:rotate-180"},t.createElement(_o,null))),t.createElement("div",{className:"ks-disclosure-body text-sm"},s)),Pe=zo;var Eo=({language:e,caption:o,children:s})=>t.createElement("div",{className:"ks-code overflow-hidden"},o!=null&&t.createElement("div",{className:"ks-code-caption font-mono text-xs"},o),t.createElement("pre",{className:"ks-code-block overflow-x-auto font-mono text-sm leading-relaxed"},t.createElement("code",{className:e==null?"":`language-${e}`},s))),Me=Eo;var se="flex flex-col gap-1 mb-3",Ie="[&_dd]:font-mono",Bo="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",To="[&_.ks-value-list]:font-mono [&_.ks-value-list]:flex [&_.ks-value-list]:flex-col [&_.ks-value-list]:gap-1 [&_.ks-value-list-row]:gap-2 [&_.ks-value-list-row]:py-0 [&_.ks-value-list-row]:border-0 [&_.ks-value-list-label]:basis-[90px]",Ao="border-t border-gray-200 pt-2.5 dark:border-zinc-700 [&_.ks-disclosure]:border-0 [&_.ks-disclosure-summary]:flex-row-reverse [&_.ks-disclosure-summary]:justify-end [&_.ks-disclosure-summary]:gap-1 [&_.ks-disclosure-summary]:p-0 [&_.ks-disclosure-summary]:font-normal [&_.ks-disclosure-body]:p-0 [&_.ks-disclosure-body]:pt-1.5 [&_.ks-code-block]:p-2 [&_.ks-code-block]:text-[11px]",Do=e=>e.values?e.columns?`${se} ${Ie} ${Bo}`:`${se} ${Ie} ${To}`:`${se} ${Ao}`,Lo=({details:e})=>t.createElement(t.Fragment,null,e.map((o,s)=>t.createElement("section",{key:s,className:Do(o)},o.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400"},o.heading),o.values&&t.createElement($e,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>t.createElement(Pe,{key:r.summary,summary:r.summary},t.createElement(Me,null,r.code)))))),je=Lo;var Oo=({as:e="div",className:o,children:s,...r})=>t.createElement(e,{...r,className:_("ks-panel",o)},s),T=Oo;var J=(e,o)=>({className:s,children:r,...n})=>t.createElement(e,{...n,className:_(o,s)},r),W=J("label","ks-label"),Jn=J("p","ks-hint"),Kn=J("p","ks-error"),Zn=J("span","ks-required");var $o={width:320,padding:"14px 16px",overflowY:"auto",display:"flex",flexDirection:"column",fontSize:12},Po={marginTop:"auto",paddingTop:12,display:"flex",flexDirection:"column",gap:8},Mo=({node:e,fields:o,holds:s,labels:r,explanations:n,recordLabels:i,recordExplanations:d,recordChoices:c,recordOutputsOf:l,choices:h,onSave:g,onDelete:u,onClose:x,onPickPicture:y,refusal:m})=>{let[S,k]=w(e.config),[C,B]=w(e.picture_url);P(()=>B(e.picture_url),[e.id,e.picture_url]),P(()=>k(e.config),[e.id,e.config]);let b=f=>{k(f),JSON.stringify(f)!==JSON.stringify(e.config)&&g(f)};return t.createElement(T,{as:"aside",style:$o,className:"max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto","data-inspector":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8,marginBottom:12}},t.createElement("div",null,t.createElement("p",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.id," \xB7 ",e.type),t.createElement("h2",{style:{fontSize:15,fontWeight:600}},e.label)),t.createElement("button",{title:"Close",onClick:x,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),m&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},m),Object.entries(o).map(([f,O])=>t.createElement(W,{key:f},t.createElement("span",{style:{display:"block",marginBottom:3}},r[f]||f),O==="list"?t.createElement(Oe,{holds:s[f]||{},labels:i[f]||{},explanations:(d||{})[f],rows:S[f],choices:{...(c||{})[f],...(e.record_choices||{})[f]},outputsOf:(l||{})[f],onChange:z=>k({...S,[f]:z}),onSettle:z=>b({...S,[f]:z})}):t.createElement(X,{name:f,type:O,value:S[f],choices:h[f],pictureUrl:C,onChange:z=>k({...S,[f]:z}),onSettle:z=>b({...S,[f]:z}),onPick:async z=>{let E=await y(z);E&&(B(E.url),b({...S,[f]:E.reference}))}}),(n||{})[f]&&t.createElement(q,{text:n[f]}))),t.createElement(je,{details:e.details||[]}),t.createElement("div",{style:Po},(e.links||[]).length>0&&t.createElement("div",{style:{display:"flex",gap:8}},e.links.map(f=>t.createElement(v,{key:f.address,variant:"secondary",size:"sm",className:"flex-1",href:f.address},f.label))),t.createElement(v,{variant:"danger",size:"sm",className:"w-full",onClick:u},"Delete step")))},He=Mo;var Io={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},jo={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},Ho="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",Wo="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Vo=({node:e,dragging:o,onFill:s,onDrop:r,compact:n=!1})=>t.createElement("div",{ref:e.ref,"data-placeholder":e.id,title:`Choose the step \u201C${e.label}\u201D should lead to`,onClick:s,onDragOver:i=>{o&&(i.preventDefault(),i.dataTransfer.dropEffect="move")},onDrop:i=>{i.preventDefault(),r()},className:o?Wo:Ho,style:n?jo:Io},t.createElement("div",{style:{fontWeight:600}},e.label),t.createElement("div",{style:{fontSize:11}},o?"drop a step here":"leads nowhere yet \u2014 click to choose")),We=Vo;var Fo=({entries:e,at:o,onPick:s,onConnect:r,onDismiss:n,hideStepTypeCodes:i})=>t.createElement(T,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:o.y,left:o.x,width:210,padding:8,borderRadius:8}},t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),e.map(d=>t.createElement(v,{key:d.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>s(d)},d.label,!i&&t.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},d.type))),r&&t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:n},"Cancel")),Ve=Fo;var Uo=e=>o=>o.label.toLowerCase().includes(e.trim().toLowerCase()),Go=(e,o,s="")=>{let r=Object.values(o).flat(),n=Object.entries(o).map(([i,d])=>({heading:i,entries:d.map(c=>e.find(l=>l.type===c)).filter(Boolean)}));return[{heading:null,entries:e.filter(i=>!r.includes(i.type))},...n].map(i=>({...i,entries:i.entries.filter(Uo(s))})).filter(i=>i.entries.length>0)},Yo={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},Xo={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},qo={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},Jo=({entries:e,groups:o,onPick:s,onCarry:r,onDrop:n})=>{let[i,d]=w("");return t.createElement(T,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:Yo},t.createElement(L,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:i,onChange:c=>d(c.target.value),style:{marginBottom:6,fontSize:12}}),Go(e,o,i).map(c=>t.createElement(t.Fragment,{key:c.heading||""},c.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:Xo},c.heading),c.entries.map(l=>t.createElement(T,{as:"button",type:"button",key:l.type,"data-step-type":l.type,className:"bg-surface-50 dark:bg-surface-950",style:qo,draggable:!0,onClick:()=>s(l),onDragStart:h=>{h.dataTransfer.effectAllowed="copyMove",h.dataTransfer.setData("text/plain",l.type),r(l)},onDragEnd:n},l.label)))))},Fe=Jo;var Ko={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Ue=({label:e,title:o,idle:s,enabled:r,onUse:n})=>t.createElement(v,{variant:"secondary",size:"sm",title:r?o:s,disabled:!r,onClick:n,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},e),Zo=({undoable:e,redoable:o,onAdd:s,onUndo:r,onRedo:n})=>t.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},t.createElement(v,{variant:"secondary",className:"rounded-full",style:Ko,title:"Add a step",onClick:s},"+"),t.createElement(Ue,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:e,onUse:r}),t.createElement(Ue,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),Ge=Zo;var Qo=({type:e="info",title:o,message:s,onDismiss:r,className:n})=>t.createElement("div",{className:_("ks-alert",`ks-alert-${e}`,n),role:"alert"},t.createElement("div",{className:"ks-alert-body"},t.createElement("div",{className:"ks-alert-content"},o&&t.createElement("p",{className:"ks-alert-title"},o),t.createElement("p",{className:o?"ks-alert-message-titled":"ks-alert-message"},s)),r&&t.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),Ye=Qo;var Xe=e=>{let o=e.map(s=>`\u201C${s.name}\u201D`).join(", ");return e.length===1?`${o} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${o} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var qe=({version:e,published:o})=>e?o?o===e?`Version ${e} \xB7 live`:`Version ${e} \xB7 visitors still on ${o}`:`Version ${e} \xB7 never published`:"No version yet";var Ro={width:280,padding:20,overflowY:"auto"},Je={fontWeight:600,marginBottom:6,marginTop:14},ne={fontSize:12,marginBottom:4,lineHeight:1.4},Ke={display:"block",marginBottom:3},Ze=(e,o,s)=>r=>{r.target.value!==(e[o]??"")&&s({[o]:r.target.value})},er=({flow:e,changes:o,refusal:s,notice:r,publishNote:n,warning:i,onCreate:d,onPublish:c,onAccept:l,onDecline:h,onSaveDetails:g,onClose:u})=>t.createElement(T,{as:"aside",style:Ro,"data-builder-panel":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},t.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},e.title||e.slug),t.createElement("button",{title:"Close",onClick:u,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),t.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:e.history_url,"data-history":!0},qe(e)),i?t.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},t.createElement(Ye,{type:"warning",className:"mb-1.5",message:Xe(i.steps)}),t.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:l,"data-accept-removal":!0},i.path==="/publish"?"Remove and publish":"Remove and create version"),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:h,"data-decline-removal":!0},"Cancel")):t.createElement("div",{style:{marginTop:14}},t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:d,"data-create-version":!0},"Create version"),t.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:c,"data-publish":!0},"Publish"),n&&t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},n)),s&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...ne,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&t.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...ne,fontWeight:600,marginTop:8},"data-notice":!0},r),t.createElement("h2",{style:Je},"Changes since the last version"),o.length===0?t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):o.map((x,y)=>t.createElement("p",{key:y,style:ne,"data-change":!0},x)),t.createElement("h2",{style:Je},"Details"),t.createElement(W,null,t.createElement("span",{style:Ke},"Title"),t.createElement(L,{className:"mb-3",defaultValue:e.title??"",onBlur:Ze(e,"title",g),"data-flow-title":!0})),t.createElement(W,null,t.createElement("span",{style:Ke},"Start label"),t.createElement(L,{className:"mb-3",defaultValue:e.start_label??"",onBlur:Ze(e,"start_label",g),"data-flow-start-label":!0})),t.createElement("div",{style:{marginTop:16}},t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.definition_url,"data-definition":!0},"Definition"),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.details_url,"data-details":!0},"Edit details"))),Qe=er;var tr=({variant:e="neutral",className:o,children:s,...r})=>t.createElement("span",{...r,className:_("ks-badge",`ks-badge-${e}`,o)},s),Re=tr;var or={center:"ks-tab-bar flex flex-wrap justify-center max-sm:flex-nowrap max-sm:overflow-x-auto max-sm:justify-start",start:"ks-tab-bar flex flex-wrap justify-start max-sm:flex-nowrap max-sm:overflow-x-auto"},rr={pills:"ks-tab-bar-pills",underline:"ks-tab-bar-underline"},sr="ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",nr="ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",ar=({shape:e,count:o})=>e?t.createElement("span",{className:"ks-tab-count"},o):t.createElement(Re,{variant:"info"},o),ir=e=>typeof e=="string"?e!=="":e>0,lr=({tabs:e,value:o,onChange:s,align:r="center",shape:n})=>t.createElement("div",null,t.createElement("div",{className:_(or[r],rr[n])},e.map(i=>t.createElement("button",{key:i.value,type:"button",className:n?nr:sr,"data-active":i.value===o?"":void 0,onClick:()=>s(i.value)},i.label,ir(i.count)&&t.createElement(t.Fragment,null," ",t.createElement(ar,{shape:n,count:i.count}))))),e.find(i=>i.value===o)?.content),et=lr;var dr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},tt="mx-6 mb-6 flex max-h-[45%] flex-none flex-col overflow-y-auto rounded-lg max-sm:m-0 max-sm:max-h-none max-sm:rounded-none [&_.ks-tab-bar]:mb-0 [&_.ks-tab-bar]:px-2",cr="max-sm:absolute max-sm:inset-0 max-sm:z-20",st={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},ot={display:"flex",gap:8,textAlign:"left"},rt={flexShrink:0,whiteSpace:"nowrap"},pr=({check:e,onSelect:o})=>{let s=t.createElement(t.Fragment,null,t.createElement("span",{className:dr[e.level],style:{...rt,fontWeight:500}},e.level),e.node&&t.createElement("span",{className:"font-mono",style:rt},e.node),t.createElement("span",null,e.sentence));return e.node?t.createElement("button",{type:"button","data-check-row":!0,"data-step-id":e.node,style:{...ot,border:"none",background:"none",padding:0,cursor:"pointer",font:"inherit",color:"inherit"},onClick:()=>o(e.node)},s):t.createElement("div",{"data-check-row":!0,style:ot},s)},mr=({checks:e,onSelect:o})=>t.createElement("div",{style:st},e.map((s,r)=>t.createElement(pr,{key:r,check:s,onSelect:o}))),ur=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,fr=({checks:e,tabs:o,onSelect:s,opened:r=ur()?null:"validation"})=>{let[n,i]=w(r);return t.createElement(T,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${tt} ${cr}`:tt},t.createElement(et,{align:"start",shape:"underline",value:n,onChange:d=>i(d===n?null:d),tabs:[{value:"validation",label:"Validation",count:e.filter(d=>d.level==="error").length,content:t.createElement(mr,{checks:e,onSelect:s})},...o.map(d=>({value:d.label,label:d.label,count:d.count??"",content:t.createElement("div",{"data-drawer-content":!0,style:st,dangerouslySetInnerHTML:{__html:d.content}})}))]}))},nt=fr;var at={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},it=e=>({opacity:e?1:0,transition:"opacity .12s"}),gr=({link:e,onInsert:o,onRemove:s,onDrop:r,dragging:n,alwaysShowInsertButtons:i})=>{let[d,c]=w(!1),l=d||n;return t.createElement("div",{"data-connector":`${e.source}-${e.target}`,style:{position:"absolute",left:e.midX-34,top:e.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onDragEnter:()=>c(!0),onDragLeave:()=>c(!1),onDragOver:h=>{h.preventDefault(),h.dataTransfer.dropEffect="move"},onDrop:h=>{h.preventDefault(),c(!1),r()}},t.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},t.createElement(v,{variant:"secondary",title:n?"Move the step here":"Insert a step here",onClick:o,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(n&&d),style:{...at,...it(l||i)}},"+"),!n&&t.createElement(v,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...at,...it(l)}},"\xD7")))},lt=gr;var xr=({links:e,extent:o,dragging:s,onInsert:r,onRemove:n,onDrop:i,alwaysShowInsertButtons:d})=>t.createElement(t.Fragment,null,t.createElement("svg",{width:o.width,height:o.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},t.createElement("defs",null,t.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},t.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),e.map(c=>t.createElement("path",{key:c.id,"data-link":c.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:c.path}))),e.filter(c=>c.label).map(c=>t.createElement("div",{key:`${c.id}-label`,"data-link-label":c.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:c.midX+(d?2:-10),top:c.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},c.label)),e.filter(c=>!c.placeholder).map(c=>t.createElement(lt,{key:c.id,link:c,dragging:!!s,alwaysShowInsertButtons:d,onInsert:()=>r(c),onRemove:()=>n(c),onDrop:()=>i(c)}))),dt=xr;var ae={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},ct="opacity-0 transition-opacity group-data-[over=true]:opacity-100",hr=({link:e,onInsert:o,onRemove:s,onDrop:r,alwaysShowInsertButtons:n,dragging:i})=>t.createElement("div",{"data-joint":e?.id,className:"group relative h-7 w-full sm:h-auto sm:w-7 sm:self-stretch",onMouseEnter:d=>{d.currentTarget.dataset.over="true"},onMouseLeave:d=>{delete d.currentTarget.dataset.over},onDragOver:d=>{e&&r&&(d.preventDefault(),d.dataTransfer.dropEffect="move")},onDrop:d=>{e&&(d.preventDefault(),r(e))}},e&&t.createElement("div",{className:"absolute left-1/2 top-0 h-full w-px bg-gray-400 sm:left-0 sm:top-1/2 sm:h-px sm:w-full dark:bg-zinc-500"}),e&&o&&t.createElement("div",{className:"absolute inset-0 flex items-center justify-center gap-1 sm:flex-col",style:{zIndex:4}},t.createElement(v,{variant:"secondary",title:"Insert a step here",onClick:d=>o(e,d),className:`rounded-full ${n?"opacity-100":ct}`,style:i?{...ae,opacity:1}:ae},"+"),t.createElement(v,{variant:"danger",title:"Remove this connection",onClick:()=>s(e),className:`rounded-full ${ct}`,style:ae},"\xD7"))),pt=hr;var yr=(e,o)=>e.row-o.row||e.column-o.column,mt=e=>{let o=[...e].sort(yr),s=o.filter(r=>e.some(n=>n.holds?.includes(r.id)));return o.filter(r=>!s.includes(r)).flatMap(r=>[r,...s.filter(n=>r.holds?.includes(n.id))])},ut=e=>{let o=mt(e),s=r=>o.some(n=>n.holds?.includes(r.id));return o.filter(r=>!s(r)).reduce((r,n)=>{if(n.holds)return[...r,{group:n,steps:o.filter(d=>n.holds.includes(d.id))}];let i=r[r.length-1];return i&&!i.group?[...r.slice(0,-1),{steps:[...i.steps,n]}]:[...r,{steps:[n]}]},[])},br=(e,o)=>e[e.findIndex(s=>s.id===o.id)+1]?.id,ft=(e,o,s)=>{let r=br(mt(s),e);return o.filter(n=>n.source===e.id&&(n.label||n.target!==r))},vr=e=>e?.placeholder?"nowhere yet":e?.label,gt=(e,o)=>[e.label,"\u2192",vr(o.find(s=>s.id===e.target))].filter(Boolean).join(" "),xt=(e,o,s)=>e.find(r=>r.source===o.id&&r.target===s.id);var kr={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},ht=({steps:e,edges:o,draw:s,joints:r})=>t.createElement("div",{"data-flow-row":!0,className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5"},e.map((n,i)=>t.createElement("div",{key:n.id,className:"flex flex-col sm:flex-row sm:items-center"},i>0&&t.createElement(pt,{link:xt(o,e[i-1],n),...r}),s(n)))),wr={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},Sr=({group:e,steps:o,edges:s,draw:r,joints:n})=>t.createElement("div",{"data-group-box":e.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:wr},r(e),t.createElement(ht,{steps:o,edges:s,draw:r,joints:n})),Cr=({nodes:e,edges:o,draw:s,joints:r,children:n,style:i})=>t.createElement("div",{"data-flow-rows":!0,style:{...kr,...i}},n,ut(e).map(d=>d.group?t.createElement(Sr,{key:d.group.id,group:d.group,steps:d.steps,edges:o,draw:s,joints:r}):t.createElement(ht,{key:d.steps[0].id,steps:d.steps,edges:o,draw:s,joints:r}))),K=Cr;var yt="Your change was not saved because the server could not be reached.",bt=({base:e,token:o,fetch:s,onFlow:r,onError:n,onNotice:i,onWarning:d=()=>{}})=>async(c,l,h)=>{let g=await s(e+c,{method:l,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:h&&JSON.stringify(h)}).catch(()=>null);if(!g)return i(null),n(yt);let u=await g.json().catch(()=>({}));if(u.unconnected)return i(null),n(null),d({path:c,steps:u.unconnected}),r(await(await s(e+".json",{headers:{Accept:"application/json"}})).json());if(d(null),!g.ok)return i(null),n(u.error||"That change was refused");n(null),i(u.notice||null),r(await(await s(e+".json",{headers:{Accept:"application/json"}})).json())},vt=({base:e,token:o,fetch:s,onError:r})=>async n=>{let i=new FormData;i.append("picture",n);let d=await s(e+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:i}).catch(()=>null);if(!d)return r(yt),null;let c=await d.json().catch(()=>({}));return d.ok?(r(null),c):(r(c.error||"That picture was refused"),null)};var Nr=(e,o,s)=>{let[r,n]=w(s),[i,d]=w(null),[c,l]=w(null),[h,g]=w(null),u=j(()=>bt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onFlow:n,onError:d,onNotice:l,onWarning:g}),[e,o]),x=j(()=>vt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onError:d}),[e,o]);return{flow:r,error:i,notice:c,warning:h,setWarning:g,send:u,pickPicture:x}},kt=Nr;var Z=(e,o,s,r)=>{let n=e.left-s.left+r.scrollLeft,i=e.top-s.top+r.scrollTop;return o==="left"?{x:n,y:i+e.height/2}:o==="right"?{x:n+e.width,y:i+e.height/2}:o==="top"?{x:n+e.width/2,y:i}:{x:n+e.width/2,y:i+e.height}},_r=(e,o,s)=>s&&o==="top"?{x:e.x,y:s.top}:e,zr=(e,o)=>o==="top"?{x:e.x,y:e.y-3}:o==="left"?{x:e.x-3,y:e.y}:o==="right"?{x:e.x+3,y:e.y}:{x:e.x,y:e.y+3},Er=(e,o,s,r,n)=>{let i={straight:`M ${o.x} ${o.y} L ${s.x} ${s.y}`,turn:`M ${o.x} ${o.y} H ${s.x} V ${s.y}`,lane:`M ${o.x} ${o.y} V ${r} H ${s.x} V ${s.y}`,detour:`M ${o.x} ${o.y} H ${n} V ${s.y} H ${s.x}`}[e.route];return{...e,path:i,midX:e.route==="detour"?n:(o.x+s.x)/2,midY:e.route==="lane"?r:(o.y+s.y)/2}},Br=(e,o,s,r)=>{let[n,i]=w([]),[d,c]=w({width:"100%",height:"100%"}),[l,h]=w([]);return xe(()=>{let g=()=>{let x=o.current?.getBoundingClientRect();if(!x)return;c({width:o.current.scrollWidth,height:o.current.scrollHeight});let y=e.nodes.filter(m=>m.holds&&!m.loose&&s.current[m.id]).map(m=>{let S=s.current[m.id],k=S.getBoundingClientRect(),C=m.holds.flatMap(b=>s.current[b]?[s.current[b].getBoundingClientRect()]:[]),B=[{left:k.left,top:k.top,width:Math.max(k.width,S.scrollWidth),height:k.height},...C];return{id:m.id,bounds:Ce(B,x,o.current)}});h(y),i(e.edges.flatMap(m=>{let S=s.current[m.source]?.getBoundingClientRect(),k=s.current[m.target]?.getBoundingClientRect();if(!S||!k)return[];let C=Z(S,m.leaves,x,o.current),B=y.find(z=>z.id===m.target)?.bounds,b=zr(_r(Z(k,m.enters,x,o.current),m.enters,B),m.enters),f=(Z(S,"bottom",x,o.current).y+Z(k,"top",x,o.current).y)/2,O=m.leaves==="left"?Math.min(C.x,b.x)-28:Math.max(C.x,b.x)+28;return[Er(m,C,b,f,O)]}))};g(),window.addEventListener("resize",g);let u=new ResizeObserver(g);return o.current&&u.observe(o.current),()=>{window.removeEventListener("resize",g),u.disconnect()}},r),{links:n,extent:d,boxes:l}},wt=Br;var St=(e,o)=>{let s=new Set(o),r=e,n=2;for(;s.has(r);)r=`${e}_${n++}`;return r};var Ar=8,Dr={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},Lr={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},Or={flex:1,minHeight:0,overflow:"auto",position:"relative"},Nt={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},$r={...Nt,position:"static",alignSelf:"flex-start"},Pr={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Mr={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Ir=({port:e,onCancel:o})=>t.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Mr},"Choose the step \u201C",e||"next","\u201D should lead to \u2014 ",t.createElement("button",{onClick:o,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),jr=({base:e,token:o,initial:s})=>{let{flow:r,error:n,notice:i,warning:d,setWarning:c,send:l,pickPicture:h}=kt(e,o,s),[g,u]=w(null),[x,y]=w(null),[m,S]=w(null),[k,C]=w(null),[B,b]=w(null),[f,O]=w(!1),z=ee({}),E=ee(null);P(()=>{let a={open:null,publish:"/publish",save_draft:"/versions"},p=N=>{let D=N.target.closest?.("[data-bar-action]");if(!D||!(D.dataset.barAction in a))return;D.closest("details")?.removeAttribute("open"),u(null),O(!0);let V=a[D.dataset.barAction];V&&l(V,"POST")};return document.addEventListener("click",p),()=>document.removeEventListener("click",p)},[l]),P(()=>{if(!f){c(null);return}let a=p=>{p.target.isConnected&&!p.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&O(!1)};return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[f]),P(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),P(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let At=j(()=>Object.fromEntries(r.nodes.map(a=>[a.id,a])),[r.nodes]),{links:Dt,extent:Lt,boxes:ie}=wt(r,E,z,[r,g,At]),le=j(()=>{let a={};return r.violations.forEach(p=>{var N;return(a[N=p.node]||(a[N]=[])).push(p)}),a},[r.violations]),A=r.direction==="left_to_right",H=r.nodes.filter(a=>!a.loose),de=r.nodes.filter(a=>a.loose),Ot=Math.max(0,...H.map(a=>a.row))+1,$t=Math.max(0,...H.map(a=>a.column))+1,Q=a=>{if(!m)return;let[p,N]=m;S(null),p!==a&&l("/edges","POST",{from:p,to:a,on:N||null})},Pt=a=>{if(a.isDefaultPrevented()||!k)return;a.preventDefault();let p=k;C(null);let N=E.current.getBoundingClientRect(),D=Ne(ie,{x:a.clientX-N.left+E.current.scrollLeft,y:a.clientY-N.top+E.current.scrollTop}),V=r.nodes.find(It=>It.holds?.includes(p))?.id||null;D!==V&&l(`/steps/${p}/group`,"PATCH",{group:D})},ce=a=>[...r.palette,...r.unoffered||[]].find(p=>p.type===a?.type),I=r.nodes.find(a=>a.id===g),$=ce(I),R=(a,p={})=>l("/steps","POST",{id:St(a.type,r.nodes.map(N=>N.id)),type:a.type,from:p.from,to:p.to,on:p.on}),pe=a=>{let[p,N]=[B,k];b(null),C(null),p?R(p,{from:a.source,to:a.target}):N&&l("/steps/"+N+"/move","PATCH",{from:a.source,to:a.target})},Mt=a=>{let p=E.current.getBoundingClientRect();return{x:a.clientX-p.left+E.current.scrollLeft+8,y:a.clientY-p.top+E.current.scrollTop+8}},me=a=>t.createElement(t.Fragment,null,a.placeholder&&t.createElement(We,{node:{...a,ref:p=>{z.current[a.id]=p}},dragging:!!k,compact:A,onFill:()=>y({from:a.from,on:a.on,at:{x:16,y:52}}),onDrop:()=>{let p=k;C(null),p&&l("/edges","POST",{from:a.from,to:p,on:a.on})}}),a.holds&&t.createElement(U,{node:{...a,ref:p=>{z.current[a.id]=p}},header:G(a,ce(a),r.hide_step_type_codes),compact:A,onSelect:()=>m?Q(a.id):u(a.id)}),!a.placeholder&&!a.holds&&t.createElement(oe,{node:{...a,ref:p=>{z.current[a.id]=p},violations:le[a.id]||[],connected:r.edges.filter(p=>p.source===a.id).map(p=>p.label||null)},selected:a.id===g,armed:m&&m[0]===a.id?m[1]:null,connecting:!!m&&m[0]!==a.id,onSelect:()=>m?Q(a.id):u(a.id),onOpen:p=>window.location.assign(p),onArm:(p,N)=>{let D=E.current.getBoundingClientRect();y({from:a.id,on:p,at:{x:N.clientX-D.left+E.current.scrollLeft+8,y:N.clientY-D.top+E.current.scrollTop+8}})},onDragEnd:()=>C(null),onDragStart:()=>C(a.id),hideStepTypeCodes:r.hide_step_type_codes,compact:A,branches:A?ft(a,r.edges,H).map(p=>gt(p,r.nodes)):[]})),ue=de.length>0&&t.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:A?$r:Nt},t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:6}},"Not in the flow yet \u2014 drag one onto a connection"),de.map(a=>t.createElement("div",{key:a.id,style:{marginBottom:8}},t.createElement(oe,{node:{...a,ref:p=>{z.current[a.id]=p},violations:le[a.id]||[],connected:[]},selected:g===a.id,armed:m&&m[0]===a.id?m[1]:null,connecting:!!m,onSelect:()=>m?Q(a.id):u(a.id),onOpen:p=>window.location.assign(p),onArm:(p,N)=>{N.stopPropagation(),S([a.id,p])},onDragStart:()=>C(a.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes}))));return t.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:Dr,onMouseUp:()=>C(null),onKeyDown:a=>{a.key==="Escape"&&(u(null),S(null),y(null))},tabIndex:-1},t.createElement(Fe,{entries:r.palette,groups:r.step_groups||{},onPick:a=>R(a),onCarry:b,onDrop:()=>b(null)}),t.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:Lr},t.createElement("div",{ref:E,style:Or,onClick:a=>{a.target===E.current&&(u(null),S(null),O(!1))},onDragOver:a=>{k&&a.preventDefault()},onDrop:Pt},m&&t.createElement(Ir,{port:m[1],onCancel:()=>S(null)}),t.createElement(Ge,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>y({at:{x:16,y:52}}),onUndo:()=>{u(null),l("/undo","POST")},onRedo:()=>{u(null),l("/redo","POST")}}),!A&&ie.map(a=>t.createElement(Se,{key:a.id,id:a.id,bounds:a.bounds,onDrop:()=>{let p=k;C(null),p&&l(`/steps/${p}/group`,"PATCH",{group:a.id})}})),!A&&t.createElement(dt,{links:_e(Dt,r.nodes),extent:Lt,dragging:k||B,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:a=>y({from:a.source,to:a.target,at:{x:a.midX+30,y:a.midY}}),onRemove:a=>{u(null),l("/edges","DELETE",{from:a.source,to:a.target})},onDrop:pe}),!A&&ue,A&&t.createElement(K,{nodes:H,edges:r.edges,draw:me,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(k||B),onInsert:(a,p)=>y({from:a.source,to:a.target,at:Mt(p)}),onRemove:a=>{u(null),l("/edges","DELETE",{from:a.source,to:a.target})},onDrop:pe}},ue),!A&&t.createElement("div",{style:{...Pr,gridTemplateColumns:`repeat(${$t+1}, ${280/2}px)`,gridTemplateRows:`repeat(${Ot}, auto)`}},H.map(a=>t.createElement("div",{key:a.id,style:{gridRow:a.row+1,gridColumn:`${a.column+1} / span 2`,zIndex:2,marginTop:ze(a,r.nodes)?Ar-64:0}},me(a)))),x&&t.createElement(Ve,{entries:r.palette,at:x.at,onDismiss:()=>y(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:x.on!==void 0?()=>{S([x.from,x.on]),y(null)}:null,onPick:a=>{let p=x;y(null),R(a,p)}})),t.createElement(nt,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:u})),f&&!I&&t.createElement(Qe,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:i,publishNote:r.publish_note,warning:d,onClose:()=>O(!1),onCreate:()=>l("/versions","POST"),onPublish:()=>l("/publish","POST"),onAccept:()=>l(d.path,"POST",{remove_unconnected:d.steps.map(a=>a.id)}),onDecline:()=>c(null),onSaveDetails:a=>l("/details","PATCH",{flow:a})}),I&&t.createElement(He,{node:I,fields:$?.fields||{},holds:$?.records||{},labels:$?.labels||{},explanations:$?.explanations||{},recordLabels:$?.record_labels||{},recordExplanations:$?.record_explanations||{},recordChoices:$?.record_choices||{},recordOutputsOf:$?.record_outputs_of||{},choices:Ee(I,$),onClose:()=>u(null),onSave:a=>l(`/steps/${I.id}`,"PATCH",{config:a}),onPickPicture:h,refusal:n,onDelete:()=>{u(null),l(`/steps/${I.id}`,"DELETE")}}))},_t=jr;var Hr={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Wr={fontSize:12,fontWeight:500,lineHeight:1.3},zt={done:"border-green-600 bg-green-50 dark:border-green-500 dark:bg-green-950",paused:"border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-950",pending:"border-gray-300 bg-white text-gray-500 dark:border-zinc-700 dark:bg-zinc-900 dark:text-gray-400",failed:"border-red-600 bg-red-50 dark:border-red-500 dark:bg-red-950"},Et={done:"text-green-700 dark:text-green-400",paused:"text-amber-800 dark:text-amber-300",pending:"text-gray-500 dark:text-gray-400",failed:"text-red-700 dark:text-red-400"},Vr="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Fr=({node:e,selected:o=!1})=>{let s=e.address?"a":"div";return t.createElement(s,{"data-step":e.id,href:e.address||void 0,className:`${e.state==="paused"?"border-2":"border"} ${zt[e.state]||zt.pending}${o?` ${Vr}`:""}`,style:Hr},t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.type),t.createElement("div",{style:Wr},e.label,e.version&&t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},e.version)),e.status&&t.createElement("div",{className:Et[e.state]||Et.pending,style:{fontSize:11}},e.status))},Bt=Fr;var Ur={gap:12,padding:0},Gr=({nodes:e,edges:o,selected:s})=>t.createElement(K,{nodes:e,edges:o,joints:{},style:Ur,draw:r=>r.holds?t.createElement(U,{node:r,header:G(r,r,!1),compact:!0}):t.createElement(Bt,{node:r,selected:r.id===s})}),Tt=Gr;te("easy_flow/flow-editor",_t);te("easy_flow/run-view",Tt);document.addEventListener("easy_flow:flow-named",e=>{let o=document.querySelector("[data-flow-heading]");o&&(o.textContent=e.detail)});document.addEventListener("easy_flow:flow-status",({detail:e})=>{e.status&&document.querySelectorAll("[data-version-status]").forEach(o=>{o.textContent=e.status}),e.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(o=>{o.textContent=`Publish v${e.publishes}`})});ve(document,fe);})();
|
|
1
|
+
(()=>{var Yt=globalThis.ReactDOM;var{createPortal:es,createRoot:ge,flushSync:ts,hydrateRoot:os,preconnect:rs,prefetchDNS:ss,preinit:ns,preinitModule:as,preload:is,preloadModule:ls,requestFormReset:ds,unstable_batchedUpdates:cs,useFormState:ps,useFormStatus:ms,version:us}=Yt;var xe=globalThis.React,t=xe,{Children:gs,Component:xs,Fragment:hs,PureComponent:ys,StrictMode:bs,Suspense:vs,cloneElement:ks,createContext:ws,createElement:Ss,createRef:Cs,forwardRef:Ns,isValidElement:_s,lazy:zs,memo:Es,startTransition:Bs,useCallback:Ts,useContext:As,useDebugValue:Ds,useDeferredValue:Ls,useEffect:M,useId:Os,useImperativeHandle:$s,useLayoutEffect:he,useMemo:$,useReducer:Ps,useRef:Z,useState:S,useSyncExternalStore:Ms,useTransition:Is}=xe;var ye=new Map,W=new Map,Q=(e,o)=>ye.set(e,o),be=()=>{W.forEach(e=>e.unmount()),W.clear()},ve=(e,o)=>e.querySelectorAll("[data-react-ui]").forEach(s=>{if(W.has(s))return;let r=ye.get(s.dataset.reactUi),n=o(s);W.set(s,n),n.render(t.createElement(r,JSON.parse(s.dataset.props)))});var ke=(e,o)=>{let s=()=>ve(e,o);e.addEventListener("turbo:load",s),e.addEventListener("turbo:frame-load",s),e.addEventListener("turbo:before-cache",be),e.readyState==="loading"?e.addEventListener("DOMContentLoaded",s):s()};var k=(...e)=>e.filter(Boolean).join(" ");var Xt={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},qt={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Jt=({variant:e="primary",size:o="md",className:s,children:r,...n})=>{let i=n.href?"a":"button";return t.createElement(i,{...n,className:k("ks-button",Xt[e],qt[o],s)},r)},b=Jt;var Kt="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Zt="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Qt="border border-accent-600 bg-accent-600 text-white",Rt=({name:e,connected:o,armed:s,onArm:r,connecting:n})=>t.createElement("button",{onClick:i=>{n||(i.stopPropagation(),r(i))},title:s?"Now choose a step to connect to":"Connect this branch",className:s?Qt:o?Zt:Kt,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},e||"next"),we=Rt;var eo={width:240,boxSizing:"border-box",borderRadius:8},to={minWidth:120,boxSizing:"border-box",borderRadius:6},oo={padding:"8px 14px",textAlign:"center",fontWeight:600},ro={fontWeight:600,lineHeight:1.3},so={fontSize:12,fontWeight:500,lineHeight:1.3},no=(e,o,s)=>{let r=s?"ring-4 ring-accent-600/15":"shadow-sm";return e||s&&!o?`border-accent-600 ${r}`:o?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},ao=(e,o)=>o&&e.label===e.id&&e.type_name||e.label,io=(e,o,s)=>s?o===e.type_name?null:e.type_name:e.type,lo=({node:e,selected:o,armed:s,connecting:r,onSelect:n,onOpen:i,onArm:l,onDragEnd:d,onDragStart:c,hideStepTypeCodes:x,branches:h=[],compact:f=!1,typeAbove:u=f})=>{let y=e.begins_here||e.ends_here,m=e.begins_here,C=e.ends_here?[]:e.ports,w=r&&!m,_=ao(e,x),E=io(e,_,x);return t.createElement("div",{ref:e.ref,"data-step":e.id,draggable:!m,onDragStart:v=>{v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("text/plain",e.id),c()},onDragEnd:d,onClick:e.opens&&!r?()=>i(e.opens):n,className:`bg-white ${f&&!o?"border":"border-2"} dark:bg-zinc-900 ${no(w,e.violations.length>0,o)}`,style:{...f?to:eo,padding:y?0:f?"8px 10px":"12px 14px",cursor:m?"default":r?"crosshair":"grab"}},!y&&u&&E&&t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},E),y&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:oo},_),!y&&t.createElement("div",{style:f?so:ro},_),e.violations.length>0&&t.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${e.violations.length} error${e.violations.length===1?"":"s"}`),!y&&e.summary&&e.violations.length===0&&t.createElement("div",{className:o?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},e.summary),!y&&!u&&E&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},E),e.picture_url&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),e.starts_a_flow&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),e.opens&&t.createElement(b,{variant:"secondary",size:"sm",className:"mt-2",onClick:v=>{v.stopPropagation(),n()}},"Settings"),h.map(v=>t.createElement("div",{key:v,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},v)),C.length>0&&t.createElement("div",{style:{padding:e.begins_here?"0 14px 8px":"10px 0 0"}},C.map(v=>t.createElement(we,{key:v,name:v,connected:e.connected.includes(v),connecting:r,armed:s===v,onArm:g=>l(v,g)}))))},R=lo;var Se={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},co={...Se,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},po=({node:e,header:o,onSelect:s,compact:r=!1})=>t.createElement("div",{ref:e.ref,"data-group-header":e.id,onClick:s,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?co:Se,...s?{}:{cursor:"default"}}},o),V=po;var mo=({id:e,bounds:o,onDrop:s})=>t.createElement("div",{"data-group-box":e,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),s()},className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",zIndex:1,borderRadius:8,boxSizing:"border-box",...o}}),Ce=mo;var uo=e=>e!=null&&e!==""&&typeof e!="object",fo=["integer","float"],go=(e,o,s)=>s&&o.labels?.[e]||e,F=(e,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>uo(e.config[n])).map(n=>`${go(n,o,s)}${fo.includes(o.fields[n])?"":":"} ${e.config[n]}`);return[s&&e.type_name||e.type,...r].join(" \xB7 ")};var Ne=(e,o,s)=>{let r=Math.min(...e.map(d=>d.left))-o.left+s.scrollLeft-12,n=Math.min(...e.map(d=>d.top))-o.top+s.scrollTop-10,i=Math.max(...e.map(d=>d.left+d.width))-o.left+s.scrollLeft+12,l=Math.max(...e.map(d=>d.top+d.height))-o.top+s.scrollTop+10;return{left:r,top:n,width:i-r,height:l-n}},xo=({left:e,top:o,width:s,height:r},n)=>n.x>=e&&n.x<=e+s&&n.y>=o&&n.y<=o+r,_e=(e,o)=>e.find(s=>xo(s.bounds,o))?.id||null,ze=(e,o)=>e.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),Ee=(e,o)=>o.some(s=>s.holds?.includes(e.id)&&!s.loose&&s.row===e.row-1);var ee=(e,o)=>e.includes(o)?e.filter(s=>s!==o):[...e,o],Be=(e,o)=>({...o?.choices||{},...e?.choices||{}});var ho=({as:e="input",disabled:o,className:s,...r})=>t.createElement(e,{...r,disabled:o,className:k("ks-input",o&&"ks-input-disabled",s)}),D=ho;var yo=e=>t.createElement(D,{...e,as:"select"}),Te=yo;var bo=({className:e,...o})=>t.createElement("input",{type:"checkbox",...o,className:k("ks-checkbox",e)}),U=bo;var vo=({name:e,value:o,label:s,hint:r,className:n,...i})=>t.createElement("label",{className:"inline-block cursor-pointer relative"},t.createElement("input",{type:"radio",name:e,value:o,...i,className:k("peer sr-only",n)}),t.createElement("span",{className:"ks-radio-card inline-flex flex-col cursor-pointer transition ks-radio-card-highlight"},t.createElement("span",{className:"ks-radio-card-header flex items-start justify-between"},t.createElement("span",{className:"ks-radio-card-label block"},s)),r!=null&&t.createElement("span",{className:"ks-radio-card-hint block text-sm"},r))),Ae=vo;var ko=({name:e,options:o,value:s,onChange:r,className:n})=>t.createElement("div",{className:k("flex flex-wrap ks-grid-gap-sm",n)},o.map(i=>t.createElement(Ae,{key:i.value,name:e,...i,checked:i.value===s,onChange:()=>r(i.value)}))),De=ko;var Le=e=>(e||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),wo=({name:e,type:o,value:s,choices:r,onChange:n,onSettle:i,onPick:l,pictureUrl:d})=>{if(o==="picture")return t.createElement("div",{className:"mb-3"},s&&d&&t.createElement("img",{src:d,alt:"The step's picture",style:{maxWidth:"100%"}}),s&&t.createElement(b,{type:"button",variant:"secondary",size:"sm","data-remove-picture":!0,onClick:()=>i("")},"Remove picture"),t.createElement("input",{type:"file",accept:"image/*",onChange:c=>c.target.files[0]&&l(c.target.files[0])}));if(o==="boolean")return t.createElement(U,{checked:!!s,onChange:c=>i(c.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return t.createElement(Te,{className:"mb-3",value:s??"",onChange:c=>i(c.target.value)},t.createElement("option",{value:""}),Le(r).map(c=>t.createElement("option",{key:c.value,value:c.value},c.label)));if(o==="radio_cards")return t.createElement("div",{"data-radio-cards":!0,className:"mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full"},t.createElement(De,{name:e,value:s,options:r||[],onChange:i}));if(o==="multi_select"){let c=Array.isArray(s)?s:[],x=h=>i(ee(c,h));return t.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(r||[]).map(h=>t.createElement("label",{key:h,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(U,{checked:c.includes(h),onChange:()=>x(h)}),t.createElement("span",null,h))))}if(o==="flows"){let c=Array.isArray(s)?s:[];return t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},Le(r).map(x=>t.createElement("label",{key:x.value,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(U,{checked:c.includes(x.value),onChange:()=>i(ee(c,x.value))}),t.createElement("span",null,x.label))))}return o==="integer"||o==="float"?t.createElement(D,{className:"mb-3",type:"number",step:o==="integer"?"1":"any",value:s??"",onChange:c=>n(c.target.value),onBlur:c=>i(c.target.value)}):t.createElement(D,{className:"mb-3",type:"text",value:s??"",onChange:c=>n(c.target.value),onBlur:c=>i(c.target.value)})},G=wo;var Oe=(e,o,s,r)=>e.map((n,i)=>i===o?{...n,[s]:r}:n);var So=({text:e})=>t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},e),Y=So;var Co=(e,o,s,r)=>{let n=(e||{})[s],i=(o||{})[s];return i?(n||{})[r[i]]:n},No=({holds:e,labels:o,explanations:s,rows:r,choices:n,outputsOf:i,onChange:l,onSettle:d})=>{let c=Array.isArray(r)?r:[],x=(h,f,u,y)=>{let m=Oe(c,h,f,u);y?d(m):l(m)};return t.createElement("div",{style:{marginBottom:12}},c.map((h,f)=>t.createElement("div",{key:f,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(e).map(([u,y])=>t.createElement("label",{key:u,style:{display:"block"}},t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[u]||u),t.createElement(G,{type:y,value:h[u],choices:Co(n,i,u,h),onChange:m=>x(f,u,m,!1),onSettle:m=>x(f,u,m,!0)}),(s||{})[u]&&t.createElement(Y,{text:s[u]}))),t.createElement(b,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>d(c.filter((u,y)=>y!==f))},"Remove"))),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>d([...c,{}])},"Add"))},$e=No;var _o={start:null,end:"ks-value-list-end"},zo="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",Eo="flex flex-col min-w-0",Bo="ks-value-list-label basis-auto text-xs",To=()=>t.createElement("svg",{"aria-label":"Right",role:"img",className:"ks-tone-success inline size-5 align-text-bottom",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},t.createElement("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z",clipRule:"evenodd"})),Ao=({value:e,fallback:o})=>String(e??"")===""?o:e,Do=({rows:e,align:o="start",columns:s=!1,className:r})=>t.createElement("dl",{className:k("ks-value-list",_o[o],s&&zo,r)},e.map((n,i)=>t.createElement("div",{key:i,className:k(s?Eo:"ks-value-list-row",n.total&&"ks-value-list-total")},t.createElement("dt",{className:s?Bo:"ks-value-list-label"},n.label,n.note!=null&&t.createElement(t.Fragment,null," ",t.createElement("span",{className:"ks-value-list-note"},n.note))),t.createElement("dd",{className:"ks-value-list-value"},Ao(n),n.right&&t.createElement(t.Fragment,null," ",t.createElement(To,null)))))),Pe=Do;var Lo=()=>t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})),Oo=({summary:e,open:o=!1,className:s,children:r})=>t.createElement("details",{className:k("ks-disclosure group",s),open:o},t.createElement("summary",{className:"ks-disclosure-summary flex cursor-pointer list-none items-center justify-between [&::-webkit-details-marker]:hidden"},t.createElement("span",null,e),t.createElement("span",{className:"ks-disclosure-icon h-4 w-4 shrink-0 transition-transform group-open:rotate-180"},t.createElement(Lo,null))),t.createElement("div",{className:"ks-disclosure-body text-sm"},r)),Me=Oo;var $o=({language:e,caption:o,className:s,children:r})=>t.createElement("div",{className:k("ks-code overflow-hidden",s)},o!=null&&t.createElement("div",{className:"ks-code-caption font-mono text-xs"},o),t.createElement("pre",{className:"ks-code-block overflow-x-auto font-mono text-sm leading-relaxed"},t.createElement("code",{className:e==null?"":`language-${e}`},r))),Ie=$o;var te="flex flex-col gap-1 mb-3",je="[&_dd]:font-mono",Po="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",Mo="[&_.ks-value-list]:font-mono [&_.ks-value-list]:flex [&_.ks-value-list]:flex-col [&_.ks-value-list]:gap-1 [&_.ks-value-list-row]:gap-2 [&_.ks-value-list-row]:py-0 [&_.ks-value-list-row]:border-0 [&_.ks-value-list-label]:basis-[90px]",Io="border-t border-gray-200 pt-2.5 dark:border-zinc-700 [&_.ks-disclosure]:border-0 [&_.ks-disclosure-summary]:flex-row-reverse [&_.ks-disclosure-summary]:justify-end [&_.ks-disclosure-summary]:gap-1 [&_.ks-disclosure-summary]:p-0 [&_.ks-disclosure-summary]:font-normal [&_.ks-disclosure-body]:p-0 [&_.ks-disclosure-body]:pt-1.5 [&_.ks-code-block]:p-2 [&_.ks-code-block]:text-[11px]",jo=e=>e.values?e.columns?`${te} ${je} ${Po}`:`${te} ${je} ${Mo}`:`${te} ${Io}`,Ho=({details:e})=>t.createElement(t.Fragment,null,e.map((o,s)=>t.createElement("section",{key:s,className:jo(o)},o.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400"},o.heading),o.values&&t.createElement(Pe,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>t.createElement(Me,{key:r.summary,summary:r.summary},t.createElement(Ie,null,r.code)))))),He=Ho;var Wo=({as:e="div",className:o,children:s,...r})=>t.createElement(e,{...r,className:k("ks-panel",o)},s),A=Wo;var X=(e,o)=>({className:s,children:r,...n})=>t.createElement(e,{...n,className:k(o,s)},r),H=X("label","ks-label"),la=X("p","ks-hint"),da=X("p","ks-error"),ca=X("span","ks-required");var Vo={width:320,padding:"14px 16px",overflowY:"auto",display:"flex",flexDirection:"column",fontSize:12},Fo={marginTop:"auto",paddingTop:12,display:"flex",flexDirection:"column",gap:8},Uo=({node:e,fields:o,holds:s,labels:r,explanations:n,recordLabels:i,recordExplanations:l,recordChoices:d,recordOutputsOf:c,choices:x,onSave:h,onDelete:f,onClose:u,onPickPicture:y,refusal:m})=>{let[C,w]=S(e.config),[_,E]=S(e.picture_url);M(()=>E(e.picture_url),[e.id,e.picture_url]),M(()=>w(e.config),[e.id,e.config]);let v=g=>{w(g),JSON.stringify(g)!==JSON.stringify(e.config)&&h(g)};return t.createElement(A,{as:"aside",style:Vo,className:"max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto","data-inspector":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8,marginBottom:12}},t.createElement("div",null,t.createElement("p",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.id," \xB7 ",e.type),t.createElement("h2",{style:{fontSize:15,fontWeight:600}},e.label)),t.createElement("button",{title:"Close",onClick:u,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),m&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},m),Object.entries(o).map(([g,L])=>t.createElement(H,{key:g},t.createElement("span",{style:{display:"block",marginBottom:3}},r[g]||g),L==="list"?t.createElement($e,{holds:s[g]||{},labels:i[g]||{},explanations:(l||{})[g],rows:C[g],choices:{...(d||{})[g],...(e.record_choices||{})[g]},outputsOf:(c||{})[g],onChange:z=>w({...C,[g]:z}),onSettle:z=>v({...C,[g]:z})}):t.createElement(G,{name:g,type:L,value:C[g],choices:x[g],pictureUrl:_,onChange:z=>w({...C,[g]:z}),onSettle:z=>v({...C,[g]:z}),onPick:async z=>{let B=await y(z);B&&(E(B.url),v({...C,[g]:B.reference}))}}),(n||{})[g]&&t.createElement(Y,{text:n[g]}))),t.createElement(He,{details:e.details||[]}),t.createElement("div",{style:Fo},(e.links||[]).length>0&&t.createElement("div",{style:{display:"flex",gap:8}},e.links.map(g=>t.createElement(b,{key:g.address,variant:"secondary",size:"sm",className:"flex-1",href:g.address},g.label))),t.createElement(b,{variant:"danger",size:"sm",className:"w-full",onClick:f},"Delete step")))},We=Uo;var Go={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},Yo={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},Xo="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",qo="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Jo=({node:e,dragging:o,onFill:s,onDrop:r,compact:n=!1})=>t.createElement("div",{ref:e.ref,"data-placeholder":e.id,title:`Choose the step \u201C${e.label}\u201D should lead to`,onClick:s,onDragOver:i=>{o&&(i.preventDefault(),i.dataTransfer.dropEffect="move")},onDrop:i=>{i.preventDefault(),r()},className:o?qo:Xo,style:n?Yo:Go},t.createElement("div",{style:{fontWeight:600}},e.label),t.createElement("div",{style:{fontSize:11}},o?"drop a step here":"leads nowhere yet \u2014 click to choose")),Ve=Jo;var Ko=({entries:e,at:o,onPick:s,onConnect:r,onDismiss:n,hideStepTypeCodes:i})=>t.createElement(A,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:o.y,left:o.x,width:210,padding:8,borderRadius:8}},t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),e.map(l=>t.createElement(b,{key:l.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>s(l)},l.label,!i&&t.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},l.type))),r&&t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full",onClick:n},"Cancel")),Fe=Ko;var Zo=e=>o=>o.label.toLowerCase().includes(e.trim().toLowerCase()),Qo=(e,o,s="")=>{let r=Object.values(o).flat(),n=Object.entries(o).map(([i,l])=>({heading:i,entries:l.map(d=>e.find(c=>c.type===d)).filter(Boolean)}));return[{heading:null,entries:e.filter(i=>!r.includes(i.type))},...n].map(i=>({...i,entries:i.entries.filter(Zo(s))})).filter(i=>i.entries.length>0)},Ro={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},er={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},tr={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},or=({entries:e,groups:o,onPick:s,onCarry:r,onDrop:n})=>{let[i,l]=S("");return t.createElement(A,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:Ro},t.createElement(D,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:i,onChange:d=>l(d.target.value),style:{marginBottom:6,fontSize:12}}),Qo(e,o,i).map(d=>t.createElement(t.Fragment,{key:d.heading||""},d.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:er},d.heading),d.entries.map(c=>t.createElement(A,{as:"button",type:"button",key:c.type,"data-step-type":c.type,className:"bg-surface-50 dark:bg-surface-950",style:tr,draggable:!0,onClick:()=>s(c),onDragStart:x=>{x.dataTransfer.effectAllowed="copyMove",x.dataTransfer.setData("text/plain",c.type),r(c)},onDragEnd:n},c.label)))))},Ue=or;var rr={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Ge=({label:e,title:o,idle:s,enabled:r,onUse:n})=>t.createElement(b,{variant:"secondary",size:"sm",title:r?o:s,disabled:!r,onClick:n,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},e),sr=({undoable:e,redoable:o,onAdd:s,onUndo:r,onRedo:n})=>t.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},t.createElement(b,{variant:"secondary",className:"rounded-full",style:rr,title:"Add a step",onClick:s},"+"),t.createElement(Ge,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:e,onUse:r}),t.createElement(Ge,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),Ye=sr;var nr=({type:e="info",title:o,message:s,onDismiss:r,className:n})=>t.createElement("div",{className:k("ks-alert",`ks-alert-${e}`,n),role:"alert"},t.createElement("div",{className:"ks-alert-body"},t.createElement("div",{className:"ks-alert-content"},o&&t.createElement("p",{className:"ks-alert-title"},o),t.createElement("p",{className:o?"ks-alert-message-titled":"ks-alert-message"},s)),r&&t.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),Xe=nr;var qe=e=>{let o=e.map(s=>`\u201C${s.name}\u201D`).join(", ");return e.length===1?`${o} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${o} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var Je=({version:e,published:o})=>e?o?o===e?`Version ${e} \xB7 live`:`Version ${e} \xB7 visitors still on ${o}`:`Version ${e} \xB7 never published`:"No version yet";var ar={width:280,padding:20,overflowY:"auto"},Ke={fontWeight:600,marginBottom:6,marginTop:14},oe={fontSize:12,marginBottom:4,lineHeight:1.4},Ze={display:"block",marginBottom:3},Qe=(e,o,s)=>r=>{r.target.value!==(e[o]??"")&&s({[o]:r.target.value})},ir=({flow:e,changes:o,refusal:s,notice:r,publishNote:n,warning:i,onCreate:l,onPublish:d,onAccept:c,onDecline:x,onSaveDetails:h,onClose:f})=>t.createElement(A,{as:"aside",style:ar,"data-builder-panel":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},t.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},e.title||e.slug),t.createElement("button",{title:"Close",onClick:f,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),t.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:e.history_url,"data-history":!0},Je(e)),i?t.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},t.createElement(Xe,{type:"warning",className:"mb-1.5",message:qe(i.steps)}),t.createElement(b,{size:"sm",className:"w-full mb-1.5",onClick:c,"data-accept-removal":!0},i.path==="/publish"?"Remove and publish":"Remove and create version"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:x,"data-decline-removal":!0},"Cancel")):t.createElement("div",{style:{marginTop:14}},t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:l,"data-create-version":!0},"Create version"),t.createElement(b,{size:"sm",className:"w-full mb-1.5",onClick:d,"data-publish":!0},"Publish"),n&&t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},n)),s&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...oe,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&t.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...oe,fontWeight:600,marginTop:8},"data-notice":!0},r),t.createElement("h2",{style:Ke},"Changes since the last version"),o.length===0?t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):o.map((u,y)=>t.createElement("p",{key:y,style:oe,"data-change":!0},u)),t.createElement("h2",{style:Ke},"Details"),t.createElement(H,null,t.createElement("span",{style:Ze},"Title"),t.createElement(D,{className:"mb-3",defaultValue:e.title??"",onBlur:Qe(e,"title",h),"data-flow-title":!0})),t.createElement(H,null,t.createElement("span",{style:Ze},"Start label"),t.createElement(D,{className:"mb-3",defaultValue:e.start_label??"",onBlur:Qe(e,"start_label",h),"data-flow-start-label":!0})),t.createElement("div",{style:{marginTop:16}},t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.definition_url,"data-definition":!0},"Definition"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.details_url,"data-details":!0},"Edit details"))),Re=ir;var lr=({variant:e="neutral",className:o,children:s,...r})=>t.createElement("span",{...r,className:k("ks-badge",`ks-badge-${e}`,o)},s),et=lr;var dr={center:"ks-tab-bar flex flex-wrap justify-center max-sm:flex-nowrap max-sm:overflow-x-auto max-sm:justify-start",start:"ks-tab-bar flex flex-wrap justify-start max-sm:flex-nowrap max-sm:overflow-x-auto"},cr={pills:"ks-tab-bar-pills",underline:"ks-tab-bar-underline"},pr="ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",mr="ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",ur=({shape:e,count:o})=>e?t.createElement("span",{className:"ks-tab-count"},o):t.createElement(et,{variant:"info"},o),fr=e=>typeof e=="string"?e!=="":e>0,gr=({tabs:e,value:o,onChange:s,align:r="center",shape:n,className:i})=>t.createElement("div",{className:i},t.createElement("div",{className:k(dr[r],cr[n])},e.map(l=>t.createElement("button",{key:l.value,type:"button",className:n?mr:pr,"data-active":l.value===o?"":void 0,onClick:()=>s(l.value)},l.label,fr(l.count)&&t.createElement(t.Fragment,null," ",t.createElement(ur,{shape:n,count:l.count}))))),e.find(l=>l.value===o)?.content),tt=gr;var xr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},ot="mx-6 mb-6 flex max-h-[45%] flex-none flex-col overflow-y-auto rounded-lg max-sm:m-0 max-sm:max-h-none max-sm:rounded-none [&_.ks-tab-bar]:mb-0 [&_.ks-tab-bar]:px-2",hr="max-sm:absolute max-sm:inset-0 max-sm:z-20",nt={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},rt={display:"flex",gap:8,textAlign:"left"},st={flexShrink:0,whiteSpace:"nowrap"},yr=({check:e,onSelect:o})=>{let s=t.createElement(t.Fragment,null,t.createElement("span",{className:xr[e.level],style:{...st,fontWeight:500}},e.level),e.node&&t.createElement("span",{className:"font-mono",style:st},e.node),t.createElement("span",null,e.sentence));return e.node?t.createElement("button",{type:"button","data-check-row":!0,"data-step-id":e.node,style:{...rt,border:"none",background:"none",padding:0,cursor:"pointer",font:"inherit",color:"inherit"},onClick:()=>o(e.node)},s):t.createElement("div",{"data-check-row":!0,style:rt},s)},br=({checks:e,onSelect:o})=>t.createElement("div",{style:nt},e.map((s,r)=>t.createElement(yr,{key:r,check:s,onSelect:o}))),vr=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,kr=({checks:e,tabs:o,onSelect:s,opened:r=vr()?null:"validation"})=>{let[n,i]=S(r);return t.createElement(A,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${ot} ${hr}`:ot},t.createElement(tt,{align:"start",shape:"underline",value:n,onChange:l=>i(l===n?null:l),tabs:[{value:"validation",label:"Validation",count:e.filter(l=>l.level==="error").length,content:t.createElement(br,{checks:e,onSelect:s})},...o.map(l=>({value:l.label,label:l.label,count:l.count??"",content:t.createElement("div",{"data-drawer-content":!0,style:nt,dangerouslySetInnerHTML:{__html:l.content}})}))]}))},at=kr;var it={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},lt=e=>({opacity:e?1:0,transition:"opacity .12s"}),wr=({link:e,onInsert:o,onRemove:s,onDrop:r,dragging:n,alwaysShowInsertButtons:i})=>{let[l,d]=S(!1),c=l||n;return t.createElement("div",{"data-connector":`${e.source}-${e.target}`,style:{position:"absolute",left:e.midX-34,top:e.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onDragEnter:()=>d(!0),onDragLeave:()=>d(!1),onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},onDrop:x=>{x.preventDefault(),d(!1),r()}},t.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},t.createElement(b,{variant:"secondary",title:n?"Move the step here":"Insert a step here",onClick:o,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(n&&l),style:{...it,...lt(c||i)}},"+"),!n&&t.createElement(b,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...it,...lt(c)}},"\xD7")))},dt=wr;var Sr=({links:e,extent:o,dragging:s,onInsert:r,onRemove:n,onDrop:i,alwaysShowInsertButtons:l})=>t.createElement(t.Fragment,null,t.createElement("svg",{width:o.width,height:o.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},t.createElement("defs",null,t.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},t.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),e.map(d=>t.createElement("path",{key:d.id,"data-link":d.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:d.path}))),e.filter(d=>d.label).map(d=>t.createElement("div",{key:`${d.id}-label`,"data-link-label":d.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:d.midX+(l?2:-10),top:d.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},d.label)),e.filter(d=>!d.placeholder).map(d=>t.createElement(dt,{key:d.id,link:d,dragging:!!s,alwaysShowInsertButtons:l,onInsert:()=>r(d),onRemove:()=>n(d),onDrop:()=>i(d)}))),ct=Sr;var re={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},pt="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Cr=({link:e,onInsert:o,onRemove:s,onDrop:r,alwaysShowInsertButtons:n,dragging:i})=>t.createElement("div",{"data-joint":e?.id,className:"group relative h-7 w-full sm:h-auto sm:w-7 sm:self-stretch",onMouseEnter:l=>{l.currentTarget.dataset.over="true"},onMouseLeave:l=>{delete l.currentTarget.dataset.over},onDragOver:l=>{e&&r&&(l.preventDefault(),l.dataTransfer.dropEffect="move")},onDrop:l=>{e&&(l.preventDefault(),r(e))}},e&&t.createElement("div",{className:"absolute left-1/2 top-0 h-full w-px bg-gray-400 sm:left-0 sm:top-1/2 sm:h-px sm:w-full dark:bg-zinc-500"}),e&&o&&t.createElement("div",{className:"absolute inset-0 flex items-center justify-center gap-1 sm:flex-col",style:{zIndex:4}},t.createElement(b,{variant:"secondary",title:"Insert a step here",onClick:l=>o(e,l),className:`rounded-full ${n?"opacity-100":pt}`,style:i?{...re,opacity:1}:re},"+"),t.createElement(b,{variant:"danger",title:"Remove this connection",onClick:()=>s(e),className:`rounded-full ${pt}`,style:re},"\xD7"))),mt=Cr;var Nr=(e,o)=>e.row-o.row||e.column-o.column,ut=e=>new Map(e.flatMap(o=>(o.holds||[]).map(s=>[s,o.id]))),ft=e=>{let o=[...e].sort(Nr),s=ut(e),r=new Map(e.filter(n=>n.holds).map(n=>[n.id,[]]));return o.filter(n=>s.has(n.id)).forEach(n=>r.get(s.get(n.id)).push(n)),o.filter(n=>!s.has(n.id)).flatMap(n=>[n,...r.get(n.id)||[]])},gt=e=>{let o=ut(e),s=ft(e),r=[],n=new Map;return s.filter(i=>!o.has(i.id)).forEach(i=>{let l=r[r.length-1];i.holds?n.set(i.id,r[r.push({group:i,steps:[]})-1]):l&&!l.group?l.steps.push(i):r.push({steps:[i]})}),s.filter(i=>o.has(i.id)).forEach(i=>n.get(o.get(i.id))?.steps.push(i)),r},_r=e=>e?.placeholder?"nowhere yet":e?.label,se=new WeakMap,zr=e=>(se.has(e)||se.set(e,new Map([...e].reverse().map(o=>[`${o.source}
|
|
2
|
+
${o.target}`,o]))),se.get(e)),xt=(e,o,s)=>zr(e).get(`${o.id}
|
|
3
|
+
${s.id}`),ht=(e,o,s)=>{let r=ft(e),n=new Map(r.map((d,c)=>[d.id,r[c+1]?.id])),i=new Map(s.map(d=>[d.id,_r(d)])),l=Object.fromEntries(e.map(d=>[d.id,[]]));return o.filter(d=>l[d.source]&&(d.label||d.target!==n.get(d.source))).forEach(d=>l[d.source].push([d.label,"\u2192",i.get(d.target)].filter(Boolean).join(" "))),l};var Er={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},yt=({steps:e,edges:o,draw:s,joints:r})=>t.createElement("div",{"data-flow-row":!0,className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5"},e.map((n,i)=>t.createElement("div",{key:n.id,className:"flex flex-col sm:flex-row sm:items-center"},i>0&&t.createElement(mt,{link:xt(o,e[i-1],n),...r}),s(n)))),Br={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},Tr=({group:e,steps:o,edges:s,draw:r,joints:n})=>t.createElement("div",{"data-group-box":e.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:Br},r(e),t.createElement(yt,{steps:o,edges:s,draw:r,joints:n})),Ar=({nodes:e,edges:o,draw:s,joints:r,children:n,style:i})=>t.createElement("div",{"data-flow-rows":!0,style:{...Er,...i}},n,gt(e).map(l=>l.group?t.createElement(Tr,{key:l.group.id,group:l.group,steps:l.steps,edges:o,draw:s,joints:r}):t.createElement(yt,{key:l.steps[0].id,steps:l.steps,edges:o,draw:s,joints:r}))),q=Ar;var vt="Your change was not saved because the server could not be reached.",Dr="Your change was saved, but the canvas could not be refreshed. Reload the page to see it.",bt=async({base:e,fetch:o,onFlow:s,onError:r})=>{let n=await o(e+".json",{headers:{Accept:"application/json"}}).catch(()=>null),i=n?.ok?await n.json().catch(()=>null):null;return i?s(i):r(Dr)},kt=({base:e,token:o,fetch:s,onFlow:r,onError:n,onNotice:i,onWarning:l=()=>{}})=>async(d,c,x)=>{let h={base:e,fetch:s,onFlow:r,onError:n},f=await s(e+d,{method:c,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:x&&JSON.stringify(x)}).catch(()=>null);if(!f)return i(null),n(vt);let u=await f.json().catch(()=>({}));return u.unconnected?(i(null),n(null),l({path:d,steps:u.unconnected}),bt(h)):(l(null),f.ok?(n(null),i(u.notice||null),bt(h)):(i(null),n(u.error||"That change was refused")))},wt=({base:e,token:o,fetch:s,onError:r})=>async n=>{let i=new FormData;i.append("picture",n);let l=await s(e+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:i}).catch(()=>null);if(!l)return r(vt),null;let d=await l.json().catch(()=>({}));return l.ok?(r(null),d):(r(d.error||"That picture was refused"),null)};var Lr=(e,o,s)=>{let[r,n]=S(s),[i,l]=S(null),[d,c]=S(null),[x,h]=S(null),f=$(()=>kt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onFlow:n,onError:l,onNotice:c,onWarning:h}),[e,o]),u=$(()=>wt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onError:l}),[e,o]);return{flow:r,error:i,notice:d,warning:x,setWarning:h,send:f,pickPicture:u}},St=Lr;var J=(e,o,s,r)=>{let n=e.left-s.left+r.scrollLeft,i=e.top-s.top+r.scrollTop;return o==="left"?{x:n,y:i+e.height/2}:o==="right"?{x:n+e.width,y:i+e.height/2}:o==="top"?{x:n+e.width/2,y:i}:{x:n+e.width/2,y:i+e.height}},Or=(e,o,s)=>s&&o==="top"?{x:e.x,y:s.top}:e,$r=(e,o)=>o==="top"?{x:e.x,y:e.y-3}:o==="left"?{x:e.x-3,y:e.y}:o==="right"?{x:e.x+3,y:e.y}:{x:e.x,y:e.y+3},Pr=(e,o,s,r,n)=>{let i={straight:`M ${o.x} ${o.y} L ${s.x} ${s.y}`,turn:`M ${o.x} ${o.y} H ${s.x} V ${s.y}`,lane:`M ${o.x} ${o.y} V ${r} H ${s.x} V ${s.y}`,detour:`M ${o.x} ${o.y} H ${n} V ${s.y} H ${s.x}`}[e.route];return{...e,path:i,midX:e.route==="detour"?n:(o.x+s.x)/2,midY:e.route==="lane"?r:(o.y+s.y)/2}},Mr=(e,o,s,r)=>{let[n,i]=S([]),[l,d]=S({width:"100%",height:"100%"}),[c,x]=S([]);return he(()=>{let h=()=>{let u=o.current?.getBoundingClientRect();if(!u)return;d({width:o.current.scrollWidth,height:o.current.scrollHeight});let y=e.nodes.filter(m=>m.holds&&!m.loose&&s.current[m.id]).map(m=>{let C=s.current[m.id],w=C.getBoundingClientRect(),_=m.holds.flatMap(v=>s.current[v]?[s.current[v].getBoundingClientRect()]:[]),E=[{left:w.left,top:w.top,width:Math.max(w.width,C.scrollWidth),height:w.height},..._];return{id:m.id,bounds:Ne(E,u,o.current)}});x(y),i(e.edges.flatMap(m=>{let C=s.current[m.source]?.getBoundingClientRect(),w=s.current[m.target]?.getBoundingClientRect();if(!C||!w)return[];let _=J(C,m.leaves,u,o.current),E=y.find(z=>z.id===m.target)?.bounds,v=$r(Or(J(w,m.enters,u,o.current),m.enters,E),m.enters),g=(J(C,"bottom",u,o.current).y+J(w,"top",u,o.current).y)/2,L=m.leaves==="left"?Math.min(_.x,v.x)-28:Math.max(_.x,v.x)+28;return[Pr(m,_,v,g,L)]}))};h(),window.addEventListener("resize",h);let f=new ResizeObserver(h);return o.current&&f.observe(o.current),()=>{window.removeEventListener("resize",h),f.disconnect()}},r),{links:n,extent:l,boxes:c}},Ct=Mr;var Nt=(e,o)=>{let s=new Set(o),r=e,n=2;for(;s.has(r);)r=`${e}_${n++}`;return r};var _t=({send:e,onPress:o})=>s=>{let r=s.target.closest?.("[data-bar-action]");r&&(r.closest("details")?.removeAttribute("open"),o(),r.dataset.barPath&&e(r.dataset.barPath,"POST"))};var jr=8,Hr={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},Wr={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},Vr={flex:1,minHeight:0,overflow:"auto",position:"relative"},Et={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},Fr={...Et,position:"static",alignSelf:"flex-start"},Ur={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Bt={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Gr=({port:e,onCancel:o})=>t.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Bt},"Choose the step \u201C",e||"next","\u201D should lead to \u2014 ",t.createElement("button",{onClick:o,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),Yr=({message:e})=>t.createElement("p",{"data-canvas-error":!0,className:"bg-red-50 text-red-800 dark:bg-red-950 dark:text-red-200",style:Bt},e),Xr=({base:e,token:o,initial:s})=>{let{flow:r,error:n,notice:i,warning:l,setWarning:d,send:c,pickPicture:x}=St(e,o,s),[h,f]=S(null),[u,y]=S(null),[m,C]=S(null),[w,_]=S(null),[E,v]=S(null),[g,L]=S(!1),z=Z({}),B=Z(null);M(()=>{let a=_t({send:c,onPress:()=>{f(null),L(!0)}});return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[c]),M(()=>{if(!g){d(null);return}let a=p=>{p.target.isConnected&&!p.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&L(!1)};return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[g]),M(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),M(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let $t=$(()=>Object.fromEntries(r.nodes.map(a=>[a.id,a])),[r.nodes]),{links:Pt,extent:Mt,boxes:ne}=Ct(r,B,z,[r,h,$t]),It=$(()=>{let a={};return r.violations.forEach(p=>{var N;return(a[N=p.node]||(a[N]=[])).push(p)}),a},[r.violations]),T=r.direction==="left_to_right",j=$(()=>r.nodes.filter(a=>!a.loose),[r.nodes]),ae=r.nodes.filter(a=>a.loose),jt=$(()=>T?ht(j,r.edges,r.nodes):{},[T,j,r.edges,r.nodes]),Ht=$(()=>{let a={};return r.edges.forEach(p=>{var N;return(a[N=p.source]||(a[N]=[])).push(p.label||null)}),a},[r.edges]),Wt=Math.max(0,...j.map(a=>a.row))+1,Vt=Math.max(0,...j.map(a=>a.column))+1,ie=a=>{if(!m)return;let[p,N]=m;C(null),p!==a&&c("/edges","POST",{from:p,to:a,on:N||null})},Ft=a=>{if(a.isDefaultPrevented()||!w)return;a.preventDefault();let p=w;_(null);let N=B.current.getBoundingClientRect(),fe=_e(ne,{x:a.clientX-N.left+B.current.scrollLeft,y:a.clientY-N.top+B.current.scrollTop}),Ut=r.nodes.find(Gt=>Gt.holds?.includes(p))?.id||null;fe!==Ut&&c(`/steps/${p}/group`,"PATCH",{group:fe})},le=a=>[...r.palette,...r.unoffered||[]].find(p=>p.type===a?.type),P=r.nodes.find(a=>a.id===h),O=le(P),K=(a,p={})=>c("/steps","POST",{id:Nt(a.type,r.nodes.map(N=>N.id)),type:a.type,from:p.from,to:p.to,on:p.on}),de=a=>{let[p,N]=[E,w];v(null),_(null),p?K(p,{from:a.source,to:a.target}):N&&c("/steps/"+N+"/move","PATCH",{from:a.source,to:a.target})},ce=a=>{let p=B.current.getBoundingClientRect();return{x:a.clientX-p.left+B.current.scrollLeft+8,y:a.clientY-p.top+B.current.scrollTop+8}},pe=(a,p)=>({node:{...a,ref:N=>{z.current[a.id]=N},violations:It[a.id]||[],connected:p},selected:a.id===h,armed:m&&m[0]===a.id?m[1]:null,connecting:!!m&&m[0]!==a.id,onSelect:()=>m?ie(a.id):f(a.id),onOpen:N=>window.location.assign(N),onDragStart:()=>_(a.id),onDragEnd:()=>_(null),hideStepTypeCodes:r.hide_step_type_codes,compact:T,branches:jt[a.id]||[]}),me=a=>t.createElement(t.Fragment,null,a.placeholder&&t.createElement(Ve,{node:{...a,ref:p=>{z.current[a.id]=p}},dragging:!!w,compact:T,onFill:()=>y({from:a.from,on:a.on,at:{x:16,y:52}}),onDrop:()=>{let p=w;_(null),p&&c("/edges","POST",{from:a.from,to:p,on:a.on})}}),a.holds&&t.createElement(V,{node:{...a,ref:p=>{z.current[a.id]=p}},header:F(a,le(a),r.hide_step_type_codes),compact:T,onSelect:()=>m?ie(a.id):f(a.id)}),!a.placeholder&&!a.holds&&t.createElement(R,{...pe(a,Ht[a.id]||[]),onArm:(p,N)=>y({from:a.id,on:p,at:ce(N)})})),ue=ae.length>0&&t.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:T?Fr:Et},t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:6}},"Not in the flow yet \u2014 drag one onto a connection"),ae.map(a=>t.createElement("div",{key:a.id,style:{marginBottom:8}},t.createElement(R,{...pe(a,[]),onArm:(p,N)=>{N.stopPropagation(),C([a.id,p])}}))));return t.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:Hr,onMouseUp:()=>_(null),onKeyDown:a=>{a.key==="Escape"&&(f(null),C(null),y(null))},tabIndex:-1},t.createElement(Ue,{entries:r.palette,groups:r.step_groups||{},onPick:a=>K(a),onCarry:v,onDrop:()=>v(null)}),t.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:Wr},t.createElement("div",{ref:B,style:Vr,onClick:a=>{a.target===B.current&&(f(null),C(null),L(!1))},onDragOver:a=>{w&&a.preventDefault()},onDrop:Ft},m&&t.createElement(Gr,{port:m[1],onCancel:()=>C(null)}),n&&!g&&!P&&t.createElement(Yr,{message:n}),t.createElement(Ye,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>y({at:{x:16,y:52}}),onUndo:()=>{f(null),c("/undo","POST")},onRedo:()=>{f(null),c("/redo","POST")}}),!T&&ne.map(a=>t.createElement(Ce,{key:a.id,id:a.id,bounds:a.bounds,onDrop:()=>{let p=w;_(null),p&&c(`/steps/${p}/group`,"PATCH",{group:a.id})}})),!T&&t.createElement(ct,{links:ze(Pt,r.nodes),extent:Mt,dragging:w||E,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:a=>y({from:a.source,to:a.target,at:{x:a.midX+30,y:a.midY}}),onRemove:a=>{f(null),c("/edges","DELETE",{from:a.source,to:a.target})},onDrop:de}),!T&&ue,T&&t.createElement(q,{nodes:j,edges:r.edges,draw:me,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(w||E),onInsert:(a,p)=>y({from:a.source,to:a.target,at:ce(p)}),onRemove:a=>{f(null),c("/edges","DELETE",{from:a.source,to:a.target})},onDrop:de}},ue),!T&&t.createElement("div",{style:{...Ur,gridTemplateColumns:`repeat(${Vt+1}, ${280/2}px)`,gridTemplateRows:`repeat(${Wt}, auto)`}},j.map(a=>t.createElement("div",{key:a.id,style:{gridRow:a.row+1,gridColumn:`${a.column+1} / span 2`,zIndex:2,marginTop:Ee(a,r.nodes)?jr-64:0}},me(a)))),u&&t.createElement(Fe,{entries:r.palette,at:u.at,onDismiss:()=>y(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:u.on!==void 0?()=>{C([u.from,u.on]),y(null)}:null,onPick:a=>{let p=u;y(null),K(a,p)}})),t.createElement(at,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:f})),g&&!P&&t.createElement(Re,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:i,publishNote:r.publish_note,warning:l,onClose:()=>L(!1),onCreate:()=>c("/versions","POST"),onPublish:()=>c("/publish","POST"),onAccept:()=>c(l.path,"POST",{remove_unconnected:l.steps.map(a=>a.id)}),onDecline:()=>d(null),onSaveDetails:a=>c("/details","PATCH",{flow:a})}),P&&t.createElement(We,{node:P,fields:O?.fields||{},holds:O?.records||{},labels:O?.labels||{},explanations:O?.explanations||{},recordLabels:O?.record_labels||{},recordExplanations:O?.record_explanations||{},recordChoices:O?.record_choices||{},recordOutputsOf:O?.record_outputs_of||{},choices:Be(P,O),onClose:()=>f(null),onSave:a=>c(`/steps/${P.id}`,"PATCH",{config:a}),onPickPicture:x,refusal:n,onDelete:()=>{f(null),c(`/steps/${P.id}`,"DELETE")}}))},Tt=Xr;var qr={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Jr={fontSize:12,fontWeight:500,lineHeight:1.3},At={done:"border-green-600 bg-green-50 dark:border-green-500 dark:bg-green-950",paused:"border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-950",pending:"border-gray-300 bg-white text-gray-500 dark:border-zinc-700 dark:bg-zinc-900 dark:text-gray-400",failed:"border-red-600 bg-red-50 dark:border-red-500 dark:bg-red-950"},Dt={done:"text-green-700 dark:text-green-400",paused:"text-amber-800 dark:text-amber-300",pending:"text-gray-500 dark:text-gray-400",failed:"text-red-700 dark:text-red-400"},Kr="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Zr=({node:e,selected:o=!1})=>{let s=e.address?"a":"div";return t.createElement(s,{"data-step":e.id,href:e.address||void 0,className:`${e.state==="paused"?"border-2":"border"} ${At[e.state]||At.pending}${o?` ${Kr}`:""}`,style:qr},t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.type),t.createElement("div",{style:Jr},e.label,e.version&&t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},e.version)),e.status&&t.createElement("div",{className:Dt[e.state]||Dt.pending,style:{fontSize:11}},e.status))},Lt=Zr;var Qr={gap:12,padding:0},Rr=({nodes:e,edges:o,selected:s})=>t.createElement(q,{nodes:e,edges:o,joints:{},style:Qr,draw:r=>r.holds?t.createElement(V,{node:r,header:F(r,r,!1),compact:!0}):t.createElement(Lt,{node:r,selected:r.id===s})}),Ot=Rr;Q("easy_flow/flow-editor",Tt);Q("easy_flow/run-view",Ot);document.addEventListener("easy_flow:flow-named",e=>{let o=document.querySelector("[data-flow-heading]");o&&(o.textContent=e.detail)});document.addEventListener("easy_flow:flow-status",({detail:e})=>{e.status&&document.querySelectorAll("[data-version-status]").forEach(o=>{o.textContent=e.status}),e.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(o=>{o.textContent=`Publish v${e.publishes}`})});ke(document,ge);})();
|
|
@@ -26,13 +26,14 @@ module EasyFlow
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def flow_details(flow)
|
|
29
|
+
status = DraftStatus.new(flow)
|
|
29
30
|
{ "title" => flow.title,
|
|
30
31
|
"slug" => flow.slug,
|
|
31
32
|
"start_label" => flow.start_label,
|
|
32
|
-
"version" =>
|
|
33
|
+
"version" => status.number,
|
|
33
34
|
"published" => flow.live_version&.number,
|
|
34
|
-
"status" =>
|
|
35
|
-
"publishes" =>
|
|
35
|
+
"status" => status.to_s,
|
|
36
|
+
"publishes" => status.publishes,
|
|
36
37
|
"definition_url" => edit_manage_flow_definition_path(flow),
|
|
37
38
|
"details_url" => edit_manage_flow_path(flow),
|
|
38
39
|
"history_url" => manage_flow_versions_path(flow) }
|
|
@@ -17,7 +17,8 @@ import useFlow from "./useFlow"
|
|
|
17
17
|
import useConnectors from "./useConnectors"
|
|
18
18
|
import { CARD, GAP_X, GAP_Y } from "./styles"
|
|
19
19
|
import { nextId } from "./ids"
|
|
20
|
-
import {
|
|
20
|
+
import { branchLinesOf } from "./reading"
|
|
21
|
+
import { barPressed } from "./topBar"
|
|
21
22
|
|
|
22
23
|
const HEADER_GAP = 8
|
|
23
24
|
|
|
@@ -37,6 +38,10 @@ export const Choosing = ({ port, onCancel }) => (
|
|
|
37
38
|
</div>
|
|
38
39
|
)
|
|
39
40
|
|
|
41
|
+
export const CanvasError = ({ message }) => (
|
|
42
|
+
<p data-canvas-error className="bg-red-50 text-red-800 dark:bg-red-950 dark:text-red-200" style={notice}>{message}</p>
|
|
43
|
+
)
|
|
44
|
+
|
|
40
45
|
const Canvas = ({ base, token, initial }) => {
|
|
41
46
|
const { flow, error, notice, warning, setWarning, send, pickPicture } = useFlow(base, token, initial)
|
|
42
47
|
const [ selected, setSelected ] = useState(null)
|
|
@@ -49,17 +54,7 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
49
54
|
const surface = useRef(null)
|
|
50
55
|
|
|
51
56
|
useEffect(() => {
|
|
52
|
-
const
|
|
53
|
-
const pressed = (event) => {
|
|
54
|
-
const button = event.target.closest?.("[data-bar-action]")
|
|
55
|
-
if (!button || !(button.dataset.barAction in paths)) return
|
|
56
|
-
|
|
57
|
-
button.closest("details")?.removeAttribute("open")
|
|
58
|
-
setSelected(null)
|
|
59
|
-
setShowing(true)
|
|
60
|
-
const path = paths[button.dataset.barAction]
|
|
61
|
-
if (path) send(path, "POST")
|
|
62
|
-
}
|
|
57
|
+
const pressed = barPressed({ send, onPress: () => { setSelected(null); setShowing(true) } })
|
|
63
58
|
document.addEventListener("click", pressed)
|
|
64
59
|
return () => document.removeEventListener("click", pressed)
|
|
65
60
|
}, [ send ])
|
|
@@ -95,8 +90,14 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
95
90
|
}, [ flow.violations ])
|
|
96
91
|
|
|
97
92
|
const leftToRight = flow.direction === "left_to_right"
|
|
98
|
-
const attached = flow.nodes.filter((node) => !node.loose)
|
|
93
|
+
const attached = useMemo(() => flow.nodes.filter((node) => !node.loose), [ flow.nodes ])
|
|
99
94
|
const loose = flow.nodes.filter((node) => node.loose)
|
|
95
|
+
const branchLines = useMemo(() => (leftToRight ? branchLinesOf(attached, flow.edges, flow.nodes) : {}), [ leftToRight, attached, flow.edges, flow.nodes ])
|
|
96
|
+
const connectedFrom = useMemo(() => {
|
|
97
|
+
const ports = {}
|
|
98
|
+
flow.edges.forEach((edge) => (ports[edge.source] ||= []).push(edge.label || null))
|
|
99
|
+
return ports
|
|
100
|
+
}, [ flow.edges ])
|
|
100
101
|
const rows = Math.max(0, ...attached.map((node) => node.row)) + 1
|
|
101
102
|
const columns = Math.max(0, ...attached.map((node) => node.column)) + 1
|
|
102
103
|
|
|
@@ -139,6 +140,20 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
139
140
|
return { x: event.clientX - frame.left + surface.current.scrollLeft + 8, y: event.clientY - frame.top + surface.current.scrollTop + 8 }
|
|
140
141
|
}
|
|
141
142
|
|
|
143
|
+
const cardProps = (node, connected) => ({
|
|
144
|
+
node: { ...node, ref: (element) => { cards.current[node.id] = element }, violations: violationsFor[node.id] || [], connected },
|
|
145
|
+
selected: node.id === selected,
|
|
146
|
+
armed: armed && armed[0] === node.id ? armed[1] : null,
|
|
147
|
+
connecting: Boolean(armed) && armed[0] !== node.id,
|
|
148
|
+
onSelect: () => (armed ? connectTo(node.id) : setSelected(node.id)),
|
|
149
|
+
onOpen: (path) => window.location.assign(path),
|
|
150
|
+
onDragStart: () => setDragging(node.id),
|
|
151
|
+
onDragEnd: () => setDragging(null),
|
|
152
|
+
hideStepTypeCodes: flow.hide_step_type_codes,
|
|
153
|
+
compact: leftToRight,
|
|
154
|
+
branches: branchLines[node.id] || []
|
|
155
|
+
})
|
|
156
|
+
|
|
142
157
|
const draw = (node) => (
|
|
143
158
|
<>
|
|
144
159
|
{node.placeholder && (
|
|
@@ -156,32 +171,8 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
156
171
|
header={headerOf(node, entryOf(node), flow.hide_step_type_codes)} compact={leftToRight}
|
|
157
172
|
onSelect={() => (armed ? connectTo(node.id) : setSelected(node.id))} />
|
|
158
173
|
)}
|
|
159
|
-
{!node.placeholder && !node.holds && <StepCard
|
|
160
|
-
|
|
161
|
-
...node,
|
|
162
|
-
ref: (element) => { cards.current[node.id] = element },
|
|
163
|
-
violations: violationsFor[node.id] || [],
|
|
164
|
-
connected: flow.edges.filter((edge) => edge.source === node.id).map((edge) => edge.label || null)
|
|
165
|
-
}}
|
|
166
|
-
selected={node.id === selected}
|
|
167
|
-
armed={armed && armed[0] === node.id ? armed[1] : null}
|
|
168
|
-
connecting={Boolean(armed) && armed[0] !== node.id}
|
|
169
|
-
onSelect={() => (armed ? connectTo(node.id) : setSelected(node.id))}
|
|
170
|
-
onOpen={(path) => window.location.assign(path)}
|
|
171
|
-
onArm={(port, event) => {
|
|
172
|
-
const frame = surface.current.getBoundingClientRect()
|
|
173
|
-
setAdding({
|
|
174
|
-
from: node.id, on: port,
|
|
175
|
-
at: { x: event.clientX - frame.left + surface.current.scrollLeft + 8,
|
|
176
|
-
y: event.clientY - frame.top + surface.current.scrollTop + 8 }
|
|
177
|
-
})
|
|
178
|
-
}}
|
|
179
|
-
onDragEnd={() => setDragging(null)}
|
|
180
|
-
onDragStart={() => setDragging(node.id)}
|
|
181
|
-
hideStepTypeCodes={flow.hide_step_type_codes}
|
|
182
|
-
compact={leftToRight}
|
|
183
|
-
branches={leftToRight ? branchesOf(node, flow.edges, attached).map((edge) => branchLine(edge, flow.nodes)) : []}
|
|
184
|
-
/>}
|
|
174
|
+
{!node.placeholder && !node.holds && <StepCard {...cardProps(node, connectedFrom[node.id] || [])}
|
|
175
|
+
onArm={(port, event) => setAdding({ from: node.id, on: port, at: pointed(event) })} />}
|
|
185
176
|
</>
|
|
186
177
|
)
|
|
187
178
|
|
|
@@ -190,22 +181,8 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
190
181
|
<div className="text-gray-500 dark:text-gray-400" style={{ fontSize: 11, marginBottom: 6 }}>Not in the flow yet — drag one onto a connection</div>
|
|
191
182
|
{loose.map((node) => (
|
|
192
183
|
<div key={node.id} style={{ marginBottom: 8 }}>
|
|
193
|
-
<StepCard
|
|
194
|
-
|
|
195
|
-
...node,
|
|
196
|
-
ref: (element) => { cards.current[node.id] = element },
|
|
197
|
-
violations: violationsFor[node.id] || [],
|
|
198
|
-
connected: []
|
|
199
|
-
}}
|
|
200
|
-
selected={selected === node.id}
|
|
201
|
-
armed={armed && armed[0] === node.id ? armed[1] : null}
|
|
202
|
-
connecting={Boolean(armed)}
|
|
203
|
-
onSelect={() => (armed ? connectTo(node.id) : setSelected(node.id))}
|
|
204
|
-
onOpen={(path) => window.location.assign(path)}
|
|
205
|
-
onArm={(port, event) => { event.stopPropagation(); setArmed([ node.id, port ]) }}
|
|
206
|
-
onDragStart={() => setDragging(node.id)}
|
|
207
|
-
onDragEnd={() => setDragging(null)}
|
|
208
|
-
hideStepTypeCodes={flow.hide_step_type_codes} />
|
|
184
|
+
<StepCard {...cardProps(node, [])}
|
|
185
|
+
onArm={(port, event) => { event.stopPropagation(); setArmed([ node.id, port ]) }} />
|
|
209
186
|
</div>
|
|
210
187
|
))}
|
|
211
188
|
</div>
|
|
@@ -225,6 +202,7 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
225
202
|
{armed && (
|
|
226
203
|
<Choosing port={armed[1]} onCancel={() => setArmed(null)} />
|
|
227
204
|
)}
|
|
205
|
+
{error && !showing && !selectedNode && <CanvasError message={error} />}
|
|
228
206
|
<Toolbar undoable={flow.undoable} redoable={flow.redoable}
|
|
229
207
|
onAdd={() => setAdding({ at: { x: 16, y: 52 } })}
|
|
230
208
|
onUndo={() => { setSelected(null); send("/undo", "POST") }}
|
|
@@ -4,6 +4,7 @@ import Input from "keystone_ui-react/src/Input.jsx"
|
|
|
4
4
|
import Select from "keystone_ui-react/src/Select.jsx"
|
|
5
5
|
import Checkbox from "keystone_ui-react/src/Checkbox.jsx"
|
|
6
6
|
import RadioCards from "keystone_ui-react/src/RadioCards.jsx"
|
|
7
|
+
import Button from "keystone_ui-react/src/Button.jsx"
|
|
7
8
|
|
|
8
9
|
const offered = (choices) =>
|
|
9
10
|
(choices || []).map((choice) => (typeof choice === "object" ? choice : { value: choice, label: choice }))
|
|
@@ -12,7 +13,7 @@ const Control = ({ name, type, value, choices, onChange, onSettle, onPick, pictu
|
|
|
12
13
|
if (type === "picture") {
|
|
13
14
|
return <div className="mb-3">
|
|
14
15
|
{value && pictureUrl && <img src={pictureUrl} alt="The step's picture" style={{ maxWidth: "100%" }} />}
|
|
15
|
-
{value && <
|
|
16
|
+
{value && <Button type="button" variant="secondary" size="sm" data-remove-picture onClick={() => onSettle("")}>Remove picture</Button>}
|
|
16
17
|
<input type="file" accept="image/*" onChange={(e) => e.target.files[0] && onPick(e.target.files[0])} />
|
|
17
18
|
</div>
|
|
18
19
|
}
|
|
@@ -28,7 +29,7 @@ const Control = ({ name, type, value, choices, onChange, onSettle, onPick, pictu
|
|
|
28
29
|
|
|
29
30
|
if (type === "radio_cards") {
|
|
30
31
|
return <div data-radio-cards className="mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full">
|
|
31
|
-
<RadioCards name={name} value={value} options={choices || []} onChange={
|
|
32
|
+
<RadioCards name={name} value={value} options={choices || []} onChange={onSettle} />
|
|
32
33
|
</div>
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
const UNREACHABLE = "Your change was not saved because the server could not be reached."
|
|
2
2
|
|
|
3
|
+
const NOT_REFRESHED = "Your change was saved, but the canvas could not be refreshed. Reload the page to see it."
|
|
4
|
+
|
|
5
|
+
const redraw = async ({ base, fetch, onFlow, onError }) => {
|
|
6
|
+
const response = await fetch(base + ".json", { headers: { Accept: "application/json" } }).catch(() => null)
|
|
7
|
+
const flow = response?.ok ? await response.json().catch(() => null) : null
|
|
8
|
+
|
|
9
|
+
return flow ? onFlow(flow) : onError(NOT_REFRESHED)
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
export const createFlowSender = ({ base, token, fetch, onFlow, onError, onNotice, onWarning = () => {} }) => async (path, method, body) => {
|
|
13
|
+
const drawn = { base, fetch, onFlow, onError }
|
|
4
14
|
const response = await fetch(base + path, {
|
|
5
15
|
method, headers: { "Content-Type": "application/json", "X-CSRF-Token": token }, body: body && JSON.stringify(body)
|
|
6
16
|
}).catch(() => null)
|
|
@@ -15,7 +25,7 @@ export const createFlowSender = ({ base, token, fetch, onFlow, onError, onNotice
|
|
|
15
25
|
onNotice(null)
|
|
16
26
|
onError(null)
|
|
17
27
|
onWarning({ path, steps: answered.unconnected })
|
|
18
|
-
return
|
|
28
|
+
return redraw(drawn)
|
|
19
29
|
}
|
|
20
30
|
|
|
21
31
|
onWarning(null)
|
|
@@ -27,7 +37,7 @@ export const createFlowSender = ({ base, token, fetch, onFlow, onError, onNotice
|
|
|
27
37
|
|
|
28
38
|
onError(null)
|
|
29
39
|
onNotice(answered.notice || null)
|
|
30
|
-
|
|
40
|
+
return redraw(drawn)
|
|
31
41
|
}
|
|
32
42
|
|
|
33
43
|
export const createPictureSender = ({ base, token, fetch, onError }) => async (file) => {
|
|
@@ -1,37 +1,52 @@
|
|
|
1
1
|
const byPlace = (a, b) => a.row - b.row || a.column - b.column
|
|
2
2
|
|
|
3
|
+
const holdersOf = (nodes) => new Map(nodes.flatMap((group) => (group.holds || []).map((id) => [ id, group.id ])))
|
|
4
|
+
|
|
3
5
|
export const readingOrder = (nodes) => {
|
|
4
6
|
const placed = [ ...nodes ].sort(byPlace)
|
|
5
|
-
const
|
|
7
|
+
const holders = holdersOf(nodes)
|
|
8
|
+
const held = new Map(nodes.filter((node) => node.holds).map((group) => [ group.id, [] ]))
|
|
9
|
+
placed.filter((node) => holders.has(node.id)).forEach((node) => held.get(holders.get(node.id)).push(node))
|
|
6
10
|
|
|
7
|
-
return placed.filter((node) => !held.
|
|
8
|
-
.flatMap((node) => [ node, ...held.filter((step) => node.holds?.includes(step.id)) ])
|
|
11
|
+
return placed.filter((node) => !holders.has(node.id)).flatMap((node) => [ node, ...(held.get(node.id) || []) ])
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
export const blocksOf = (nodes) => {
|
|
15
|
+
const holders = holdersOf(nodes)
|
|
12
16
|
const ordered = readingOrder(nodes)
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
return ordered.filter((node) => !held(node)).reduce((blocks, node) => {
|
|
16
|
-
if (node.holds) return [ ...blocks, { group: node, steps: ordered.filter((step) => node.holds.includes(step.id)) } ]
|
|
17
|
+
const blocks = []
|
|
18
|
+
const boxes = new Map()
|
|
17
19
|
|
|
20
|
+
ordered.filter((node) => !holders.has(node.id)).forEach((node) => {
|
|
18
21
|
const last = blocks[blocks.length - 1]
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
if (node.holds) boxes.set(node.id, blocks[blocks.push({ group: node, steps: [] }) - 1])
|
|
23
|
+
else if (last && !last.group) last.steps.push(node)
|
|
24
|
+
else blocks.push({ steps: [ node ] })
|
|
25
|
+
})
|
|
26
|
+
ordered.filter((node) => holders.has(node.id)).forEach((node) => boxes.get(holders.get(node.id))?.steps.push(node))
|
|
27
|
+
|
|
28
|
+
return blocks
|
|
22
29
|
}
|
|
23
30
|
|
|
24
|
-
const
|
|
31
|
+
const nameOf = (step) => (step?.placeholder ? "nowhere yet" : step?.label)
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
const next = nextAfter(readingOrder(nodes), node)
|
|
33
|
+
const joins = new WeakMap()
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
const joinsOf = (edges) => {
|
|
36
|
+
if (!joins.has(edges)) joins.set(edges, new Map([ ...edges ].reverse().map((edge) => [ `${edge.source}\n${edge.target}`, edge ])))
|
|
37
|
+
return joins.get(edges)
|
|
30
38
|
}
|
|
31
39
|
|
|
32
|
-
const
|
|
40
|
+
export const joining = (edges, before, after) => joinsOf(edges).get(`${before.id}\n${after.id}`)
|
|
41
|
+
|
|
42
|
+
export const branchLinesOf = (steps, edges, nodes) => {
|
|
43
|
+
const ordered = readingOrder(steps)
|
|
44
|
+
const next = new Map(ordered.map((step, at) => [ step.id, ordered[at + 1]?.id ]))
|
|
45
|
+
const names = new Map(nodes.map((node) => [ node.id, nameOf(node) ]))
|
|
46
|
+
const lines = Object.fromEntries(steps.map((step) => [ step.id, [] ]))
|
|
33
47
|
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
edges.filter((edge) => lines[edge.source] && (edge.label || edge.target !== next.get(edge.source)))
|
|
49
|
+
.forEach((edge) => lines[edge.source].push([ edge.label, "→", names.get(edge.target) ].filter(Boolean).join(" ")))
|
|
36
50
|
|
|
37
|
-
|
|
51
|
+
return lines
|
|
52
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const barPressed = ({ send, onPress }) => (event) => {
|
|
2
|
+
const button = event.target.closest?.("[data-bar-action]")
|
|
3
|
+
if (!button) return
|
|
4
|
+
|
|
5
|
+
button.closest("details")?.removeAttribute("open")
|
|
6
|
+
onPress()
|
|
7
|
+
if (button.dataset.barPath) send(button.dataset.barPath, "POST")
|
|
8
|
+
}
|
|
@@ -20,11 +20,18 @@ module EasyFlow
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def drawn_step(node)
|
|
23
|
-
{ "id" => node.id, "type" => node.type, "type_name" => step_type_for(node)&.step_name, "label" => label_for(node), "summary" =>
|
|
23
|
+
{ "id" => node.id, "type" => node.type, "type_name" => step_type_for(node)&.step_name, "label" => label_for(node), "summary" => drawn_by_type(node, :summary_of), "details" => drawn_by_type(node, :details_of).to_a, "links" => drawn_by_type(node, :links_of).to_a,
|
|
24
24
|
"config" => node.config.merge(kept_values(node)), "ports" => [], "ends_here" => ends_here?(node), "begins_here" => begins_here?(node),
|
|
25
25
|
"starts_a_flow" => starts_a_flow?(node), "holds" => holds(node), "opens" => opens(node), "loose" => loose?(node), "choices" => choices_for(node), "record_choices" => record_choices_for(node), "placeholder" => false, "picture_url" => picture_url(node), **placed[node.id] }
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
def drawn_by_type(node, part)
|
|
29
|
+
step_type_for(node)&.public_send(part, node)
|
|
30
|
+
rescue StandardError => error
|
|
31
|
+
Rails.logger.error("EasyFlow could not draw step #{node.id}'s #{part}: #{error.class}: #{error.message}")
|
|
32
|
+
nil
|
|
33
|
+
end
|
|
34
|
+
|
|
28
35
|
def picture_url(node)
|
|
29
36
|
EasyFlow.picture_url(node.config["picture"]) if node.config["picture"].present?
|
|
30
37
|
end
|
|
@@ -112,7 +119,14 @@ module EasyFlow
|
|
|
112
119
|
"record_outputs_of" => step_type.settings.record_outputs_of.to_h { |name, sources| [ name.to_s, sources.to_h { |field, source| [ field.to_s, source.to_s ] } ] },
|
|
113
120
|
"record_labels" => step_type.settings.record_labels.to_h { |name, held| [ name.to_s, held.transform_keys(&:to_s) ] },
|
|
114
121
|
"record_explanations" => record_explanations_of(step_type),
|
|
115
|
-
"awaits_input" => step_type.awaits_input
|
|
122
|
+
"awaits_input" => step_type.awaits_input?,
|
|
123
|
+
"outputs" => step_type.outputs.map { |output| palette_output(output) },
|
|
124
|
+
"outputs_named_by" => step_type.outputs_named_by&.to_s }
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def palette_output(output)
|
|
128
|
+
{ "name" => output.name.to_s, "label" => output.label, "type" => output.type.to_s,
|
|
129
|
+
"values" => output.values.respond_to?(:call) ? nil : output.values }
|
|
116
130
|
end
|
|
117
131
|
|
|
118
132
|
def hidden_settings_of(step_type)
|
|
@@ -99,6 +99,7 @@ module EasyFlow
|
|
|
99
99
|
|
|
100
100
|
def group(id, into:)
|
|
101
101
|
raise InvalidEdit, "#{into} cannot hold steps" if into && (into == id || !holds_steps?(node(into)))
|
|
102
|
+
raise InvalidEdit, "#{id} is a group step and cannot go inside another group step" if into && holds_steps?(node(id))
|
|
102
103
|
|
|
103
104
|
regrouped = released(id).map do |node|
|
|
104
105
|
node["id"] == into ? node.merge("holds" => Array(node["holds"]) + [ id ]) : node
|
|
@@ -9,15 +9,24 @@ module EasyFlow
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def publishes
|
|
12
|
-
return
|
|
12
|
+
return version.number if version && @flow.document == version.definition
|
|
13
13
|
|
|
14
14
|
@flow.definition_versions.maximum(:number).to_i + 1
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def number
|
|
18
|
+
version&.number
|
|
19
|
+
end
|
|
20
|
+
|
|
17
21
|
private
|
|
18
22
|
|
|
23
|
+
def version
|
|
24
|
+
return @version if defined?(@version)
|
|
25
|
+
|
|
26
|
+
@version = @flow.current_definition_version
|
|
27
|
+
end
|
|
28
|
+
|
|
19
29
|
def based_on
|
|
20
|
-
version = @flow.current_definition_version
|
|
21
30
|
version ? "draft from v#{version.number}" : "new draft"
|
|
22
31
|
end
|
|
23
32
|
|
|
@@ -8,7 +8,7 @@ module EasyFlow
|
|
|
8
8
|
behaviour.present? && behaviour.parameters.include?([ :key, :run ])
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
attr_reader :id, :step_name, :settings, :naming_field, :naming, :outputs, :drawn_by, :unsaved_refusal
|
|
11
|
+
attr_reader :id, :step_name, :settings, :naming_field, :naming, :outputs, :outputs_named_by, :drawn_by, :unsaved_refusal
|
|
12
12
|
|
|
13
13
|
def initialize(id:, step_name:, settings:, awaits_input:, behaviour:, routing:,
|
|
14
14
|
ends_here: false, begins_here: false, starts_a_flow: false, plays_the_picked_flow: false, holds_steps: false, flow_chooser: nil, run_chooser: nil, display: nil, drawn_by: nil,
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
<% actions << { label: "Try it", href: flow_routes.manage_flow_preview_path(flow) } %>
|
|
29
29
|
<% flow_host.editor_buttons_for(flow).each { |button| actions << { label: button.label, href: button.address } } %>
|
|
30
30
|
<% if showing == :canvas %>
|
|
31
|
-
<% actions << { label: "Save draft", data: { bar_action: "save_draft" } } %>
|
|
32
|
-
<% actions << { label: "Publish v#{EasyFlow::DraftStatus.new(flow).publishes}", data: { bar_action: "publish" }, primary: true } %>
|
|
31
|
+
<% actions << { label: "Save draft", data: { bar_action: "save_draft", bar_path: "/versions" } } %>
|
|
32
|
+
<% actions << { label: "Publish v#{EasyFlow::DraftStatus.new(flow).publishes}", data: { bar_action: "publish", bar_path: "/publish" }, primary: true } %>
|
|
33
33
|
<% end %>
|
|
34
34
|
|
|
35
35
|
<div class="ml-auto hidden flex-wrap items-center gap-2 sm:flex">
|
data/lib/easy_flow/engine.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require "keystone_ui"
|
|
1
2
|
require "keystone_ui-react"
|
|
2
3
|
|
|
3
4
|
module EasyFlow
|
|
@@ -5,9 +6,6 @@ module EasyFlow
|
|
|
5
6
|
isolate_namespace EasyFlow
|
|
6
7
|
|
|
7
8
|
initializer "easy_flow.tailwind" do
|
|
8
|
-
next unless Gem.loaded_specs.key?("keystone_ui")
|
|
9
|
-
|
|
10
|
-
require "keystone_ui"
|
|
11
9
|
KeystoneUi.configuration.tailwind_sources << root.join("app/views/**/*.erb").to_s
|
|
12
10
|
KeystoneUi.configuration.tailwind_sources << root.join("app/javascript/**/*.{js,jsx}").to_s
|
|
13
11
|
KeystoneUi.configuration.tailwind_sources << root.join("app/assets/builds/easy_flow/*.js").to_s
|
data/lib/easy_flow/version.rb
CHANGED
|
@@ -109,7 +109,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
109
109
|
- `shows_values(heading = nil, columns: false) { |node| ... }` — a read-only section of the step settings panel, shown under the step's editable settings. The block returns a hash of labels to values, such as `shows_values("Inputs") { |node| { "brief" => "load_brief.out.brief" } }`, and each value is shown as text in a monospace font. Without `columns:` each label sits beside its value with the labels in one column. With `columns: true` the pairs sit two to a row, each label above its value, such as `shows_values(columns: true) { |node| { "Timeout" => "90s", "Retry" => "3" } }`. Declare it several times for several sections, which are shown in the order declared. Nothing in a section can be edited from the panel.
|
|
110
110
|
- `shows_code(heading = nil) { |node| ... }` — a read-only section of the step settings panel holding code blocks. The block returns a hash of summary lines to code, such as `shows_code("Schemas") { |node| { "input_schema" => node.config["input_schema"].to_s } }`. Each block is closed until its summary line is clicked, and a line wider than the panel scrolls sideways inside its block.
|
|
111
111
|
- `links_to { |node| ... }` — buttons at the foot of the step settings panel, side by side above Delete step. The block returns a list of hashes each with a `label` and an `address`, such as `links_to { |node| [ { label: "Open agent", address: "/agents/#{node.config['agent']}" } ] }`. Each address is used as written.
|
|
112
|
-
- The blocks of `shows_values`, `shows_code` and `links_to` are called every time the canvas is drawn, so they must not be slow and must not change anything. Ask the developer what an admin should read about a step of this type in its settings without being able to change it, and which pages it should link to.
|
|
112
|
+
- The blocks of `shows_values`, `shows_code` and `links_to` are called every time the canvas is drawn, so they must not be slow and must not change anything. When the block of `summarizes_by`, `shows_values`, `shows_code` or `links_to` raises an error, the canvas still opens, that step is drawn without the summary, sections or links that failed, and the error is written to the app's log. Ask the developer what an admin should read about a step of this type in its settings without being able to change it, and which pages it should link to.
|
|
113
113
|
- `awaits_input` — the visitor is shown this step and submits an answer to it.
|
|
114
114
|
- `waits_until { |node, state| ... }` or `waits_until { |node, state, times| ... }` — the run stops at this step until the block returns a truthy value. See step 8.
|
|
115
115
|
- `answer_check { |node, value| ... }` — checks a submitted answer before it is recorded. `value` is the submitted string, an array of strings when the input submits several values, or `nil` or `""` when the input sent nothing. An array may hold blank strings. Return a message to refuse the answer, or `nil` to accept it. Without it every answer is accepted, including a blank one. For a file input, see step 7.
|
|
@@ -187,7 +187,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
187
187
|
- `holds_steps` — a step of the type holds other steps of the same flow, such as a "for each" step. Ask the developer what the step should do with the steps it holds when a run reaches it. Do not pick, since the engine does nothing with them at run time.
|
|
188
188
|
- On the canvas, a step of the type is drawn as a dashed box around the steps it holds, with a header line at its top in place of a step card. The header is the type's id followed by each filled-in setting as `<name>: <value>`, or `<name> <value>` for an `integer` or `float` setting, joined by ` · `, leaving out a blank setting and a setting whose value is a list or an array. On a host that hides step type codes, set through `easy_flow-install`, the header uses the type's `step_name` and each setting's label instead.
|
|
189
189
|
- Clicking the header opens the step's settings. The header shows none of the error counts a step card shows, and has none of a card's buttons for starting a connection.
|
|
190
|
-
- An admin puts a step in the box by dragging it onto the box, and takes it out by dragging it onto the canvas outside the box. A step is held by one group step at a time, a group step cannot hold itself, and a step cannot be moved into a step whose type does not declare `holds_steps`. Moving a step in or out leaves every connection as it was.
|
|
190
|
+
- An admin puts a step in the box by dragging it onto the box, and takes it out by dragging it onto the canvas outside the box. A step is held by one group step at a time, a group step cannot hold itself or be put inside another group step, and a step cannot be moved into a step whose type does not declare `holds_steps`. Moving a step in or out leaves every connection as it was.
|
|
191
191
|
- The ids of the steps held are kept in the flow's document under `holds` on the group step, so `node.config["holds"]` is an array of step ids, in the order they were moved in, or is missing when no step was ever moved in. Read it with `Array(node.config["holds"])`. Removing a held step takes its id out of the list, and saving the group step's settings keeps the list as it was.
|
|
192
192
|
- The type must not declare a setting named `holds`, since a value saved under that name is dropped.
|
|
193
193
|
- A run follows connections only. A run reaching a step of a type that declares none of `awaits_input`, `process`, `route` or `waits_until` passes on along its connection, and the steps it holds run once, where their connections place them, like any other steps.
|
|
@@ -96,7 +96,7 @@ easy_flow declares no commands of its own for this local. Its surface is split b
|
|
|
96
96
|
- **Waiting step** — a step whose type carries a rule saying whether what it waits for has happened, such as a payment clearing or a document being signed. A run that reaches it stops there, and the visitor sees "Waiting for" followed by the step's name, with no form to submit. Once the rule says it has happened, the run moves past the step the next time the visitor's page is loaded or the app moves the run on, and the step is recorded as `true`.
|
|
97
97
|
- **Check again** — a button a visitor sees under the "Waiting for" line in a flow that carries its answers in the page. It loads the step page again with the answers and their completion times, so the run moves past a waiting step whose rule now says it has happened, such as a Wait step whose time has come. A stored run shows no such button, since loading its page again does the same.
|
|
98
98
|
- **Group step** — a step whose type is declared as holding steps, such as an app's own "for each" step. The canvas draws it as a dashed box with a header line at the top and the steps it holds inside. The header line is the step type's code followed by each filled-in setting as `name: value`, or `name value` for a number setting, joined by ` · `. It sits right above the first step the box holds, and the connection from the group step to a step it holds is not drawn. A host that hides step type codes shows the type's name and the settings' labels instead. Clicking the header opens the step's settings, and a connection drawn into a group step ends at the top of its box.
|
|
99
|
-
- **Holding a step** — an admin puts a step in a group step by dragging it onto the group's box, and takes it out by dragging it onto the canvas outside the box. Moving a step in or out changes only which steps the group holds and leaves every connection as it was. The group step lists the ids of the steps it holds under `holds` in the flow's document. Removing a step takes it out of the group that held it, and a step cannot be put in itself or in a step whose type does not hold steps. A run reaching a group step passes straight on along its connection, and the steps it holds run once like any other steps.
|
|
99
|
+
- **Holding a step** — an admin puts a step in a group step by dragging it onto the group's box, and takes it out by dragging it onto the canvas outside the box. Moving a step in or out changes only which steps the group holds and leaves every connection as it was. The group step lists the ids of the steps it holds under `holds` in the flow's document. Removing a step takes it out of the group that held it, and a step cannot be put in itself or in a step whose type does not hold steps, and a group step cannot be put in another group step. A run reaching a group step passes straight on along its connection, and the steps it holds run once like any other steps.
|
|
100
100
|
- **Registry** — the list of step types the app has registered, alongside the built-in ones. A step whose type is not registered is not shown or run as that type, and its answers are not checked.
|
|
101
101
|
- **Host** — a named part of the app that owns a set of flows. A host sets the visitor layout and the admin layout, how admins are authenticated, how visitors are authorized, how a refusal is answered, and optionally which step types it offers and which answers it allows a step in a run. Flows are always looked up through a host, so one host never sees another's flows.
|
|
102
102
|
- **Offered step types** — the list of step types a host names for its admins to add. A host that names no list offers every registered step type. The list only narrows the palette.
|
|
@@ -26,8 +26,8 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
26
26
|
|
|
27
27
|
## How to use it
|
|
28
28
|
|
|
29
|
-
1. Confirm the app
|
|
30
|
-
2. Read the `keystone_ui` version in the app's `Gemfile.lock`. easy_flow's visitor pages pass each answer's info text to Keystone UI's radio cards and checkbox rows and draw a File upload step with Keystone UI's file upload control, and easy_flow is built against `keystone_ui` 0.27.0.
|
|
29
|
+
1. Confirm Keystone UI is set up in the app. easy_flow declares `keystone_ui` 0.27 or a later 0.x release as a dependency, so bundling easy_flow installs the gem, but its install generator still has to have been run. If it has not, stop and hand off to the `keystone_ui-install` local before continuing.
|
|
30
|
+
2. Read the `keystone_ui` version in the app's `Gemfile.lock`. easy_flow's visitor pages pass each answer's info text to Keystone UI's radio cards and checkbox rows and draw a File upload step with Keystone UI's file upload control, and easy_flow is built against `keystone_ui` 0.27.0. Bundler will not install an older one alongside easy_flow, so an app whose `Gemfile.lock` holds an older version has to run `bundle update keystone_ui` when it adds easy_flow. It also accepts `keystone_ui-react` releases only up to 0.6.0, so an app that needs a newer `keystone_ui-react` waits for an easy_flow release that accepts it.
|
|
31
31
|
3. Add `gem "easy_flow"` to the host's `Gemfile` and run `bundle install`.
|
|
32
32
|
4. Run `bin/rails easy_flow:install:migrations`, then `bin/rails db:migrate`. This writes eleven migrations into `db/migrate` and updates `db/schema.rb`.
|
|
33
33
|
5. Ask the developer which hosts the app needs. A host is one part of the app that owns its own set of flows, and one host never sees another's flows. Ask for each host's name and the path it is served under.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: easy_flow
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.49.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tylercschneider
|
|
@@ -37,6 +37,20 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '0.2'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: keystone_ui
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0.27'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0.27'
|
|
40
54
|
- !ruby/object:Gem::Dependency
|
|
41
55
|
name: keystone_ui-react
|
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -44,6 +58,9 @@ dependencies:
|
|
|
44
58
|
- - ">="
|
|
45
59
|
- !ruby/object:Gem::Version
|
|
46
60
|
version: 0.1.2
|
|
61
|
+
- - "<="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: 0.6.0
|
|
47
64
|
type: :runtime
|
|
48
65
|
prerelease: false
|
|
49
66
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -51,6 +68,9 @@ dependencies:
|
|
|
51
68
|
- - ">="
|
|
52
69
|
- !ruby/object:Gem::Version
|
|
53
70
|
version: 0.1.2
|
|
71
|
+
- - "<="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: 0.6.0
|
|
54
74
|
description: EasyFlow stores flows as versioned documents of steps and the connections
|
|
55
75
|
between them, and runs a visitor through the live version one step at a time. Apps
|
|
56
76
|
register their own step types.
|
|
@@ -109,6 +129,7 @@ files:
|
|
|
109
129
|
- app/javascript/easy_flow/canvas/reading.js
|
|
110
130
|
- app/javascript/easy_flow/canvas/rows.js
|
|
111
131
|
- app/javascript/easy_flow/canvas/styles.js
|
|
132
|
+
- app/javascript/easy_flow/canvas/topBar.js
|
|
112
133
|
- app/javascript/easy_flow/canvas/useConnectors.js
|
|
113
134
|
- app/javascript/easy_flow/canvas/useFlow.js
|
|
114
135
|
- app/jobs/easy_flow/advance_parent_job.rb
|