@object-ui/plugin-workflow 4.0.3 → 4.0.4

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.
@@ -1,7 +1,2 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`clsx`),require(`tailwind-merge`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`clsx`,`tailwind-merge`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginWorkflow={},e.ObjectUICore,e.React,e.ObjectUIComponents,e.lucide_react,e.clsx,e.tailwind_merge))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:s(d(e)),m(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var h=p((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),g=p((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(typeof e.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=k.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(A.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){N||(N=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,`key`,{get:n,configurable:!0})}function l(){var e=t(this.type);return P[e]||(P[e]=!0,console.error(`Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.`)),e=this.props.ref,e===void 0?null:e}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,`ref`,{enumerable:!1,value:null}):Object.defineProperty(e,`ref`,{enumerable:!1,get:l}),e._store={},Object.defineProperty(e._store,`validated`,{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,`_debugInfo`,{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,`_debugStack`,{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,`_debugTask`,{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0)if(o)if(j(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}else console.error(`React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.`);else f(p);if(A.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,L[p+o]||(m=0<m.length?`{`+m.join(`: ..., `)+`: ...}`:`{}`,console.error(`A props object containing a "key" prop is being spread into JSX:
2
- let props = %s;
3
- <%s {...props} />
4
- React keys must be passed directly to JSX without using spread:
5
- let props = %s;
6
- <%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require(`react`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),_=p(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=h():t.exports=g()}))(),v={start:(0,_.jsx)(i.Play,{className:`h-4 w-4 text-green-500`}),end:(0,_.jsx)(i.CheckCircle,{className:`h-4 w-4 text-red-500`}),task:(0,_.jsx)(i.Circle,{className:`h-4 w-4 text-blue-500`}),approval:(0,_.jsx)(i.Users,{className:`h-4 w-4 text-purple-500`}),condition:(0,_.jsx)(i.GitBranch,{className:`h-4 w-4 text-orange-500`}),parallel:(0,_.jsx)(i.ArrowRight,{className:`h-4 w-4 text-teal-500`}),delay:(0,_.jsx)(i.Clock,{className:`h-4 w-4 text-gray-500`}),notification:(0,_.jsx)(i.Bell,{className:`h-4 w-4 text-yellow-500`}),script:(0,_.jsx)(i.Code,{className:`h-4 w-4 text-indigo-500`})},y={start:`border-green-300 bg-green-50`,end:`border-red-300 bg-red-50`,task:`border-blue-300 bg-blue-50`,approval:`border-purple-300 bg-purple-50`,condition:`border-orange-300 bg-orange-50`,parallel:`border-teal-300 bg-teal-50`,delay:`border-gray-300 bg-gray-50`,notification:`border-yellow-300 bg-yellow-50`,script:`border-indigo-300 bg-indigo-50`},b={draft:{variant:`secondary`,label:`Draft`},active:{variant:`default`,label:`Active`},paused:{variant:`outline`,label:`Paused`},completed:{variant:`default`,label:`Completed`},cancelled:{variant:`destructive`,label:`Cancelled`}},x=({schema:e})=>{let{workflow:t,readOnly:a=!1,showToolbar:o=!0}=e,[s,c]=(0,n.useState)(t||{type:`workflow`,title:`New Workflow`,status:`draft`,nodes:[{id:`start-1`,type:`start`,label:`Start`,position:{x:100,y:100}},{id:`end-1`,type:`end`,label:`End`,position:{x:100,y:400}}],edges:[],variables:[]}),[l,u]=(0,n.useState)(null),[d,f]=(0,n.useState)(null),p=(0,n.useMemo)(()=>s.nodes.find(e=>e.id===l),[s.nodes,l]),m=(0,n.useCallback)(e=>{if(a)return;let t=`${e}-${Date.now()}`,n={id:t,type:e,label:`New ${e.charAt(0).toUpperCase()+e.slice(1)}`,position:{x:200,y:(s.nodes.length+1)*80}};c(e=>({...e,nodes:[...e.nodes,n]})),u(t)},[a,s.nodes.length]),h=(0,n.useCallback)((e,t)=>{a||c(n=>({...n,nodes:n.nodes.map(n=>n.id===e?{...n,...t}:n)}))},[a]),g=(0,n.useCallback)(e=>{a||(c(t=>({...t,nodes:t.nodes.filter(t=>t.id!==e),edges:t.edges.filter(t=>t.source!==e&&t.target!==e)})),l===e&&u(null))},[a,l]),x=(0,n.useCallback)((e,t)=>{if(a)return;let n={id:`edge-${Date.now()}`,source:e,target:t};c(e=>({...e,edges:[...e.edges,n]}))},[a]),S=(0,n.useCallback)(e=>{a||(c(t=>({...t,edges:t.edges.filter(t=>t.id!==e)})),d===e&&f(null))},[a,d]),C=()=>{console.log(`Saving workflow:`,s),e.onSave},w=()=>{c(e=>({...e,status:`active`})),console.log(`Publishing workflow`),e.onPublish},T=b[s.status||`draft`];return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[o&&(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-4 bg-card rounded-lg border`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,_.jsx)(`div`,{children:(0,_.jsx)(r.Input,{value:s.title||``,onChange:e=>c(t=>({...t,title:e.target.value})),className:`text-lg font-semibold border-none p-0 h-auto focus-visible:ring-0`,readOnly:a,placeholder:`Workflow Title`})}),(0,_.jsx)(r.Badge,{variant:T.variant,children:T.label})]}),!a&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:C,children:[(0,_.jsx)(i.Save,{className:`h-4 w-4 mr-2`}),`Save`]}),(0,_.jsxs)(r.Button,{size:`sm`,onClick:w,disabled:s.status===`active`,children:[(0,_.jsx)(i.Play,{className:`h-4 w-4 mr-2`}),`Publish`]})]})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-4 gap-4`,children:[!a&&(0,_.jsxs)(r.Card,{className:`lg:col-span-1`,children:[(0,_.jsx)(r.CardHeader,{children:(0,_.jsx)(r.CardTitle,{className:`text-sm`,children:`Add Node`})}),(0,_.jsx)(r.CardContent,{className:`space-y-2`,children:[`task`,`approval`,`condition`,`parallel`,`delay`,`notification`,`script`].map(e=>(0,_.jsxs)(`button`,{onClick:()=>m(e),className:`w-full flex items-center gap-2 p-2 rounded-md border hover:bg-muted/50 transition-colors text-sm`,children:[v[e],(0,_.jsx)(`span`,{className:`capitalize`,children:e})]},e))})]}),(0,_.jsxs)(r.Card,{className:a?`lg:col-span-3`:`lg:col-span-2`,children:[(0,_.jsx)(r.CardHeader,{children:(0,_.jsxs)(r.CardTitle,{className:`text-sm flex items-center gap-2`,children:[(0,_.jsx)(i.GitBranch,{className:`h-4 w-4`}),`Workflow Flow`]})}),(0,_.jsx)(r.CardContent,{children:(0,_.jsxs)(`div`,{className:`space-y-2`,children:[s.nodes.map(e=>(0,_.jsxs)(`div`,{onClick:()=>{u(e.id),f(null)},className:`flex items-center justify-between p-3 rounded-lg border-2 cursor-pointer transition-all ${y[e.type]} ${l===e.id?`ring-2 ring-primary shadow-md`:`hover:shadow-sm`}`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v[e.type],(0,_.jsx)(`span`,{className:`font-medium text-sm`,children:e.label}),(0,_.jsxs)(`span`,{className:`text-xs text-muted-foreground capitalize`,children:[`(`,e.type,`)`]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-1`,children:[s.edges.filter(t=>t.source===e.id).length>0&&(0,_.jsxs)(r.Badge,{variant:`outline`,className:`text-xs`,children:[s.edges.filter(t=>t.source===e.id).length,` out`]}),!a&&e.type!==`start`&&e.type!==`end`&&(0,_.jsx)(r.Button,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 text-red-500 hover:text-red-700`,onClick:t=>{t.stopPropagation(),g(e.id)},children:(0,_.jsx)(i.Trash2,{className:`h-3 w-3`})})]})]},e.id)),s.edges.length>0&&(0,_.jsxs)(`div`,{className:`mt-4 pt-4 border-t`,children:[(0,_.jsx)(r.Label,{className:`text-xs text-muted-foreground mb-2 block`,children:`Connections`}),s.edges.map(e=>{let t=s.nodes.find(t=>t.id===e.source),n=s.nodes.find(t=>t.id===e.target);return(0,_.jsxs)(`div`,{className:`flex items-center gap-2 p-2 text-sm`,children:[(0,_.jsx)(`span`,{children:t?.label||e.source}),(0,_.jsx)(i.ArrowRight,{className:`h-3 w-3 text-muted-foreground`}),(0,_.jsx)(`span`,{children:n?.label||e.target}),e.label&&(0,_.jsx)(r.Badge,{variant:`outline`,className:`text-xs`,children:e.label}),!a&&(0,_.jsx)(r.Button,{size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 ml-auto text-red-500`,onClick:()=>S(e.id),children:(0,_.jsx)(i.Trash2,{className:`h-3 w-3`})})]},e.id)})]}),!a&&s.nodes.length>=2&&(0,_.jsxs)(`div`,{className:`mt-4 pt-4 border-t`,children:[(0,_.jsx)(r.Label,{className:`text-xs text-muted-foreground mb-2 block`,children:`Quick Connect`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,_.jsxs)(`select`,{id:`edge-source`,className:`border rounded-md p-1.5 text-sm bg-background`,children:[(0,_.jsx)(`option`,{value:``,children:`From...`}),s.nodes.filter(e=>e.type!==`end`).map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),(0,_.jsxs)(`select`,{id:`edge-target`,className:`border rounded-md p-1.5 text-sm bg-background`,children:[(0,_.jsx)(`option`,{value:``,children:`To...`}),s.nodes.filter(e=>e.type!==`start`).map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,_.jsxs)(r.Button,{size:`sm`,variant:`outline`,className:`mt-2 w-full`,onClick:()=>{let e=document.getElementById(`edge-source`)?.value,t=document.getElementById(`edge-target`)?.value;e&&t&&e!==t&&x(e,t)},children:[(0,_.jsx)(i.Plus,{className:`h-3 w-3 mr-1`}),`Connect`]})]})]})})]}),(0,_.jsxs)(r.Card,{className:`lg:col-span-1`,children:[(0,_.jsx)(r.CardHeader,{children:(0,_.jsxs)(r.CardTitle,{className:`text-sm flex items-center gap-2`,children:[(0,_.jsx)(i.Settings,{className:`h-4 w-4`}),`Properties`]})}),(0,_.jsx)(r.CardContent,{children:p?(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Label`}),(0,_.jsx)(r.Input,{value:p.label,onChange:e=>h(p.id,{label:e.target.value}),className:`h-8 text-sm`,readOnly:a})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Type`}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-md bg-muted text-sm`,children:[v[p.type],(0,_.jsx)(`span`,{className:`capitalize`,children:p.type})]})]}),p.description!==void 0&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Description`}),(0,_.jsx)(r.Input,{value:p.description||``,onChange:e=>h(p.id,{description:e.target.value}),className:`h-8 text-sm`,readOnly:a})]}),(p.type===`approval`||p.type===`task`)&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Assignee`}),(0,_.jsx)(r.Input,{value:p.assignee||``,onChange:e=>h(p.id,{assignee:e.target.value}),className:`h-8 text-sm`,placeholder:`User, role, or expression`,readOnly:a})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Assignee Type`}),(0,_.jsxs)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2 bg-background`,value:p.assigneeType||`user`,onChange:e=>h(p.id,{assigneeType:e.target.value}),disabled:a,children:[(0,_.jsx)(`option`,{value:`user`,children:`User`}),(0,_.jsx)(`option`,{value:`role`,children:`Role`}),(0,_.jsx)(`option`,{value:`group`,children:`Group`}),(0,_.jsx)(`option`,{value:`expression`,children:`Expression`})]})]})]}),p.type===`delay`&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Timeout (minutes)`}),(0,_.jsx)(r.Input,{type:`number`,value:p.timeout||60,onChange:e=>h(p.id,{timeout:Number(e.target.value)}),className:`h-8 text-sm`,readOnly:a})]}),(0,_.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-2`,children:[`ID: `,p.id]})]}):(0,_.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:`Select a node to edit its properties`})})]})]})]})},S=({schema:e})=>{let{currentNodeId:t,approvalRule:a,history:o=[],data:s,showHistory:c=!0,showComments:l=!0}=e,[u,d]=(0,n.useState)(``),[f,p]=(0,n.useState)(!1),m=e=>{p(!0),console.log(`Approval action: ${e}`,{currentNodeId:t,comment:u,data:s}),setTimeout(()=>{p(!1),d(``)},500)},h=e=>{switch(e){case`approve`:case`approved`:return(0,_.jsx)(r.Badge,{variant:`default`,className:`bg-green-500`,children:`Approved`});case`reject`:case`rejected`:return(0,_.jsx)(r.Badge,{variant:`destructive`,children:`Rejected`});case`reassign`:case`reassigned`:return(0,_.jsx)(r.Badge,{variant:`secondary`,children:`Reassigned`});case`comment`:return(0,_.jsx)(r.Badge,{variant:`outline`,children:`Comment`});case`escalate`:case`escalated`:return(0,_.jsx)(r.Badge,{variant:`secondary`,className:`bg-orange-500 text-white`,children:`Escalated`});default:return(0,_.jsx)(r.Badge,{variant:`outline`,children:e})}};return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(r.Card,{children:[(0,_.jsx)(r.CardHeader,{children:(0,_.jsxs)(r.CardTitle,{className:`flex items-center gap-2`,children:[(0,_.jsx)(i.Clock,{className:`h-5 w-5`}),`Pending Approval`,a&&(0,_.jsxs)(r.Badge,{variant:`outline`,className:`ml-2`,children:[a.type===`any`&&`Any approver`,a.type===`all`&&`All must approve`,a.type===`majority`&&`Majority approval`,a.type===`sequential`&&`Sequential`]})]})}),(0,_.jsxs)(r.CardContent,{className:`space-y-4`,children:[s&&Object.keys(s).length>0&&(0,_.jsxs)(`div`,{className:`p-3 bg-muted/50 rounded-lg`,children:[(0,_.jsx)(r.Label,{className:`text-xs text-muted-foreground mb-2 block`,children:`Request Details`}),(0,_.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:Object.entries(s).slice(0,6).map(([e,t])=>(0,_.jsxs)(`div`,{className:`text-sm`,children:[(0,_.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`: `]}),(0,_.jsx)(`span`,{className:`font-medium`,children:String(t)})]},e))})]}),l&&(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsxs)(r.Label,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(i.MessageSquare,{className:`h-4 w-4`}),`Comment`]}),(0,_.jsx)(r.Input,{value:u,onChange:e=>d(e.target.value),placeholder:`Add a comment (optional)`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsxs)(r.Button,{onClick:()=>m(`approve`),disabled:f,className:`bg-green-600 hover:bg-green-700`,children:[(0,_.jsx)(i.Check,{className:`h-4 w-4 mr-2`}),`Approve`]}),(0,_.jsxs)(r.Button,{variant:`destructive`,onClick:()=>m(`reject`),disabled:f,children:[(0,_.jsx)(i.X,{className:`h-4 w-4 mr-2`}),`Reject`]}),(0,_.jsxs)(r.Button,{variant:`outline`,onClick:()=>m(`reassign`),disabled:f,children:[(0,_.jsx)(i.RefreshCw,{className:`h-4 w-4 mr-2`}),`Reassign`]})]})]})]}),c&&o.length>0&&(0,_.jsxs)(r.Card,{children:[(0,_.jsx)(r.CardHeader,{children:(0,_.jsx)(r.CardTitle,{className:`text-sm`,children:`Approval History`})}),(0,_.jsx)(r.CardContent,{children:(0,_.jsx)(`div`,{className:`space-y-3`,children:o.map((e,t)=>(0,_.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-lg border`,children:[(0,_.jsx)(`div`,{className:`mt-0.5`,children:(0,_.jsx)(i.User,{className:`h-4 w-4 text-muted-foreground`})}),(0,_.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,_.jsx)(`span`,{className:`font-medium text-sm`,children:e.actorName||e.actor}),h(e.action),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(e.timestamp).toLocaleString()})]}),e.comment&&(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.comment})]})]},t))})})]}),c&&o.length===0&&(0,_.jsx)(r.Card,{children:(0,_.jsx)(r.CardContent,{className:`p-6 text-center text-muted-foreground text-sm`,children:`No approval history yet`})})]})},C={record_created:`Record Created`,record_updated:`Record Updated`,record_deleted:`Record Deleted`,field_changed:`Field Changed`,scheduled:`Scheduled`},w={send_email:`Send Email`,update_field:`Update Field`,create_record:`Create Record`,delete_record:`Delete Record`,webhook:`Webhook`,notification:`Notification`},T={send_email:(0,_.jsx)(i.Mail,{className:`h-4 w-4`}),update_field:(0,_.jsx)(i.FileEdit,{className:`h-4 w-4`}),create_record:(0,_.jsx)(i.Plus,{className:`h-4 w-4`}),delete_record:(0,_.jsx)(i.Trash2,{className:`h-4 w-4`}),webhook:(0,_.jsx)(i.Globe,{className:`h-4 w-4`}),notification:(0,_.jsx)(i.Bell,{className:`h-4 w-4`})},E={equals:`Equals`,not_equals:`Not Equals`,contains:`Contains`,greater_than:`Greater Than`,less_than:`Less Than`},D=()=>({id:`auto-${Date.now()}`,name:``,description:``,enabled:!0,trigger:{type:`record_created`},actions:[],createdAt:new Date().toISOString()}),O=({label:e,value:t,placeholder:n,onChange:i})=>(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:e}),(0,_.jsx)(r.Input,{value:t,onChange:e=>i(e.target.value),placeholder:n})]}),k=({automation:e,objects:t=[],onSave:a,onCancel:o,className:s})=>{let[c,l]=(0,n.useState)(e??D()),u=(0,n.useCallback)(e=>{l(t=>({...t,trigger:{...t.trigger,...e}}))},[]),d=(0,n.useCallback)(()=>{l(e=>({...e,actions:[...e.actions,{type:`send_email`,params:{}}]}))},[]),f=(0,n.useCallback)((e,t)=>{l(n=>({...n,actions:n.actions.map((n,r)=>r===e?{...n,...t}:n)}))},[]),p=(0,n.useCallback)(e=>{l(t=>({...t,actions:t.actions.filter((t,n)=>n!==e)}))},[]),m=c.trigger.type!==`scheduled`,h=c.trigger.type===`field_changed`,g=c.trigger.type===`scheduled`,v=t.find(e=>e.name===c.trigger.objectName)?.fields,y=(e,t)=>{let n=(n,r)=>f(t,{params:{...e.params,[n]:r}});switch(e.type){case`send_email`:return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(O,{label:`To`,value:e.params.to??``,placeholder:`Recipient email`,onChange:e=>n(`to`,e)}),(0,_.jsx)(O,{label:`Subject`,value:e.params.subject??``,placeholder:`Email subject`,onChange:e=>n(`subject`,e)})]});case`webhook`:return(0,_.jsx)(O,{label:`URL`,value:e.params.url??``,placeholder:`https://...`,onChange:e=>n(`url`,e)});case`notification`:return(0,_.jsx)(O,{label:`Message`,value:e.params.message??``,placeholder:`Notification message`,onChange:e=>n(`message`,e)});case`update_field`:case`create_record`:case`delete_record`:return(0,_.jsx)(O,{label:`Target Object`,value:e.params.objectName??``,placeholder:`Object name`,onChange:e=>n(`objectName`,e)});default:return null}};return(0,_.jsxs)(`div`,{className:s??`space-y-4`,children:[(0,_.jsxs)(r.Card,{children:[(0,_.jsx)(r.CardHeader,{children:(0,_.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(i.Zap,{className:`h-4 w-4 text-yellow-500`}),`Trigger`]})}),(0,_.jsxs)(r.CardContent,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Trigger Type`}),(0,_.jsxs)(r.Select,{value:c.trigger.type,onValueChange:e=>u({type:e}),children:[(0,_.jsx)(r.SelectTrigger,{children:(0,_.jsx)(r.SelectValue,{placeholder:`Select trigger type`})}),(0,_.jsx)(r.SelectContent,{children:Object.keys(C).map(e=>(0,_.jsx)(r.SelectItem,{value:e,children:C[e]},e))})]})]}),m&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Object`}),t.length>0?(0,_.jsxs)(r.Select,{value:c.trigger.objectName??``,onValueChange:e=>u({objectName:e}),children:[(0,_.jsx)(r.SelectTrigger,{children:(0,_.jsx)(r.SelectValue,{placeholder:`Select object`})}),(0,_.jsx)(r.SelectContent,{children:t.map(e=>(0,_.jsx)(r.SelectItem,{value:e.name,children:e.label},e.name))})]}):(0,_.jsx)(r.Input,{value:c.trigger.objectName??``,onChange:e=>u({objectName:e.target.value}),placeholder:`Object name`})]}),h&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Field`}),v?(0,_.jsxs)(r.Select,{value:c.trigger.fieldName??``,onValueChange:e=>u({fieldName:e}),children:[(0,_.jsx)(r.SelectTrigger,{children:(0,_.jsx)(r.SelectValue,{placeholder:`Select field`})}),(0,_.jsx)(r.SelectContent,{children:Object.keys(v).map(e=>(0,_.jsx)(r.SelectItem,{value:e,children:e},e))})]}):(0,_.jsx)(r.Input,{value:c.trigger.fieldName??``,onChange:e=>u({fieldName:e.target.value}),placeholder:`Field name`})]}),g&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(r.Label,{className:`text-xs flex items-center gap-1`,children:[(0,_.jsx)(i.Clock,{className:`h-3 w-3`}),` Cron Schedule`]}),(0,_.jsx)(r.Input,{value:c.trigger.schedule??``,onChange:e=>u({schedule:e.target.value}),placeholder:`e.g. 0 9 * * 1-5`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Condition (optional)`}),(0,_.jsx)(r.Input,{value:c.trigger.condition??``,onChange:e=>u({condition:e.target.value}),placeholder:'e.g. ${data.status === "active"}'})]}),(0,_.jsx)(r.Separator,{}),(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsx)(r.Label,{className:`text-xs font-medium`,children:`Conditional Trigger (optional)`}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Run only when a field matches a specific value.`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Field`}),v?(0,_.jsxs)(r.Select,{value:c.trigger.conditionField??``,onValueChange:e=>u({conditionField:e}),children:[(0,_.jsx)(r.SelectTrigger,{children:(0,_.jsx)(r.SelectValue,{placeholder:`Field`})}),(0,_.jsx)(r.SelectContent,{children:Object.keys(v).map(e=>(0,_.jsx)(r.SelectItem,{value:e,children:e},e))})]}):(0,_.jsx)(r.Input,{value:c.trigger.conditionField??``,onChange:e=>u({conditionField:e.target.value}),placeholder:`e.g. status`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Operator`}),(0,_.jsxs)(r.Select,{value:c.trigger.conditionOperator??`equals`,onValueChange:e=>u({conditionOperator:e}),children:[(0,_.jsx)(r.SelectTrigger,{children:(0,_.jsx)(r.SelectValue,{placeholder:`Operator`})}),(0,_.jsx)(r.SelectContent,{children:Object.keys(E).map(e=>(0,_.jsx)(r.SelectItem,{value:e,children:E[e]},e))})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Value`}),(0,_.jsx)(r.Input,{value:c.trigger.conditionValue??``,onChange:e=>u({conditionValue:e.target.value}),placeholder:`e.g. urgent`})]})]})]})]})]}),(0,_.jsxs)(r.Card,{children:[(0,_.jsx)(r.CardHeader,{children:(0,_.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(i.Settings,{className:`h-4 w-4`}),` Actions`,(0,_.jsx)(r.Badge,{variant:`secondary`,className:`ml-auto`,children:c.actions.length})]})}),(0,_.jsxs)(r.CardContent,{className:`space-y-3`,children:[c.actions.length>1&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Execution`}),(0,_.jsxs)(r.Select,{value:c.executionMode??`sequential`,onValueChange:e=>l(t=>({...t,executionMode:e})),children:[(0,_.jsx)(r.SelectTrigger,{className:`h-7 w-36`,children:(0,_.jsx)(r.SelectValue,{})}),(0,_.jsxs)(r.SelectContent,{children:[(0,_.jsx)(r.SelectItem,{value:`sequential`,children:`Sequential`}),(0,_.jsx)(r.SelectItem,{value:`parallel`,children:`Parallel`})]})]})]}),c.actions.map((e,t)=>(0,_.jsxs)(`div`,{className:`rounded-lg border p-3 space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T[e.type],(0,_.jsx)(`span`,{className:`text-sm font-medium`,children:c.actions.length>1&&(c.executionMode??`sequential`)===`sequential`?`Step ${t+1}`:`Action ${t+1}`}),t>0&&c.actions.length>1&&(c.executionMode??`sequential`)===`sequential`&&(0,_.jsx)(r.Badge,{variant:`outline`,className:`text-[10px] px-1`,children:`then`})]}),(0,_.jsx)(r.Button,{size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0 text-red-500 hover:text-red-700`,onClick:()=>p(t),children:(0,_.jsx)(i.Trash2,{className:`h-4 w-4`})})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Action Type`}),(0,_.jsxs)(r.Select,{value:e.type,onValueChange:e=>f(t,{type:e,params:{}}),children:[(0,_.jsx)(r.SelectTrigger,{children:(0,_.jsx)(r.SelectValue,{})}),(0,_.jsx)(r.SelectContent,{children:Object.keys(w).map(e=>(0,_.jsx)(r.SelectItem,{value:e,children:w[e]},e))})]})]}),y(e,t)]},t)),(0,_.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`w-full`,onClick:d,children:[(0,_.jsx)(i.Plus,{className:`h-4 w-4 mr-2`}),` Add Action`]})]})]}),(0,_.jsxs)(r.Card,{children:[(0,_.jsx)(r.CardHeader,{children:(0,_.jsx)(r.CardTitle,{className:`text-sm`,children:`Summary`})}),(0,_.jsxs)(r.CardContent,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Name`}),(0,_.jsx)(r.Input,{value:c.name,onChange:e=>l(t=>({...t,name:e.target.value})),placeholder:`Automation name`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Description`}),(0,_.jsx)(r.Input,{value:c.description??``,onChange:e=>l(t=>({...t,description:e.target.value})),placeholder:`Optional description`})]}),(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(r.Label,{className:`text-sm`,children:`Enabled`}),(0,_.jsx)(r.Switch,{checked:c.enabled,onCheckedChange:e=>l(t=>({...t,enabled:e}))})]}),(0,_.jsx)(r.Separator,{}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[o&&(0,_.jsx)(r.Button,{variant:`outline`,size:`sm`,onClick:o,children:`Cancel`}),(0,_.jsxs)(r.Button,{size:`sm`,onClick:()=>a?.(c),children:[(0,_.jsx)(i.Zap,{className:`h-4 w-4 mr-2`}),` Save Automation`]})]})]})]})]})},A={success:`default`,failure:`destructive`,running:`secondary`,pending:`outline`},j={success:`Success`,failure:`Failed`,running:`Running`,pending:`Pending`};function M(e,t){if(!t)return`—`;let n=new Date(t).getTime()-new Date(e).getTime();if(n<1e3)return`${n}ms`;let r=Math.floor(n/1e3);return r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`}var N=({runs:e=[],className:t})=>(0,_.jsxs)(r.Card,{className:t,children:[(0,_.jsx)(r.CardHeader,{children:(0,_.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-sm`,children:[(0,_.jsx)(i.Clock,{className:`h-4 w-4`}),`Automation Run History`,(0,_.jsx)(r.Badge,{variant:`outline`,className:`ml-auto`,children:e.length})]})}),(0,_.jsx)(r.CardContent,{children:e.length===0?(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-6`,children:`No automation runs yet`}):(0,_.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,_.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border p-3`,children:[(0,_.jsx)(r.Badge,{variant:A[e.status],children:j[e.status]}),(0,_.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,_.jsx)(`span`,{className:`text-sm font-medium`,children:e.automationName}),e.triggerEvent&&(0,_.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`— `,e.triggerEvent]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,_.jsx)(`span`,{children:new Date(e.startedAt).toLocaleString()}),(0,_.jsxs)(`span`,{children:[`Duration: `,M(e.startedAt,e.completedAt)]})]}),e.status===`failure`&&e.error&&(0,_.jsx)(`p`,{className:`text-xs text-red-600 mt-1`,children:e.error})]})]},e.id))})})]});function P(...e){return(0,o.twMerge)((0,a.clsx)(e))}var F=130,I=52,L={start:`Start`,end:`End`,task:`Task`,user_task:`User Task`,service_task:`Service Task`,script_task:`Script Task`,approval:`Approval`,condition:`Condition`,parallel_gateway:`Parallel Gateway`,join_gateway:`Join Gateway`,boundary_event:`Boundary Event`,delay:`Delay`,notification:`Notification`,webhook:`Webhook`},R={start:(0,_.jsx)(i.Play,{className:`h-3.5 w-3.5 text-green-500`}),end:(0,_.jsx)(i.Square,{className:`h-3.5 w-3.5 text-red-500`}),task:(0,_.jsx)(i.CheckCircle,{className:`h-3.5 w-3.5 text-blue-500`}),user_task:(0,_.jsx)(i.Users,{className:`h-3.5 w-3.5 text-blue-600`}),service_task:(0,_.jsx)(i.Settings,{className:`h-3.5 w-3.5 text-blue-400`}),script_task:(0,_.jsx)(i.Code,{className:`h-3.5 w-3.5 text-indigo-500`}),approval:(0,_.jsx)(i.Users,{className:`h-3.5 w-3.5 text-purple-500`}),condition:(0,_.jsx)(i.GitBranch,{className:`h-3.5 w-3.5 text-orange-500`}),parallel_gateway:(0,_.jsx)(i.GitBranch,{className:`h-3.5 w-3.5 text-teal-500`}),join_gateway:(0,_.jsx)(i.GitMerge,{className:`h-3.5 w-3.5 text-teal-600`}),boundary_event:(0,_.jsx)(i.AlertCircle,{className:`h-3.5 w-3.5 text-amber-500`}),delay:(0,_.jsx)(i.Clock,{className:`h-3.5 w-3.5 text-gray-500`}),notification:(0,_.jsx)(i.Bell,{className:`h-3.5 w-3.5 text-yellow-500`}),webhook:(0,_.jsx)(i.Globe,{className:`h-3.5 w-3.5 text-cyan-500`})},z={start:`border-green-400 bg-green-50 dark:bg-green-950`,end:`border-red-400 bg-red-50 dark:bg-red-950`,task:`border-blue-300 bg-blue-50 dark:bg-blue-950`,user_task:`border-blue-400 bg-blue-50 dark:bg-blue-950`,service_task:`border-blue-200 bg-slate-50 dark:bg-slate-900`,script_task:`border-indigo-300 bg-indigo-50 dark:bg-indigo-950`,approval:`border-purple-400 bg-purple-50 dark:bg-purple-950`,condition:`border-orange-400 bg-orange-50 dark:bg-orange-950`,parallel_gateway:`border-teal-400 bg-teal-50 dark:bg-teal-950`,join_gateway:`border-teal-500 bg-teal-50 dark:bg-teal-950`,boundary_event:`border-amber-400 bg-amber-50 dark:bg-amber-950 border-dashed`,delay:`border-gray-400 bg-gray-50 dark:bg-gray-900`,notification:`border-yellow-400 bg-yellow-50 dark:bg-yellow-950`,webhook:`border-cyan-400 bg-cyan-50 dark:bg-cyan-950`},B={pending:{color:`text-muted-foreground`,icon:(0,_.jsx)(i.Clock,{className:`h-3 w-3`})},running:{color:`text-blue-500`,icon:(0,_.jsx)(i.Loader2,{className:`h-3 w-3 animate-spin`})},completed:{color:`text-green-500`,icon:(0,_.jsx)(i.CheckCircle,{className:`h-3 w-3`})},failed:{color:`text-red-500`,icon:(0,_.jsx)(i.AlertCircle,{className:`h-3 w-3`})},skipped:{color:`text-gray-400`,icon:(0,_.jsx)(i.SkipForward,{className:`h-3 w-3`})}},ee=[`task`,`user_task`,`service_task`,`script_task`,`approval`,`condition`,`parallel_gateway`,`join_gateway`,`boundary_event`,`delay`,`notification`,`webhook`],te={allow:`Allow (run concurrently)`,forbid:`Forbid (skip new)`,replace:`Replace (cancel existing)`,queue:`Queue (run after current)`},V={condition:`Condition`,manual:`Manual`,webhook:`Webhook`,timer:`Timer`,signal:`Signal`},H=()=>[{id:`start-1`,type:`start`,label:`Start`,position:{x:80,y:200}},{id:`end-1`,type:`end`,label:`End`,position:{x:500,y:200}}],ne=()=>[];function re(e){let[t,r]=(0,n.useState)([e]),[i,a]=(0,n.useState)(0);return{current:t[i],push:(0,n.useCallback)(e=>{r(t=>[...t.slice(0,i+1),e]),a(e=>e+1)},[i]),undo:(0,n.useCallback)(()=>{a(e=>Math.max(0,e-1))},[]),redo:(0,n.useCallback)(()=>{r(e=>(a(t=>Math.min(e.length-1,t+1)),e))},[]),canUndo:i>0,canRedo:i<t.length-1}}function ie(e,t,n){let r=[],i=[`boundary_event`];e.forEach(e=>{i.includes(e.type)&&r.push(`Node "${e.label}" (${e.type}) has limited BPMN mapping.`)});let a=[`<?xml version="1.0" encoding="UTF-8"?>`,`<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"`,` xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"`,` targetNamespace="http://objectui.org/bpmn">`,` <process id="process-1" name="${n}" isExecutable="true">`,...e.map(e=>` <${U(e.type)} id="${e.id}" name="${e.label}" />`),...t.map(e=>` <sequenceFlow ${[`id="${e.id}"`,`sourceRef="${e.source}"`,`targetRef="${e.target}"`,e.condition?`conditionExpression="${e.condition}"`:``].filter(Boolean).join(` `)} />`),` </process>`,`</definitions>`].join(`
7
- `);return{success:!0,nodeCount:e.length,edgeCount:t.length,warnings:r.length?r:void 0,bpmnXml:a}}function U(e){return{start:`startEvent`,end:`endEvent`,task:`task`,user_task:`userTask`,service_task:`serviceTask`,script_task:`scriptTask`,approval:`userTask`,condition:`exclusiveGateway`,parallel_gateway:`parallelGateway`,join_gateway:`parallelGateway`,boundary_event:`boundaryEvent`,delay:`intermediateCatchEvent`,notification:`sendTask`,webhook:`serviceTask`}[e]??`task`}function ae(e,t){let n=e.position.x+F,r=e.position.y+I/2,i=t.position.x,a=t.position.y+I/2,o=(n+i)/2;return{d:`M ${n} ${r} C ${o} ${r}, ${o} ${a}, ${i} ${a}`,labelX:o,labelY:(r+a)/2-8}}var oe=({node:e,isSelected:t,isConnectSource:n,connectMode:r,readOnly:a,showExecutionOverlay:o,onSelect:s,onDelete:c,onDragStart:l,onPortClick:u})=>{let d=e.executionStatus,f=d?B[d]:null;return(0,_.jsxs)(`div`,{className:`absolute select-none`,style:{left:e.position.x,top:e.position.y},draggable:!a&&!r,onDragStart:t=>l(t,e.id),onClick:t=>s(e.id,t.shiftKey),role:`group`,"aria-label":e.label,children:[(0,_.jsxs)(`div`,{className:P(`flex items-center gap-2 border-2 rounded px-3 py-2 min-h-[52px] transition-shadow cursor-pointer`,z[e.type],t&&`ring-2 ring-primary shadow-md`,n&&`ring-2 ring-blue-400 shadow-lg`,r&&!n&&`cursor-crosshair`,o&&d===`running`&&`ring-2 ring-blue-400`,o&&d===`failed`&&`ring-2 ring-red-400`,o&&d===`completed`&&`ring-2 ring-green-400`),style:{width:F,minHeight:I},children:[(0,_.jsx)(`span`,{className:`shrink-0`,children:R[e.type]}),(0,_.jsx)(`span`,{className:`text-xs font-medium leading-tight flex-1 truncate`,children:e.label}),o&&f&&(0,_.jsx)(`span`,{className:P(`shrink-0`,f.color),children:f.icon})]}),!a&&(t||r)&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-primary border-2 border-background shadow cursor-crosshair`,style:{right:-6,top:I/2-6},title:`Connect from this node`,onClick:t=>{t.stopPropagation(),u(e.id)}}),(0,_.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-muted-foreground border-2 border-background shadow cursor-crosshair`,style:{left:-6,top:I/2-6},title:`Connect to this node`,onClick:t=>{t.stopPropagation(),u(e.id)}})]}),!a&&t&&!r&&(0,_.jsx)(`button`,{className:`absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow`,onClick:t=>{t.stopPropagation(),c(e.id)},"aria-label":`Delete node ${e.label}`,children:(0,_.jsx)(i.Trash2,{className:`h-3 w-3`})})]})},se=({node:e,edge:t,readOnly:n,onNodeChange:i,onEdgeChange:a})=>!e&&!t?(0,_.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Select a node or edge to edit its properties.`}):e?(0,_.jsxs)(`div`,{className:`p-3 space-y-3 overflow-y-auto`,children:[(0,_.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Node Properties`}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Label`}),(0,_.jsx)(r.Input,{value:e.label,onChange:t=>i({...e,label:t.target.value}),disabled:n,className:`h-7 text-xs`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Type`}),(0,_.jsxs)(r.Select,{value:e.type,onValueChange:t=>i({...e,type:t}),disabled:n,children:[(0,_.jsx)(r.SelectTrigger,{className:`h-7 text-xs`,children:(0,_.jsx)(r.SelectValue,{})}),(0,_.jsx)(r.SelectContent,{children:Object.keys(L).map(e=>(0,_.jsx)(r.SelectItem,{value:e,className:`text-xs`,children:L[e]},e))})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Description`}),(0,_.jsx)(r.Input,{value:e.description??``,onChange:t=>i({...e,description:t.target.value}),disabled:n,className:`h-7 text-xs`,placeholder:`Optional description`})]}),[`task`,`user_task`,`service_task`,`script_task`,`delay`,`webhook`].includes(e.type)&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(r.Separator,{}),(0,_.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Executor`}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Executor Type`}),(0,_.jsx)(r.Input,{value:e.executor?.type??``,onChange:t=>i({...e,executor:{...e.executor,type:t.target.value}}),disabled:n,className:`h-7 text-xs`,placeholder:`e.g. http, script, email`})]}),e.type===`delay`&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Wait Event Type`}),(0,_.jsxs)(r.Select,{value:e.executor?.waitEventConfig?.eventType??`timer`,onValueChange:t=>i({...e,executor:{...e.executor,type:e.executor?.type??`wait`,waitEventConfig:{...e.executor?.waitEventConfig,eventType:t}}}),disabled:n,children:[(0,_.jsx)(r.SelectTrigger,{className:`h-7 text-xs`,children:(0,_.jsx)(r.SelectValue,{})}),(0,_.jsx)(r.SelectContent,{children:Object.keys(V).map(e=>(0,_.jsx)(r.SelectItem,{value:e,className:`text-xs`,children:V[e]},e))})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Timeout (ms)`}),(0,_.jsx)(r.Input,{type:`number`,value:e.executor?.timeoutMs??``,onChange:t=>i({...e,executor:{...e.executor,type:e.executor?.type??``,timeoutMs:t.target.value?Number(t.target.value):void 0}}),disabled:n,className:`h-7 text-xs`,placeholder:`e.g. 30000`})]})]}),e.type===`boundary_event`&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(r.Separator,{}),(0,_.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Boundary Config`}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Attached To Node ID`}),(0,_.jsx)(r.Input,{value:e.boundaryConfig?.attachedToNodeId??``,onChange:t=>i({...e,boundaryConfig:{...e.boundaryConfig,attachedToNodeId:t.target.value,eventType:e.boundaryConfig?.eventType??`error`}}),disabled:n,className:`h-7 text-xs`,placeholder:`Host node id`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Event Type`}),(0,_.jsxs)(r.Select,{value:e.boundaryConfig?.eventType??`error`,onValueChange:t=>i({...e,boundaryConfig:{...e.boundaryConfig,attachedToNodeId:e.boundaryConfig?.attachedToNodeId??``,eventType:t}}),disabled:n,children:[(0,_.jsx)(r.SelectTrigger,{className:`h-7 text-xs`,children:(0,_.jsx)(r.SelectValue,{})}),(0,_.jsx)(r.SelectContent,{children:[`error`,`timer`,`message`,`signal`,`compensation`].map(e=>(0,_.jsx)(r.SelectItem,{value:e,className:`text-xs capitalize`,children:e},e))})]})]})]})]}):t?(0,_.jsxs)(`div`,{className:`p-3 space-y-3 overflow-y-auto`,children:[(0,_.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Edge Properties`}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Label`}),(0,_.jsx)(r.Input,{value:t.label??``,onChange:e=>a({...t,label:e.target.value}),disabled:n,className:`h-7 text-xs`})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Type`}),(0,_.jsxs)(r.Select,{value:t.type??`default`,onValueChange:e=>a({...t,type:e}),disabled:n,children:[(0,_.jsx)(r.SelectTrigger,{className:`h-7 text-xs`,children:(0,_.jsx)(r.SelectValue,{})}),(0,_.jsxs)(r.SelectContent,{children:[(0,_.jsx)(r.SelectItem,{value:`default`,className:`text-xs`,children:`Default`}),(0,_.jsx)(r.SelectItem,{value:`conditional`,className:`text-xs`,children:`Conditional`}),(0,_.jsx)(r.SelectItem,{value:`timeout`,className:`text-xs`,children:`Timeout`})]})]})]}),t.type===`conditional`&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(r.Label,{className:`text-xs`,children:`Condition Expression`}),(0,_.jsx)(r.Input,{value:t.condition??``,onChange:e=>a({...t,condition:e.target.value}),disabled:n,className:`h-7 text-xs font-mono`,placeholder:`e.g. status === 'approved'`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`input`,{type:`checkbox`,id:`edge-isDefault`,checked:t.isDefault??!1,onChange:e=>a({...t,isDefault:e.target.checked}),disabled:n,className:`h-3.5 w-3.5`}),(0,_.jsx)(r.Label,{htmlFor:`edge-isDefault`,className:`text-xs`,children:`Default edge (isDefault)`})]})]}):null,ce=({versions:e})=>(0,_.jsxs)(`div`,{className:`p-3 space-y-2`,children:[(0,_.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Version History`}),e.length===0&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No version history available.`}),(0,_.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>(0,_.jsxs)(`div`,{className:P(`rounded border p-2 text-xs`,e.isCurrent?`border-primary bg-primary/5`:`border-border bg-muted/30`),children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsxs)(`span`,{className:`font-medium`,children:[`v`,e.version]}),e.isCurrent&&(0,_.jsx)(r.Badge,{variant:`default`,className:`text-[10px] h-4`,children:`Current`})]}),e.changeNote&&(0,_.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.changeNote}),(0,_.jsxs)(`p`,{className:`text-muted-foreground mt-0.5`,children:[e.author&&(0,_.jsxs)(_.Fragment,{children:[e.author,` · `]}),new Date(e.createdAt).toLocaleDateString()]})]},e.version))})]}),W=({schema:e,onSave:t})=>{let{readOnly:a=!1,showToolbar:o=!0,showMinimap:s=!1,showVersionHistory:c=!1,showExecutionOverlay:l=!1,executionSteps:u=[],versionHistory:d=[],concurrencyPolicy:f,title:p=`New Flow`,description:m=``,status:h=`draft`}=e,[g,v]=(0,n.useState)(p),[y,b]=(0,n.useState)(m),{current:x,push:S,undo:C,redo:w,canUndo:T,canRedo:E}=re({nodes:e.nodes??H(),edges:e.edges??ne()}),D=x.nodes,O=x.edges,[k,A]=(0,n.useState)(null),[j,M]=(0,n.useState)(null),[N,P]=(0,n.useState)(!1),[F,I]=(0,n.useState)(null),[z,B]=(0,n.useState)(!0),[V,U]=(0,n.useState)(c),[W,le]=(0,n.useState)(null),[G,K]=(0,n.useState)(1),q=(0,n.useRef)(null),ue=(0,n.useMemo)(()=>D.find(e=>e.id===k)??null,[D,k]),de=(0,n.useMemo)(()=>O.find(e=>e.id===j)??null,[O,j]),J=(0,n.useMemo)(()=>{if(!l||u.length===0)return D;let e=new Map(u.map(e=>[e.nodeId,e.status]));return D.map(t=>e.has(t.id)?{...t,executionStatus:e.get(t.id)}:t)},[D,l,u]),fe=(0,n.useCallback)(e=>{if(a)return;let t={id:`${e}-${Date.now()}`,type:e,label:L[e],position:{x:200,y:80+D.length*70}};S({nodes:[...D,t],edges:O})},[a,D,O,S]),Y=(0,n.useCallback)(e=>{a||(S({nodes:D.filter(t=>t.id!==e),edges:O.filter(t=>t.source!==e&&t.target!==e)}),k===e&&A(null))},[a,D,O,S,k]),pe=(0,n.useCallback)(e=>{a||S({nodes:D.map(t=>t.id===e.id?e:t),edges:O})},[a,D,O,S]),X=(0,n.useCallback)(e=>{a||(S({nodes:D,edges:O.filter(t=>t.id!==e)}),j===e&&M(null))},[a,D,O,S,j]),me=(0,n.useCallback)(e=>{a||S({nodes:D,edges:O.map(t=>t.id===e.id?e:t)})},[a,D,O,S]),he=(0,n.useCallback)(e=>{if(!a){if(!N){P(!0),I(e);return}if(F&&F!==e){let t={id:`edge-${Date.now()}`,source:F,target:e};S({nodes:D,edges:[...O,t]})}P(!1),I(null)}},[a,N,F,D,O,S]),Z=(0,n.useRef)(null),Q=(0,n.useRef)(null),ge=(0,n.useCallback)((e,t)=>{Z.current=t;let n=D.find(e=>e.id===t);n&&(Q.current={mouseX:e.clientX,mouseY:e.clientY,nodeX:n.position.x,nodeY:n.position.y}),e.dataTransfer.effectAllowed=`move`},[D]),_e=(0,n.useCallback)(e=>{if(e.preventDefault(),!Z.current||!Q.current||!q.current)return;q.current.getBoundingClientRect();let t=(e.clientX-Q.current.mouseX)/G,n=(e.clientY-Q.current.mouseY)/G,r=Math.max(0,Q.current.nodeX+t),i=Math.max(0,Q.current.nodeY+n),a=Z.current;S({nodes:D.map(e=>e.id===a?{...e,position:{x:r,y:i}}:e),edges:O}),Z.current=null,Q.current=null},[D,O,S,G]),ve=(0,n.useCallback)(()=>{let e=ie(D,O,g);le(e);let t=new Blob([e.bpmnXml??``],{type:`application/xml`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${g.replace(/\s+/g,`-`).toLowerCase()}.bpmn`,r.click(),URL.revokeObjectURL(n)},[D,O,g]),$=(0,n.useCallback)(()=>{t?.(D,O)},[D,O,t]);return(0,_.jsxs)(r.Card,{className:`flex flex-col h-full min-h-[600px] outline-none`,tabIndex:0,onKeyDown:(0,n.useCallback)(e=>{let t=e.ctrlKey||e.metaKey;if(t&&e.key===`z`&&!e.shiftKey){e.preventDefault(),C();return}if(t&&(e.key===`y`||e.key===`z`&&e.shiftKey)){e.preventDefault(),w();return}if(t&&e.key===`s`){e.preventDefault(),$();return}e.key===`Escape`&&(P(!1),I(null),A(null),M(null)),(e.key===`Delete`||e.key===`Backspace`)&&(k?Y(k):j&&X(j))},[C,w,$,k,j,Y,X]),children:[(0,_.jsx)(r.CardHeader,{className:`py-2 px-4 border-b flex-shrink-0`,children:(0,_.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,_.jsx)(i.Zap,{className:`h-4 w-4 text-primary shrink-0`}),(0,_.jsx)(r.CardTitle,{className:`text-sm font-semibold`,children:a?(0,_.jsx)(`span`,{children:g}):(0,_.jsx)(r.Input,{value:g,onChange:e=>v(e.target.value),className:`h-6 text-sm font-semibold border-0 p-0 focus-visible:ring-0 bg-transparent`,"aria-label":`Flow title`})}),(0,_.jsx)(r.Badge,{variant:`outline`,className:`text-xs capitalize`,children:h}),f&&(0,_.jsx)(r.Badge,{variant:`secondary`,className:`text-xs`,children:te[f]}),(0,_.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[!a&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:C,disabled:!T,title:`Undo (Ctrl+Z)`,children:(0,_.jsx)(i.Undo2,{className:`h-4 w-4`})}),(0,_.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:w,disabled:!E,title:`Redo (Ctrl+Y)`,children:(0,_.jsx)(i.Redo2,{className:`h-4 w-4`})}),(0,_.jsx)(r.Separator,{orientation:`vertical`,className:`h-5 mx-1`})]}),(0,_.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:()=>K(e=>Math.min(2,e+.1)),title:`Zoom in`,children:(0,_.jsx)(i.ZoomIn,{className:`h-4 w-4`})}),(0,_.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:()=>K(1),title:`Reset zoom`,children:(0,_.jsx)(i.RotateCcw,{className:`h-4 w-4`})}),(0,_.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:()=>K(e=>Math.max(.3,e-.1)),title:`Zoom out`,children:(0,_.jsx)(i.ZoomOut,{className:`h-4 w-4`})}),(0,_.jsx)(r.Separator,{orientation:`vertical`,className:`h-5 mx-1`}),d.length>0&&(0,_.jsx)(r.Button,{size:`icon`,variant:V?`secondary`:`ghost`,className:`h-7 w-7`,onClick:()=>U(e=>!e),title:`Version history`,children:(0,_.jsx)(i.History,{className:`h-4 w-4`})}),(0,_.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:ve,title:`Export BPMN`,children:(0,_.jsx)(i.Download,{className:`h-4 w-4`})}),!a&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,title:`Import BPMN (drag & drop)`,children:(0,_.jsx)(i.Upload,{className:`h-4 w-4`})}),(0,_.jsxs)(r.Button,{size:`sm`,variant:`default`,className:`h-7 text-xs gap-1`,onClick:$,title:`Save (Ctrl+S)`,children:[(0,_.jsx)(i.Save,{className:`h-3.5 w-3.5`}),` Save`]})]}),(0,_.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:()=>B(e=>!e),title:z?`Hide properties`:`Show properties`,children:z?(0,_.jsx)(i.PanelRightClose,{className:`h-4 w-4`}):(0,_.jsx)(i.PanelRightOpen,{className:`h-4 w-4`})})]})]})}),(0,_.jsxs)(r.CardContent,{className:`flex flex-1 p-0 overflow-hidden`,children:[o&&!a&&(0,_.jsxs)(`div`,{className:`w-36 border-r bg-muted/30 flex-shrink-0 overflow-y-auto py-2 px-2`,children:[(0,_.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-2 px-1`,children:`Add Node`}),(0,_.jsx)(`div`,{className:`space-y-1`,children:ee.map(e=>(0,_.jsxs)(`button`,{className:`w-full flex items-center gap-2 text-xs px-2 py-1.5 rounded hover:bg-muted transition-colors text-left`,onClick:()=>fe(e),title:`Add ${L[e]}`,children:[R[e],(0,_.jsx)(`span`,{className:`truncate`,children:L[e]})]},e))}),N&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(r.Separator,{className:`my-2`}),(0,_.jsxs)(`div`,{className:`px-1`,children:[(0,_.jsx)(`p`,{className:`text-[10px] text-blue-600 font-medium`,children:`Connect mode`}),(0,_.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Click a target node port to connect.`}),(0,_.jsx)(r.Button,{size:`sm`,variant:`outline`,className:`h-6 text-xs mt-1 w-full`,onClick:()=>{P(!1),I(null)},children:`Cancel`})]})]})]}),(0,_.jsx)(`div`,{className:`flex-1 overflow-auto relative bg-dot-pattern`,children:(0,_.jsxs)(`div`,{ref:q,className:`relative`,style:{width:1200,height:700,transform:`scale(${G})`,transformOrigin:`top left`},onDrop:_e,onDragOver:e=>e.preventDefault(),onClick:e=>{e.target===q.current&&(A(null),M(null))},children:[(0,_.jsxs)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:1200,height:700,style:{overflow:`visible`},children:[(0,_.jsxs)(`defs`,{children:[(0,_.jsx)(`marker`,{id:`fd-arrowhead`,markerWidth:`10`,markerHeight:`7`,refX:`9`,refY:`3.5`,orient:`auto`,children:(0,_.jsx)(`polygon`,{points:`0 0, 10 3.5, 0 7`,fill:`hsl(var(--foreground) / 0.5)`})}),(0,_.jsx)(`marker`,{id:`fd-arrowhead-selected`,markerWidth:`10`,markerHeight:`7`,refX:`9`,refY:`3.5`,orient:`auto`,children:(0,_.jsx)(`polygon`,{points:`0 0, 10 3.5, 0 7`,fill:`hsl(var(--primary))`})}),(0,_.jsx)(`marker`,{id:`fd-arrowhead-conditional`,markerWidth:`10`,markerHeight:`7`,refX:`9`,refY:`3.5`,orient:`auto`,children:(0,_.jsx)(`polygon`,{points:`0 0, 10 3.5, 0 7`,fill:`hsl(var(--foreground) / 0.6)`})})]}),O.map(e=>{let t=J.find(t=>t.id===e.source),n=J.find(t=>t.id===e.target);if(!t||!n)return null;let{d:r,labelX:i,labelY:a}=ae(t,n),o=e.id===j,s=e.type===`conditional`,c=e.isDefault;return(0,_.jsxs)(`g`,{className:`pointer-events-auto cursor-pointer`,onClick:t=>{t.stopPropagation(),M(e.id),A(null)},children:[(0,_.jsx)(`path`,{d:r,fill:`none`,stroke:o?`hsl(var(--primary))`:s?`hsl(var(--foreground) / 0.6)`:`hsl(var(--foreground) / 0.4)`,strokeWidth:o?2.5:2,strokeDasharray:s?`6 3`:c?`3 3`:void 0,markerEnd:`url(#fd-arrowhead${o?`-selected`:s?`-conditional`:``})`}),(e.label||c)&&(0,_.jsx)(`text`,{x:i,y:a,textAnchor:`middle`,className:`text-[10px] fill-muted-foreground`,style:{fontSize:10},children:e.label??(c?`(default)`:``)}),e.condition&&(0,_.jsx)(`text`,{x:i,y:a+12,textAnchor:`middle`,className:`text-[9px] fill-orange-500`,style:{fontSize:9},children:e.condition.length>24?e.condition.slice(0,24)+`…`:e.condition}),(0,_.jsx)(`path`,{d:r,fill:`none`,stroke:`transparent`,strokeWidth:12})]},e.id)})]}),J.map(e=>(0,_.jsx)(oe,{node:e,isSelected:k===e.id,isConnectSource:F===e.id,connectMode:N,readOnly:a,showExecutionOverlay:l,onSelect:(e,t)=>{t||M(null),A(e)},onDelete:Y,onDragStart:ge,onPortClick:he},e.id)),N&&F&&(0,_.jsxs)(`div`,{className:`absolute bottom-4 left-1/2 -translate-x-1/2 bg-blue-600 text-white text-xs px-3 py-1.5 rounded shadow-lg pointer-events-none`,children:[(0,_.jsx)(i.Link,{className:`h-3 w-3 inline mr-1`}),`Click a node port to complete the connection — Esc to cancel`]}),D.length===0&&(0,_.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-muted-foreground text-sm`,children:`No nodes yet. Use the toolbar to add nodes.`})]})}),V&&d.length>0&&(0,_.jsx)(`div`,{className:`w-48 border-l bg-background flex-shrink-0 overflow-y-auto`,children:(0,_.jsx)(ce,{versions:d})}),z&&(0,_.jsxs)(`div`,{className:`w-52 border-l bg-background flex-shrink-0 overflow-y-auto`,children:[(0,_.jsx)(se,{node:ue,edge:de,readOnly:a,onNodeChange:pe,onEdgeChange:me}),W&&(0,_.jsxs)(`div`,{className:`p-3 border-t`,children:[(0,_.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-1`,children:`BPMN Export`}),(0,_.jsx)(r.Badge,{variant:W.success?`default`:`destructive`,className:`text-[10px]`,children:W.success?`Exported ${W.nodeCount} nodes`:`Export failed`}),W.warnings?.map((e,t)=>(0,_.jsx)(`p`,{className:`text-[10px] text-amber-600 mt-0.5`,children:e},t))]})]})]})]})};t.ComponentRegistry.register(`workflow-designer`,x,{label:`Workflow Designer`,category:`Enterprise`,inputs:[{name:`workflow`,type:`code`,label:`Initial Workflow Definition`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`,defaultValue:!0},{name:`showMinimap`,type:`boolean`,label:`Show Minimap`,defaultValue:!1}]}),t.ComponentRegistry.register(`approval-process`,S,{label:`Approval Process`,category:`Enterprise`,inputs:[{name:`workflowId`,type:`string`,label:`Workflow ID`},{name:`instanceId`,type:`string`,label:`Instance ID`},{name:`currentNodeId`,type:`string`,label:`Current Node ID`},{name:`approvalRule`,type:`code`,label:`Approval Rule`},{name:`history`,type:`code`,label:`History`},{name:`showHistory`,type:`boolean`,label:`Show History`,defaultValue:!0},{name:`showComments`,type:`boolean`,label:`Show Comments`,defaultValue:!0}]}),t.ComponentRegistry.register(`automation-builder`,k,{label:`Automation Builder`,category:`Enterprise`,inputs:[{name:`automation`,type:`code`,label:`Automation Definition`},{name:`objects`,type:`code`,label:`Available Objects`}]}),t.ComponentRegistry.register(`automation-run-history`,N,{label:`Automation Run History`,category:`Enterprise`,inputs:[{name:`runs`,type:`code`,label:`Run History`}]}),t.ComponentRegistry.register(`flow-designer`,W,{label:`Flow Designer`,category:`Enterprise`,inputs:[{name:`nodes`,type:`code`,label:`Flow Nodes`},{name:`edges`,type:`code`,label:`Flow Edges`},{name:`title`,type:`string`,label:`Flow Title`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`,defaultValue:!0},{name:`showMinimap`,type:`boolean`,label:`Show Minimap`,defaultValue:!1},{name:`showVersionHistory`,type:`boolean`,label:`Show Version History`,defaultValue:!1},{name:`showExecutionOverlay`,type:`boolean`,label:`Show Execution Overlay`,defaultValue:!1},{name:`concurrencyPolicy`,type:`string`,label:`Concurrency Policy`},{name:`versionHistory`,type:`code`,label:`Version History`},{name:`executionSteps`,type:`code`,label:`Execution Steps`}]}),e.ApprovalProcess=S,e.AutomationBuilder=k,e.AutomationRunHistory=N,e.FlowDesigner=W,e.WorkflowDesigner=x});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`react/jsx-runtime`),require(`clsx`),require(`tailwind-merge`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`react/jsx-runtime`,`clsx`,`tailwind-merge`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginWorkflow={},e.ObjectUICore,e.React,e.ObjectUIComponents,e.lucide_react,e.react_jsx_runtime,e.clsx,e.tailwind_merge))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=Object.create,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=d(t),a=0,o=i.length,s;a<o;a++)s=i[a],!p.call(e,s)&&s!==n&&l(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=u(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:c(f(e)),m(t||!e||!e.__esModule?l(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var h={start:(0,a.jsx)(i.Play,{className:`h-4 w-4 text-green-500`}),end:(0,a.jsx)(i.CheckCircle,{className:`h-4 w-4 text-red-500`}),task:(0,a.jsx)(i.Circle,{className:`h-4 w-4 text-blue-500`}),approval:(0,a.jsx)(i.Users,{className:`h-4 w-4 text-purple-500`}),condition:(0,a.jsx)(i.GitBranch,{className:`h-4 w-4 text-orange-500`}),parallel:(0,a.jsx)(i.ArrowRight,{className:`h-4 w-4 text-teal-500`}),delay:(0,a.jsx)(i.Clock,{className:`h-4 w-4 text-gray-500`}),notification:(0,a.jsx)(i.Bell,{className:`h-4 w-4 text-yellow-500`}),script:(0,a.jsx)(i.Code,{className:`h-4 w-4 text-indigo-500`})},g={start:`border-green-300 bg-green-50`,end:`border-red-300 bg-red-50`,task:`border-blue-300 bg-blue-50`,approval:`border-purple-300 bg-purple-50`,condition:`border-orange-300 bg-orange-50`,parallel:`border-teal-300 bg-teal-50`,delay:`border-gray-300 bg-gray-50`,notification:`border-yellow-300 bg-yellow-50`,script:`border-indigo-300 bg-indigo-50`},_={draft:{variant:`secondary`,label:`Draft`},active:{variant:`default`,label:`Active`},paused:{variant:`outline`,label:`Paused`},completed:{variant:`default`,label:`Completed`},cancelled:{variant:`destructive`,label:`Cancelled`}},v=({schema:e})=>{let{workflow:t,readOnly:o=!1,showToolbar:s=!0}=e,[c,l]=(0,n.useState)(t||{type:`workflow`,title:`New Workflow`,status:`draft`,nodes:[{id:`start-1`,type:`start`,label:`Start`,position:{x:100,y:100}},{id:`end-1`,type:`end`,label:`End`,position:{x:100,y:400}}],edges:[],variables:[]}),[u,d]=(0,n.useState)(null),[f,p]=(0,n.useState)(null),m=(0,n.useMemo)(()=>c.nodes.find(e=>e.id===u),[c.nodes,u]),v=(0,n.useCallback)(e=>{if(o)return;let t=`${e}-${Date.now()}`,n={id:t,type:e,label:`New ${e.charAt(0).toUpperCase()+e.slice(1)}`,position:{x:200,y:(c.nodes.length+1)*80}};l(e=>({...e,nodes:[...e.nodes,n]})),d(t)},[o,c.nodes.length]),y=(0,n.useCallback)((e,t)=>{o||l(n=>({...n,nodes:n.nodes.map(n=>n.id===e?{...n,...t}:n)}))},[o]),b=(0,n.useCallback)(e=>{o||(l(t=>({...t,nodes:t.nodes.filter(t=>t.id!==e),edges:t.edges.filter(t=>t.source!==e&&t.target!==e)})),u===e&&d(null))},[o,u]),x=(0,n.useCallback)((e,t)=>{if(o)return;let n={id:`edge-${Date.now()}`,source:e,target:t};l(e=>({...e,edges:[...e.edges,n]}))},[o]),S=(0,n.useCallback)(e=>{o||(l(t=>({...t,edges:t.edges.filter(t=>t.id!==e)})),f===e&&p(null))},[o,f]),C=()=>{console.log(`Saving workflow:`,c),e.onSave},w=()=>{l(e=>({...e,status:`active`})),console.log(`Publishing workflow`),e.onPublish},T=_[c.status||`draft`];return(0,a.jsxs)(`div`,{className:`space-y-4`,children:[s&&(0,a.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-4 bg-card rounded-lg border`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,a.jsx)(`div`,{children:(0,a.jsx)(r.Input,{value:c.title||``,onChange:e=>l(t=>({...t,title:e.target.value})),className:`text-lg font-semibold border-none p-0 h-auto focus-visible:ring-0`,readOnly:o,placeholder:`Workflow Title`})}),(0,a.jsx)(r.Badge,{variant:T.variant,children:T.label})]}),!o&&(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:C,children:[(0,a.jsx)(i.Save,{className:`h-4 w-4 mr-2`}),`Save`]}),(0,a.jsxs)(r.Button,{size:`sm`,onClick:w,disabled:c.status===`active`,children:[(0,a.jsx)(i.Play,{className:`h-4 w-4 mr-2`}),`Publish`]})]})]}),(0,a.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-4 gap-4`,children:[!o&&(0,a.jsxs)(r.Card,{className:`lg:col-span-1`,children:[(0,a.jsx)(r.CardHeader,{children:(0,a.jsx)(r.CardTitle,{className:`text-sm`,children:`Add Node`})}),(0,a.jsx)(r.CardContent,{className:`space-y-2`,children:[`task`,`approval`,`condition`,`parallel`,`delay`,`notification`,`script`].map(e=>(0,a.jsxs)(`button`,{onClick:()=>v(e),className:`w-full flex items-center gap-2 p-2 rounded-md border hover:bg-muted/50 transition-colors text-sm`,children:[h[e],(0,a.jsx)(`span`,{className:`capitalize`,children:e})]},e))})]}),(0,a.jsxs)(r.Card,{className:o?`lg:col-span-3`:`lg:col-span-2`,children:[(0,a.jsx)(r.CardHeader,{children:(0,a.jsxs)(r.CardTitle,{className:`text-sm flex items-center gap-2`,children:[(0,a.jsx)(i.GitBranch,{className:`h-4 w-4`}),`Workflow Flow`]})}),(0,a.jsx)(r.CardContent,{children:(0,a.jsxs)(`div`,{className:`space-y-2`,children:[c.nodes.map(e=>(0,a.jsxs)(`div`,{onClick:()=>{d(e.id),p(null)},className:`flex items-center justify-between p-3 rounded-lg border-2 cursor-pointer transition-all ${g[e.type]} ${u===e.id?`ring-2 ring-primary shadow-md`:`hover:shadow-sm`}`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[h[e.type],(0,a.jsx)(`span`,{className:`font-medium text-sm`,children:e.label}),(0,a.jsxs)(`span`,{className:`text-xs text-muted-foreground capitalize`,children:[`(`,e.type,`)`]})]}),(0,a.jsxs)(`div`,{className:`flex items-center gap-1`,children:[c.edges.filter(t=>t.source===e.id).length>0&&(0,a.jsxs)(r.Badge,{variant:`outline`,className:`text-xs`,children:[c.edges.filter(t=>t.source===e.id).length,` out`]}),!o&&e.type!==`start`&&e.type!==`end`&&(0,a.jsx)(r.Button,{size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 text-red-500 hover:text-red-700`,onClick:t=>{t.stopPropagation(),b(e.id)},children:(0,a.jsx)(i.Trash2,{className:`h-3 w-3`})})]})]},e.id)),c.edges.length>0&&(0,a.jsxs)(`div`,{className:`mt-4 pt-4 border-t`,children:[(0,a.jsx)(r.Label,{className:`text-xs text-muted-foreground mb-2 block`,children:`Connections`}),c.edges.map(e=>{let t=c.nodes.find(t=>t.id===e.source),n=c.nodes.find(t=>t.id===e.target);return(0,a.jsxs)(`div`,{className:`flex items-center gap-2 p-2 text-sm`,children:[(0,a.jsx)(`span`,{children:t?.label||e.source}),(0,a.jsx)(i.ArrowRight,{className:`h-3 w-3 text-muted-foreground`}),(0,a.jsx)(`span`,{children:n?.label||e.target}),e.label&&(0,a.jsx)(r.Badge,{variant:`outline`,className:`text-xs`,children:e.label}),!o&&(0,a.jsx)(r.Button,{size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 ml-auto text-red-500`,onClick:()=>S(e.id),children:(0,a.jsx)(i.Trash2,{className:`h-3 w-3`})})]},e.id)})]}),!o&&c.nodes.length>=2&&(0,a.jsxs)(`div`,{className:`mt-4 pt-4 border-t`,children:[(0,a.jsx)(r.Label,{className:`text-xs text-muted-foreground mb-2 block`,children:`Quick Connect`}),(0,a.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,a.jsxs)(`select`,{id:`edge-source`,className:`border rounded-md p-1.5 text-sm bg-background`,children:[(0,a.jsx)(`option`,{value:``,children:`From...`}),c.nodes.filter(e=>e.type!==`end`).map(e=>(0,a.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),(0,a.jsxs)(`select`,{id:`edge-target`,className:`border rounded-md p-1.5 text-sm bg-background`,children:[(0,a.jsx)(`option`,{value:``,children:`To...`}),c.nodes.filter(e=>e.type!==`start`).map(e=>(0,a.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,a.jsxs)(r.Button,{size:`sm`,variant:`outline`,className:`mt-2 w-full`,onClick:()=>{let e=document.getElementById(`edge-source`)?.value,t=document.getElementById(`edge-target`)?.value;e&&t&&e!==t&&x(e,t)},children:[(0,a.jsx)(i.Plus,{className:`h-3 w-3 mr-1`}),`Connect`]})]})]})})]}),(0,a.jsxs)(r.Card,{className:`lg:col-span-1`,children:[(0,a.jsx)(r.CardHeader,{children:(0,a.jsxs)(r.CardTitle,{className:`text-sm flex items-center gap-2`,children:[(0,a.jsx)(i.Settings,{className:`h-4 w-4`}),`Properties`]})}),(0,a.jsx)(r.CardContent,{children:m?(0,a.jsxs)(`div`,{className:`space-y-3`,children:[(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Label`}),(0,a.jsx)(r.Input,{value:m.label,onChange:e=>y(m.id,{label:e.target.value}),className:`h-8 text-sm`,readOnly:o})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Type`}),(0,a.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-md bg-muted text-sm`,children:[h[m.type],(0,a.jsx)(`span`,{className:`capitalize`,children:m.type})]})]}),m.description!==void 0&&(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Description`}),(0,a.jsx)(r.Input,{value:m.description||``,onChange:e=>y(m.id,{description:e.target.value}),className:`h-8 text-sm`,readOnly:o})]}),(m.type===`approval`||m.type===`task`)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Assignee`}),(0,a.jsx)(r.Input,{value:m.assignee||``,onChange:e=>y(m.id,{assignee:e.target.value}),className:`h-8 text-sm`,placeholder:`User, role, or expression`,readOnly:o})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Assignee Type`}),(0,a.jsxs)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2 bg-background`,value:m.assigneeType||`user`,onChange:e=>y(m.id,{assigneeType:e.target.value}),disabled:o,children:[(0,a.jsx)(`option`,{value:`user`,children:`User`}),(0,a.jsx)(`option`,{value:`role`,children:`Role`}),(0,a.jsx)(`option`,{value:`group`,children:`Group`}),(0,a.jsx)(`option`,{value:`expression`,children:`Expression`})]})]})]}),m.type===`delay`&&(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Timeout (minutes)`}),(0,a.jsx)(r.Input,{type:`number`,value:m.timeout||60,onChange:e=>y(m.id,{timeout:Number(e.target.value)}),className:`h-8 text-sm`,readOnly:o})]}),(0,a.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-2`,children:[`ID: `,m.id]})]}):(0,a.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:`Select a node to edit its properties`})})]})]})]})},y=({schema:e})=>{let{currentNodeId:t,approvalRule:o,history:s=[],data:c,showHistory:l=!0,showComments:u=!0}=e,[d,f]=(0,n.useState)(``),[p,m]=(0,n.useState)(!1),h=e=>{m(!0),console.log(`Approval action: ${e}`,{currentNodeId:t,comment:d,data:c}),setTimeout(()=>{m(!1),f(``)},500)},g=e=>{switch(e){case`approve`:case`approved`:return(0,a.jsx)(r.Badge,{variant:`default`,className:`bg-green-500`,children:`Approved`});case`reject`:case`rejected`:return(0,a.jsx)(r.Badge,{variant:`destructive`,children:`Rejected`});case`reassign`:case`reassigned`:return(0,a.jsx)(r.Badge,{variant:`secondary`,children:`Reassigned`});case`comment`:return(0,a.jsx)(r.Badge,{variant:`outline`,children:`Comment`});case`escalate`:case`escalated`:return(0,a.jsx)(r.Badge,{variant:`secondary`,className:`bg-orange-500 text-white`,children:`Escalated`});default:return(0,a.jsx)(r.Badge,{variant:`outline`,children:e})}};return(0,a.jsxs)(`div`,{className:`space-y-4`,children:[(0,a.jsxs)(r.Card,{children:[(0,a.jsx)(r.CardHeader,{children:(0,a.jsxs)(r.CardTitle,{className:`flex items-center gap-2`,children:[(0,a.jsx)(i.Clock,{className:`h-5 w-5`}),`Pending Approval`,o&&(0,a.jsxs)(r.Badge,{variant:`outline`,className:`ml-2`,children:[o.type===`any`&&`Any approver`,o.type===`all`&&`All must approve`,o.type===`majority`&&`Majority approval`,o.type===`sequential`&&`Sequential`]})]})}),(0,a.jsxs)(r.CardContent,{className:`space-y-4`,children:[c&&Object.keys(c).length>0&&(0,a.jsxs)(`div`,{className:`p-3 bg-muted/50 rounded-lg`,children:[(0,a.jsx)(r.Label,{className:`text-xs text-muted-foreground mb-2 block`,children:`Request Details`}),(0,a.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:Object.entries(c).slice(0,6).map(([e,t])=>(0,a.jsxs)(`div`,{className:`text-sm`,children:[(0,a.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`: `]}),(0,a.jsx)(`span`,{className:`font-medium`,children:String(t)})]},e))})]}),u&&(0,a.jsxs)(`div`,{className:`space-y-2`,children:[(0,a.jsxs)(r.Label,{className:`flex items-center gap-2 text-sm`,children:[(0,a.jsx)(i.MessageSquare,{className:`h-4 w-4`}),`Comment`]}),(0,a.jsx)(r.Input,{value:d,onChange:e=>f(e.target.value),placeholder:`Add a comment (optional)`})]}),(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsxs)(r.Button,{onClick:()=>h(`approve`),disabled:p,className:`bg-green-600 hover:bg-green-700`,children:[(0,a.jsx)(i.Check,{className:`h-4 w-4 mr-2`}),`Approve`]}),(0,a.jsxs)(r.Button,{variant:`destructive`,onClick:()=>h(`reject`),disabled:p,children:[(0,a.jsx)(i.X,{className:`h-4 w-4 mr-2`}),`Reject`]}),(0,a.jsxs)(r.Button,{variant:`outline`,onClick:()=>h(`reassign`),disabled:p,children:[(0,a.jsx)(i.RefreshCw,{className:`h-4 w-4 mr-2`}),`Reassign`]})]})]})]}),l&&s.length>0&&(0,a.jsxs)(r.Card,{children:[(0,a.jsx)(r.CardHeader,{children:(0,a.jsx)(r.CardTitle,{className:`text-sm`,children:`Approval History`})}),(0,a.jsx)(r.CardContent,{children:(0,a.jsx)(`div`,{className:`space-y-3`,children:s.map((e,t)=>(0,a.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-lg border`,children:[(0,a.jsx)(`div`,{className:`mt-0.5`,children:(0,a.jsx)(i.User,{className:`h-4 w-4 text-muted-foreground`})}),(0,a.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,a.jsx)(`span`,{className:`font-medium text-sm`,children:e.actorName||e.actor}),g(e.action),(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:new Date(e.timestamp).toLocaleString()})]}),e.comment&&(0,a.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.comment})]})]},t))})})]}),l&&s.length===0&&(0,a.jsx)(r.Card,{children:(0,a.jsx)(r.CardContent,{className:`p-6 text-center text-muted-foreground text-sm`,children:`No approval history yet`})})]})},b={record_created:`Record Created`,record_updated:`Record Updated`,record_deleted:`Record Deleted`,field_changed:`Field Changed`,scheduled:`Scheduled`},x={send_email:`Send Email`,update_field:`Update Field`,create_record:`Create Record`,delete_record:`Delete Record`,webhook:`Webhook`,notification:`Notification`},S={send_email:(0,a.jsx)(i.Mail,{className:`h-4 w-4`}),update_field:(0,a.jsx)(i.FileEdit,{className:`h-4 w-4`}),create_record:(0,a.jsx)(i.Plus,{className:`h-4 w-4`}),delete_record:(0,a.jsx)(i.Trash2,{className:`h-4 w-4`}),webhook:(0,a.jsx)(i.Globe,{className:`h-4 w-4`}),notification:(0,a.jsx)(i.Bell,{className:`h-4 w-4`})},C={equals:`Equals`,not_equals:`Not Equals`,contains:`Contains`,greater_than:`Greater Than`,less_than:`Less Than`},w=()=>({id:`auto-${Date.now()}`,name:``,description:``,enabled:!0,trigger:{type:`record_created`},actions:[],createdAt:new Date().toISOString()}),T=({label:e,value:t,placeholder:n,onChange:i})=>(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:e}),(0,a.jsx)(r.Input,{value:t,onChange:e=>i(e.target.value),placeholder:n})]}),E=({automation:e,objects:t=[],onSave:o,onCancel:s,className:c})=>{let[l,u]=(0,n.useState)(e??w()),d=(0,n.useCallback)(e=>{u(t=>({...t,trigger:{...t.trigger,...e}}))},[]),f=(0,n.useCallback)(()=>{u(e=>({...e,actions:[...e.actions,{type:`send_email`,params:{}}]}))},[]),p=(0,n.useCallback)((e,t)=>{u(n=>({...n,actions:n.actions.map((n,r)=>r===e?{...n,...t}:n)}))},[]),m=(0,n.useCallback)(e=>{u(t=>({...t,actions:t.actions.filter((t,n)=>n!==e)}))},[]),h=l.trigger.type!==`scheduled`,g=l.trigger.type===`field_changed`,_=l.trigger.type===`scheduled`,v=t.find(e=>e.name===l.trigger.objectName)?.fields,y=(e,t)=>{let n=(n,r)=>p(t,{params:{...e.params,[n]:r}});switch(e.type){case`send_email`:return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(T,{label:`To`,value:e.params.to??``,placeholder:`Recipient email`,onChange:e=>n(`to`,e)}),(0,a.jsx)(T,{label:`Subject`,value:e.params.subject??``,placeholder:`Email subject`,onChange:e=>n(`subject`,e)})]});case`webhook`:return(0,a.jsx)(T,{label:`URL`,value:e.params.url??``,placeholder:`https://...`,onChange:e=>n(`url`,e)});case`notification`:return(0,a.jsx)(T,{label:`Message`,value:e.params.message??``,placeholder:`Notification message`,onChange:e=>n(`message`,e)});case`update_field`:case`create_record`:case`delete_record`:return(0,a.jsx)(T,{label:`Target Object`,value:e.params.objectName??``,placeholder:`Object name`,onChange:e=>n(`objectName`,e)});default:return null}};return(0,a.jsxs)(`div`,{className:c??`space-y-4`,children:[(0,a.jsxs)(r.Card,{children:[(0,a.jsx)(r.CardHeader,{children:(0,a.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-sm`,children:[(0,a.jsx)(i.Zap,{className:`h-4 w-4 text-yellow-500`}),`Trigger`]})}),(0,a.jsxs)(r.CardContent,{className:`space-y-4`,children:[(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Trigger Type`}),(0,a.jsxs)(r.Select,{value:l.trigger.type,onValueChange:e=>d({type:e}),children:[(0,a.jsx)(r.SelectTrigger,{children:(0,a.jsx)(r.SelectValue,{placeholder:`Select trigger type`})}),(0,a.jsx)(r.SelectContent,{children:Object.keys(b).map(e=>(0,a.jsx)(r.SelectItem,{value:e,children:b[e]},e))})]})]}),h&&(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Object`}),t.length>0?(0,a.jsxs)(r.Select,{value:l.trigger.objectName??``,onValueChange:e=>d({objectName:e}),children:[(0,a.jsx)(r.SelectTrigger,{children:(0,a.jsx)(r.SelectValue,{placeholder:`Select object`})}),(0,a.jsx)(r.SelectContent,{children:t.map(e=>(0,a.jsx)(r.SelectItem,{value:e.name,children:e.label},e.name))})]}):(0,a.jsx)(r.Input,{value:l.trigger.objectName??``,onChange:e=>d({objectName:e.target.value}),placeholder:`Object name`})]}),g&&(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Field`}),v?(0,a.jsxs)(r.Select,{value:l.trigger.fieldName??``,onValueChange:e=>d({fieldName:e}),children:[(0,a.jsx)(r.SelectTrigger,{children:(0,a.jsx)(r.SelectValue,{placeholder:`Select field`})}),(0,a.jsx)(r.SelectContent,{children:Object.keys(v).map(e=>(0,a.jsx)(r.SelectItem,{value:e,children:e},e))})]}):(0,a.jsx)(r.Input,{value:l.trigger.fieldName??``,onChange:e=>d({fieldName:e.target.value}),placeholder:`Field name`})]}),_&&(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsxs)(r.Label,{className:`text-xs flex items-center gap-1`,children:[(0,a.jsx)(i.Clock,{className:`h-3 w-3`}),` Cron Schedule`]}),(0,a.jsx)(r.Input,{value:l.trigger.schedule??``,onChange:e=>d({schedule:e.target.value}),placeholder:`e.g. 0 9 * * 1-5`})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Condition (optional)`}),(0,a.jsx)(r.Input,{value:l.trigger.condition??``,onChange:e=>d({condition:e.target.value}),placeholder:'e.g. ${data.status === "active"}'})]}),(0,a.jsx)(r.Separator,{}),(0,a.jsxs)(`div`,{className:`space-y-3`,children:[(0,a.jsx)(r.Label,{className:`text-xs font-medium`,children:`Conditional Trigger (optional)`}),(0,a.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Run only when a field matches a specific value.`}),(0,a.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Field`}),v?(0,a.jsxs)(r.Select,{value:l.trigger.conditionField??``,onValueChange:e=>d({conditionField:e}),children:[(0,a.jsx)(r.SelectTrigger,{children:(0,a.jsx)(r.SelectValue,{placeholder:`Field`})}),(0,a.jsx)(r.SelectContent,{children:Object.keys(v).map(e=>(0,a.jsx)(r.SelectItem,{value:e,children:e},e))})]}):(0,a.jsx)(r.Input,{value:l.trigger.conditionField??``,onChange:e=>d({conditionField:e.target.value}),placeholder:`e.g. status`})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Operator`}),(0,a.jsxs)(r.Select,{value:l.trigger.conditionOperator??`equals`,onValueChange:e=>d({conditionOperator:e}),children:[(0,a.jsx)(r.SelectTrigger,{children:(0,a.jsx)(r.SelectValue,{placeholder:`Operator`})}),(0,a.jsx)(r.SelectContent,{children:Object.keys(C).map(e=>(0,a.jsx)(r.SelectItem,{value:e,children:C[e]},e))})]})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Value`}),(0,a.jsx)(r.Input,{value:l.trigger.conditionValue??``,onChange:e=>d({conditionValue:e.target.value}),placeholder:`e.g. urgent`})]})]})]})]})]}),(0,a.jsxs)(r.Card,{children:[(0,a.jsx)(r.CardHeader,{children:(0,a.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-sm`,children:[(0,a.jsx)(i.Settings,{className:`h-4 w-4`}),` Actions`,(0,a.jsx)(r.Badge,{variant:`secondary`,className:`ml-auto`,children:l.actions.length})]})}),(0,a.jsxs)(r.CardContent,{className:`space-y-3`,children:[l.actions.length>1&&(0,a.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Execution`}),(0,a.jsxs)(r.Select,{value:l.executionMode??`sequential`,onValueChange:e=>u(t=>({...t,executionMode:e})),children:[(0,a.jsx)(r.SelectTrigger,{className:`h-7 w-36`,children:(0,a.jsx)(r.SelectValue,{})}),(0,a.jsxs)(r.SelectContent,{children:[(0,a.jsx)(r.SelectItem,{value:`sequential`,children:`Sequential`}),(0,a.jsx)(r.SelectItem,{value:`parallel`,children:`Parallel`})]})]})]}),l.actions.map((e,t)=>(0,a.jsxs)(`div`,{className:`rounded-lg border p-3 space-y-3`,children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S[e.type],(0,a.jsx)(`span`,{className:`text-sm font-medium`,children:l.actions.length>1&&(l.executionMode??`sequential`)===`sequential`?`Step ${t+1}`:`Action ${t+1}`}),t>0&&l.actions.length>1&&(l.executionMode??`sequential`)===`sequential`&&(0,a.jsx)(r.Badge,{variant:`outline`,className:`text-[10px] px-1`,children:`then`})]}),(0,a.jsx)(r.Button,{size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0 text-red-500 hover:text-red-700`,onClick:()=>m(t),children:(0,a.jsx)(i.Trash2,{className:`h-4 w-4`})})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Action Type`}),(0,a.jsxs)(r.Select,{value:e.type,onValueChange:e=>p(t,{type:e,params:{}}),children:[(0,a.jsx)(r.SelectTrigger,{children:(0,a.jsx)(r.SelectValue,{})}),(0,a.jsx)(r.SelectContent,{children:Object.keys(x).map(e=>(0,a.jsx)(r.SelectItem,{value:e,children:x[e]},e))})]})]}),y(e,t)]},t)),(0,a.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`w-full`,onClick:f,children:[(0,a.jsx)(i.Plus,{className:`h-4 w-4 mr-2`}),` Add Action`]})]})]}),(0,a.jsxs)(r.Card,{children:[(0,a.jsx)(r.CardHeader,{children:(0,a.jsx)(r.CardTitle,{className:`text-sm`,children:`Summary`})}),(0,a.jsxs)(r.CardContent,{className:`space-y-4`,children:[(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Name`}),(0,a.jsx)(r.Input,{value:l.name,onChange:e=>u(t=>({...t,name:e.target.value})),placeholder:`Automation name`})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Description`}),(0,a.jsx)(r.Input,{value:l.description??``,onChange:e=>u(t=>({...t,description:e.target.value})),placeholder:`Optional description`})]}),(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsx)(r.Label,{className:`text-sm`,children:`Enabled`}),(0,a.jsx)(r.Switch,{checked:l.enabled,onCheckedChange:e=>u(t=>({...t,enabled:e}))})]}),(0,a.jsx)(r.Separator,{}),(0,a.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[s&&(0,a.jsx)(r.Button,{variant:`outline`,size:`sm`,onClick:s,children:`Cancel`}),(0,a.jsxs)(r.Button,{size:`sm`,onClick:()=>o?.(l),children:[(0,a.jsx)(i.Zap,{className:`h-4 w-4 mr-2`}),` Save Automation`]})]})]})]})]})},D={success:`default`,failure:`destructive`,running:`secondary`,pending:`outline`},O={success:`Success`,failure:`Failed`,running:`Running`,pending:`Pending`};function k(e,t){if(!t)return`—`;let n=new Date(t).getTime()-new Date(e).getTime();if(n<1e3)return`${n}ms`;let r=Math.floor(n/1e3);return r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`}var A=({runs:e=[],className:t})=>(0,a.jsxs)(r.Card,{className:t,children:[(0,a.jsx)(r.CardHeader,{children:(0,a.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-sm`,children:[(0,a.jsx)(i.Clock,{className:`h-4 w-4`}),`Automation Run History`,(0,a.jsx)(r.Badge,{variant:`outline`,className:`ml-auto`,children:e.length})]})}),(0,a.jsx)(r.CardContent,{children:e.length===0?(0,a.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-6`,children:`No automation runs yet`}):(0,a.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,a.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border p-3`,children:[(0,a.jsx)(r.Badge,{variant:D[e.status],children:O[e.status]}),(0,a.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,a.jsx)(`span`,{className:`text-sm font-medium`,children:e.automationName}),e.triggerEvent&&(0,a.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`— `,e.triggerEvent]})]}),(0,a.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,a.jsx)(`span`,{children:new Date(e.startedAt).toLocaleString()}),(0,a.jsxs)(`span`,{children:[`Duration: `,k(e.startedAt,e.completedAt)]})]}),e.status===`failure`&&e.error&&(0,a.jsx)(`p`,{className:`text-xs text-red-600 mt-1`,children:e.error})]})]},e.id))})})]});function j(...e){return(0,s.twMerge)((0,o.clsx)(e))}var M=130,N=52,P={start:`Start`,end:`End`,task:`Task`,user_task:`User Task`,service_task:`Service Task`,script_task:`Script Task`,approval:`Approval`,condition:`Condition`,parallel_gateway:`Parallel Gateway`,join_gateway:`Join Gateway`,boundary_event:`Boundary Event`,delay:`Delay`,notification:`Notification`,webhook:`Webhook`},F={start:(0,a.jsx)(i.Play,{className:`h-3.5 w-3.5 text-green-500`}),end:(0,a.jsx)(i.Square,{className:`h-3.5 w-3.5 text-red-500`}),task:(0,a.jsx)(i.CheckCircle,{className:`h-3.5 w-3.5 text-blue-500`}),user_task:(0,a.jsx)(i.Users,{className:`h-3.5 w-3.5 text-blue-600`}),service_task:(0,a.jsx)(i.Settings,{className:`h-3.5 w-3.5 text-blue-400`}),script_task:(0,a.jsx)(i.Code,{className:`h-3.5 w-3.5 text-indigo-500`}),approval:(0,a.jsx)(i.Users,{className:`h-3.5 w-3.5 text-purple-500`}),condition:(0,a.jsx)(i.GitBranch,{className:`h-3.5 w-3.5 text-orange-500`}),parallel_gateway:(0,a.jsx)(i.GitBranch,{className:`h-3.5 w-3.5 text-teal-500`}),join_gateway:(0,a.jsx)(i.GitMerge,{className:`h-3.5 w-3.5 text-teal-600`}),boundary_event:(0,a.jsx)(i.AlertCircle,{className:`h-3.5 w-3.5 text-amber-500`}),delay:(0,a.jsx)(i.Clock,{className:`h-3.5 w-3.5 text-gray-500`}),notification:(0,a.jsx)(i.Bell,{className:`h-3.5 w-3.5 text-yellow-500`}),webhook:(0,a.jsx)(i.Globe,{className:`h-3.5 w-3.5 text-cyan-500`})},I={start:`border-green-400 bg-green-50 dark:bg-green-950`,end:`border-red-400 bg-red-50 dark:bg-red-950`,task:`border-blue-300 bg-blue-50 dark:bg-blue-950`,user_task:`border-blue-400 bg-blue-50 dark:bg-blue-950`,service_task:`border-blue-200 bg-slate-50 dark:bg-slate-900`,script_task:`border-indigo-300 bg-indigo-50 dark:bg-indigo-950`,approval:`border-purple-400 bg-purple-50 dark:bg-purple-950`,condition:`border-orange-400 bg-orange-50 dark:bg-orange-950`,parallel_gateway:`border-teal-400 bg-teal-50 dark:bg-teal-950`,join_gateway:`border-teal-500 bg-teal-50 dark:bg-teal-950`,boundary_event:`border-amber-400 bg-amber-50 dark:bg-amber-950 border-dashed`,delay:`border-gray-400 bg-gray-50 dark:bg-gray-900`,notification:`border-yellow-400 bg-yellow-50 dark:bg-yellow-950`,webhook:`border-cyan-400 bg-cyan-50 dark:bg-cyan-950`},L={pending:{color:`text-muted-foreground`,icon:(0,a.jsx)(i.Clock,{className:`h-3 w-3`})},running:{color:`text-blue-500`,icon:(0,a.jsx)(i.Loader2,{className:`h-3 w-3 animate-spin`})},completed:{color:`text-green-500`,icon:(0,a.jsx)(i.CheckCircle,{className:`h-3 w-3`})},failed:{color:`text-red-500`,icon:(0,a.jsx)(i.AlertCircle,{className:`h-3 w-3`})},skipped:{color:`text-gray-400`,icon:(0,a.jsx)(i.SkipForward,{className:`h-3 w-3`})}},ee=[`task`,`user_task`,`service_task`,`script_task`,`approval`,`condition`,`parallel_gateway`,`join_gateway`,`boundary_event`,`delay`,`notification`,`webhook`],R={allow:`Allow (run concurrently)`,forbid:`Forbid (skip new)`,replace:`Replace (cancel existing)`,queue:`Queue (run after current)`},z={condition:`Condition`,manual:`Manual`,webhook:`Webhook`,timer:`Timer`,signal:`Signal`},te=()=>[{id:`start-1`,type:`start`,label:`Start`,position:{x:80,y:200}},{id:`end-1`,type:`end`,label:`End`,position:{x:500,y:200}}],ne=()=>[];function re(e){let[t,r]=(0,n.useState)([e]),[i,a]=(0,n.useState)(0);return{current:t[i],push:(0,n.useCallback)(e=>{r(t=>[...t.slice(0,i+1),e]),a(e=>e+1)},[i]),undo:(0,n.useCallback)(()=>{a(e=>Math.max(0,e-1))},[]),redo:(0,n.useCallback)(()=>{r(e=>(a(t=>Math.min(e.length-1,t+1)),e))},[]),canUndo:i>0,canRedo:i<t.length-1}}function ie(e,t,n){let r=[],i=[`boundary_event`];e.forEach(e=>{i.includes(e.type)&&r.push(`Node "${e.label}" (${e.type}) has limited BPMN mapping.`)});let a=[`<?xml version="1.0" encoding="UTF-8"?>`,`<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"`,` xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"`,` targetNamespace="http://objectui.org/bpmn">`,` <process id="process-1" name="${n}" isExecutable="true">`,...e.map(e=>` <${B(e.type)} id="${e.id}" name="${e.label}" />`),...t.map(e=>` <sequenceFlow ${[`id="${e.id}"`,`sourceRef="${e.source}"`,`targetRef="${e.target}"`,e.condition?`conditionExpression="${e.condition}"`:``].filter(Boolean).join(` `)} />`),` </process>`,`</definitions>`].join(`
2
+ `);return{success:!0,nodeCount:e.length,edgeCount:t.length,warnings:r.length?r:void 0,bpmnXml:a}}function B(e){return{start:`startEvent`,end:`endEvent`,task:`task`,user_task:`userTask`,service_task:`serviceTask`,script_task:`scriptTask`,approval:`userTask`,condition:`exclusiveGateway`,parallel_gateway:`parallelGateway`,join_gateway:`parallelGateway`,boundary_event:`boundaryEvent`,delay:`intermediateCatchEvent`,notification:`sendTask`,webhook:`serviceTask`}[e]??`task`}function ae(e,t){let n=e.position.x+M,r=e.position.y+N/2,i=t.position.x,a=t.position.y+N/2,o=(n+i)/2;return{d:`M ${n} ${r} C ${o} ${r}, ${o} ${a}, ${i} ${a}`,labelX:o,labelY:(r+a)/2-8}}var oe=({node:e,isSelected:t,isConnectSource:n,connectMode:r,readOnly:o,showExecutionOverlay:s,onSelect:c,onDelete:l,onDragStart:u,onPortClick:d})=>{let f=e.executionStatus,p=f?L[f]:null;return(0,a.jsxs)(`div`,{className:`absolute select-none`,style:{left:e.position.x,top:e.position.y},draggable:!o&&!r,onDragStart:t=>u(t,e.id),onClick:t=>c(e.id,t.shiftKey),role:`group`,"aria-label":e.label,children:[(0,a.jsxs)(`div`,{className:j(`flex items-center gap-2 border-2 rounded px-3 py-2 min-h-[52px] transition-shadow cursor-pointer`,I[e.type],t&&`ring-2 ring-primary shadow-md`,n&&`ring-2 ring-blue-400 shadow-lg`,r&&!n&&`cursor-crosshair`,s&&f===`running`&&`ring-2 ring-blue-400`,s&&f===`failed`&&`ring-2 ring-red-400`,s&&f===`completed`&&`ring-2 ring-green-400`),style:{width:M,minHeight:N},children:[(0,a.jsx)(`span`,{className:`shrink-0`,children:F[e.type]}),(0,a.jsx)(`span`,{className:`text-xs font-medium leading-tight flex-1 truncate`,children:e.label}),s&&p&&(0,a.jsx)(`span`,{className:j(`shrink-0`,p.color),children:p.icon})]}),!o&&(t||r)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-primary border-2 border-background shadow cursor-crosshair`,style:{right:-6,top:N/2-6},title:`Connect from this node`,onClick:t=>{t.stopPropagation(),d(e.id)}}),(0,a.jsx)(`div`,{className:`absolute w-3 h-3 rounded-full bg-muted-foreground border-2 border-background shadow cursor-crosshair`,style:{left:-6,top:N/2-6},title:`Connect to this node`,onClick:t=>{t.stopPropagation(),d(e.id)}})]}),!o&&t&&!r&&(0,a.jsx)(`button`,{className:`absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow`,onClick:t=>{t.stopPropagation(),l(e.id)},"aria-label":`Delete node ${e.label}`,children:(0,a.jsx)(i.Trash2,{className:`h-3 w-3`})})]})},se=({node:e,edge:t,readOnly:n,onNodeChange:i,onEdgeChange:o})=>!e&&!t?(0,a.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Select a node or edge to edit its properties.`}):e?(0,a.jsxs)(`div`,{className:`p-3 space-y-3 overflow-y-auto`,children:[(0,a.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Node Properties`}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Label`}),(0,a.jsx)(r.Input,{value:e.label,onChange:t=>i({...e,label:t.target.value}),disabled:n,className:`h-7 text-xs`})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Type`}),(0,a.jsxs)(r.Select,{value:e.type,onValueChange:t=>i({...e,type:t}),disabled:n,children:[(0,a.jsx)(r.SelectTrigger,{className:`h-7 text-xs`,children:(0,a.jsx)(r.SelectValue,{})}),(0,a.jsx)(r.SelectContent,{children:Object.keys(P).map(e=>(0,a.jsx)(r.SelectItem,{value:e,className:`text-xs`,children:P[e]},e))})]})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Description`}),(0,a.jsx)(r.Input,{value:e.description??``,onChange:t=>i({...e,description:t.target.value}),disabled:n,className:`h-7 text-xs`,placeholder:`Optional description`})]}),[`task`,`user_task`,`service_task`,`script_task`,`delay`,`webhook`].includes(e.type)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Separator,{}),(0,a.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Executor`}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Executor Type`}),(0,a.jsx)(r.Input,{value:e.executor?.type??``,onChange:t=>i({...e,executor:{...e.executor,type:t.target.value}}),disabled:n,className:`h-7 text-xs`,placeholder:`e.g. http, script, email`})]}),e.type===`delay`&&(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Wait Event Type`}),(0,a.jsxs)(r.Select,{value:e.executor?.waitEventConfig?.eventType??`timer`,onValueChange:t=>i({...e,executor:{...e.executor,type:e.executor?.type??`wait`,waitEventConfig:{...e.executor?.waitEventConfig,eventType:t}}}),disabled:n,children:[(0,a.jsx)(r.SelectTrigger,{className:`h-7 text-xs`,children:(0,a.jsx)(r.SelectValue,{})}),(0,a.jsx)(r.SelectContent,{children:Object.keys(z).map(e=>(0,a.jsx)(r.SelectItem,{value:e,className:`text-xs`,children:z[e]},e))})]})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Timeout (ms)`}),(0,a.jsx)(r.Input,{type:`number`,value:e.executor?.timeoutMs??``,onChange:t=>i({...e,executor:{...e.executor,type:e.executor?.type??``,timeoutMs:t.target.value?Number(t.target.value):void 0}}),disabled:n,className:`h-7 text-xs`,placeholder:`e.g. 30000`})]})]}),e.type===`boundary_event`&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Separator,{}),(0,a.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Boundary Config`}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Attached To Node ID`}),(0,a.jsx)(r.Input,{value:e.boundaryConfig?.attachedToNodeId??``,onChange:t=>i({...e,boundaryConfig:{...e.boundaryConfig,attachedToNodeId:t.target.value,eventType:e.boundaryConfig?.eventType??`error`}}),disabled:n,className:`h-7 text-xs`,placeholder:`Host node id`})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Event Type`}),(0,a.jsxs)(r.Select,{value:e.boundaryConfig?.eventType??`error`,onValueChange:t=>i({...e,boundaryConfig:{...e.boundaryConfig,attachedToNodeId:e.boundaryConfig?.attachedToNodeId??``,eventType:t}}),disabled:n,children:[(0,a.jsx)(r.SelectTrigger,{className:`h-7 text-xs`,children:(0,a.jsx)(r.SelectValue,{})}),(0,a.jsx)(r.SelectContent,{children:[`error`,`timer`,`message`,`signal`,`compensation`].map(e=>(0,a.jsx)(r.SelectItem,{value:e,className:`text-xs capitalize`,children:e},e))})]})]})]})]}):t?(0,a.jsxs)(`div`,{className:`p-3 space-y-3 overflow-y-auto`,children:[(0,a.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Edge Properties`}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Label`}),(0,a.jsx)(r.Input,{value:t.label??``,onChange:e=>o({...t,label:e.target.value}),disabled:n,className:`h-7 text-xs`})]}),(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Type`}),(0,a.jsxs)(r.Select,{value:t.type??`default`,onValueChange:e=>o({...t,type:e}),disabled:n,children:[(0,a.jsx)(r.SelectTrigger,{className:`h-7 text-xs`,children:(0,a.jsx)(r.SelectValue,{})}),(0,a.jsxs)(r.SelectContent,{children:[(0,a.jsx)(r.SelectItem,{value:`default`,className:`text-xs`,children:`Default`}),(0,a.jsx)(r.SelectItem,{value:`conditional`,className:`text-xs`,children:`Conditional`}),(0,a.jsx)(r.SelectItem,{value:`timeout`,className:`text-xs`,children:`Timeout`})]})]})]}),t.type===`conditional`&&(0,a.jsxs)(`div`,{className:`space-y-1`,children:[(0,a.jsx)(r.Label,{className:`text-xs`,children:`Condition Expression`}),(0,a.jsx)(r.Input,{value:t.condition??``,onChange:e=>o({...t,condition:e.target.value}),disabled:n,className:`h-7 text-xs font-mono`,placeholder:`e.g. status === 'approved'`})]}),(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsx)(`input`,{type:`checkbox`,id:`edge-isDefault`,checked:t.isDefault??!1,onChange:e=>o({...t,isDefault:e.target.checked}),disabled:n,className:`h-3.5 w-3.5`}),(0,a.jsx)(r.Label,{htmlFor:`edge-isDefault`,className:`text-xs`,children:`Default edge (isDefault)`})]})]}):null,ce=({versions:e})=>(0,a.jsxs)(`div`,{className:`p-3 space-y-2`,children:[(0,a.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Version History`}),e.length===0&&(0,a.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No version history available.`}),(0,a.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>(0,a.jsxs)(`div`,{className:j(`rounded border p-2 text-xs`,e.isCurrent?`border-primary bg-primary/5`:`border-border bg-muted/30`),children:[(0,a.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,a.jsxs)(`span`,{className:`font-medium`,children:[`v`,e.version]}),e.isCurrent&&(0,a.jsx)(r.Badge,{variant:`default`,className:`text-[10px] h-4`,children:`Current`})]}),e.changeNote&&(0,a.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:e.changeNote}),(0,a.jsxs)(`p`,{className:`text-muted-foreground mt-0.5`,children:[e.author&&(0,a.jsxs)(a.Fragment,{children:[e.author,` · `]}),new Date(e.createdAt).toLocaleDateString()]})]},e.version))})]}),V=({schema:e,onSave:t})=>{let{readOnly:o=!1,showToolbar:s=!0,showMinimap:c=!1,showVersionHistory:l=!1,showExecutionOverlay:u=!1,executionSteps:d=[],versionHistory:f=[],concurrencyPolicy:p,title:m=`New Flow`,description:h=``,status:g=`draft`}=e,[_,v]=(0,n.useState)(m),[y,b]=(0,n.useState)(h),{current:x,push:S,undo:C,redo:w,canUndo:T,canRedo:E}=re({nodes:e.nodes??te(),edges:e.edges??ne()}),D=x.nodes,O=x.edges,[k,A]=(0,n.useState)(null),[j,M]=(0,n.useState)(null),[N,I]=(0,n.useState)(!1),[L,z]=(0,n.useState)(null),[B,V]=(0,n.useState)(!0),[H,le]=(0,n.useState)(l),[U,W]=(0,n.useState)(null),[G,K]=(0,n.useState)(1),q=(0,n.useRef)(null),ue=(0,n.useMemo)(()=>D.find(e=>e.id===k)??null,[D,k]),de=(0,n.useMemo)(()=>O.find(e=>e.id===j)??null,[O,j]),J=(0,n.useMemo)(()=>{if(!u||d.length===0)return D;let e=new Map(d.map(e=>[e.nodeId,e.status]));return D.map(t=>e.has(t.id)?{...t,executionStatus:e.get(t.id)}:t)},[D,u,d]),fe=(0,n.useCallback)(e=>{if(o)return;let t={id:`${e}-${Date.now()}`,type:e,label:P[e],position:{x:200,y:80+D.length*70}};S({nodes:[...D,t],edges:O})},[o,D,O,S]),Y=(0,n.useCallback)(e=>{o||(S({nodes:D.filter(t=>t.id!==e),edges:O.filter(t=>t.source!==e&&t.target!==e)}),k===e&&A(null))},[o,D,O,S,k]),pe=(0,n.useCallback)(e=>{o||S({nodes:D.map(t=>t.id===e.id?e:t),edges:O})},[o,D,O,S]),X=(0,n.useCallback)(e=>{o||(S({nodes:D,edges:O.filter(t=>t.id!==e)}),j===e&&M(null))},[o,D,O,S,j]),me=(0,n.useCallback)(e=>{o||S({nodes:D,edges:O.map(t=>t.id===e.id?e:t)})},[o,D,O,S]),he=(0,n.useCallback)(e=>{if(!o){if(!N){I(!0),z(e);return}if(L&&L!==e){let t={id:`edge-${Date.now()}`,source:L,target:e};S({nodes:D,edges:[...O,t]})}I(!1),z(null)}},[o,N,L,D,O,S]),Z=(0,n.useRef)(null),Q=(0,n.useRef)(null),ge=(0,n.useCallback)((e,t)=>{Z.current=t;let n=D.find(e=>e.id===t);n&&(Q.current={mouseX:e.clientX,mouseY:e.clientY,nodeX:n.position.x,nodeY:n.position.y}),e.dataTransfer.effectAllowed=`move`},[D]),_e=(0,n.useCallback)(e=>{if(e.preventDefault(),!Z.current||!Q.current||!q.current)return;q.current.getBoundingClientRect();let t=(e.clientX-Q.current.mouseX)/G,n=(e.clientY-Q.current.mouseY)/G,r=Math.max(0,Q.current.nodeX+t),i=Math.max(0,Q.current.nodeY+n),a=Z.current;S({nodes:D.map(e=>e.id===a?{...e,position:{x:r,y:i}}:e),edges:O}),Z.current=null,Q.current=null},[D,O,S,G]),ve=(0,n.useCallback)(()=>{let e=ie(D,O,_);W(e);let t=new Blob([e.bpmnXml??``],{type:`application/xml`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${_.replace(/\s+/g,`-`).toLowerCase()}.bpmn`,r.click(),URL.revokeObjectURL(n)},[D,O,_]),$=(0,n.useCallback)(()=>{t?.(D,O)},[D,O,t]);return(0,a.jsxs)(r.Card,{className:`flex flex-col h-full min-h-[600px] outline-none`,tabIndex:0,onKeyDown:(0,n.useCallback)(e=>{let t=e.ctrlKey||e.metaKey;if(t&&e.key===`z`&&!e.shiftKey){e.preventDefault(),C();return}if(t&&(e.key===`y`||e.key===`z`&&e.shiftKey)){e.preventDefault(),w();return}if(t&&e.key===`s`){e.preventDefault(),$();return}e.key===`Escape`&&(I(!1),z(null),A(null),M(null)),(e.key===`Delete`||e.key===`Backspace`)&&(k?Y(k):j&&X(j))},[C,w,$,k,j,Y,X]),children:[(0,a.jsx)(r.CardHeader,{className:`py-2 px-4 border-b flex-shrink-0`,children:(0,a.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,a.jsx)(i.Zap,{className:`h-4 w-4 text-primary shrink-0`}),(0,a.jsx)(r.CardTitle,{className:`text-sm font-semibold`,children:o?(0,a.jsx)(`span`,{children:_}):(0,a.jsx)(r.Input,{value:_,onChange:e=>v(e.target.value),className:`h-6 text-sm font-semibold border-0 p-0 focus-visible:ring-0 bg-transparent`,"aria-label":`Flow title`})}),(0,a.jsx)(r.Badge,{variant:`outline`,className:`text-xs capitalize`,children:g}),p&&(0,a.jsx)(r.Badge,{variant:`secondary`,className:`text-xs`,children:R[p]}),(0,a.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[!o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:C,disabled:!T,title:`Undo (Ctrl+Z)`,children:(0,a.jsx)(i.Undo2,{className:`h-4 w-4`})}),(0,a.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:w,disabled:!E,title:`Redo (Ctrl+Y)`,children:(0,a.jsx)(i.Redo2,{className:`h-4 w-4`})}),(0,a.jsx)(r.Separator,{orientation:`vertical`,className:`h-5 mx-1`})]}),(0,a.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:()=>K(e=>Math.min(2,e+.1)),title:`Zoom in`,children:(0,a.jsx)(i.ZoomIn,{className:`h-4 w-4`})}),(0,a.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:()=>K(1),title:`Reset zoom`,children:(0,a.jsx)(i.RotateCcw,{className:`h-4 w-4`})}),(0,a.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:()=>K(e=>Math.max(.3,e-.1)),title:`Zoom out`,children:(0,a.jsx)(i.ZoomOut,{className:`h-4 w-4`})}),(0,a.jsx)(r.Separator,{orientation:`vertical`,className:`h-5 mx-1`}),f.length>0&&(0,a.jsx)(r.Button,{size:`icon`,variant:H?`secondary`:`ghost`,className:`h-7 w-7`,onClick:()=>le(e=>!e),title:`Version history`,children:(0,a.jsx)(i.History,{className:`h-4 w-4`})}),(0,a.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:ve,title:`Export BPMN`,children:(0,a.jsx)(i.Download,{className:`h-4 w-4`})}),!o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,title:`Import BPMN (drag & drop)`,children:(0,a.jsx)(i.Upload,{className:`h-4 w-4`})}),(0,a.jsxs)(r.Button,{size:`sm`,variant:`default`,className:`h-7 text-xs gap-1`,onClick:$,title:`Save (Ctrl+S)`,children:[(0,a.jsx)(i.Save,{className:`h-3.5 w-3.5`}),` Save`]})]}),(0,a.jsx)(r.Button,{size:`icon`,variant:`ghost`,className:`h-7 w-7`,onClick:()=>V(e=>!e),title:B?`Hide properties`:`Show properties`,children:B?(0,a.jsx)(i.PanelRightClose,{className:`h-4 w-4`}):(0,a.jsx)(i.PanelRightOpen,{className:`h-4 w-4`})})]})]})}),(0,a.jsxs)(r.CardContent,{className:`flex flex-1 p-0 overflow-hidden`,children:[s&&!o&&(0,a.jsxs)(`div`,{className:`w-36 border-r bg-muted/30 flex-shrink-0 overflow-y-auto py-2 px-2`,children:[(0,a.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-2 px-1`,children:`Add Node`}),(0,a.jsx)(`div`,{className:`space-y-1`,children:ee.map(e=>(0,a.jsxs)(`button`,{className:`w-full flex items-center gap-2 text-xs px-2 py-1.5 rounded hover:bg-muted transition-colors text-left`,onClick:()=>fe(e),title:`Add ${P[e]}`,children:[F[e],(0,a.jsx)(`span`,{className:`truncate`,children:P[e]})]},e))}),N&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Separator,{className:`my-2`}),(0,a.jsxs)(`div`,{className:`px-1`,children:[(0,a.jsx)(`p`,{className:`text-[10px] text-blue-600 font-medium`,children:`Connect mode`}),(0,a.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Click a target node port to connect.`}),(0,a.jsx)(r.Button,{size:`sm`,variant:`outline`,className:`h-6 text-xs mt-1 w-full`,onClick:()=>{I(!1),z(null)},children:`Cancel`})]})]})]}),(0,a.jsx)(`div`,{className:`flex-1 overflow-auto relative bg-dot-pattern`,children:(0,a.jsxs)(`div`,{ref:q,className:`relative`,style:{width:1200,height:700,transform:`scale(${G})`,transformOrigin:`top left`},onDrop:_e,onDragOver:e=>e.preventDefault(),onClick:e=>{e.target===q.current&&(A(null),M(null))},children:[(0,a.jsxs)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:1200,height:700,style:{overflow:`visible`},children:[(0,a.jsxs)(`defs`,{children:[(0,a.jsx)(`marker`,{id:`fd-arrowhead`,markerWidth:`10`,markerHeight:`7`,refX:`9`,refY:`3.5`,orient:`auto`,children:(0,a.jsx)(`polygon`,{points:`0 0, 10 3.5, 0 7`,fill:`hsl(var(--foreground) / 0.5)`})}),(0,a.jsx)(`marker`,{id:`fd-arrowhead-selected`,markerWidth:`10`,markerHeight:`7`,refX:`9`,refY:`3.5`,orient:`auto`,children:(0,a.jsx)(`polygon`,{points:`0 0, 10 3.5, 0 7`,fill:`hsl(var(--primary))`})}),(0,a.jsx)(`marker`,{id:`fd-arrowhead-conditional`,markerWidth:`10`,markerHeight:`7`,refX:`9`,refY:`3.5`,orient:`auto`,children:(0,a.jsx)(`polygon`,{points:`0 0, 10 3.5, 0 7`,fill:`hsl(var(--foreground) / 0.6)`})})]}),O.map(e=>{let t=J.find(t=>t.id===e.source),n=J.find(t=>t.id===e.target);if(!t||!n)return null;let{d:r,labelX:i,labelY:o}=ae(t,n),s=e.id===j,c=e.type===`conditional`,l=e.isDefault;return(0,a.jsxs)(`g`,{className:`pointer-events-auto cursor-pointer`,onClick:t=>{t.stopPropagation(),M(e.id),A(null)},children:[(0,a.jsx)(`path`,{d:r,fill:`none`,stroke:s?`hsl(var(--primary))`:c?`hsl(var(--foreground) / 0.6)`:`hsl(var(--foreground) / 0.4)`,strokeWidth:s?2.5:2,strokeDasharray:c?`6 3`:l?`3 3`:void 0,markerEnd:`url(#fd-arrowhead${s?`-selected`:c?`-conditional`:``})`}),(e.label||l)&&(0,a.jsx)(`text`,{x:i,y:o,textAnchor:`middle`,className:`text-[10px] fill-muted-foreground`,style:{fontSize:10},children:e.label??(l?`(default)`:``)}),e.condition&&(0,a.jsx)(`text`,{x:i,y:o+12,textAnchor:`middle`,className:`text-[9px] fill-orange-500`,style:{fontSize:9},children:e.condition.length>24?e.condition.slice(0,24)+`…`:e.condition}),(0,a.jsx)(`path`,{d:r,fill:`none`,stroke:`transparent`,strokeWidth:12})]},e.id)})]}),J.map(e=>(0,a.jsx)(oe,{node:e,isSelected:k===e.id,isConnectSource:L===e.id,connectMode:N,readOnly:o,showExecutionOverlay:u,onSelect:(e,t)=>{t||M(null),A(e)},onDelete:Y,onDragStart:ge,onPortClick:he},e.id)),N&&L&&(0,a.jsxs)(`div`,{className:`absolute bottom-4 left-1/2 -translate-x-1/2 bg-blue-600 text-white text-xs px-3 py-1.5 rounded shadow-lg pointer-events-none`,children:[(0,a.jsx)(i.Link,{className:`h-3 w-3 inline mr-1`}),`Click a node port to complete the connection — Esc to cancel`]}),D.length===0&&(0,a.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-muted-foreground text-sm`,children:`No nodes yet. Use the toolbar to add nodes.`})]})}),H&&f.length>0&&(0,a.jsx)(`div`,{className:`w-48 border-l bg-background flex-shrink-0 overflow-y-auto`,children:(0,a.jsx)(ce,{versions:f})}),B&&(0,a.jsxs)(`div`,{className:`w-52 border-l bg-background flex-shrink-0 overflow-y-auto`,children:[(0,a.jsx)(se,{node:ue,edge:de,readOnly:o,onNodeChange:pe,onEdgeChange:me}),U&&(0,a.jsxs)(`div`,{className:`p-3 border-t`,children:[(0,a.jsx)(`p`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wide mb-1`,children:`BPMN Export`}),(0,a.jsx)(r.Badge,{variant:U.success?`default`:`destructive`,className:`text-[10px]`,children:U.success?`Exported ${U.nodeCount} nodes`:`Export failed`}),U.warnings?.map((e,t)=>(0,a.jsx)(`p`,{className:`text-[10px] text-amber-600 mt-0.5`,children:e},t))]})]})]})]})};t.ComponentRegistry.register(`workflow-designer`,v,{label:`Workflow Designer`,category:`Enterprise`,inputs:[{name:`workflow`,type:`code`,label:`Initial Workflow Definition`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`,defaultValue:!0},{name:`showMinimap`,type:`boolean`,label:`Show Minimap`,defaultValue:!1}]}),t.ComponentRegistry.register(`approval-process`,y,{label:`Approval Process`,category:`Enterprise`,inputs:[{name:`workflowId`,type:`string`,label:`Workflow ID`},{name:`instanceId`,type:`string`,label:`Instance ID`},{name:`currentNodeId`,type:`string`,label:`Current Node ID`},{name:`approvalRule`,type:`code`,label:`Approval Rule`},{name:`history`,type:`code`,label:`History`},{name:`showHistory`,type:`boolean`,label:`Show History`,defaultValue:!0},{name:`showComments`,type:`boolean`,label:`Show Comments`,defaultValue:!0}]}),t.ComponentRegistry.register(`automation-builder`,E,{label:`Automation Builder`,category:`Enterprise`,inputs:[{name:`automation`,type:`code`,label:`Automation Definition`},{name:`objects`,type:`code`,label:`Available Objects`}]}),t.ComponentRegistry.register(`automation-run-history`,A,{label:`Automation Run History`,category:`Enterprise`,inputs:[{name:`runs`,type:`code`,label:`Run History`}]}),t.ComponentRegistry.register(`flow-designer`,V,{label:`Flow Designer`,category:`Enterprise`,inputs:[{name:`nodes`,type:`code`,label:`Flow Nodes`},{name:`edges`,type:`code`,label:`Flow Edges`},{name:`title`,type:`string`,label:`Flow Title`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`,defaultValue:!0},{name:`showMinimap`,type:`boolean`,label:`Show Minimap`,defaultValue:!1},{name:`showVersionHistory`,type:`boolean`,label:`Show Version History`,defaultValue:!1},{name:`showExecutionOverlay`,type:`boolean`,label:`Show Execution Overlay`,defaultValue:!1},{name:`concurrencyPolicy`,type:`string`,label:`Concurrency Policy`},{name:`versionHistory`,type:`code`,label:`Version History`},{name:`executionSteps`,type:`code`,label:`Execution Steps`}]}),e.ApprovalProcess=y,e.AutomationBuilder=E,e.AutomationRunHistory=A,e.FlowDesigner=V,e.WorkflowDesigner=v});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-workflow",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.umd.cjs",
6
6
  "module": "dist/index.js",
@@ -26,10 +26,10 @@
26
26
  "clsx": "^2.1.1",
27
27
  "lucide-react": "^1.14.0",
28
28
  "tailwind-merge": "^3.5.0",
29
- "@object-ui/components": "4.0.3",
30
- "@object-ui/core": "4.0.3",
31
- "@object-ui/react": "4.0.3",
32
- "@object-ui/types": "4.0.3"
29
+ "@object-ui/components": "4.0.4",
30
+ "@object-ui/core": "4.0.4",
31
+ "@object-ui/react": "4.0.4",
32
+ "@object-ui/types": "4.0.4"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "^25.6.0",