easy_flow 0.44.0 → 0.46.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 064f8dfb5ca6d7730825965a3626d67305d3587076b4fb17f588fceab3d9bd19
4
- data.tar.gz: a5e3f50c22bfd721eae1f6ed3d244f5f82f7d0c71ef7215250c66342da58bccc
3
+ metadata.gz: d2d01ac6719c4ac588b773d40c837a1aa44a8bb11a2ab706b72d4f7ee26e2652
4
+ data.tar.gz: 7b6906ca902c81e673f51565f6587d5419b3f75a22318832e57e14b3fb65bd3f
5
5
  SHA512:
6
- metadata.gz: afb0b6791154182b1b08a1089e9c06bd79f3a75c3d47c52e03032e41fefcde84e6e690f0bbd7776302309c67591ed7c0aa3a098c4da941695d5bec66d506f3ce
7
- data.tar.gz: e77630969b101a2a9b566e6d379becd8f7c1059ee63e0f70b6e9be581317b48fe29b724488dd54a823d28fda38f4167911d6aadc36b5bd5c4adfe736e227e7b6
6
+ metadata.gz: 389df5471ea91af789069085119f692cc5c90cd0e05c96d06bee957ab81039c355f01f44fb3d52378b7e31b0cb607b65fe053d75ae058e3cfc05a79fadc2f9ec
7
+ data.tar.gz: 8ee68d7b39b10980ad9cbacae3f48c838fad7a8f50199b602557d00e29b632263c0a0ce647f3f66c4210f4389d8b7540c272a40a6ee3c73f2de184487e394c7f
@@ -1 +1 @@
1
- (()=>{var Ce=globalThis.ReactDOM;var{createPortal:Zo,createRoot:mt,flushSync:Ro,hydrateRoot:tr,preconnect:er,prefetchDNS:or,preinit:rr,preinitModule:nr,preload:sr,preloadModule:ar,requestFormReset:ir,unstable_batchedUpdates:lr,useFormState:dr,useFormStatus:cr,version:pr}=Ce;var ft=globalThis.React,o=ft,{Children:mr,Component:fr,Fragment:gr,PureComponent:yr,StrictMode:hr,Suspense:xr,cloneElement:br,createContext:vr,createElement:wr,createRef:kr,forwardRef:Sr,isValidElement:Cr,lazy:Nr,memo:zr,startTransition:Br,useCallback:Tr,useContext:_r,useDebugValue:Er,useDeferredValue:Dr,useEffect:I,useId:Or,useImperativeHandle:Ar,useLayoutEffect:gt,useMemo:M,useReducer:Pr,useRef:tt,useState:S,useSyncExternalStore:Lr,useTransition:$r}=ft;var yt=new Map,F=new Map,et=(t,e)=>yt.set(t,e),ht=()=>{F.forEach(t=>t.unmount()),F.clear()},xt=(t,e)=>t.querySelectorAll("[data-react-ui]").forEach(n=>{if(F.has(n))return;let r=yt.get(n.dataset.reactUi),a=e(n);F.set(n,a),a.render(o.createElement(r,JSON.parse(n.dataset.props)))});var bt=(t,e)=>{let n=()=>xt(t,e);t.addEventListener("turbo:load",n),t.addEventListener("turbo:frame-load",n),t.addEventListener("turbo:before-cache",ht),t.readyState==="loading"?t.addEventListener("DOMContentLoaded",n):n()};var _=(...t)=>t.filter(Boolean).join(" ");var Ne={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},ze={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Be=({variant:t="primary",size:e="md",className:n,children:r,...a})=>{let l=a.href?"a":"button";return o.createElement(l,{...a,className:_("ks-button",Ne[t],ze[e],n)},r)},w=Be;var Te="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",_e="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Ee="border border-accent-600 bg-accent-600 text-white",De=({name:t,connected:e,armed:n,onArm:r,connecting:a})=>o.createElement("button",{onClick:l=>{a||(l.stopPropagation(),r(l))},title:n?"Now choose a step to connect to":"Connect this branch",className:n?Ee:e?_e:Te,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},t||"next"),vt=De;var Oe={width:240,boxSizing:"border-box",borderRadius:8},Ae={minWidth:120,boxSizing:"border-box",borderRadius:6},Pe={padding:"8px 14px",textAlign:"center",fontWeight:600},Le={fontWeight:600,lineHeight:1.3},$e={fontSize:12,fontWeight:500,lineHeight:1.3},Ie=(t,e,n)=>{let r=n?"ring-4 ring-accent-600/15":"shadow-sm";return t||n&&!e?`border-accent-600 ${r}`:e?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},Me=(t,e)=>e&&t.label===t.id&&t.type_name||t.label,je=(t,e,n)=>n?e===t.type_name?null:t.type_name:t.type,He=({node:t,selected:e,armed:n,connecting:r,onSelect:a,onOpen:l,onArm:d,onDragEnd:i,onDragStart:p,hideStepTypeCodes:y,branches:b=[],compact:m=!1})=>{let f=t.begins_here||t.ends_here,g=t.begins_here,u=t.ends_here?[]:t.ports,k=r&&!g,v=Me(t,y),C=je(t,v,y);return o.createElement("div",{ref:t.ref,"data-step":t.id,draggable:!g,onDragStart:x=>{x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",t.id),p()},onDragEnd:i,onClick:t.opens&&!r?()=>l(t.opens):a,className:`bg-white ${m&&!e?"border":"border-2"} dark:bg-zinc-900 ${Ie(k,t.violations.length>0,e)}`,style:{...m?Ae:Oe,padding:f?0:m?"8px 10px":"12px 14px",cursor:g?"default":r?"crosshair":"grab"}},!f&&m&&C&&o.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},C),f&&o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:Pe},v),!f&&o.createElement("div",{style:m?$e:Le},v),!f&&!m&&C&&o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},C),t.picture_url&&o.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),t.starts_a_flow&&o.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),t.opens&&o.createElement(w,{variant:"secondary",size:"sm",className:"mt-2",onClick:x=>{x.stopPropagation(),a()}},"Settings"),b.map(x=>o.createElement("div",{key:x,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},x)),t.violations.map(x=>o.createElement("div",{key:x.problem+x.detail,className:"text-red-600 dark:text-red-400",style:{fontSize:11,padding:"0 14px 6px"}},x.sentence)),u.length>0&&o.createElement("div",{style:{padding:t.begins_here?"0 14px 8px":"10px 0 0"}},u.map(x=>o.createElement(vt,{key:x,name:x,connected:t.connected.includes(x),connecting:r,armed:n===x,onArm:B=>d(x,B)}))))},ot=He;var wt={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},We={...wt,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},Fe=({node:t,header:e,onSelect:n,compact:r=!1})=>o.createElement("div",{ref:t.ref,"data-group-header":t.id,onClick:n,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?We:wt,...n?{}:{cursor:"default"}}},e),V=Fe;var Ve=({id:t,bounds:e,onDrop:n})=>o.createElement("div",{"data-group-box":t,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),n()},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",...e}}),kt=Ve;var Ye=t=>t!=null&&t!==""&&typeof t!="object",Ue=["integer","float"],Ge=(t,e,n)=>n&&e.labels?.[t]||t,Y=(t,e,n)=>{let r=Object.keys(e?.fields||{}).filter(a=>Ye(t.config[a])).map(a=>`${Ge(a,e,n)}${Ue.includes(e.fields[a])?"":":"} ${t.config[a]}`);return[n&&t.type_name||t.type,...r].join(" \xB7 ")};var St=(t,e,n)=>{let r=Math.min(...t.map(i=>i.left))-e.left+n.scrollLeft-12,a=Math.min(...t.map(i=>i.top))-e.top+n.scrollTop-10,l=Math.max(...t.map(i=>i.left+i.width))-e.left+n.scrollLeft+12,d=Math.max(...t.map(i=>i.top+i.height))-e.top+n.scrollTop+10;return{left:r,top:a,width:l-r,height:d-a}},Xe=({left:t,top:e,width:n,height:r},a)=>a.x>=t&&a.x<=t+n&&a.y>=e&&a.y<=e+r,Ct=(t,e)=>t.find(n=>Xe(n.bounds,e))?.id||null,Nt=(t,e)=>t.filter(n=>!e.some(r=>r.id===n.source&&r.holds?.includes(n.target))),zt=(t,e)=>e.some(n=>n.holds?.includes(t.id)&&!n.loose&&n.row===t.row-1);var rt=(t,e)=>t.includes(e)?t.filter(n=>n!==e):[...t,e],Bt=(t,e)=>({...e?.choices||{},...t?.choices||{}});var qe=({as:t="input",disabled:e,className:n,...r})=>o.createElement(t,{...r,disabled:e,className:_("ks-input",e&&"ks-input-disabled",n)}),D=qe;var Je=t=>o.createElement(D,{...t,as:"select"}),Tt=Je;var Ke=({className:t,...e})=>o.createElement("input",{type:"checkbox",...e,className:_("ks-checkbox",t)}),U=Ke;var _t=t=>(t||[]).map(e=>typeof e=="object"?e:{value:e,label:e}),Qe=({type:t,value:e,choices:n,onChange:r,onSettle:a,onPick:l,pictureUrl:d})=>{if(t==="picture")return o.createElement("div",{className:"mb-3"},e&&d&&o.createElement("img",{src:d,alt:"The step's picture",style:{maxWidth:"100%"}}),e&&o.createElement("button",{type:"button","data-remove-picture":!0,className:"ks-button ks-button-secondary ks-button-sm",onClick:()=>a("")},"Remove picture"),o.createElement("input",{type:"file",accept:"image/*",onChange:i=>i.target.files[0]&&l(i.target.files[0])}));if(t==="boolean")return o.createElement(U,{checked:!!e,onChange:i=>a(i.target.checked)});if(t==="select"||t==="previous_step"||t==="from_step"||t==="flow")return o.createElement(Tt,{className:"mb-3",value:e??"",onChange:i=>a(i.target.value)},o.createElement("option",{value:""}),_t(n).map(i=>o.createElement("option",{key:i.value,value:i.value},i.label)));if(t==="multi_select"){let i=Array.isArray(e)?e:[],p=y=>a(rt(i,y));return o.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(n||[]).map(y=>o.createElement("label",{key:y,style:{display:"inline-flex",alignItems:"center",gap:4}},o.createElement(U,{checked:i.includes(y),onChange:()=>p(y)}),o.createElement("span",null,y))))}if(t==="flows"){let i=Array.isArray(e)?e:[];return o.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},_t(n).map(p=>o.createElement("label",{key:p.value,style:{display:"inline-flex",alignItems:"center",gap:4}},o.createElement(U,{checked:i.includes(p.value),onChange:()=>a(rt(i,p.value))}),o.createElement("span",null,p.label))))}return t==="integer"||t==="float"?o.createElement(D,{className:"mb-3",type:"number",step:t==="integer"?"1":"any",value:e??"",onChange:i=>r(i.target.value),onBlur:i=>a(i.target.value)}):o.createElement(D,{className:"mb-3",type:"text",value:e??"",onChange:i=>r(i.target.value),onBlur:i=>a(i.target.value)})},G=Qe;var Et=(t,e,n,r)=>t.map((a,l)=>l===e?{...a,[n]:r}:a);var Ze=({text:t})=>o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},t),X=Ze;var Re=(t,e,n,r)=>{let a=(t||{})[n],l=(e||{})[n];return l?(a||{})[r[l]]:a},to=({holds:t,labels:e,explanations:n,rows:r,choices:a,outputsOf:l,onChange:d,onSettle:i})=>{let p=Array.isArray(r)?r:[],y=(b,m,f,g)=>{let u=Et(p,b,m,f);g?i(u):d(u)};return o.createElement("div",{style:{marginBottom:12}},p.map((b,m)=>o.createElement("div",{key:m,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(t).map(([f,g])=>o.createElement("label",{key:f,style:{display:"block"}},o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(e||{})[f]||f),o.createElement(G,{type:g,value:b[f],choices:Re(a,l,f,b),onChange:u=>y(m,f,u,!1),onSettle:u=>y(m,f,u,!0)}),(n||{})[f]&&o.createElement(X,{text:n[f]}))),o.createElement(w,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>i(p.filter((f,g)=>g!==m))},"Remove"))),o.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>i([...p,{}])},"Add"))},Dt=to;var eo=({as:t="div",className:e,children:n,...r})=>o.createElement(t,{...r,className:_("ks-panel",e)},n),P=eo;var q=(t,e)=>({className:n,children:r,...a})=>o.createElement(t,{...a,className:_(e,n)},r),W=q("label","ks-label"),In=q("p","ks-hint"),Mn=q("p","ks-error"),jn=q("span","ks-required");var oo={width:280,padding:20,overflowY:"auto"},ro=({node:t,fields:e,holds:n,labels:r,explanations:a,recordLabels:l,recordExplanations:d,recordChoices:i,recordOutputsOf:p,choices:y,onSave:b,onDelete:m,onClose:f,onPickPicture:g,refusal:u})=>{let[k,v]=S(t.config),[C,x]=S(t.picture_url);I(()=>x(t.picture_url),[t.id,t.picture_url]),I(()=>v(t.config),[t.id,t.config]);let B=h=>{v(h),JSON.stringify(h)!==JSON.stringify(t.config)&&b(h)};return o.createElement(P,{as:"aside",style:oo,"data-inspector":!0},o.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},o.createElement("h2",{style:{fontWeight:600,marginBottom:2}},t.label),o.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")),o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:16}},t.id," \xB7 ",t.type),u&&o.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},u),Object.entries(e).map(([h,O])=>o.createElement(W,{key:h},o.createElement("span",{style:{display:"block",marginBottom:3}},r[h]||h),O==="list"?o.createElement(Dt,{holds:n[h]||{},labels:l[h]||{},explanations:(d||{})[h],rows:k[h],choices:{...(i||{})[h],...(t.record_choices||{})[h]},outputsOf:(p||{})[h],onChange:N=>v({...k,[h]:N}),onSettle:N=>B({...k,[h]:N})}):o.createElement(G,{type:O,value:k[h],choices:y[h],pictureUrl:C,onChange:N=>v({...k,[h]:N}),onSettle:N=>B({...k,[h]:N}),onPick:async N=>{let T=await g(N);T&&(x(T.url),B({...k,[h]:T.reference}))}}),(a||{})[h]&&o.createElement(X,{text:a[h]}))),o.createElement(w,{variant:"danger",size:"sm",className:"w-full",onClick:m},"Delete step"))},Ot=ro;var no={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},so={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},ao="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",io="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",lo=({node:t,dragging:e,onFill:n,onDrop:r,compact:a=!1})=>o.createElement("div",{ref:t.ref,"data-placeholder":t.id,title:`Choose the step \u201C${t.label}\u201D should lead to`,onClick:n,onDragOver:l=>{e&&(l.preventDefault(),l.dataTransfer.dropEffect="move")},onDrop:l=>{l.preventDefault(),r()},className:e?io:ao,style:a?so:no},o.createElement("div",{style:{fontWeight:600}},t.label),o.createElement("div",{style:{fontSize:11}},e?"drop a step here":"leads nowhere yet \u2014 click to choose")),At=lo;var co=({entries:t,at:e,onPick:n,onConnect:r,onDismiss:a,hideStepTypeCodes:l})=>o.createElement(P,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:e.y,left:e.x,width:210,padding:8,borderRadius:8}},o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),t.map(d=>o.createElement(w,{key:d.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>n(d)},d.label,!l&&o.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},d.type))),r&&o.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),o.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:a},"Cancel")),Pt=co;var po=t=>e=>e.label.toLowerCase().includes(t.trim().toLowerCase()),uo=(t,e,n="")=>{let r=Object.values(e).flat(),a=Object.entries(e).map(([l,d])=>({heading:l,entries:d.map(i=>t.find(p=>p.type===i)).filter(Boolean)}));return[{heading:null,entries:t.filter(l=>!r.includes(l.type))},...a].map(l=>({...l,entries:l.entries.filter(po(n))})).filter(l=>l.entries.length>0)},mo={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},fo={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},go={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},yo=({entries:t,groups:e,onPick:n,onCarry:r,onDrop:a})=>{let[l,d]=S("");return o.createElement(P,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:mo},o.createElement(D,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:l,onChange:i=>d(i.target.value),style:{marginBottom:6,fontSize:12}}),uo(t,e,l).map(i=>o.createElement(o.Fragment,{key:i.heading||""},i.heading&&o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:fo},i.heading),i.entries.map(p=>o.createElement(P,{as:"button",type:"button",key:p.type,"data-step-type":p.type,className:"bg-surface-50 dark:bg-surface-950",style:go,draggable:!0,onClick:()=>n(p),onDragStart:y=>{y.dataTransfer.effectAllowed="copyMove",y.dataTransfer.setData("text/plain",p.type),r(p)},onDragEnd:a},p.label)))))},Lt=yo;var ho={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},$t=({label:t,title:e,idle:n,enabled:r,onUse:a})=>o.createElement(w,{variant:"secondary",size:"sm",title:r?e:n,disabled:!r,onClick:a,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},t),xo=({undoable:t,redoable:e,onAdd:n,onUndo:r,onRedo:a})=>o.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},o.createElement(w,{variant:"secondary",className:"rounded-full",style:ho,title:"Add a step",onClick:n},"+"),o.createElement($t,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:t,onUse:r}),o.createElement($t,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:e,onUse:a})),It=xo;var bo=({type:t="info",title:e,message:n,onDismiss:r,className:a})=>o.createElement("div",{className:_("ks-alert",`ks-alert-${t}`,a),role:"alert"},o.createElement("div",{className:"ks-alert-body"},o.createElement("div",{className:"ks-alert-content"},e&&o.createElement("p",{className:"ks-alert-title"},e),o.createElement("p",{className:e?"ks-alert-message-titled":"ks-alert-message"},n)),r&&o.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),Mt=bo;var jt=t=>{let e=t.map(n=>`\u201C${n.name}\u201D`).join(", ");return t.length===1?`${e} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${e} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var Ht=({version:t,published:e})=>t?e?e===t?`Version ${t} \xB7 live`:`Version ${t} \xB7 visitors still on ${e}`:`Version ${t} \xB7 never published`:"No version yet";var vo={width:280,padding:20,overflowY:"auto"},nt={fontWeight:600,marginBottom:6,marginTop:14},J={fontSize:12,marginBottom:4,lineHeight:1.4},Wt={display:"block",marginBottom:3},Ft=(t,e,n)=>r=>{r.target.value!==(t[e]??"")&&n({[e]:r.target.value})},wo=({flow:t,changes:e,problems:n,refusal:r,notice:a,publishNote:l,warning:d,onCreate:i,onPublish:p,onAccept:y,onDecline:b,onSaveDetails:m,onClose:f})=>o.createElement(P,{as:"aside",style:vo,"data-builder-panel":!0},o.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},o.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},t.title||t.slug),o.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")),o.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:t.history_url,"data-history":!0},Ht(t)),d?o.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},o.createElement(Mt,{type:"warning",className:"mb-1.5",message:jt(d.steps)}),o.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:y,"data-accept-removal":!0},d.path==="/publish"?"Remove and publish":"Remove and create version"),o.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:b,"data-decline-removal":!0},"Cancel")):o.createElement("div",{style:{marginTop:14}},o.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:i,"data-create-version":!0},"Create version"),o.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:p,"data-publish":!0},"Publish"),l&&o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},l)),o.createElement("h2",{style:nt},"Problems"),r&&o.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...J,fontWeight:600},"data-refusal":!0},r),a&&!r&&o.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...J,fontWeight:600},"data-notice":!0},a),n.length===0&&!r?o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing wrong with this flow."):n.map(g=>o.createElement("p",{key:`${g.node}-${g.problem}`,className:"text-amber-700 dark:text-amber-400",style:J,"data-problem":!0},"\u26A0 ",g.sentence)),o.createElement("h2",{style:nt},"Changes since the last version"),e.length===0?o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):e.map((g,u)=>o.createElement("p",{key:u,style:J,"data-change":!0},g)),o.createElement("h2",{style:nt},"Details"),o.createElement(W,null,o.createElement("span",{style:Wt},"Title"),o.createElement(D,{className:"mb-3",defaultValue:t.title??"",onBlur:Ft(t,"title",m),"data-flow-title":!0})),o.createElement(W,null,o.createElement("span",{style:Wt},"Start label"),o.createElement(D,{className:"mb-3",defaultValue:t.start_label??"",onBlur:Ft(t,"start_label",m),"data-flow-start-label":!0})),o.createElement("div",{style:{marginTop:16}},o.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.definition_url,"data-definition":!0},"Definition"),o.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.details_url,"data-details":!0},"Edit details"))),Vt=wo;var Yt={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Ut=t=>({opacity:t?1:0,transition:"opacity .12s"}),ko=({link:t,onInsert:e,onRemove:n,onDrop:r,dragging:a,alwaysShowInsertButtons:l})=>{let[d,i]=S(!1),p=d||a;return o.createElement("div",{"data-connector":`${t.source}-${t.target}`,style:{position:"absolute",left:t.midX-34,top:t.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDragOver:y=>{y.preventDefault(),y.dataTransfer.dropEffect="move"},onDrop:y=>{y.preventDefault(),i(!1),r()}},o.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},o.createElement(w,{variant:"secondary",title:a?"Move the step here":"Insert a step here",onClick:e,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(a&&d),style:{...Yt,...Ut(p||l)}},"+"),!a&&o.createElement(w,{variant:"danger",title:"Remove this connection",onClick:n,className:"rounded-full",style:{...Yt,...Ut(p)}},"\xD7")))},Gt=ko;var So=({links:t,extent:e,dragging:n,onInsert:r,onRemove:a,onDrop:l,alwaysShowInsertButtons:d})=>o.createElement(o.Fragment,null,o.createElement("svg",{width:e.width,height:e.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},o.createElement("defs",null,o.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},o.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),t.map(i=>o.createElement("path",{key:i.id,"data-link":i.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:i.path}))),t.filter(i=>i.label).map(i=>o.createElement("div",{key:`${i.id}-label`,"data-link-label":i.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:i.midX+(d?2:-10),top:i.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},i.label)),t.filter(i=>!i.placeholder).map(i=>o.createElement(Gt,{key:i.id,link:i,dragging:!!n,alwaysShowInsertButtons:d,onInsert:()=>r(i),onRemove:()=>a(i),onDrop:()=>l(i)}))),Xt=So;var st={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},qt="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Co=({link:t,onInsert:e,onRemove:n,onDrop:r,alwaysShowInsertButtons:a,dragging:l})=>o.createElement("div",{"data-joint":t?.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=>{t&&r&&(d.preventDefault(),d.dataTransfer.dropEffect="move")},onDrop:d=>{t&&(d.preventDefault(),r(t))}},t&&o.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"}),t&&e&&o.createElement("div",{className:"absolute inset-0 flex items-center justify-center gap-1 sm:flex-col",style:{zIndex:4}},o.createElement(w,{variant:"secondary",title:"Insert a step here",onClick:d=>e(t,d),className:`rounded-full ${a?"opacity-100":qt}`,style:l?{...st,opacity:1}:st},"+"),o.createElement(w,{variant:"danger",title:"Remove this connection",onClick:()=>n(t),className:`rounded-full ${qt}`,style:st},"\xD7"))),Jt=Co;var No=(t,e)=>t.row-e.row||t.column-e.column,Kt=t=>{let e=[...t].sort(No),n=e.filter(r=>t.some(a=>a.holds?.includes(r.id)));return e.filter(r=>!n.includes(r)).flatMap(r=>[r,...n.filter(a=>r.holds?.includes(a.id))])},Qt=t=>{let e=Kt(t),n=r=>e.some(a=>a.holds?.includes(r.id));return e.filter(r=>!n(r)).reduce((r,a)=>{if(a.holds)return[...r,{group:a,steps:e.filter(d=>a.holds.includes(d.id))}];let l=r[r.length-1];return l&&!l.group?[...r.slice(0,-1),{steps:[...l.steps,a]}]:[...r,{steps:[a]}]},[])},zo=(t,e)=>t[t.findIndex(n=>n.id===e.id)+1]?.id,Zt=(t,e,n)=>{let r=zo(Kt(n),t);return e.filter(a=>a.source===t.id&&(a.label||a.target!==r))},Bo=t=>t?.placeholder?"nowhere yet":t?.label,Rt=(t,e)=>[t.label,"\u2192",Bo(e.find(n=>n.id===t.target))].filter(Boolean).join(" "),te=(t,e,n)=>t.find(r=>r.source===e.id&&r.target===n.id);var To={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},ee=({steps:t,edges:e,draw:n,joints:r})=>o.createElement("div",{"data-flow-row":!0,className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5"},t.map((a,l)=>o.createElement("div",{key:a.id,className:"flex flex-col sm:flex-row sm:items-center"},l>0&&o.createElement(Jt,{link:te(e,t[l-1],a),...r}),n(a)))),_o={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},Eo=({group:t,steps:e,edges:n,draw:r,joints:a})=>o.createElement("div",{"data-group-box":t.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:_o},r(t),o.createElement(ee,{steps:e,edges:n,draw:r,joints:a})),Do=({nodes:t,edges:e,draw:n,joints:r,children:a,style:l})=>o.createElement("div",{"data-flow-rows":!0,style:{...To,...l}},a,Qt(t).map(d=>d.group?o.createElement(Eo,{key:d.group.id,group:d.group,steps:d.steps,edges:e,draw:n,joints:r}):o.createElement(ee,{key:d.steps[0].id,steps:d.steps,edges:e,draw:n,joints:r}))),K=Do;var oe="Your change was not saved because the server could not be reached.",re=({base:t,token:e,fetch:n,onFlow:r,onError:a,onNotice:l,onWarning:d=()=>{}})=>async(i,p,y)=>{let b=await n(t+i,{method:p,headers:{"Content-Type":"application/json","X-CSRF-Token":e},body:y&&JSON.stringify(y)}).catch(()=>null);if(!b)return l(null),a(oe);let m=await b.json().catch(()=>({}));if(m.unconnected)return l(null),a(null),d({path:i,steps:m.unconnected}),r(await(await n(t+".json",{headers:{Accept:"application/json"}})).json());if(d(null),!b.ok)return l(null),a(m.error||"That change was refused");a(null),l(m.notice||null),r(await(await n(t+".json",{headers:{Accept:"application/json"}})).json())},ne=({base:t,token:e,fetch:n,onError:r})=>async a=>{let l=new FormData;l.append("picture",a);let d=await n(t+"/pictures",{method:"POST",headers:{"X-CSRF-Token":e},body:l}).catch(()=>null);if(!d)return r(oe),null;let i=await d.json().catch(()=>({}));return d.ok?(r(null),i):(r(i.error||"That picture was refused"),null)};var Oo=(t,e,n)=>{let[r,a]=S(n),[l,d]=S(null),[i,p]=S(null),[y,b]=S(null),m=M(()=>re({base:t,token:e,fetch:(...g)=>window.fetch(...g),onFlow:a,onError:d,onNotice:p,onWarning:b}),[t,e]),f=M(()=>ne({base:t,token:e,fetch:(...g)=>window.fetch(...g),onError:d}),[t,e]);return{flow:r,error:l,notice:i,warning:y,setWarning:b,send:m,pickPicture:f}},se=Oo;var Q=(t,e,n,r)=>{let a=t.left-n.left+r.scrollLeft,l=t.top-n.top+r.scrollTop;return e==="left"?{x:a,y:l+t.height/2}:e==="right"?{x:a+t.width,y:l+t.height/2}:e==="top"?{x:a+t.width/2,y:l}:{x:a+t.width/2,y:l+t.height}},Ao=(t,e,n)=>n&&e==="top"?{x:t.x,y:n.top}:t,Po=(t,e)=>e==="top"?{x:t.x,y:t.y-3}:e==="left"?{x:t.x-3,y:t.y}:e==="right"?{x:t.x+3,y:t.y}:{x:t.x,y:t.y+3},Lo=(t,e,n,r,a)=>{let l={straight:`M ${e.x} ${e.y} L ${n.x} ${n.y}`,turn:`M ${e.x} ${e.y} H ${n.x} V ${n.y}`,lane:`M ${e.x} ${e.y} V ${r} H ${n.x} V ${n.y}`,detour:`M ${e.x} ${e.y} H ${a} V ${n.y} H ${n.x}`}[t.route];return{...t,path:l,midX:t.route==="detour"?a:(e.x+n.x)/2,midY:t.route==="lane"?r:(e.y+n.y)/2}},$o=(t,e,n,r)=>{let[a,l]=S([]),[d,i]=S({width:"100%",height:"100%"}),[p,y]=S([]);return gt(()=>{let b=()=>{let f=e.current?.getBoundingClientRect();if(!f)return;i({width:e.current.scrollWidth,height:e.current.scrollHeight});let g=t.nodes.filter(u=>u.holds&&!u.loose&&n.current[u.id]).map(u=>{let k=n.current[u.id],v=k.getBoundingClientRect(),C=u.holds.flatMap(B=>n.current[B]?[n.current[B].getBoundingClientRect()]:[]),x=[{left:v.left,top:v.top,width:Math.max(v.width,k.scrollWidth),height:v.height},...C];return{id:u.id,bounds:St(x,f,e.current)}});y(g),l(t.edges.flatMap(u=>{let k=n.current[u.source]?.getBoundingClientRect(),v=n.current[u.target]?.getBoundingClientRect();if(!k||!v)return[];let C=Q(k,u.leaves,f,e.current),x=g.find(N=>N.id===u.target)?.bounds,B=Po(Ao(Q(v,u.enters,f,e.current),u.enters,x),u.enters),h=(Q(k,"bottom",f,e.current).y+Q(v,"top",f,e.current).y)/2,O=u.leaves==="left"?Math.min(C.x,B.x)-28:Math.max(C.x,B.x)+28;return[Lo(u,C,B,h,O)]}))};b(),window.addEventListener("resize",b);let m=new ResizeObserver(b);return e.current&&m.observe(e.current),()=>{window.removeEventListener("resize",b),m.disconnect()}},r),{links:a,extent:d,boxes:p}},ae=$o;var ie=(t,e)=>{let n=new Set(e),r=t,a=2;for(;n.has(r);)r=`${t}_${a++}`;return r};var Mo=8,jo={display:"flex",height:"100%",minHeight:0,fontSize:13},Ho={flex:1,overflow:"auto",position:"relative"},de={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},Wo={...de,position:"static",alignSelf:"flex-start"},Fo={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Vo={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Yo=({port:t,onCancel:e})=>o.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Vo},"Choose the step \u201C",t||"next","\u201D should lead to \u2014 ",o.createElement("button",{onClick:e,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),Uo=({base:t,token:e,initial:n})=>{let{flow:r,error:a,notice:l,warning:d,setWarning:i,send:p,pickPicture:y}=se(t,e,n),[b,m]=S(null),[f,g]=S(null),[u,k]=S(null),[v,C]=S(null),[x,B]=S(null),[h,O]=S(!1),N=tt({}),T=tt(null);I(()=>{let s=()=>{m(null),O(!0)};return document.addEventListener("easy_flow:open-flow",s),()=>document.removeEventListener("easy_flow:open-flow",s)},[]),I(()=>{if(!h){i(null);return}let s=c=>{c.target.isConnected&&!c.target.closest("[data-builder-panel], [data-open-panel]")&&O(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[h]),I(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]);let ge=M(()=>Object.fromEntries(r.nodes.map(s=>[s.id,s])),[r.nodes]),{links:ye,extent:he,boxes:at}=ae(r,T,N,[r,b,ge]),it=M(()=>{let s={};return r.violations.forEach(c=>{var z;return(s[z=c.node]||(s[z]=[])).push(c)}),s},[r.violations]),E=r.direction==="left_to_right",j=r.nodes.filter(s=>!s.loose),lt=r.nodes.filter(s=>s.loose),xe=Math.max(0,...j.map(s=>s.row))+1,be=Math.max(0,...j.map(s=>s.column))+1,Z=s=>{if(!u)return;let[c,z]=u;k(null),c!==s&&p("/edges","POST",{from:c,to:s,on:z||null})},ve=s=>{if(s.isDefaultPrevented()||!v)return;s.preventDefault();let c=v;C(null);let z=T.current.getBoundingClientRect(),H=Ct(at,{x:s.clientX-z.left+T.current.scrollLeft,y:s.clientY-z.top+T.current.scrollTop}),ke=r.nodes.find(Se=>Se.holds?.includes(c))?.id||null;H!==ke&&p(`/steps/${c}/group`,"PATCH",{group:H})},dt=s=>[...r.palette,...r.unoffered||[]].find(c=>c.type===s?.type),$=r.nodes.find(s=>s.id===b),A=dt($),R=(s,c={})=>p("/steps","POST",{id:ie(s.type,r.nodes.map(z=>z.id)),type:s.type,from:c.from,to:c.to,on:c.on}),ct=s=>{let[c,z]=[x,v];B(null),C(null),c?R(c,{from:s.source,to:s.target}):z&&p("/steps/"+z+"/move","PATCH",{from:s.source,to:s.target})},we=s=>{let c=T.current.getBoundingClientRect();return{x:s.clientX-c.left+T.current.scrollLeft+8,y:s.clientY-c.top+T.current.scrollTop+8}},pt=s=>o.createElement(o.Fragment,null,s.placeholder&&o.createElement(At,{node:{...s,ref:c=>{N.current[s.id]=c}},dragging:!!v,compact:E,onFill:()=>g({from:s.from,on:s.on,at:{x:16,y:52}}),onDrop:()=>{let c=v;C(null),c&&p("/edges","POST",{from:s.from,to:c,on:s.on})}}),s.holds&&o.createElement(V,{node:{...s,ref:c=>{N.current[s.id]=c}},header:Y(s,dt(s),r.hide_step_type_codes),compact:E,onSelect:()=>u?Z(s.id):m(s.id)}),!s.placeholder&&!s.holds&&o.createElement(ot,{node:{...s,ref:c=>{N.current[s.id]=c},violations:it[s.id]||[],connected:r.edges.filter(c=>c.source===s.id).map(c=>c.label||null)},selected:s.id===b,armed:u&&u[0]===s.id?u[1]:null,connecting:!!u&&u[0]!==s.id,onSelect:()=>u?Z(s.id):m(s.id),onOpen:c=>window.location.assign(c),onArm:(c,z)=>{let H=T.current.getBoundingClientRect();g({from:s.id,on:c,at:{x:z.clientX-H.left+T.current.scrollLeft+8,y:z.clientY-H.top+T.current.scrollTop+8}})},onDragEnd:()=>C(null),onDragStart:()=>C(s.id),hideStepTypeCodes:r.hide_step_type_codes,compact:E,branches:E?Zt(s,r.edges,j).map(c=>Rt(c,r.nodes)):[]})),ut=lt.length>0&&o.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:E?Wo:de},o.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"),lt.map(s=>o.createElement("div",{key:s.id,style:{marginBottom:8}},o.createElement(ot,{node:{...s,ref:c=>{N.current[s.id]=c},violations:it[s.id]||[],connected:[]},selected:b===s.id,armed:u&&u[0]===s.id?u[1]:null,connecting:!!u,onSelect:()=>u?Z(s.id):m(s.id),onOpen:c=>window.location.assign(c),onArm:(c,z)=>{z.stopPropagation(),k([s.id,c])},onDragStart:()=>C(s.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes}))));return o.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:jo,onMouseUp:()=>C(null),onKeyDown:s=>{s.key==="Escape"&&(m(null),k(null),g(null))},tabIndex:-1},o.createElement(Lt,{entries:r.palette,groups:r.step_groups||{},onPick:s=>R(s),onCarry:B,onDrop:()=>B(null)}),o.createElement("div",{ref:T,className:"bg-surface-50 dark:bg-surface-950",style:Ho,onClick:s=>{s.target===T.current&&(m(null),k(null),O(!1))},onDragOver:s=>{v&&s.preventDefault()},onDrop:ve},u&&o.createElement(Yo,{port:u[1],onCancel:()=>k(null)}),o.createElement(It,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>g({at:{x:16,y:52}}),onUndo:()=>{m(null),p("/undo","POST")},onRedo:()=>{m(null),p("/redo","POST")}}),!E&&at.map(s=>o.createElement(kt,{key:s.id,id:s.id,bounds:s.bounds,onDrop:()=>{let c=v;C(null),c&&p(`/steps/${c}/group`,"PATCH",{group:s.id})}})),!E&&o.createElement(Xt,{links:Nt(ye,r.nodes),extent:he,dragging:v||x,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:s=>g({from:s.source,to:s.target,at:{x:s.midX+30,y:s.midY}}),onRemove:s=>{m(null),p("/edges","DELETE",{from:s.source,to:s.target})},onDrop:ct}),!E&&ut,E&&o.createElement(K,{nodes:j,edges:r.edges,draw:pt,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(v||x),onInsert:(s,c)=>g({from:s.source,to:s.target,at:we(c)}),onRemove:s=>{m(null),p("/edges","DELETE",{from:s.source,to:s.target})},onDrop:ct}},ut),!E&&o.createElement("div",{style:{...Fo,gridTemplateColumns:`repeat(${be+1}, ${280/2}px)`,gridTemplateRows:`repeat(${xe}, auto)`}},j.map(s=>o.createElement("div",{key:s.id,style:{gridRow:s.row+1,gridColumn:`${s.column+1} / span 2`,zIndex:2,marginTop:zt(s,r.nodes)?Mo-64:0}},pt(s)))),f&&o.createElement(Pt,{entries:r.palette,at:f.at,onDismiss:()=>g(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:f.on!==void 0?()=>{k([f.from,f.on]),g(null)}:null,onPick:s=>{let c=f;g(null),R(s,c)}})),h&&!$&&o.createElement(Vt,{flow:r.flow||{},changes:r.changes||[],problems:r.violations,refusal:a,notice:l,publishNote:r.publish_note,warning:d,onClose:()=>O(!1),onCreate:()=>p("/versions","POST"),onPublish:()=>p("/publish","POST"),onAccept:()=>p(d.path,"POST",{remove_unconnected:d.steps.map(s=>s.id)}),onDecline:()=>i(null),onSaveDetails:s=>p("/details","PATCH",{flow:s})}),$&&o.createElement(Ot,{node:$,fields:A?.fields||{},holds:A?.records||{},labels:A?.labels||{},explanations:A?.explanations||{},recordLabels:A?.record_labels||{},recordExplanations:A?.record_explanations||{},recordChoices:A?.record_choices||{},recordOutputsOf:A?.record_outputs_of||{},choices:Bt($,A),onClose:()=>m(null),onSave:s=>p(`/steps/${$.id}`,"PATCH",{config:s}),onPickPicture:y,refusal:a,onDelete:()=>{m(null),p(`/steps/${$.id}`,"DELETE")}}))},ce=Uo;var Go={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Xo={fontSize:12,fontWeight:500,lineHeight:1.3},pe={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"},ue={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"},qo="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Jo=({node:t,selected:e=!1})=>{let n=t.address?"a":"div";return o.createElement(n,{"data-step":t.id,href:t.address||void 0,className:`${t.state==="paused"?"border-2":"border"} ${pe[t.state]||pe.pending}${e?` ${qo}`:""}`,style:Go},o.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.type),o.createElement("div",{style:Xo},t.label,t.version&&o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},t.version)),t.status&&o.createElement("div",{className:ue[t.state]||ue.pending,style:{fontSize:11}},t.status))},me=Jo;var Ko={gap:12,padding:0},Qo=({nodes:t,edges:e,selected:n})=>o.createElement(K,{nodes:t,edges:e,joints:{},style:Ko,draw:r=>r.holds?o.createElement(V,{node:r,header:Y(r,r,!1),compact:!0}):o.createElement(me,{node:r,selected:r.id===n})}),fe=Qo;et("easy_flow/flow-editor",ce);et("easy_flow/run-view",fe);document.addEventListener("easy_flow:flow-named",t=>{let e=document.querySelector("[data-flow-heading]");e&&(e.textContent=t.detail)});bt(document,mt);})();
1
+ (()=>{var Ce=globalThis.ReactDOM;var{createPortal:Zo,createRoot:ft,flushSync:Ro,hydrateRoot:tr,preconnect:er,prefetchDNS:or,preinit:rr,preinitModule:nr,preload:sr,preloadModule:ar,requestFormReset:ir,unstable_batchedUpdates:lr,useFormState:dr,useFormStatus:cr,version:pr}=Ce;var gt=globalThis.React,o=gt,{Children:mr,Component:fr,Fragment:gr,PureComponent:hr,StrictMode:yr,Suspense:xr,cloneElement:br,createContext:vr,createElement:wr,createRef:kr,forwardRef:Sr,isValidElement:Cr,lazy:Nr,memo:zr,startTransition:Br,useCallback:Tr,useContext:Er,useDebugValue:_r,useDeferredValue:Dr,useEffect:L,useId:Ar,useImperativeHandle:Or,useLayoutEffect:ht,useMemo:j,useReducer:Pr,useRef:et,useState:S,useSyncExternalStore:$r,useTransition:Lr}=gt;var yt=new Map,V=new Map,ot=(t,e)=>yt.set(t,e),xt=()=>{V.forEach(t=>t.unmount()),V.clear()},bt=(t,e)=>t.querySelectorAll("[data-react-ui]").forEach(n=>{if(V.has(n))return;let r=yt.get(n.dataset.reactUi),a=e(n);V.set(n,a),a.render(o.createElement(r,JSON.parse(n.dataset.props)))});var vt=(t,e)=>{let n=()=>bt(t,e);t.addEventListener("turbo:load",n),t.addEventListener("turbo:frame-load",n),t.addEventListener("turbo:before-cache",xt),t.readyState==="loading"?t.addEventListener("DOMContentLoaded",n):n()};var E=(...t)=>t.filter(Boolean).join(" ");var Ne={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},ze={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Be=({variant:t="primary",size:e="md",className:n,children:r,...a})=>{let l=a.href?"a":"button";return o.createElement(l,{...a,className:E("ks-button",Ne[t],ze[e],n)},r)},v=Be;var Te="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Ee="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",_e="border border-accent-600 bg-accent-600 text-white",De=({name:t,connected:e,armed:n,onArm:r,connecting:a})=>o.createElement("button",{onClick:l=>{a||(l.stopPropagation(),r(l))},title:n?"Now choose a step to connect to":"Connect this branch",className:n?_e:e?Ee:Te,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},t||"next"),wt=De;var Ae={width:240,boxSizing:"border-box",borderRadius:8},Oe={minWidth:120,boxSizing:"border-box",borderRadius:6},Pe={padding:"8px 14px",textAlign:"center",fontWeight:600},$e={fontWeight:600,lineHeight:1.3},Le={fontSize:12,fontWeight:500,lineHeight:1.3},Ie=(t,e,n)=>{let r=n?"ring-4 ring-accent-600/15":"shadow-sm";return t||n&&!e?`border-accent-600 ${r}`:e?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},Me=(t,e)=>e&&t.label===t.id&&t.type_name||t.label,je=(t,e,n)=>n?e===t.type_name?null:t.type_name:t.type,He=({node:t,selected:e,armed:n,connecting:r,onSelect:a,onOpen:l,onArm:d,onDragEnd:i,onDragStart:p,hideStepTypeCodes:h,branches:b=[],compact:m=!1,typeAbove:g=m})=>{let f=t.begins_here||t.ends_here,u=t.begins_here,k=t.ends_here?[]:t.ports,w=r&&!u,C=Me(t,h),T=je(t,C,h);return o.createElement("div",{ref:t.ref,"data-step":t.id,draggable:!u,onDragStart:x=>{x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",t.id),p()},onDragEnd:i,onClick:t.opens&&!r?()=>l(t.opens):a,className:`bg-white ${m&&!e?"border":"border-2"} dark:bg-zinc-900 ${Ie(w,t.violations.length>0,e)}`,style:{...m?Oe:Ae,padding:f?0:m?"8px 10px":"12px 14px",cursor:u?"default":r?"crosshair":"grab"}},!f&&g&&T&&o.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},T),f&&o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:Pe},C),!f&&o.createElement("div",{style:m?Le:$e},C),t.violations.length>0&&o.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${t.violations.length} error${t.violations.length===1?"":"s"}`),!f&&t.summary&&t.violations.length===0&&o.createElement("div",{className:e?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},t.summary),!f&&!g&&T&&o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},T),t.picture_url&&o.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),t.starts_a_flow&&o.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),t.opens&&o.createElement(v,{variant:"secondary",size:"sm",className:"mt-2",onClick:x=>{x.stopPropagation(),a()}},"Settings"),b.map(x=>o.createElement("div",{key:x,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},x)),k.length>0&&o.createElement("div",{style:{padding:t.begins_here?"0 14px 8px":"10px 0 0"}},k.map(x=>o.createElement(wt,{key:x,name:x,connected:t.connected.includes(x),connecting:r,armed:n===x,onArm:y=>d(x,y)}))))},rt=He;var kt={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},We={...kt,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},Fe=({node:t,header:e,onSelect:n,compact:r=!1})=>o.createElement("div",{ref:t.ref,"data-group-header":t.id,onClick:n,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?We:kt,...n?{}:{cursor:"default"}}},e),Y=Fe;var Ve=({id:t,bounds:e,onDrop:n})=>o.createElement("div",{"data-group-box":t,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),n()},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",...e}}),St=Ve;var Ye=t=>t!=null&&t!==""&&typeof t!="object",Ue=["integer","float"],Ge=(t,e,n)=>n&&e.labels?.[t]||t,U=(t,e,n)=>{let r=Object.keys(e?.fields||{}).filter(a=>Ye(t.config[a])).map(a=>`${Ge(a,e,n)}${Ue.includes(e.fields[a])?"":":"} ${t.config[a]}`);return[n&&t.type_name||t.type,...r].join(" \xB7 ")};var Ct=(t,e,n)=>{let r=Math.min(...t.map(i=>i.left))-e.left+n.scrollLeft-12,a=Math.min(...t.map(i=>i.top))-e.top+n.scrollTop-10,l=Math.max(...t.map(i=>i.left+i.width))-e.left+n.scrollLeft+12,d=Math.max(...t.map(i=>i.top+i.height))-e.top+n.scrollTop+10;return{left:r,top:a,width:l-r,height:d-a}},Xe=({left:t,top:e,width:n,height:r},a)=>a.x>=t&&a.x<=t+n&&a.y>=e&&a.y<=e+r,Nt=(t,e)=>t.find(n=>Xe(n.bounds,e))?.id||null,zt=(t,e)=>t.filter(n=>!e.some(r=>r.id===n.source&&r.holds?.includes(n.target))),Bt=(t,e)=>e.some(n=>n.holds?.includes(t.id)&&!n.loose&&n.row===t.row-1);var nt=(t,e)=>t.includes(e)?t.filter(n=>n!==e):[...t,e],Tt=(t,e)=>({...e?.choices||{},...t?.choices||{}});var qe=({as:t="input",disabled:e,className:n,...r})=>o.createElement(t,{...r,disabled:e,className:E("ks-input",e&&"ks-input-disabled",n)}),A=qe;var Je=t=>o.createElement(A,{...t,as:"select"}),Et=Je;var Ke=({className:t,...e})=>o.createElement("input",{type:"checkbox",...e,className:E("ks-checkbox",t)}),G=Ke;var _t=t=>(t||[]).map(e=>typeof e=="object"?e:{value:e,label:e}),Qe=({type:t,value:e,choices:n,onChange:r,onSettle:a,onPick:l,pictureUrl:d})=>{if(t==="picture")return o.createElement("div",{className:"mb-3"},e&&d&&o.createElement("img",{src:d,alt:"The step's picture",style:{maxWidth:"100%"}}),e&&o.createElement("button",{type:"button","data-remove-picture":!0,className:"ks-button ks-button-secondary ks-button-sm",onClick:()=>a("")},"Remove picture"),o.createElement("input",{type:"file",accept:"image/*",onChange:i=>i.target.files[0]&&l(i.target.files[0])}));if(t==="boolean")return o.createElement(G,{checked:!!e,onChange:i=>a(i.target.checked)});if(t==="select"||t==="previous_step"||t==="from_step"||t==="flow")return o.createElement(Et,{className:"mb-3",value:e??"",onChange:i=>a(i.target.value)},o.createElement("option",{value:""}),_t(n).map(i=>o.createElement("option",{key:i.value,value:i.value},i.label)));if(t==="multi_select"){let i=Array.isArray(e)?e:[],p=h=>a(nt(i,h));return o.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(n||[]).map(h=>o.createElement("label",{key:h,style:{display:"inline-flex",alignItems:"center",gap:4}},o.createElement(G,{checked:i.includes(h),onChange:()=>p(h)}),o.createElement("span",null,h))))}if(t==="flows"){let i=Array.isArray(e)?e:[];return o.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},_t(n).map(p=>o.createElement("label",{key:p.value,style:{display:"inline-flex",alignItems:"center",gap:4}},o.createElement(G,{checked:i.includes(p.value),onChange:()=>a(nt(i,p.value))}),o.createElement("span",null,p.label))))}return t==="integer"||t==="float"?o.createElement(A,{className:"mb-3",type:"number",step:t==="integer"?"1":"any",value:e??"",onChange:i=>r(i.target.value),onBlur:i=>a(i.target.value)}):o.createElement(A,{className:"mb-3",type:"text",value:e??"",onChange:i=>r(i.target.value),onBlur:i=>a(i.target.value)})},X=Qe;var Dt=(t,e,n,r)=>t.map((a,l)=>l===e?{...a,[n]:r}:a);var Ze=({text:t})=>o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},t),q=Ze;var Re=(t,e,n,r)=>{let a=(t||{})[n],l=(e||{})[n];return l?(a||{})[r[l]]:a},to=({holds:t,labels:e,explanations:n,rows:r,choices:a,outputsOf:l,onChange:d,onSettle:i})=>{let p=Array.isArray(r)?r:[],h=(b,m,g,f)=>{let u=Dt(p,b,m,g);f?i(u):d(u)};return o.createElement("div",{style:{marginBottom:12}},p.map((b,m)=>o.createElement("div",{key:m,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(t).map(([g,f])=>o.createElement("label",{key:g,style:{display:"block"}},o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(e||{})[g]||g),o.createElement(X,{type:f,value:b[g],choices:Re(a,l,g,b),onChange:u=>h(m,g,u,!1),onSettle:u=>h(m,g,u,!0)}),(n||{})[g]&&o.createElement(q,{text:n[g]}))),o.createElement(v,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>i(p.filter((g,f)=>f!==m))},"Remove"))),o.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>i([...p,{}])},"Add"))},At=to;var eo=({as:t="div",className:e,children:n,...r})=>o.createElement(t,{...r,className:E("ks-panel",e)},n),$=eo;var J=(t,e)=>({className:n,children:r,...a})=>o.createElement(t,{...a,className:E(e,n)},r),W=J("label","ks-label"),In=J("p","ks-hint"),Mn=J("p","ks-error"),jn=J("span","ks-required");var oo={width:280,padding:20,overflowY:"auto"},ro=({node:t,fields:e,holds:n,labels:r,explanations:a,recordLabels:l,recordExplanations:d,recordChoices:i,recordOutputsOf:p,choices:h,onSave:b,onDelete:m,onClose:g,onPickPicture:f,refusal:u})=>{let[k,w]=S(t.config),[C,T]=S(t.picture_url);L(()=>T(t.picture_url),[t.id,t.picture_url]),L(()=>w(t.config),[t.id,t.config]);let x=y=>{w(y),JSON.stringify(y)!==JSON.stringify(t.config)&&b(y)};return o.createElement($,{as:"aside",style:oo,"data-inspector":!0},o.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},o.createElement("h2",{style:{fontWeight:600,marginBottom:2}},t.label),o.createElement("button",{title:"Close",onClick:g,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:16}},t.id," \xB7 ",t.type),u&&o.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},u),Object.entries(e).map(([y,O])=>o.createElement(W,{key:y},o.createElement("span",{style:{display:"block",marginBottom:3}},r[y]||y),O==="list"?o.createElement(At,{holds:n[y]||{},labels:l[y]||{},explanations:(d||{})[y],rows:k[y],choices:{...(i||{})[y],...(t.record_choices||{})[y]},outputsOf:(p||{})[y],onChange:z=>w({...k,[y]:z}),onSettle:z=>x({...k,[y]:z})}):o.createElement(X,{type:O,value:k[y],choices:h[y],pictureUrl:C,onChange:z=>w({...k,[y]:z}),onSettle:z=>x({...k,[y]:z}),onPick:async z=>{let B=await f(z);B&&(T(B.url),x({...k,[y]:B.reference}))}}),(a||{})[y]&&o.createElement(q,{text:a[y]}))),o.createElement(v,{variant:"danger",size:"sm",className:"w-full",onClick:m},"Delete step"))},Ot=ro;var no={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},so={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},ao="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",io="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",lo=({node:t,dragging:e,onFill:n,onDrop:r,compact:a=!1})=>o.createElement("div",{ref:t.ref,"data-placeholder":t.id,title:`Choose the step \u201C${t.label}\u201D should lead to`,onClick:n,onDragOver:l=>{e&&(l.preventDefault(),l.dataTransfer.dropEffect="move")},onDrop:l=>{l.preventDefault(),r()},className:e?io:ao,style:a?so:no},o.createElement("div",{style:{fontWeight:600}},t.label),o.createElement("div",{style:{fontSize:11}},e?"drop a step here":"leads nowhere yet \u2014 click to choose")),Pt=lo;var co=({entries:t,at:e,onPick:n,onConnect:r,onDismiss:a,hideStepTypeCodes:l})=>o.createElement($,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:e.y,left:e.x,width:210,padding:8,borderRadius:8}},o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),t.map(d=>o.createElement(v,{key:d.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>n(d)},d.label,!l&&o.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},d.type))),r&&o.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),o.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:a},"Cancel")),$t=co;var po=t=>e=>e.label.toLowerCase().includes(t.trim().toLowerCase()),uo=(t,e,n="")=>{let r=Object.values(e).flat(),a=Object.entries(e).map(([l,d])=>({heading:l,entries:d.map(i=>t.find(p=>p.type===i)).filter(Boolean)}));return[{heading:null,entries:t.filter(l=>!r.includes(l.type))},...a].map(l=>({...l,entries:l.entries.filter(po(n))})).filter(l=>l.entries.length>0)},mo={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},fo={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},go={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},ho=({entries:t,groups:e,onPick:n,onCarry:r,onDrop:a})=>{let[l,d]=S("");return o.createElement($,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:mo},o.createElement(A,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:l,onChange:i=>d(i.target.value),style:{marginBottom:6,fontSize:12}}),uo(t,e,l).map(i=>o.createElement(o.Fragment,{key:i.heading||""},i.heading&&o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:fo},i.heading),i.entries.map(p=>o.createElement($,{as:"button",type:"button",key:p.type,"data-step-type":p.type,className:"bg-surface-50 dark:bg-surface-950",style:go,draggable:!0,onClick:()=>n(p),onDragStart:h=>{h.dataTransfer.effectAllowed="copyMove",h.dataTransfer.setData("text/plain",p.type),r(p)},onDragEnd:a},p.label)))))},Lt=ho;var yo={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},It=({label:t,title:e,idle:n,enabled:r,onUse:a})=>o.createElement(v,{variant:"secondary",size:"sm",title:r?e:n,disabled:!r,onClick:a,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},t),xo=({undoable:t,redoable:e,onAdd:n,onUndo:r,onRedo:a})=>o.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},o.createElement(v,{variant:"secondary",className:"rounded-full",style:yo,title:"Add a step",onClick:n},"+"),o.createElement(It,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:t,onUse:r}),o.createElement(It,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:e,onUse:a})),Mt=xo;var bo=({type:t="info",title:e,message:n,onDismiss:r,className:a})=>o.createElement("div",{className:E("ks-alert",`ks-alert-${t}`,a),role:"alert"},o.createElement("div",{className:"ks-alert-body"},o.createElement("div",{className:"ks-alert-content"},e&&o.createElement("p",{className:"ks-alert-title"},e),o.createElement("p",{className:e?"ks-alert-message-titled":"ks-alert-message"},n)),r&&o.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),jt=bo;var Ht=t=>{let e=t.map(n=>`\u201C${n.name}\u201D`).join(", ");return t.length===1?`${e} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${e} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var Wt=({version:t,published:e})=>t?e?e===t?`Version ${t} \xB7 live`:`Version ${t} \xB7 visitors still on ${e}`:`Version ${t} \xB7 never published`:"No version yet";var vo={width:280,padding:20,overflowY:"auto"},st={fontWeight:600,marginBottom:6,marginTop:14},K={fontSize:12,marginBottom:4,lineHeight:1.4},Ft={display:"block",marginBottom:3},Vt=(t,e,n)=>r=>{r.target.value!==(t[e]??"")&&n({[e]:r.target.value})},wo=({flow:t,changes:e,problems:n,refusal:r,notice:a,publishNote:l,warning:d,onCreate:i,onPublish:p,onAccept:h,onDecline:b,onSaveDetails:m,onClose:g})=>o.createElement($,{as:"aside",style:vo,"data-builder-panel":!0},o.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},o.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},t.title||t.slug),o.createElement("button",{title:"Close",onClick:g,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),o.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:t.history_url,"data-history":!0},Wt(t)),d?o.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},o.createElement(jt,{type:"warning",className:"mb-1.5",message:Ht(d.steps)}),o.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:h,"data-accept-removal":!0},d.path==="/publish"?"Remove and publish":"Remove and create version"),o.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:b,"data-decline-removal":!0},"Cancel")):o.createElement("div",{style:{marginTop:14}},o.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:i,"data-create-version":!0},"Create version"),o.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:p,"data-publish":!0},"Publish"),l&&o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},l)),o.createElement("h2",{style:st},"Problems"),r&&o.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...K,fontWeight:600},"data-refusal":!0},r),a&&!r&&o.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...K,fontWeight:600},"data-notice":!0},a),n.length===0&&!r?o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing wrong with this flow."):n.map(f=>o.createElement("p",{key:`${f.node}-${f.problem}`,className:"text-amber-700 dark:text-amber-400",style:K,"data-problem":!0},"\u26A0 ",f.sentence)),o.createElement("h2",{style:st},"Changes since the last version"),e.length===0?o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):e.map((f,u)=>o.createElement("p",{key:u,style:K,"data-change":!0},f)),o.createElement("h2",{style:st},"Details"),o.createElement(W,null,o.createElement("span",{style:Ft},"Title"),o.createElement(A,{className:"mb-3",defaultValue:t.title??"",onBlur:Vt(t,"title",m),"data-flow-title":!0})),o.createElement(W,null,o.createElement("span",{style:Ft},"Start label"),o.createElement(A,{className:"mb-3",defaultValue:t.start_label??"",onBlur:Vt(t,"start_label",m),"data-flow-start-label":!0})),o.createElement("div",{style:{marginTop:16}},o.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.definition_url,"data-definition":!0},"Definition"),o.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.details_url,"data-details":!0},"Edit details"))),Yt=wo;var Ut={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Gt=t=>({opacity:t?1:0,transition:"opacity .12s"}),ko=({link:t,onInsert:e,onRemove:n,onDrop:r,dragging:a,alwaysShowInsertButtons:l})=>{let[d,i]=S(!1),p=d||a;return o.createElement("div",{"data-connector":`${t.source}-${t.target}`,style:{position:"absolute",left:t.midX-34,top:t.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDragOver:h=>{h.preventDefault(),h.dataTransfer.dropEffect="move"},onDrop:h=>{h.preventDefault(),i(!1),r()}},o.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},o.createElement(v,{variant:"secondary",title:a?"Move the step here":"Insert a step here",onClick:e,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(a&&d),style:{...Ut,...Gt(p||l)}},"+"),!a&&o.createElement(v,{variant:"danger",title:"Remove this connection",onClick:n,className:"rounded-full",style:{...Ut,...Gt(p)}},"\xD7")))},Xt=ko;var So=({links:t,extent:e,dragging:n,onInsert:r,onRemove:a,onDrop:l,alwaysShowInsertButtons:d})=>o.createElement(o.Fragment,null,o.createElement("svg",{width:e.width,height:e.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},o.createElement("defs",null,o.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},o.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),t.map(i=>o.createElement("path",{key:i.id,"data-link":i.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:i.path}))),t.filter(i=>i.label).map(i=>o.createElement("div",{key:`${i.id}-label`,"data-link-label":i.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:i.midX+(d?2:-10),top:i.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},i.label)),t.filter(i=>!i.placeholder).map(i=>o.createElement(Xt,{key:i.id,link:i,dragging:!!n,alwaysShowInsertButtons:d,onInsert:()=>r(i),onRemove:()=>a(i),onDrop:()=>l(i)}))),qt=So;var at={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Jt="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Co=({link:t,onInsert:e,onRemove:n,onDrop:r,alwaysShowInsertButtons:a,dragging:l})=>o.createElement("div",{"data-joint":t?.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=>{t&&r&&(d.preventDefault(),d.dataTransfer.dropEffect="move")},onDrop:d=>{t&&(d.preventDefault(),r(t))}},t&&o.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"}),t&&e&&o.createElement("div",{className:"absolute inset-0 flex items-center justify-center gap-1 sm:flex-col",style:{zIndex:4}},o.createElement(v,{variant:"secondary",title:"Insert a step here",onClick:d=>e(t,d),className:`rounded-full ${a?"opacity-100":Jt}`,style:l?{...at,opacity:1}:at},"+"),o.createElement(v,{variant:"danger",title:"Remove this connection",onClick:()=>n(t),className:`rounded-full ${Jt}`,style:at},"\xD7"))),Kt=Co;var No=(t,e)=>t.row-e.row||t.column-e.column,Qt=t=>{let e=[...t].sort(No),n=e.filter(r=>t.some(a=>a.holds?.includes(r.id)));return e.filter(r=>!n.includes(r)).flatMap(r=>[r,...n.filter(a=>r.holds?.includes(a.id))])},Zt=t=>{let e=Qt(t),n=r=>e.some(a=>a.holds?.includes(r.id));return e.filter(r=>!n(r)).reduce((r,a)=>{if(a.holds)return[...r,{group:a,steps:e.filter(d=>a.holds.includes(d.id))}];let l=r[r.length-1];return l&&!l.group?[...r.slice(0,-1),{steps:[...l.steps,a]}]:[...r,{steps:[a]}]},[])},zo=(t,e)=>t[t.findIndex(n=>n.id===e.id)+1]?.id,Rt=(t,e,n)=>{let r=zo(Qt(n),t);return e.filter(a=>a.source===t.id&&(a.label||a.target!==r))},Bo=t=>t?.placeholder?"nowhere yet":t?.label,te=(t,e)=>[t.label,"\u2192",Bo(e.find(n=>n.id===t.target))].filter(Boolean).join(" "),ee=(t,e,n)=>t.find(r=>r.source===e.id&&r.target===n.id);var To={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},oe=({steps:t,edges:e,draw:n,joints:r})=>o.createElement("div",{"data-flow-row":!0,className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5"},t.map((a,l)=>o.createElement("div",{key:a.id,className:"flex flex-col sm:flex-row sm:items-center"},l>0&&o.createElement(Kt,{link:ee(e,t[l-1],a),...r}),n(a)))),Eo={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},_o=({group:t,steps:e,edges:n,draw:r,joints:a})=>o.createElement("div",{"data-group-box":t.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:Eo},r(t),o.createElement(oe,{steps:e,edges:n,draw:r,joints:a})),Do=({nodes:t,edges:e,draw:n,joints:r,children:a,style:l})=>o.createElement("div",{"data-flow-rows":!0,style:{...To,...l}},a,Zt(t).map(d=>d.group?o.createElement(_o,{key:d.group.id,group:d.group,steps:d.steps,edges:e,draw:n,joints:r}):o.createElement(oe,{key:d.steps[0].id,steps:d.steps,edges:e,draw:n,joints:r}))),Q=Do;var re="Your change was not saved because the server could not be reached.",ne=({base:t,token:e,fetch:n,onFlow:r,onError:a,onNotice:l,onWarning:d=()=>{}})=>async(i,p,h)=>{let b=await n(t+i,{method:p,headers:{"Content-Type":"application/json","X-CSRF-Token":e},body:h&&JSON.stringify(h)}).catch(()=>null);if(!b)return l(null),a(re);let m=await b.json().catch(()=>({}));if(m.unconnected)return l(null),a(null),d({path:i,steps:m.unconnected}),r(await(await n(t+".json",{headers:{Accept:"application/json"}})).json());if(d(null),!b.ok)return l(null),a(m.error||"That change was refused");a(null),l(m.notice||null),r(await(await n(t+".json",{headers:{Accept:"application/json"}})).json())},se=({base:t,token:e,fetch:n,onError:r})=>async a=>{let l=new FormData;l.append("picture",a);let d=await n(t+"/pictures",{method:"POST",headers:{"X-CSRF-Token":e},body:l}).catch(()=>null);if(!d)return r(re),null;let i=await d.json().catch(()=>({}));return d.ok?(r(null),i):(r(i.error||"That picture was refused"),null)};var Ao=(t,e,n)=>{let[r,a]=S(n),[l,d]=S(null),[i,p]=S(null),[h,b]=S(null),m=j(()=>ne({base:t,token:e,fetch:(...f)=>window.fetch(...f),onFlow:a,onError:d,onNotice:p,onWarning:b}),[t,e]),g=j(()=>se({base:t,token:e,fetch:(...f)=>window.fetch(...f),onError:d}),[t,e]);return{flow:r,error:l,notice:i,warning:h,setWarning:b,send:m,pickPicture:g}},ae=Ao;var Z=(t,e,n,r)=>{let a=t.left-n.left+r.scrollLeft,l=t.top-n.top+r.scrollTop;return e==="left"?{x:a,y:l+t.height/2}:e==="right"?{x:a+t.width,y:l+t.height/2}:e==="top"?{x:a+t.width/2,y:l}:{x:a+t.width/2,y:l+t.height}},Oo=(t,e,n)=>n&&e==="top"?{x:t.x,y:n.top}:t,Po=(t,e)=>e==="top"?{x:t.x,y:t.y-3}:e==="left"?{x:t.x-3,y:t.y}:e==="right"?{x:t.x+3,y:t.y}:{x:t.x,y:t.y+3},$o=(t,e,n,r,a)=>{let l={straight:`M ${e.x} ${e.y} L ${n.x} ${n.y}`,turn:`M ${e.x} ${e.y} H ${n.x} V ${n.y}`,lane:`M ${e.x} ${e.y} V ${r} H ${n.x} V ${n.y}`,detour:`M ${e.x} ${e.y} H ${a} V ${n.y} H ${n.x}`}[t.route];return{...t,path:l,midX:t.route==="detour"?a:(e.x+n.x)/2,midY:t.route==="lane"?r:(e.y+n.y)/2}},Lo=(t,e,n,r)=>{let[a,l]=S([]),[d,i]=S({width:"100%",height:"100%"}),[p,h]=S([]);return ht(()=>{let b=()=>{let g=e.current?.getBoundingClientRect();if(!g)return;i({width:e.current.scrollWidth,height:e.current.scrollHeight});let f=t.nodes.filter(u=>u.holds&&!u.loose&&n.current[u.id]).map(u=>{let k=n.current[u.id],w=k.getBoundingClientRect(),C=u.holds.flatMap(x=>n.current[x]?[n.current[x].getBoundingClientRect()]:[]),T=[{left:w.left,top:w.top,width:Math.max(w.width,k.scrollWidth),height:w.height},...C];return{id:u.id,bounds:Ct(T,g,e.current)}});h(f),l(t.edges.flatMap(u=>{let k=n.current[u.source]?.getBoundingClientRect(),w=n.current[u.target]?.getBoundingClientRect();if(!k||!w)return[];let C=Z(k,u.leaves,g,e.current),T=f.find(z=>z.id===u.target)?.bounds,x=Po(Oo(Z(w,u.enters,g,e.current),u.enters,T),u.enters),y=(Z(k,"bottom",g,e.current).y+Z(w,"top",g,e.current).y)/2,O=u.leaves==="left"?Math.min(C.x,x.x)-28:Math.max(C.x,x.x)+28;return[$o(u,C,x,y,O)]}))};b(),window.addEventListener("resize",b);let m=new ResizeObserver(b);return e.current&&m.observe(e.current),()=>{window.removeEventListener("resize",b),m.disconnect()}},r),{links:a,extent:d,boxes:p}},ie=Lo;var le=(t,e)=>{let n=new Set(e),r=t,a=2;for(;n.has(r);)r=`${t}_${a++}`;return r};var Mo=8,jo={display:"flex",height:"100%",minHeight:0,fontSize:13},Ho={flex:1,overflow:"auto",position:"relative"},ce={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},Wo={...ce,position:"static",alignSelf:"flex-start"},Fo={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Vo={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Yo=({port:t,onCancel:e})=>o.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Vo},"Choose the step \u201C",t||"next","\u201D should lead to \u2014 ",o.createElement("button",{onClick:e,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),Uo=({base:t,token:e,initial:n})=>{let{flow:r,error:a,notice:l,warning:d,setWarning:i,send:p,pickPicture:h}=ae(t,e,n),[b,m]=S(null),[g,f]=S(null),[u,k]=S(null),[w,C]=S(null),[T,x]=S(null),[y,O]=S(!1),z=et({}),B=et(null);L(()=>{let s={open:null,publish:"/publish",save_draft:"/versions"},c=N=>{let D=N.target.closest?.("[data-bar-action]");if(!D||!(D.dataset.barAction in s))return;D.closest("details")?.removeAttribute("open"),m(null),O(!0);let F=s[D.dataset.barAction];F&&p(F,"POST")};return document.addEventListener("click",c),()=>document.removeEventListener("click",c)},[p]),L(()=>{if(!y){i(null);return}let s=c=>{c.target.isConnected&&!c.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&O(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[y]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let he=j(()=>Object.fromEntries(r.nodes.map(s=>[s.id,s])),[r.nodes]),{links:ye,extent:xe,boxes:it}=ie(r,B,z,[r,b,he]),lt=j(()=>{let s={};return r.violations.forEach(c=>{var N;return(s[N=c.node]||(s[N]=[])).push(c)}),s},[r.violations]),_=r.direction==="left_to_right",H=r.nodes.filter(s=>!s.loose),dt=r.nodes.filter(s=>s.loose),be=Math.max(0,...H.map(s=>s.row))+1,ve=Math.max(0,...H.map(s=>s.column))+1,R=s=>{if(!u)return;let[c,N]=u;k(null),c!==s&&p("/edges","POST",{from:c,to:s,on:N||null})},we=s=>{if(s.isDefaultPrevented()||!w)return;s.preventDefault();let c=w;C(null);let N=B.current.getBoundingClientRect(),D=Nt(it,{x:s.clientX-N.left+B.current.scrollLeft,y:s.clientY-N.top+B.current.scrollTop}),F=r.nodes.find(Se=>Se.holds?.includes(c))?.id||null;D!==F&&p(`/steps/${c}/group`,"PATCH",{group:D})},ct=s=>[...r.palette,...r.unoffered||[]].find(c=>c.type===s?.type),M=r.nodes.find(s=>s.id===b),P=ct(M),tt=(s,c={})=>p("/steps","POST",{id:le(s.type,r.nodes.map(N=>N.id)),type:s.type,from:c.from,to:c.to,on:c.on}),pt=s=>{let[c,N]=[T,w];x(null),C(null),c?tt(c,{from:s.source,to:s.target}):N&&p("/steps/"+N+"/move","PATCH",{from:s.source,to:s.target})},ke=s=>{let c=B.current.getBoundingClientRect();return{x:s.clientX-c.left+B.current.scrollLeft+8,y:s.clientY-c.top+B.current.scrollTop+8}},ut=s=>o.createElement(o.Fragment,null,s.placeholder&&o.createElement(Pt,{node:{...s,ref:c=>{z.current[s.id]=c}},dragging:!!w,compact:_,onFill:()=>f({from:s.from,on:s.on,at:{x:16,y:52}}),onDrop:()=>{let c=w;C(null),c&&p("/edges","POST",{from:s.from,to:c,on:s.on})}}),s.holds&&o.createElement(Y,{node:{...s,ref:c=>{z.current[s.id]=c}},header:U(s,ct(s),r.hide_step_type_codes),compact:_,onSelect:()=>u?R(s.id):m(s.id)}),!s.placeholder&&!s.holds&&o.createElement(rt,{node:{...s,ref:c=>{z.current[s.id]=c},violations:lt[s.id]||[],connected:r.edges.filter(c=>c.source===s.id).map(c=>c.label||null)},selected:s.id===b,armed:u&&u[0]===s.id?u[1]:null,connecting:!!u&&u[0]!==s.id,onSelect:()=>u?R(s.id):m(s.id),onOpen:c=>window.location.assign(c),onArm:(c,N)=>{let D=B.current.getBoundingClientRect();f({from:s.id,on:c,at:{x:N.clientX-D.left+B.current.scrollLeft+8,y:N.clientY-D.top+B.current.scrollTop+8}})},onDragEnd:()=>C(null),onDragStart:()=>C(s.id),hideStepTypeCodes:r.hide_step_type_codes,compact:_,branches:_?Rt(s,r.edges,H).map(c=>te(c,r.nodes)):[]})),mt=dt.length>0&&o.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:_?Wo:ce},o.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"),dt.map(s=>o.createElement("div",{key:s.id,style:{marginBottom:8}},o.createElement(rt,{node:{...s,ref:c=>{z.current[s.id]=c},violations:lt[s.id]||[],connected:[]},selected:b===s.id,armed:u&&u[0]===s.id?u[1]:null,connecting:!!u,onSelect:()=>u?R(s.id):m(s.id),onOpen:c=>window.location.assign(c),onArm:(c,N)=>{N.stopPropagation(),k([s.id,c])},onDragStart:()=>C(s.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes}))));return o.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:jo,onMouseUp:()=>C(null),onKeyDown:s=>{s.key==="Escape"&&(m(null),k(null),f(null))},tabIndex:-1},o.createElement(Lt,{entries:r.palette,groups:r.step_groups||{},onPick:s=>tt(s),onCarry:x,onDrop:()=>x(null)}),o.createElement("div",{ref:B,className:"bg-surface-50 dark:bg-surface-950",style:Ho,onClick:s=>{s.target===B.current&&(m(null),k(null),O(!1))},onDragOver:s=>{w&&s.preventDefault()},onDrop:we},u&&o.createElement(Yo,{port:u[1],onCancel:()=>k(null)}),o.createElement(Mt,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>f({at:{x:16,y:52}}),onUndo:()=>{m(null),p("/undo","POST")},onRedo:()=>{m(null),p("/redo","POST")}}),!_&&it.map(s=>o.createElement(St,{key:s.id,id:s.id,bounds:s.bounds,onDrop:()=>{let c=w;C(null),c&&p(`/steps/${c}/group`,"PATCH",{group:s.id})}})),!_&&o.createElement(qt,{links:zt(ye,r.nodes),extent:xe,dragging:w||T,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:s=>f({from:s.source,to:s.target,at:{x:s.midX+30,y:s.midY}}),onRemove:s=>{m(null),p("/edges","DELETE",{from:s.source,to:s.target})},onDrop:pt}),!_&&mt,_&&o.createElement(Q,{nodes:H,edges:r.edges,draw:ut,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(w||T),onInsert:(s,c)=>f({from:s.source,to:s.target,at:ke(c)}),onRemove:s=>{m(null),p("/edges","DELETE",{from:s.source,to:s.target})},onDrop:pt}},mt),!_&&o.createElement("div",{style:{...Fo,gridTemplateColumns:`repeat(${ve+1}, ${280/2}px)`,gridTemplateRows:`repeat(${be}, auto)`}},H.map(s=>o.createElement("div",{key:s.id,style:{gridRow:s.row+1,gridColumn:`${s.column+1} / span 2`,zIndex:2,marginTop:Bt(s,r.nodes)?Mo-64:0}},ut(s)))),g&&o.createElement($t,{entries:r.palette,at:g.at,onDismiss:()=>f(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:g.on!==void 0?()=>{k([g.from,g.on]),f(null)}:null,onPick:s=>{let c=g;f(null),tt(s,c)}})),y&&!M&&o.createElement(Yt,{flow:r.flow||{},changes:r.changes||[],problems:r.violations,refusal:a,notice:l,publishNote:r.publish_note,warning:d,onClose:()=>O(!1),onCreate:()=>p("/versions","POST"),onPublish:()=>p("/publish","POST"),onAccept:()=>p(d.path,"POST",{remove_unconnected:d.steps.map(s=>s.id)}),onDecline:()=>i(null),onSaveDetails:s=>p("/details","PATCH",{flow:s})}),M&&o.createElement(Ot,{node:M,fields:P?.fields||{},holds:P?.records||{},labels:P?.labels||{},explanations:P?.explanations||{},recordLabels:P?.record_labels||{},recordExplanations:P?.record_explanations||{},recordChoices:P?.record_choices||{},recordOutputsOf:P?.record_outputs_of||{},choices:Tt(M,P),onClose:()=>m(null),onSave:s=>p(`/steps/${M.id}`,"PATCH",{config:s}),onPickPicture:h,refusal:a,onDelete:()=>{m(null),p(`/steps/${M.id}`,"DELETE")}}))},pe=Uo;var Go={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Xo={fontSize:12,fontWeight:500,lineHeight:1.3},ue={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"},me={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"},qo="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Jo=({node:t,selected:e=!1})=>{let n=t.address?"a":"div";return o.createElement(n,{"data-step":t.id,href:t.address||void 0,className:`${t.state==="paused"?"border-2":"border"} ${ue[t.state]||ue.pending}${e?` ${qo}`:""}`,style:Go},o.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.type),o.createElement("div",{style:Xo},t.label,t.version&&o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},t.version)),t.status&&o.createElement("div",{className:me[t.state]||me.pending,style:{fontSize:11}},t.status))},fe=Jo;var Ko={gap:12,padding:0},Qo=({nodes:t,edges:e,selected:n})=>o.createElement(Q,{nodes:t,edges:e,joints:{},style:Ko,draw:r=>r.holds?o.createElement(Y,{node:r,header:U(r,r,!1),compact:!0}):o.createElement(fe,{node:r,selected:r.id===n})}),ge=Qo;ot("easy_flow/flow-editor",pe);ot("easy_flow/run-view",ge);document.addEventListener("easy_flow:flow-named",t=>{let e=document.querySelector("[data-flow-heading]");e&&(e.textContent=t.detail)});document.addEventListener("easy_flow:flow-status",({detail:t})=>{t.status&&document.querySelectorAll("[data-version-status]").forEach(e=>{e.textContent=t.status}),t.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(e=>{e.textContent=`Publish v${t.publishes}`})});vt(document,ft);})();
@@ -30,6 +30,8 @@ module EasyFlow
30
30
  "start_label" => flow.start_label,
31
31
  "version" => flow.current_definition_version&.number,
32
32
  "published" => flow.live_version&.number,
33
+ "status" => DraftStatus.new(flow).to_s,
34
+ "publishes" => DraftStatus.new(flow).publishes,
33
35
  "definition_url" => edit_manage_flow_definition_path(flow),
34
36
  "details_url" => edit_manage_flow_path(flow),
35
37
  "history_url" => manage_flow_versions_path(flow) }
@@ -17,7 +17,7 @@ module EasyFlow
17
17
 
18
18
  before_action { AppRoutesHelper.define_app_route_helpers }
19
19
 
20
- helper_method :flow_routes
20
+ helper_method :flow_routes, :flow_host
21
21
 
22
22
  private
23
23
 
@@ -3,6 +3,7 @@ module EasyFlow
3
3
  class DefinitionsController < BaseController
4
4
  def edit
5
5
  @flow = hosted_flows.find_by_public_code!(params[:flow_id])
6
+ @back_link = flow_host.back_link_for(@flow)
6
7
  end
7
8
 
8
9
  def update
@@ -47,10 +47,20 @@ const Canvas = ({ base, token, initial }) => {
47
47
  const surface = useRef(null)
48
48
 
49
49
  useEffect(() => {
50
- const open = () => { setSelected(null); setShowing(true) }
51
- document.addEventListener("easy_flow:open-flow", open)
52
- return () => document.removeEventListener("easy_flow:open-flow", open)
53
- }, [])
50
+ const paths = { open: null, publish: "/publish", save_draft: "/versions" }
51
+ const pressed = (event) => {
52
+ const button = event.target.closest?.("[data-bar-action]")
53
+ if (!button || !(button.dataset.barAction in paths)) return
54
+
55
+ button.closest("details")?.removeAttribute("open")
56
+ setSelected(null)
57
+ setShowing(true)
58
+ const path = paths[button.dataset.barAction]
59
+ if (path) send(path, "POST")
60
+ }
61
+ document.addEventListener("click", pressed)
62
+ return () => document.removeEventListener("click", pressed)
63
+ }, [ send ])
54
64
 
55
65
  useEffect(() => {
56
66
  if (!showing) {
@@ -59,7 +69,7 @@ const Canvas = ({ base, token, initial }) => {
59
69
  }
60
70
 
61
71
  const away = (event) => {
62
- if (event.target.isConnected && !event.target.closest("[data-builder-panel], [data-open-panel]")) setShowing(false)
72
+ if (event.target.isConnected && !event.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")) setShowing(false)
63
73
  }
64
74
  document.addEventListener("click", away)
65
75
  return () => document.removeEventListener("click", away)
@@ -69,6 +79,10 @@ const Canvas = ({ base, token, initial }) => {
69
79
  document.dispatchEvent(new CustomEvent("easy_flow:flow-named", { detail: flow.flow?.title || flow.flow?.slug }))
70
80
  }, [ flow.flow?.title, flow.flow?.slug ])
71
81
 
82
+ useEffect(() => {
83
+ document.dispatchEvent(new CustomEvent("easy_flow:flow-status", { detail: { status: flow.flow?.status, publishes: flow.flow?.publishes } }))
84
+ }, [ flow.flow?.status, flow.flow?.publishes ])
85
+
72
86
  const byId = useMemo(() => Object.fromEntries(flow.nodes.map((node) => [ node.id, node ])), [ flow.nodes ])
73
87
  const { links, extent, boxes } = useConnectors(flow, surface, cards, [ flow, selected, byId ])
74
88
 
@@ -28,7 +28,7 @@ const typeLineOf = (node, heading, hideStepTypeCodes) => {
28
28
  return heading === node.type_name ? null : node.type_name
29
29
  }
30
30
 
31
- const StepCard = ({ node, selected, armed, connecting, onSelect, onOpen, onArm, onDragEnd, onDragStart, hideStepTypeCodes, branches = [], compact = false }) => {
31
+ const StepCard = ({ node, selected, armed, connecting, onSelect, onOpen, onArm, onDragEnd, onDragStart, hideStepTypeCodes, branches = [], compact = false, typeAbove = compact }) => {
32
32
  const bookend = node.begins_here || node.ends_here
33
33
  const pinned = node.begins_here
34
34
  const ports = node.ends_here ? [] : node.ports
@@ -49,21 +49,18 @@ const StepCard = ({ node, selected, armed, connecting, onSelect, onOpen, onArm,
49
49
  padding: bookend ? 0 : compact ? "8px 10px" : "12px 14px",
50
50
  cursor: pinned ? "default" : connecting ? "crosshair" : "grab"
51
51
  }}>
52
- {!bookend && compact && typeLine && <div className="font-mono text-gray-500 dark:text-gray-400" style={{ fontSize: 11 }}>{typeLine}</div>}
52
+ {!bookend && typeAbove && typeLine && <div className="font-mono text-gray-500 dark:text-gray-400" style={{ fontSize: 11 }}>{typeLine}</div>}
53
53
  {bookend && <div className="text-gray-500 dark:text-gray-400" style={bookendCard}>{heading}</div>}
54
54
  {!bookend && <div style={compact ? compactName : named}>{heading}</div>}
55
- {!bookend && !compact && typeLine && <div className="text-gray-500 dark:text-gray-400" style={{ fontSize: 11, marginTop: 2 }}>{typeLine}</div>}
55
+ {node.violations.length > 0 && <div data-error-count className="text-red-600 dark:text-red-400" style={{ fontSize: 10 }}>{`${node.violations.length} error${node.violations.length === 1 ? "" : "s"}`}</div>}
56
+ {!bookend && node.summary && node.violations.length === 0 && <div className={selected ? "text-accent-600 dark:text-accent-400" : "text-gray-500 dark:text-gray-400"} style={{ fontSize: 10 }}>{node.summary}</div>}
57
+ {!bookend && !typeAbove && typeLine && <div className="text-gray-500 dark:text-gray-400" style={{ fontSize: 11, marginTop: 2 }}>{typeLine}</div>}
56
58
  {node.picture_url && <div className="text-accent-600 dark:text-accent-400" style={{ fontSize: 11, marginTop: 2 }}>Has a picture</div>}
57
59
  {node.starts_a_flow && <div className="text-accent-600 dark:text-accent-400" style={{ fontSize: 11, marginTop: 2 }}>Runs a flow</div>}
58
60
  {node.opens && <Button variant="secondary" size="sm" className="mt-2" onClick={(event) => { event.stopPropagation(); onSelect() }}>Settings</Button>}
59
61
  {branches.map((branch) => (
60
62
  <div key={branch} className="text-gray-500 dark:text-gray-400" style={{ fontSize: 10 }}>{branch}</div>
61
63
  ))}
62
- {node.violations.map((violation) => (
63
- <div key={violation.problem + violation.detail} className="text-red-600 dark:text-red-400" style={{ fontSize: 11, padding: "0 14px 6px" }}>
64
- {violation.sentence}
65
- </div>
66
- ))}
67
64
  {ports.length > 0 && (
68
65
  <div style={{ padding: node.begins_here ? "0 14px 8px" : "10px 0 0" }}>
69
66
  {ports.map((port) => (
@@ -12,4 +12,9 @@ document.addEventListener("easy_flow:flow-named", (event) => {
12
12
  if (heading) heading.textContent = event.detail
13
13
  })
14
14
 
15
+ document.addEventListener("easy_flow:flow-status", ({ detail }) => {
16
+ if (detail.status) document.querySelectorAll("[data-version-status]").forEach((shown) => { shown.textContent = detail.status })
17
+ if (detail.publishes) document.querySelectorAll("[data-bar-action=publish]").forEach((shown) => { shown.textContent = `Publish v${detail.publishes}` })
18
+ })
19
+
15
20
  startMounting(document, createRoot)
@@ -20,7 +20,7 @@ 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),
23
+ { "id" => node.id, "type" => node.type, "type_name" => step_type_for(node)&.step_name, "label" => label_for(node), "summary" => step_type_for(node)&.summary_of(node),
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
@@ -0,0 +1,28 @@
1
+ module EasyFlow
2
+ class DraftStatus
3
+ def initialize(flow)
4
+ @flow = flow
5
+ end
6
+
7
+ def to_s
8
+ "#{based_on} · unsaved #{changes} #{"change".pluralize(changes)}"
9
+ end
10
+
11
+ def publishes
12
+ return @flow.current_definition_version.number if @flow.current_definition_version && @flow.versioned?
13
+
14
+ @flow.definition_versions.maximum(:number).to_i + 1
15
+ end
16
+
17
+ private
18
+
19
+ def based_on
20
+ version = @flow.current_definition_version
21
+ version ? "draft from v#{version.number}" : "new draft"
22
+ end
23
+
24
+ def changes
25
+ Change.listed(@flow.changes_since_version.to_a).size
26
+ end
27
+ end
28
+ end
@@ -115,6 +115,10 @@ module EasyFlow
115
115
  @naming = naming
116
116
  end
117
117
 
118
+ def summarizes_by(&summarizing)
119
+ @summarizing = summarizing
120
+ end
121
+
118
122
  def setting(name, type: nil, from: nil, outputs_of: nil, label: nil, explanation: nil, options: nil, limit: nil, check: nil, required: false, optional: false, kept_on: nil, attribute: nil, &entries)
119
123
  type ||= :from_step if from
120
124
  type ||= :from_step if outputs_of
@@ -163,7 +167,7 @@ module EasyFlow
163
167
  def to_step_type
164
168
  StepType.new(id: @id, step_name: @step_name, settings: settings, awaits_input: @awaits_input,
165
169
  ends_here: @ends_here, begins_here: @begins_here, starts_a_flow: @starts_a_flow, plays_the_picked_flow: @plays_the_picked_flow, holds_steps: @holds_steps, flow_chooser: @flow_chooser, run_chooser: @run_chooser, behaviour: @behaviour, routing: @routing,
166
- display: @display, drawn_by: @drawn_by, naming_field: @naming_field, naming: @naming,
170
+ display: @display, drawn_by: @drawn_by, naming_field: @naming_field, naming: @naming, summarizing: @summarizing,
167
171
  outputs: @declared_outputs, outputs_named_by: @outputs_named_by, answer_check: @answer_check, answer_labelling: @answer_labelling, readiness: @readiness, return_rule: @return_rule, unsaved_refusal: @unsaved_refusal)
168
172
  end
169
173
 
@@ -12,7 +12,7 @@ module EasyFlow
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,
15
- naming_field: nil, naming: nil, outputs: [], outputs_named_by: nil, answer_check: nil, answer_labelling: nil, readiness: nil, return_rule: nil, unsaved_refusal: nil)
15
+ naming_field: nil, naming: nil, summarizing: nil, outputs: [], outputs_named_by: nil, answer_check: nil, answer_labelling: nil, readiness: nil, return_rule: nil, unsaved_refusal: nil)
16
16
  @id = id
17
17
  @step_name = step_name
18
18
  @settings = settings
@@ -30,6 +30,7 @@ module EasyFlow
30
30
  @drawn_by = drawn_by
31
31
  @naming_field = naming_field
32
32
  @naming = naming
33
+ @summarizing = summarizing
33
34
  @outputs = outputs
34
35
  @outputs_named_by = outputs_named_by
35
36
  @answer_check = answer_check
@@ -79,6 +80,10 @@ module EasyFlow
79
80
  @naming&.call(node).presence || node.config[naming_field.to_s].presence || worked_out_flow_name(node)
80
81
  end
81
82
 
83
+ def summary_of(node)
84
+ @summarizing&.call(node).presence
85
+ end
86
+
82
87
  def acts?
83
88
  @behaviour.present?
84
89
  end
@@ -1,8 +1,6 @@
1
- <%= ui_page(max_width: :lg) do %>
2
- <p class="mb-4">
3
- <%= link_to "← Back to the flow", flow_routes.manage_flow_path(@flow), class: "text-sm text-accent-600 hover:text-accent-700" %>
4
- </p>
1
+ <%= render "easy_flow/manage/flows/top_bar", flow: @flow, showing: :text, parent: nil, back_link: @back_link %>
5
2
 
3
+ <%= ui_page(max_width: :lg) do %>
6
4
  <%= ui_form_page(title: "Definition", back_url: flow_routes.manage_flow_path(@flow), subtitle: @flow.slug) %>
7
5
 
8
6
  <%= ui_form(action: flow_routes.manage_flow_definition_path(@flow), method: :patch) do %>
@@ -0,0 +1,53 @@
1
+ <% muted = "text-[var(--ks-color-text-muted)] dark:text-[var(--ks-color-text-muted-dark)]" %>
2
+ <% segment = "px-3 py-1.5" %>
3
+ <header class="flex shrink-0 flex-wrap items-center gap-x-3 gap-y-2 border-b border-[var(--ks-color-divider)] dark:border-[var(--ks-color-divider-dark)] px-5 py-2.5" data-top-bar>
4
+ <% if back_link %>
5
+ <%= link_to back_link.label, back_link.address, class: "text-sm #{muted} before:content-['←_']" %>
6
+ <% else %>
7
+ <%= link_to "All flows", flow_routes.manage_flows_path, class: "text-sm #{muted} before:content-['←_']" %>
8
+ <% end %>
9
+ <% if parent %>
10
+ <%= link_to "Back to #{parent.title.presence || parent.slug}", flow_routes.manage_flow_path(parent), class: "text-sm #{muted} before:content-['←_']" %>
11
+ <% end %>
12
+
13
+ <h1 class="text-base font-semibold text-[var(--ks-color-text)] dark:text-[var(--ks-color-text-dark)]" data-flow-heading><%= flow.title.presence || flow.slug %></h1>
14
+ <span class="font-mono text-xs <%= muted %>" data-version-status><%= EasyFlow::DraftStatus.new(flow) %></span>
15
+
16
+ <nav class="flex overflow-hidden rounded-md border border-[var(--ks-color-border-control)] dark:border-[var(--ks-color-border-control-dark)] ml-3 text-xs" data-view-switch>
17
+ <% { "Canvas" => [ :canvas, flow_routes.manage_flow_path(flow) ], "Text" => [ :text, flow_routes.edit_manage_flow_definition_path(flow) ] }.each do |label, (view, address)| %>
18
+ <% if view == showing %>
19
+ <span class="<%= segment %> bg-accent-600 text-white" aria-current="page"><%= label %></span>
20
+ <% else %>
21
+ <%= link_to label, address, class: "#{segment} text-[var(--ks-color-text)] dark:text-[var(--ks-color-text-dark)]" %>
22
+ <% end %>
23
+ <% end %>
24
+ </nav>
25
+
26
+ <% actions = [] %>
27
+ <% actions << { label: "This flow", data: { bar_action: "open", open_panel: true } } if showing == :canvas %>
28
+ <% actions << { label: "Try it", href: flow_routes.manage_flow_preview_path(flow) } %>
29
+ <% flow_host.editor_buttons_for(flow).each { |button| actions << { label: button.label, href: button.address } } %>
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 } %>
33
+ <% end %>
34
+
35
+ <div class="ml-auto hidden flex-wrap items-center gap-2 sm:flex">
36
+ <% actions.each do |action| %>
37
+ <%= ui_button(label: action[:label], href: action[:href], type: :button, variant: action[:primary] ? :primary : :secondary, size: :sm, data: action[:data]) %>
38
+ <% end %>
39
+ </div>
40
+
41
+ <details class="relative ml-auto sm:hidden" data-bar-menu>
42
+ <summary class="ks-button ks-button-secondary ks-button-sm cursor-pointer list-none" aria-label="Actions">⋯</summary>
43
+ <div class="ks-action-menu absolute right-0 z-50 w-48">
44
+ <% actions.each do |action| %>
45
+ <% if action[:href] %>
46
+ <%= link_to action[:label], action[:href], class: "ks-menu-option block w-full text-left text-sm" %>
47
+ <% else %>
48
+ <%= tag.button action[:label], type: "button", class: "ks-menu-option block w-full text-left text-sm", data: action[:data] %>
49
+ <% end %>
50
+ <% end %>
51
+ </div>
52
+ </details>
53
+ </header>
@@ -4,29 +4,7 @@
4
4
  <% end %>
5
5
 
6
6
  <div class="flex h-screen flex-col overflow-hidden">
7
- <header class="flex shrink-0 items-center justify-between gap-4 border-b border-[var(--ks-color-divider)] dark:border-[var(--ks-color-divider-dark)] px-6 py-3">
8
- <div>
9
- <h1 class="text-lg font-semibold text-[var(--ks-color-text)] dark:text-[var(--ks-color-text-dark)]" data-flow-heading><%= @flow.title.presence || @flow.slug %></h1>
10
- <p class="text-sm text-[var(--ks-color-text-muted)] dark:text-[var(--ks-color-text-muted-dark)]"><%= @flow.slug %></p>
11
- </div>
12
- <div class="flex items-center gap-2">
13
- <button type="button" data-open-panel
14
- onclick="document.dispatchEvent(new CustomEvent('easy_flow:open-flow'))"
15
- class="inline-flex items-center justify-center font-semibold rounded-lg border-0 cursor-pointer bg-accent-600 text-white hover:bg-accent-700 text-base px-4 py-2">This flow</button>
16
-
17
- <%= ui_button(label: "Try it", href: flow_routes.manage_flow_preview_path(@flow), variant: :secondary) %>
18
-
19
- <% if @parent %>
20
- <%= ui_button(label: "Back to #{@parent.title.presence || @parent.slug}", href: flow_routes.manage_flow_path(@parent), variant: :secondary) %>
21
- <% end %>
22
-
23
- <% if @back_link %>
24
- <%= ui_button(label: @back_link.label, href: @back_link.address, variant: :secondary) %>
25
- <% else %>
26
- <%= ui_button(label: "All flows", href: flow_routes.manage_flows_path, variant: :secondary) %>
27
- <% end %>
28
- </div>
29
- </header>
7
+ <%= render "easy_flow/manage/flows/top_bar", flow: @flow, showing: :canvas, parent: @parent, back_link: @back_link %>
30
8
 
31
9
  <%= react_ui("easy_flow/flow-editor", { base: flow_routes.manage_flow_canvas_path(@flow), token: form_authenticity_token, initial: @canvas },
32
10
  class: "min-h-0 flex-1",
@@ -1,9 +1,10 @@
1
1
  module EasyFlow
2
2
  class Host
3
3
  BackLink = Data.define(:label, :address)
4
+ Button = Data.define(:label, :address)
4
5
 
5
6
  attr_reader :name, :back_link
6
- attr_writer :layout, :admin_layout, :offers, :allowed_answers, :always_show_insert_buttons, :hide_step_type_codes, :marks_ends, :on_publish, :canvas_direction
7
+ attr_writer :layout, :admin_layout, :offers, :allowed_answers, :always_show_insert_buttons, :hide_step_type_codes, :marks_ends, :on_publish, :canvas_direction, :editor_buttons
7
8
  attr_accessor :admin_authentication_method, :visitor_authorization_method, :refusal_method, :owner_method, :finds_flows_across_owners, :publish_note
8
9
 
9
10
  def initialize(name)
@@ -18,6 +19,11 @@ module EasyFlow
18
19
  @back_link.respond_to?(:call) ? BackLink.new(**@back_link.call(flow)) : @back_link
19
20
  end
20
21
 
22
+ def editor_buttons_for(flow)
23
+ listed = @editor_buttons.respond_to?(:call) ? @editor_buttons.call(flow) : @editor_buttons
24
+ Array(listed).map { |button| Button.new(**button) }
25
+ end
26
+
21
27
  def setting_explanations=(explanations)
22
28
  explained = explanations.to_h.deep_stringify_keys
23
29
  raise ArgumentError, "an explanation must be text, and a list entry's setting is named like answers.weight" unless explained.values.flat_map(&:values).all? { |text| text.nil? || text.is_a?(String) }
@@ -1,3 +1,3 @@
1
1
  module EasyFlow
2
- VERSION = "0.44.0"
2
+ VERSION = "0.46.0"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: easy_flow-develop
3
- description: Use PROACTIVELY for adding a step type to easy_flow flows (a step that asks the visitor something, takes several answers at once, computes a value from earlier answers, records several values under names an admin enters in the step's settings, counts how many times an earlier step was answered so a loop can give up after a number of tries, picks the next branch, or holds the visitor until something outside the flow has happened), adding a step type an admin draws as a box that holds other steps on the canvas, such as a "for each" step, branching on whether all or any of several comparisons of earlier answers hold, holding a run until a number of minutes after an earlier answer, the next time of day after it, or a date, branching on the hour, weekday or time an earlier step was completed or on the minutes between two completed steps, reading when each step was completed and when a waiting run will move on, showing a step differently depending on the visitor's stored run, branching on what a visitor ticked on a checklist, moving a paused run on once what it waits for has happened, refusing a blank or invalid answer to a step with a message, offering an admin a step setting whose options are read from the app's own records, letting an admin pick another flow of the same host in a step's settings, adding a step type that starts another flow and works out which flow and version to run from its own settings, adding a step type that starts another flow chosen from the visitor's run, such as its owner or its answers, offering a visitor only the answers to a step that their earlier answers allow, filling in a step that has only one possible answer without asking it, skipping a step that does not apply to a visitor, letting an admin edit a value stored on one of the app's own records from a step's settings on the canvas, serving a host's flows from the app's own controller and routes, starting a visitor's run on a published version of a flow other than the live one, acting when a visitor finishes a flow, acting on the output a visitor's flow ended with, telling whether a run ended at an End step or was stopped by a loop that came back with nothing new answered and at which step, keeping a flow from being published while a step that starts another flow names a flow or version that cannot run or leads back to the flow it sits in, finding the run of another flow that a Flow step started, the run a waiting run is waiting on, and the run that started it, sending a visitor back to the run that started a flow once that flow ends, handling a run whose starting run was removed with its flow, handling a Flow step that cannot start its flow, whose flow ended with no output, or whose flow was stopped by a loop, taking one file or several from a visitor at a step, showing a step's recorded answer by a label the step type works out, and reading a run's recorded answers and question labels, including every answer ticked on a checklist and every visit's answer when a flow loops back to a question already asked, and showing on the app's own page where a run stands, with each step's state, status line and link — MUST BE USED instead of hand-rolling questionnaire steps, checkbox lists, file upload steps, branching logic, answer lists filtered by earlier answers, skipped questions, number comparisons, comparisons of two earlier answers, and/or conditions over several comparisons, hard-coded setting options, copying a record's value into a flow and back, answer validation, retry counters, timers or scheduled delays, step completion timestamps, polling or "come back later" pages, flow controllers, answer lookups or hand-drawn run diagrams.
3
+ description: Use PROACTIVELY for adding a step type to easy_flow flows (a step that asks the visitor something, takes several answers at once, computes a value from earlier answers, records several values under names an admin enters in the step's settings, counts how many times an earlier step was answered so a loop can give up after a number of tries, picks the next branch, or holds the visitor until something outside the flow has happened), adding a step type an admin draws as a box that holds other steps on the canvas, such as a "for each" step, branching on whether all or any of several comparisons of earlier answers hold, holding a run until a number of minutes after an earlier answer, the next time of day after it, or a date, branching on the hour, weekday or time an earlier step was completed or on the minutes between two completed steps, reading when each step was completed and when a waiting run will move on, showing a step differently depending on the visitor's stored run, branching on what a visitor ticked on a checklist, moving a paused run on once what it waits for has happened, refusing a blank or invalid answer to a step with a message, offering an admin a step setting whose options are read from the app's own records, letting an admin pick another flow of the same host in a step's settings, adding a step type that starts another flow and works out which flow and version to run from its own settings, adding a step type that starts another flow chosen from the visitor's run, such as its owner or its answers, offering a visitor only the answers to a step that their earlier answers allow, filling in a step that has only one possible answer without asking it, skipping a step that does not apply to a visitor, letting an admin edit a value stored on one of the app's own records from a step's settings on the canvas, serving a host's flows from the app's own controller and routes, starting a visitor's run on a published version of a flow other than the live one, acting when a visitor finishes a flow, acting on the output a visitor's flow ended with, telling whether a run ended at an End step or was stopped by a loop that came back with nothing new answered and at which step, keeping a flow from being published while a step that starts another flow names a flow or version that cannot run or leads back to the flow it sits in, finding the run of another flow that a Flow step started, the run a waiting run is waiting on, and the run that started it, sending a visitor back to the run that started a flow once that flow ends, handling a run whose starting run was removed with its flow, handling a Flow step that cannot start its flow, whose flow ended with no output, or whose flow was stopped by a loop, taking one file or several from a visitor at a step, showing a one-line summary of a step's settings on its canvas card, showing a step's recorded answer by a label the step type works out, and reading a run's recorded answers and question labels, including every answer ticked on a checklist and every visit's answer when a flow loops back to a question already asked, and showing on the app's own page where a run stands, with each step's state, status line and link — MUST BE USED instead of hand-rolling questionnaire steps, checkbox lists, file upload steps, branching logic, answer lists filtered by earlier answers, skipped questions, number comparisons, comparisons of two earlier answers, and/or conditions over several comparisons, hard-coded setting options, copying a record's value into a flow and back, answer validation, retry counters, timers or scheduled delays, step completion timestamps, polling or "come back later" pages, flow controllers, answer lookups or hand-drawn run diagrams.
4
4
  tools: Read, Write, Edit, Grep
5
5
  scope: guided flows — versioned documents of steps and the connections between them, drawn on a canvas by an admin and run by a visitor one step at a time, with step types the host registers
6
6
  ---
@@ -105,6 +105,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
105
105
 
106
106
  Here `CheckResult.for` is the app's own lookup.
107
107
  - `names_by :setting` or `names_by { |node| ... }` — what the step is called on the canvas, from a setting or computed.
108
+ - `summarizes_by { |node| ... }` — the one line the step's card shows under its name on the canvas, worked out from the step's settings, such as `summarizes_by { |node| "role: #{node.config['role']} · #{node.config['hours']}h" }`. Return a short phrase, or `nil` or `""` to show no line. Without it the card shows no summary, and a step with problems shows its error count in the summary's place. The block is called every time the canvas is drawn, so it must not be slow and must not change anything, and like `names_by` its `node.config` holds no kept setting. Ask the developer what an admin should read about a step of this type without opening it.
108
109
  - `awaits_input` — the visitor is shown this step and submits an answer to it.
109
110
  - `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.
110
111
  - `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.
@@ -116,8 +117,8 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
116
117
  - A flow's page reached by clicking the step shows a `Back to <title>` button, or `Back to <slug>` when the flow it came from has no title, which returns the admin to the flow the step is in. The button is shown only when that flow belongs to the same host.
117
118
  - While the step's `flow` setting is blank, clicking the step opens its settings like any other step.
118
119
  - While an admin is connecting two steps, clicking the step picks it as the connection's target, the same as any other step.
119
- - The step's card warns that the step `is missing a flow` while its `flow` setting is blank or names no existing flow, and that it `names a version that cannot run` while the flow exists but its `version` setting is blank, names no version of that flow, or names one that is a draft, retired or withdrawn.
120
- - The step's card warns that the step `leads back to the flow it sits in` while its `flow` setting names the flow the step sits in, or names a flow whose chosen version holds a `starts_a_flow` step that leads back to it the same way, through any number of flows. Each flow along the way is read at the version named in the `version` setting of the step that leads to it.
120
+ - The flow's problem list warns that the step `is missing a flow` while its `flow` setting is blank or names no existing flow, and that it `names a version that cannot run` while the flow exists but its `version` setting is blank, names no version of that flow, or names one that is a draft, retired or withdrawn.
121
+ - The flow's problem list warns that the step `leads back to the flow it sits in` while its `flow` setting names the flow the step sits in, or names a flow whose chosen version holds a `starts_a_flow` step that leads back to it the same way, through any number of flows. Each flow along the way is read at the version named in the `version` setting of the step that leads to it.
121
122
  - While any of those three warnings shows, saving the flow as a new version and publishing it are refused. These checks are always made and are not among the optional checks set through `easy_flow-install`, so the type needs no `required:` or `check:` on those two settings for them.
122
123
  - `chooses_flow { |node| { flow: ..., version: ... } }` — for a `starts_a_flow` type, works out the flow and version a step runs from the step's own settings instead of reading the settings named `flow` and `version`. Ask the developer which settings decide the flow and version, and how. Do not pick.
123
124
  - The block is given the node only. `node.config` holds the admin's settings with string keys, without any setting declared with `kept_on:`.
@@ -181,7 +182,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
181
182
  Here `PlanFlow.for_customer` is the app's own lookup, returning `{ flow: <id>, version: <number> }` or `nil`.
182
183
  - `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.
183
184
  - 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.
184
- - Clicking the header opens the step's settings. The header shows none of the warnings a step card shows, and has none of a card's buttons for starting a connection.
185
+ - 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.
185
186
  - 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.
186
187
  - 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.
187
188
  - The type must not declare a setting named `holds`, since a value saved under that name is dropped.
@@ -86,9 +86,9 @@ easy_flow declares no commands of its own for this local. Its surface is split b
86
86
  - **Wait step name** — what a Wait step is called on its canvas card and in the "Waiting for" line a visitor sees, following the same order as the rule that holds the run. A date set names it by that date, such as "2026-12-01". Otherwise it is named by the time of day, or by the minutes followed by "minutes", then "after" and the earlier step, such as "09:00 after signup" or "30 minutes after signup", with "minute" in place of "minutes" when the number is 1, such as "1 minute after signup". A Wait step with no date, time of day or minutes has no name of its own, so its canvas card shows the step's id and the visitor sees "Waiting for Wait".
87
87
  - **Count** — a built-in step that acts on its own and records a whole number: how many visits to an earlier step the run has recorded. When the admin picks an answer, only visits that gave that answer are counted, and when the admin picks none, every visit is counted. The admin picks which of the earlier step's outputs the answer is read from, as described under chosen output. On the canvas the step is named "Count" followed by the earlier step and the answer it counts, such as "Count tests failed". Each visit to a Count step in a loop records a new count under its own visit key, so a Compare step after it can end the loop once the count reaches an amount.
88
88
  - **Flow step** — a built-in step that names another flow and the number of one of its versions. The admin picks the flow from the same host's flows, listed by title as the admin's list of flows shows them. The step has one connection for each different output the End steps of that version write, and none when no flow or version is picked or no End step there has an output. On the canvas its card is named after the flow's title and the version, such as "Onboarding, version 2", and is marked "Runs a flow". Once a flow is picked, clicking the card opens that flow's canvas, and the card's Settings button opens the step's own settings instead. A canvas opened from a Flow step's card shows a "Back to" button named after the title of the flow it was opened from, or its slug when it has no title, which returns to that flow's canvas. The button only appears when that flow belongs to the same host, and to the same owner when the host has one. While the admin is connecting steps, clicking the card picks it as the connection's target. A run that reaches a Flow step stops there. When the run is a stored run, it starts one inner run of the named flow on the picked version, and a visitor on the run's page is taken to that inner run's first unanswered step. A run that carries its answers in the page, and an admin's preview, stop at the Flow step, start no run, and never move past it.
89
- - **Play flows step** — a built-in step (`play_flows`) that lists several flows and lets a visitor play each one once, in the order they choose. The admin ticks the flows from the same host's flows, and only that owner's flows when the host has an owner, and fills in the question asked above them. A visitor whose stored run reaches the step picks one of the listed flows not yet played, and it plays as an inner run of the visitor's run, linked to that visit of the step, the same way a Flow step's inner run is. When that inner run ends, the step records its output, or `ended`, under the visit's key, and the visitor is back at the step under its next visit with only the flows not yet played offered. A pick of a flow already played plays nothing. Once every listed flow has been played the run follows the step's one connection out, and a listed flow that no longer exists or has no live version is neither offered nor waited for. Its card warns that the step is missing a flow while a listed flow no longer exists, and in a host that names an owner, saving the step or publishing its flow is refused while it lists another owner's flow. A run that carries its answers in the page, and an admin's preview, offer no flows at the step.
90
- - **Unrunnable Flow step** — a Flow step whose picked flow or version cannot be run. Its card warns that the step is missing a flow when no flow is picked or the picked flow no longer exists, and that it names a version that cannot run when the picked flow has no version with that number or that version is a draft, retired or withdrawn. These are always on, unlike the optional checks below, and the flow holding such a step cannot be saved as a new version or published until it is fixed.
91
- - **Circular Flow step** — a Flow step that leads back to the flow it sits in. That is either a Flow step naming its own flow, or one naming a flow whose picked version holds a Flow step that leads back the same way, through any number of flows. Each flow along the way is read at the version its Flow step picked. Its card warns that the step leads back to the flow it sits in, and like an unrunnable Flow step this is always on and keeps the flow from being saved as a new version or published until it is fixed.
89
+ - **Play flows step** — a built-in step (`play_flows`) that lists several flows and lets a visitor play each one once, in the order they choose. The admin ticks the flows from the same host's flows, and only that owner's flows when the host has an owner, and fills in the question asked above them. A visitor whose stored run reaches the step picks one of the listed flows not yet played, and it plays as an inner run of the visitor's run, linked to that visit of the step, the same way a Flow step's inner run is. When that inner run ends, the step records its output, or `ended`, under the visit's key, and the visitor is back at the step under its next visit with only the flows not yet played offered. A pick of a flow already played plays nothing. Once every listed flow has been played the run follows the step's one connection out, and a listed flow that no longer exists or has no live version is neither offered nor waited for. The flow's problem list warns that the step is missing a flow while a listed flow no longer exists, and in a host that names an owner, saving the step or publishing its flow is refused while it lists another owner's flow. A run that carries its answers in the page, and an admin's preview, offer no flows at the step.
90
+ - **Unrunnable Flow step** — a Flow step whose picked flow or version cannot be run. The flow's problem list warns that the step is missing a flow when no flow is picked or the picked flow no longer exists, and that it names a version that cannot run when the picked flow has no version with that number or that version is a draft, retired or withdrawn. These are always on, unlike the optional checks below, and the flow holding such a step cannot be saved as a new version or published until it is fixed.
91
+ - **Circular Flow step** — a Flow step that leads back to the flow it sits in. That is either a Flow step naming its own flow, or one naming a flow whose picked version holds a Flow step that leads back the same way, through any number of flows. Each flow along the way is read at the version its Flow step picked. The flow's problem list warns that the step leads back to the flow it sits in, and like an unrunnable Flow step this is always on and keeps the flow from being saved as a new version or published until it is fixed.
92
92
  - **Flow-starting step type** — a step type of the app's own that starts another flow the way the Flow step does. By default it runs the flow and version named in its settings called flow and version. It may instead carry a rule that works out the flow and version from its other settings, and that choice is then used everywhere a Flow step's choice is: starting the inner run, the unrunnable and circular checks, and the canvas link to that flow. When the step type gives the step no name of its own, the step is named after the flow and version that rule works out, the same way a Flow step is, such as "Onboarding, version 2", on its canvas card and in the "Waiting for" line a visitor sees. Everything said below about a Flow step's inner run and handing back applies to it too, except where a run-chosen flow says otherwise.
93
93
  - **Run-chosen flow** — a flow-starting step type of the app's own that chooses the flow and version from the run it is in rather than from its settings, so two runs of one flow can start two different inner flows from the same step. Where there is no run, such as on the canvas, it has no chosen flow. Its steps are left out of the unrunnable and circular checks, so a flow holding one can be published with no flow in its settings. A run that reaches it and has no flow chosen fails with an error naming the step. When its inner run ends with no output, the step records `ended` and its run moves on.
94
94
  - **Inner run** — the run a Flow step starts. It records which run started it and at which step, and that run holds at most one inner run for each Flow step, however often it is moved on. It belongs to the same owner as the run that started it. When the picked version has been retired or withdrawn, no inner run is started and the run that reached the Flow step fails with an error naming that step. While the run that started it is stopped at the Flow step, that run can name the inner run it is waiting on, and it names none when it is stopped at any other step or has finished. Its steps that act on their own run as soon as it starts, and it stops at its first step that asks for input or waits.
@@ -102,15 +102,18 @@ easy_flow declares no commands of its own for this local. Its surface is split b
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.
103
103
  - **Allowed answers** — a rule a host may carry that looks at a step and the answers given so far in a run and names the answer values that step allows. When it names nothing for a step, the step offers every answer. When it names several, a question or checklist offers only those. When it names exactly one, the step records that answer without being shown, and when it names none, the step is passed over and records a blank answer. This holds in a stored run, a run moved on outside a visitor's request, a flow that carries its answers in the page, and an admin's preview. Going back skips the steps the host filled in and returns to the last step the visitor was shown.
104
104
  - **Always-visible insert buttons** — a setting a host may turn on, `always_show_insert_buttons`, that shows each connection's button for inserting a step on its canvas without the pointer over the connection, with the connection's label moved to the right of the line. It is off by default, and with it off the button shows only with the pointer over the connection.
105
+ - **Step card** — the box that draws one step on the canvas. It shows the step's name, the one-line summary the step's type works out from its settings under the name when the type declares one, and the step's type code under those, or above the name on a left-to-right canvas. A step with problems is bordered in red and its card counts them under the name, such as "1 error" or "2 errors", in place of the summary, and the sentence for each problem is in the flow panel's list of problems rather than on the card.
105
106
  - **Hidden step type codes** — a setting a host may turn on, `hide_step_type_codes`, that hides step type code names on its canvas. The add menu lists each step type by its name alone, and a step's box shows its step type's name in place of the code name, with a step that has no name of its own headed by its step type's name. It is off by default, and with it off the add menu and step boxes show the code names. The settings panel shows a step's id and code name either way.
106
107
  - **Canvas direction** — a setting a host may set, `canvas_direction`, to `:left_to_right` to lay its canvas out left to right in place of top to bottom. Steps sit as compact cards in rows joined by short lines, a row that reaches the edge of the canvas goes on in a new row, each branch or loop that leads anywhere but the step beside it is written on its step's card with the step it leads to, a group step's box takes a row of its own, and a phone-width screen shows one step per row. Top to bottom is the default.
107
108
  - **Step list** — a list beside the editing canvas, on screens 640 pixels and wider, of every step type the host offers, with a search field that keeps only the types whose name holds what was typed. A host may set `step_groups`, a hash of headings each with the step types listed under it, in the host's order, and the types it puts in no group are listed above the first heading. Clicking a type adds the step unconnected, as the add menu does, and dragging a type onto a connection inserts the step on that connection. On a phone the list is hidden and the add menu is the way to add steps.
108
109
  - **Run view** — a read-only view of one flow version that an app draws on its own page with `easy_flow_run_view`, showing each step as a compact card with its type code, name, the version and status line the app supplies, and an edge coloured by the state the app supplies, done, paused, pending or failed. A paused step's edge is thicker, the step the app names as selected is ringed, a card the app gives an address is a link to it, and steps sit left to right as on a left-to-right canvas, with a group step's box holding its steps and one card per row on a phone. It has no editing controls.
109
110
  - **Publish note** — a setting a host may set, `publish_note`, whose sentence is shown directly under the Publish button in its flow panel. With none set, the panel shows no note.
110
- - **Back link** — a setting a host may set, `back_link`, holding a label and an address, or a callable that takes the flow being shown and returns them, that shows a button with that label and address in its builder header in place of `All flows`. With a callable, each flow's canvas shows the back link worked out for that flow. With none set, the header shows `All flows`.
111
+ - **Back link** — a setting a host may set, `back_link`, holding a label and an address, or a callable that takes the flow being shown and returns them, that shows a link with that label and address at the start of the editor's top bar in place of `All flows`. With a callable, each flow's canvas shows the back link worked out for that flow. With none set, the bar shows `All flows`.
112
+ - **Top bar** — the bar across the top of the canvas and of the definition text page. From left to right it shows the back link, the flow's name, the draft's status, such as `draft from v14 · unsaved 2 changes` or `new draft · unsaved 0 changes` for a flow with no version yet, and a Canvas / Text switch between the canvas and the definition text. On the canvas its buttons are `This flow`, `Try it`, the host's editor buttons, `Save draft` and a `Publish` button naming the version it will create, such as `Publish v15`. `Save draft` creates a version as the panel's Create version does, and both open the flow panel with the result. The status and the Publish label follow each change made on the canvas. The definition text page's bar shows `Try it` and the host's editor buttons, and the page keeps its own Save button. On a screen narrower than 640 pixels the back link, name, status and switch wrap onto more lines, and the buttons are reached from an actions menu in the bar.
113
+ - **Editor buttons** — a setting a host may set, `editor_buttons`, holding a list of buttons each with a label and an address, or a callable that takes the flow being shown and returns that list, whose buttons the top bar shows before `Save draft`, such as Run tests and Dry-run. The app decides what each address does. With none set, the bar shows no extra buttons.
111
114
  - **On publish** — a setting a host may set, `on_publish`, holding a callable that takes a flow. easy_flow calls it each time a new version of one of that host's flows goes live, from the canvas's Publish button or from the app calling publish. Publishing a version that is already live does not call it. With none set, nothing is called.
112
115
  - **Host setting explanations** — a setting a host may set, `setting_explanations`, giving its own explanation for one setting of one step type, including a setting inside a list. It shows in place of the step type's own. A setting it gives none for shows the step type's own, and with none set nothing changes.
113
- - **Flow panel** — the panel the `This flow` button opens on the canvas, on every host. It shows Create version and Publish above its lists of problems and changes. Each problem is a sentence naming the step by its name, or by its step type's name when it has none, never by its id, and saying what to do to clear it. Several saves to the same step in a row show as one line in the changes list, named by the step's latest name. A save, a move and any other change each keep their own line, and the history of versions still lists every change a version captured.
116
+ - **Flow panel** — the panel the top bar's `This flow`, `Save draft` and `Publish` buttons open on the canvas, on every host. It shows Create version and Publish above its lists of problems and changes. Each problem is a sentence naming the step by its name, or by its step type's name when it has none, never by its id, and saying what to do to clear it. Several saves to the same step in a row show as one line in the changes list, named by the step's latest name. A save, a move and any other change each keep their own line, and the history of versions still lists every change a version captured.
114
117
  - **Picture mark** — the words `Has a picture` on the box of a step with a picture on the canvas, on every host.
115
118
  - **Palette** — the step types an admin can add on a host's canvas. It never holds the start step, always holds the end step, and otherwise holds the step types the host offers. A step already in a flow whose type the host does not offer is still drawn and run, and still opens with all its settings and can be saved.
116
119
  - **Run** — one visitor's pass through a flow. A run may belong to one of the app's own records, its owner, which the app sets. A run is pinned to the version it started on, so publishing a new version does not change a run already under way. A run starts on the live version unless the app chooses another of the flow's published versions. A run is refused when the chosen version is a draft, is retired or withdrawn, or belongs to another flow. It records each visit, and going back discards the last visit on the path.
@@ -64,7 +64,8 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
64
64
  - `step_groups` — a hash of the headings this host's canvas step list shows, each with the step types listed under it by name, such as `{ "Agents" => [ :question, :checklist ], "Control" => [ :switch, :wait ] }`. Headings appear in the order given. Offered step types the hash leaves out are listed above the first heading, and a type the host does not offer is not listed. With none set, the list shows every offered step type under no heading. Ask the developer how each host's step types should be grouped.
65
65
  - `marks_ends` — set to `true` to have this host's admins mark each End step as success or failure. The End step's settings then show a Mark with those two choices, and publishing one of this host's flows with an End left unmarked is refused, the refusal shown on that End's card. With none set, End steps show no mark and publish as they do. Ask the developer whether this host's runs need to say if they ended well.
66
66
  - `publish_note` — a sentence shown directly under the Publish button in this host's flow panel. It is shown as plain text. With none set, the panel shows no note.
67
- - `back_link` — a hash with a `label` and an `address`, such as `{ label: "Games", address: "/admin/games" }`, that shows a button with that label and address in this host's builder header in place of `All flows`. The header then has no `All flows` button. A hash missing either key raises `ArgumentError` when the host is declared, and a blank value is not refused. The address is used as written and is not checked, so it comes from the app's own configuration and never from a request. It may instead be a callable that takes the flow being shown and returns that hash, such as `->(flow) { { label: "Funnel", address: "/funnels/#{flow.owner_id}" } }`, so each flow's canvas links to a page of its own, such as its owner record's page. A returned hash missing either key raises `ArgumentError` when that flow's canvas is opened. With none set, the header shows `All flows`.
67
+ - `back_link` — a hash with a `label` and an `address`, such as `{ label: "Games", address: "/admin/games" }`, that shows a link with that label and address at the start of this host's editor top bar in place of `All flows`. The bar then has no `All flows` link. A hash missing either key raises `ArgumentError` when the host is declared, and a blank value is not refused. The address is used as written and is not checked, so it comes from the app's own configuration and never from a request. It may instead be a callable that takes the flow being shown and returns that hash, such as `->(flow) { { label: "Funnel", address: "/funnels/#{flow.owner_id}" } }`, so each flow's canvas links to a page of its own, such as its owner record's page. A returned hash missing either key raises `ArgumentError` when that flow's canvas is opened. With none set, the bar shows `All flows`.
68
+ - `editor_buttons` — a list of hashes each with a `label` and an `address`, such as `[ { label: "Run tests", address: "/admin/flow_tests" }, { label: "Dry-run", address: "/admin/dry_runs" } ]`, shown as buttons in this host's editor top bar before `Save draft`, on the canvas and on the definition text page. On a phone they are reached from the bar's actions menu. It may instead be a callable that takes the flow being shown and returns that list, such as `->(flow) { [ { label: "Run tests", address: "/admin/flow_tests/#{flow.slug}" } ] }`, so each flow's buttons lead to pages of its own. A hash missing either key raises `ArgumentError` when the canvas is opened. Each address is used as written, so it comes from the app's own configuration and never from a request. The app decides what each address does. With none set, the bar shows no extra buttons. Ask the developer which buttons each host's editor needs.
68
69
  - `on_publish` — a callable that takes a flow, such as `->(flow) { RecountJob.perform_later(flow.id) }`, that easy_flow calls each time a new version of one of this host's flows goes live, whether an admin pressed Publish on the canvas or the app called `publish` on the flow. It runs inside the publish request, so slow work belongs in a job it starts. Publishing a version that is already live does not call it. With none set, nothing is called. Ask the developer what the app must do when a flow goes live.
69
70
  - `setting_explanations` — this host's own explanations for step type settings, as a hash of step type name to setting name to a sentence, such as `{ multiple_select: { category: "The round this question counts toward.", "answers.weight" => "Points this answer adds to the score." } }`. A setting inside a list is named by the list and the setting joined with a dot, and a list setting's own explanation is named by the list alone. The sentence is shown as plain text under the setting in the step's settings, in place of the step type's own. A setting with none, or with a blank one, shows the step type's own, if it has one. A step type or setting name that matches nothing is ignored. A value that is not text, such as a nested hash, raises `ArgumentError` when the host is declared. With none set, every setting shows the step type's own explanation.
70
71
 
@@ -167,6 +168,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
167
168
  - After setting `canvas_direction` to `:left_to_right` on a host, check that its canvas shows the steps in rows joined by short lines, that a branch or loop to a step not beside it is written on its step's card, and that a phone-width screen shows one step per row.
168
169
  - A page of the app that calls `easy_flow_run_view` needs the `keystone_ui/react` and `easy_flow/canvas` scripts in its head, the same two the canvas page loads. The helper needs no setting in the initializer, and it is available in every view of the app. After adding one, check that the page shows each step's card with the state and status line the app supplied, and that a phone-width screen shows one card per row.
169
170
  - After setting `step_groups` on a host, check that its canvas shows the step list beside the canvas with each step type under its heading, that typing in its search field narrows the list, that clicking a type adds an unconnected step, that dragging a type onto a connection inserts it there, and that a phone-width screen shows no step list.
171
+ - After setting `editor_buttons` on a host, check that its canvas's top bar shows each button between `Try it` and `Save draft` with the label given, that each opens its address, and that on a phone-width screen the buttons are listed in the bar's actions menu.
170
172
  - Every stored run keeps each step's value together with the time the step was completed. An app upgrading from a version that kept values alone runs `bin/rails easy_flow:install:migrations` and `bin/rails db:migrate` before any stored run takes an answer. The migration wraps each value its existing runs already hold, and those values carry no completion time. Running the migration back drops every completion time.
171
173
  - After install, check that a Compare step, a Compare two values step, or a comparison of an All of or Any of step, once its earlier step is picked, offers "Hour completed", "Weekday completed" and "Minutes since 1970 when completed" beside that step's own outputs. They need no setting in the initializer.
172
174
  - After install, check that a Wait step placed on the canvas asks for the earlier step it counts from, minutes after it, a time of day as HH:MM and a date as YYYY-MM-DD. It needs no migration beyond the one that keeps each step's completion time with its value and no setting in the initializer beyond being listed in a host's `offers` when that host sets `offers`.
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.44.0
4
+ version: 0.46.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -127,6 +127,7 @@ files:
127
127
  - app/models/easy_flow/definition.rb
128
128
  - app/models/easy_flow/digest.rb
129
129
  - app/models/easy_flow/document.rb
130
+ - app/models/easy_flow/draft_status.rb
130
131
  - app/models/easy_flow/drawing.rb
131
132
  - app/models/easy_flow/edge.rb
132
133
  - app/models/easy_flow/edit_history.rb
@@ -170,6 +171,7 @@ files:
170
171
  - app/views/easy_flow/flows/show.html.erb
171
172
  - app/views/easy_flow/flows/step.html.erb
172
173
  - app/views/easy_flow/manage/definitions/edit.html.erb
174
+ - app/views/easy_flow/manage/flows/_top_bar.html.erb
173
175
  - app/views/easy_flow/manage/flows/edit.html.erb
174
176
  - app/views/easy_flow/manage/flows/index.html.erb
175
177
  - app/views/easy_flow/manage/flows/new.html.erb