easy_flow 0.51.0 → 0.52.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: 77d02cd907f2840a4791fed3dd33e5618fafc3005ee7addb574356591440ecde
4
- data.tar.gz: 274741cc8c1bcd6c4a2a02eef6e0ccef0b30f6d11e2c417eb412335a2f684d56
3
+ metadata.gz: 9d7c7fe6e156649f27feced89f3bcead9bdac9fe6f39ebe8a9956e11716eefcd
4
+ data.tar.gz: c7635a07ec44d41af799c51f17542b3346d8143a267630696527593d899a6091
5
5
  SHA512:
6
- metadata.gz: 3c9d6f4059767823106dff2370609ad97e3556c04460e7a729d7a10095905c6c97590ce3385635f85a26509b4818465662ba16d859e9a5ba98d5a8025d437913
7
- data.tar.gz: ac3cd1d1c8605564a1be75478f1467a65b94293241af23569c8356bb0e2df0cdbc9ea9109d4b8984849067b7a8ddbbddb922240b88a8eb773f46b7ce9dbcdf9e
6
+ metadata.gz: 8abdee407d6ce1ffc63a98484d70ea89e1a0781a797c355886c39a08f95fad0a4a2a7966272825be60f01f9f9a0758763efbea2d126c35778adc8751aca6ca17
7
+ data.tar.gz: 957d60c9212f3fee557badd513bfeab88c5854df885f4cbd74042bb664bd3944cc3ac64253796da67bf14968aa554870588fbe4fc447270b44a2b3a05a8e5c4a
@@ -1 +1 @@
1
- (()=>{var Xe=globalThis.ReactDOM;var{createPortal:xs,createRoot:At,flushSync:ys,hydrateRoot:bs,preconnect:vs,prefetchDNS:ws,preinit:ks,preinitModule:Ss,preload:Cs,preloadModule:Ns,requestFormReset:Es,unstable_batchedUpdates:_s,useFormState:As,useFormStatus:zs,version:Ts}=Xe;var zt=globalThis.React,e=zt,{Children:Os,Component:Bs,Fragment:Ds,PureComponent:Ls,StrictMode:Ps,Suspense:Is,cloneElement:$s,createContext:Hs,createElement:Ws,createRef:js,forwardRef:Gs,isValidElement:Vs,lazy:Fs,memo:Us,startTransition:Xs,useCallback:Ys,useContext:qs,useDebugValue:Js,useDeferredValue:Ks,useEffect:L,useId:Zs,useImperativeHandle:Qs,useLayoutEffect:R,useMemo:P,useReducer:Rs,useRef:Y,useState:E,useSyncExternalStore:tn,useTransition:en}=zt;var Tt=new Map,tt=new Map,ft=(t,o)=>Tt.set(t,o),Mt=()=>{tt.forEach(t=>t.unmount()),tt.clear()},Ot=(t,o)=>t.querySelectorAll("[data-react-ui]").forEach(s=>{if(tt.has(s))return;let r=Tt.get(s.dataset.reactUi),n=o(s);tt.set(s,n),n.render(e.createElement(r,JSON.parse(s.dataset.props)))});var Bt=(t,o)=>{let s=()=>Ot(t,o);t.addEventListener("turbo:load",s),t.addEventListener("turbo:frame-load",s),t.addEventListener("turbo:before-cache",Mt),t.readyState==="loading"?t.addEventListener("DOMContentLoaded",s):s()};var A=(...t)=>t.filter(Boolean).join(" ");var Ye={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},qe={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Je=({variant:t="primary",size:o="md",className:s,children:r,...n})=>{let a=n.href?"a":"button";return e.createElement(a,{...n,className:A("ks-button",Ye[t],qe[o],s)},r)},w=Je;var Ke="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Ze="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Qe="border border-accent-600 bg-accent-600 text-white",Re=({name:t,connected:o,armed:s,onArm:r,connecting:n})=>e.createElement("button",{onClick:a=>{n||(a.stopPropagation(),r(a))},title:s?"Now choose a step to connect to":"Connect this branch",className:s?Qe:o?Ze:Ke,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},t||"next"),Dt=Re;var to={width:240,boxSizing:"border-box",borderRadius:8},eo={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=(t,o,s)=>{let r=s?"ring-4 ring-accent-600/15":"shadow-sm";return t||s&&!o?`border-accent-600 ${r}`:o?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},ao=(t,o)=>o&&t.label===t.id&&t.type_name||t.label,io=(t,o,s)=>s?o===t.type_name?null:t.type_name:t.type,lo=({node:t,selected:o,armed:s,connecting:r,onSelect:n,onOpen:a,onArm:p,onDragEnd:c,onDragStart:l,hideStepTypeCodes:m,compact:u=!1,typeAbove:x=u})=>{let h=t.begins_here||t.ends_here,d=t.begins_here,f=t.ends_here?[]:t.ports,_=r&&!d,v=ao(t,m),C=io(t,v,m);return e.createElement("div",{ref:t.ref,"data-step":t.id,draggable:!d,onDragStart:k=>{k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("text/plain",t.id),l()},onDragEnd:c,onClick:t.opens&&!r?()=>a(t.opens):n,className:`bg-white ${u&&!o?"border":"border-2"} dark:bg-zinc-900 ${no(_,t.violations.length>0,o)}`,style:{...u?eo:to,padding:h?0:u?"8px 10px":"12px 14px",cursor:d?"default":r?"crosshair":"grab"}},!h&&x&&C&&e.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},C),h&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:oo},v),!h&&e.createElement("div",{style:u?so:ro},v),t.violations.length>0&&e.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${t.violations.length} error${t.violations.length===1?"":"s"}`),!h&&t.summary&&t.violations.length===0&&e.createElement("div",{className:o?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},t.summary),!h&&!x&&C&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},C),t.picture_url&&e.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),t.starts_a_flow&&e.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),t.opens&&e.createElement(w,{variant:"secondary",size:"sm",className:"mt-2",onClick:k=>{k.stopPropagation(),n()}},"Settings"),f.length>0&&e.createElement("div",{style:{padding:t.begins_here?"0 14px 8px":"10px 0 0"}},f.map(k=>e.createElement(Dt,{key:k,name:k,connected:t.connected.includes(k),connecting:r,armed:s===k,onArm:N=>p(k,N)}))))},gt=lo;var Lt={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},co={...Lt,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},po=({node:t,header:o,onSelect:s,compact:r=!1})=>e.createElement("div",{ref:t.ref,"data-group-header":t.id,onClick:s,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?co:Lt,...s?{}:{cursor:"default"}}},o),et=po;var mo=({id:t,bounds:o,onDrop:s})=>e.createElement("div",{"data-group-box":t,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}}),Pt=mo;var uo=t=>t!=null&&t!==""&&typeof t!="object",fo=["integer","float"],go=(t,o,s)=>s&&o.labels?.[t]||t,ot=(t,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>uo(t.config[n])).map(n=>`${go(n,o,s)}${fo.includes(o.fields[n])?"":":"} ${t.config[n]}`);return[s&&t.type_name||t.type,...r].join(" \xB7 ")};var It=(t,o,s)=>{let r=Math.min(...t.map(c=>c.left))-o.left+s.scrollLeft-12,n=Math.min(...t.map(c=>c.top))-o.top+s.scrollTop-10,a=Math.max(...t.map(c=>c.left+c.width))-o.left+s.scrollLeft+12,p=Math.max(...t.map(c=>c.top+c.height))-o.top+s.scrollTop+10;return{left:r,top:n,width:a-r,height:p-n}},ho=({left:t,top:o,width:s,height:r},n)=>n.x>=t&&n.x<=t+s&&n.y>=o&&n.y<=o+r,$t=(t,o)=>t.find(s=>ho(s.bounds,o))?.id||null,Ht=(t,o)=>t.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),Wt=(t,o)=>o.some(s=>s.holds?.includes(t.id)&&!s.loose&&s.row===t.row-1);var ht=(t,o)=>t.includes(o)?t.filter(s=>s!==o):[...t,o],jt=(t,o)=>({...o?.choices||{},...t?.choices||{}});var xo=({as:t="input",disabled:o,className:s,...r})=>e.createElement(t,{...r,disabled:o,className:A("ks-input",o&&"ks-input-disabled",s)}),I=xo;var yo=t=>e.createElement(I,{...t,as:"select"}),Gt=yo;var bo=({className:t,...o})=>e.createElement("input",{type:"checkbox",...o,className:A("ks-checkbox",t)}),rt=bo;var vo=({name:t,value:o,label:s,hint:r,className:n,...a})=>e.createElement("label",{className:"inline-block cursor-pointer relative"},e.createElement("input",{type:"radio",name:t,value:o,...a,className:A("peer sr-only",n)}),e.createElement("span",{className:"ks-radio-card inline-flex flex-col cursor-pointer transition ks-radio-card-highlight"},e.createElement("span",{className:"ks-radio-card-header flex items-start justify-between"},e.createElement("span",{className:"ks-radio-card-label block"},s)),r!=null&&e.createElement("span",{className:"ks-radio-card-hint block text-sm"},r))),Vt=vo;var wo=({name:t,options:o,value:s,onChange:r,className:n})=>e.createElement("div",{className:A("flex flex-wrap ks-grid-gap-sm",n)},o.map(a=>e.createElement(Vt,{key:a.value,name:t,...a,checked:a.value===s,onChange:()=>r(a.value)}))),Ft=wo;var Ut=t=>(t||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),ko=({name:t,type:o,value:s,choices:r,onChange:n,onSettle:a,onPick:p,pictureUrl:c})=>{if(o==="picture")return e.createElement("div",{className:"mb-3"},s&&c&&e.createElement("img",{src:c,alt:"The step's picture",style:{maxWidth:"100%"}}),s&&e.createElement(w,{type:"button",variant:"secondary",size:"sm","data-remove-picture":!0,onClick:()=>a("")},"Remove picture"),e.createElement("input",{type:"file",accept:"image/*",onChange:l=>l.target.files[0]&&p(l.target.files[0])}));if(o==="boolean")return e.createElement(rt,{checked:!!s,onChange:l=>a(l.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return e.createElement(Gt,{className:"mb-3",value:s??"",onChange:l=>a(l.target.value)},e.createElement("option",{value:""}),Ut(r).map(l=>e.createElement("option",{key:l.value,value:l.value},l.label)));if(o==="radio_cards")return e.createElement("div",{"data-radio-cards":!0,className:"mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full"},e.createElement(Ft,{name:t,value:s,options:r||[],onChange:a}));if(o==="multi_select"){let l=Array.isArray(s)?s:[],m=u=>a(ht(l,u));return e.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(r||[]).map(u=>e.createElement("label",{key:u,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(rt,{checked:l.includes(u),onChange:()=>m(u)}),e.createElement("span",null,u))))}if(o==="flows"){let l=Array.isArray(s)?s:[];return e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},Ut(r).map(m=>e.createElement("label",{key:m.value,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(rt,{checked:l.includes(m.value),onChange:()=>a(ht(l,m.value))}),e.createElement("span",null,m.label))))}return o==="integer"||o==="float"?e.createElement(I,{className:"mb-3",type:"number",step:o==="integer"?"1":"any",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>a(l.target.value)}):e.createElement(I,{className:"mb-3",type:"text",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>a(l.target.value)})},st=ko;var Xt=(t,o,s,r)=>t.map((n,a)=>a===o?{...n,[s]:r}:n);var So=({text:t})=>e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},t),nt=So;var Co=(t,o,s,r)=>{let n=(t||{})[s],a=(o||{})[s];return a?(n||{})[r[a]]:n},No=({holds:t,labels:o,explanations:s,rows:r,choices:n,outputsOf:a,onChange:p,onSettle:c})=>{let l=Array.isArray(r)?r:[],m=(u,x,h,d)=>{let f=Xt(l,u,x,h);d?c(f):p(f)};return e.createElement("div",{style:{marginBottom:12}},l.map((u,x)=>e.createElement("div",{key:x,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(t).map(([h,d])=>e.createElement("label",{key:h,style:{display:"block"}},e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[h]||h),e.createElement(st,{type:d,value:u[h],choices:Co(n,a,h,u),onChange:f=>m(x,h,f,!1),onSettle:f=>m(x,h,f,!0)}),(s||{})[h]&&e.createElement(nt,{text:s[h]}))),e.createElement(w,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>c(l.filter((h,d)=>d!==x))},"Remove"))),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>c([...l,{}])},"Add"))},Yt=No;var Eo={start:null,end:"ks-value-list-end"},_o="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",Ao="flex flex-col min-w-0",zo="ks-value-list-label basis-auto text-xs",To=()=>e.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"},e.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"})),Mo=({value:t,fallback:o})=>String(t??"")===""?o:t,Oo=({rows:t,align:o="start",columns:s=!1,className:r})=>e.createElement("dl",{className:A("ks-value-list",Eo[o],s&&_o,r)},t.map((n,a)=>e.createElement("div",{key:a,className:A(s?Ao:"ks-value-list-row",n.total&&"ks-value-list-total")},e.createElement("dt",{className:s?zo:"ks-value-list-label"},n.label,n.note!=null&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"ks-value-list-note"},n.note))),e.createElement("dd",{className:"ks-value-list-value"},Mo(n),n.right&&e.createElement(e.Fragment,null," ",e.createElement(To,null)))))),qt=Oo;var Bo=()=>e.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"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})),Do=({summary:t,open:o=!1,className:s,children:r})=>e.createElement("details",{className:A("ks-disclosure group",s),open:o},e.createElement("summary",{className:"ks-disclosure-summary flex cursor-pointer list-none items-center justify-between [&::-webkit-details-marker]:hidden"},e.createElement("span",null,t),e.createElement("span",{className:"ks-disclosure-icon h-4 w-4 shrink-0 transition-transform group-open:rotate-180"},e.createElement(Bo,null))),e.createElement("div",{className:"ks-disclosure-body text-sm"},r)),Jt=Do;var Lo=({language:t,caption:o,className:s,children:r})=>e.createElement("div",{className:A("ks-code overflow-hidden",s)},o!=null&&e.createElement("div",{className:"ks-code-caption font-mono text-xs"},o),e.createElement("pre",{className:"ks-code-block overflow-x-auto font-mono text-sm leading-relaxed"},e.createElement("code",{className:t==null?"":`language-${t}`},r))),Kt=Lo;var xt="flex flex-col gap-1 mb-3",Zt="[&_dd]:font-mono",Po="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",Io="[&_.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]",$o="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]",Ho=t=>t.values?t.columns?`${xt} ${Zt} ${Po}`:`${xt} ${Zt} ${Io}`:`${xt} ${$o}`,Wo=({details:t})=>e.createElement(e.Fragment,null,t.map((o,s)=>e.createElement("section",{key:s,className:Ho(o)},o.heading&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400"},o.heading),o.values&&e.createElement(qt,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>e.createElement(Jt,{key:r.summary,summary:r.summary},e.createElement(Kt,null,r.code)))))),Qt=Wo;var jo=({as:t="div",className:o,children:s,...r})=>e.createElement(t,{...r,className:A("ks-panel",o)},s),D=jo;var at=(t,o)=>({className:s,children:r,...n})=>e.createElement(t,{...n,className:A(o,s)},r),q=at("label","ks-label"),Na=at("p","ks-hint"),Ea=at("p","ks-error"),_a=at("span","ks-required");var Go={width:320,padding:"14px 16px",overflowY:"auto",display:"flex",flexDirection:"column",fontSize:12},Vo={marginTop:"auto",paddingTop:12,display:"flex",flexDirection:"column",gap:8},Fo=({node:t,fields:o,holds:s,labels:r,explanations:n,recordLabels:a,recordExplanations:p,recordChoices:c,recordOutputsOf:l,choices:m,onSave:u,onDelete:x,onClose:h,onPickPicture:d,refusal:f,notice:_})=>{let[v,C]=E(t.config),[k,N]=E(t.picture_url);L(()=>N(t.picture_url),[t.id,t.picture_url]),L(()=>C(t.config),[t.id,t.config]);let O=b=>{C(b),JSON.stringify(b)!==JSON.stringify(t.config)&&u(b)};return e.createElement(D,{as:"aside",style:Go,className:"max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto","data-inspector":!0},e.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8,marginBottom:12}},e.createElement("div",null,e.createElement("p",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.id," \xB7 ",t.type),e.createElement("h2",{style:{fontSize:15,fontWeight:600}},t.label)),e.createElement("button",{title:"Close",onClick:h,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),f&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},f),_&&!f&&e.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{fontWeight:600,marginBottom:12},"data-notice":!0},_),Object.entries(o).map(([b,B])=>e.createElement(q,{key:b},e.createElement("span",{style:{display:"block",marginBottom:3}},r[b]||b),B==="list"?e.createElement(Yt,{holds:s[b]||{},labels:a[b]||{},explanations:(p||{})[b],rows:v[b],choices:{...(c||{})[b],...(t.record_choices||{})[b]},outputsOf:(l||{})[b],onChange:T=>C({...v,[b]:T}),onSettle:T=>O({...v,[b]:T})}):e.createElement(st,{name:b,type:B,value:v[b],choices:m[b],pictureUrl:k,onChange:T=>C({...v,[b]:T}),onSettle:T=>O({...v,[b]:T}),onPick:async T=>{let H=await d(T);H&&(N(H.url),O({...v,[b]:H.reference}))}}),(n||{})[b]&&e.createElement(nt,{text:n[b]}))),e.createElement(Qt,{details:t.details||[]}),e.createElement("div",{style:Vo},(t.links||[]).length>0&&e.createElement("div",{style:{display:"flex",gap:8}},t.links.map(b=>e.createElement(w,{key:b.address,variant:"secondary",size:"sm",className:"flex-1",href:b.address},b.label))),e.createElement(w,{variant:"danger",size:"sm",className:"w-full",onClick:x},"Delete step")))},Rt=Fo;var Uo={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},Xo={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},Yo="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:t,dragging:o,onFill:s,onDrop:r,compact:n=!1})=>e.createElement("div",{ref:t.ref,"data-placeholder":t.id,title:`Choose the step \u201C${t.label}\u201D should lead to`,onClick:s,onDragOver:a=>{o&&(a.preventDefault(),a.dataTransfer.dropEffect="move")},onDrop:a=>{a.preventDefault(),r()},className:o?qo:Yo,style:n?Xo:Uo},e.createElement("div",{style:{fontWeight:600}},t.label),e.createElement("div",{style:{fontSize:11}},o?"drop a step here":"leads nowhere yet \u2014 click to choose")),te=Jo;var Ko=({entries:t,at:o,onPick:s,onConnect:r,onDismiss:n,hideStepTypeCodes:a})=>e.createElement(D,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:o.y,left:o.x,width:210,padding:8,borderRadius:8}},e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),t.map(p=>e.createElement(w,{key:p.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>s(p)},p.label,!a&&e.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},p.type))),r&&e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:n},"Cancel")),ee=Ko;var Zo=t=>o=>o.label.toLowerCase().includes(t.trim().toLowerCase()),Qo=(t,o,s="")=>{let r=Object.values(o).flat(),n=Object.entries(o).map(([a,p])=>({heading:a,entries:p.map(c=>t.find(l=>l.type===c)).filter(Boolean)}));return[{heading:null,entries:t.filter(a=>!r.includes(a.type))},...n].map(a=>({...a,entries:a.entries.filter(Zo(s))})).filter(a=>a.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"},tr={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},er={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},or=({entries:t,groups:o,onPick:s,onCarry:r,onDrop:n})=>{let[a,p]=E("");return e.createElement(D,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:Ro},e.createElement(I,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:a,onChange:c=>p(c.target.value),style:{marginBottom:6,fontSize:12}}),Qo(t,o,a).map(c=>e.createElement(e.Fragment,{key:c.heading||""},c.heading&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:tr},c.heading),c.entries.map(l=>e.createElement(D,{as:"button",type:"button",key:l.type,"data-step-type":l.type,className:"bg-surface-50 dark:bg-surface-950",style:er,draggable:!0,onClick:()=>s(l),onDragStart:m=>{m.dataTransfer.effectAllowed="copyMove",m.dataTransfer.setData("text/plain",l.type),r(l)},onDragEnd:n},l.label)))))},oe=or;var rr={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},re=({label:t,title:o,idle:s,enabled:r,onUse:n})=>e.createElement(w,{variant:"secondary",size:"sm",title:r?o:s,disabled:!r,onClick:n,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},t),sr=({undoable:t,redoable:o,onAdd:s,onUndo:r,onRedo:n})=>e.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},e.createElement(w,{variant:"secondary",className:"rounded-full",style:rr,title:"Add a step",onClick:s},"+"),e.createElement(re,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:t,onUse:r}),e.createElement(re,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),se=sr;var nr=({type:t="info",title:o,message:s,onDismiss:r,className:n})=>e.createElement("div",{className:A("ks-alert",`ks-alert-${t}`,n),role:"alert"},e.createElement("div",{className:"ks-alert-body"},e.createElement("div",{className:"ks-alert-content"},o&&e.createElement("p",{className:"ks-alert-title"},o),e.createElement("p",{className:o?"ks-alert-message-titled":"ks-alert-message"},s)),r&&e.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),ne=nr;var ae=t=>{let o=t.map(s=>`\u201C${s.name}\u201D`).join(", ");return t.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 ie=({version:t,published:o})=>t?o?o===t?`Version ${t} \xB7 live`:`Version ${t} \xB7 visitors still on ${o}`:`Version ${t} \xB7 never published`:"No version yet";var ar={width:280,padding:20,overflowY:"auto"},le={fontWeight:600,marginBottom:6,marginTop:14},yt={fontSize:12,marginBottom:4,lineHeight:1.4},de={display:"block",marginBottom:3},ce=(t,o,s)=>r=>{r.target.value!==(t[o]??"")&&s({[o]:r.target.value})},ir=({flow:t,changes:o,refusal:s,notice:r,publishNote:n,warning:a,onCreate:p,onPublish:c,onAccept:l,onDecline:m,onSaveDetails:u,onClose:x})=>e.createElement(D,{as:"aside",style:ar,"data-builder-panel":!0},e.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},e.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},t.title||t.slug),e.createElement("button",{title:"Close",onClick:x,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),e.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:t.history_url,"data-history":!0},ie(t)),a?e.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},e.createElement(ne,{type:"warning",className:"mb-1.5",message:ae(a.steps)}),e.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:l,"data-accept-removal":!0},a.path==="/publish"?"Remove and publish":"Remove and create version"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:m,"data-decline-removal":!0},"Cancel")):e.createElement("div",{style:{marginTop:14}},e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:p,"data-create-version":!0},"Create version"),e.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:c,"data-publish":!0},"Publish"),n&&e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},n)),s&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...yt,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&e.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...yt,fontWeight:600,marginTop:8},"data-notice":!0},r),e.createElement("h2",{style:le},"Changes since the last version"),o.length===0?e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):o.map((h,d)=>e.createElement("p",{key:d,style:yt,"data-change":!0},h)),e.createElement("h2",{style:le},"Details"),e.createElement(q,null,e.createElement("span",{style:de},"Title"),e.createElement(I,{className:"mb-3",defaultValue:t.title??"",onBlur:ce(t,"title",u),"data-flow-title":!0})),e.createElement(q,null,e.createElement("span",{style:de},"Start label"),e.createElement(I,{className:"mb-3",defaultValue:t.start_label??"",onBlur:ce(t,"start_label",u),"data-flow-start-label":!0})),e.createElement("div",{style:{marginTop:16}},e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.definition_url,"data-definition":!0},"Definition"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.details_url,"data-details":!0},"Edit details"))),pe=ir;var lr=({variant:t="neutral",className:o,children:s,...r})=>e.createElement("span",{...r,className:A("ks-badge",`ks-badge-${t}`,o)},s),me=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:t,count:o})=>t?e.createElement("span",{className:"ks-tab-count"},o):e.createElement(me,{variant:"info"},o),fr=t=>typeof t=="string"?t!=="":t>0,gr=({tabs:t,value:o,onChange:s,align:r="center",shape:n,className:a})=>e.createElement("div",{className:a},e.createElement("div",{className:A(dr[r],cr[n])},t.map(p=>e.createElement("button",{key:p.value,type:"button",className:n?mr:pr,"data-active":p.value===o?"":void 0,onClick:()=>s(p.value)},p.label,fr(p.count)&&e.createElement(e.Fragment,null," ",e.createElement(ur,{shape:n,count:p.count}))))),t.find(p=>p.value===o)?.content),ue=gr;var hr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},fe="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",xr="max-sm:absolute max-sm:inset-0 max-sm:z-20",xe={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},ge={display:"flex",gap:8,textAlign:"left"},he={flexShrink:0,whiteSpace:"nowrap"},yr=({check:t,onSelect:o})=>{let s=e.createElement(e.Fragment,null,e.createElement("span",{className:hr[t.level],style:{...he,fontWeight:500}},t.level),t.node&&e.createElement("span",{className:"font-mono",style:he},t.node),e.createElement("span",null,t.sentence));return t.node?e.createElement("button",{type:"button","data-check-row":!0,"data-step-id":t.node,style:{...ge,border:"none",background:"none",padding:0,cursor:"pointer",font:"inherit",color:"inherit"},onClick:()=>o(t.node)},s):e.createElement("div",{"data-check-row":!0,style:ge},s)},br=({checks:t,onSelect:o})=>e.createElement("div",{style:xe},t.map((s,r)=>e.createElement(yr,{key:r,check:s,onSelect:o}))),vr=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,wr=({checks:t,tabs:o,onSelect:s,opened:r=vr()?null:"validation"})=>{let[n,a]=E(r);return e.createElement(D,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${fe} ${xr}`:fe},e.createElement(ue,{align:"start",shape:"underline",value:n,onChange:p=>a(p===n?null:p),tabs:[{value:"validation",label:"Validation",count:t.filter(p=>p.level==="error").length,content:e.createElement(br,{checks:t,onSelect:s})},...o.map(p=>({value:p.label,label:p.label,count:p.count??"",content:e.createElement("div",{"data-drawer-content":!0,style:xe,dangerouslySetInnerHTML:{__html:p.content}})}))]}))},ye=wr;var be={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},ve=t=>({opacity:t?1:0,transition:"opacity .12s"}),kr=({link:t,onInsert:o,onRemove:s,onDrop:r,dragging:n,alwaysShowInsertButtons:a})=>{let[p,c]=E(!1),l=p||n;return e.createElement("div",{"data-connector":`${t.source}-${t.target}`,style:{position:"absolute",left:t.midX-34,top:t.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onDragEnter:()=>c(!0),onDragLeave:()=>c(!1),onDragOver:m=>{m.preventDefault(),m.dataTransfer.dropEffect="move"},onDrop:m=>{m.preventDefault(),c(!1),r()}},e.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},e.createElement(w,{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&&p),style:{...be,...ve(l||a)}},"+"),!n&&e.createElement(w,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...be,...ve(l)}},"\xD7")))},we=kr;var Sr=({links:t,extent:o,dragging:s,onInsert:r,onRemove:n,onDrop:a,alwaysShowInsertButtons:p})=>e.createElement(e.Fragment,null,e.createElement("svg",{width:o.width,height:o.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},e.createElement("defs",null,e.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},e.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),t.map(c=>e.createElement("path",{key:c.id,"data-link":c.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:c.path}))),t.filter(c=>c.label).map(c=>e.createElement("div",{key:`${c.id}-label`,"data-link-label":c.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:c.midX+(p?2:-10),top:c.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},c.label)),t.filter(c=>!c.placeholder).map(c=>e.createElement(we,{key:c.id,link:c,dragging:!!s,alwaysShowInsertButtons:p,onInsert:()=>r(c),onRemove:()=>n(c),onDrop:()=>a(c)}))),ke=Sr;var bt={width:22,height:22,padding:0,fontSize:14,lineHeight:"14px"},Se="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Cr={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:2,height:"100%"},Nr=({link:t,onInsert:o,onRemove:s,onDrop:r,alwaysShowInsertButtons:n,dragging:a,shown:p=!1,className:c="",style:l,children:m})=>e.createElement("div",{"data-joint":t?.id,className:`group ${c}`.trim(),style:l,onMouseEnter:u=>{u.currentTarget.dataset.over="true"},onMouseLeave:u=>{delete u.currentTarget.dataset.over},onDragOver:u=>{t&&r&&(u.preventDefault(),u.dataTransfer.dropEffect="move")},onDrop:u=>{t&&(u.preventDefault(),r(t))}},m,t&&o&&e.createElement("div",{style:Cr},e.createElement(w,{variant:"secondary",title:"Insert a step here",onClick:u=>o(t,u),className:`rounded-full ${n?"opacity-100":Se}`,style:a?{...bt,opacity:1}:bt},"+"),e.createElement(w,{variant:"danger",title:"Remove this connection",onClick:()=>s(t),className:`rounded-full ${p?"opacity-100":Se}`,style:bt},"\xD7"))),it=Nr;var Er=(t,o)=>{let s=new Map(t.map(p=>[p,0])),r=new Map(t.map(p=>[p,[]])),n=new Map(t.map(p=>[p,0]));o.forEach(p=>{r.get(p.source).push(p.target),n.set(p.target,n.get(p.target)+1)});let a=t.filter(p=>n.get(p)===0);for(let p=0;p<a.length;p++){let c=a[p];r.get(c).forEach(l=>{s.set(l,Math.max(s.get(l),s.get(c)+1)),n.set(l,n.get(l)-1),n.get(l)===0&&a.push(l)})}return s},wt=(t,o)=>{let s=new Map(t.map(r=>[r,[]]));return o.forEach(r=>s.get(r.source).push(r)),s},_r=(t,o)=>{let s=wt(t,o),r=new Set(o.map(c=>c.target)),n=new Map,a=new Set,p=c=>{let l=[[c,0]];for(n.set(c,"open");l.length>0;){let m=l[l.length-1],u=s.get(m[0])[m[1]++];u?n.get(u.target)==="open"?a.add(u):n.has(u.target)||(n.set(u.target,"open"),l.push([u.target,0])):(n.set(m[0],"done"),l.pop())}};return t.filter(c=>!r.has(c)).forEach(p),t.forEach(c=>{n.has(c)||p(c)}),a},Ar=(t,o,s)=>{let r=[];t.forEach(l=>{var m;return(r[m=s.get(l)]||(r[m]=[])).push(l)});let n=wt(t,o),a=new Map;n.forEach(l=>l.forEach((m,u)=>a.set(m,(u+1)/(l.length+1))));let p=new Map(t.map(l=>[l,[]]));o.forEach(l=>p.get(l.target).push(l));let c=new Map;return r.forEach(l=>{let m=new Map(l.map(u=>{let x=p.get(u),h=x.reduce((d,f)=>d+c.get(f.source)+a.get(f),0);return[u,x.length>0?h/x.length:1/0]}));l.sort((u,x)=>m.get(u)===m.get(x)?0:m.get(u)<m.get(x)?-1:1),l.forEach((u,x)=>c.set(u,x))}),c};var vt=(t,o,s)=>{let r=[];return t.forEach((n,a)=>{r[a]=a===0?s:r[a-1]+t[a-1]+o}),r},zr=(t,o)=>t.length>0?t[t.length-1]+o[o.length-1]:0,Tr=t=>{let o=[t];for(let s=1;s*2<=t.length;s*=2){let r=o[o.length-1];o.push(r.slice(0,t.length-s*2+1).map((n,a)=>Math.max(n,r[a+s])))}return(s,r)=>{let n=Math.floor(Math.log2(r-s+1));return Math.max(o[n][s],o[n][r-(1<<n)+1])}},Ce=(t,o,s,r)=>{let n=_r(t,o),a=o.filter(g=>!n.has(g)),p=Er(t,a),c=Ar(t,a,p),l=[],m=[];t.forEach(g=>{var S;l[p.get(g)]=Math.max(l[p.get(g)]||0,s(g).width),(m[S=p.get(g)]||(m[S]=[]))[c.get(g)]=g});let u=g=>p.get(g.target)>p.get(g.source)+1,x=g=>{let S=new Map;return g.forEach(M=>{S.has(M.target)||S.set(M.target,S.size)}),S},h=x(o.filter(g=>n.has(g))),d=x(a.filter(u)),f=vt(l,64,r.left),_=r.top+h.size*14,v=new Map,C=m.map(g=>{let S=g.map(M=>s(M).height);return vt(S,24,_).forEach((M,W)=>v.set(g[W],M)),zr(vt(S,24,_),S)}),k=Tr(C),N=Object.fromEntries(t.map(g=>[g,{column:p.get(g),row:c.get(g),x:f[p.get(g)],y:v.get(g),width:s(g).width,height:s(g).height}])),O=new Map;a.filter(u).forEach(g=>O.set(g.target,Math.max(O.get(g.target)||0,k(p.get(g.source)+1,p.get(g.target)-1))));let b=g=>n.has(g)?r.top+(h.size-1-h.get(g.target))*14:u(g)?O.get(g.target)+(d.get(g.target)+1)*14:null,B=g=>N[g].y+(s(g).arrives??N[g].height/2),T=g=>b(g)??B(g.target),H=new Map;wt(t,o).forEach(g=>[...g].sort((S,M)=>T(S)-T(M)).forEach((S,M)=>H.set(S,(M+1)/(g.length+1))));let pt=g=>{let S=N[g.source],M=N[g.target],W=S.y+S.height*H.get(g),U=B(g.target),X=f[S.column]+l[S.column]+40,V=b(g),Q=[[S.x+S.width,W],[X,W]],F=[[M.x-64+40,U],[M.x,U]];return{...g.drawn,points:V===null?[...Q,[X,U],F[1]]:[...Q,[X,V],[F[0][0],V],...F]}},K=o.map(pt),Z=[...Object.values(N).map(g=>[g.x+g.width,g.y+g.height]),...K.flatMap(g=>g.points)].reduce(([g,S],[M,W])=>[Math.max(g,M),Math.max(S,W)],[0,0]);return{places:N,links:K,width:Z[0]+r.right,height:Z[1]+r.bottom}},J="\0entry";var Mr={left:44,top:40,right:20,bottom:40},Or={left:0,top:8,right:16,bottom:12},lt=(t,o,{heights:s={}}={})=>{let r=new Set(t.map(d=>d.id)),n=new Map(t.flatMap(d=>(d.holds||[]).filter(f=>r.has(f)).map(f=>[f,d.id]))),a=new Map([[null,{ids:[],edges:[]}]]);t.filter(d=>d.holds).forEach(d=>a.set(d.id,{ids:[J],edges:[]})),t.forEach(d=>a.get(n.get(d.id)??null).ids.push(d.id)),o.filter(d=>r.has(d.source)&&r.has(d.target)).forEach(d=>{let f=n.get(d.target);f&&f===d.source?a.get(f).edges.push({source:J,target:d.target,drawn:d}):f&&f===n.get(d.source)?a.get(f).edges.push({source:d.source,target:d.target,drawn:d}):a.get(null).edges.push({source:n.get(d.source)??d.source,target:f??d.target,drawn:d})});let p=d=>({width:184,height:s[d]||64}),c=new Map([...a].filter(([d])=>d).map(([d,f])=>[d,Ce(f.ids,f.edges,_=>_===J?{width:0,height:64}:p(_),Or)])),l=d=>s[d]||24,m=d=>{let f=c.get(d);return f?{width:f.width,height:l(d)+f.height,arrives:l(d)+f.places[J].y+64/2}:p(d)},u=Ce(a.get(null).ids,a.get(null).edges,m,Mr),x={...u.places},h=[...u.links];return c.forEach((d,f)=>{let _=u.places[f],[v,C]=[_.x,_.y+l(f)];Object.entries(d.places).filter(([k])=>k!==J).forEach(([k,N])=>{x[k]={...N,x:N.x+v,y:N.y+C}}),d.links.forEach(k=>h.push({...k,points:k.points.map(([N,O])=>[N+v,O+C])}))}),{places:x,links:h,width:u.width,height:u.height}};var Br={display:"flex",flexDirection:"column",gap:14,padding:"64px 16px 24px"},Dr={display:"flex",flexDirection:"column",gap:10,padding:"8px 10px",borderRadius:8},Lr={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,minHeight:26,paddingLeft:12,fontSize:11},Pr=t=>(o,s)=>t[o.id].column-t[s.id].column||t[o.id].row-t[s.id].row,Ir=t=>t?.placeholder?"nowhere yet":t?.label,$r=({node:t,leaving:o,named:s,draw:r,joints:n})=>e.createElement("div",{"data-step-row":t.id},r(t),o.map(a=>e.createElement(it,{key:a.id,link:a,...n,alwaysShowInsertButtons:!0,shown:!0,className:"border-l border-gray-300 text-gray-500 dark:border-zinc-600 dark:text-gray-400",style:Lr},e.createElement("span",null,[a.label,"\u2192",s.get(a.target)].filter(Boolean).join(" "))))),Hr=({nodes:t,edges:o,draw:s,joints:r,children:n,style:a})=>{let{places:p}=lt(t,o),c=new Map(t.map(d=>[d.id,Ir(d)])),l=new Map(t.map(d=>[d.id,[]]));o.forEach(d=>{l.has(d.source)&&c.has(d.target)&&l.get(d.source).push(d)});let m=new Map(t.flatMap(d=>(d.holds||[]).map(f=>[f,d.id]))),u=[...t].sort(Pr(p)),x=new Map;u.filter(d=>m.has(d.id)).forEach(d=>{x.has(m.get(d.id))||x.set(m.get(d.id),[]),x.get(m.get(d.id)).push(d)});let h=d=>e.createElement($r,{key:d.id,node:d,leaving:l.get(d.id),named:c,draw:s,joints:r});return e.createElement("div",{"data-flow-rows":!0,style:{...Br,...a}},n,u.filter(d=>!m.has(d.id)).map(d=>d.holds?e.createElement("div",{key:d.id,"data-group-box":d.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:Dr},h(d),(x.get(d.id)||[]).map(h)):h(d)))},Ne=Hr;var Wr={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:14,padding:"64px 0 0"},jr={position:"absolute",zIndex:3,maxWidth:56,fontSize:10,lineHeight:"13px",pointerEvents:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Gr=t=>t.map(([o,s],r)=>`${r===0?"M":"L"} ${o} ${s}`).join(" "),Vr=t=>Object.fromEntries(Object.entries(t).filter(([,o])=>o?.firstElementChild).map(([o,s])=>[o,s.firstElementChild.offsetHeight])),Fr=(t,o)=>Object.keys(o).some(s=>t[s]!==o[s]),Ur=({nodes:t,edges:o,draw:s,joints:r})=>{let[n,a]=E({}),p=Y({}),c=P(()=>lt(t,o,{heights:n}),[t,o,n]);R(()=>{let m=Vr(p.current);Fr(n,m)&&a({...n,...m})});let l=m=>u=>{p.current[m]=u};return e.createElement("div",{"data-flow-graph":!0,style:{position:"relative",flex:"none",width:c.width,height:c.height}},e.createElement("svg",{width:c.width,height:c.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("defs",null,e.createElement("marker",{id:"easy_flow-graph-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},e.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),c.links.map(m=>e.createElement("path",{key:m.id,"data-link":m.id,d:Gr(m.points),fill:"none",strokeWidth:"1.5",className:"stroke-gray-400 dark:stroke-zinc-500",markerEnd:"url(#easy_flow-graph-arrow)"}))),t.map(m=>{let u=c.places[m.id];return m.holds?e.createElement("div",{key:m.id,ref:l(m.id),"data-group-box":m.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",left:u.x,top:u.y,width:u.width,height:u.height,boxSizing:"border-box",borderRadius:8}},e.createElement("div",{style:{padding:"4px 10px"}},s(m))):e.createElement("div",{key:m.id,ref:l(m.id),style:{position:"absolute",left:u.x,top:u.y,width:u.width,zIndex:2}},s(m))}),c.links.filter(m=>m.label).map(m=>e.createElement("div",{key:`${m.id}-label`,"data-link-label":m.id,title:m.label,className:"text-gray-500 dark:text-gray-400",style:{...jr,left:m.points[0][0]+6,top:m.points[0][1]-14}},m.label)),r.onInsert&&c.links.filter(m=>!m.placeholder).map(m=>e.createElement(it,{key:m.id,link:m,...r,style:{position:"absolute",left:m.points[0][0],top:m.points[0][1]-12,width:62,height:24,zIndex:3}})))},_e="(min-width: 640px)",Xr=()=>typeof window>"u"||!window.matchMedia||window.matchMedia(_e).matches,Yr=()=>{let[t,o]=E(Xr);return L(()=>{if(!window.matchMedia)return;let s=window.matchMedia(_e),r=()=>o(s.matches);return s.addEventListener("change",r),()=>s.removeEventListener("change",r)},[]),t},qr=({nodes:t,edges:o,draw:s,joints:r,children:n,style:a})=>Yr()?e.createElement("div",{"data-flow-rows":!0,style:{...Wr,...a}},n,e.createElement(Ur,{nodes:t,edges:o,draw:s,joints:r})):e.createElement(Ne,{nodes:t,edges:o,draw:s,joints:r,style:a},n),dt=qr;var ze="Your change was not saved because the server could not be reached.",Jr="Your change was saved, but the canvas could not be refreshed. Reload the page to see it.",Ae=async({base:t,fetch:o,onFlow:s,onError:r})=>{let n=await o(t+".json",{headers:{Accept:"application/json"}}).catch(()=>null),a=n?.ok?await n.json().catch(()=>null):null;return a?s(a):r(Jr)},Te=({base:t,token:o,fetch:s,onFlow:r,onError:n,onNotice:a,onWarning:p=()=>{}})=>async(c,l,m)=>{let u={base:t,fetch:s,onFlow:r,onError:n},x=await s(t+c,{method:l,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:m&&JSON.stringify(m)}).catch(()=>null);if(!x)return a(null),n(ze);let h=await x.json().catch(()=>({}));return h.unconnected?(a(null),n(null),p({path:c,steps:h.unconnected}),Ae(u)):(p(null),x.ok?(n(null),a(h.notice||null),Ae(u)):(a(null),n(h.error||"That change was refused")))},Me=({base:t,token:o,fetch:s,onError:r})=>async n=>{let a=new FormData;a.append("picture",n);let p=await s(t+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:a}).catch(()=>null);if(!p)return r(ze),null;let c=await p.json().catch(()=>({}));return p.ok?(r(null),c):(r(c.error||"That picture was refused"),null)};var Kr=(t,o,s)=>{let[r,n]=E(s),[a,p]=E(null),[c,l]=E(null),[m,u]=E(null),x=P(()=>Te({base:t,token:o,fetch:(...d)=>window.fetch(...d),onFlow:n,onError:p,onNotice:l,onWarning:u}),[t,o]),h=P(()=>Me({base:t,token:o,fetch:(...d)=>window.fetch(...d),onError:p}),[t,o]);return{flow:r,error:a,notice:c,warning:m,setWarning:u,send:x,pickPicture:h}},Oe=Kr;var ct=(t,o,s,r)=>{let n=t.left-s.left+r.scrollLeft,a=t.top-s.top+r.scrollTop;return o==="left"?{x:n,y:a+t.height/2}:o==="right"?{x:n+t.width,y:a+t.height/2}:o==="top"?{x:n+t.width/2,y:a}:{x:n+t.width/2,y:a+t.height}},Zr=(t,o,s)=>s&&o==="top"?{x:t.x,y:s.top}:t,Qr=(t,o)=>o==="top"?{x:t.x,y:t.y-3}:o==="left"?{x:t.x-3,y:t.y}:o==="right"?{x:t.x+3,y:t.y}:{x:t.x,y:t.y+3},Rr=(t,o,s,r,n)=>{let a={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}`}[t.route];return{...t,path:a,midX:t.route==="detour"?n:(o.x+s.x)/2,midY:t.route==="lane"?r:(o.y+s.y)/2}},ts=(t,o,s,r)=>{let[n,a]=E([]),[p,c]=E({width:"100%",height:"100%"}),[l,m]=E([]);return R(()=>{let u=()=>{let h=o.current?.getBoundingClientRect();if(!h)return;c({width:o.current.scrollWidth,height:o.current.scrollHeight});let d=t.nodes.filter(f=>f.holds&&!f.loose&&s.current[f.id]).map(f=>{let _=s.current[f.id],v=_.getBoundingClientRect(),C=f.holds.flatMap(N=>s.current[N]?[s.current[N].getBoundingClientRect()]:[]),k=[{left:v.left,top:v.top,width:Math.max(v.width,_.scrollWidth),height:v.height},...C];return{id:f.id,bounds:It(k,h,o.current)}});m(d),a(t.edges.flatMap(f=>{let _=s.current[f.source]?.getBoundingClientRect(),v=s.current[f.target]?.getBoundingClientRect();if(!_||!v)return[];let C=ct(_,f.leaves,h,o.current),k=d.find(B=>B.id===f.target)?.bounds,N=Qr(Zr(ct(v,f.enters,h,o.current),f.enters,k),f.enters),O=(ct(_,"bottom",h,o.current).y+ct(v,"top",h,o.current).y)/2,b=f.leaves==="left"?Math.min(C.x,N.x)-28:Math.max(C.x,N.x)+28;return[Rr(f,C,N,O,b)]}))};u(),window.addEventListener("resize",u);let x=new ResizeObserver(u);return o.current&&x.observe(o.current),()=>{window.removeEventListener("resize",u),x.disconnect()}},r),{links:n,extent:p,boxes:l}},Be=ts;var De=(t,o)=>{let s=new Set(o),r=t,n=2;for(;s.has(r);)r=`${t}_${n++}`;return r};var Le=({send:t,onPress:o})=>s=>{let r=s.target.closest?.("[data-bar-action]");r&&(r.closest("details")?.removeAttribute("open"),o(),r.dataset.barPath&&t(r.dataset.barPath,"POST"))};var os=8,rs={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},ss={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},ns={flex:1,minHeight:0,overflow:"auto",position:"relative"},Ie={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},as={...Ie,position:"static",alignSelf:"flex-start"},is={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},$e={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},ls=({port:t,onCancel:o})=>e.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:$e},"Choose the step \u201C",t||"next","\u201D should lead to \u2014 ",e.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")),ds=({message:t})=>e.createElement("p",{"data-canvas-error":!0,className:"bg-red-50 text-red-800 dark:bg-red-950 dark:text-red-200",style:$e},t),cs=({base:t,token:o,initial:s})=>{let{flow:r,error:n,notice:a,warning:p,setWarning:c,send:l,pickPicture:m}=Oe(t,o,s),[u,x]=E(null),[h,d]=E(null),[f,_]=E(null),[v,C]=E(null),[k,N]=E(null),[O,b]=E(!1),B=Y({}),T=Y(null);L(()=>{let i=Le({send:l,onPress:()=>{x(null),b(!0)}});return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[l]),L(()=>{if(!O){c(null);return}let i=y=>{y.target.isConnected&&!y.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&b(!1)};return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[O]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let H=P(()=>Object.fromEntries(r.nodes.map(i=>[i.id,i])),[r.nodes]),{links:pt,extent:K,boxes:mt}=Be(r,T,B,[r,u,H]),Z=P(()=>{let i={};return r.violations.forEach(y=>{var z;return(i[z=y.node]||(i[z]=[])).push(y)}),i},[r.violations]),g=r.direction==="left_to_right",S=P(()=>r.nodes.filter(i=>!i.loose),[r.nodes]),M=r.nodes.filter(i=>i.loose),W=P(()=>{let i={};return r.edges.forEach(y=>{var z;return(i[z=y.source]||(i[z]=[])).push(y.label||null)}),i},[r.edges]),U=Math.max(0,...S.map(i=>i.row))+1,X=Math.max(0,...S.map(i=>i.column))+1,V=i=>{if(!f)return;let[y,z]=f;_(null),y!==i&&l("/edges","POST",{from:y,to:i,on:z||null})},Q=i=>{if(i.isDefaultPrevented()||!v)return;i.preventDefault();let y=v;C(null);let z=T.current.getBoundingClientRect(),_t=$t(mt,{x:i.clientX-z.left+T.current.scrollLeft,y:i.clientY-z.top+T.current.scrollTop}),Fe=r.nodes.find(Ue=>Ue.holds?.includes(y))?.id||null;_t!==Fe&&l(`/steps/${y}/group`,"PATCH",{group:_t})},F=i=>[...r.palette,...r.unoffered||[]].find(y=>y.type===i?.type),j=r.nodes.find(i=>i.id===u),$=F(j),ut=(i,y={})=>l("/steps","POST",{id:De(i.type,r.nodes.map(z=>z.id)),type:i.type,from:y.from,to:y.to,on:y.on}),kt=i=>{let[y,z]=[k,v];N(null),C(null),y?ut(y,{from:i.source,to:i.target}):z&&l("/steps/"+z+"/move","PATCH",{from:i.source,to:i.target})},St=i=>{let y=T.current.getBoundingClientRect();return{x:i.clientX-y.left+T.current.scrollLeft+8,y:i.clientY-y.top+T.current.scrollTop+8}},Ct=(i,y)=>({node:{...i,ref:z=>{B.current[i.id]=z},violations:Z[i.id]||[],connected:y},selected:i.id===u,armed:f&&f[0]===i.id?f[1]:null,connecting:!!f&&f[0]!==i.id,onSelect:()=>f?V(i.id):x(i.id),onOpen:z=>window.location.assign(z),onDragStart:()=>C(i.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes,compact:g}),Nt=i=>e.createElement(e.Fragment,null,i.placeholder&&e.createElement(te,{node:{...i,ref:y=>{B.current[i.id]=y}},dragging:!!v,compact:g,onFill:()=>d({from:i.from,on:i.on,at:{x:16,y:52}}),onDrop:()=>{let y=v;C(null),y&&l("/edges","POST",{from:i.from,to:y,on:i.on})}}),i.holds&&e.createElement(et,{node:{...i,ref:y=>{B.current[i.id]=y}},header:ot(i,F(i),r.hide_step_type_codes),compact:g,onSelect:()=>f?V(i.id):x(i.id)}),!i.placeholder&&!i.holds&&e.createElement(gt,{...Ct(i,W[i.id]||[]),onArm:(y,z)=>d({from:i.id,on:y,at:St(z)})})),Et=M.length>0&&e.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:g?as:Ie},e.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"),M.map(i=>e.createElement("div",{key:i.id,style:{marginBottom:8}},e.createElement(gt,{...Ct(i,[]),onArm:(y,z)=>{z.stopPropagation(),_([i.id,y])}}))));return e.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:rs,onMouseUp:()=>C(null),onKeyDown:i=>{i.key==="Escape"&&(x(null),_(null),d(null))},tabIndex:-1},e.createElement(oe,{entries:r.palette,groups:r.step_groups||{},onPick:i=>ut(i),onCarry:N,onDrop:()=>N(null)}),e.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:ss},e.createElement("div",{ref:T,style:ns,onClick:i=>{i.target===T.current&&(x(null),_(null),b(!1))},onDragOver:i=>{v&&i.preventDefault()},onDrop:Q},f&&e.createElement(ls,{port:f[1],onCancel:()=>_(null)}),n&&!O&&!j&&e.createElement(ds,{message:n}),e.createElement(se,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>d({at:{x:16,y:52}}),onUndo:()=>{x(null),l("/undo","POST")},onRedo:()=>{x(null),l("/redo","POST")}}),!g&&mt.map(i=>e.createElement(Pt,{key:i.id,id:i.id,bounds:i.bounds,onDrop:()=>{let y=v;C(null),y&&l(`/steps/${y}/group`,"PATCH",{group:i.id})}})),!g&&e.createElement(ke,{links:Ht(pt,r.nodes),extent:K,dragging:v||k,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:i=>d({from:i.source,to:i.target,at:{x:i.midX+30,y:i.midY}}),onRemove:i=>{x(null),l("/edges","DELETE",{from:i.source,to:i.target})},onDrop:kt}),!g&&Et,g&&e.createElement(dt,{nodes:S,edges:r.edges,draw:Nt,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(v||k),onInsert:(i,y)=>d({from:i.source,to:i.target,at:St(y)}),onRemove:i=>{x(null),l("/edges","DELETE",{from:i.source,to:i.target})},onDrop:kt}},Et),!g&&e.createElement("div",{style:{...is,gridTemplateColumns:`repeat(${X+1}, ${280/2}px)`,gridTemplateRows:`repeat(${U}, auto)`}},S.map(i=>e.createElement("div",{key:i.id,style:{gridRow:i.row+1,gridColumn:`${i.column+1} / span 2`,zIndex:2,marginTop:Wt(i,r.nodes)?os-64:0}},Nt(i)))),h&&e.createElement(ee,{entries:r.palette,at:h.at,onDismiss:()=>d(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:h.on!==void 0?()=>{_([h.from,h.on]),d(null)}:null,onPick:i=>{let y=h;d(null),ut(i,y)}})),e.createElement(ye,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:x})),O&&!j&&e.createElement(pe,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:a,publishNote:r.publish_note,warning:p,onClose:()=>b(!1),onCreate:()=>l("/versions","POST"),onPublish:()=>l("/publish","POST"),onAccept:()=>l(p.path,"POST",{remove_unconnected:p.steps.map(i=>i.id)}),onDecline:()=>c(null),onSaveDetails:i=>l("/details","PATCH",{flow:i})}),j&&e.createElement(Rt,{node:j,fields:$?.fields||{},holds:$?.records||{},labels:$?.labels||{},explanations:$?.explanations||{},recordLabels:$?.record_labels||{},recordExplanations:$?.record_explanations||{},recordChoices:$?.record_choices||{},recordOutputsOf:$?.record_outputs_of||{},choices:jt(j,$),onClose:()=>x(null),onSave:i=>l(`/steps/${j.id}`,"PATCH",{config:i}),onPickPicture:m,refusal:n,notice:a,onDelete:()=>{x(null),l(`/steps/${j.id}`,"DELETE")}}))},He=cs;var ps={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},ms={fontSize:12,fontWeight:500,lineHeight:1.3},We={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"},je={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"},us="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",fs=({node:t,selected:o=!1})=>{let s=t.address?"a":"div";return e.createElement(s,{"data-step":t.id,href:t.address||void 0,className:`${t.state==="paused"?"border-2":"border"} ${We[t.state]||We.pending}${o?` ${us}`:""}`,style:ps},e.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.type),e.createElement("div",{style:ms},t.label,t.version&&e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},t.version)),t.status&&e.createElement("div",{className:je[t.state]||je.pending,style:{fontSize:11}},t.status))},Ge=fs;var gs={gap:12,padding:0,maxWidth:"100%",overflowX:"auto"},hs=({nodes:t,edges:o,selected:s})=>e.createElement(dt,{nodes:t,edges:o,joints:{},style:gs,draw:r=>r.holds?e.createElement(et,{node:r,header:ot(r,r,!1),compact:!0}):e.createElement(Ge,{node:r,selected:r.id===s})}),Ve=hs;ft("easy_flow/flow-editor",He);ft("easy_flow/run-view",Ve);document.addEventListener("easy_flow:flow-named",t=>{let o=document.querySelector("[data-flow-heading]");o&&(o.textContent=t.detail)});document.addEventListener("easy_flow:flow-status",({detail:t})=>{t.status&&document.querySelectorAll("[data-version-status]").forEach(o=>{o.textContent=t.status}),t.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(o=>{o.textContent=`Publish v${t.publishes}`})});Bt(document,At);})();
1
+ (()=>{var Ye=globalThis.ReactDOM;var{createPortal:xs,createRoot:At,flushSync:ys,hydrateRoot:bs,preconnect:vs,prefetchDNS:ws,preinit:ks,preinitModule:Ss,preload:Cs,preloadModule:Ns,requestFormReset:Es,unstable_batchedUpdates:_s,useFormState:As,useFormStatus:zs,version:Ts}=Ye;var zt=globalThis.React,e=zt,{Children:Os,Component:Bs,Fragment:Ds,PureComponent:Ls,StrictMode:Ps,Suspense:Is,cloneElement:$s,createContext:Hs,createElement:Ws,createRef:js,forwardRef:Gs,isValidElement:Vs,lazy:Fs,memo:Us,startTransition:Xs,useCallback:Ys,useContext:qs,useDebugValue:Js,useDeferredValue:Ks,useEffect:L,useId:Zs,useImperativeHandle:Qs,useLayoutEffect:R,useMemo:P,useReducer:Rs,useRef:Y,useState:E,useSyncExternalStore:tn,useTransition:en}=zt;var Tt=new Map,tt=new Map,ft=(t,o)=>Tt.set(t,o),Mt=()=>{tt.forEach(t=>t.unmount()),tt.clear()},Ot=(t,o)=>t.querySelectorAll("[data-react-ui]").forEach(s=>{if(tt.has(s))return;let r=Tt.get(s.dataset.reactUi),n=o(s);tt.set(s,n),n.render(e.createElement(r,JSON.parse(s.dataset.props)))});var Bt=(t,o)=>{let s=()=>Ot(t,o);t.addEventListener("turbo:load",s),t.addEventListener("turbo:frame-load",s),t.addEventListener("turbo:before-cache",Mt),t.readyState==="loading"?t.addEventListener("DOMContentLoaded",s):s()};var A=(...t)=>t.filter(Boolean).join(" ");var qe={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},Je={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Ke=({variant:t="primary",size:o="md",className:s,children:r,...n})=>{let a=n.href?"a":"button";return e.createElement(a,{...n,className:A("ks-button",qe[t],Je[o],s)},r)},w=Ke;var Ze="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Qe="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Re="border border-accent-600 bg-accent-600 text-white",to=({name:t,connected:o,armed:s,onArm:r,connecting:n})=>e.createElement("button",{onClick:a=>{n||(a.stopPropagation(),r(a))},title:s?"Now choose a step to connect to":"Connect this branch",className:s?Re:o?Qe:Ze,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},t||"next"),Dt=to;var eo={width:240,boxSizing:"border-box",borderRadius:8},oo={minWidth:120,boxSizing:"border-box",borderRadius:6},ro={padding:"8px 14px",textAlign:"center",fontWeight:600},so={fontWeight:600,lineHeight:1.3},no={fontSize:12,fontWeight:500,lineHeight:1.3},ao=(t,o,s)=>{let r=s?"ring-4 ring-accent-600/15":"shadow-sm";return t||s&&!o?`border-accent-600 ${r}`:o?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},io=(t,o)=>o&&t.label===t.id&&t.type_name||t.label,lo=(t,o,s)=>s?o===t.type_name?null:t.type_name:t.type,co=({node:t,selected:o,armed:s,connecting:r,onSelect:n,onOpen:a,onArm:p,onDragEnd:c,onDragStart:l,hideStepTypeCodes:m,compact:u=!1,typeAbove:x=u})=>{let h=t.begins_here||t.ends_here,d=t.begins_here,f=t.ends_here?[]:t.ports,_=r&&!d,v=io(t,m),C=lo(t,v,m);return e.createElement("div",{ref:t.ref,"data-step":t.id,draggable:!d,onDragStart:k=>{k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("text/plain",t.id),l()},onDragEnd:c,onClick:t.opens&&!r?()=>a(t.opens):n,className:`bg-white ${u&&!o?"border":"border-2"} dark:bg-zinc-900 ${ao(_,t.violations.length>0,o)}`,style:{...u?oo:eo,padding:h?0:u?"8px 10px":"12px 14px",cursor:d?"default":r?"crosshair":"grab"}},!h&&x&&C&&e.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},C),h&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:ro},v),!h&&e.createElement("div",{style:u?no:so},v),t.violations.length>0&&e.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${t.violations.length} error${t.violations.length===1?"":"s"}`),!h&&t.summary&&t.violations.length===0&&e.createElement("div",{className:o?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},t.summary),!h&&!x&&C&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},C),t.picture_url&&e.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),t.starts_a_flow&&e.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),t.opens&&e.createElement(w,{variant:"secondary",size:"sm",className:"mt-2",onClick:k=>{k.stopPropagation(),n()}},"Settings"),f.length>0&&e.createElement("div",{style:{padding:t.begins_here?"0 14px 8px":"10px 0 0"}},f.map(k=>e.createElement(Dt,{key:k,name:k,connected:t.connected.includes(k),connecting:r,armed:s===k,onArm:N=>p(k,N)}))))},gt=co;var Lt={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},po={...Lt,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},mo=({node:t,header:o,onSelect:s,compact:r=!1})=>e.createElement("div",{ref:t.ref,"data-group-header":t.id,onClick:s,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?po:Lt,...s?{}:{cursor:"default"}}},o),et=mo;var uo=({id:t,bounds:o,onDrop:s})=>e.createElement("div",{"data-group-box":t,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}}),Pt=uo;var fo=t=>t!=null&&t!==""&&typeof t!="object",go=["integer","float"],ho=(t,o,s)=>s&&o.labels?.[t]||t,ot=(t,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>fo(t.config[n])).map(n=>`${ho(n,o,s)}${go.includes(o.fields[n])?"":":"} ${t.config[n]}`);return[s&&t.type_name||t.type,...r].join(" \xB7 ")};var It=(t,o,s)=>{let r=Math.min(...t.map(c=>c.left))-o.left+s.scrollLeft-12,n=Math.min(...t.map(c=>c.top))-o.top+s.scrollTop-10,a=Math.max(...t.map(c=>c.left+c.width))-o.left+s.scrollLeft+12,p=Math.max(...t.map(c=>c.top+c.height))-o.top+s.scrollTop+10;return{left:r,top:n,width:a-r,height:p-n}},xo=({left:t,top:o,width:s,height:r},n)=>n.x>=t&&n.x<=t+s&&n.y>=o&&n.y<=o+r,$t=(t,o)=>t.find(s=>xo(s.bounds,o))?.id||null,Ht=(t,o)=>t.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),Wt=(t,o)=>o.some(s=>s.holds?.includes(t.id)&&!s.loose&&s.row===t.row-1);var ht=(t,o)=>t.includes(o)?t.filter(s=>s!==o):[...t,o],jt=(t,o)=>({...o?.choices||{},...t?.choices||{}});var yo=({as:t="input",disabled:o,className:s,...r})=>e.createElement(t,{...r,disabled:o,className:A("ks-input",o&&"ks-input-disabled",s)}),I=yo;var bo=t=>e.createElement(I,{...t,as:"select"}),Gt=bo;var vo=({className:t,...o})=>e.createElement("input",{type:"checkbox",...o,className:A("ks-checkbox",t)}),rt=vo;var wo=({name:t,value:o,label:s,hint:r,className:n,...a})=>e.createElement("label",{className:"inline-block cursor-pointer relative"},e.createElement("input",{type:"radio",name:t,value:o,...a,className:A("peer sr-only",n)}),e.createElement("span",{className:"ks-radio-card inline-flex flex-col cursor-pointer transition ks-radio-card-highlight"},e.createElement("span",{className:"ks-radio-card-header flex items-start justify-between"},e.createElement("span",{className:"ks-radio-card-label block"},s)),r!=null&&e.createElement("span",{className:"ks-radio-card-hint block text-sm"},r))),Vt=wo;var ko=({name:t,options:o,value:s,onChange:r,className:n})=>e.createElement("div",{className:A("flex flex-wrap ks-grid-gap-sm",n)},o.map(a=>e.createElement(Vt,{key:a.value,name:t,...a,checked:a.value===s,onChange:()=>r(a.value)}))),Ft=ko;var Ut=t=>(t||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),So=({name:t,type:o,value:s,choices:r,onChange:n,onSettle:a,onPick:p,pictureUrl:c})=>{if(o==="picture")return e.createElement("div",{className:"mb-3"},s&&c&&e.createElement("img",{src:c,alt:"The step's picture",style:{maxWidth:"100%"}}),s&&e.createElement(w,{type:"button",variant:"secondary",size:"sm","data-remove-picture":!0,onClick:()=>a("")},"Remove picture"),e.createElement("input",{type:"file",accept:"image/*",onChange:l=>l.target.files[0]&&p(l.target.files[0])}));if(o==="boolean")return e.createElement(rt,{checked:!!s,onChange:l=>a(l.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return e.createElement(Gt,{className:"mb-3",value:s??"",onChange:l=>a(l.target.value)},e.createElement("option",{value:""}),Ut(r).map(l=>e.createElement("option",{key:l.value,value:l.value},l.label)));if(o==="radio_cards")return e.createElement("div",{"data-radio-cards":!0,className:"mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full"},e.createElement(Ft,{name:t,value:s,options:r||[],onChange:a}));if(o==="multi_select"){let l=Array.isArray(s)?s:[],m=u=>a(ht(l,u));return e.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(r||[]).map(u=>e.createElement("label",{key:u,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(rt,{checked:l.includes(u),onChange:()=>m(u)}),e.createElement("span",null,u))))}if(o==="flows"){let l=Array.isArray(s)?s:[];return e.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},Ut(r).map(m=>e.createElement("label",{key:m.value,style:{display:"inline-flex",alignItems:"center",gap:4}},e.createElement(rt,{checked:l.includes(m.value),onChange:()=>a(ht(l,m.value))}),e.createElement("span",null,m.label))))}return o==="integer"||o==="float"?e.createElement(I,{className:"mb-3",type:"number",step:o==="integer"?"1":"any",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>a(l.target.value)}):e.createElement(I,{className:"mb-3",type:"text",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>a(l.target.value)})},st=So;var Xt=(t,o,s,r)=>t.map((n,a)=>a===o?{...n,[s]:r}:n);var Co=({text:t})=>e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},t),nt=Co;var No=(t,o,s,r)=>{let n=(t||{})[s],a=(o||{})[s];return a?(n||{})[r[a]]:n},Eo=({holds:t,labels:o,explanations:s,rows:r,choices:n,outputsOf:a,onChange:p,onSettle:c})=>{let l=Array.isArray(r)?r:[],m=(u,x,h,d)=>{let f=Xt(l,u,x,h);d?c(f):p(f)};return e.createElement("div",{style:{marginBottom:12}},l.map((u,x)=>e.createElement("div",{key:x,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(t).map(([h,d])=>e.createElement("label",{key:h,style:{display:"block"}},e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[h]||h),e.createElement(st,{type:d,value:u[h],choices:No(n,a,h,u),onChange:f=>m(x,h,f,!1),onSettle:f=>m(x,h,f,!0)}),(s||{})[h]&&e.createElement(nt,{text:s[h]}))),e.createElement(w,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>c(l.filter((h,d)=>d!==x))},"Remove"))),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>c([...l,{}])},"Add"))},Yt=Eo;var _o={start:null,end:"ks-value-list-end"},Ao="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",zo="flex flex-col min-w-0",To="ks-value-list-label basis-auto text-xs",Mo=()=>e.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"},e.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"})),Oo=({value:t,fallback:o})=>String(t??"")===""?o:t,Bo=({rows:t,align:o="start",columns:s=!1,className:r})=>e.createElement("dl",{className:A("ks-value-list",_o[o],s&&Ao,r)},t.map((n,a)=>e.createElement("div",{key:a,className:A(s?zo:"ks-value-list-row",n.total&&"ks-value-list-total")},e.createElement("dt",{className:s?To:"ks-value-list-label"},n.label,n.note!=null&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"ks-value-list-note"},n.note))),e.createElement("dd",{className:"ks-value-list-value"},Oo(n),n.right&&e.createElement(e.Fragment,null," ",e.createElement(Mo,null)))))),qt=Bo;var Do=()=>e.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"},e.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})),Lo=({summary:t,open:o=!1,className:s,children:r})=>e.createElement("details",{className:A("ks-disclosure group",s),open:o},e.createElement("summary",{className:"ks-disclosure-summary flex cursor-pointer list-none items-center justify-between [&::-webkit-details-marker]:hidden"},e.createElement("span",null,t),e.createElement("span",{className:"ks-disclosure-icon h-4 w-4 shrink-0 transition-transform group-open:rotate-180"},e.createElement(Do,null))),e.createElement("div",{className:"ks-disclosure-body text-sm"},r)),Jt=Lo;var Po=({language:t,caption:o,className:s,children:r})=>e.createElement("div",{className:A("ks-code overflow-hidden",s)},o!=null&&e.createElement("div",{className:"ks-code-caption font-mono text-xs"},o),e.createElement("pre",{className:"ks-code-block overflow-x-auto font-mono text-sm leading-relaxed"},e.createElement("code",{className:t==null?"":`language-${t}`},r))),Kt=Po;var xt="flex flex-col gap-1 mb-3",Zt="[&_dd]:font-mono",Io="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",$o="[&_.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]",Ho="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]",Wo=t=>t.values?t.columns?`${xt} ${Zt} ${Io}`:`${xt} ${Zt} ${$o}`:`${xt} ${Ho}`,jo=({details:t})=>e.createElement(e.Fragment,null,t.map((o,s)=>e.createElement("section",{key:s,className:Wo(o)},o.heading&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400"},o.heading),o.values&&e.createElement(qt,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>e.createElement(Jt,{key:r.summary,summary:r.summary},e.createElement(Kt,null,r.code)))))),Qt=jo;var Go=({as:t="div",className:o,children:s,...r})=>e.createElement(t,{...r,className:A("ks-panel",o)},s),D=Go;var at=(t,o)=>({className:s,children:r,...n})=>e.createElement(t,{...n,className:A(o,s)},r),q=at("label","ks-label"),Na=at("p","ks-hint"),Ea=at("p","ks-error"),_a=at("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:t,fields:o,holds:s,labels:r,explanations:n,recordLabels:a,recordExplanations:p,recordChoices:c,recordOutputsOf:l,choices:m,onSave:u,onDelete:x,onClose:h,onPickPicture:d,refusal:f,notice:_})=>{let[v,C]=E(t.config),[k,N]=E(t.picture_url);L(()=>N(t.picture_url),[t.id,t.picture_url]),L(()=>C(t.config),[t.id,t.config]);let O=b=>{C(b),JSON.stringify(b)!==JSON.stringify(t.config)&&u(b)};return e.createElement(D,{as:"aside",style:Vo,className:"max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto","data-inspector":!0},e.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8,marginBottom:12}},e.createElement("div",null,e.createElement("p",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.id," \xB7 ",t.type),e.createElement("h2",{style:{fontSize:15,fontWeight:600}},t.label)),e.createElement("button",{title:"Close",onClick:h,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),f&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},f),_&&!f&&e.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{fontWeight:600,marginBottom:12},"data-notice":!0},_),Object.entries(o).map(([b,B])=>e.createElement(q,{key:b},e.createElement("span",{style:{display:"block",marginBottom:3}},r[b]||b),B==="list"?e.createElement(Yt,{holds:s[b]||{},labels:a[b]||{},explanations:(p||{})[b],rows:v[b],choices:{...(c||{})[b],...(t.record_choices||{})[b]},outputsOf:(l||{})[b],onChange:T=>C({...v,[b]:T}),onSettle:T=>O({...v,[b]:T})}):e.createElement(st,{name:b,type:B,value:v[b],choices:m[b],pictureUrl:k,onChange:T=>C({...v,[b]:T}),onSettle:T=>O({...v,[b]:T}),onPick:async T=>{let H=await d(T);H&&(N(H.url),O({...v,[b]:H.reference}))}}),(n||{})[b]&&e.createElement(nt,{text:n[b]}))),e.createElement(Qt,{details:t.details||[]}),e.createElement("div",{style:Fo},(t.links||[]).length>0&&e.createElement("div",{style:{display:"flex",gap:8}},t.links.map(b=>e.createElement(w,{key:b.address,variant:"secondary",size:"sm",className:"flex-1",href:b.address},b.label))),e.createElement(w,{variant:"danger",size:"sm",className:"w-full",onClick:x},"Delete step")))},Rt=Uo;var Xo={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"},qo="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",Jo="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Ko=({node:t,dragging:o,onFill:s,onDrop:r,compact:n=!1})=>e.createElement("div",{ref:t.ref,"data-placeholder":t.id,title:`Choose the step \u201C${t.label}\u201D should lead to`,onClick:s,onDragOver:a=>{o&&(a.preventDefault(),a.dataTransfer.dropEffect="move")},onDrop:a=>{a.preventDefault(),r()},className:o?Jo:qo,style:n?Yo:Xo},e.createElement("div",{style:{fontWeight:600}},t.label),e.createElement("div",{style:{fontSize:11}},o?"drop a step here":"leads nowhere yet \u2014 click to choose")),te=Ko;var Zo=({entries:t,at:o,onPick:s,onConnect:r,onDismiss:n,hideStepTypeCodes:a})=>e.createElement(D,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:o.y,left:o.x,width:210,padding:8,borderRadius:8}},e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),t.map(p=>e.createElement(w,{key:p.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>s(p)},p.label,!a&&e.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},p.type))),r&&e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full",onClick:n},"Cancel")),ee=Zo;var Qo=t=>o=>o.label.toLowerCase().includes(t.trim().toLowerCase()),Ro=(t,o,s="")=>{let r=Object.values(o).flat(),n=Object.entries(o).map(([a,p])=>({heading:a,entries:p.map(c=>t.find(l=>l.type===c)).filter(Boolean)}));return[{heading:null,entries:t.filter(a=>!r.includes(a.type))},...n].map(a=>({...a,entries:a.entries.filter(Qo(s))})).filter(a=>a.entries.length>0)},tr={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"},or={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},rr=({entries:t,groups:o,onPick:s,onCarry:r,onDrop:n})=>{let[a,p]=E("");return e.createElement(D,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:tr},e.createElement(I,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:a,onChange:c=>p(c.target.value),style:{marginBottom:6,fontSize:12}}),Ro(t,o,a).map(c=>e.createElement(e.Fragment,{key:c.heading||""},c.heading&&e.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:er},c.heading),c.entries.map(l=>e.createElement(D,{as:"button",type:"button",key:l.type,"data-step-type":l.type,className:"bg-surface-50 dark:bg-surface-950",style:or,draggable:!0,onClick:()=>s(l),onDragStart:m=>{m.dataTransfer.effectAllowed="copyMove",m.dataTransfer.setData("text/plain",l.type),r(l)},onDragEnd:n},l.label)))))},oe=rr;var sr={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},re=({label:t,title:o,idle:s,enabled:r,onUse:n})=>e.createElement(w,{variant:"secondary",size:"sm",title:r?o:s,disabled:!r,onClick:n,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},t),nr=({undoable:t,redoable:o,onAdd:s,onUndo:r,onRedo:n})=>e.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},e.createElement(w,{variant:"secondary",className:"rounded-full",style:sr,title:"Add a step",onClick:s},"+"),e.createElement(re,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:t,onUse:r}),e.createElement(re,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),se=nr;var ar=({type:t="info",title:o,message:s,onDismiss:r,className:n})=>e.createElement("div",{className:A("ks-alert",`ks-alert-${t}`,n),role:"alert"},e.createElement("div",{className:"ks-alert-body"},e.createElement("div",{className:"ks-alert-content"},o&&e.createElement("p",{className:"ks-alert-title"},o),e.createElement("p",{className:o?"ks-alert-message-titled":"ks-alert-message"},s)),r&&e.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),ne=ar;var ae=t=>{let o=t.map(s=>`\u201C${s.name}\u201D`).join(", ");return t.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 ie=({version:t,published:o})=>t?o?o===t?`Version ${t} \xB7 live`:`Version ${t} \xB7 visitors still on ${o}`:`Version ${t} \xB7 never published`:"No version yet";var ir={width:280,padding:20,overflowY:"auto"},le={fontWeight:600,marginBottom:6,marginTop:14},yt={fontSize:12,marginBottom:4,lineHeight:1.4},de={display:"block",marginBottom:3},ce=(t,o,s)=>r=>{r.target.value!==(t[o]??"")&&s({[o]:r.target.value})},lr=({flow:t,changes:o,refusal:s,notice:r,publishNote:n,warning:a,onCreate:p,onPublish:c,onAccept:l,onDecline:m,onSaveDetails:u,onClose:x})=>e.createElement(D,{as:"aside",style:ir,"data-builder-panel":!0},e.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},e.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},t.title||t.slug),e.createElement("button",{title:"Close",onClick:x,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),e.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:t.history_url,"data-history":!0},ie(t)),a?e.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},e.createElement(ne,{type:"warning",className:"mb-1.5",message:ae(a.steps)}),e.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:l,"data-accept-removal":!0},a.path==="/publish"?"Remove and publish":"Remove and create version"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:m,"data-decline-removal":!0},"Cancel")):e.createElement("div",{style:{marginTop:14}},e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:p,"data-create-version":!0},"Create version"),e.createElement(w,{size:"sm",className:"w-full mb-1.5",onClick:c,"data-publish":!0},"Publish"),n&&e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},n)),s&&e.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...yt,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&e.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...yt,fontWeight:600,marginTop:8},"data-notice":!0},r),e.createElement("h2",{style:le},"Changes since the last version"),o.length===0?e.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):o.map((h,d)=>e.createElement("p",{key:d,style:yt,"data-change":!0},h)),e.createElement("h2",{style:le},"Details"),e.createElement(q,null,e.createElement("span",{style:de},"Title"),e.createElement(I,{className:"mb-3",defaultValue:t.title??"",onBlur:ce(t,"title",u),"data-flow-title":!0})),e.createElement(q,null,e.createElement("span",{style:de},"Start label"),e.createElement(I,{className:"mb-3",defaultValue:t.start_label??"",onBlur:ce(t,"start_label",u),"data-flow-start-label":!0})),e.createElement("div",{style:{marginTop:16}},e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.definition_url,"data-definition":!0},"Definition"),e.createElement(w,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.details_url,"data-details":!0},"Edit details"))),pe=lr;var dr=({variant:t="neutral",className:o,children:s,...r})=>e.createElement("span",{...r,className:A("ks-badge",`ks-badge-${t}`,o)},s),me=dr;var cr={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"},pr={pills:"ks-tab-bar-pills",underline:"ks-tab-bar-underline"},mr="ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",ur="ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",fr=({shape:t,count:o})=>t?e.createElement("span",{className:"ks-tab-count"},o):e.createElement(me,{variant:"info"},o),gr=t=>typeof t=="string"?t!=="":t>0,hr=({tabs:t,value:o,onChange:s,align:r="center",shape:n,className:a})=>e.createElement("div",{className:a},e.createElement("div",{className:A(cr[r],pr[n])},t.map(p=>e.createElement("button",{key:p.value,type:"button",className:n?ur:mr,"data-active":p.value===o?"":void 0,onClick:()=>s(p.value)},p.label,gr(p.count)&&e.createElement(e.Fragment,null," ",e.createElement(fr,{shape:n,count:p.count}))))),t.find(p=>p.value===o)?.content),ue=hr;var xr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},fe="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",yr="max-sm:absolute max-sm:inset-0 max-sm:z-20",xe={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},ge={display:"flex",gap:8,textAlign:"left"},he={flexShrink:0,whiteSpace:"nowrap"},br=({check:t,onSelect:o})=>{let s=e.createElement(e.Fragment,null,e.createElement("span",{className:xr[t.level],style:{...he,fontWeight:500}},t.level),t.node&&e.createElement("span",{className:"font-mono",style:he},t.node),e.createElement("span",null,t.sentence));return t.node?e.createElement("button",{type:"button","data-check-row":!0,"data-step-id":t.node,style:{...ge,border:"none",background:"none",padding:0,cursor:"pointer",font:"inherit",color:"inherit"},onClick:()=>o(t.node)},s):e.createElement("div",{"data-check-row":!0,style:ge},s)},vr=({checks:t,onSelect:o})=>e.createElement("div",{style:xe},t.map((s,r)=>e.createElement(br,{key:r,check:s,onSelect:o}))),wr=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,kr=({checks:t,tabs:o,onSelect:s,opened:r=wr()?null:"validation"})=>{let[n,a]=E(r);return e.createElement(D,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${fe} ${yr}`:fe},e.createElement(ue,{align:"start",shape:"underline",value:n,onChange:p=>a(p===n?null:p),tabs:[{value:"validation",label:"Validation",count:t.filter(p=>p.level==="error").length,content:e.createElement(vr,{checks:t,onSelect:s})},...o.map(p=>({value:p.label,label:p.label,count:p.count??"",content:e.createElement("div",{"data-drawer-content":!0,style:xe,dangerouslySetInnerHTML:{__html:p.content}})}))]}))},ye=kr;var be={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},ve=t=>({opacity:t?1:0,transition:"opacity .12s"}),Sr=({link:t,onInsert:o,onRemove:s,onDrop:r,dragging:n,alwaysShowInsertButtons:a})=>{let[p,c]=E(!1),l=p||n;return e.createElement("div",{"data-connector":`${t.source}-${t.target}`,style:{position:"absolute",left:t.midX-34,top:t.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onDragEnter:()=>c(!0),onDragLeave:()=>c(!1),onDragOver:m=>{m.preventDefault(),m.dataTransfer.dropEffect="move"},onDrop:m=>{m.preventDefault(),c(!1),r()}},e.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},e.createElement(w,{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&&p),style:{...be,...ve(l||a)}},"+"),!n&&e.createElement(w,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...be,...ve(l)}},"\xD7")))},we=Sr;var Cr=({links:t,extent:o,dragging:s,onInsert:r,onRemove:n,onDrop:a,alwaysShowInsertButtons:p})=>e.createElement(e.Fragment,null,e.createElement("svg",{width:o.width,height:o.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},e.createElement("defs",null,e.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},e.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),t.map(c=>e.createElement("path",{key:c.id,"data-link":c.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:c.path}))),t.filter(c=>c.label).map(c=>e.createElement("div",{key:`${c.id}-label`,"data-link-label":c.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:c.midX+(p?2:-10),top:c.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},c.label)),t.filter(c=>!c.placeholder).map(c=>e.createElement(we,{key:c.id,link:c,dragging:!!s,alwaysShowInsertButtons:p,onInsert:()=>r(c),onRemove:()=>n(c),onDrop:()=>a(c)}))),ke=Cr;var bt={width:22,height:22,padding:0,fontSize:14,lineHeight:"14px"},Se="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Nr={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:2,height:"100%"},Er=({link:t,onInsert:o,onRemove:s,onDrop:r,alwaysShowInsertButtons:n,dragging:a,shown:p=!1,className:c="",style:l,children:m})=>e.createElement("div",{"data-joint":t?.id,className:`group ${c}`.trim(),style:l,onMouseEnter:u=>{u.currentTarget.dataset.over="true"},onMouseLeave:u=>{delete u.currentTarget.dataset.over},onDragOver:u=>{t&&r&&(u.preventDefault(),u.dataTransfer.dropEffect="move")},onDrop:u=>{t&&(u.preventDefault(),r(t))}},m,t&&o&&e.createElement("div",{style:Nr},e.createElement(w,{variant:"secondary",title:"Insert a step here",onClick:u=>o(t,u),className:`rounded-full ${n?"opacity-100":Se}`,style:a?{...bt,opacity:1}:bt},"+"),e.createElement(w,{variant:"danger",title:"Remove this connection",onClick:()=>s(t),className:`rounded-full ${p?"opacity-100":Se}`,style:bt},"\xD7"))),it=Er;var _r=(t,o)=>{let s=new Map(t.map(p=>[p,0])),r=new Map(t.map(p=>[p,[]])),n=new Map(t.map(p=>[p,0]));o.forEach(p=>{r.get(p.source).push(p.target),n.set(p.target,n.get(p.target)+1)});let a=t.filter(p=>n.get(p)===0);for(let p=0;p<a.length;p++){let c=a[p];r.get(c).forEach(l=>{s.set(l,Math.max(s.get(l),s.get(c)+1)),n.set(l,n.get(l)-1),n.get(l)===0&&a.push(l)})}return s},wt=(t,o)=>{let s=new Map(t.map(r=>[r,[]]));return o.forEach(r=>s.get(r.source).push(r)),s},Ar=(t,o)=>{let s=wt(t,o),r=new Set(o.map(c=>c.target)),n=new Map,a=new Set,p=c=>{let l=[[c,0]];for(n.set(c,"open");l.length>0;){let m=l[l.length-1],u=s.get(m[0])[m[1]++];u?n.get(u.target)==="open"?a.add(u):n.has(u.target)||(n.set(u.target,"open"),l.push([u.target,0])):(n.set(m[0],"done"),l.pop())}};return t.filter(c=>!r.has(c)).forEach(p),t.forEach(c=>{n.has(c)||p(c)}),a},zr=(t,o,s)=>{let r=[];t.forEach(l=>{var m;return(r[m=s.get(l)]||(r[m]=[])).push(l)});let n=wt(t,o),a=new Map;n.forEach(l=>l.forEach((m,u)=>a.set(m,(u+1)/(l.length+1))));let p=new Map(t.map(l=>[l,[]]));o.forEach(l=>p.get(l.target).push(l));let c=new Map;return r.forEach(l=>{let m=new Map(l.map(u=>{let x=p.get(u),h=x.reduce((d,f)=>d+c.get(f.source)+a.get(f),0);return[u,x.length>0?h/x.length:1/0]}));l.sort((u,x)=>m.get(u)===m.get(x)?0:m.get(u)<m.get(x)?-1:1),l.forEach((u,x)=>c.set(u,x))}),c};var vt=(t,o,s)=>{let r=[];return t.forEach((n,a)=>{r[a]=a===0?s:r[a-1]+t[a-1]+o}),r},Tr=(t,o)=>t.length>0?t[t.length-1]+o[o.length-1]:0,Mr=t=>{let o=[t];for(let s=1;s*2<=t.length;s*=2){let r=o[o.length-1];o.push(r.slice(0,t.length-s*2+1).map((n,a)=>Math.max(n,r[a+s])))}return(s,r)=>{let n=Math.floor(Math.log2(r-s+1));return Math.max(o[n][s],o[n][r-(1<<n)+1])}},Ce=(t,o,s,r)=>{let n=Ar(t,o),a=o.filter(g=>!n.has(g)),p=_r(t,a),c=zr(t,a,p),l=[],m=[];t.forEach(g=>{var S;l[p.get(g)]=Math.max(l[p.get(g)]||0,s(g).width),(m[S=p.get(g)]||(m[S]=[]))[c.get(g)]=g});let u=g=>p.get(g.target)>p.get(g.source)+1,x=g=>{let S=new Map;return g.forEach(M=>{S.has(M.target)||S.set(M.target,S.size)}),S},h=x(o.filter(g=>n.has(g))),d=x(a.filter(u)),f=vt(l,64,r.left),_=r.top+h.size*14,v=new Map,C=m.map(g=>{let S=g.map(M=>s(M).height);return vt(S,24,_).forEach((M,W)=>v.set(g[W],M)),Tr(vt(S,24,_),S)}),k=Mr(C),N=Object.fromEntries(t.map(g=>[g,{column:p.get(g),row:c.get(g),x:f[p.get(g)],y:v.get(g),width:s(g).width,height:s(g).height}])),O=new Map;a.filter(u).forEach(g=>O.set(g.target,Math.max(O.get(g.target)||0,k(p.get(g.source)+1,p.get(g.target)-1))));let b=g=>n.has(g)?r.top+(h.size-1-h.get(g.target))*14:u(g)?O.get(g.target)+(d.get(g.target)+1)*14:null,B=g=>N[g].y+(s(g).arrives??N[g].height/2),T=g=>b(g)??B(g.target),H=new Map;wt(t,o).forEach(g=>[...g].sort((S,M)=>T(S)-T(M)).forEach((S,M)=>H.set(S,(M+1)/(g.length+1))));let pt=g=>{let S=N[g.source],M=N[g.target],W=S.y+S.height*H.get(g),U=B(g.target),X=f[S.column]+l[S.column]+40,V=b(g),Q=[[S.x+S.width,W],[X,W]],F=[[M.x-64+40,U],[M.x,U]];return{...g.drawn,points:V===null?[...Q,[X,U],F[1]]:[...Q,[X,V],[F[0][0],V],...F]}},K=o.map(pt),Z=[...Object.values(N).map(g=>[g.x+g.width,g.y+g.height]),...K.flatMap(g=>g.points)].reduce(([g,S],[M,W])=>[Math.max(g,M),Math.max(S,W)],[0,0]);return{places:N,links:K,width:Z[0]+r.right,height:Z[1]+r.bottom}},J="\0entry";var Or={left:44,top:40,right:20,bottom:40},Br={left:0,top:8,right:16,bottom:12},lt=(t,o,{heights:s={}}={})=>{let r=new Set(t.map(d=>d.id)),n=new Map(t.flatMap(d=>(d.holds||[]).filter(f=>r.has(f)).map(f=>[f,d.id]))),a=new Map([[null,{ids:[],edges:[]}]]);t.filter(d=>d.holds).forEach(d=>a.set(d.id,{ids:[J],edges:[]})),t.forEach(d=>a.get(n.get(d.id)??null).ids.push(d.id)),o.filter(d=>r.has(d.source)&&r.has(d.target)).forEach(d=>{let f=n.get(d.target);f&&f===d.source?a.get(f).edges.push({source:J,target:d.target,drawn:d}):f&&f===n.get(d.source)?a.get(f).edges.push({source:d.source,target:d.target,drawn:d}):a.get(null).edges.push({source:n.get(d.source)??d.source,target:f??d.target,drawn:d})});let p=d=>({width:184,height:s[d]||64}),c=new Map([...a].filter(([d])=>d).map(([d,f])=>[d,Ce(f.ids,f.edges,_=>_===J?{width:0,height:64}:p(_),Br)])),l=d=>s[d]||24,m=d=>{let f=c.get(d);return f?{width:f.width,height:l(d)+f.height,arrives:l(d)+f.places[J].y+64/2}:p(d)},u=Ce(a.get(null).ids,a.get(null).edges,m,Or),x={...u.places},h=[...u.links];return c.forEach((d,f)=>{let _=u.places[f],[v,C]=[_.x,_.y+l(f)];Object.entries(d.places).filter(([k])=>k!==J).forEach(([k,N])=>{x[k]={...N,x:N.x+v,y:N.y+C}}),d.links.forEach(k=>h.push({...k,points:k.points.map(([N,O])=>[N+v,O+C])}))}),{places:x,links:h,width:u.width,height:u.height}};var Dr={display:"flex",flexDirection:"column",gap:14,padding:"64px 16px 24px"},Lr={display:"flex",flexDirection:"column",gap:10,padding:"8px 10px",borderRadius:8},Pr={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,minHeight:26,paddingLeft:12,fontSize:11},Ir=t=>(o,s)=>t[o.id].column-t[s.id].column||t[o.id].row-t[s.id].row,$r=t=>t?.placeholder?"nowhere yet":t?.label,Hr=({node:t,leaving:o,named:s,draw:r,joints:n})=>e.createElement("div",{"data-step-row":t.id},r(t),o.map(a=>e.createElement(it,{key:a.id,link:a,...n,alwaysShowInsertButtons:!0,shown:!0,className:"border-l border-gray-300 text-gray-500 dark:border-zinc-600 dark:text-gray-400",style:Pr},e.createElement("span",null,[a.label,"\u2192",s.get(a.target)].filter(Boolean).join(" "))))),Wr=({nodes:t,edges:o,draw:s,joints:r,children:n,style:a})=>{let{places:p}=lt(t,o),c=new Map(t.map(d=>[d.id,$r(d)])),l=new Map(t.map(d=>[d.id,[]]));o.forEach(d=>{l.has(d.source)&&c.has(d.target)&&l.get(d.source).push(d)});let m=new Map(t.flatMap(d=>(d.holds||[]).map(f=>[f,d.id]))),u=[...t].sort(Ir(p)),x=new Map;u.filter(d=>m.has(d.id)).forEach(d=>{x.has(m.get(d.id))||x.set(m.get(d.id),[]),x.get(m.get(d.id)).push(d)});let h=d=>e.createElement(Hr,{key:d.id,node:d,leaving:l.get(d.id),named:c,draw:s,joints:r});return e.createElement("div",{"data-flow-rows":!0,style:{...Dr,...a}},n,u.filter(d=>!m.has(d.id)).map(d=>d.holds?e.createElement("div",{key:d.id,"data-group-box":d.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:Lr},h(d),(x.get(d.id)||[]).map(h)):h(d)))},Ne=Wr;var jr={display:"flex",flexDirection:"column",alignItems:"flex-start",gap:14,padding:"64px 0 0"},Gr={position:"absolute",zIndex:3,maxWidth:56,fontSize:10,lineHeight:"13px",pointerEvents:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Vr=t=>t.map(([o,s],r)=>`${r===0?"M":"L"} ${o} ${s}`).join(" "),Fr=t=>Object.fromEntries(Object.entries(t).filter(([,o])=>o?.firstElementChild).map(([o,s])=>[o,s.firstElementChild.offsetHeight])),Ur=(t,o)=>Object.keys(o).some(s=>t[s]!==o[s]),Xr=({nodes:t,edges:o,draw:s,joints:r})=>{let[n,a]=E({}),p=Y({}),c=P(()=>lt(t,o,{heights:n}),[t,o,n]);R(()=>{let m=Fr(p.current);Ur(n,m)&&a({...n,...m})});let l=m=>u=>{p.current[m]=u};return e.createElement("div",{"data-flow-graph":!0,style:{position:"relative",flex:"none",width:c.width,height:c.height}},e.createElement("svg",{width:c.width,height:c.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("defs",null,e.createElement("marker",{id:"easy_flow-graph-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},e.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),c.links.map(m=>e.createElement("path",{key:m.id,"data-link":m.id,d:Vr(m.points),fill:"none",strokeWidth:"1.5",className:"stroke-gray-400 dark:stroke-zinc-500",markerEnd:"url(#easy_flow-graph-arrow)"}))),t.map(m=>{let u=c.places[m.id];return m.holds?e.createElement("div",{key:m.id,ref:l(m.id),"data-group-box":m.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",left:u.x,top:u.y,width:u.width,height:u.height,boxSizing:"border-box",borderRadius:8}},e.createElement("div",{style:{padding:"4px 10px"}},s(m))):e.createElement("div",{key:m.id,ref:l(m.id),style:{position:"absolute",left:u.x,top:u.y,width:u.width,zIndex:2}},s(m))}),c.links.filter(m=>m.label).map(m=>e.createElement("div",{key:`${m.id}-label`,"data-link-label":m.id,title:m.label,className:"text-gray-500 dark:text-gray-400",style:{...Gr,left:m.points[0][0]+6,top:m.points[0][1]-14}},m.label)),r.onInsert&&c.links.filter(m=>!m.placeholder).map(m=>e.createElement(it,{key:m.id,link:m,...r,style:{position:"absolute",left:m.points[0][0],top:m.points[0][1]-12,width:62,height:24,zIndex:3}})))},_e="(min-width: 640px)",Yr=()=>typeof window>"u"||!window.matchMedia||window.matchMedia(_e).matches,qr=()=>{let[t,o]=E(Yr);return L(()=>{if(!window.matchMedia)return;let s=window.matchMedia(_e),r=()=>o(s.matches);return s.addEventListener("change",r),()=>s.removeEventListener("change",r)},[]),t},Jr=({nodes:t,edges:o,draw:s,joints:r,children:n,style:a})=>qr()?e.createElement("div",{"data-flow-rows":!0,style:{...jr,...a}},n,e.createElement(Xr,{nodes:t,edges:o,draw:s,joints:r})):e.createElement(Ne,{nodes:t,edges:o,draw:s,joints:r,style:a},n),dt=Jr;var ze="Your change was not saved because the server could not be reached.",Kr="Your change was saved, but the canvas could not be refreshed. Reload the page to see it.",Ae=async({base:t,fetch:o,onFlow:s,onError:r})=>{let n=await o(t+".json",{headers:{Accept:"application/json"}}).catch(()=>null),a=n?.ok?await n.json().catch(()=>null):null;return a?s(a):r(Kr)},Te=({base:t,token:o,fetch:s,onFlow:r,onError:n,onNotice:a,onWarning:p=()=>{}})=>async(c,l,m)=>{let u={base:t,fetch:s,onFlow:r,onError:n},x=await s(t+c,{method:l,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:m&&JSON.stringify(m)}).catch(()=>null);if(!x)return a(null),n(ze);let h=await x.json().catch(()=>({}));return h.unconnected?(a(null),n(null),p({path:c,steps:h.unconnected}),Ae(u)):(p(null),x.ok?(n(null),a(h.notice||null),Ae(u)):(a(null),n(h.error||"That change was refused")))},Me=({base:t,token:o,fetch:s,onError:r})=>async n=>{let a=new FormData;a.append("picture",n);let p=await s(t+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:a}).catch(()=>null);if(!p)return r(ze),null;let c=await p.json().catch(()=>({}));return p.ok?(r(null),c):(r(c.error||"That picture was refused"),null)};var Zr=(t,o,s)=>{let[r,n]=E(s),[a,p]=E(null),[c,l]=E(null),[m,u]=E(null),x=P(()=>Te({base:t,token:o,fetch:(...d)=>window.fetch(...d),onFlow:n,onError:p,onNotice:l,onWarning:u}),[t,o]),h=P(()=>Me({base:t,token:o,fetch:(...d)=>window.fetch(...d),onError:p}),[t,o]);return{flow:r,error:a,notice:c,warning:m,setWarning:u,send:x,pickPicture:h}},Oe=Zr;var ct=(t,o,s,r)=>{let n=t.left-s.left+r.scrollLeft,a=t.top-s.top+r.scrollTop;return o==="left"?{x:n,y:a+t.height/2}:o==="right"?{x:n+t.width,y:a+t.height/2}:o==="top"?{x:n+t.width/2,y:a}:{x:n+t.width/2,y:a+t.height}},Qr=(t,o,s)=>s&&o==="top"?{x:t.x,y:s.top}:t,Rr=(t,o)=>o==="top"?{x:t.x,y:t.y-3}:o==="left"?{x:t.x-3,y:t.y}:o==="right"?{x:t.x+3,y:t.y}:{x:t.x,y:t.y+3},ts=(t,o,s,r,n)=>{let a={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}`}[t.route];return{...t,path:a,midX:t.route==="detour"?n:(o.x+s.x)/2,midY:t.route==="lane"?r:(o.y+s.y)/2}},es=(t,o,s,r)=>{let[n,a]=E([]),[p,c]=E({width:"100%",height:"100%"}),[l,m]=E([]);return R(()=>{let u=()=>{let h=o.current?.getBoundingClientRect();if(!h)return;c({width:o.current.scrollWidth,height:o.current.scrollHeight});let d=t.nodes.filter(f=>f.holds&&!f.loose&&s.current[f.id]).map(f=>{let _=s.current[f.id],v=_.getBoundingClientRect(),C=f.holds.flatMap(N=>s.current[N]?[s.current[N].getBoundingClientRect()]:[]),k=[{left:v.left,top:v.top,width:Math.max(v.width,_.scrollWidth),height:v.height},...C];return{id:f.id,bounds:It(k,h,o.current)}});m(d),a(t.edges.flatMap(f=>{let _=s.current[f.source]?.getBoundingClientRect(),v=s.current[f.target]?.getBoundingClientRect();if(!_||!v)return[];let C=ct(_,f.leaves,h,o.current),k=d.find(B=>B.id===f.target)?.bounds,N=Rr(Qr(ct(v,f.enters,h,o.current),f.enters,k),f.enters),O=(ct(_,"bottom",h,o.current).y+ct(v,"top",h,o.current).y)/2,b=f.leaves==="left"?Math.min(C.x,N.x)-28:Math.max(C.x,N.x)+28;return[ts(f,C,N,O,b)]}))};u(),window.addEventListener("resize",u);let x=new ResizeObserver(u);return o.current&&x.observe(o.current),()=>{window.removeEventListener("resize",u),x.disconnect()}},r),{links:n,extent:p,boxes:l}},Be=es;var De=(t,o)=>{let s=new Set(o),r=t,n=2;for(;s.has(r);)r=`${t}_${n++}`;return r};var Le=({send:t,onPress:o})=>s=>{let r=s.target.closest?.("[data-bar-action]");r&&(r.closest("details")?.removeAttribute("open"),o(),r.dataset.barPath&&t(r.dataset.barPath,"POST"))};var rs=8,ss={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},ns={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},as={flex:1,minHeight:0,overflow:"auto",position:"relative"},Ie={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},is={...Ie,position:"static",alignSelf:"flex-start"},ls={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},$e={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},ds=({port:t,onCancel:o})=>e.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:$e},"Choose the step \u201C",t||"next","\u201D should lead to \u2014 ",e.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")),cs=({message:t})=>e.createElement("p",{"data-canvas-error":!0,className:"bg-red-50 text-red-800 dark:bg-red-950 dark:text-red-200",style:$e},t),ps=({base:t,token:o,initial:s})=>{let{flow:r,error:n,notice:a,warning:p,setWarning:c,send:l,pickPicture:m}=Oe(t,o,s),[u,x]=E(null),[h,d]=E(null),[f,_]=E(null),[v,C]=E(null),[k,N]=E(null),[O,b]=E(!1),B=Y({}),T=Y(null);L(()=>{let i=Le({send:l,onPress:()=>{x(null),b(!0)}});return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[l]),L(()=>{if(!O){c(null);return}let i=y=>{y.target.isConnected&&!y.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&b(!1)};return document.addEventListener("click",i),()=>document.removeEventListener("click",i)},[O]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let H=P(()=>Object.fromEntries(r.nodes.map(i=>[i.id,i])),[r.nodes]),{links:pt,extent:K,boxes:mt}=Be(r,T,B,[r,u,H]),Z=P(()=>{let i={};return r.violations.forEach(y=>{var z;return(i[z=y.node]||(i[z]=[])).push(y)}),i},[r.violations]),g=r.direction==="left_to_right",S=P(()=>r.nodes.filter(i=>!i.loose),[r.nodes]),M=r.nodes.filter(i=>i.loose),W=P(()=>{let i={};return r.edges.forEach(y=>{var z;return(i[z=y.source]||(i[z]=[])).push(y.label||null)}),i},[r.edges]),U=Math.max(0,...S.map(i=>i.row))+1,X=Math.max(0,...S.map(i=>i.column))+1,V=i=>{if(!f)return;let[y,z]=f;_(null),y!==i&&l("/edges","POST",{from:y,to:i,on:z||null})},Q=i=>{if(i.isDefaultPrevented()||!v)return;i.preventDefault();let y=v;C(null);let z=T.current.getBoundingClientRect(),_t=$t(mt,{x:i.clientX-z.left+T.current.scrollLeft,y:i.clientY-z.top+T.current.scrollTop}),Ue=r.nodes.find(Xe=>Xe.holds?.includes(y))?.id||null;_t!==Ue&&l(`/steps/${y}/group`,"PATCH",{group:_t})},F=i=>[...r.palette,...r.unoffered||[]].find(y=>y.type===i?.type),j=r.nodes.find(i=>i.id===u),$=F(j),ut=(i,y={})=>l("/steps","POST",{id:De(i.type,r.nodes.map(z=>z.id)),type:i.type,from:y.from,to:y.to,on:y.on}),kt=i=>{let[y,z]=[k,v];N(null),C(null),y?ut(y,{from:i.source,to:i.target}):z&&l("/steps/"+z+"/move","PATCH",{from:i.source,to:i.target})},St=i=>{let y=T.current.getBoundingClientRect();return{x:i.clientX-y.left+T.current.scrollLeft+8,y:i.clientY-y.top+T.current.scrollTop+8}},Ct=(i,y)=>({node:{...i,ref:z=>{B.current[i.id]=z},violations:Z[i.id]||[],connected:y},selected:i.id===u,armed:f&&f[0]===i.id?f[1]:null,connecting:!!f&&f[0]!==i.id,onSelect:()=>f?V(i.id):x(i.id),onOpen:z=>window.location.assign(z),onDragStart:()=>C(i.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes,compact:g}),Nt=i=>e.createElement(e.Fragment,null,i.placeholder&&e.createElement(te,{node:{...i,ref:y=>{B.current[i.id]=y}},dragging:!!v,compact:g,onFill:()=>d({from:i.from,on:i.on,at:{x:16,y:52}}),onDrop:()=>{let y=v;C(null),y&&l("/edges","POST",{from:i.from,to:y,on:i.on})}}),i.holds&&e.createElement(et,{node:{...i,ref:y=>{B.current[i.id]=y}},header:ot(i,F(i),r.hide_step_type_codes),compact:g,onSelect:()=>f?V(i.id):x(i.id)}),!i.placeholder&&!i.holds&&e.createElement(gt,{...Ct(i,W[i.id]||[]),onArm:(y,z)=>d({from:i.id,on:y,at:St(z)})})),Et=M.length>0&&e.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:g?is:Ie},e.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"),M.map(i=>e.createElement("div",{key:i.id,style:{marginBottom:8}},e.createElement(gt,{...Ct(i,[]),onArm:(y,z)=>{z.stopPropagation(),_([i.id,y])}}))));return e.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:ss,onMouseUp:()=>C(null),onKeyDown:i=>{i.key==="Escape"&&(x(null),_(null),d(null))},tabIndex:-1},e.createElement(oe,{entries:r.palette,groups:r.step_groups||{},onPick:i=>ut(i),onCarry:N,onDrop:()=>N(null)}),e.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:ns},e.createElement("div",{ref:T,style:as,onClick:i=>{i.target===T.current&&(x(null),_(null),b(!1))},onDragOver:i=>{v&&i.preventDefault()},onDrop:Q},f&&e.createElement(ds,{port:f[1],onCancel:()=>_(null)}),n&&!O&&!j&&e.createElement(cs,{message:n}),e.createElement(se,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>d({at:{x:16,y:52}}),onUndo:()=>{x(null),l("/undo","POST")},onRedo:()=>{x(null),l("/redo","POST")}}),!g&&mt.map(i=>e.createElement(Pt,{key:i.id,id:i.id,bounds:i.bounds,onDrop:()=>{let y=v;C(null),y&&l(`/steps/${y}/group`,"PATCH",{group:i.id})}})),!g&&e.createElement(ke,{links:Ht(pt,r.nodes),extent:K,dragging:v||k,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:i=>d({from:i.source,to:i.target,at:{x:i.midX+30,y:i.midY}}),onRemove:i=>{x(null),l("/edges","DELETE",{from:i.source,to:i.target})},onDrop:kt}),!g&&Et,g&&e.createElement(dt,{nodes:S,edges:r.edges,draw:Nt,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(v||k),onInsert:(i,y)=>d({from:i.source,to:i.target,at:St(y)}),onRemove:i=>{x(null),l("/edges","DELETE",{from:i.source,to:i.target})},onDrop:kt}},Et),!g&&e.createElement("div",{style:{...ls,gridTemplateColumns:`repeat(${X+1}, ${280/2}px)`,gridTemplateRows:`repeat(${U}, auto)`}},S.map(i=>e.createElement("div",{key:i.id,style:{gridRow:i.row+1,gridColumn:`${i.column+1} / span 2`,zIndex:2,marginTop:Wt(i,r.nodes)?rs-64:0}},Nt(i)))),h&&e.createElement(ee,{entries:r.palette,at:h.at,onDismiss:()=>d(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:h.on!==void 0?()=>{_([h.from,h.on]),d(null)}:null,onPick:i=>{let y=h;d(null),ut(i,y)}})),e.createElement(ye,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:x})),O&&!j&&e.createElement(pe,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:a,publishNote:r.publish_note,warning:p,onClose:()=>b(!1),onCreate:()=>l("/versions","POST"),onPublish:()=>l("/publish","POST"),onAccept:()=>l(p.path,"POST",{remove_unconnected:p.steps.map(i=>i.id)}),onDecline:()=>c(null),onSaveDetails:i=>l("/details","PATCH",{flow:i})}),j&&e.createElement(Rt,{node:j,fields:$?.fields||{},holds:$?.records||{},labels:$?.labels||{},explanations:$?.explanations||{},recordLabels:$?.record_labels||{},recordExplanations:$?.record_explanations||{},recordChoices:$?.record_choices||{},recordOutputsOf:$?.record_outputs_of||{},choices:jt(j,$),onClose:()=>x(null),onSave:i=>l(`/steps/${j.id}`,"PATCH",{config:i}),onPickPicture:m,refusal:n,notice:a,onDelete:()=>{x(null),l(`/steps/${j.id}`,"DELETE")}}))},He=ps;var ms={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},We={fontSize:12,fontWeight:500,lineHeight:1.3},je={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"},Ge={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"},us="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",fs=({node:t,selected:o=!1})=>{let s=t.address?"a":"div",r=t.begins_here||t.ends_here;return e.createElement(s,{"data-step":t.id,href:t.address||void 0,className:`${t.state==="paused"?"border-2":"border"} ${je[t.state]||je.pending}${o?` ${us}`:""}`,style:ms},!r&&e.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.type),e.createElement("div",{style:r?{...We,textAlign:"center"}:We},t.label,t.version&&e.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},t.version)),t.status&&e.createElement("div",{className:Ge[t.state]||Ge.pending,style:{fontSize:11}},t.status))},Ve=fs;var gs={gap:12,padding:0,maxWidth:"100%",overflowX:"auto"},hs=({nodes:t,edges:o,selected:s})=>e.createElement(dt,{nodes:t,edges:o,joints:{},style:gs,draw:r=>r.holds?e.createElement(et,{node:r,header:ot(r,r,!1),compact:!0}):e.createElement(Ve,{node:r,selected:r.id===s})}),Fe=hs;ft("easy_flow/flow-editor",He);ft("easy_flow/run-view",Fe);document.addEventListener("easy_flow:flow-named",t=>{let o=document.querySelector("[data-flow-heading]");o&&(o.textContent=t.detail)});document.addEventListener("easy_flow:flow-status",({detail:t})=>{t.status&&document.querySelectorAll("[data-version-status]").forEach(o=>{o.textContent=t.status}),t.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(o=>{o.textContent=`Publish v${t.publishes}`})});Bt(document,At);})();
@@ -4,8 +4,8 @@ module EasyFlow
4
4
  module RunViewHelper
5
5
  include KeystoneUi::React::MountHelper
6
6
 
7
- def easy_flow_run_view(version, steps:, selected: nil, **attributes)
8
- react_ui("easy_flow/run-view", RunView.new(version, steps: steps, selected: selected).to_h,
7
+ def easy_flow_run_view(version, steps:, selected: nil, ended_at: nil, start_and_end: true, **attributes)
8
+ react_ui("easy_flow/run-view", RunView.new(version, steps: steps, selected: selected, ended_at: ended_at, start_and_end: start_and_end).to_h,
9
9
  data: { flow_run_view: true }, **attributes)
10
10
  end
11
11
  end
@@ -22,11 +22,12 @@ const marked = "ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950"
22
22
 
23
23
  const RunCard = ({ node, selected = false }) => {
24
24
  const Card = node.address ? "a" : "div"
25
+ const bookend = node.begins_here || node.ends_here
25
26
 
26
27
  return (
27
28
  <Card data-step={node.id} href={node.address || undefined} className={`${node.state === "paused" ? "border-2" : "border"} ${STATES[node.state] || STATES.pending}${selected ? ` ${marked}` : ""}`} style={card}>
28
- <div className="font-mono text-gray-500 dark:text-gray-400" style={{ fontSize: 11 }}>{node.type}</div>
29
- <div style={named}>{node.label}{node.version && <span className="text-gray-500 dark:text-gray-400" style={{ fontWeight: 400, marginLeft: 4 }}>{node.version}</span>}</div>
29
+ {!bookend && <div className="font-mono text-gray-500 dark:text-gray-400" style={{ fontSize: 11 }}>{node.type}</div>}
30
+ <div style={bookend ? { ...named, textAlign: "center" } : named}>{node.label}{node.version && <span className="text-gray-500 dark:text-gray-400" style={{ fontWeight: 400, marginLeft: 4 }}>{node.version}</span>}</div>
30
31
  {node.status && <div className={STATUS_LINES[node.state] || STATUS_LINES.pending} style={{ fontSize: 11 }}>{node.status}</div>}
31
32
  </Card>
32
33
  )
@@ -1,9 +1,11 @@
1
1
  module EasyFlow
2
2
  class RunView
3
- def initialize(version, steps: {}, selected: nil, registry: EasyFlow.registry)
3
+ def initialize(version, steps: {}, selected: nil, ended_at: nil, start_and_end: true, registry: EasyFlow.registry)
4
4
  @document = Document.new(version.definition || {}, registry: registry)
5
5
  @steps = steps.to_h.transform_keys(&:to_s)
6
6
  @selected = selected
7
+ @ended_at = ended_at&.to_s
8
+ @start_and_end = start_and_end
7
9
  @registry = registry
8
10
  end
9
11
 
@@ -14,7 +16,7 @@ module EasyFlow
14
16
  private
15
17
 
16
18
  def nodes
17
- @document.nodes.reject { |node| bookend?(node) }.map { |node| drawn_step(node) }
19
+ @document.nodes.reject { |node| hidden?(node) }.map { |node| drawn_step(node) }
18
20
  end
19
21
 
20
22
  def edges
@@ -27,11 +29,6 @@ module EasyFlow
27
29
  @placed ||= Layout.new(@document).positions
28
30
  end
29
31
 
30
- def bookend?(node)
31
- step_type = step_type_for(node)
32
- step_type.present? && (step_type.begins_here? || step_type.ends_here?)
33
- end
34
-
35
32
  def holds(node)
36
33
  Array(node.config["holds"]) if step_type_for(node)&.holds_steps?
37
34
  end
@@ -43,8 +40,29 @@ module EasyFlow
43
40
  def drawn_step(node)
44
41
  shown = @steps.fetch(node.id, {}).to_h.symbolize_keys
45
42
 
46
- { "id" => node.id, "type" => node.type, "label" => Name.of(node, @registry), "state" => shown[:state]&.to_s, "status" => shown[:status], "address" => shown[:address], "version" => shown[:version],
47
- "holds" => holds(node), **header_of(node), **placed.fetch(node.id, {}) }
43
+ { "id" => node.id, "type" => node.type, "label" => Name.of(node, @registry), "state" => state_of(node, shown), "status" => shown[:status], "address" => (shown[:address] unless bookend?(node)), "version" => shown[:version],
44
+ "begins_here" => step_type_for(node)&.begins_here? || false, "ends_here" => step_type_for(node)&.ends_here? || false, "holds" => holds(node), **header_of(node), **placed.fetch(node.id, {}) }
45
+ end
46
+
47
+ def hidden?(node)
48
+ !@start_and_end && bookend?(node)
49
+ end
50
+
51
+ def bookend?(node)
52
+ step_type = step_type_for(node)
53
+ step_type.present? && (step_type.begins_here? || step_type.ends_here?)
54
+ end
55
+
56
+ def state_of(node, shown)
57
+ return "done" if node.id == @ended_at
58
+ return "pending" if step_type_for(node)&.ends_here?
59
+ return shown[:state]&.to_s unless step_type_for(node)&.begins_here?
60
+
61
+ started? ? "done" : "pending"
62
+ end
63
+
64
+ def started?
65
+ @steps.values.map { |shown| shown.to_h.symbolize_keys[:state].to_s }.any? { |state| state.present? && state != "pending" }
48
66
  end
49
67
 
50
68
  def header_of(node)
@@ -1,3 +1,3 @@
1
1
  module EasyFlow
2
- VERSION = "0.51.0"
2
+ VERSION = "0.52.0"
3
3
  end
@@ -25,7 +25,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
25
25
  - `run_address` — private method a `FlowsController` subclass overrides to give the value put in a run's address in place of its id.
26
26
  - `find_run` — private method a `FlowsController` subclass overrides to find a run, among the host's own runs, from the value in its address.
27
27
  - `EasyFlow::Run` — the stored record of one visitor's pass through a flow, started with `EasyFlow::Run.start` on the live version or a chosen published one and pinned to that version, moved on past a waiting step with `advance`, read for the output its flow ended with by `output`, for the mark of the End it reached by `end_mark`, for whether it ended at an End step by `ended_at_end?`, for the step a loop stopped it at by `stopped_on_loop`, for when each step visit was completed by `completed_at` and for the time a Wait step holds it until by `held_until`, and linked to the runs its Flow steps started by `inner_runs`, to the one it is waiting on by `waiting_on`, and to the run that started it by `parent_run`.
28
- - `easy_flow_run_view(version, steps:, selected: nil)` — a view helper every view in the app can call, drawing a read-only view of one flow version's steps with the state, status line, version and address the app supplies for each step.
28
+ - `easy_flow_run_view(version, steps:, selected: nil, ended_at: nil, start_and_end: true)` — a view helper every view in the app can call, drawing a read-only view of one flow version's steps with the state, status line, version and address the app supplies for each step, and the Start and End steps unless the app hides them.
29
29
  - `EasyFlow::QuestionRunner` — reads a flow document: its steps, the next step for a set of answers and the times their steps were completed, the answers on the path taken, and a question's text and an answer's label.
30
30
 
31
31
  ## How to use it
@@ -571,7 +571,7 @@ Use this when a visitor's run should stop until a set time has passed, such as a
571
571
  <%= easy_flow_run_view(run.definition_version,
572
572
  steps: { "outline" => { state: :done, status: "8.2s · $0.04", version: "v9", address: run_step_path(run, "outline") },
573
573
  "human_approve" => { state: :paused, status: "waiting · expires 46h", address: run_step_path(run, "human_approve") } },
574
- selected: "outline") %>
574
+ selected: "outline", ended_at: "published") %>
575
575
  ```
576
576
 
577
577
  - `state` — `:done`, `:paused`, `:pending` or `:failed`, shown on the card's edge. A paused step's edge is thicker than the others. A step with no state or an unknown one is drawn as pending.
@@ -579,8 +579,10 @@ Use this when a visitor's run should stop until a set time has passed, such as a
579
579
  - `version` — optional text written after the step's name, such as `v9`.
580
580
  - `address` — optional. A card with one is a link to it, and a card without one is not a link.
581
581
  - `selected` — the id of one step whose card is ringed in the accent colour, such as the step whose details the page shows.
582
+ - `ended_at` — optional, the id of the End step the run ended at. That End card is drawn as done, and every other End card as pending. Without it every End card is pending.
583
+ - `start_and_end` — `true` by default, drawing the Start and End steps. `false` leaves them out, and the graph begins at the first step after Start.
582
584
  - Any other keyword is passed to the wrapping element, such as `class:`.
583
- 3. The view lays the steps out left to right whatever the host's `canvas_direction`, as the same graph a left-to-right canvas draws: compact cards in columns by stage, every connection drawn as a line labelled with the answer it is taken on, and a group step's box holding its steps as their own small graph. A flow wider than its box scrolls sideways inside it. On a screen narrower than 640 pixels each step sits on a row of its own with its connections listed under it. The Start and End steps are left out. It has no buttons and nothing on it changes the flow.
585
+ 3. The view lays the steps out left to right whatever the host's `canvas_direction`, as the same graph a left-to-right canvas draws: compact cards in columns by stage, every connection drawn as a line labelled with the answer it is taken on, and a group step's box holding its steps as their own small graph. A flow wider than its box scrolls sideways inside it. On a screen narrower than 640 pixels each step sits on a row of its own with its connections listed under it. The Start and End steps are drawn as cards with their name alone, as the editor draws them, with every line into an End step and its branch label. The Start card is done once any step the app supplied has a state other than pending, and pending before that. A Start or End card is never a link, even when the app gives it an address, since neither has a page of its own. On a phone they are listed one per row with the other steps. It has no buttons and nothing on it changes the flow.
584
586
  4. Ask the developer what each step's status line says and where each card links. Do not pick.
585
587
 
586
588
  ### Read a run and its answers
@@ -106,7 +106,7 @@ easy_flow declares no commands of its own for this local. Its surface is split b
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 columns by stage, every connection is drawn as a line labelled with the answer it is taken on, a loop back runs above the steps, a group step's box holds its steps as their own small graph, a flow wider than the canvas scrolls sideways, and a phone-width screen shows one step per row with its connections listed under it. 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.
109
- - **Run view** — a read-only view of one flow version that an app draws on its own page with `easy_flow_run_view`, showing each step as a compact card with its type code, name, the version and status line the app supplies, and an edge coloured by the state the app supplies, done, paused, pending or failed. A paused step's edge is thicker, the step the app names as selected is ringed, a card the app gives an address is a link to it, and steps sit in the same graph a left-to-right canvas draws, with every connection drawn as a line, a group step's box holding its steps, and one card per row with its connections listed on a phone. It has no editing controls.
109
+ - **Run view** — a read-only view of one flow version that an app draws on its own page with `easy_flow_run_view`, showing each step as a compact card with its type code, name, the version and status line the app supplies, and an edge coloured by the state the app supplies, done, paused, pending or failed. A paused step's edge is thicker, the step the app names as selected is ringed, a card the app gives an address is a link to it, and steps sit in the same graph a left-to-right canvas draws, with every connection drawn as a line, a group step's box holding its steps, and one card per row with its connections listed on a phone. The Start and End steps are drawn as cards with their name alone and never link anywhere, Start shows as done once any step has left pending, and an End shows as done when the app names it as the step the run ended at and as pending otherwise. An app can hide Start and End. It has no editing controls.
110
110
  - **Publish note** — a setting a host may set, `publish_note`, whose sentence is shown directly under the Publish button in its flow panel. With none set, the panel shows no note.
111
111
  - **Back link** — a setting a host may set, `back_link`, holding a label and an address, or a callable that takes the flow being shown and returns them, that shows a link with that label and address at the start of the editor's top bar in place of `All flows`. With a callable, each flow's canvas shows the back link worked out for that flow. With none set, the bar shows `All flows`.
112
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.
@@ -168,7 +168,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
168
168
  - After adding a step type that holds other steps to a flow, check that its header line shows the step type's code followed by each filled-in setting, or the type's name and the settings' labels on a host with `hide_step_type_codes` set, and that clicking the header opens the step's settings.
169
169
  - After adding a step type that holds other steps to a flow, check that dragging another step onto its box puts the step inside the box, that dragging it onto the canvas outside the box takes it out, and that both leave the step's connections as they were.
170
170
  - After setting `canvas_direction` to `:left_to_right` on a host, check that its canvas shows the steps in columns with every connection drawn as a labelled line, that a flow wider than the canvas scrolls sideways inside it, and that a phone-width screen shows one step per row with its connections listed under it.
171
- - A page of the app that calls `easy_flow_run_view` needs the `keystone_ui/react` and `easy_flow/canvas` scripts in its head, the same two the canvas page loads. The helper needs no setting in the initializer, and it is available in every view of the app. After adding one, check that the page shows each step's card with the state and status line the app supplied, and that a phone-width screen shows one card per row.
171
+ - A page of the app that calls `easy_flow_run_view` needs the `keystone_ui/react` and `easy_flow/canvas` scripts in its head, the same two the canvas page loads. The helper needs no setting in the initializer, and it is available in every view of the app. After adding one, check that the page shows each step's card with the state and status line the app supplied, the Start and End cards unless the page passes `start_and_end: false`, and that a phone-width screen shows one card per row.
172
172
  - After setting `step_groups` on a host, check that its canvas shows the step list beside the canvas with each step type under its heading, that typing in its search field narrows the list, that clicking a type adds an unconnected step, that dragging a type onto a connection inserts it there, and that a phone-width screen shows no step list.
173
173
  - After setting `editor_buttons` on a host, check that its canvas's top bar shows each button between `Try it` and `Save draft` with the label given, that each opens its address, and that on a phone-width screen the buttons are listed in the bar's actions menu.
174
174
  - After setting `drawer_tabs` on a host, check that the drawer under its canvas shows each tab after Validation with its count, that choosing a tab shows its content, and that on a phone-width screen the drawer shows only its tabs until one is tapped.
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.51.0
4
+ version: 0.52.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider