easy_flow 0.49.1 → 0.50.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: d1bc6c3021e5483a54e6b7437ccd1bfb77e1b6f55b756a297229001a23890344
4
- data.tar.gz: 05f7f41e775e425c575d1674704a4b2d1d6027e36085a1da1126ac03ced0de98
3
+ metadata.gz: 4954c47f87f709a5002637d67d4b0d7c3a8f74c1100aeb4738312cc25af79b8d
4
+ data.tar.gz: 4a0c68e2ca8bbe8227adca1889c29afccb9d61ebbe20049059bf767640078485
5
5
  SHA512:
6
- metadata.gz: 75709e2b24eb83d2d3864415a9986e15aa5b13c12d1edb722afaef188914640e5396d85897b2477b65d56c2635f1ec5dc2035348a4183aa3c319fb4612b5ae2c
7
- data.tar.gz: a728dacda4be3a8d33fc93d45e5b4913703b21f3496a5f88a8ff74cd4aaecb5746a9794d8d42f2cd8d8f76130186f42cb5e47aac63a628b1720887b0e3ae7e42
6
+ metadata.gz: 2f9ff5fec448f4044635885f2ac33abf9620fc081261392b60da0cdb81d18d48bb2e310933b2d6754e6eed8e02e73ed463f4166deff3f13a8e53cbfba0fa9908
7
+ data.tar.gz: a10f84cfdd3573f2584d362976219226f82b66c565d7655fef8916f6fb0bf008944cc7a953ee6d626ac8a6b5e9b474f1a361633862bb013a3fc2c797e471558c
@@ -1,3 +1,3 @@
1
- (()=>{var Yt=globalThis.ReactDOM;var{createPortal:es,createRoot:ge,flushSync:ts,hydrateRoot:os,preconnect:rs,prefetchDNS:ss,preinit:ns,preinitModule:as,preload:is,preloadModule:ls,requestFormReset:ds,unstable_batchedUpdates:cs,useFormState:ps,useFormStatus:ms,version:us}=Yt;var xe=globalThis.React,t=xe,{Children:gs,Component:xs,Fragment:hs,PureComponent:ys,StrictMode:bs,Suspense:vs,cloneElement:ks,createContext:ws,createElement:Ss,createRef:Cs,forwardRef:Ns,isValidElement:_s,lazy:zs,memo:Es,startTransition:Bs,useCallback:Ts,useContext:As,useDebugValue:Ds,useDeferredValue:Ls,useEffect:M,useId:Os,useImperativeHandle:$s,useLayoutEffect:he,useMemo:$,useReducer:Ps,useRef:Z,useState:S,useSyncExternalStore:Ms,useTransition:Is}=xe;var ye=new Map,W=new Map,Q=(e,o)=>ye.set(e,o),be=()=>{W.forEach(e=>e.unmount()),W.clear()},ve=(e,o)=>e.querySelectorAll("[data-react-ui]").forEach(s=>{if(W.has(s))return;let r=ye.get(s.dataset.reactUi),n=o(s);W.set(s,n),n.render(t.createElement(r,JSON.parse(s.dataset.props)))});var ke=(e,o)=>{let s=()=>ve(e,o);e.addEventListener("turbo:load",s),e.addEventListener("turbo:frame-load",s),e.addEventListener("turbo:before-cache",be),e.readyState==="loading"?e.addEventListener("DOMContentLoaded",s):s()};var k=(...e)=>e.filter(Boolean).join(" ");var Xt={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},qt={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Jt=({variant:e="primary",size:o="md",className:s,children:r,...n})=>{let i=n.href?"a":"button";return t.createElement(i,{...n,className:k("ks-button",Xt[e],qt[o],s)},r)},b=Jt;var Kt="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Zt="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Qt="border border-accent-600 bg-accent-600 text-white",Rt=({name:e,connected:o,armed:s,onArm:r,connecting:n})=>t.createElement("button",{onClick:i=>{n||(i.stopPropagation(),r(i))},title:s?"Now choose a step to connect to":"Connect this branch",className:s?Qt:o?Zt:Kt,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},e||"next"),we=Rt;var eo={width:240,boxSizing:"border-box",borderRadius:8},to={minWidth:120,boxSizing:"border-box",borderRadius:6},oo={padding:"8px 14px",textAlign:"center",fontWeight:600},ro={fontWeight:600,lineHeight:1.3},so={fontSize:12,fontWeight:500,lineHeight:1.3},no=(e,o,s)=>{let r=s?"ring-4 ring-accent-600/15":"shadow-sm";return e||s&&!o?`border-accent-600 ${r}`:o?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},ao=(e,o)=>o&&e.label===e.id&&e.type_name||e.label,io=(e,o,s)=>s?o===e.type_name?null:e.type_name:e.type,lo=({node:e,selected:o,armed:s,connecting:r,onSelect:n,onOpen:i,onArm:l,onDragEnd:d,onDragStart:c,hideStepTypeCodes:x,branches:h=[],compact:f=!1,typeAbove:u=f})=>{let y=e.begins_here||e.ends_here,m=e.begins_here,C=e.ends_here?[]:e.ports,w=r&&!m,_=ao(e,x),E=io(e,_,x);return t.createElement("div",{ref:e.ref,"data-step":e.id,draggable:!m,onDragStart:v=>{v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("text/plain",e.id),c()},onDragEnd:d,onClick:e.opens&&!r?()=>i(e.opens):n,className:`bg-white ${f&&!o?"border":"border-2"} dark:bg-zinc-900 ${no(w,e.violations.length>0,o)}`,style:{...f?to:eo,padding:y?0:f?"8px 10px":"12px 14px",cursor:m?"default":r?"crosshair":"grab"}},!y&&u&&E&&t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},E),y&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:oo},_),!y&&t.createElement("div",{style:f?so:ro},_),e.violations.length>0&&t.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${e.violations.length} error${e.violations.length===1?"":"s"}`),!y&&e.summary&&e.violations.length===0&&t.createElement("div",{className:o?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},e.summary),!y&&!u&&E&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},E),e.picture_url&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),e.starts_a_flow&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),e.opens&&t.createElement(b,{variant:"secondary",size:"sm",className:"mt-2",onClick:v=>{v.stopPropagation(),n()}},"Settings"),h.map(v=>t.createElement("div",{key:v,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},v)),C.length>0&&t.createElement("div",{style:{padding:e.begins_here?"0 14px 8px":"10px 0 0"}},C.map(v=>t.createElement(we,{key:v,name:v,connected:e.connected.includes(v),connecting:r,armed:s===v,onArm:g=>l(v,g)}))))},R=lo;var Se={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},co={...Se,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},po=({node:e,header:o,onSelect:s,compact:r=!1})=>t.createElement("div",{ref:e.ref,"data-group-header":e.id,onClick:s,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?co:Se,...s?{}:{cursor:"default"}}},o),V=po;var mo=({id:e,bounds:o,onDrop:s})=>t.createElement("div",{"data-group-box":e,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),s()},className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",zIndex:1,borderRadius:8,boxSizing:"border-box",...o}}),Ce=mo;var uo=e=>e!=null&&e!==""&&typeof e!="object",fo=["integer","float"],go=(e,o,s)=>s&&o.labels?.[e]||e,F=(e,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>uo(e.config[n])).map(n=>`${go(n,o,s)}${fo.includes(o.fields[n])?"":":"} ${e.config[n]}`);return[s&&e.type_name||e.type,...r].join(" \xB7 ")};var Ne=(e,o,s)=>{let r=Math.min(...e.map(d=>d.left))-o.left+s.scrollLeft-12,n=Math.min(...e.map(d=>d.top))-o.top+s.scrollTop-10,i=Math.max(...e.map(d=>d.left+d.width))-o.left+s.scrollLeft+12,l=Math.max(...e.map(d=>d.top+d.height))-o.top+s.scrollTop+10;return{left:r,top:n,width:i-r,height:l-n}},xo=({left:e,top:o,width:s,height:r},n)=>n.x>=e&&n.x<=e+s&&n.y>=o&&n.y<=o+r,_e=(e,o)=>e.find(s=>xo(s.bounds,o))?.id||null,ze=(e,o)=>e.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),Ee=(e,o)=>o.some(s=>s.holds?.includes(e.id)&&!s.loose&&s.row===e.row-1);var ee=(e,o)=>e.includes(o)?e.filter(s=>s!==o):[...e,o],Be=(e,o)=>({...o?.choices||{},...e?.choices||{}});var ho=({as:e="input",disabled:o,className:s,...r})=>t.createElement(e,{...r,disabled:o,className:k("ks-input",o&&"ks-input-disabled",s)}),D=ho;var yo=e=>t.createElement(D,{...e,as:"select"}),Te=yo;var bo=({className:e,...o})=>t.createElement("input",{type:"checkbox",...o,className:k("ks-checkbox",e)}),U=bo;var vo=({name:e,value:o,label:s,hint:r,className:n,...i})=>t.createElement("label",{className:"inline-block cursor-pointer relative"},t.createElement("input",{type:"radio",name:e,value:o,...i,className:k("peer sr-only",n)}),t.createElement("span",{className:"ks-radio-card inline-flex flex-col cursor-pointer transition ks-radio-card-highlight"},t.createElement("span",{className:"ks-radio-card-header flex items-start justify-between"},t.createElement("span",{className:"ks-radio-card-label block"},s)),r!=null&&t.createElement("span",{className:"ks-radio-card-hint block text-sm"},r))),Ae=vo;var ko=({name:e,options:o,value:s,onChange:r,className:n})=>t.createElement("div",{className:k("flex flex-wrap ks-grid-gap-sm",n)},o.map(i=>t.createElement(Ae,{key:i.value,name:e,...i,checked:i.value===s,onChange:()=>r(i.value)}))),De=ko;var Le=e=>(e||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),wo=({name:e,type:o,value:s,choices:r,onChange:n,onSettle:i,onPick:l,pictureUrl:d})=>{if(o==="picture")return t.createElement("div",{className:"mb-3"},s&&d&&t.createElement("img",{src:d,alt:"The step's picture",style:{maxWidth:"100%"}}),s&&t.createElement(b,{type:"button",variant:"secondary",size:"sm","data-remove-picture":!0,onClick:()=>i("")},"Remove picture"),t.createElement("input",{type:"file",accept:"image/*",onChange:c=>c.target.files[0]&&l(c.target.files[0])}));if(o==="boolean")return t.createElement(U,{checked:!!s,onChange:c=>i(c.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return t.createElement(Te,{className:"mb-3",value:s??"",onChange:c=>i(c.target.value)},t.createElement("option",{value:""}),Le(r).map(c=>t.createElement("option",{key:c.value,value:c.value},c.label)));if(o==="radio_cards")return t.createElement("div",{"data-radio-cards":!0,className:"mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full"},t.createElement(De,{name:e,value:s,options:r||[],onChange:i}));if(o==="multi_select"){let c=Array.isArray(s)?s:[],x=h=>i(ee(c,h));return t.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(r||[]).map(h=>t.createElement("label",{key:h,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(U,{checked:c.includes(h),onChange:()=>x(h)}),t.createElement("span",null,h))))}if(o==="flows"){let c=Array.isArray(s)?s:[];return t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},Le(r).map(x=>t.createElement("label",{key:x.value,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(U,{checked:c.includes(x.value),onChange:()=>i(ee(c,x.value))}),t.createElement("span",null,x.label))))}return o==="integer"||o==="float"?t.createElement(D,{className:"mb-3",type:"number",step:o==="integer"?"1":"any",value:s??"",onChange:c=>n(c.target.value),onBlur:c=>i(c.target.value)}):t.createElement(D,{className:"mb-3",type:"text",value:s??"",onChange:c=>n(c.target.value),onBlur:c=>i(c.target.value)})},G=wo;var Oe=(e,o,s,r)=>e.map((n,i)=>i===o?{...n,[s]:r}:n);var So=({text:e})=>t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},e),Y=So;var Co=(e,o,s,r)=>{let n=(e||{})[s],i=(o||{})[s];return i?(n||{})[r[i]]:n},No=({holds:e,labels:o,explanations:s,rows:r,choices:n,outputsOf:i,onChange:l,onSettle:d})=>{let c=Array.isArray(r)?r:[],x=(h,f,u,y)=>{let m=Oe(c,h,f,u);y?d(m):l(m)};return t.createElement("div",{style:{marginBottom:12}},c.map((h,f)=>t.createElement("div",{key:f,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(e).map(([u,y])=>t.createElement("label",{key:u,style:{display:"block"}},t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[u]||u),t.createElement(G,{type:y,value:h[u],choices:Co(n,i,u,h),onChange:m=>x(f,u,m,!1),onSettle:m=>x(f,u,m,!0)}),(s||{})[u]&&t.createElement(Y,{text:s[u]}))),t.createElement(b,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>d(c.filter((u,y)=>y!==f))},"Remove"))),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>d([...c,{}])},"Add"))},$e=No;var _o={start:null,end:"ks-value-list-end"},zo="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",Eo="flex flex-col min-w-0",Bo="ks-value-list-label basis-auto text-xs",To=()=>t.createElement("svg",{"aria-label":"Right",role:"img",className:"ks-tone-success inline size-5 align-text-bottom",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},t.createElement("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z",clipRule:"evenodd"})),Ao=({value:e,fallback:o})=>String(e??"")===""?o:e,Do=({rows:e,align:o="start",columns:s=!1,className:r})=>t.createElement("dl",{className:k("ks-value-list",_o[o],s&&zo,r)},e.map((n,i)=>t.createElement("div",{key:i,className:k(s?Eo:"ks-value-list-row",n.total&&"ks-value-list-total")},t.createElement("dt",{className:s?Bo:"ks-value-list-label"},n.label,n.note!=null&&t.createElement(t.Fragment,null," ",t.createElement("span",{className:"ks-value-list-note"},n.note))),t.createElement("dd",{className:"ks-value-list-value"},Ao(n),n.right&&t.createElement(t.Fragment,null," ",t.createElement(To,null)))))),Pe=Do;var Lo=()=>t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})),Oo=({summary:e,open:o=!1,className:s,children:r})=>t.createElement("details",{className:k("ks-disclosure group",s),open:o},t.createElement("summary",{className:"ks-disclosure-summary flex cursor-pointer list-none items-center justify-between [&::-webkit-details-marker]:hidden"},t.createElement("span",null,e),t.createElement("span",{className:"ks-disclosure-icon h-4 w-4 shrink-0 transition-transform group-open:rotate-180"},t.createElement(Lo,null))),t.createElement("div",{className:"ks-disclosure-body text-sm"},r)),Me=Oo;var $o=({language:e,caption:o,className:s,children:r})=>t.createElement("div",{className:k("ks-code overflow-hidden",s)},o!=null&&t.createElement("div",{className:"ks-code-caption font-mono text-xs"},o),t.createElement("pre",{className:"ks-code-block overflow-x-auto font-mono text-sm leading-relaxed"},t.createElement("code",{className:e==null?"":`language-${e}`},r))),Ie=$o;var te="flex flex-col gap-1 mb-3",je="[&_dd]:font-mono",Po="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",Mo="[&_.ks-value-list]:font-mono [&_.ks-value-list]:flex [&_.ks-value-list]:flex-col [&_.ks-value-list]:gap-1 [&_.ks-value-list-row]:gap-2 [&_.ks-value-list-row]:py-0 [&_.ks-value-list-row]:border-0 [&_.ks-value-list-label]:basis-[90px]",Io="border-t border-gray-200 pt-2.5 dark:border-zinc-700 [&_.ks-disclosure]:border-0 [&_.ks-disclosure-summary]:flex-row-reverse [&_.ks-disclosure-summary]:justify-end [&_.ks-disclosure-summary]:gap-1 [&_.ks-disclosure-summary]:p-0 [&_.ks-disclosure-summary]:font-normal [&_.ks-disclosure-body]:p-0 [&_.ks-disclosure-body]:pt-1.5 [&_.ks-code-block]:p-2 [&_.ks-code-block]:text-[11px]",jo=e=>e.values?e.columns?`${te} ${je} ${Po}`:`${te} ${je} ${Mo}`:`${te} ${Io}`,Ho=({details:e})=>t.createElement(t.Fragment,null,e.map((o,s)=>t.createElement("section",{key:s,className:jo(o)},o.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400"},o.heading),o.values&&t.createElement(Pe,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>t.createElement(Me,{key:r.summary,summary:r.summary},t.createElement(Ie,null,r.code)))))),He=Ho;var Wo=({as:e="div",className:o,children:s,...r})=>t.createElement(e,{...r,className:k("ks-panel",o)},s),A=Wo;var X=(e,o)=>({className:s,children:r,...n})=>t.createElement(e,{...n,className:k(o,s)},r),H=X("label","ks-label"),la=X("p","ks-hint"),da=X("p","ks-error"),ca=X("span","ks-required");var Vo={width:320,padding:"14px 16px",overflowY:"auto",display:"flex",flexDirection:"column",fontSize:12},Fo={marginTop:"auto",paddingTop:12,display:"flex",flexDirection:"column",gap:8},Uo=({node:e,fields:o,holds:s,labels:r,explanations:n,recordLabels:i,recordExplanations:l,recordChoices:d,recordOutputsOf:c,choices:x,onSave:h,onDelete:f,onClose:u,onPickPicture:y,refusal:m})=>{let[C,w]=S(e.config),[_,E]=S(e.picture_url);M(()=>E(e.picture_url),[e.id,e.picture_url]),M(()=>w(e.config),[e.id,e.config]);let v=g=>{w(g),JSON.stringify(g)!==JSON.stringify(e.config)&&h(g)};return t.createElement(A,{as:"aside",style:Vo,className:"max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto","data-inspector":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8,marginBottom:12}},t.createElement("div",null,t.createElement("p",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.id," \xB7 ",e.type),t.createElement("h2",{style:{fontSize:15,fontWeight:600}},e.label)),t.createElement("button",{title:"Close",onClick:u,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),m&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},m),Object.entries(o).map(([g,L])=>t.createElement(H,{key:g},t.createElement("span",{style:{display:"block",marginBottom:3}},r[g]||g),L==="list"?t.createElement($e,{holds:s[g]||{},labels:i[g]||{},explanations:(l||{})[g],rows:C[g],choices:{...(d||{})[g],...(e.record_choices||{})[g]},outputsOf:(c||{})[g],onChange:z=>w({...C,[g]:z}),onSettle:z=>v({...C,[g]:z})}):t.createElement(G,{name:g,type:L,value:C[g],choices:x[g],pictureUrl:_,onChange:z=>w({...C,[g]:z}),onSettle:z=>v({...C,[g]:z}),onPick:async z=>{let B=await y(z);B&&(E(B.url),v({...C,[g]:B.reference}))}}),(n||{})[g]&&t.createElement(Y,{text:n[g]}))),t.createElement(He,{details:e.details||[]}),t.createElement("div",{style:Fo},(e.links||[]).length>0&&t.createElement("div",{style:{display:"flex",gap:8}},e.links.map(g=>t.createElement(b,{key:g.address,variant:"secondary",size:"sm",className:"flex-1",href:g.address},g.label))),t.createElement(b,{variant:"danger",size:"sm",className:"w-full",onClick:f},"Delete step")))},We=Uo;var Go={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},Yo={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},Xo="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",qo="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Jo=({node:e,dragging:o,onFill:s,onDrop:r,compact:n=!1})=>t.createElement("div",{ref:e.ref,"data-placeholder":e.id,title:`Choose the step \u201C${e.label}\u201D should lead to`,onClick:s,onDragOver:i=>{o&&(i.preventDefault(),i.dataTransfer.dropEffect="move")},onDrop:i=>{i.preventDefault(),r()},className:o?qo:Xo,style:n?Yo:Go},t.createElement("div",{style:{fontWeight:600}},e.label),t.createElement("div",{style:{fontSize:11}},o?"drop a step here":"leads nowhere yet \u2014 click to choose")),Ve=Jo;var Ko=({entries:e,at:o,onPick:s,onConnect:r,onDismiss:n,hideStepTypeCodes:i})=>t.createElement(A,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:o.y,left:o.x,width:210,padding:8,borderRadius:8}},t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),e.map(l=>t.createElement(b,{key:l.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>s(l)},l.label,!i&&t.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},l.type))),r&&t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full",onClick:n},"Cancel")),Fe=Ko;var Zo=e=>o=>o.label.toLowerCase().includes(e.trim().toLowerCase()),Qo=(e,o,s="")=>{let r=Object.values(o).flat(),n=Object.entries(o).map(([i,l])=>({heading:i,entries:l.map(d=>e.find(c=>c.type===d)).filter(Boolean)}));return[{heading:null,entries:e.filter(i=>!r.includes(i.type))},...n].map(i=>({...i,entries:i.entries.filter(Zo(s))})).filter(i=>i.entries.length>0)},Ro={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},er={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},tr={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},or=({entries:e,groups:o,onPick:s,onCarry:r,onDrop:n})=>{let[i,l]=S("");return t.createElement(A,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:Ro},t.createElement(D,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:i,onChange:d=>l(d.target.value),style:{marginBottom:6,fontSize:12}}),Qo(e,o,i).map(d=>t.createElement(t.Fragment,{key:d.heading||""},d.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:er},d.heading),d.entries.map(c=>t.createElement(A,{as:"button",type:"button",key:c.type,"data-step-type":c.type,className:"bg-surface-50 dark:bg-surface-950",style:tr,draggable:!0,onClick:()=>s(c),onDragStart:x=>{x.dataTransfer.effectAllowed="copyMove",x.dataTransfer.setData("text/plain",c.type),r(c)},onDragEnd:n},c.label)))))},Ue=or;var rr={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Ge=({label:e,title:o,idle:s,enabled:r,onUse:n})=>t.createElement(b,{variant:"secondary",size:"sm",title:r?o:s,disabled:!r,onClick:n,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},e),sr=({undoable:e,redoable:o,onAdd:s,onUndo:r,onRedo:n})=>t.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},t.createElement(b,{variant:"secondary",className:"rounded-full",style:rr,title:"Add a step",onClick:s},"+"),t.createElement(Ge,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:e,onUse:r}),t.createElement(Ge,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),Ye=sr;var nr=({type:e="info",title:o,message:s,onDismiss:r,className:n})=>t.createElement("div",{className:k("ks-alert",`ks-alert-${e}`,n),role:"alert"},t.createElement("div",{className:"ks-alert-body"},t.createElement("div",{className:"ks-alert-content"},o&&t.createElement("p",{className:"ks-alert-title"},o),t.createElement("p",{className:o?"ks-alert-message-titled":"ks-alert-message"},s)),r&&t.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),Xe=nr;var qe=e=>{let o=e.map(s=>`\u201C${s.name}\u201D`).join(", ");return e.length===1?`${o} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${o} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var Je=({version:e,published:o})=>e?o?o===e?`Version ${e} \xB7 live`:`Version ${e} \xB7 visitors still on ${o}`:`Version ${e} \xB7 never published`:"No version yet";var ar={width:280,padding:20,overflowY:"auto"},Ke={fontWeight:600,marginBottom:6,marginTop:14},oe={fontSize:12,marginBottom:4,lineHeight:1.4},Ze={display:"block",marginBottom:3},Qe=(e,o,s)=>r=>{r.target.value!==(e[o]??"")&&s({[o]:r.target.value})},ir=({flow:e,changes:o,refusal:s,notice:r,publishNote:n,warning:i,onCreate:l,onPublish:d,onAccept:c,onDecline:x,onSaveDetails:h,onClose:f})=>t.createElement(A,{as:"aside",style:ar,"data-builder-panel":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},t.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},e.title||e.slug),t.createElement("button",{title:"Close",onClick:f,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),t.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:e.history_url,"data-history":!0},Je(e)),i?t.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},t.createElement(Xe,{type:"warning",className:"mb-1.5",message:qe(i.steps)}),t.createElement(b,{size:"sm",className:"w-full mb-1.5",onClick:c,"data-accept-removal":!0},i.path==="/publish"?"Remove and publish":"Remove and create version"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:x,"data-decline-removal":!0},"Cancel")):t.createElement("div",{style:{marginTop:14}},t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:l,"data-create-version":!0},"Create version"),t.createElement(b,{size:"sm",className:"w-full mb-1.5",onClick:d,"data-publish":!0},"Publish"),n&&t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},n)),s&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...oe,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&t.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...oe,fontWeight:600,marginTop:8},"data-notice":!0},r),t.createElement("h2",{style:Ke},"Changes since the last version"),o.length===0?t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):o.map((u,y)=>t.createElement("p",{key:y,style:oe,"data-change":!0},u)),t.createElement("h2",{style:Ke},"Details"),t.createElement(H,null,t.createElement("span",{style:Ze},"Title"),t.createElement(D,{className:"mb-3",defaultValue:e.title??"",onBlur:Qe(e,"title",h),"data-flow-title":!0})),t.createElement(H,null,t.createElement("span",{style:Ze},"Start label"),t.createElement(D,{className:"mb-3",defaultValue:e.start_label??"",onBlur:Qe(e,"start_label",h),"data-flow-start-label":!0})),t.createElement("div",{style:{marginTop:16}},t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.definition_url,"data-definition":!0},"Definition"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.details_url,"data-details":!0},"Edit details"))),Re=ir;var lr=({variant:e="neutral",className:o,children:s,...r})=>t.createElement("span",{...r,className:k("ks-badge",`ks-badge-${e}`,o)},s),et=lr;var dr={center:"ks-tab-bar flex flex-wrap justify-center max-sm:flex-nowrap max-sm:overflow-x-auto max-sm:justify-start",start:"ks-tab-bar flex flex-wrap justify-start max-sm:flex-nowrap max-sm:overflow-x-auto"},cr={pills:"ks-tab-bar-pills",underline:"ks-tab-bar-underline"},pr="ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",mr="ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",ur=({shape:e,count:o})=>e?t.createElement("span",{className:"ks-tab-count"},o):t.createElement(et,{variant:"info"},o),fr=e=>typeof e=="string"?e!=="":e>0,gr=({tabs:e,value:o,onChange:s,align:r="center",shape:n,className:i})=>t.createElement("div",{className:i},t.createElement("div",{className:k(dr[r],cr[n])},e.map(l=>t.createElement("button",{key:l.value,type:"button",className:n?mr:pr,"data-active":l.value===o?"":void 0,onClick:()=>s(l.value)},l.label,fr(l.count)&&t.createElement(t.Fragment,null," ",t.createElement(ur,{shape:n,count:l.count}))))),e.find(l=>l.value===o)?.content),tt=gr;var xr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},ot="mx-6 mb-6 flex max-h-[45%] flex-none flex-col overflow-y-auto rounded-lg max-sm:m-0 max-sm:max-h-none max-sm:rounded-none [&_.ks-tab-bar]:mb-0 [&_.ks-tab-bar]:px-2",hr="max-sm:absolute max-sm:inset-0 max-sm:z-20",nt={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},rt={display:"flex",gap:8,textAlign:"left"},st={flexShrink:0,whiteSpace:"nowrap"},yr=({check:e,onSelect:o})=>{let s=t.createElement(t.Fragment,null,t.createElement("span",{className:xr[e.level],style:{...st,fontWeight:500}},e.level),e.node&&t.createElement("span",{className:"font-mono",style:st},e.node),t.createElement("span",null,e.sentence));return e.node?t.createElement("button",{type:"button","data-check-row":!0,"data-step-id":e.node,style:{...rt,border:"none",background:"none",padding:0,cursor:"pointer",font:"inherit",color:"inherit"},onClick:()=>o(e.node)},s):t.createElement("div",{"data-check-row":!0,style:rt},s)},br=({checks:e,onSelect:o})=>t.createElement("div",{style:nt},e.map((s,r)=>t.createElement(yr,{key:r,check:s,onSelect:o}))),vr=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,kr=({checks:e,tabs:o,onSelect:s,opened:r=vr()?null:"validation"})=>{let[n,i]=S(r);return t.createElement(A,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${ot} ${hr}`:ot},t.createElement(tt,{align:"start",shape:"underline",value:n,onChange:l=>i(l===n?null:l),tabs:[{value:"validation",label:"Validation",count:e.filter(l=>l.level==="error").length,content:t.createElement(br,{checks:e,onSelect:s})},...o.map(l=>({value:l.label,label:l.label,count:l.count??"",content:t.createElement("div",{"data-drawer-content":!0,style:nt,dangerouslySetInnerHTML:{__html:l.content}})}))]}))},at=kr;var it={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},lt=e=>({opacity:e?1:0,transition:"opacity .12s"}),wr=({link:e,onInsert:o,onRemove:s,onDrop:r,dragging:n,alwaysShowInsertButtons:i})=>{let[l,d]=S(!1),c=l||n;return t.createElement("div",{"data-connector":`${e.source}-${e.target}`,style:{position:"absolute",left:e.midX-34,top:e.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onDragEnter:()=>d(!0),onDragLeave:()=>d(!1),onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},onDrop:x=>{x.preventDefault(),d(!1),r()}},t.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},t.createElement(b,{variant:"secondary",title:n?"Move the step here":"Insert a step here",onClick:o,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(n&&l),style:{...it,...lt(c||i)}},"+"),!n&&t.createElement(b,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...it,...lt(c)}},"\xD7")))},dt=wr;var Sr=({links:e,extent:o,dragging:s,onInsert:r,onRemove:n,onDrop:i,alwaysShowInsertButtons:l})=>t.createElement(t.Fragment,null,t.createElement("svg",{width:o.width,height:o.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},t.createElement("defs",null,t.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},t.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),e.map(d=>t.createElement("path",{key:d.id,"data-link":d.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:d.path}))),e.filter(d=>d.label).map(d=>t.createElement("div",{key:`${d.id}-label`,"data-link-label":d.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:d.midX+(l?2:-10),top:d.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},d.label)),e.filter(d=>!d.placeholder).map(d=>t.createElement(dt,{key:d.id,link:d,dragging:!!s,alwaysShowInsertButtons:l,onInsert:()=>r(d),onRemove:()=>n(d),onDrop:()=>i(d)}))),ct=Sr;var re={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},pt="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Cr=({link:e,onInsert:o,onRemove:s,onDrop:r,alwaysShowInsertButtons:n,dragging:i})=>t.createElement("div",{"data-joint":e?.id,className:"group relative h-7 w-full sm:h-auto sm:w-7 sm:self-stretch",onMouseEnter:l=>{l.currentTarget.dataset.over="true"},onMouseLeave:l=>{delete l.currentTarget.dataset.over},onDragOver:l=>{e&&r&&(l.preventDefault(),l.dataTransfer.dropEffect="move")},onDrop:l=>{e&&(l.preventDefault(),r(e))}},e&&t.createElement("div",{className:"absolute left-1/2 top-0 h-full w-px bg-gray-400 sm:left-0 sm:top-1/2 sm:h-px sm:w-full dark:bg-zinc-500"}),e&&o&&t.createElement("div",{className:"absolute inset-0 flex items-center justify-center gap-1 sm:flex-col",style:{zIndex:4}},t.createElement(b,{variant:"secondary",title:"Insert a step here",onClick:l=>o(e,l),className:`rounded-full ${n?"opacity-100":pt}`,style:i?{...re,opacity:1}:re},"+"),t.createElement(b,{variant:"danger",title:"Remove this connection",onClick:()=>s(e),className:`rounded-full ${pt}`,style:re},"\xD7"))),mt=Cr;var Nr=(e,o)=>e.row-o.row||e.column-o.column,ut=e=>new Map(e.flatMap(o=>(o.holds||[]).map(s=>[s,o.id]))),ft=e=>{let o=[...e].sort(Nr),s=ut(e),r=new Map(e.filter(n=>n.holds).map(n=>[n.id,[]]));return o.filter(n=>s.has(n.id)).forEach(n=>r.get(s.get(n.id)).push(n)),o.filter(n=>!s.has(n.id)).flatMap(n=>[n,...r.get(n.id)||[]])},gt=e=>{let o=ut(e),s=ft(e),r=[],n=new Map;return s.filter(i=>!o.has(i.id)).forEach(i=>{let l=r[r.length-1];i.holds?n.set(i.id,r[r.push({group:i,steps:[]})-1]):l&&!l.group?l.steps.push(i):r.push({steps:[i]})}),s.filter(i=>o.has(i.id)).forEach(i=>n.get(o.get(i.id))?.steps.push(i)),r},_r=e=>e?.placeholder?"nowhere yet":e?.label,se=new WeakMap,zr=e=>(se.has(e)||se.set(e,new Map([...e].reverse().map(o=>[`${o.source}
2
- ${o.target}`,o]))),se.get(e)),xt=(e,o,s)=>zr(e).get(`${o.id}
3
- ${s.id}`),ht=(e,o,s)=>{let r=ft(e),n=new Map(r.map((d,c)=>[d.id,r[c+1]?.id])),i=new Map(s.map(d=>[d.id,_r(d)])),l=Object.fromEntries(e.map(d=>[d.id,[]]));return o.filter(d=>l[d.source]&&(d.label||d.target!==n.get(d.source))).forEach(d=>l[d.source].push([d.label,"\u2192",i.get(d.target)].filter(Boolean).join(" "))),l};var Er={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},yt=({steps:e,edges:o,draw:s,joints:r})=>t.createElement("div",{"data-flow-row":!0,className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5"},e.map((n,i)=>t.createElement("div",{key:n.id,className:"flex flex-col sm:flex-row sm:items-center"},i>0&&t.createElement(mt,{link:xt(o,e[i-1],n),...r}),s(n)))),Br={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},Tr=({group:e,steps:o,edges:s,draw:r,joints:n})=>t.createElement("div",{"data-group-box":e.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:Br},r(e),t.createElement(yt,{steps:o,edges:s,draw:r,joints:n})),Ar=({nodes:e,edges:o,draw:s,joints:r,children:n,style:i})=>t.createElement("div",{"data-flow-rows":!0,style:{...Er,...i}},n,gt(e).map(l=>l.group?t.createElement(Tr,{key:l.group.id,group:l.group,steps:l.steps,edges:o,draw:s,joints:r}):t.createElement(yt,{key:l.steps[0].id,steps:l.steps,edges:o,draw:s,joints:r}))),q=Ar;var vt="Your change was not saved because the server could not be reached.",Dr="Your change was saved, but the canvas could not be refreshed. Reload the page to see it.",bt=async({base:e,fetch:o,onFlow:s,onError:r})=>{let n=await o(e+".json",{headers:{Accept:"application/json"}}).catch(()=>null),i=n?.ok?await n.json().catch(()=>null):null;return i?s(i):r(Dr)},kt=({base:e,token:o,fetch:s,onFlow:r,onError:n,onNotice:i,onWarning:l=()=>{}})=>async(d,c,x)=>{let h={base:e,fetch:s,onFlow:r,onError:n},f=await s(e+d,{method:c,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:x&&JSON.stringify(x)}).catch(()=>null);if(!f)return i(null),n(vt);let u=await f.json().catch(()=>({}));return u.unconnected?(i(null),n(null),l({path:d,steps:u.unconnected}),bt(h)):(l(null),f.ok?(n(null),i(u.notice||null),bt(h)):(i(null),n(u.error||"That change was refused")))},wt=({base:e,token:o,fetch:s,onError:r})=>async n=>{let i=new FormData;i.append("picture",n);let l=await s(e+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:i}).catch(()=>null);if(!l)return r(vt),null;let d=await l.json().catch(()=>({}));return l.ok?(r(null),d):(r(d.error||"That picture was refused"),null)};var Lr=(e,o,s)=>{let[r,n]=S(s),[i,l]=S(null),[d,c]=S(null),[x,h]=S(null),f=$(()=>kt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onFlow:n,onError:l,onNotice:c,onWarning:h}),[e,o]),u=$(()=>wt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onError:l}),[e,o]);return{flow:r,error:i,notice:d,warning:x,setWarning:h,send:f,pickPicture:u}},St=Lr;var J=(e,o,s,r)=>{let n=e.left-s.left+r.scrollLeft,i=e.top-s.top+r.scrollTop;return o==="left"?{x:n,y:i+e.height/2}:o==="right"?{x:n+e.width,y:i+e.height/2}:o==="top"?{x:n+e.width/2,y:i}:{x:n+e.width/2,y:i+e.height}},Or=(e,o,s)=>s&&o==="top"?{x:e.x,y:s.top}:e,$r=(e,o)=>o==="top"?{x:e.x,y:e.y-3}:o==="left"?{x:e.x-3,y:e.y}:o==="right"?{x:e.x+3,y:e.y}:{x:e.x,y:e.y+3},Pr=(e,o,s,r,n)=>{let i={straight:`M ${o.x} ${o.y} L ${s.x} ${s.y}`,turn:`M ${o.x} ${o.y} H ${s.x} V ${s.y}`,lane:`M ${o.x} ${o.y} V ${r} H ${s.x} V ${s.y}`,detour:`M ${o.x} ${o.y} H ${n} V ${s.y} H ${s.x}`}[e.route];return{...e,path:i,midX:e.route==="detour"?n:(o.x+s.x)/2,midY:e.route==="lane"?r:(o.y+s.y)/2}},Mr=(e,o,s,r)=>{let[n,i]=S([]),[l,d]=S({width:"100%",height:"100%"}),[c,x]=S([]);return he(()=>{let h=()=>{let u=o.current?.getBoundingClientRect();if(!u)return;d({width:o.current.scrollWidth,height:o.current.scrollHeight});let y=e.nodes.filter(m=>m.holds&&!m.loose&&s.current[m.id]).map(m=>{let C=s.current[m.id],w=C.getBoundingClientRect(),_=m.holds.flatMap(v=>s.current[v]?[s.current[v].getBoundingClientRect()]:[]),E=[{left:w.left,top:w.top,width:Math.max(w.width,C.scrollWidth),height:w.height},..._];return{id:m.id,bounds:Ne(E,u,o.current)}});x(y),i(e.edges.flatMap(m=>{let C=s.current[m.source]?.getBoundingClientRect(),w=s.current[m.target]?.getBoundingClientRect();if(!C||!w)return[];let _=J(C,m.leaves,u,o.current),E=y.find(z=>z.id===m.target)?.bounds,v=$r(Or(J(w,m.enters,u,o.current),m.enters,E),m.enters),g=(J(C,"bottom",u,o.current).y+J(w,"top",u,o.current).y)/2,L=m.leaves==="left"?Math.min(_.x,v.x)-28:Math.max(_.x,v.x)+28;return[Pr(m,_,v,g,L)]}))};h(),window.addEventListener("resize",h);let f=new ResizeObserver(h);return o.current&&f.observe(o.current),()=>{window.removeEventListener("resize",h),f.disconnect()}},r),{links:n,extent:l,boxes:c}},Ct=Mr;var Nt=(e,o)=>{let s=new Set(o),r=e,n=2;for(;s.has(r);)r=`${e}_${n++}`;return r};var _t=({send:e,onPress:o})=>s=>{let r=s.target.closest?.("[data-bar-action]");r&&(r.closest("details")?.removeAttribute("open"),o(),r.dataset.barPath&&e(r.dataset.barPath,"POST"))};var jr=8,Hr={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},Wr={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},Vr={flex:1,minHeight:0,overflow:"auto",position:"relative"},Et={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},Fr={...Et,position:"static",alignSelf:"flex-start"},Ur={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Bt={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Gr=({port:e,onCancel:o})=>t.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Bt},"Choose the step \u201C",e||"next","\u201D should lead to \u2014 ",t.createElement("button",{onClick:o,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),Yr=({message:e})=>t.createElement("p",{"data-canvas-error":!0,className:"bg-red-50 text-red-800 dark:bg-red-950 dark:text-red-200",style:Bt},e),Xr=({base:e,token:o,initial:s})=>{let{flow:r,error:n,notice:i,warning:l,setWarning:d,send:c,pickPicture:x}=St(e,o,s),[h,f]=S(null),[u,y]=S(null),[m,C]=S(null),[w,_]=S(null),[E,v]=S(null),[g,L]=S(!1),z=Z({}),B=Z(null);M(()=>{let a=_t({send:c,onPress:()=>{f(null),L(!0)}});return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[c]),M(()=>{if(!g){d(null);return}let a=p=>{p.target.isConnected&&!p.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&L(!1)};return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[g]),M(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),M(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let $t=$(()=>Object.fromEntries(r.nodes.map(a=>[a.id,a])),[r.nodes]),{links:Pt,extent:Mt,boxes:ne}=Ct(r,B,z,[r,h,$t]),It=$(()=>{let a={};return r.violations.forEach(p=>{var N;return(a[N=p.node]||(a[N]=[])).push(p)}),a},[r.violations]),T=r.direction==="left_to_right",j=$(()=>r.nodes.filter(a=>!a.loose),[r.nodes]),ae=r.nodes.filter(a=>a.loose),jt=$(()=>T?ht(j,r.edges,r.nodes):{},[T,j,r.edges,r.nodes]),Ht=$(()=>{let a={};return r.edges.forEach(p=>{var N;return(a[N=p.source]||(a[N]=[])).push(p.label||null)}),a},[r.edges]),Wt=Math.max(0,...j.map(a=>a.row))+1,Vt=Math.max(0,...j.map(a=>a.column))+1,ie=a=>{if(!m)return;let[p,N]=m;C(null),p!==a&&c("/edges","POST",{from:p,to:a,on:N||null})},Ft=a=>{if(a.isDefaultPrevented()||!w)return;a.preventDefault();let p=w;_(null);let N=B.current.getBoundingClientRect(),fe=_e(ne,{x:a.clientX-N.left+B.current.scrollLeft,y:a.clientY-N.top+B.current.scrollTop}),Ut=r.nodes.find(Gt=>Gt.holds?.includes(p))?.id||null;fe!==Ut&&c(`/steps/${p}/group`,"PATCH",{group:fe})},le=a=>[...r.palette,...r.unoffered||[]].find(p=>p.type===a?.type),P=r.nodes.find(a=>a.id===h),O=le(P),K=(a,p={})=>c("/steps","POST",{id:Nt(a.type,r.nodes.map(N=>N.id)),type:a.type,from:p.from,to:p.to,on:p.on}),de=a=>{let[p,N]=[E,w];v(null),_(null),p?K(p,{from:a.source,to:a.target}):N&&c("/steps/"+N+"/move","PATCH",{from:a.source,to:a.target})},ce=a=>{let p=B.current.getBoundingClientRect();return{x:a.clientX-p.left+B.current.scrollLeft+8,y:a.clientY-p.top+B.current.scrollTop+8}},pe=(a,p)=>({node:{...a,ref:N=>{z.current[a.id]=N},violations:It[a.id]||[],connected:p},selected:a.id===h,armed:m&&m[0]===a.id?m[1]:null,connecting:!!m&&m[0]!==a.id,onSelect:()=>m?ie(a.id):f(a.id),onOpen:N=>window.location.assign(N),onDragStart:()=>_(a.id),onDragEnd:()=>_(null),hideStepTypeCodes:r.hide_step_type_codes,compact:T,branches:jt[a.id]||[]}),me=a=>t.createElement(t.Fragment,null,a.placeholder&&t.createElement(Ve,{node:{...a,ref:p=>{z.current[a.id]=p}},dragging:!!w,compact:T,onFill:()=>y({from:a.from,on:a.on,at:{x:16,y:52}}),onDrop:()=>{let p=w;_(null),p&&c("/edges","POST",{from:a.from,to:p,on:a.on})}}),a.holds&&t.createElement(V,{node:{...a,ref:p=>{z.current[a.id]=p}},header:F(a,le(a),r.hide_step_type_codes),compact:T,onSelect:()=>m?ie(a.id):f(a.id)}),!a.placeholder&&!a.holds&&t.createElement(R,{...pe(a,Ht[a.id]||[]),onArm:(p,N)=>y({from:a.id,on:p,at:ce(N)})})),ue=ae.length>0&&t.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:T?Fr:Et},t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:6}},"Not in the flow yet \u2014 drag one onto a connection"),ae.map(a=>t.createElement("div",{key:a.id,style:{marginBottom:8}},t.createElement(R,{...pe(a,[]),onArm:(p,N)=>{N.stopPropagation(),C([a.id,p])}}))));return t.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:Hr,onMouseUp:()=>_(null),onKeyDown:a=>{a.key==="Escape"&&(f(null),C(null),y(null))},tabIndex:-1},t.createElement(Ue,{entries:r.palette,groups:r.step_groups||{},onPick:a=>K(a),onCarry:v,onDrop:()=>v(null)}),t.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:Wr},t.createElement("div",{ref:B,style:Vr,onClick:a=>{a.target===B.current&&(f(null),C(null),L(!1))},onDragOver:a=>{w&&a.preventDefault()},onDrop:Ft},m&&t.createElement(Gr,{port:m[1],onCancel:()=>C(null)}),n&&!g&&!P&&t.createElement(Yr,{message:n}),t.createElement(Ye,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>y({at:{x:16,y:52}}),onUndo:()=>{f(null),c("/undo","POST")},onRedo:()=>{f(null),c("/redo","POST")}}),!T&&ne.map(a=>t.createElement(Ce,{key:a.id,id:a.id,bounds:a.bounds,onDrop:()=>{let p=w;_(null),p&&c(`/steps/${p}/group`,"PATCH",{group:a.id})}})),!T&&t.createElement(ct,{links:ze(Pt,r.nodes),extent:Mt,dragging:w||E,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:a=>y({from:a.source,to:a.target,at:{x:a.midX+30,y:a.midY}}),onRemove:a=>{f(null),c("/edges","DELETE",{from:a.source,to:a.target})},onDrop:de}),!T&&ue,T&&t.createElement(q,{nodes:j,edges:r.edges,draw:me,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(w||E),onInsert:(a,p)=>y({from:a.source,to:a.target,at:ce(p)}),onRemove:a=>{f(null),c("/edges","DELETE",{from:a.source,to:a.target})},onDrop:de}},ue),!T&&t.createElement("div",{style:{...Ur,gridTemplateColumns:`repeat(${Vt+1}, ${280/2}px)`,gridTemplateRows:`repeat(${Wt}, auto)`}},j.map(a=>t.createElement("div",{key:a.id,style:{gridRow:a.row+1,gridColumn:`${a.column+1} / span 2`,zIndex:2,marginTop:Ee(a,r.nodes)?jr-64:0}},me(a)))),u&&t.createElement(Fe,{entries:r.palette,at:u.at,onDismiss:()=>y(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:u.on!==void 0?()=>{C([u.from,u.on]),y(null)}:null,onPick:a=>{let p=u;y(null),K(a,p)}})),t.createElement(at,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:f})),g&&!P&&t.createElement(Re,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:i,publishNote:r.publish_note,warning:l,onClose:()=>L(!1),onCreate:()=>c("/versions","POST"),onPublish:()=>c("/publish","POST"),onAccept:()=>c(l.path,"POST",{remove_unconnected:l.steps.map(a=>a.id)}),onDecline:()=>d(null),onSaveDetails:a=>c("/details","PATCH",{flow:a})}),P&&t.createElement(We,{node:P,fields:O?.fields||{},holds:O?.records||{},labels:O?.labels||{},explanations:O?.explanations||{},recordLabels:O?.record_labels||{},recordExplanations:O?.record_explanations||{},recordChoices:O?.record_choices||{},recordOutputsOf:O?.record_outputs_of||{},choices:Be(P,O),onClose:()=>f(null),onSave:a=>c(`/steps/${P.id}`,"PATCH",{config:a}),onPickPicture:x,refusal:n,onDelete:()=>{f(null),c(`/steps/${P.id}`,"DELETE")}}))},Tt=Xr;var qr={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Jr={fontSize:12,fontWeight:500,lineHeight:1.3},At={done:"border-green-600 bg-green-50 dark:border-green-500 dark:bg-green-950",paused:"border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-950",pending:"border-gray-300 bg-white text-gray-500 dark:border-zinc-700 dark:bg-zinc-900 dark:text-gray-400",failed:"border-red-600 bg-red-50 dark:border-red-500 dark:bg-red-950"},Dt={done:"text-green-700 dark:text-green-400",paused:"text-amber-800 dark:text-amber-300",pending:"text-gray-500 dark:text-gray-400",failed:"text-red-700 dark:text-red-400"},Kr="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Zr=({node:e,selected:o=!1})=>{let s=e.address?"a":"div";return t.createElement(s,{"data-step":e.id,href:e.address||void 0,className:`${e.state==="paused"?"border-2":"border"} ${At[e.state]||At.pending}${o?` ${Kr}`:""}`,style:qr},t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.type),t.createElement("div",{style:Jr},e.label,e.version&&t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},e.version)),e.status&&t.createElement("div",{className:Dt[e.state]||Dt.pending,style:{fontSize:11}},e.status))},Lt=Zr;var Qr={gap:12,padding:0},Rr=({nodes:e,edges:o,selected:s})=>t.createElement(q,{nodes:e,edges:o,joints:{},style:Qr,draw:r=>r.holds?t.createElement(V,{node:r,header:F(r,r,!1),compact:!0}):t.createElement(Lt,{node:r,selected:r.id===s})}),Ot=Rr;Q("easy_flow/flow-editor",Tt);Q("easy_flow/run-view",Ot);document.addEventListener("easy_flow:flow-named",e=>{let o=document.querySelector("[data-flow-heading]");o&&(o.textContent=e.detail)});document.addEventListener("easy_flow:flow-status",({detail:e})=>{e.status&&document.querySelectorAll("[data-version-status]").forEach(o=>{o.textContent=e.status}),e.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(o=>{o.textContent=`Publish v${e.publishes}`})});ke(document,ge);})();
1
+ (()=>{var Yt=globalThis.ReactDOM;var{createPortal:es,createRoot:xe,flushSync:ts,hydrateRoot:os,preconnect:rs,prefetchDNS:ss,preinit:ns,preinitModule:as,preload:is,preloadModule:ls,requestFormReset:ds,unstable_batchedUpdates:cs,useFormState:ps,useFormStatus:ms,version:us}=Yt;var he=globalThis.React,t=he,{Children:gs,Component:xs,Fragment:hs,PureComponent:ys,StrictMode:bs,Suspense:vs,cloneElement:ks,createContext:ws,createElement:Ss,createRef:Cs,forwardRef:Ns,isValidElement:_s,lazy:zs,memo:Es,startTransition:Bs,useCallback:Ts,useContext:As,useDebugValue:Ds,useDeferredValue:Ls,useEffect:M,useId:Os,useImperativeHandle:$s,useLayoutEffect:ye,useMemo:$,useReducer:Ps,useRef:Q,useState:S,useSyncExternalStore:Ms,useTransition:Is}=he;var be=new Map,V=new Map,R=(e,o)=>be.set(e,o),ve=()=>{V.forEach(e=>e.unmount()),V.clear()},ke=(e,o)=>e.querySelectorAll("[data-react-ui]").forEach(s=>{if(V.has(s))return;let r=be.get(s.dataset.reactUi),n=o(s);V.set(s,n),n.render(t.createElement(r,JSON.parse(s.dataset.props)))});var we=(e,o)=>{let s=()=>ke(e,o);e.addEventListener("turbo:load",s),e.addEventListener("turbo:frame-load",s),e.addEventListener("turbo:before-cache",ve),e.readyState==="loading"?e.addEventListener("DOMContentLoaded",s):s()};var w=(...e)=>e.filter(Boolean).join(" ");var Xt={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},qt={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Jt=({variant:e="primary",size:o="md",className:s,children:r,...n})=>{let i=n.href?"a":"button";return t.createElement(i,{...n,className:w("ks-button",Xt[e],qt[o],s)},r)},b=Jt;var Kt="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Zt="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Qt="border border-accent-600 bg-accent-600 text-white",Rt=({name:e,connected:o,armed:s,onArm:r,connecting:n})=>t.createElement("button",{onClick:i=>{n||(i.stopPropagation(),r(i))},title:s?"Now choose a step to connect to":"Connect this branch",className:s?Qt:o?Zt:Kt,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},e||"next"),Se=Rt;var eo={width:240,boxSizing:"border-box",borderRadius:8},to={minWidth:120,boxSizing:"border-box",borderRadius:6},oo={padding:"8px 14px",textAlign:"center",fontWeight:600},ro={fontWeight:600,lineHeight:1.3},so={fontSize:12,fontWeight:500,lineHeight:1.3},no=(e,o,s)=>{let r=s?"ring-4 ring-accent-600/15":"shadow-sm";return e||s&&!o?`border-accent-600 ${r}`:o?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},ao=(e,o)=>o&&e.label===e.id&&e.type_name||e.label,io=(e,o,s)=>s?o===e.type_name?null:e.type_name:e.type,lo=({node:e,selected:o,armed:s,connecting:r,onSelect:n,onOpen:i,onArm:l,onDragEnd:d,onDragStart:c,hideStepTypeCodes:x,branches:h=[],compact:f=!1,typeAbove:u=f})=>{let y=e.begins_here||e.ends_here,m=e.begins_here,_=e.ends_here?[]:e.ports,v=r&&!m,N=ao(e,x),E=io(e,N,x);return t.createElement("div",{ref:e.ref,"data-step":e.id,draggable:!m,onDragStart:k=>{k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("text/plain",e.id),c()},onDragEnd:d,onClick:e.opens&&!r?()=>i(e.opens):n,className:`bg-white ${f&&!o?"border":"border-2"} dark:bg-zinc-900 ${no(v,e.violations.length>0,o)}`,style:{...f?to:eo,padding:y?0:f?"8px 10px":"12px 14px",cursor:m?"default":r?"crosshair":"grab"}},!y&&u&&E&&t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},E),y&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:oo},N),!y&&t.createElement("div",{style:f?so:ro},N),e.violations.length>0&&t.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${e.violations.length} error${e.violations.length===1?"":"s"}`),!y&&e.summary&&e.violations.length===0&&t.createElement("div",{className:o?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},e.summary),!y&&!u&&E&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},E),e.picture_url&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),e.starts_a_flow&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),e.opens&&t.createElement(b,{variant:"secondary",size:"sm",className:"mt-2",onClick:k=>{k.stopPropagation(),n()}},"Settings"),h.map(k=>t.createElement("div",{key:k,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},k)),_.length>0&&t.createElement("div",{style:{padding:e.begins_here?"0 14px 8px":"10px 0 0"}},_.map(k=>t.createElement(Se,{key:k,name:k,connected:e.connected.includes(k),connecting:r,armed:s===k,onArm:B=>l(k,B)}))))},ee=lo;var Ce={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},co={...Ce,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},po=({node:e,header:o,onSelect:s,compact:r=!1})=>t.createElement("div",{ref:e.ref,"data-group-header":e.id,onClick:s,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?co:Ce,...s?{}:{cursor:"default"}}},o),F=po;var mo=({id:e,bounds:o,onDrop:s})=>t.createElement("div",{"data-group-box":e,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),s()},className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",zIndex:1,borderRadius:8,boxSizing:"border-box",...o}}),Ne=mo;var uo=e=>e!=null&&e!==""&&typeof e!="object",fo=["integer","float"],go=(e,o,s)=>s&&o.labels?.[e]||e,U=(e,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>uo(e.config[n])).map(n=>`${go(n,o,s)}${fo.includes(o.fields[n])?"":":"} ${e.config[n]}`);return[s&&e.type_name||e.type,...r].join(" \xB7 ")};var _e=(e,o,s)=>{let r=Math.min(...e.map(d=>d.left))-o.left+s.scrollLeft-12,n=Math.min(...e.map(d=>d.top))-o.top+s.scrollTop-10,i=Math.max(...e.map(d=>d.left+d.width))-o.left+s.scrollLeft+12,l=Math.max(...e.map(d=>d.top+d.height))-o.top+s.scrollTop+10;return{left:r,top:n,width:i-r,height:l-n}},xo=({left:e,top:o,width:s,height:r},n)=>n.x>=e&&n.x<=e+s&&n.y>=o&&n.y<=o+r,ze=(e,o)=>e.find(s=>xo(s.bounds,o))?.id||null,Ee=(e,o)=>e.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),Be=(e,o)=>o.some(s=>s.holds?.includes(e.id)&&!s.loose&&s.row===e.row-1);var te=(e,o)=>e.includes(o)?e.filter(s=>s!==o):[...e,o],Te=(e,o)=>({...o?.choices||{},...e?.choices||{}});var ho=({as:e="input",disabled:o,className:s,...r})=>t.createElement(e,{...r,disabled:o,className:w("ks-input",o&&"ks-input-disabled",s)}),D=ho;var yo=e=>t.createElement(D,{...e,as:"select"}),Ae=yo;var bo=({className:e,...o})=>t.createElement("input",{type:"checkbox",...o,className:w("ks-checkbox",e)}),G=bo;var vo=({name:e,value:o,label:s,hint:r,className:n,...i})=>t.createElement("label",{className:"inline-block cursor-pointer relative"},t.createElement("input",{type:"radio",name:e,value:o,...i,className:w("peer sr-only",n)}),t.createElement("span",{className:"ks-radio-card inline-flex flex-col cursor-pointer transition ks-radio-card-highlight"},t.createElement("span",{className:"ks-radio-card-header flex items-start justify-between"},t.createElement("span",{className:"ks-radio-card-label block"},s)),r!=null&&t.createElement("span",{className:"ks-radio-card-hint block text-sm"},r))),De=vo;var ko=({name:e,options:o,value:s,onChange:r,className:n})=>t.createElement("div",{className:w("flex flex-wrap ks-grid-gap-sm",n)},o.map(i=>t.createElement(De,{key:i.value,name:e,...i,checked:i.value===s,onChange:()=>r(i.value)}))),Le=ko;var Oe=e=>(e||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),wo=({name:e,type:o,value:s,choices:r,onChange:n,onSettle:i,onPick:l,pictureUrl:d})=>{if(o==="picture")return t.createElement("div",{className:"mb-3"},s&&d&&t.createElement("img",{src:d,alt:"The step's picture",style:{maxWidth:"100%"}}),s&&t.createElement(b,{type:"button",variant:"secondary",size:"sm","data-remove-picture":!0,onClick:()=>i("")},"Remove picture"),t.createElement("input",{type:"file",accept:"image/*",onChange:c=>c.target.files[0]&&l(c.target.files[0])}));if(o==="boolean")return t.createElement(G,{checked:!!s,onChange:c=>i(c.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return t.createElement(Ae,{className:"mb-3",value:s??"",onChange:c=>i(c.target.value)},t.createElement("option",{value:""}),Oe(r).map(c=>t.createElement("option",{key:c.value,value:c.value},c.label)));if(o==="radio_cards")return t.createElement("div",{"data-radio-cards":!0,className:"mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full"},t.createElement(Le,{name:e,value:s,options:r||[],onChange:i}));if(o==="multi_select"){let c=Array.isArray(s)?s:[],x=h=>i(te(c,h));return t.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(r||[]).map(h=>t.createElement("label",{key:h,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(G,{checked:c.includes(h),onChange:()=>x(h)}),t.createElement("span",null,h))))}if(o==="flows"){let c=Array.isArray(s)?s:[];return t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},Oe(r).map(x=>t.createElement("label",{key:x.value,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(G,{checked:c.includes(x.value),onChange:()=>i(te(c,x.value))}),t.createElement("span",null,x.label))))}return o==="integer"||o==="float"?t.createElement(D,{className:"mb-3",type:"number",step:o==="integer"?"1":"any",value:s??"",onChange:c=>n(c.target.value),onBlur:c=>i(c.target.value)}):t.createElement(D,{className:"mb-3",type:"text",value:s??"",onChange:c=>n(c.target.value),onBlur:c=>i(c.target.value)})},Y=wo;var $e=(e,o,s,r)=>e.map((n,i)=>i===o?{...n,[s]:r}:n);var So=({text:e})=>t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},e),X=So;var Co=(e,o,s,r)=>{let n=(e||{})[s],i=(o||{})[s];return i?(n||{})[r[i]]:n},No=({holds:e,labels:o,explanations:s,rows:r,choices:n,outputsOf:i,onChange:l,onSettle:d})=>{let c=Array.isArray(r)?r:[],x=(h,f,u,y)=>{let m=$e(c,h,f,u);y?d(m):l(m)};return t.createElement("div",{style:{marginBottom:12}},c.map((h,f)=>t.createElement("div",{key:f,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(e).map(([u,y])=>t.createElement("label",{key:u,style:{display:"block"}},t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[u]||u),t.createElement(Y,{type:y,value:h[u],choices:Co(n,i,u,h),onChange:m=>x(f,u,m,!1),onSettle:m=>x(f,u,m,!0)}),(s||{})[u]&&t.createElement(X,{text:s[u]}))),t.createElement(b,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>d(c.filter((u,y)=>y!==f))},"Remove"))),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>d([...c,{}])},"Add"))},Pe=No;var _o={start:null,end:"ks-value-list-end"},zo="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",Eo="flex flex-col min-w-0",Bo="ks-value-list-label basis-auto text-xs",To=()=>t.createElement("svg",{"aria-label":"Right",role:"img",className:"ks-tone-success inline size-5 align-text-bottom",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},t.createElement("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z",clipRule:"evenodd"})),Ao=({value:e,fallback:o})=>String(e??"")===""?o:e,Do=({rows:e,align:o="start",columns:s=!1,className:r})=>t.createElement("dl",{className:w("ks-value-list",_o[o],s&&zo,r)},e.map((n,i)=>t.createElement("div",{key:i,className:w(s?Eo:"ks-value-list-row",n.total&&"ks-value-list-total")},t.createElement("dt",{className:s?Bo:"ks-value-list-label"},n.label,n.note!=null&&t.createElement(t.Fragment,null," ",t.createElement("span",{className:"ks-value-list-note"},n.note))),t.createElement("dd",{className:"ks-value-list-value"},Ao(n),n.right&&t.createElement(t.Fragment,null," ",t.createElement(To,null)))))),Me=Do;var Lo=()=>t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})),Oo=({summary:e,open:o=!1,className:s,children:r})=>t.createElement("details",{className:w("ks-disclosure group",s),open:o},t.createElement("summary",{className:"ks-disclosure-summary flex cursor-pointer list-none items-center justify-between [&::-webkit-details-marker]:hidden"},t.createElement("span",null,e),t.createElement("span",{className:"ks-disclosure-icon h-4 w-4 shrink-0 transition-transform group-open:rotate-180"},t.createElement(Lo,null))),t.createElement("div",{className:"ks-disclosure-body text-sm"},r)),Ie=Oo;var $o=({language:e,caption:o,className:s,children:r})=>t.createElement("div",{className:w("ks-code overflow-hidden",s)},o!=null&&t.createElement("div",{className:"ks-code-caption font-mono text-xs"},o),t.createElement("pre",{className:"ks-code-block overflow-x-auto font-mono text-sm leading-relaxed"},t.createElement("code",{className:e==null?"":`language-${e}`},r))),je=$o;var oe="flex flex-col gap-1 mb-3",He="[&_dd]:font-mono",Po="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",Mo="[&_.ks-value-list]:font-mono [&_.ks-value-list]:flex [&_.ks-value-list]:flex-col [&_.ks-value-list]:gap-1 [&_.ks-value-list-row]:gap-2 [&_.ks-value-list-row]:py-0 [&_.ks-value-list-row]:border-0 [&_.ks-value-list-label]:basis-[90px]",Io="border-t border-gray-200 pt-2.5 dark:border-zinc-700 [&_.ks-disclosure]:border-0 [&_.ks-disclosure-summary]:flex-row-reverse [&_.ks-disclosure-summary]:justify-end [&_.ks-disclosure-summary]:gap-1 [&_.ks-disclosure-summary]:p-0 [&_.ks-disclosure-summary]:font-normal [&_.ks-disclosure-body]:p-0 [&_.ks-disclosure-body]:pt-1.5 [&_.ks-code-block]:p-2 [&_.ks-code-block]:text-[11px]",jo=e=>e.values?e.columns?`${oe} ${He} ${Po}`:`${oe} ${He} ${Mo}`:`${oe} ${Io}`,Ho=({details:e})=>t.createElement(t.Fragment,null,e.map((o,s)=>t.createElement("section",{key:s,className:jo(o)},o.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400"},o.heading),o.values&&t.createElement(Me,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>t.createElement(Ie,{key:r.summary,summary:r.summary},t.createElement(je,null,r.code)))))),We=Ho;var Wo=({as:e="div",className:o,children:s,...r})=>t.createElement(e,{...r,className:w("ks-panel",o)},s),A=Wo;var q=(e,o)=>({className:s,children:r,...n})=>t.createElement(e,{...n,className:w(o,s)},r),W=q("label","ks-label"),la=q("p","ks-hint"),da=q("p","ks-error"),ca=q("span","ks-required");var Vo={width:320,padding:"14px 16px",overflowY:"auto",display:"flex",flexDirection:"column",fontSize:12},Fo={marginTop:"auto",paddingTop:12,display:"flex",flexDirection:"column",gap:8},Uo=({node:e,fields:o,holds:s,labels:r,explanations:n,recordLabels:i,recordExplanations:l,recordChoices:d,recordOutputsOf:c,choices:x,onSave:h,onDelete:f,onClose:u,onPickPicture:y,refusal:m,notice:_})=>{let[v,N]=S(e.config),[E,k]=S(e.picture_url);M(()=>k(e.picture_url),[e.id,e.picture_url]),M(()=>N(e.config),[e.id,e.config]);let B=g=>{N(g),JSON.stringify(g)!==JSON.stringify(e.config)&&h(g)};return t.createElement(A,{as:"aside",style:Vo,className:"max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto","data-inspector":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8,marginBottom:12}},t.createElement("div",null,t.createElement("p",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.id," \xB7 ",e.type),t.createElement("h2",{style:{fontSize:15,fontWeight:600}},e.label)),t.createElement("button",{title:"Close",onClick:u,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),m&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},m),_&&!m&&t.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{fontWeight:600,marginBottom:12},"data-notice":!0},_),Object.entries(o).map(([g,L])=>t.createElement(W,{key:g},t.createElement("span",{style:{display:"block",marginBottom:3}},r[g]||g),L==="list"?t.createElement(Pe,{holds:s[g]||{},labels:i[g]||{},explanations:(l||{})[g],rows:v[g],choices:{...(d||{})[g],...(e.record_choices||{})[g]},outputsOf:(c||{})[g],onChange:z=>N({...v,[g]:z}),onSettle:z=>B({...v,[g]:z})}):t.createElement(Y,{name:g,type:L,value:v[g],choices:x[g],pictureUrl:E,onChange:z=>N({...v,[g]:z}),onSettle:z=>B({...v,[g]:z}),onPick:async z=>{let H=await y(z);H&&(k(H.url),B({...v,[g]:H.reference}))}}),(n||{})[g]&&t.createElement(X,{text:n[g]}))),t.createElement(We,{details:e.details||[]}),t.createElement("div",{style:Fo},(e.links||[]).length>0&&t.createElement("div",{style:{display:"flex",gap:8}},e.links.map(g=>t.createElement(b,{key:g.address,variant:"secondary",size:"sm",className:"flex-1",href:g.address},g.label))),t.createElement(b,{variant:"danger",size:"sm",className:"w-full",onClick:f},"Delete step")))},Ve=Uo;var Go={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},Yo={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},Xo="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",qo="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Jo=({node:e,dragging:o,onFill:s,onDrop:r,compact:n=!1})=>t.createElement("div",{ref:e.ref,"data-placeholder":e.id,title:`Choose the step \u201C${e.label}\u201D should lead to`,onClick:s,onDragOver:i=>{o&&(i.preventDefault(),i.dataTransfer.dropEffect="move")},onDrop:i=>{i.preventDefault(),r()},className:o?qo:Xo,style:n?Yo:Go},t.createElement("div",{style:{fontWeight:600}},e.label),t.createElement("div",{style:{fontSize:11}},o?"drop a step here":"leads nowhere yet \u2014 click to choose")),Fe=Jo;var Ko=({entries:e,at:o,onPick:s,onConnect:r,onDismiss:n,hideStepTypeCodes:i})=>t.createElement(A,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:o.y,left:o.x,width:210,padding:8,borderRadius:8}},t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),e.map(l=>t.createElement(b,{key:l.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>s(l)},l.label,!i&&t.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},l.type))),r&&t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full",onClick:n},"Cancel")),Ue=Ko;var Zo=e=>o=>o.label.toLowerCase().includes(e.trim().toLowerCase()),Qo=(e,o,s="")=>{let r=Object.values(o).flat(),n=Object.entries(o).map(([i,l])=>({heading:i,entries:l.map(d=>e.find(c=>c.type===d)).filter(Boolean)}));return[{heading:null,entries:e.filter(i=>!r.includes(i.type))},...n].map(i=>({...i,entries:i.entries.filter(Zo(s))})).filter(i=>i.entries.length>0)},Ro={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},er={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},tr={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},or=({entries:e,groups:o,onPick:s,onCarry:r,onDrop:n})=>{let[i,l]=S("");return t.createElement(A,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:Ro},t.createElement(D,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:i,onChange:d=>l(d.target.value),style:{marginBottom:6,fontSize:12}}),Qo(e,o,i).map(d=>t.createElement(t.Fragment,{key:d.heading||""},d.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:er},d.heading),d.entries.map(c=>t.createElement(A,{as:"button",type:"button",key:c.type,"data-step-type":c.type,className:"bg-surface-50 dark:bg-surface-950",style:tr,draggable:!0,onClick:()=>s(c),onDragStart:x=>{x.dataTransfer.effectAllowed="copyMove",x.dataTransfer.setData("text/plain",c.type),r(c)},onDragEnd:n},c.label)))))},Ge=or;var rr={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Ye=({label:e,title:o,idle:s,enabled:r,onUse:n})=>t.createElement(b,{variant:"secondary",size:"sm",title:r?o:s,disabled:!r,onClick:n,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},e),sr=({undoable:e,redoable:o,onAdd:s,onUndo:r,onRedo:n})=>t.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},t.createElement(b,{variant:"secondary",className:"rounded-full",style:rr,title:"Add a step",onClick:s},"+"),t.createElement(Ye,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:e,onUse:r}),t.createElement(Ye,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),Xe=sr;var nr=({type:e="info",title:o,message:s,onDismiss:r,className:n})=>t.createElement("div",{className:w("ks-alert",`ks-alert-${e}`,n),role:"alert"},t.createElement("div",{className:"ks-alert-body"},t.createElement("div",{className:"ks-alert-content"},o&&t.createElement("p",{className:"ks-alert-title"},o),t.createElement("p",{className:o?"ks-alert-message-titled":"ks-alert-message"},s)),r&&t.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),qe=nr;var Je=e=>{let o=e.map(s=>`\u201C${s.name}\u201D`).join(", ");return e.length===1?`${o} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${o} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var Ke=({version:e,published:o})=>e?o?o===e?`Version ${e} \xB7 live`:`Version ${e} \xB7 visitors still on ${o}`:`Version ${e} \xB7 never published`:"No version yet";var ar={width:280,padding:20,overflowY:"auto"},Ze={fontWeight:600,marginBottom:6,marginTop:14},re={fontSize:12,marginBottom:4,lineHeight:1.4},Qe={display:"block",marginBottom:3},Re=(e,o,s)=>r=>{r.target.value!==(e[o]??"")&&s({[o]:r.target.value})},ir=({flow:e,changes:o,refusal:s,notice:r,publishNote:n,warning:i,onCreate:l,onPublish:d,onAccept:c,onDecline:x,onSaveDetails:h,onClose:f})=>t.createElement(A,{as:"aside",style:ar,"data-builder-panel":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},t.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},e.title||e.slug),t.createElement("button",{title:"Close",onClick:f,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),t.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:e.history_url,"data-history":!0},Ke(e)),i?t.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},t.createElement(qe,{type:"warning",className:"mb-1.5",message:Je(i.steps)}),t.createElement(b,{size:"sm",className:"w-full mb-1.5",onClick:c,"data-accept-removal":!0},i.path==="/publish"?"Remove and publish":"Remove and create version"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:x,"data-decline-removal":!0},"Cancel")):t.createElement("div",{style:{marginTop:14}},t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:l,"data-create-version":!0},"Create version"),t.createElement(b,{size:"sm",className:"w-full mb-1.5",onClick:d,"data-publish":!0},"Publish"),n&&t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},n)),s&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...re,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&t.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...re,fontWeight:600,marginTop:8},"data-notice":!0},r),t.createElement("h2",{style:Ze},"Changes since the last version"),o.length===0?t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):o.map((u,y)=>t.createElement("p",{key:y,style:re,"data-change":!0},u)),t.createElement("h2",{style:Ze},"Details"),t.createElement(W,null,t.createElement("span",{style:Qe},"Title"),t.createElement(D,{className:"mb-3",defaultValue:e.title??"",onBlur:Re(e,"title",h),"data-flow-title":!0})),t.createElement(W,null,t.createElement("span",{style:Qe},"Start label"),t.createElement(D,{className:"mb-3",defaultValue:e.start_label??"",onBlur:Re(e,"start_label",h),"data-flow-start-label":!0})),t.createElement("div",{style:{marginTop:16}},t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.definition_url,"data-definition":!0},"Definition"),t.createElement(b,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.details_url,"data-details":!0},"Edit details"))),et=ir;var lr=({variant:e="neutral",className:o,children:s,...r})=>t.createElement("span",{...r,className:w("ks-badge",`ks-badge-${e}`,o)},s),tt=lr;var dr={center:"ks-tab-bar flex flex-wrap justify-center max-sm:flex-nowrap max-sm:overflow-x-auto max-sm:justify-start",start:"ks-tab-bar flex flex-wrap justify-start max-sm:flex-nowrap max-sm:overflow-x-auto"},cr={pills:"ks-tab-bar-pills",underline:"ks-tab-bar-underline"},pr="ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",mr="ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",ur=({shape:e,count:o})=>e?t.createElement("span",{className:"ks-tab-count"},o):t.createElement(tt,{variant:"info"},o),fr=e=>typeof e=="string"?e!=="":e>0,gr=({tabs:e,value:o,onChange:s,align:r="center",shape:n,className:i})=>t.createElement("div",{className:i},t.createElement("div",{className:w(dr[r],cr[n])},e.map(l=>t.createElement("button",{key:l.value,type:"button",className:n?mr:pr,"data-active":l.value===o?"":void 0,onClick:()=>s(l.value)},l.label,fr(l.count)&&t.createElement(t.Fragment,null," ",t.createElement(ur,{shape:n,count:l.count}))))),e.find(l=>l.value===o)?.content),ot=gr;var xr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},rt="mx-6 mb-6 flex max-h-[45%] flex-none flex-col overflow-y-auto rounded-lg max-sm:m-0 max-sm:max-h-none max-sm:rounded-none [&_.ks-tab-bar]:mb-0 [&_.ks-tab-bar]:px-2",hr="max-sm:absolute max-sm:inset-0 max-sm:z-20",at={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},st={display:"flex",gap:8,textAlign:"left"},nt={flexShrink:0,whiteSpace:"nowrap"},yr=({check:e,onSelect:o})=>{let s=t.createElement(t.Fragment,null,t.createElement("span",{className:xr[e.level],style:{...nt,fontWeight:500}},e.level),e.node&&t.createElement("span",{className:"font-mono",style:nt},e.node),t.createElement("span",null,e.sentence));return e.node?t.createElement("button",{type:"button","data-check-row":!0,"data-step-id":e.node,style:{...st,border:"none",background:"none",padding:0,cursor:"pointer",font:"inherit",color:"inherit"},onClick:()=>o(e.node)},s):t.createElement("div",{"data-check-row":!0,style:st},s)},br=({checks:e,onSelect:o})=>t.createElement("div",{style:at},e.map((s,r)=>t.createElement(yr,{key:r,check:s,onSelect:o}))),vr=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,kr=({checks:e,tabs:o,onSelect:s,opened:r=vr()?null:"validation"})=>{let[n,i]=S(r);return t.createElement(A,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${rt} ${hr}`:rt},t.createElement(ot,{align:"start",shape:"underline",value:n,onChange:l=>i(l===n?null:l),tabs:[{value:"validation",label:"Validation",count:e.filter(l=>l.level==="error").length,content:t.createElement(br,{checks:e,onSelect:s})},...o.map(l=>({value:l.label,label:l.label,count:l.count??"",content:t.createElement("div",{"data-drawer-content":!0,style:at,dangerouslySetInnerHTML:{__html:l.content}})}))]}))},it=kr;var lt={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},dt=e=>({opacity:e?1:0,transition:"opacity .12s"}),wr=({link:e,onInsert:o,onRemove:s,onDrop:r,dragging:n,alwaysShowInsertButtons:i})=>{let[l,d]=S(!1),c=l||n;return t.createElement("div",{"data-connector":`${e.source}-${e.target}`,style:{position:"absolute",left:e.midX-34,top:e.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onDragEnter:()=>d(!0),onDragLeave:()=>d(!1),onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},onDrop:x=>{x.preventDefault(),d(!1),r()}},t.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},t.createElement(b,{variant:"secondary",title:n?"Move the step here":"Insert a step here",onClick:o,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(n&&l),style:{...lt,...dt(c||i)}},"+"),!n&&t.createElement(b,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...lt,...dt(c)}},"\xD7")))},ct=wr;var Sr=({links:e,extent:o,dragging:s,onInsert:r,onRemove:n,onDrop:i,alwaysShowInsertButtons:l})=>t.createElement(t.Fragment,null,t.createElement("svg",{width:o.width,height:o.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},t.createElement("defs",null,t.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},t.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),e.map(d=>t.createElement("path",{key:d.id,"data-link":d.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:d.path}))),e.filter(d=>d.label).map(d=>t.createElement("div",{key:`${d.id}-label`,"data-link-label":d.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:d.midX+(l?2:-10),top:d.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},d.label)),e.filter(d=>!d.placeholder).map(d=>t.createElement(ct,{key:d.id,link:d,dragging:!!s,alwaysShowInsertButtons:l,onInsert:()=>r(d),onRemove:()=>n(d),onDrop:()=>i(d)}))),pt=Sr;var se={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},mt="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Cr=({link:e,onInsert:o,onRemove:s,onDrop:r,alwaysShowInsertButtons:n,dragging:i})=>t.createElement("div",{"data-joint":e?.id,className:"group relative h-7 w-full sm:h-auto sm:w-7 sm:self-stretch",onMouseEnter:l=>{l.currentTarget.dataset.over="true"},onMouseLeave:l=>{delete l.currentTarget.dataset.over},onDragOver:l=>{e&&r&&(l.preventDefault(),l.dataTransfer.dropEffect="move")},onDrop:l=>{e&&(l.preventDefault(),r(e))}},e&&t.createElement("div",{className:"absolute left-1/2 top-0 h-full w-px bg-gray-400 sm:left-0 sm:top-1/2 sm:h-px sm:w-full dark:bg-zinc-500"}),e&&o&&t.createElement("div",{className:"absolute inset-0 flex items-center justify-center gap-1 sm:flex-col",style:{zIndex:4}},t.createElement(b,{variant:"secondary",title:"Insert a step here",onClick:l=>o(e,l),className:`rounded-full ${n?"opacity-100":mt}`,style:i?{...se,opacity:1}:se},"+"),t.createElement(b,{variant:"danger",title:"Remove this connection",onClick:()=>s(e),className:`rounded-full ${mt}`,style:se},"\xD7"))),ut=Cr;var Nr=(e,o)=>e.row-o.row||e.column-o.column,ft=e=>new Map(e.flatMap(o=>(o.holds||[]).map(s=>[s,o.id]))),gt=e=>{let o=[...e].sort(Nr),s=ft(e),r=new Map(e.filter(n=>n.holds).map(n=>[n.id,[]]));return o.filter(n=>s.has(n.id)).forEach(n=>r.get(s.get(n.id)).push(n)),o.filter(n=>!s.has(n.id)).flatMap(n=>[n,...r.get(n.id)||[]])},xt=e=>{let o=ft(e),s=gt(e),r=[],n=new Map;return s.filter(i=>!o.has(i.id)).forEach(i=>{let l=r[r.length-1];i.holds?n.set(i.id,r[r.push({group:i,steps:[]})-1]):l&&!l.group?l.steps.push(i):r.push({steps:[i]})}),s.filter(i=>o.has(i.id)).forEach(i=>n.get(o.get(i.id))?.steps.push(i)),r},_r=e=>e?.placeholder?"nowhere yet":e?.label,ne=new WeakMap,zr=e=>(ne.has(e)||ne.set(e,new Map([...e].reverse().map(o=>[`${o.source}
2
+ ${o.target}`,o]))),ne.get(e)),ht=(e,o,s)=>zr(e).get(`${o.id}
3
+ ${s.id}`),yt=(e,o,s)=>{let r=gt(e),n=new Map(r.map((d,c)=>[d.id,r[c+1]?.id])),i=new Map(s.map(d=>[d.id,_r(d)])),l=Object.fromEntries(e.map(d=>[d.id,[]]));return o.filter(d=>l[d.source]&&(d.label||d.target!==n.get(d.source))).forEach(d=>l[d.source].push([d.label,"\u2192",i.get(d.target)].filter(Boolean).join(" "))),l};var Er={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},bt=({steps:e,edges:o,draw:s,joints:r})=>t.createElement("div",{"data-flow-row":!0,className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5"},e.map((n,i)=>t.createElement("div",{key:n.id,className:"flex flex-col sm:flex-row sm:items-center"},i>0&&t.createElement(ut,{link:ht(o,e[i-1],n),...r}),s(n)))),Br={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},Tr=({group:e,steps:o,edges:s,draw:r,joints:n})=>t.createElement("div",{"data-group-box":e.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:Br},r(e),t.createElement(bt,{steps:o,edges:s,draw:r,joints:n})),Ar=({nodes:e,edges:o,draw:s,joints:r,children:n,style:i})=>t.createElement("div",{"data-flow-rows":!0,style:{...Er,...i}},n,xt(e).map(l=>l.group?t.createElement(Tr,{key:l.group.id,group:l.group,steps:l.steps,edges:o,draw:s,joints:r}):t.createElement(bt,{key:l.steps[0].id,steps:l.steps,edges:o,draw:s,joints:r}))),J=Ar;var kt="Your change was not saved because the server could not be reached.",Dr="Your change was saved, but the canvas could not be refreshed. Reload the page to see it.",vt=async({base:e,fetch:o,onFlow:s,onError:r})=>{let n=await o(e+".json",{headers:{Accept:"application/json"}}).catch(()=>null),i=n?.ok?await n.json().catch(()=>null):null;return i?s(i):r(Dr)},wt=({base:e,token:o,fetch:s,onFlow:r,onError:n,onNotice:i,onWarning:l=()=>{}})=>async(d,c,x)=>{let h={base:e,fetch:s,onFlow:r,onError:n},f=await s(e+d,{method:c,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:x&&JSON.stringify(x)}).catch(()=>null);if(!f)return i(null),n(kt);let u=await f.json().catch(()=>({}));return u.unconnected?(i(null),n(null),l({path:d,steps:u.unconnected}),vt(h)):(l(null),f.ok?(n(null),i(u.notice||null),vt(h)):(i(null),n(u.error||"That change was refused")))},St=({base:e,token:o,fetch:s,onError:r})=>async n=>{let i=new FormData;i.append("picture",n);let l=await s(e+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:i}).catch(()=>null);if(!l)return r(kt),null;let d=await l.json().catch(()=>({}));return l.ok?(r(null),d):(r(d.error||"That picture was refused"),null)};var Lr=(e,o,s)=>{let[r,n]=S(s),[i,l]=S(null),[d,c]=S(null),[x,h]=S(null),f=$(()=>wt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onFlow:n,onError:l,onNotice:c,onWarning:h}),[e,o]),u=$(()=>St({base:e,token:o,fetch:(...y)=>window.fetch(...y),onError:l}),[e,o]);return{flow:r,error:i,notice:d,warning:x,setWarning:h,send:f,pickPicture:u}},Ct=Lr;var K=(e,o,s,r)=>{let n=e.left-s.left+r.scrollLeft,i=e.top-s.top+r.scrollTop;return o==="left"?{x:n,y:i+e.height/2}:o==="right"?{x:n+e.width,y:i+e.height/2}:o==="top"?{x:n+e.width/2,y:i}:{x:n+e.width/2,y:i+e.height}},Or=(e,o,s)=>s&&o==="top"?{x:e.x,y:s.top}:e,$r=(e,o)=>o==="top"?{x:e.x,y:e.y-3}:o==="left"?{x:e.x-3,y:e.y}:o==="right"?{x:e.x+3,y:e.y}:{x:e.x,y:e.y+3},Pr=(e,o,s,r,n)=>{let i={straight:`M ${o.x} ${o.y} L ${s.x} ${s.y}`,turn:`M ${o.x} ${o.y} H ${s.x} V ${s.y}`,lane:`M ${o.x} ${o.y} V ${r} H ${s.x} V ${s.y}`,detour:`M ${o.x} ${o.y} H ${n} V ${s.y} H ${s.x}`}[e.route];return{...e,path:i,midX:e.route==="detour"?n:(o.x+s.x)/2,midY:e.route==="lane"?r:(o.y+s.y)/2}},Mr=(e,o,s,r)=>{let[n,i]=S([]),[l,d]=S({width:"100%",height:"100%"}),[c,x]=S([]);return ye(()=>{let h=()=>{let u=o.current?.getBoundingClientRect();if(!u)return;d({width:o.current.scrollWidth,height:o.current.scrollHeight});let y=e.nodes.filter(m=>m.holds&&!m.loose&&s.current[m.id]).map(m=>{let _=s.current[m.id],v=_.getBoundingClientRect(),N=m.holds.flatMap(k=>s.current[k]?[s.current[k].getBoundingClientRect()]:[]),E=[{left:v.left,top:v.top,width:Math.max(v.width,_.scrollWidth),height:v.height},...N];return{id:m.id,bounds:_e(E,u,o.current)}});x(y),i(e.edges.flatMap(m=>{let _=s.current[m.source]?.getBoundingClientRect(),v=s.current[m.target]?.getBoundingClientRect();if(!_||!v)return[];let N=K(_,m.leaves,u,o.current),E=y.find(L=>L.id===m.target)?.bounds,k=$r(Or(K(v,m.enters,u,o.current),m.enters,E),m.enters),B=(K(_,"bottom",u,o.current).y+K(v,"top",u,o.current).y)/2,g=m.leaves==="left"?Math.min(N.x,k.x)-28:Math.max(N.x,k.x)+28;return[Pr(m,N,k,B,g)]}))};h(),window.addEventListener("resize",h);let f=new ResizeObserver(h);return o.current&&f.observe(o.current),()=>{window.removeEventListener("resize",h),f.disconnect()}},r),{links:n,extent:l,boxes:c}},Nt=Mr;var _t=(e,o)=>{let s=new Set(o),r=e,n=2;for(;s.has(r);)r=`${e}_${n++}`;return r};var zt=({send:e,onPress:o})=>s=>{let r=s.target.closest?.("[data-bar-action]");r&&(r.closest("details")?.removeAttribute("open"),o(),r.dataset.barPath&&e(r.dataset.barPath,"POST"))};var jr=8,Hr={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},Wr={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},Vr={flex:1,minHeight:0,overflow:"auto",position:"relative"},Bt={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},Fr={...Bt,position:"static",alignSelf:"flex-start"},Ur={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Tt={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Gr=({port:e,onCancel:o})=>t.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Tt},"Choose the step \u201C",e||"next","\u201D should lead to \u2014 ",t.createElement("button",{onClick:o,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),Yr=({message:e})=>t.createElement("p",{"data-canvas-error":!0,className:"bg-red-50 text-red-800 dark:bg-red-950 dark:text-red-200",style:Tt},e),Xr=({base:e,token:o,initial:s})=>{let{flow:r,error:n,notice:i,warning:l,setWarning:d,send:c,pickPicture:x}=Ct(e,o,s),[h,f]=S(null),[u,y]=S(null),[m,_]=S(null),[v,N]=S(null),[E,k]=S(null),[B,g]=S(!1),L=Q({}),z=Q(null);M(()=>{let a=zt({send:c,onPress:()=>{f(null),g(!0)}});return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[c]),M(()=>{if(!B){d(null);return}let a=p=>{p.target.isConnected&&!p.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&g(!1)};return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[B]),M(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),M(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let H=$(()=>Object.fromEntries(r.nodes.map(a=>[a.id,a])),[r.nodes]),{links:Pt,extent:Mt,boxes:ae}=Nt(r,z,L,[r,h,H]),It=$(()=>{let a={};return r.violations.forEach(p=>{var C;return(a[C=p.node]||(a[C]=[])).push(p)}),a},[r.violations]),T=r.direction==="left_to_right",j=$(()=>r.nodes.filter(a=>!a.loose),[r.nodes]),ie=r.nodes.filter(a=>a.loose),jt=$(()=>T?yt(j,r.edges,r.nodes):{},[T,j,r.edges,r.nodes]),Ht=$(()=>{let a={};return r.edges.forEach(p=>{var C;return(a[C=p.source]||(a[C]=[])).push(p.label||null)}),a},[r.edges]),Wt=Math.max(0,...j.map(a=>a.row))+1,Vt=Math.max(0,...j.map(a=>a.column))+1,le=a=>{if(!m)return;let[p,C]=m;_(null),p!==a&&c("/edges","POST",{from:p,to:a,on:C||null})},Ft=a=>{if(a.isDefaultPrevented()||!v)return;a.preventDefault();let p=v;N(null);let C=z.current.getBoundingClientRect(),ge=ze(ae,{x:a.clientX-C.left+z.current.scrollLeft,y:a.clientY-C.top+z.current.scrollTop}),Ut=r.nodes.find(Gt=>Gt.holds?.includes(p))?.id||null;ge!==Ut&&c(`/steps/${p}/group`,"PATCH",{group:ge})},de=a=>[...r.palette,...r.unoffered||[]].find(p=>p.type===a?.type),P=r.nodes.find(a=>a.id===h),O=de(P),Z=(a,p={})=>c("/steps","POST",{id:_t(a.type,r.nodes.map(C=>C.id)),type:a.type,from:p.from,to:p.to,on:p.on}),ce=a=>{let[p,C]=[E,v];k(null),N(null),p?Z(p,{from:a.source,to:a.target}):C&&c("/steps/"+C+"/move","PATCH",{from:a.source,to:a.target})},pe=a=>{let p=z.current.getBoundingClientRect();return{x:a.clientX-p.left+z.current.scrollLeft+8,y:a.clientY-p.top+z.current.scrollTop+8}},me=(a,p)=>({node:{...a,ref:C=>{L.current[a.id]=C},violations:It[a.id]||[],connected:p},selected:a.id===h,armed:m&&m[0]===a.id?m[1]:null,connecting:!!m&&m[0]!==a.id,onSelect:()=>m?le(a.id):f(a.id),onOpen:C=>window.location.assign(C),onDragStart:()=>N(a.id),onDragEnd:()=>N(null),hideStepTypeCodes:r.hide_step_type_codes,compact:T,branches:jt[a.id]||[]}),ue=a=>t.createElement(t.Fragment,null,a.placeholder&&t.createElement(Fe,{node:{...a,ref:p=>{L.current[a.id]=p}},dragging:!!v,compact:T,onFill:()=>y({from:a.from,on:a.on,at:{x:16,y:52}}),onDrop:()=>{let p=v;N(null),p&&c("/edges","POST",{from:a.from,to:p,on:a.on})}}),a.holds&&t.createElement(F,{node:{...a,ref:p=>{L.current[a.id]=p}},header:U(a,de(a),r.hide_step_type_codes),compact:T,onSelect:()=>m?le(a.id):f(a.id)}),!a.placeholder&&!a.holds&&t.createElement(ee,{...me(a,Ht[a.id]||[]),onArm:(p,C)=>y({from:a.id,on:p,at:pe(C)})})),fe=ie.length>0&&t.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:T?Fr:Bt},t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:6}},"Not in the flow yet \u2014 drag one onto a connection"),ie.map(a=>t.createElement("div",{key:a.id,style:{marginBottom:8}},t.createElement(ee,{...me(a,[]),onArm:(p,C)=>{C.stopPropagation(),_([a.id,p])}}))));return t.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:Hr,onMouseUp:()=>N(null),onKeyDown:a=>{a.key==="Escape"&&(f(null),_(null),y(null))},tabIndex:-1},t.createElement(Ge,{entries:r.palette,groups:r.step_groups||{},onPick:a=>Z(a),onCarry:k,onDrop:()=>k(null)}),t.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:Wr},t.createElement("div",{ref:z,style:Vr,onClick:a=>{a.target===z.current&&(f(null),_(null),g(!1))},onDragOver:a=>{v&&a.preventDefault()},onDrop:Ft},m&&t.createElement(Gr,{port:m[1],onCancel:()=>_(null)}),n&&!B&&!P&&t.createElement(Yr,{message:n}),t.createElement(Xe,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>y({at:{x:16,y:52}}),onUndo:()=>{f(null),c("/undo","POST")},onRedo:()=>{f(null),c("/redo","POST")}}),!T&&ae.map(a=>t.createElement(Ne,{key:a.id,id:a.id,bounds:a.bounds,onDrop:()=>{let p=v;N(null),p&&c(`/steps/${p}/group`,"PATCH",{group:a.id})}})),!T&&t.createElement(pt,{links:Ee(Pt,r.nodes),extent:Mt,dragging:v||E,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:a=>y({from:a.source,to:a.target,at:{x:a.midX+30,y:a.midY}}),onRemove:a=>{f(null),c("/edges","DELETE",{from:a.source,to:a.target})},onDrop:ce}),!T&&fe,T&&t.createElement(J,{nodes:j,edges:r.edges,draw:ue,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(v||E),onInsert:(a,p)=>y({from:a.source,to:a.target,at:pe(p)}),onRemove:a=>{f(null),c("/edges","DELETE",{from:a.source,to:a.target})},onDrop:ce}},fe),!T&&t.createElement("div",{style:{...Ur,gridTemplateColumns:`repeat(${Vt+1}, ${280/2}px)`,gridTemplateRows:`repeat(${Wt}, auto)`}},j.map(a=>t.createElement("div",{key:a.id,style:{gridRow:a.row+1,gridColumn:`${a.column+1} / span 2`,zIndex:2,marginTop:Be(a,r.nodes)?jr-64:0}},ue(a)))),u&&t.createElement(Ue,{entries:r.palette,at:u.at,onDismiss:()=>y(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:u.on!==void 0?()=>{_([u.from,u.on]),y(null)}:null,onPick:a=>{let p=u;y(null),Z(a,p)}})),t.createElement(it,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:f})),B&&!P&&t.createElement(et,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:i,publishNote:r.publish_note,warning:l,onClose:()=>g(!1),onCreate:()=>c("/versions","POST"),onPublish:()=>c("/publish","POST"),onAccept:()=>c(l.path,"POST",{remove_unconnected:l.steps.map(a=>a.id)}),onDecline:()=>d(null),onSaveDetails:a=>c("/details","PATCH",{flow:a})}),P&&t.createElement(Ve,{node:P,fields:O?.fields||{},holds:O?.records||{},labels:O?.labels||{},explanations:O?.explanations||{},recordLabels:O?.record_labels||{},recordExplanations:O?.record_explanations||{},recordChoices:O?.record_choices||{},recordOutputsOf:O?.record_outputs_of||{},choices:Te(P,O),onClose:()=>f(null),onSave:a=>c(`/steps/${P.id}`,"PATCH",{config:a}),onPickPicture:x,refusal:n,notice:i,onDelete:()=>{f(null),c(`/steps/${P.id}`,"DELETE")}}))},At=Xr;var qr={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Jr={fontSize:12,fontWeight:500,lineHeight:1.3},Dt={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"},Lt={done:"text-green-700 dark:text-green-400",paused:"text-amber-800 dark:text-amber-300",pending:"text-gray-500 dark:text-gray-400",failed:"text-red-700 dark:text-red-400"},Kr="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Zr=({node:e,selected:o=!1})=>{let s=e.address?"a":"div";return t.createElement(s,{"data-step":e.id,href:e.address||void 0,className:`${e.state==="paused"?"border-2":"border"} ${Dt[e.state]||Dt.pending}${o?` ${Kr}`:""}`,style:qr},t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.type),t.createElement("div",{style:Jr},e.label,e.version&&t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},e.version)),e.status&&t.createElement("div",{className:Lt[e.state]||Lt.pending,style:{fontSize:11}},e.status))},Ot=Zr;var Qr={gap:12,padding:0},Rr=({nodes:e,edges:o,selected:s})=>t.createElement(J,{nodes:e,edges:o,joints:{},style:Qr,draw:r=>r.holds?t.createElement(F,{node:r,header:U(r,r,!1),compact:!0}):t.createElement(Ot,{node:r,selected:r.id===s})}),$t=Rr;R("easy_flow/flow-editor",At);R("easy_flow/run-view",$t);document.addEventListener("easy_flow:flow-named",e=>{let o=document.querySelector("[data-flow-heading]");o&&(o.textContent=e.detail)});document.addEventListener("easy_flow:flow-status",({detail:e})=>{e.status&&document.querySelectorAll("[data-version-status]").forEach(o=>{o.textContent=e.status}),e.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(o=>{o.textContent=`Publish v${e.publishes}`})});we(document,xe);})();
@@ -104,7 +104,7 @@ module EasyFlow
104
104
  def apply(action = nil, *steps)
105
105
  before = document.to_h
106
106
  flow.edit_history.record(yield(document), action, steps, before)
107
- head :no_content
107
+ @notice ? render(json: { notice: @notice }) : head(:no_content)
108
108
  rescue InvalidEdit => invalid
109
109
  render json: { error: invalid.message }, status: :unprocessable_entity
110
110
  end
@@ -193,10 +193,15 @@ module EasyFlow
193
193
  return configuration unless step_type && EasyFlow.registry.registered?(step_type)
194
194
 
195
195
  settled(EasyFlow.registry.fetch(step_type))
196
+ rescue Settings::OptionsUnavailable => unavailable
197
+ Rails.logger.error("EasyFlow could not save step #{id}: #{unavailable.message}")
198
+ raise InvalidEdit, "#{unavailable.setting} could not be worked out, so the change was not saved."
196
199
  end
197
200
 
198
201
  def settled(step_type)
199
- step_type.settings.coerce(configuration).tap do |values|
202
+ coerced = step_type.settings.coerce(configuration)
203
+ @notice = cleared_notice(step_type, coerced)
204
+ step_type.settings.cleared(coerced).tap do |values|
200
205
  objections = step_type.settings.objections(values)
201
206
  raise InvalidEdit, objections.join(", ") if objections.any?
202
207
 
@@ -208,6 +213,10 @@ module EasyFlow
208
213
  end.then { |values| step_type.settings.unkept(values) }
209
214
  end
210
215
 
216
+ def cleared_notice(step_type, values)
217
+ step_type.settings.strays(values).map { |name| "Cleared #{step_type.settings.labels[name.to_sym]} because #{values[name]} is not offered for the step's other settings." }.join(" ").presence
218
+ end
219
+
211
220
  def foreign_flows(step_type, values)
212
221
  step_type.settings.fields.select { |name, type| %i[flow flows].include?(type) && values[name.to_s].present? }
213
222
  .reject { |name, _type| Array(values[name.to_s]).all? { |id| flow.reaches?(Definition.find_by(id: id)) } }
@@ -269,6 +269,7 @@ const Canvas = ({ base, token, initial }) => {
269
269
  onSave={(config) => send(`/steps/${selectedNode.id}`, "PATCH", { config })}
270
270
  onPickPicture={pickPicture}
271
271
  refusal={error}
272
+ notice={notice}
272
273
  onDelete={() => { setSelected(null); send(`/steps/${selectedNode.id}`, "DELETE") }} />
273
274
  )}
274
275
  </div>
@@ -11,7 +11,7 @@ const panel = { width: 320, padding: "14px 16px", overflowY: "auto", display: "f
11
11
 
12
12
  const foot = { marginTop: "auto", paddingTop: 12, display: "flex", flexDirection: "column", gap: 8 }
13
13
 
14
- const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, recordExplanations, recordChoices, recordOutputsOf, choices, onSave, onDelete, onClose, onPickPicture, refusal }) => {
14
+ const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, recordExplanations, recordChoices, recordOutputsOf, choices, onSave, onDelete, onClose, onPickPicture, refusal, notice }) => {
15
15
  const [ draft, setDraft ] = useState(node.config)
16
16
  const [ pictureUrl, setPictureUrl ] = useState(node.picture_url)
17
17
  useEffect(() => setPictureUrl(node.picture_url), [ node.id, node.picture_url ])
@@ -33,6 +33,7 @@ const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, re
33
33
  style={{ border: "none", background: "none", cursor: "pointer", fontSize: 18, lineHeight: 1 }}>×</button>
34
34
  </div>
35
35
  {refusal && <p className="text-red-800 dark:text-red-400" style={{ fontWeight: 600, marginBottom: 12 }} data-refusal>{refusal}</p>}
36
+ {notice && !refusal && <p className="text-emerald-800 dark:text-emerald-400" style={{ fontWeight: 600, marginBottom: 12 }} data-notice>{notice}</p>}
36
37
  {Object.entries(fields).map(([ name, type ]) => (
37
38
  <Label key={name}>
38
39
  <span style={{ display: "block", marginBottom: 3 }}>{labels[name] || name}</span>
@@ -16,6 +16,8 @@ module EasyFlow
16
16
 
17
17
  output :result, type: :boolean, values: [ true, false ]
18
18
 
19
+ summarizes_by { |node| Array(node.config["comparisons"]).size.then { |count| "#{node.config["join"]} #{count} #{"comparison".pluralize(count)}" } }
20
+
19
21
  def route(node, state, times)
20
22
  comparisons = Array(node.config["comparisons"])
21
23
  return false if comparisons.empty?
@@ -20,13 +20,21 @@ module EasyFlow
20
20
  end
21
21
 
22
22
  def drawn_step(node)
23
- { "id" => node.id, "type" => node.type, "type_name" => step_type_for(node)&.step_name, "label" => label_for(node), "summary" => drawn_by_type(node, :summary_of), "details" => drawn_by_type(node, :details_of).to_a, "links" => drawn_by_type(node, :links_of).to_a,
23
+ { "id" => node.id, "type" => node.type, "type_name" => step_type_for(node)&.step_name, "label" => label_for(node), "summary" => summary_of(node), "details" => drawn_by_type(node, :details_of).to_a, "links" => drawn_by_type(node, :links_of).to_a,
24
24
  "config" => node.config.merge(kept_values(node)), "ports" => [], "ends_here" => ends_here?(node), "begins_here" => begins_here?(node),
25
25
  "starts_a_flow" => starts_a_flow?(node), "holds" => holds(node), "opens" => opens(node), "loose" => loose?(node), "choices" => choices_for(node), "record_choices" => record_choices_for(node), "placeholder" => false, "picture_url" => picture_url(node), **placed[node.id] }
26
26
  end
27
27
 
28
+ def summary_of(node)
29
+ drawn_safely(node, :summary_of) { (@host&.summarizes?(node.type) ? @host : step_type_for(node))&.summary_of(node) }
30
+ end
31
+
28
32
  def drawn_by_type(node, part)
29
- step_type_for(node)&.public_send(part, node)
33
+ drawn_safely(node, part) { step_type_for(node)&.public_send(part, node) }
34
+ end
35
+
36
+ def drawn_safely(node, part)
37
+ yield
30
38
  rescue StandardError => error
31
39
  Rails.logger.error("EasyFlow could not draw step #{node.id}'s #{part}: #{error.class}: #{error.message}")
32
40
  nil
@@ -171,7 +179,11 @@ module EasyFlow
171
179
 
172
180
  def choices_for(node)
173
181
  naming_steps(node).index_with { earlier_than(node) }.merge(naming_flows(node).index_with { offered_flows })
174
- .merge(drawn_by(node)).merge(named_outputs_by(node))
182
+ .merge(drawn_by(node)).merge(named_outputs_by(node)).merge(worked_out_choices(node))
183
+ end
184
+
185
+ def worked_out_choices(node)
186
+ drawn_safely(node, :options) { step_type_for(node)&.settings&.worked_out_choices(node.config) }.to_h.transform_keys(&:to_s)
175
187
  end
176
188
 
177
189
  def record_choices_for(node)
@@ -13,6 +13,15 @@ module EasyFlow
13
13
 
14
14
  output :result, type: :boolean, values: [ true, false ]
15
15
 
16
+ summarizes_by { |node| [ node.config.values_at("step", "output").compact_blank.join("."), node.config["comparison"], Compare.amount_of(node.config["amount"]) ].compact_blank.join(" ") }
17
+
18
+ def self.amount_of(value)
19
+ number = Float(value.to_s, exception: false)
20
+ return value if number.nil?
21
+
22
+ number == number.round ? number.to_i.to_s : number.to_s
23
+ end
24
+
16
25
  def route(node, state, times)
17
26
  number = Float(CompletedAt.value_of(state, times, *node.config.values_at("step", "output")).to_s, exception: false)
18
27
  return false if number.nil?
@@ -15,6 +15,19 @@ module EasyFlow
15
15
 
16
16
  output :result, type: :boolean, values: [ true, false ]
17
17
 
18
+ summarizes_by { |node| CompareTwoValues.summarized(node.config) }
19
+
20
+ def self.summarized(config)
21
+ [ config.values_at("step", "output").compact_blank.join("."), config["comparison"], compared_with(config) ].compact_blank.join(" ")
22
+ end
23
+
24
+ def self.compared_with(config)
25
+ amount = Compare.amount_of(config["amount"])
26
+ return amount if config["other_step"].blank?
27
+
28
+ [ config.values_at("other_step", "other_output").compact_blank.join("."), ("+ #{amount}" if amount.present?) ].compact.join(" ")
29
+ end
30
+
18
31
  def route(node, state, times)
19
32
  first = number(CompletedAt.value_of(state, times, *node.config.values_at("step", "output")))
20
33
  second = node.config["other_step"].present? ? number(CompletedAt.value_of(state, times, *node.config.values_at("other_step", "other_output"))) : 0.0
@@ -12,6 +12,7 @@ module EasyFlow
12
12
  output :result, type: :boolean, values: [ true, false ]
13
13
 
14
14
  names_by { |node| node.config.values_at("step", "comparison", "answer").compact_blank.join(" ").presence }
15
+ summarizes_by { |node| [ node.config.values_at("step", "output").compact_blank.join("."), *node.config.values_at("comparison", "answer") ].compact_blank.join(" ") }
15
16
 
16
17
  def route(node, state)
17
18
  answer = state[node.config["step"]]
@@ -11,6 +11,14 @@ module EasyFlow
11
11
  output :count, type: :integer
12
12
 
13
13
  names_by { |node| [ "Count", *node.config.values_at("step", "answer") ].compact_blank.join(" ") }
14
+ summarizes_by { |node| Count.summarized(node.config) }
15
+
16
+ def self.summarized(config)
17
+ return if config["step"].blank?
18
+
19
+ counted = config.values_at("step", "output").compact_blank.join(".")
20
+ config["answer"].blank? ? "counts every answer to #{counted}" : "counts #{counted} is #{config["answer"]}"
21
+ end
14
22
 
15
23
  def process(node, state)
16
24
  visits(node, state).count { |answer| counted?(node, answer) }
@@ -9,6 +9,7 @@ module EasyFlow
9
9
 
10
10
  setting(:values, type: :list, label: "Values it reports") { setting :name, type: :string, required: true }
11
11
  outputs_named_by :values
12
+ summarizes_by { |node| Array(node.config["values"]).filter_map { |value| value["name"].presence }.then { |names| "reports #{names.join(", ")}" if names.any? } }
12
13
 
13
14
  output :result, values: %w[passed failed]
14
15
  output :reason
@@ -14,6 +14,12 @@ module EasyFlow
14
14
  waits_until { |_node, _state| false }
15
15
 
16
16
  names_by { |node| ChosenFlow.of(node).name }
17
+ summarizes_by { |node| FlowStep.steps_in(node)&.then { |count| "#{count} #{"step".pluralize(count)}" } }
18
+
19
+ def self.steps_in(node)
20
+ version = ChosenFlow.of(node).version
21
+ Array(version.definition.to_h["nodes"]).count { |step| %w[start terminal].exclude?(step["type"]) } if version
22
+ end
17
23
 
18
24
  def self.endings_of(node)
19
25
  version = ChosenFlow.of(node).version
@@ -8,6 +8,7 @@ module EasyFlow
8
8
  setting :flows, type: :flows, required: true
9
9
 
10
10
  names_by :question
11
+ summarizes_by { |node| Array(node.config["flows"]).size.then { |count| "offers #{count} #{"flow".pluralize(count)}" } }
11
12
  awaits_input
12
13
 
13
14
  plays_the_picked_flow
@@ -1,5 +1,14 @@
1
1
  module EasyFlow
2
2
  class Settings
3
+ class OptionsUnavailable < StandardError
4
+ attr_reader :setting
5
+
6
+ def initialize(setting, cause)
7
+ @setting = setting
8
+ super("#{setting} options could not be worked out: #{cause.class}: #{cause.message}")
9
+ end
10
+ end
11
+
3
12
  attr_reader :fields, :labels, :explanations, :record_fields, :record_labels, :record_explanations, :record_choices, :record_outputs_of, :record_required, :drawn_from, :outputs_of
4
13
 
5
14
  def initialize(fields: {}, labels: {}, explanations: {}, record_fields: {}, record_labels: {}, record_explanations: {}, record_choices: {}, record_outputs_of: {}, record_required: {}, choices: {},
@@ -24,7 +33,30 @@ module EasyFlow
24
33
  end
25
34
 
26
35
  def choices
27
- @choices.transform_values { |offered| offered.respond_to?(:call) ? offered.call : offered }
36
+ @choices.transform_values { |offered| depends_on_settings?(offered) ? [] : worked_out(offered) }
37
+ end
38
+
39
+ def choices_for(config)
40
+ choices.merge(worked_out_choices(config))
41
+ end
42
+
43
+ def worked_out_choices(config)
44
+ @choices.select { |_name, offered| depends_on_settings?(offered) }.to_h do |name, offered|
45
+ [ name, offered.call(config.to_h) ]
46
+ rescue StandardError => error
47
+ raise OptionsUnavailable.new(labels[name], error)
48
+ end
49
+ end
50
+
51
+ def strays(config)
52
+ worked_out_choices(config).filter_map do |name, offered|
53
+ chosen = config.to_h[name.to_s]
54
+ name.to_s if chosen.present? && values_of(offered).exclude?(chosen)
55
+ end
56
+ end
57
+
58
+ def cleared(config)
59
+ config.to_h.merge(strays(config).index_with(nil))
28
60
  end
29
61
 
30
62
  def kept_values(config)
@@ -66,17 +98,25 @@ module EasyFlow
66
98
  end
67
99
 
68
100
  def objections(config)
69
- config.to_h.flat_map { |name, value| objections_to(name.to_sym, value) }.compact
101
+ offered = choices_for(config)
102
+ config.to_h.flat_map { |name, value| objections_to(name.to_sym, value, offered) }.compact
70
103
  end
71
104
 
72
105
  private
73
106
 
74
- def objections_to(name, value)
75
- [ unoffered(name, value), over_limit(name, value), refused(name, value) ]
107
+ def worked_out(offered)
108
+ offered.respond_to?(:call) ? offered.call : offered
109
+ end
110
+
111
+ def depends_on_settings?(offered)
112
+ offered.respond_to?(:arity) && offered.arity == 1
113
+ end
114
+
115
+ def objections_to(name, value, offered)
116
+ [ unoffered(name, value, offered[name]), over_limit(name, value), refused(name, value) ]
76
117
  end
77
118
 
78
- def unoffered(name, value)
79
- offered = choices[name]
119
+ def unoffered(name, value, offered)
80
120
  return unless offered
81
121
 
82
122
  stray = Array(value).find { |chosen| values_of(offered).exclude?(chosen) }
@@ -14,6 +14,7 @@ module EasyFlow
14
14
  end
15
15
 
16
16
  names_by :question
17
+ summarizes_by { |node| Question.summarized(node.config) }
17
18
  awaits_input
18
19
  drawn_by "easy_flow/steps/ticking"
19
20
  answer_check { |node, value| "Tick at least one to go on." if node.config["required"] && Array(value).compact_blank.empty? }
@@ -12,6 +12,7 @@ module EasyFlow
12
12
  setting :required, type: :boolean
13
13
 
14
14
  names_by :question
15
+ summarizes_by { |node| FileUpload.accepted_extensions(node).then { |extensions| "accepts #{extensions.join(", ")}" if extensions.any? } }
15
16
  awaits_input
16
17
  drawn_by "easy_flow/steps/uploading"
17
18
  answer_check { |node, value| FileUpload.problem_with(node, value) }
@@ -20,6 +20,7 @@ module EasyFlow
20
20
  end
21
21
 
22
22
  names_by :question
23
+ summarizes_by { |node| Array(node.config["accepted_answers"]).size.then { |count| "accepts #{count} #{"answer".pluralize(count)}" } }
23
24
  awaits_input
24
25
  drawn_by "easy_flow/steps/typing"
25
26
  answer_check { |node, value| "Type an answer to go on." if node.config["required"] && value.blank? }
@@ -16,6 +16,7 @@ module EasyFlow
16
16
  end
17
17
 
18
18
  names_by :question
19
+ summarizes_by { |node| Question.summarized(node.config) }
19
20
  awaits_input
20
21
  drawn_by "easy_flow/steps/ticking"
21
22
  answer_check { |node, value| "Pick at least one answer to go on." if node.config["required"] && Array(value).compact_blank.empty? }
@@ -20,6 +20,7 @@ module EasyFlow
20
20
  output :answer, type: :string, label: "Answer", values: ->(node) { Question.offered(node.config) }
21
21
 
22
22
  names_by :question
23
+ summarizes_by { |node| Question.summarized(node.config) }
23
24
  awaits_input
24
25
  answer_check { |node, value| "Fill this in to go on." if node.config["required"] && value.blank? }
25
26
 
@@ -29,6 +30,10 @@ module EasyFlow
29
30
  step.to_h["question"] || step.to_h["text"]
30
31
  end
31
32
 
33
+ def self.summarized(step)
34
+ answers_of(step).size.then { |count| "#{count} #{"answer".pluralize(count)}" }
35
+ end
36
+
32
37
  def self.answers_of(step)
33
38
  Array(step.to_h["answers"] || step.to_h["options"])
34
39
  end
@@ -8,6 +8,8 @@ module EasyFlow
8
8
 
9
9
  output :choice, type: :string, label: "Choice", from: :step
10
10
 
11
+ summarizes_by { |node| "branches on #{node.config["step"]}" if node.config["step"].present? }
12
+
11
13
  def route(node, state)
12
14
  state[node.config["step"]]
13
15
  end
@@ -10,6 +10,7 @@ module EasyFlow
10
10
  setting :date, type: :string, label: "Date, as YYYY-MM-DD"
11
11
 
12
12
  names_by { |node| Wait.named(node.config) }
13
+ summarizes_by { |node| Wait.summarized(node.config) }
13
14
 
14
15
  waits_until { |node, _state, times| Wait.held_until(node, times)&.then { |held| held <= Time.current } || false }
15
16
 
@@ -20,6 +21,13 @@ module EasyFlow
20
21
  "#{waited} after #{config["step"]}" if waited
21
22
  end
22
23
 
24
+ def self.summarized(config)
25
+ until_then = config["date"].presence || config["time_of_day"].presence
26
+ return "waits until #{until_then}" if until_then
27
+
28
+ "waits #{config["minutes"]} #{"minute".pluralize(config["minutes"].to_i)}" if config["minutes"].present?
29
+ end
30
+
23
31
  def self.held_until(node, times)
24
32
  from = times[node.config["step"]]
25
33
  return Time.zone.parse(node.config["date"]) if node.config["date"].present?
@@ -85,6 +85,18 @@ module EasyFlow
85
85
  @step_groups || {}
86
86
  end
87
87
 
88
+ def summaries=(summaries)
89
+ @summaries = summaries.to_h.transform_keys(&:to_s)
90
+ end
91
+
92
+ def summarizes?(step_type)
93
+ @summaries.to_h.key?(step_type.to_s)
94
+ end
95
+
96
+ def summary_of(node)
97
+ @summaries.to_h[node.type.to_s]&.call(node).presence
98
+ end
99
+
88
100
  def explanation_for(step_type, setting)
89
101
  @setting_explanations.to_h.dig(step_type.to_s, setting.to_s).presence
90
102
  end
@@ -1,3 +1,3 @@
1
1
  module EasyFlow
2
- VERSION = "0.49.1"
2
+ VERSION = "0.50.0"
3
3
  end
@@ -83,7 +83,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
83
83
  4. Ask the developer which hosts' admins should be able to add the type. A registered type is in a host's palette, the step types an admin can add on that host's canvas, only when the host names no list of offered step types or its list includes the type's id. A type that declares `ends_here` is in every host's palette, and a type that declares `begins_here` is in none. When a host that names a list should offer the new type, add the type's id to that host's list through `easy_flow-install`. Leaving a type off a host's list only keeps admins from adding it there, and a step of that type already in one of the host's flows is still drawn and run, and still opens with all its settings and can be saved.
84
84
  5. Use these words to declare the type. Each is called once at class level (or inside the `EasyFlow.step` block):
85
85
  - `step_name "<label>"` — the name admins see on the canvas. Defaults to the id.
86
- - `setting :name, type:, label:, explanation:, options:, required:, optional:, limit:, check:, from:, outputs_of:, kept_on:, attribute:` — a field the admin fills in on the canvas. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, `:select`, `:multi_select`, `:radio_cards`, `:previous_step`, `:from_step`, `:list`, `:flow`, or boot raises `EasyFlow::UnknownFieldType`. A `:select`, `:multi_select` or `:radio_cards` must pass `options:`, or boot raises the same error. A `:radio_cards` setting is drawn in the step's settings as one keystone radio card per option, side by side with each card taking an equal share of the row, and one card per row when the panel is too narrow; its `options:` are hashes `{ value:, label:, hint: }`, as a fixed array or a lambda that works them out from the app's records (`options: -> { Release.aliases.map { |release| { value: release.alias, label: "#{release.alias} → #{release.version}", hint: release.stats_line } } }`), the chosen card's `value` is stored in `node.config`, and a saved value that is not one of the options' values is refused. `options:` is either an array of strings, or a lambda taking no arguments that returns one; the lambda is called each time the canvas is opened and each time an admin saves the step's settings, so the options follow the app's data without a restart (`options: -> { Region.order(:name).pluck(:code) }`). A saved setting whose value is no longer among the options is refused the next time the admin saves that step. When the options come from the app's records, ask the developer which records, which column is stored as the value, and whether the list must differ by account or host, since the lambda is passed nothing and the same list is offered everywhere the type is used. A `:list` must take a block of `setting` calls describing one entry. `:previous_step` lets the admin pick an earlier step, and is required unless declared with `optional: true`. Ask the developer whether a step of the type may be left without that earlier step, and when it may, declare `optional: true` and handle a blank value in the type's code. `outputs_of: :<setting>` offers the outputs of the step chosen in that setting, and `from: :<setting>` offers the values of the output chosen in that setting; either one makes the type `:from_step`. A required setting left blank shows a warning on the step's card that the step `needs a value for <label>`, and saving the flow as a new version and publishing it are refused until the admin fills it in. An `outputs_of:` setting left blank is flagged and refused the same way once the setting it reads names a step, whether or not it is declared `required:`. Inside a `:list` entry, a blank required setting, or a blank `outputs_of:` setting whose step is picked, shows `needs a value for <label> in <list label> entry <n>` for the entry at position `n` counting from 1. `optional:` has no effect inside a `:list` entry, where a `:previous_step` is required only when declared `required: true`. `:flow` lets the admin pick one of the flows the admin's list shows on the same host, offered by title, and is stored in `node.config` as that flow's id as a string. A `:flow` setting is not checked on save against the flows offered, so code that reads it looks the flow up through the host and handles a blank or unknown id. `limit:` is the most values a `:multi_select` takes. `check:` is a lambda given the value that returns an error message, or `nil` when the value is acceptable. `label:` defaults to the name humanized. `explanation:` is an optional sentence shown under the setting in the step's settings, inside a `:list` entry as well, and a setting with none shows nothing there. A host can replace it with its own through `setting_explanations`, set through `easy_flow-install`. `kept_on:` and `attribute:` keep the setting's value on one of the app's own records instead of in the flow; see "Keep a setting on one of the app's records".
86
+ - `setting :name, type:, label:, explanation:, options:, required:, optional:, limit:, check:, from:, outputs_of:, kept_on:, attribute:` — a field the admin fills in on the canvas. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, `:select`, `:multi_select`, `:radio_cards`, `:previous_step`, `:from_step`, `:list`, `:flow`, or boot raises `EasyFlow::UnknownFieldType`. A `:select`, `:multi_select` or `:radio_cards` must pass `options:`, or boot raises the same error. A `:radio_cards` setting is drawn in the step's settings as one keystone radio card per option, side by side with each card taking an equal share of the row, and one card per row when the panel is too narrow; its `options:` are hashes `{ value:, label:, hint: }`, as a fixed array or a lambda that works them out from the app's records (`options: -> { Release.aliases.map { |release| { value: release.alias, label: "#{release.alias} → #{release.version}", hint: release.stats_line } } }`), the chosen card's `value` is stored in `node.config`, and a saved value that is not one of the options' values is refused. A `:radio_cards` lambda that takes one argument is given the step's settings as a hash and works out the cards from them, such as `options: ->(config) { Agent.find_by(name: config["agent"])&.aliases.to_a.map { |release| { value: release.alias, label: "#{release.alias} → #{release.version}", hint: release.stats_line } } }`, so an alias the chosen agent does not have gets no card. The canvas works the cards out again each time the admin saves the step, so they change as soon as the other setting is saved, without reloading the page. When a save leaves the chosen card no longer among them, the choice is cleared instead of refused, and the settings panel shows a notice such as "Cleared Alias because candidate is not offered for the step's other settings." When the lambda raises, the canvas still opens and the setting shows no cards, and the error is written to the app's log. When it raises while the admin saves the step, the error is written to the log and the save is refused, and the settings panel says the setting "could not be worked out, so the change was not saved." The palette offers no cards for such a setting, since it has no step's settings to work them out from. `options:` is either an array of strings, or a lambda taking no arguments that returns one; the lambda is called each time the canvas is opened and each time an admin saves the step's settings, so the options follow the app's data without a restart (`options: -> { Region.order(:name).pluck(:code) }`). A saved setting whose value is no longer among the options is refused the next time the admin saves that step. When the options come from the app's records, ask the developer which records, which column is stored as the value, and whether the list must differ by account or host, since the lambda is passed nothing and the same list is offered everywhere the type is used. A `:list` must take a block of `setting` calls describing one entry. `:previous_step` lets the admin pick an earlier step, and is required unless declared with `optional: true`. Ask the developer whether a step of the type may be left without that earlier step, and when it may, declare `optional: true` and handle a blank value in the type's code. `outputs_of: :<setting>` offers the outputs of the step chosen in that setting, and `from: :<setting>` offers the values of the output chosen in that setting; either one makes the type `:from_step`. A required setting left blank shows a warning on the step's card that the step `needs a value for <label>`, and saving the flow as a new version and publishing it are refused until the admin fills it in. An `outputs_of:` setting left blank is flagged and refused the same way once the setting it reads names a step, whether or not it is declared `required:`. Inside a `:list` entry, a blank required setting, or a blank `outputs_of:` setting whose step is picked, shows `needs a value for <label> in <list label> entry <n>` for the entry at position `n` counting from 1. `optional:` has no effect inside a `:list` entry, where a `:previous_step` is required only when declared `required: true`. `:flow` lets the admin pick one of the flows the admin's list shows on the same host, offered by title, and is stored in `node.config` as that flow's id as a string. A `:flow` setting is not checked on save against the flows offered, so code that reads it looks the flow up through the host and handles a blank or unknown id. `limit:` is the most values a `:multi_select` takes. `check:` is a lambda given the value that returns an error message, or `nil` when the value is acceptable. `label:` defaults to the name humanized. `explanation:` is an optional sentence shown under the setting in the step's settings, inside a `:list` entry as well, and a setting with none shows nothing there. A host can replace it with its own through `setting_explanations`, set through `easy_flow-install`. `kept_on:` and `attribute:` keep the setting's value on one of the app's own records instead of in the flow; see "Keep a setting on one of the app's records".
87
87
  - `output :name, type:, label:, values:, from:` — a value the step records. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, or boot raises `EasyFlow::UnknownOutputType`. `values:` is an array or a lambda taking the node, listing the values the output can take; the canvas offers these as the connections leaving the step, so a type that routes must declare them. `from: :<setting>` takes the values from the step chosen in that setting. A Condition step requires the admin to pick one of the earlier step's outputs, so a type whose answer admins should test with a Condition declares at least one `output`, with `values:` so the Condition offers answers to pick.
88
88
  - `outputs_named_by :<list setting>` — adds one output for each entry an admin enters in that `:list` setting, named by the entry's `name`, so the setting's entry block must declare `setting :name, type: :string`. Ask the developer whether the admin or the type decides the names of the values the step records. Do not pick.
89
89
  - The named outputs follow any outputs the type declares with `output`, in the order the admin entered them. An entry with a blank `name` adds none.
@@ -105,7 +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
+ - `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. easy_flow's own step types already give a summary, such as "tests.result is not passed" on a Condition step or "waits 5 minutes" on a Wait step, and a host replaces any type's summary, its own or easy_flow's, through the host's `summaries`, set through `easy_flow-install`. 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.
109
109
  - `shows_values(heading = nil, columns: false) { |node| ... }` — a read-only section of the step settings panel, shown under the step's editable settings. The block returns a hash of labels to values, such as `shows_values("Inputs") { |node| { "brief" => "load_brief.out.brief" } }`, and each value is shown as text in a monospace font. Without `columns:` each label sits beside its value with the labels in one column. With `columns: true` the pairs sit two to a row, each label above its value, such as `shows_values(columns: true) { |node| { "Timeout" => "90s", "Retry" => "3" } }`. Declare it several times for several sections, which are shown in the order declared. Nothing in a section can be edited from the panel.
110
110
  - `shows_code(heading = nil) { |node| ... }` — a read-only section of the step settings panel holding code blocks. The block returns a hash of summary lines to code, such as `shows_code("Schemas") { |node| { "input_schema" => node.config["input_schema"].to_s } }`. Each block is closed until its summary line is clicked, and a line wider than the panel scrolls sideways inside its block.
111
111
  - `links_to { |node| ... }` — buttons at the foot of the step settings panel, side by side above Delete step. The block returns a list of hashes each with a `label` and an `address`, such as `links_to { |node| [ { label: "Open agent", address: "/agents/#{node.config['agent']}" } ] }`. Each address is used as written.
@@ -55,7 +55,7 @@ easy_flow declares no commands of its own for this local. Its surface is split b
55
55
  - **Display** — what a step type hands the visitor's page to draw a step, such as its question text and its answers. A step type may build its display from the step alone, or from the step and the visitor's stored run, so the same step can show something different to each visitor. There is no stored run in an admin's preview or in a flow that carries its answers in the page, and the display is then built without one. A host can draw a single-choice, multiple-select or fill-in-the-blank step with an answer already chosen by passing it as `chosen`, and the step is drawn blank when none is passed.
56
56
  - **Answer check** — a rule a step type may carry that looks at a visitor's answer and, when the answer is not acceptable, returns the message the visitor sees. A step type with no such rule accepts every answer.
57
57
  - **Setting** — one field an admin fills in when configuring a step on the canvas. A step type may give a setting a one-sentence explanation, which shows under it in the step's settings. It is text, a whole number, a decimal, a yes or no, a pick from a list, a pick from a few choices drawn as radio cards side by side with a hint under each, several picks from a list, an earlier step, an earlier step's output, another flow of the same host, or a list of entries that each hold their own fields. A setting can be required, limited to a number of picks, or checked by a rule the step type supplies.
58
- - **Options** — the values a pick-from-a-list setting offers, and for a radio card setting each value's label and hint. They are either a fixed list written into the step type, or a lookup the app provides that is read each time the canvas or a save asks for them, so they can come from the app's own data. A saved value that is not among the options is refused.
58
+ - **Options** — the values a pick-from-a-list setting offers, and for a radio card setting each value's label and hint. They are either a fixed list written into the step type, or a lookup the app provides that is read each time the canvas or a save asks for them, so they can come from the app's own data. A radio card setting's lookup may also be given the step's other settings, so its cards follow another setting, such as an agent's own aliases following the agent chosen. Its cards change as soon as the admin saves that other setting, without reloading the page. A saved value that is not among the options is refused, except that a radio card choice the step's other settings no longer offer is cleared on save, and the settings panel says it was cleared.
59
59
  - **Kept setting** — a setting whose value lives on one of the app's own records rather than in the flow. The step type says how to find that record from the step's other settings and which of its attributes holds the value. The canvas shows the value read from the record, and saving the step's settings writes it straight to the record, so the flow's document and its versions never hold it and undo or publishing does not change it. When no record is found, nothing is written. When the record refuses a value, the save is refused with the record's own error and none of the step's kept settings are written.
60
60
  - **Output** — a value a step records into the run, with a type and a label. Later steps read outputs, and a setting that points at an earlier step offers that step's known values on the canvas. A step type may also take further outputs from a list setting, one for each entry the admin gives a name, labelled with that name written as a phrase, such as "First reading" for `first_reading`. An entry left without a name adds no output. Those outputs are offered wherever the step's declared outputs are, such as when a Condition, Compare, Compare two values, All of or Any of or Count step picks which output to read.
61
61
  - **Chosen output** — which of an earlier step's outputs a step reads. Every built-in step that names an earlier step and then reads one of its outputs asks the admin to pick that output, as does a step type of the app's own whose output setting points at a step setting. Once the earlier step is named, a step with no output picked is reported as missing that setting, and the same holds for each comparison in an All of or Any of list, for its first step and for its second step. A step that names no earlier step, such as a Compare two values step with its second step left empty, is not asked for that step's output.
@@ -102,7 +102,7 @@ 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 Validation tab of the drawer under the canvas rather than on the card.
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 or the host replaces it, 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 Validation tab of the drawer under the canvas rather than on the card.
106
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.
107
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.
108
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.
@@ -112,6 +112,8 @@ easy_flow declares no commands of its own for this local. Its surface is split b
112
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
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.
114
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.
115
+ - **Built-in summaries** — the summary line easy_flow's own step types give their cards. A Question, Checklist or Multiple select step shows how many answers it offers, such as "3 answers", and a Fill in the blank step how many answers it accepts. A File upload step shows the file types it accepts. A Condition, Compare or Compare two values step shows the comparison it makes, such as "tests.result is not passed". An All of or Any of step shows which must hold and how many comparisons it has, such as "all of 2 comparisons". A Count step shows what it counts, a Switch step the step it branches on, and a Read data or Write data step the values it reports. A Wait step shows how long it waits, such as "waits 5 minutes" or "waits until 09:00". A Flow step shows how many steps the version it runs holds, and a Play flows step how many flows it offers. Start and End steps show none.
116
+ - **Host summaries** — a setting a host may set, `summaries`, giving its own summary block for any step type, including easy_flow's own. Its line shows on the card in place of the step type's own, and a block that returns nothing shows no line. A block that raises is drawn without a summary, the error is written to the log, and the flow still opens.
115
117
  - **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.
116
118
  - **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, the message saying what the last of them did or why it was refused, and the list of changes since the last version. 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.
117
119
  - **Drawer** — the panel under the editing canvas, on every host, with a row of tabs. Its first tab is Validation, followed by the number of problems the flow has when it has any. Validation lists one row per check: an `error` row for each problem with the step's id and a sentence naming the step by its name, or by its step type's name when it has none, and saying what to do to clear it, then an `ok` row for each check that found nothing. Clicking a row that names a step selects that step and opens its settings. A host may set `drawer_tabs` to add its own tabs after Validation, each with a label, an optional count such as `12/12` and its own content. On a phone the drawer shows only its tabs until one is tapped, an open drawer covers the canvas, and tapping the open tab again closes it.
@@ -68,6 +68,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
68
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.
69
69
  - `drawer_tabs` — a list of hashes each with a `label`, an optional `count` and its `content` as HTML, such as `[ { label: "Fixtures", count: "12/12", content: "<p>12 of 12 fixtures pass.</p>" }, { label: "Dry-run", content: "<p>No dry-run yet.</p>" } ]`, shown as tabs after Validation in the drawer under this host's canvas. The count is written after the label, and a tab with no count shows only its label. It may instead be a callable that takes the flow being edited and returns that list, such as `->(flow) { [ { label: "Fixtures", count: FixtureRun.score(flow), content: ApplicationController.render(partial: "flows/fixtures", locals: { flow: flow }) } ] }`. The content is put on the page as given, so it is built by the app and any value from a record in it is escaped. The list is worked out each time the canvas is drawn, so a slow lookup slows the canvas. A hash missing `label` or `content` raises `ArgumentError` when the canvas is opened. With none set, the drawer shows only Validation. Ask the developer which tabs each host's drawer needs and what each shows.
70
70
  - `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.
71
+ - `summaries` — this host's own summary lines for step cards, as a hash of step type name to a block given the step, such as `{ condition: ->(node) { "#{node.config['step']} must be #{node.config['answer']}" } }`. It replaces the summary of any step type, easy_flow's own included, so a host can word the cards of Condition, Wait and the other built-in types its own way without changing the gem. A block that returns `nil` or `""` shows no line. The block is called each time the canvas is drawn, so it must not be slow and must not change anything. When it raises, the step is drawn without a summary, the error is written to the app's log, and the flow still opens. With none set, every step shows its type's own summary. Ask the developer which step types' cards should read differently from easy_flow's own summaries.
71
72
  - `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.
72
73
 
73
74
  Each method named here must exist on the base controller. Ask the developer to point at it or write it. Do not invent its logic.
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.49.1
4
+ version: 0.50.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider