@universal-workflow/widget-react 0.1.0 → 0.1.2
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.
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var nt=Object.create;var Q=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var dt=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty;var pt=(e,t)=>{for(var a in t)Q(e,a,{get:t[a],enumerable:!0})},he=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of lt(t))!ct.call(e,n)&&n!==a&&Q(e,n,{get:()=>t[n],enumerable:!(i=st(t,n))||i.enumerable});return e};var fe=(e,t,a)=>(a=e!=null?nt(dt(e)):{},he(t||!e||!e.__esModule?Q(a,"default",{value:e,enumerable:!0}):a,e)),ut=e=>he(Q({},"__esModule",{value:!0}),e);var wt={};pt(wt,{ApiClient:()=>ie,EmbeddableWidget:()=>vt,LicenseManager:()=>re,WorkflowBuilder:()=>be,WorkflowSerializer:()=>ne,WorkflowWidget:()=>me,createConnectorNode:()=>de,deserialize:()=>le,getConnectorDetails:()=>ce,nodeRegistry:()=>L,registerConnector:()=>mt,serialize:()=>se,standardConnectors:()=>ee});module.exports=ut(wt);var x=require("react"),M=fe(require("reactflow")),mo=require("reactflow/dist/style.css");var bt="http://localhost:3000/api/v1/license/validate",re=class{constructor(e){this.config=e,this.validationResult=null}async validate(){if(this.validationResult)return this.validationResult;try{let e=this.config.validationEndpoint||bt,t=await(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({licenseKey:this.config.licenseKey,widgetVersion:this.config.widgetVersion,originUrl:typeof window!="undefined"?window.location.origin:""})})).json();return this.validationResult=t,t}catch(e){return console.error("License validation failed",e),{valid:!1,reason:"Network Error"}}}isFeatureEnabled(e){var t,a;return(t=this.validationResult)!=null&&t.valid?!!((a=this.validationResult.features)!=null&&a[e]):!1}},ie=class{constructor(e){this.config=e}async request(e,t,a){let i={"Content-Type":"application/json",...this.config.headers},n=await fetch(e,{method:t,headers:i,body:a?JSON.stringify(a):void 0});if(!n.ok)throw new Error(`API Request failed: ${n.statusText}`);return n.json()}async getWorkflow(e){let t=`${this.config.baseUrl}${this.config.endpoints.get.replace(":id",e)}`;return this.request(t,"GET")}async createWorkflow(e){let t=`${this.config.baseUrl}${this.config.endpoints.create}`;return this.request(t,"POST",e)}async updateWorkflow(e,t){let a=`${this.config.baseUrl}${this.config.endpoints.update.replace(":id",e)}`;return this.request(a,"PUT",t)}},ne=class{static serialize(e,t,a){return JSON.stringify({nodes:e,edges:t,viewport:a})}static deserialize(e){try{let t=JSON.parse(e);return{nodes:t.nodes||[],edges:t.edges||[],viewport:t.viewport}}catch{return{nodes:[],edges:[]}}}},se=ne.serialize,le=ne.deserialize;function de(e){return{type:e.id,label:e.label,description:`Integration with ${e.label}`,category:e.category,icon:e.icon,color:e.color,handles:[{id:"in",type:"target"},{id:"out",type:"source"}],inputs:[{key:"auth_token",label:"API Key / Token",type:"text",placeholder:e.auth.placeholder||"Enter API Key"},{key:"operation",label:"Action",type:"select",options:e.operations.map(t=>({label:t.label,value:t.id}))}]}}var ee=[{id:"google-sheets",label:"Google Sheets",category:"utility",icon:"Sheet",color:"emerald",baseUrl:"https://sheets.googleapis.com/v4/spreadsheets",auth:{type:"bearer",placeholder:"OAuth Token"},operations:[{id:"append_row",label:"Append Row",method:"POST",path:"/{spreadsheetId}/values/{range}:append",inputs:[{key:"spreadsheetId",label:"Spreadsheet ID",type:"text"},{key:"range",label:"Range (Sheet1!A1)",type:"text"},{key:"values",label:"Row Values (JSON Array)",type:"json"}]},{id:"get_values",label:"Get Row(s)",method:"GET",path:"/{spreadsheetId}/values/{range}",inputs:[{key:"spreadsheetId",label:"Spreadsheet ID",type:"text"},{key:"range",label:"Range",type:"text"}]}]},{id:"slack-connector",label:"Slack API",category:"action",icon:"MessageSquare",color:"blue",baseUrl:"https://slack.com/api",auth:{type:"bearer",placeholder:"xoxb-..."},operations:[{id:"post_message",label:"Post Message",method:"POST",path:"/chat.postMessage",inputs:[{key:"channel",label:"Channel ID",type:"text"},{key:"text",label:"Message Text",type:"text"}]}]},{id:"openai",label:"OpenAI",category:"action",icon:"Bot",color:"zinc",baseUrl:"https://api.openai.com/v1",auth:{type:"bearer",placeholder:"sk-..."},operations:[{id:"chat_completion",label:"Chat Completion",method:"POST",path:"/chat/completions",inputs:[{key:"model",label:"Model",type:"select",options:[{label:"GPT-4o",value:"gpt-4o"},{label:"GPT-3.5",value:"gpt-3.5-turbo"}]},{key:"messages",label:"Messages (JSON)",type:"json"}]}]}];function mt(e){ee.push(e)}var gt=[{id:"triggers",nodes:[{type:"manual-trigger",label:"Manual Trigger",description:"Start flow on button click",category:"trigger",icon:"Play",color:"emerald",inputs:[]},{type:"cron-trigger",label:"Cron Schedule",description:"Trigger on a schedule",category:"trigger",icon:"Clock",color:"emerald",inputs:[{key:"expression",label:"Cron Expression",type:"text",placeholder:"0 9 * * 1 (Every Mon at 9am)"}]},{id:"github-trigger",label:"GitHub Trigger",category:"trigger",icon:"Github",color:"zinc",baseUrl:"https://api.github.com",auth:{type:"header",key:"X-GitHub-Token"},operations:[{id:"on_push",label:"On Push",method:"POST",path:"/repos/{owner}/{repo}/hooks",inputs:[{key:"owner",label:"Owner",type:"text"},{key:"repo",label:"Repository",type:"text"}]},{id:"on_star",label:"On New Star",method:"POST",path:"/repos/{owner}/{repo}/hooks",inputs:[{key:"owner",label:"Owner",type:"text"},{key:"repo",label:"Repository",type:"text"}]}]}]},{id:"logic",nodes:[{type:"switch",label:"Switch / Router",description:"Route based on value",category:"logic",icon:"GitFork",color:"orange",inputs:[{key:"property",label:"Property to Check",type:"text"},{key:"cases",label:"Cases (comma sep)",type:"text",placeholder:"marketing, sales, support"}]},{type:"ab-split",label:"A/B Split",description:"Randomly split traffic",category:"logic",icon:"Percent",color:"orange",inputs:[{key:"percentA",label:"Percentage for A",type:"text",placeholder:"50"}]},{type:"wait",label:"Wait / Delay",description:"Pause execution",category:"logic",icon:"Timer",color:"orange",inputs:[{key:"duration",label:"Duration",type:"text",placeholder:"5000"},{key:"unit",label:"Unit",type:"select",options:[{label:"Milliseconds",value:"ms"},{label:"Seconds",value:"s"}]}]}]},{id:"utilities",nodes:[{type:"text-transform",label:"Text Transform",description:"Modify text strings",category:"utility",icon:"Type",color:"zinc",inputs:[{key:"action",label:"Action",type:"select",options:[{label:"To Upper Case",value:"upper"},{label:"To Lower Case",value:"lower"},{label:"Trim",value:"trim"},{label:"Replace",value:"replace"}]},{key:"input",label:"Input Text",type:"text"}]},{type:"json-parser",label:"JSON Helper",description:"Parse or stringify JSON",category:"utility",icon:"Code",color:"zinc",inputs:[{key:"action",label:"Action",type:"select",options:[{label:"Parse (String to JSON)",value:"parse"},{label:"Stringify (JSON to String)",value:"stringify"}]},{key:"data",label:"Data",type:"json"}]},{type:"math-calc",label:"Math Calculator",description:"Perform calculations",category:"utility",icon:"Calculator",color:"zinc",inputs:[{key:"operation",label:"Operation",type:"select",options:[{label:"Add",value:"add"},{label:"Subtract",value:"sub"},{label:"Multiply",value:"mul"},{label:"Divide",value:"div"},{label:"Random Number",value:"random"}]},{key:"a",label:"Value A",type:"text"},{key:"b",label:"Value B",type:"text"}]},{type:"crypto",label:"Cryptography",description:"Hash or Encrypt data",category:"utility",icon:"Lock",color:"zinc",inputs:[{key:"algo",label:"Algorithm",type:"select",options:[{label:"MD5",value:"md5"},{label:"SHA-256",value:"sha256"},{label:"Base64 Encode",value:"base64_enc"},{label:"Base64 Decode",value:"base64_dec"}]},{key:"input",label:"value",type:"text"}]},{type:"date-time",label:"Date & Time",description:"Format or manipulate dates",category:"utility",icon:"Calendar",color:"zinc",inputs:[{key:"operation",label:"Action",type:"select",options:[{label:"Now (ISO)",value:"now"},{label:"Format Date",value:"format"},{label:"Add Time",value:"add"}]},{key:"date",label:"Date String",type:"text"},{key:"format",label:"Format Pattern",type:"text",placeholder:"YYYY-MM-DD"}]}]},{id:"integrations-productivity",nodes:[{id:"google-drive",label:"Google Drive",icon:"HardDrive",color:"blue",category:"action",baseUrl:"https://www.googleapis.com/drive/v3",auth:{type:"bearer",placeholder:"OAuth Token"},operations:[{id:"list",label:"List Files",method:"GET",path:"/files",inputs:[{key:"q",label:"Query",type:"text"}]},{id:"upload",label:"Upload File",method:"POST",path:"/files",inputs:[{key:"name",label:"Name",type:"text"},{key:"content",label:"Content",type:"text"}]}]},{id:"notion",label:"Notion",icon:"FileText",color:"zinc",category:"action",baseUrl:"https://api.notion.com/v1",auth:{type:"header",key:"Authorization",placeholder:"Bearer secret_..."},operations:[{id:"create_page",label:"Create Page",method:"POST",path:"/pages",inputs:[{key:"parent_id",label:"Parent DB ID",type:"text"},{key:"properties",label:"Properties JSON",type:"json"}]},{id:"query_db",label:"Query Database",method:"POST",path:"/databases/{id}/query",inputs:[{key:"id",label:"Database ID",type:"text"}]}]},{id:"airtable",label:"Airtable",icon:"Database",color:"amber",category:"action",baseUrl:"https://api.airtable.com/v0",auth:{type:"bearer",placeholder:"pat_..."},operations:[{id:"create_record",label:"Create Record",method:"POST",path:"/{baseId}/{tableId}",inputs:[{key:"baseId",label:"Base ID",type:"text"},{key:"tableId",label:"Table Name",type:"text"},{key:"fields",label:"Fields JSON",type:"json"}]},{id:"list_records",label:"List Records",method:"GET",path:"/{baseId}/{tableId}",inputs:[{key:"baseId",label:"Base ID",type:"text"},{key:"tableId",label:"Table Name",type:"text"}]}]}]},{id:"integrations-crm-marketing",nodes:[{id:"salesforce",label:"Salesforce",icon:"Cloud",color:"blue",category:"action",baseUrl:"https://{instance}.salesforce.com/services/data/vXX.X",auth:{type:"bearer"},operations:[{id:"create_lead",label:"Create Lead",method:"POST",path:"/sobjects/Lead",inputs:[{key:"instance",label:"Instance URL",type:"text"},{key:"LastName",label:"Last Name",type:"text"},{key:"Company",label:"Company",type:"text"}]}]},{id:"hubspot",label:"HubSpot",icon:"Users",color:"orange",category:"action",baseUrl:"https://api.hubapi.com",auth:{type:"bearer"},operations:[{id:"create_contact",label:"Create Contact",method:"POST",path:"/crm/v3/objects/contacts",inputs:[{key:"properties",label:"Properties JSON",type:"json"}]}]},{id:"mailchimp",label:"Mailchimp",icon:"Mail",color:"yellow",category:"action",baseUrl:"https://{dc}.api.mailchimp.com/3.0",auth:{type:"bearer"},operations:[{id:"add_member",label:"Add Subscriber",method:"POST",path:"/lists/{list_id}/members",inputs:[{key:"dc",label:"Data Center (usX)",type:"text"},{key:"list_id",label:"List ID",type:"text"},{key:"email_address",label:"Email",type:"text"},{key:"status",label:"Status",type:"select",options:[{label:"subscribed",value:"subscribed"}]}]}]}]},{id:"integrations-commerce",nodes:[{id:"shopify",label:"Shopify",icon:"ShoppingBag",color:"emerald",category:"action",baseUrl:"https://{shop}.myshopify.com/admin/api/2023-10",auth:{type:"header",key:"X-Shopify-Access-Token"},operations:[{id:"get_products",label:"Get Products",method:"GET",path:"/products.json",inputs:[{key:"shop",label:"Shop Name",type:"text"}]},{id:"create_order",label:"Create Order",method:"POST",path:"/orders.json",inputs:[{key:"shop",label:"Shop Name",type:"text"},{key:"order",label:"Order JSON",type:"json"}]}]},{id:"stripe",label:"Stripe",icon:"CreditCard",color:"indigo",category:"action",baseUrl:"https://api.stripe.com/v1",auth:{type:"bearer"},operations:[{id:"create_customer",label:"Create Customer",method:"POST",path:"/customers",inputs:[{key:"email",label:"Email",type:"text"}]},{id:"list_charges",label:"List Charges",method:"GET",path:"/charges",inputs:[{key:"limit",label:"Limit",type:"text"}]}]}]}];function yt(){gt.forEach(e=>{e.nodes.forEach(t=>{if(t.operations){let a={id:t.id,label:t.label,category:t.category,icon:t.icon,color:t.color,baseUrl:t.baseUrl,auth:t.auth,operations:t.operations};L[a.id]=de(a)}else{let a={type:t.type,label:t.label,description:t.description,category:t.category,icon:t.icon,color:t.color,handles:t.handles||[{id:"in",type:"target"},{id:"out",type:"source"}],inputs:t.inputs};L[a.type]=a}})})}var L={webhook:{type:"webhook",label:"Webhook",description:"Triggers when a URL is called",category:"trigger",icon:"Webhook",color:"emerald",handles:[{id:"out",type:"source"}],inputs:[{key:"method",label:"HTTP Method",type:"select",options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"}]},{key:"path",label:"Path",type:"text",placeholder:"/webhook/..."}]},schedule:{type:"schedule",label:"Schedule",description:"Triggers on a specific interval",category:"trigger",icon:"Clock",color:"emerald",handles:[{id:"out",type:"source"}],inputs:[{key:"interval",label:"Interval",type:"select",options:[{label:"Every Minute",value:"1m"},{label:"Every Hour",value:"1h"},{label:"Every Day",value:"1d"}]},{key:"cron",label:"Cron Expression",type:"text",placeholder:"* * * * *"}]},"http-request":{type:"http-request",label:"HTTP Request",description:"Make an external API call",category:"action",icon:"Globe",color:"blue",handles:[{id:"in",type:"target"},{id:"out",type:"source"}],inputs:[{key:"url",label:"URL",type:"text",placeholder:"https://api.example.com"},{key:"method",label:"Method",type:"select",options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"DELETE",value:"DELETE"}]},{key:"headers",label:"Headers",type:"json"},{key:"body",label:"Body",type:"json"}]},email:{type:"email",label:"Send Email",description:"Send an email to a recipient",category:"action",icon:"Mail",color:"blue",handles:[{id:"in",type:"target"},{id:"out",type:"source"}],inputs:[{key:"to",label:"To",type:"text"},{key:"subject",label:"Subject",type:"text"},{key:"body",label:"Body",type:"text"}]},slack:{type:"slack",label:"Slack (Simple)",description:"Send a message to a channel",category:"action",icon:"MessageSquare",color:"blue",handles:[{id:"in",type:"target"},{id:"out",type:"source"}],inputs:[{key:"webhookUrl",label:"Webhook URL",type:"text"},{key:"message",label:"Message",type:"text"}]},"if-else":{type:"if-else",label:"If / Else",description:"Branch flow based on condition",category:"logic",icon:"Split",color:"orange",handles:[{id:"in",type:"target"},{id:"true",type:"source",label:"True"},{id:"false",type:"source",label:"False"}],inputs:[{key:"condition",label:"Condition",type:"code",description:"Javascript expression returning true/false"}]},merge:{type:"merge",label:"Merge",description:"Combine multiple branches",category:"logic",icon:"GitMerge",color:"orange",handles:[{id:"in-a",type:"target",label:"A"},{id:"in-b",type:"target",label:"B"},{id:"out",type:"source"}],inputs:[]}};ee.forEach(e=>{L[e.id]=de(e)});yt();function ce(e){return ee.find(t=>t.id===e)}var Ne=require("react"),_=require("reactflow"),I=require("lucide-react");var xe=require("clsx"),ve=require("tailwind-merge");function W(...e){return(0,ve.twMerge)((0,xe.clsx)(e))}var l=require("lucide-react"),K={Sheet:l.Sheet,Bot:l.Bot,Type:l.Type,Code:l.Code,Calculator:l.Calculator,Timer:l.Timer,GitFork:l.GitFork,Percent:l.Percent,HardDrive:l.HardDrive,Calendar:l.Calendar,Play:l.Play,Github:l.Github,Lock:l.Lock,FileText:l.FileText,Database:l.Database,Cloud:l.Cloud,Users:l.Users,ShoppingBag:l.ShoppingBag,CreditCard:l.CreditCard};var z=require("react/jsx-runtime"),ht={Webhook:I.Webhook,Clock:I.Clock,Globe:I.Globe,Mail:I.Mail,MessageSquare:I.MessageSquare,Split:I.Split,GitMerge:I.GitMerge,Zap:I.Zap,...K},we={emerald:"text-emerald-600 bg-emerald-50 border-emerald-200",blue:"text-blue-600 bg-blue-50 border-blue-200",orange:"text-orange-600 bg-orange-50 border-orange-200",zinc:"text-zinc-600 bg-zinc-50 border-zinc-200"},ke={emerald:"ring-emerald-500/20",blue:"ring-blue-500/20",orange:"ring-orange-500/20",zinc:"ring-zinc-500/20"},pe=(0,Ne.memo)(({data:e,selected:t,type:a})=>{let i=L[e.type||a]||L.webhook;if(!i)return(0,z.jsxs)("div",{className:"p-2 border border-red-500 rounded bg-red-50 text-red-600",children:["Unknown Node Type: ",a]});let n=ht[i.icon]||I.Zap,p=we[i.color]||we.zinc,r=ke[i.color]||ke.zinc,h=e.executionStatus,m="";return h==="running"?m="ring-4 ring-indigo-500/30 border-indigo-500 shadow-lg shadow-indigo-200 animate-pulse":h==="success"?m="ring-4 ring-emerald-500/40 border-emerald-500 shadow-lg shadow-emerald-200":h==="error"&&(m="ring-4 ring-red-500/40 border-red-500 shadow-lg shadow-red-200"),(0,z.jsxs)("div",{className:W("min-w-[240px] bg-white rounded-lg shadow-sm border-2 transition-all duration-300",t?`border-indigo-500 shadow-xl ring-2 ${r}`:"border-zinc-200 hover:border-zinc-300",m),children:[(0,z.jsxs)("div",{className:W("flex items-center justify-between p-3 border-b border-zinc-100/50 rounded-t-md bg-zinc-50/50"),children:[(0,z.jsxs)("div",{className:"flex items-center gap-3",children:[(0,z.jsx)("div",{className:W("p-1.5 rounded-md border shadow-sm",p),children:(0,z.jsx)(n,{size:16,strokeWidth:2.5})}),(0,z.jsxs)("div",{children:[(0,z.jsx)("span",{className:"block text-xs font-bold uppercase tracking-wider text-zinc-500",children:i.category}),(0,z.jsx)("span",{className:"block text-sm font-semibold text-zinc-900 leading-none mt-0.5",children:i.label})]})]}),(0,z.jsx)("button",{className:"text-zinc-400 hover:text-zinc-600 transition-colors",children:(0,z.jsx)(I.MoreHorizontal,{size:16})})]}),(0,z.jsxs)("div",{className:"p-4 bg-white rounded-b-lg",children:[i.type==="http-request"&&(0,z.jsxs)("div",{className:"flex items-center gap-2 font-mono text-xs text-zinc-600 bg-zinc-50 p-2 rounded border border-zinc-100",children:[(0,z.jsx)("span",{className:"font-bold text-blue-600",children:e.method||"GET"}),(0,z.jsx)("span",{className:"truncate max-w-[140px]",children:e.url||"https://..."})]}),i.type==="webhook"&&(0,z.jsxs)("div",{className:"flex items-center gap-2 font-mono text-xs text-zinc-600",children:[(0,z.jsx)("span",{className:"font-bold text-emerald-600",children:e.method||"POST"}),(0,z.jsx)("span",{children:e.path||"/webhook/..."})]}),i.type==="if-else"&&(0,z.jsx)("div",{className:"text-xs font-mono text-orange-600 bg-orange-50 p-2 rounded border border-orange-100 truncate",children:e.condition||"x > 0"}),!["http-request","webhook","if-else"].includes(i.type)&&(0,z.jsx)("p",{className:"text-sm text-zinc-500",children:i.description})]}),i.handles.map(o=>{let f=o.type==="target"?_.Position.Left:_.Position.Right,v={};i.type==="if-else"&&o.type;let d=o.type==="source",s=i.handles.filter(P=>P.type===o.type).indexOf(o),w=i.handles.filter(P=>P.type===o.type).length,k=w>1?`${(s+1)*100/(w+1)}%`:"50%";return(0,z.jsx)(_.Handle,{id:o.id,type:o.type,position:d?_.Position.Right:_.Position.Left,style:{top:k,...v},className:W("!w-3 !h-3 !border-2 !border-white transition-all duration-200 bg-zinc-400 group-hover:bg-indigo-500",d?"-right-1.5":"-left-1.5",o.id==="true"?"!bg-emerald-500":o.id==="false"?"!bg-red-500":""),children:o.label&&(0,z.jsx)("span",{className:W("absolute text-[10px] uppercase font-bold text-zinc-500 pointer-events-none w-max block mb-1",d?"right-4 mr-1 text-right":"left-4 ml-1 text-left","top-1/2 -translate-y-1/2"),children:o.label})},o.id)})]})});var ze=require("react"),S=require("lucide-react"),b=require("react/jsx-runtime");function Ce({onSave:e,onExport:t,onImport:a,onAddNode:i,onAutoLayout:n,onClear:p,onRun:r,isSaving:h,isRunning:m,canUndo:o,canRedo:f,onUndo:v,onRedo:d}){let s=(0,ze.useRef)(null);return(0,b.jsxs)("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-50 flex items-center gap-1 p-1 bg-white/90 backdrop-blur-md border border-zinc-200/50 shadow-xl rounded-full",children:[(0,b.jsx)("input",{type:"file",ref:s,onChange:k=>{var J;let P=(J=k.target.files)==null?void 0:J[0];P&&a(P),s.current&&(s.current.value="")},accept:".json",className:"hidden"}),(0,b.jsxs)("div",{className:"flex items-center gap-1 px-1 border-r border-zinc-200",children:[(0,b.jsx)("button",{className:"p-2 text-zinc-500 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all",title:"Select",children:(0,b.jsx)(S.MousePointer2,{size:18})}),(0,b.jsx)("button",{onClick:i,className:"p-2 text-zinc-500 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all",title:"Add Node",children:(0,b.jsx)(S.Plus,{size:18})})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 px-1 border-r border-zinc-200",children:[(0,b.jsx)("button",{onClick:v,disabled:!o,className:"p-2 text-zinc-400 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all disabled:opacity-30 disabled:cursor-not-allowed",title:"Undo",children:(0,b.jsx)(S.Undo2,{size:18})}),(0,b.jsx)("button",{onClick:d,disabled:!f,className:"p-2 text-zinc-400 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all disabled:opacity-30 disabled:cursor-not-allowed",title:"Redo",children:(0,b.jsx)(S.Redo2,{size:18})})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 px-1 border-r border-zinc-200",children:[(0,b.jsx)("button",{onClick:n,className:"p-2 text-zinc-600 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all",title:"Auto Layout",children:(0,b.jsx)(S.Layout,{size:18})}),(0,b.jsx)("button",{onClick:p,className:"p-2 text-zinc-600 hover:text-red-600 hover:bg-red-50 rounded-full transition-all",title:"Clear Canvas",children:(0,b.jsx)(S.Trash2,{size:18})})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 px-1 border-r border-zinc-200",children:[(0,b.jsx)("button",{onClick:t,className:"p-2 text-zinc-600 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all",title:"Export JSON",children:(0,b.jsx)(S.Download,{size:18})}),(0,b.jsx)("button",{onClick:()=>{var k;return(k=s.current)==null?void 0:k.click()},className:"p-2 text-zinc-600 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all",title:"Import JSON",children:(0,b.jsx)(S.Upload,{size:18})})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 px-1",children:[(0,b.jsx)("button",{className:"flex items-center gap-2 px-3 py-2 bg-emerald-500 text-white rounded-full font-medium text-sm hover:bg-emerald-600 shadow-md shadow-emerald-200 transition-all mr-1",onClick:r,disabled:m,children:m?(0,b.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,b.jsx)(S.Play,{size:16,fill:"currentColor"})}),(0,b.jsxs)("button",{className:"flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-full font-medium text-sm hover:bg-indigo-700 shadow-md shadow-indigo-200 transition-all disabled:opacity-70 disabled:cursor-not-allowed",onClick:e,disabled:h,children:[h?(0,b.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,b.jsx)(S.Save,{size:16}),(0,b.jsx)("span",{children:"Save"})]})]})]})}var D=require("lucide-react"),Te=require("reactflow");function Se(e){if(!e.trim().toLowerCase().startsWith("curl"))return null;let t="GET",a={},i,n="",p=e.replace(/\\\n/g," ").replace(/\n/g," "),r=p.match(/'(http[^']*)'|"(http[^"]*)"|(http\S+)/);r&&(n=r[1]||r[2]||r[3]);let h=p.match(/-X\s+([A-Z]+)/);h&&(t=h[1]);let m=/-H\s+['"]([^'"]+)['"]/g,o;for(;(o=m.exec(p))!==null;){let[v,d]=o[1].split(/:\s?(.+)/);v&&d&&(a[v]=d)}let f=p.match(/(-d|--data|--data-raw)\s+['"]([^'"]+)['"]/);return f&&(i=f[2],t==="GET"&&(t="POST")),{method:t,url:n,headers:a,body:i}}var c=require("react/jsx-runtime");function Pe({selectedNodeId:e,selectedNodeType:t,onClose:a}){var d;let{setNodes:i,getNodes:n,deleteElements:p}=(0,Te.useReactFlow)();if(!e)return null;let r=n().find(s=>s.id===e);if(!r)return null;let h=((d=r.data)==null?void 0:d.type)||r.type||t,m=L[h],o=ce(h);if(o){m=JSON.parse(JSON.stringify(m));let s=r.data.operation;if(s){let w=o.operations.find(k=>k.id===s);w&&(m.inputs=[...m.inputs,...w.inputs])}}if(!m)return(0,c.jsxs)("div",{className:"absolute top-4 right-4 w-80 bg-white p-4 rounded shadow border border-red-200 z-50",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between text-red-600 mb-2",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)(D.AlertCircle,{size:16}),(0,c.jsx)("span",{className:"font-bold",children:"Unknown Node Type"})]}),(0,c.jsx)("button",{onClick:a,children:(0,c.jsx)(D.X,{size:16})})]}),(0,c.jsxs)("p",{className:"text-xs text-zinc-500 mt-1",children:["ID: ",h]})]});let f=(s,w)=>{i(k=>k.map(P=>P.id===e?{...P,data:{...P.data,[s]:w}}:P))},v=()=>{p({nodes:[{id:e}]}),a()};return(0,c.jsxs)("div",{className:"absolute top-4 right-4 bottom-4 w-80 bg-white/95 backdrop-blur-md border border-zinc-200 shadow-2xl rounded-xl z-50 flex flex-col overflow-hidden animate-in slide-in-from-right duration-200",children:[(0,c.jsxs)("div",{className:"p-4 border-b border-zinc-100 flex items-center justify-between bg-zinc-50/50",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 text-zinc-700 font-semibold",children:[(0,c.jsx)(D.Settings2,{size:16}),(0,c.jsxs)("span",{children:[m.label," Properties"]})]}),(0,c.jsxs)("div",{className:"flex items-center gap-1",children:[h==="http-request"&&(0,c.jsxs)("button",{onClick:()=>{let s=prompt("Paste your cURL command here:");if(s){let w=Se(s);w?i(k=>k.map(P=>P.id===e?{...P,data:{...P.data,method:w.method,url:w.url,headers:JSON.stringify(w.headers,null,2),body:w.body||"{}"}}:P)):alert("Could not parse cURL command.")}},className:"p-1.5 text-indigo-500 hover:text-indigo-700 hover:bg-indigo-50 rounded-md transition-colors flex items-center gap-1 text-xs font-medium mr-1",title:"Import cURL",children:[(0,c.jsx)(D.Import,{size:14}),(0,c.jsx)("span",{children:"Import cURL"})]}),(0,c.jsx)("button",{onClick:v,className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded-md transition-colors",title:"Delete Node",children:(0,c.jsx)(D.Trash2,{size:16})}),(0,c.jsx)("button",{onClick:a,className:"p-1.5 text-zinc-400 hover:text-zinc-700 hover:bg-zinc-100 rounded-md transition-colors",children:(0,c.jsx)(D.X,{size:16})})]})]}),(0,c.jsxs)("div",{className:"p-4 space-y-5 flex-1 overflow-y-auto",children:[(0,c.jsxs)("div",{className:"space-y-1 pb-4 border-b border-zinc-100",children:[(0,c.jsx)("label",{className:"text-xs font-bold uppercase tracking-wider text-zinc-400",children:"Description"}),(0,c.jsx)("p",{className:"text-sm text-zinc-600",children:m.description})]}),m.inputs.map(s=>{var w;return(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)("label",{className:"block text-xs font-bold uppercase tracking-wider text-zinc-500",children:s.label}),s.type==="text"&&(0,c.jsx)("input",{type:"text",value:r.data[s.key]||"",onChange:k=>f(s.key,k.target.value),placeholder:s.placeholder,className:"w-full px-3 py-2 bg-white border border-zinc-200 rounded-md text-sm text-zinc-800 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"}),s.type==="select"&&(0,c.jsxs)("select",{value:r.data[s.key]||"",onChange:k=>f(s.key,k.target.value),className:"w-full px-3 py-2 bg-white border border-zinc-200 rounded-md text-sm text-zinc-800 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all",children:[(0,c.jsx)("option",{value:"",disabled:!0,children:"Select..."}),(w=s.options)==null?void 0:w.map(k=>(0,c.jsx)("option",{value:k.value,children:k.label},k.value))]}),(s.type==="json"||s.type==="code")&&(0,c.jsx)("textarea",{value:typeof r.data[s.key]=="object"?JSON.stringify(r.data[s.key],null,2):r.data[s.key]||"",onChange:k=>f(s.key,k.target.value),rows:5,className:"w-full px-3 py-2 bg-white border border-zinc-200 rounded-md text-sm font-mono text-zinc-800 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all resize-y"})]},s.key)})]})]})}var te=require("react"),T=require("lucide-react");var y=require("react/jsx-runtime"),ft={Webhook:T.Zap,Clock:T.Clock,Globe:T.Globe,Mail:T.Mail,MessageSquare:T.MessageSquare,Split:T.Split,GitMerge:T.GitMerge,Zap:T.Zap,...K};function Re({isOpen:e,onClose:t,onSelect:a}){let[i,n]=(0,te.useState)(""),p=(0,te.useMemo)(()=>{let r={};Object.values(L).forEach(o=>{if(o.label.toLowerCase().includes(i.toLowerCase())||o.description&&o.description.toLowerCase().includes(i.toLowerCase())){let v=o.category||"other";r[v]||(r[v]=[]),r[v].push(o)}});let h=["trigger","logic","action","utility","integration"],m={};return h.forEach(o=>{r[o]&&(m[o]=r[o])}),Object.keys(r).forEach(o=>{h.includes(o)||(m[o]=r[o])}),m},[i]);return e?(0,y.jsxs)("div",{className:"absolute inset-0 z-[100] bg-black/20 backdrop-blur-sm flex items-start justify-center pt-20 animate-in fade-in duration-200",children:[(0,y.jsxs)("div",{className:"w-[600px] bg-white rounded-xl shadow-2xl border border-zinc-200 overflow-hidden flex flex-col max-h-[70vh] animate-in slide-in-from-bottom-4 duration-300",children:[(0,y.jsxs)("div",{className:"p-4 border-b border-zinc-100 flex items-center gap-3 bg-zinc-50/50",children:[(0,y.jsx)(T.Search,{className:"text-zinc-400",size:20}),(0,y.jsx)("input",{autoFocus:!0,type:"text",placeholder:"Search nodes...",className:"flex-1 bg-transparent border-none outline-none text-zinc-900 placeholder:text-zinc-400 text-lg",value:i,onChange:r=>n(r.target.value)}),(0,y.jsx)("div",{className:"px-2 py-1 bg-zinc-100 border border-zinc-200 rounded text-xs text-zinc-500 font-medium",children:"ESC"}),(0,y.jsx)("button",{onClick:t,className:"text-zinc-400 hover:text-zinc-700",children:(0,y.jsx)(T.X,{size:20})})]}),(0,y.jsxs)("div",{className:"overflow-y-auto p-4 space-y-2",children:[Object.entries(p).map(([r,h])=>{if(h.length===0)return null;let m=i.length>0;return(0,y.jsxs)("details",{open:!0,className:"group border border-zinc-200 rounded-lg bg-zinc-50/30 open:bg-white transition-all duration-200",children:[(0,y.jsxs)("summary",{className:"flex items-center justify-between p-3 cursor-pointer list-none text-zinc-600 font-medium hover:bg-zinc-50 select-none",children:[(0,y.jsxs)("div",{className:"flex items-center gap-2",children:[(0,y.jsx)("span",{className:"uppercase tracking-wider text-xs font-bold text-zinc-500",children:r}),(0,y.jsx)("span",{className:"text-xs bg-zinc-100 text-zinc-400 px-1.5 py-0.5 rounded-full",children:h.length})]}),(0,y.jsx)("div",{className:"text-zinc-400 group-open:rotate-180 transition-transform",children:(0,y.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,y.jsx)("path",{d:"m6 9 6 6 6-6"})})})]}),(0,y.jsx)("div",{className:"p-3 pt-0 border-t border-transparent group-open:border-zinc-100",children:(0,y.jsx)("div",{className:"grid grid-cols-2 gap-3 pt-2",children:h.map(o=>{let f=ft[o.icon]||K[o.icon]||T.Zap;return(0,y.jsxs)("button",{onClick:()=>a(o.type),className:"flex items-start gap-3 p-3 rounded-lg border border-zinc-100 bg-white hover:border-indigo-200 hover:shadow-md hover:bg-indigo-50/30 transition-all text-left group/btn",children:[(0,y.jsx)("div",{className:W("p-2 rounded-md transition-colors",`bg-${o.color}-50 text-${o.color}-600 group-hover/btn:bg-white`),children:(0,y.jsx)(f,{size:20})}),(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{className:"font-semibold text-zinc-900 text-sm",children:o.label}),(0,y.jsx)("div",{className:"text-xs text-zinc-500 line-clamp-2 leading-relaxed",children:o.description})]})]},o.type)})})})]},r)}),Object.values(p).every(r=>r.length===0)&&(0,y.jsx)("div",{className:"text-center py-12 text-zinc-400",children:(0,y.jsxs)("p",{children:['No nodes found matching "',i,'"']})})]})]}),(0,y.jsx)("div",{className:"absolute inset-0 -z-10",onClick:t})]}):null}var oe=require("react"),$=require("lucide-react");var B=require("react/jsx-runtime");function Ee({message:e,type:t,isVisible:a,onClose:i}){let[n,p]=(0,oe.useState)(!1);return(0,oe.useEffect)(()=>{if(a){p(!0);let r=setTimeout(()=>{i()},4e3);return()=>clearTimeout(r)}else setTimeout(()=>p(!1),300)},[a,i]),!n&&!a?null:(0,B.jsxs)("div",{className:W("absolute bottom-6 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-3 px-4 py-3 rounded-lg shadow-xl border transition-all duration-300 transform",t==="success"?"bg-white border-emerald-100 text-emerald-800":"bg-white border-red-100 text-red-800",a?"translate-y-0 opacity-100 scale-100":"translate-y-4 opacity-0 scale-95"),children:[t==="success"?(0,B.jsx)($.CheckCircle2,{size:20,className:"text-emerald-500"}):(0,B.jsx)($.AlertCircle,{size:20,className:"text-red-500"}),(0,B.jsx)("span",{className:"font-medium text-sm",children:e}),(0,B.jsx)("button",{onClick:i,className:"ml-2 hover:opacity-70",children:(0,B.jsx)($.X,{size:16,className:"text-zinc-400"})})]})}var We=require("reactflow");var ue=fe(require("dagre")),Y=require("reactflow"),X=new ue.default.graphlib.Graph;X.setDefaultEdgeLabel(()=>({}));var Ie=240,Oe=150,Me=(e,t,a="LR")=>{let i=a==="LR";return X.setGraph({rankdir:a}),e.forEach(p=>{X.setNode(p.id,{width:Ie,height:Oe})}),t.forEach(p=>{X.setEdge(p.source,p.target)}),ue.default.layout(X),{nodes:e.map(p=>{let r=X.node(p.id);return p.targetPosition=i?Y.Position.Left:Y.Position.Top,p.sourcePosition=i?Y.Position.Right:Y.Position.Bottom,p.position={x:r.x-Ie/2,y:r.y-Oe/2},p}),edges:t}};var q=require("react");function Le(e,t,a,i){let[n,p]=(0,q.useState)([{nodes:e,edges:t}]),[r,h]=(0,q.useState)(0),m=(0,q.useCallback)((v,d)=>{p(s=>{let w=s.slice(0,r+1);return w.push({nodes:v,edges:d}),w.length>50&&w.shift(),w}),h(s=>Math.min(s+1,50))},[r]),o=(0,q.useCallback)(()=>{if(r>0){let v=r-1,d=n[v];a(d.nodes),i(d.edges),h(v)}},[r,n,a,i]),f=(0,q.useCallback)(()=>{if(r<n.length-1){let v=r+1,d=n[v];a(d.nodes),i(d.edges),h(v)}},[r,n,a,i]);return{takeSnapshot:m,undo:o,redo:f,canUndo:r>0,canRedo:r<n.length-1}}function Ue(e,t){let a=[];if(e.length===0)return a.push({nodeId:"root",message:"Workflow is empty",severity:"warning"}),a;let i=new Set;return t.forEach(n=>{i.add(n.source),i.add(n.target)}),e.forEach(n=>{!i.has(n.id)&&e.length>1&&a.push({nodeId:n.id,message:"Node is disconnected",severity:"warning"}),n.type&&L[n.type],n.type==="http-request"&&(n.data.url||a.push({nodeId:n.id,field:"url",message:"URL is required",severity:"error"})),n.type}),a}var C=require("react/jsx-runtime"),De=[{id:"1",type:"webhook",position:{x:100,y:100},data:{method:"POST",path:"/start"}},{id:"2",type:"http-request",position:{x:100,y:300},data:{method:"POST",url:"https://api.example.com/data"}},{id:"3",type:"slack",position:{x:400,y:200},data:{message:"Workflow completed",webhookUrl:"https://hooks.slack.com/..."}}],Ae=[{id:"e1-2",source:"1",target:"2",type:"smoothstep",animated:!0,style:{stroke:"#6366f1",strokeWidth:2}},{id:"e2-3",source:"2",target:"3",type:"smoothstep",animated:!0,style:{stroke:"#6366f1",strokeWidth:2}}],be=e=>(0,C.jsx)(We.ReactFlowProvider,{children:(0,C.jsx)(xt,{...e})}),xt=({licenseKey:e,apiConfig:t,className:a,style:i})=>{let[n,p]=(0,x.useState)(null),[r,h]=(0,x.useState)(""),[m]=(0,x.useState)(()=>new re({licenseKey:e,widgetVersion:"1.0.0",validationEndpoint:"http://localhost:3000/api/v1/license/validate"})),[o,f,v]=(0,M.useNodesState)(De),[d,s,w]=(0,M.useEdgesState)(Ae),[k,P]=(0,x.useState)(!1),[J,ye]=(0,x.useState)(!1),[H,j]=(0,x.useState)(null),{takeSnapshot:U,undo:je,redo:Be,canUndo:Fe,canRedo:He}=Le(De,Ae,g=>f([...g]),g=>s([...g])),kt=(0,x.useCallback)(()=>{U(o,d)},[o,d,U]),[_e,Z]=(0,x.useState)(null),qe=(0,x.useMemo)(()=>{let g={custom:pe};return Object.keys(L).forEach(u=>{g[u]=pe}),g},[]);(0,x.useEffect)(()=>{async function g(){let u=await m.validate();p(u.valid),u.valid||h(u.reason||"Invalid License")}g()},[m]);let Je=(0,x.useCallback)(g=>{s(u=>{let N=(0,M.addEdge)({...g,type:"smoothstep",animated:!0,style:{stroke:"#6366f1",strokeWidth:2}},u);return U(o,N),N})},[s,o,U]),Ve=(0,x.useCallback)((g,u)=>{Z(u.id)},[]),$e=(0,x.useCallback)(()=>{Z(null)},[]),Xe=(0,x.useRef)(null),[G,Ke]=(0,x.useState)(null),[Ye,ae]=(0,x.useState)(!1),Ze=(0,x.useCallback)(g=>{let u=`node-${Date.now()}`,N={x:250,y:250};G&&(N={x:100+Math.random()*200,y:100+Math.random()*200});let R={id:u,type:g,position:N,data:{}},E=o.concat(R);f(E),U(E,d),ae(!1),Z(u)},[G,o,d,U,f]),Qe=(0,x.useCallback)(()=>{let{nodes:g,edges:u}=Me(o,d);f([...g]),s([...u]),U([...g],[...u]),setTimeout(()=>G==null?void 0:G.fitView(),100)},[o,d,f,s,U,G]),et=(0,x.useCallback)(()=>{confirm("Are you sure you want to clear the canvas?")&&(f([]),s([]),U([],[]))},[f,s,U]),tt=(0,x.useCallback)(async()=>{if(J)return;ye(!0),j(null);let g=o.map(N=>({...N,data:{...N.data,executionStatus:void 0}}));f(g);let u=(N,R)=>{f(E=>E.map(A=>A.id===N?{...A,data:{...A.data,executionStatus:R}}:A))};try{let N={};d.forEach(E=>{N[E.source]||(N[E.source]=[]),N[E.source].push(E.target)});let R=o.filter(E=>["webhook","schedule","connector"].includes(E.type||"")||d.every(A=>A.target!==E.id)).map(E=>E.id);if(R.length===0&&o.length>0&&R.push(o[0].id),R.length===0)throw new Error("No start node found");for(let E of R){u(E,"running"),await new Promise(V=>setTimeout(V,800)),u(E,"success");let A=N[E]||[];for(let V of A)u(V,"running"),await new Promise(it=>setTimeout(it,800)),u(V,"success")}j({message:"Execution completed successfully",type:"success"})}catch(N){j({message:N.message||"Execution Success",type:"success"})}finally{ye(!1)}},[o,d,J,f]),ot=async()=>{let g=Ue(o,d),u=g.filter(V=>V.severity==="error");if(u.length>0){j({message:`Cannot save: ${u[0].message}`,type:"error"});return}g.length>0&&j({message:`Saved with warnings: ${g[0].message}`,type:"success"}),P(!0);let N=new ie(t),R={nodes:o,edges:d},A=!!await N.createWorkflow(R);P(!1),j(A?{message:"Workflow saved successfully",type:"success"}:{message:"Failed to save workflow",type:"error"})},at=()=>{let g=se(o,d),u=new Blob([g],{type:"application/json"}),N=URL.createObjectURL(u),R=document.createElement("a");R.href=N,R.download=`workflow-${Date.now()}.json`,document.body.appendChild(R),R.click(),document.body.removeChild(R)},rt=async g=>{try{let u=await g.text(),{nodes:N,edges:R}=le(u);f(N),s(R),U(N,R),setTimeout(()=>{G==null||G.fitView({padding:.2})},50)}catch(u){alert("Failed to import workflow. Invalid file."),console.error(u)}};return n===null?(0,C.jsx)("div",{className:"flex items-center justify-center h-[600px] w-full bg-zinc-50 rounded-xl border border-zinc-200",children:(0,C.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,C.jsx)("div",{className:"w-6 h-6 border-2 border-indigo-600 border-t-transparent rounded-full animate-spin"}),(0,C.jsx)("p",{className:"text-zinc-500 text-sm font-medium",children:"Verifying License..."})]})}):(0,C.jsxs)("div",{style:i,className:`relative w-full h-[800px] rounded-xl border border-zinc-200 shadow-sm overflow-hidden bg-zinc-50/50 group ${a||""}`,children:[!n&&(0,C.jsxs)("div",{className:"absolute inset-0 z-50 bg-white/80 backdrop-blur-md flex flex-col items-center justify-center p-8 text-center",children:[(0,C.jsx)("div",{className:"w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4",children:(0,C.jsx)("div",{className:"w-8 h-8 text-red-600",children:"\u26A0\uFE0F"})}),(0,C.jsx)("h2",{className:"text-2xl font-bold text-zinc-900 mb-2",children:"License Verification Failed"}),(0,C.jsxs)("p",{className:"text-zinc-600 max-w-md",children:[r,". Please update your license key to access the builder."]})]}),(0,C.jsx)(Ce,{onSave:ot,onExport:at,onImport:rt,onAddNode:()=>ae(!0),onAutoLayout:Qe,onClear:et,onRun:tt,isSaving:k,isRunning:J,canUndo:Fe,canRedo:He,onUndo:je,onRedo:Be}),(0,C.jsx)(Pe,{selectedNodeId:_e||void 0,onClose:()=>Z(null)}),(0,C.jsx)(Re,{isOpen:Ye,onClose:()=>ae(!1),onSelect:Ze}),(0,C.jsx)(Ee,{message:(H==null?void 0:H.message)||"",type:(H==null?void 0:H.type)||"success",isVisible:!!H,onClose:()=>j(null)}),(0,C.jsx)("div",{className:"w-full h-full",ref:Xe,children:(0,C.jsxs)(M.default,{nodes:o,edges:d,onNodesChange:v,onEdgesChange:w,onConnect:Je,onNodeClick:Ve,onPaneClick:$e,onInit:Ke,nodeTypes:qe,fitView:!0,className:"bg-zinc-50",children:[(0,C.jsx)(M.Background,{variant:M.BackgroundVariant.Dots,gap:20,size:1,color:"#94a3b8",className:"bg-slate-50"}),(0,C.jsx)(M.Controls,{className:"!bg-white !border-slate-200 !shadow-xl !rounded-lg overflow-hidden [&>button]:!border-b-slate-100 [&>button]:!text-slate-600 hover:[&>button]:!bg-indigo-50 hover:[&>button]:!text-indigo-600 transition-colors"}),(0,C.jsx)(M.MiniMap,{className:"!bg-white !border-slate-200 !shadow-xl !rounded-lg !mb-8 !mr-8",maskColor:"rgba(241, 245, 249, 0.7)",nodeColor:g=>{var u;return(u=g.type)!=null&&u.includes("trigger")||g.type==="webhook"?"#818cf8":g.type==="action"?"#34d399":"#cbd5e1"},zoomable:!0,pannable:!0})]})})]})};var Ge=require("react/jsx-runtime");function me(e){return(0,Ge.jsx)(be,{...e})}var ge=require("react"),F=require("lucide-react");var O=require("react/jsx-runtime");function vt({licenseKey:e,apiConfig:t,position:a="bottom-right",themeColor:i="#2563eb"}){let[n,p]=(0,ge.useState)(!1),[r,h]=(0,ge.useState)(!1),m=()=>p(!n),o=()=>h(!r),f={position:"fixed",bottom:"20px",[a==="bottom-right"?"right":"left"]:"20px",zIndex:9999,display:"flex",flexDirection:"column",alignItems:a==="bottom-right"?"flex-end":"flex-start",gap:"10px"},v=r?{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"white",zIndex:1e4,boxShadow:"0 0 20px rgba(0,0,0,0.2)",display:"flex",flexDirection:"column"}:{width:"800px",height:"600px",backgroundColor:"white",borderRadius:"12px",boxShadow:"0 4px 20px rgba(0,0,0,0.15)",border:"1px solid #e5e7eb",display:"flex",flexDirection:"column",overflow:"hidden"};return n?(0,O.jsx)("div",{style:r?{position:"fixed",top:0,left:0,zIndex:1e4}:f,children:(0,O.jsxs)("div",{style:v,children:[(0,O.jsxs)("div",{style:{padding:"12px 16px",borderBottom:"1px solid #eee",display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"#f9fafb",color:"black"},children:[(0,O.jsx)("h3",{style:{margin:0,fontSize:"16px",fontWeight:600},children:"Workflow Builder"}),(0,O.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,O.jsx)("button",{onClick:o,style:{background:"none",border:"none",cursor:"pointer",padding:4},children:r?(0,O.jsx)(F.Minimize2,{size:18}):(0,O.jsx)(F.Maximize2,{size:18})}),(0,O.jsx)("button",{onClick:m,style:{background:"none",border:"none",cursor:"pointer",padding:4},children:(0,O.jsx)(F.X,{size:18})})]})]}),(0,O.jsx)("div",{style:{flex:1,position:"relative"},children:(0,O.jsx)(me,{licenseKey:e,apiConfig:t})})]})}):(0,O.jsx)("div",{style:f,children:(0,O.jsx)("button",{onClick:m,style:{width:"60px",height:"60px",borderRadius:"50%",backgroundColor:i,color:"white",border:"none",cursor:"pointer",boxShadow:"0 4px 12px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",justifyContent:"center",transition:"transform 0.2s"},onMouseEnter:d=>d.currentTarget.style.transform="scale(1.05)",onMouseLeave:d=>d.currentTarget.style.transform="scale(1)",children:(0,O.jsx)(F.Settings,{size:28})})})}0&&(module.exports={ApiClient,EmbeddableWidget,LicenseManager,WorkflowBuilder,WorkflowSerializer,WorkflowWidget,createConnectorNode,deserialize,getConnectorDetails,nodeRegistry,registerConnector,serialize,standardConnectors});
|
|
1
|
+
"use strict";var st=Object.create;var Q=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var ct=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var ut=(e,t)=>{for(var o in t)Q(e,o,{get:t[o],enumerable:!0})},fe=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of dt(t))!pt.call(e,s)&&s!==o&&Q(e,s,{get:()=>t[s],enumerable:!(r=lt(t,s))||r.enumerable});return e};var xe=(e,t,o)=>(o=e!=null?st(ct(e)):{},fe(t||!e||!e.__esModule?Q(o,"default",{value:e,enumerable:!0}):o,e)),bt=e=>fe(Q({},"__esModule",{value:!0}),e);var kt={};ut(kt,{ApiClient:()=>ne,EmbeddableWidget:()=>wt,LicenseManager:()=>ie,WorkflowBuilder:()=>me,WorkflowSerializer:()=>se,WorkflowWidget:()=>ge,createConnectorNode:()=>ce,deserialize:()=>de,getConnectorDetails:()=>pe,nodeRegistry:()=>M,registerConnector:()=>gt,serialize:()=>le,standardConnectors:()=>ee});module.exports=bt(kt);var w=require("react"),L=xe(require("reactflow")),go=require("reactflow/dist/style.css");var mt=typeof process!="undefined"&&process.env.NEXT_PUBLIC_LICENSE_VALIDATION_URL||"http://localhost:3000/api/v1/license/validate",ie=class{constructor(e){this.config=e,this.validationResult=null}async validate(){if(this.validationResult)return this.validationResult;try{let e=this.config.validationEndpoint||mt,t=await(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({licenseKey:this.config.licenseKey,widgetVersion:this.config.widgetVersion,originUrl:typeof window!="undefined"?window.location.origin:""})})).json();return this.validationResult=t,t}catch(e){return console.error("License validation failed",e),{valid:!1,reason:"Network Error"}}}isFeatureEnabled(e){var t,o;return(t=this.validationResult)!=null&&t.valid?!!((o=this.validationResult.features)!=null&&o[e]):!1}},ne=class{constructor(e){this.config=e}async request(e,t,o){let r={"Content-Type":"application/json",...this.config.headers},s=await fetch(e,{method:t,headers:r,body:o?JSON.stringify(o):void 0});if(!s.ok)throw new Error(`API Request failed: ${s.statusText}`);return s.json()}async getWorkflow(e){let t=`${this.config.baseUrl}${this.config.endpoints.get.replace(":id",e)}`;return this.request(t,"GET")}async createWorkflow(e){let t=`${this.config.baseUrl}${this.config.endpoints.create}`;return this.request(t,"POST",e)}async updateWorkflow(e,t){let o=`${this.config.baseUrl}${this.config.endpoints.update.replace(":id",e)}`;return this.request(o,"PUT",t)}},se=class{static serialize(e,t,o){return JSON.stringify({nodes:e,edges:t,viewport:o})}static deserialize(e){try{let t=JSON.parse(e);return{nodes:t.nodes||[],edges:t.edges||[],viewport:t.viewport}}catch{return{nodes:[],edges:[]}}}},le=se.serialize,de=se.deserialize;function ce(e){return{type:e.id,label:e.label,description:`Integration with ${e.label}`,category:e.category,icon:e.icon,color:e.color,handles:[{id:"in",type:"target"},{id:"out",type:"source"}],inputs:[{key:"auth_token",label:"API Key / Token",type:"text",placeholder:e.auth.placeholder||"Enter API Key"},{key:"operation",label:"Action",type:"select",options:e.operations.map(t=>({label:t.label,value:t.id}))}]}}var ee=[{id:"google-sheets",label:"Google Sheets",category:"utility",icon:"Sheet",color:"emerald",baseUrl:"https://sheets.googleapis.com/v4/spreadsheets",auth:{type:"bearer",placeholder:"OAuth Token"},operations:[{id:"append_row",label:"Append Row",method:"POST",path:"/{spreadsheetId}/values/{range}:append",inputs:[{key:"spreadsheetId",label:"Spreadsheet ID",type:"text"},{key:"range",label:"Range (Sheet1!A1)",type:"text"},{key:"values",label:"Row Values (JSON Array)",type:"json"}]},{id:"get_values",label:"Get Row(s)",method:"GET",path:"/{spreadsheetId}/values/{range}",inputs:[{key:"spreadsheetId",label:"Spreadsheet ID",type:"text"},{key:"range",label:"Range",type:"text"}]}]},{id:"slack-connector",label:"Slack API",category:"action",icon:"MessageSquare",color:"blue",baseUrl:"https://slack.com/api",auth:{type:"bearer",placeholder:"xoxb-..."},operations:[{id:"post_message",label:"Post Message",method:"POST",path:"/chat.postMessage",inputs:[{key:"channel",label:"Channel ID",type:"text"},{key:"text",label:"Message Text",type:"text"}]}]},{id:"openai",label:"OpenAI",category:"action",icon:"Bot",color:"zinc",baseUrl:"https://api.openai.com/v1",auth:{type:"bearer",placeholder:"sk-..."},operations:[{id:"chat_completion",label:"Chat Completion",method:"POST",path:"/chat/completions",inputs:[{key:"model",label:"Model",type:"select",options:[{label:"GPT-4o",value:"gpt-4o"},{label:"GPT-3.5",value:"gpt-3.5-turbo"}]},{key:"messages",label:"Messages (JSON)",type:"json"}]}]}];function gt(e){ee.push(e)}var yt=[{id:"triggers",nodes:[{type:"manual-trigger",label:"Manual Trigger",description:"Start flow on button click",category:"trigger",icon:"Play",color:"emerald",inputs:[]},{type:"cron-trigger",label:"Cron Schedule",description:"Trigger on a schedule",category:"trigger",icon:"Clock",color:"emerald",inputs:[{key:"expression",label:"Cron Expression",type:"text",placeholder:"0 9 * * 1 (Every Mon at 9am)"}]},{id:"github-trigger",label:"GitHub Trigger",category:"trigger",icon:"Github",color:"zinc",baseUrl:"https://api.github.com",auth:{type:"header",key:"X-GitHub-Token"},operations:[{id:"on_push",label:"On Push",method:"POST",path:"/repos/{owner}/{repo}/hooks",inputs:[{key:"owner",label:"Owner",type:"text"},{key:"repo",label:"Repository",type:"text"}]},{id:"on_star",label:"On New Star",method:"POST",path:"/repos/{owner}/{repo}/hooks",inputs:[{key:"owner",label:"Owner",type:"text"},{key:"repo",label:"Repository",type:"text"}]}]}]},{id:"logic",nodes:[{type:"switch",label:"Switch / Router",description:"Route based on value",category:"logic",icon:"GitFork",color:"orange",inputs:[{key:"property",label:"Property to Check",type:"text"},{key:"cases",label:"Cases (comma sep)",type:"text",placeholder:"marketing, sales, support"}]},{type:"ab-split",label:"A/B Split",description:"Randomly split traffic",category:"logic",icon:"Percent",color:"orange",inputs:[{key:"percentA",label:"Percentage for A",type:"text",placeholder:"50"}]},{type:"wait",label:"Wait / Delay",description:"Pause execution",category:"logic",icon:"Timer",color:"orange",inputs:[{key:"duration",label:"Duration",type:"text",placeholder:"5000"},{key:"unit",label:"Unit",type:"select",options:[{label:"Milliseconds",value:"ms"},{label:"Seconds",value:"s"}]}]}]},{id:"utilities",nodes:[{type:"text-transform",label:"Text Transform",description:"Modify text strings",category:"utility",icon:"Type",color:"zinc",inputs:[{key:"action",label:"Action",type:"select",options:[{label:"To Upper Case",value:"upper"},{label:"To Lower Case",value:"lower"},{label:"Trim",value:"trim"},{label:"Replace",value:"replace"}]},{key:"input",label:"Input Text",type:"text"}]},{type:"json-parser",label:"JSON Helper",description:"Parse or stringify JSON",category:"utility",icon:"Code",color:"zinc",inputs:[{key:"action",label:"Action",type:"select",options:[{label:"Parse (String to JSON)",value:"parse"},{label:"Stringify (JSON to String)",value:"stringify"}]},{key:"data",label:"Data",type:"json"}]},{type:"math-calc",label:"Math Calculator",description:"Perform calculations",category:"utility",icon:"Calculator",color:"zinc",inputs:[{key:"operation",label:"Operation",type:"select",options:[{label:"Add",value:"add"},{label:"Subtract",value:"sub"},{label:"Multiply",value:"mul"},{label:"Divide",value:"div"},{label:"Random Number",value:"random"}]},{key:"a",label:"Value A",type:"text"},{key:"b",label:"Value B",type:"text"}]},{type:"crypto",label:"Cryptography",description:"Hash or Encrypt data",category:"utility",icon:"Lock",color:"zinc",inputs:[{key:"algo",label:"Algorithm",type:"select",options:[{label:"MD5",value:"md5"},{label:"SHA-256",value:"sha256"},{label:"Base64 Encode",value:"base64_enc"},{label:"Base64 Decode",value:"base64_dec"}]},{key:"input",label:"value",type:"text"}]},{type:"date-time",label:"Date & Time",description:"Format or manipulate dates",category:"utility",icon:"Calendar",color:"zinc",inputs:[{key:"operation",label:"Action",type:"select",options:[{label:"Now (ISO)",value:"now"},{label:"Format Date",value:"format"},{label:"Add Time",value:"add"}]},{key:"date",label:"Date String",type:"text"},{key:"format",label:"Format Pattern",type:"text",placeholder:"YYYY-MM-DD"}]}]},{id:"integrations-productivity",nodes:[{id:"google-drive",label:"Google Drive",icon:"HardDrive",color:"blue",category:"action",baseUrl:"https://www.googleapis.com/drive/v3",auth:{type:"bearer",placeholder:"OAuth Token"},operations:[{id:"list",label:"List Files",method:"GET",path:"/files",inputs:[{key:"q",label:"Query",type:"text"}]},{id:"upload",label:"Upload File",method:"POST",path:"/files",inputs:[{key:"name",label:"Name",type:"text"},{key:"content",label:"Content",type:"text"}]}]},{id:"notion",label:"Notion",icon:"FileText",color:"zinc",category:"action",baseUrl:"https://api.notion.com/v1",auth:{type:"header",key:"Authorization",placeholder:"Bearer secret_..."},operations:[{id:"create_page",label:"Create Page",method:"POST",path:"/pages",inputs:[{key:"parent_id",label:"Parent DB ID",type:"text"},{key:"properties",label:"Properties JSON",type:"json"}]},{id:"query_db",label:"Query Database",method:"POST",path:"/databases/{id}/query",inputs:[{key:"id",label:"Database ID",type:"text"}]}]},{id:"airtable",label:"Airtable",icon:"Database",color:"amber",category:"action",baseUrl:"https://api.airtable.com/v0",auth:{type:"bearer",placeholder:"pat_..."},operations:[{id:"create_record",label:"Create Record",method:"POST",path:"/{baseId}/{tableId}",inputs:[{key:"baseId",label:"Base ID",type:"text"},{key:"tableId",label:"Table Name",type:"text"},{key:"fields",label:"Fields JSON",type:"json"}]},{id:"list_records",label:"List Records",method:"GET",path:"/{baseId}/{tableId}",inputs:[{key:"baseId",label:"Base ID",type:"text"},{key:"tableId",label:"Table Name",type:"text"}]}]}]},{id:"integrations-crm-marketing",nodes:[{id:"salesforce",label:"Salesforce",icon:"Cloud",color:"blue",category:"action",baseUrl:"https://{instance}.salesforce.com/services/data/vXX.X",auth:{type:"bearer"},operations:[{id:"create_lead",label:"Create Lead",method:"POST",path:"/sobjects/Lead",inputs:[{key:"instance",label:"Instance URL",type:"text"},{key:"LastName",label:"Last Name",type:"text"},{key:"Company",label:"Company",type:"text"}]}]},{id:"hubspot",label:"HubSpot",icon:"Users",color:"orange",category:"action",baseUrl:"https://api.hubapi.com",auth:{type:"bearer"},operations:[{id:"create_contact",label:"Create Contact",method:"POST",path:"/crm/v3/objects/contacts",inputs:[{key:"properties",label:"Properties JSON",type:"json"}]}]},{id:"mailchimp",label:"Mailchimp",icon:"Mail",color:"yellow",category:"action",baseUrl:"https://{dc}.api.mailchimp.com/3.0",auth:{type:"bearer"},operations:[{id:"add_member",label:"Add Subscriber",method:"POST",path:"/lists/{list_id}/members",inputs:[{key:"dc",label:"Data Center (usX)",type:"text"},{key:"list_id",label:"List ID",type:"text"},{key:"email_address",label:"Email",type:"text"},{key:"status",label:"Status",type:"select",options:[{label:"subscribed",value:"subscribed"}]}]}]}]},{id:"integrations-commerce",nodes:[{id:"shopify",label:"Shopify",icon:"ShoppingBag",color:"emerald",category:"action",baseUrl:"https://{shop}.myshopify.com/admin/api/2023-10",auth:{type:"header",key:"X-Shopify-Access-Token"},operations:[{id:"get_products",label:"Get Products",method:"GET",path:"/products.json",inputs:[{key:"shop",label:"Shop Name",type:"text"}]},{id:"create_order",label:"Create Order",method:"POST",path:"/orders.json",inputs:[{key:"shop",label:"Shop Name",type:"text"},{key:"order",label:"Order JSON",type:"json"}]}]},{id:"stripe",label:"Stripe",icon:"CreditCard",color:"indigo",category:"action",baseUrl:"https://api.stripe.com/v1",auth:{type:"bearer"},operations:[{id:"create_customer",label:"Create Customer",method:"POST",path:"/customers",inputs:[{key:"email",label:"Email",type:"text"}]},{id:"list_charges",label:"List Charges",method:"GET",path:"/charges",inputs:[{key:"limit",label:"Limit",type:"text"}]}]}]}];function ht(){yt.forEach(e=>{e.nodes.forEach(t=>{if(t.operations){let o={id:t.id,label:t.label,category:t.category,icon:t.icon,color:t.color,baseUrl:t.baseUrl,auth:t.auth,operations:t.operations};M[o.id]=ce(o)}else{let o={type:t.type,label:t.label,description:t.description,category:t.category,icon:t.icon,color:t.color,handles:t.handles||[{id:"in",type:"target"},{id:"out",type:"source"}],inputs:t.inputs};M[o.type]=o}})})}var M={webhook:{type:"webhook",label:"Webhook",description:"Triggers when a URL is called",category:"trigger",icon:"Webhook",color:"emerald",handles:[{id:"out",type:"source"}],inputs:[{key:"method",label:"HTTP Method",type:"select",options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"}]},{key:"path",label:"Path",type:"text",placeholder:"/webhook/..."}]},schedule:{type:"schedule",label:"Schedule",description:"Triggers on a specific interval",category:"trigger",icon:"Clock",color:"emerald",handles:[{id:"out",type:"source"}],inputs:[{key:"interval",label:"Interval",type:"select",options:[{label:"Every Minute",value:"1m"},{label:"Every Hour",value:"1h"},{label:"Every Day",value:"1d"}]},{key:"cron",label:"Cron Expression",type:"text",placeholder:"* * * * *"}]},"http-request":{type:"http-request",label:"HTTP Request",description:"Make an external API call",category:"action",icon:"Globe",color:"blue",handles:[{id:"in",type:"target"},{id:"out",type:"source"}],inputs:[{key:"url",label:"URL",type:"text",placeholder:"https://api.example.com"},{key:"method",label:"Method",type:"select",options:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"DELETE",value:"DELETE"}]},{key:"headers",label:"Headers",type:"json"},{key:"body",label:"Body",type:"json"}]},email:{type:"email",label:"Send Email",description:"Send an email to a recipient",category:"action",icon:"Mail",color:"blue",handles:[{id:"in",type:"target"},{id:"out",type:"source"}],inputs:[{key:"to",label:"To",type:"text"},{key:"subject",label:"Subject",type:"text"},{key:"body",label:"Body",type:"text"}]},slack:{type:"slack",label:"Slack (Simple)",description:"Send a message to a channel",category:"action",icon:"MessageSquare",color:"blue",handles:[{id:"in",type:"target"},{id:"out",type:"source"}],inputs:[{key:"webhookUrl",label:"Webhook URL",type:"text"},{key:"message",label:"Message",type:"text"}]},"if-else":{type:"if-else",label:"If / Else",description:"Branch flow based on condition",category:"logic",icon:"Split",color:"orange",handles:[{id:"in",type:"target"},{id:"true",type:"source",label:"True"},{id:"false",type:"source",label:"False"}],inputs:[{key:"condition",label:"Condition",type:"code",description:"Javascript expression returning true/false"}]},merge:{type:"merge",label:"Merge",description:"Combine multiple branches",category:"logic",icon:"GitMerge",color:"orange",handles:[{id:"in-a",type:"target",label:"A"},{id:"in-b",type:"target",label:"B"},{id:"out",type:"source"}],inputs:[]}};ee.forEach(e=>{M[e.id]=ce(e)});ht();function pe(e){return ee.find(t=>t.id===e)}var ze=require("react"),H=require("reactflow"),R=require("lucide-react");var ve=require("clsx"),we=require("tailwind-merge");function W(...e){return(0,we.twMerge)((0,ve.clsx)(e))}var l=require("lucide-react"),K={Sheet:l.Sheet,Bot:l.Bot,Type:l.Type,Code:l.Code,Calculator:l.Calculator,Timer:l.Timer,GitFork:l.GitFork,Percent:l.Percent,HardDrive:l.HardDrive,Calendar:l.Calendar,Play:l.Play,Github:l.Github,Lock:l.Lock,FileText:l.FileText,Database:l.Database,Cloud:l.Cloud,Users:l.Users,ShoppingBag:l.ShoppingBag,CreditCard:l.CreditCard};var z=require("react/jsx-runtime"),ft={Webhook:R.Webhook,Clock:R.Clock,Globe:R.Globe,Mail:R.Mail,MessageSquare:R.MessageSquare,Split:R.Split,GitMerge:R.GitMerge,Zap:R.Zap,...K},ke={emerald:"text-emerald-600 bg-emerald-50 border-emerald-200",blue:"text-blue-600 bg-blue-50 border-blue-200",orange:"text-orange-600 bg-orange-50 border-orange-200",zinc:"text-zinc-600 bg-zinc-50 border-zinc-200"},Ne={emerald:"ring-emerald-500/20",blue:"ring-blue-500/20",orange:"ring-orange-500/20",zinc:"ring-zinc-500/20"},ue=(0,ze.memo)(({data:e,selected:t,type:o})=>{let r=M[e.type||o]||M.webhook;if(!r)return(0,z.jsxs)("div",{className:"p-2 border border-red-500 rounded bg-red-50 text-red-600",children:["Unknown Node Type: ",o]});let s=ft[r.icon]||R.Zap,c=ke[r.color]||ke.zinc,a=Ne[r.color]||Ne.zinc,x=e.executionStatus,y="";return x==="running"?y="ring-4 ring-indigo-500/30 border-indigo-500 shadow-lg shadow-indigo-200 animate-pulse":x==="success"?y="ring-4 ring-emerald-500/40 border-emerald-500 shadow-lg shadow-emerald-200":x==="error"&&(y="ring-4 ring-red-500/40 border-red-500 shadow-lg shadow-red-200"),(0,z.jsxs)("div",{className:W("min-w-[240px] bg-white rounded-lg shadow-sm border-2 transition-all duration-300",t?`border-indigo-500 shadow-xl ring-2 ${a}`:"border-zinc-200 hover:border-zinc-300",y),children:[(0,z.jsxs)("div",{className:W("flex items-center justify-between p-3 border-b border-zinc-100/50 rounded-t-md bg-zinc-50/50"),children:[(0,z.jsxs)("div",{className:"flex items-center gap-3",children:[(0,z.jsx)("div",{className:W("p-1.5 rounded-md border shadow-sm",c),children:(0,z.jsx)(s,{size:16,strokeWidth:2.5})}),(0,z.jsxs)("div",{children:[(0,z.jsx)("span",{className:"block text-xs font-bold uppercase tracking-wider text-zinc-500",children:r.category}),(0,z.jsx)("span",{className:"block text-sm font-semibold text-zinc-900 leading-none mt-0.5",children:r.label})]})]}),(0,z.jsx)("button",{className:"text-zinc-400 hover:text-zinc-600 transition-colors",children:(0,z.jsx)(R.MoreHorizontal,{size:16})})]}),(0,z.jsxs)("div",{className:"p-4 bg-white rounded-b-lg",children:[r.type==="http-request"&&(0,z.jsxs)("div",{className:"flex items-center gap-2 font-mono text-xs text-zinc-600 bg-zinc-50 p-2 rounded border border-zinc-100",children:[(0,z.jsx)("span",{className:"font-bold text-blue-600",children:e.method||"GET"}),(0,z.jsx)("span",{className:"truncate max-w-[140px]",children:e.url||"https://..."})]}),r.type==="webhook"&&(0,z.jsxs)("div",{className:"flex items-center gap-2 font-mono text-xs text-zinc-600",children:[(0,z.jsx)("span",{className:"font-bold text-emerald-600",children:e.method||"POST"}),(0,z.jsx)("span",{children:e.path||"/webhook/..."})]}),r.type==="if-else"&&(0,z.jsx)("div",{className:"text-xs font-mono text-orange-600 bg-orange-50 p-2 rounded border border-orange-100 truncate",children:e.condition||"x > 0"}),!["http-request","webhook","if-else"].includes(r.type)&&(0,z.jsx)("p",{className:"text-sm text-zinc-500",children:r.description})]}),r.handles.map(i=>{let d=i.type==="target"?H.Position.Left:H.Position.Right,p={};r.type==="if-else"&&i.type;let v=i.type==="source",n=r.handles.filter(I=>I.type===i.type).indexOf(i),g=r.handles.filter(I=>I.type===i.type).length,k=g>1?`${(n+1)*100/(g+1)}%`:"50%";return(0,z.jsx)(H.Handle,{id:i.id,type:i.type,position:v?H.Position.Right:H.Position.Left,style:{top:k,...p},className:W("!w-3 !h-3 !border-2 !border-white transition-all duration-200 bg-zinc-400 group-hover:bg-indigo-500",v?"-right-1.5":"-left-1.5",i.id==="true"?"!bg-emerald-500":i.id==="false"?"!bg-red-500":""),children:i.label&&(0,z.jsx)("span",{className:W("absolute text-[10px] uppercase font-bold text-zinc-500 pointer-events-none w-max block mb-1",v?"right-4 mr-1 text-right":"left-4 ml-1 text-left","top-1/2 -translate-y-1/2"),children:i.label})},i.id)})]})});var Ce=require("react"),S=require("lucide-react"),m=require("react/jsx-runtime");function Se({onSave:e,onExport:t,onImport:o,onAddNode:r,onAutoLayout:s,onClear:c,onRun:a,isSaving:x,isRunning:y,canUndo:i,canRedo:d,onUndo:p,onRedo:v}){let n=(0,Ce.useRef)(null);return(0,m.jsxs)("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-50 flex items-center gap-1 p-1 bg-white/90 backdrop-blur-md border border-zinc-200/50 shadow-xl rounded-full",children:[(0,m.jsx)("input",{type:"file",ref:n,onChange:k=>{var X;let I=(X=k.target.files)==null?void 0:X[0];I&&o(I),n.current&&(n.current.value="")},accept:".json",className:"hidden"}),(0,m.jsxs)("div",{className:"flex items-center gap-1 px-1 border-r border-zinc-200",children:[(0,m.jsx)("button",{className:"p-2 text-zinc-500 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all",title:"Select",children:(0,m.jsx)(S.MousePointer2,{size:18})}),(0,m.jsx)("button",{onClick:r,className:"p-2 text-zinc-500 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all",title:"Add Node",children:(0,m.jsx)(S.Plus,{size:18})})]}),(0,m.jsxs)("div",{className:"flex items-center gap-1 px-1 border-r border-zinc-200",children:[(0,m.jsx)("button",{onClick:p,disabled:!i,className:"p-2 text-zinc-400 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all disabled:opacity-30 disabled:cursor-not-allowed",title:"Undo",children:(0,m.jsx)(S.Undo2,{size:18})}),(0,m.jsx)("button",{onClick:v,disabled:!d,className:"p-2 text-zinc-400 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all disabled:opacity-30 disabled:cursor-not-allowed",title:"Redo",children:(0,m.jsx)(S.Redo2,{size:18})})]}),(0,m.jsxs)("div",{className:"flex items-center gap-1 px-1 border-r border-zinc-200",children:[(0,m.jsx)("button",{onClick:s,className:"p-2 text-zinc-600 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all",title:"Auto Layout",children:(0,m.jsx)(S.Layout,{size:18})}),(0,m.jsx)("button",{onClick:c,className:"p-2 text-zinc-600 hover:text-red-600 hover:bg-red-50 rounded-full transition-all",title:"Clear Canvas",children:(0,m.jsx)(S.Trash2,{size:18})})]}),(0,m.jsxs)("div",{className:"flex items-center gap-1 px-1 border-r border-zinc-200",children:[(0,m.jsx)("button",{onClick:t,className:"p-2 text-zinc-600 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all",title:"Export JSON",children:(0,m.jsx)(S.Download,{size:18})}),(0,m.jsx)("button",{onClick:()=>{var k;return(k=n.current)==null?void 0:k.click()},className:"p-2 text-zinc-600 hover:text-zinc-900 hover:bg-zinc-100 rounded-full transition-all",title:"Import JSON",children:(0,m.jsx)(S.Upload,{size:18})})]}),(0,m.jsxs)("div",{className:"flex items-center gap-1 px-1",children:[(0,m.jsx)("button",{className:"flex items-center gap-2 px-3 py-2 bg-emerald-500 text-white rounded-full font-medium text-sm hover:bg-emerald-600 shadow-md shadow-emerald-200 transition-all mr-1",onClick:a,disabled:y,children:y?(0,m.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,m.jsx)(S.Play,{size:16,fill:"currentColor"})}),(0,m.jsxs)("button",{className:"flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-full font-medium text-sm hover:bg-indigo-700 shadow-md shadow-indigo-200 transition-all disabled:opacity-70 disabled:cursor-not-allowed",onClick:e,disabled:x,children:[x?(0,m.jsx)("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):(0,m.jsx)(S.Save,{size:16}),(0,m.jsx)("span",{children:"Save"})]})]})]})}var D=require("lucide-react"),Pe=require("reactflow");function Te(e){if(!e.trim().toLowerCase().startsWith("curl"))return null;let t="GET",o={},r,s="",c=e.replace(/\\\n/g," ").replace(/\n/g," "),a=c.match(/'(http[^']*)'|"(http[^"]*)"|(http\S+)/);a&&(s=a[1]||a[2]||a[3]);let x=c.match(/-X\s+([A-Z]+)/);x&&(t=x[1]);let y=/-H\s+['"]([^'"]+)['"]/g,i;for(;(i=y.exec(c))!==null;){let[p,v]=i[1].split(/:\s?(.+)/);p&&v&&(o[p]=v)}let d=c.match(/(-d|--data|--data-raw)\s+['"]([^'"]+)['"]/);return d&&(r=d[2],t==="GET"&&(t="POST")),{method:t,url:s,headers:o,body:r}}var u=require("react/jsx-runtime");function Ee({selectedNodeId:e,selectedNodeType:t,onClose:o}){var v;let{setNodes:r,getNodes:s,deleteElements:c}=(0,Pe.useReactFlow)();if(!e)return null;let a=s().find(n=>n.id===e);if(!a)return null;let x=((v=a.data)==null?void 0:v.type)||a.type||t,y=M[x],i=pe(x);if(i){y=JSON.parse(JSON.stringify(y));let n=a.data.operation;if(n){let g=i.operations.find(k=>k.id===n);g&&(y.inputs=[...y.inputs,...g.inputs])}}if(!y)return(0,u.jsxs)("div",{className:"absolute top-4 right-4 w-80 bg-white p-4 rounded shadow border border-red-200 z-50",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between text-red-600 mb-2",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(D.AlertCircle,{size:16}),(0,u.jsx)("span",{className:"font-bold",children:"Unknown Node Type"})]}),(0,u.jsx)("button",{onClick:o,children:(0,u.jsx)(D.X,{size:16})})]}),(0,u.jsxs)("p",{className:"text-xs text-zinc-500 mt-1",children:["ID: ",x]})]});let d=(n,g)=>{r(k=>k.map(I=>I.id===e?{...I,data:{...I.data,[n]:g}}:I))},p=()=>{c({nodes:[{id:e}]}),o()};return(0,u.jsxs)("div",{className:"absolute top-4 right-4 bottom-4 w-80 bg-white/95 backdrop-blur-md border border-zinc-200 shadow-2xl rounded-xl z-50 flex flex-col overflow-hidden animate-in slide-in-from-right duration-200",children:[(0,u.jsxs)("div",{className:"p-4 border-b border-zinc-100 flex items-center justify-between bg-zinc-50/50",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 text-zinc-700 font-semibold",children:[(0,u.jsx)(D.Settings2,{size:16}),(0,u.jsxs)("span",{children:[y.label," Properties"]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[x==="http-request"&&(0,u.jsxs)("button",{onClick:()=>{let n=prompt("Paste your cURL command here:");if(n){let g=Te(n);g?r(k=>k.map(I=>I.id===e?{...I,data:{...I.data,method:g.method,url:g.url,headers:JSON.stringify(g.headers,null,2),body:g.body||"{}"}}:I)):alert("Could not parse cURL command.")}},className:"p-1.5 text-indigo-500 hover:text-indigo-700 hover:bg-indigo-50 rounded-md transition-colors flex items-center gap-1 text-xs font-medium mr-1",title:"Import cURL",children:[(0,u.jsx)(D.Import,{size:14}),(0,u.jsx)("span",{children:"Import cURL"})]}),(0,u.jsx)("button",{onClick:p,className:"p-1.5 text-red-400 hover:text-red-600 hover:bg-red-50 rounded-md transition-colors",title:"Delete Node",children:(0,u.jsx)(D.Trash2,{size:16})}),(0,u.jsx)("button",{onClick:o,className:"p-1.5 text-zinc-400 hover:text-zinc-700 hover:bg-zinc-100 rounded-md transition-colors",children:(0,u.jsx)(D.X,{size:16})})]})]}),(0,u.jsxs)("div",{className:"p-4 space-y-5 flex-1 overflow-y-auto",children:[(0,u.jsxs)("div",{className:"space-y-1 pb-4 border-b border-zinc-100",children:[(0,u.jsx)("label",{className:"text-xs font-bold uppercase tracking-wider text-zinc-400",children:"Description"}),(0,u.jsx)("p",{className:"text-sm text-zinc-600",children:y.description})]}),y.inputs.map(n=>{var g;return(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("label",{className:"block text-xs font-bold uppercase tracking-wider text-zinc-500",children:n.label}),n.type==="text"&&(0,u.jsx)("input",{type:"text",value:a.data[n.key]||"",onChange:k=>d(n.key,k.target.value),placeholder:n.placeholder,className:"w-full px-3 py-2 bg-white border border-zinc-200 rounded-md text-sm text-zinc-800 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all"}),n.type==="select"&&(0,u.jsxs)("select",{value:a.data[n.key]||"",onChange:k=>d(n.key,k.target.value),className:"w-full px-3 py-2 bg-white border border-zinc-200 rounded-md text-sm text-zinc-800 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all",children:[(0,u.jsx)("option",{value:"",disabled:!0,children:"Select..."}),(g=n.options)==null?void 0:g.map(k=>(0,u.jsx)("option",{value:k.value,children:k.label},k.value))]}),(n.type==="json"||n.type==="code")&&(0,u.jsx)("textarea",{value:typeof a.data[n.key]=="object"?JSON.stringify(a.data[n.key],null,2):a.data[n.key]||"",onChange:k=>d(n.key,k.target.value),rows:5,className:"w-full px-3 py-2 bg-white border border-zinc-200 rounded-md text-sm font-mono text-zinc-800 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all resize-y"})]},n.key)})]})]})}var te=require("react"),T=require("lucide-react");var f=require("react/jsx-runtime"),xt={Webhook:T.Zap,Clock:T.Clock,Globe:T.Globe,Mail:T.Mail,MessageSquare:T.MessageSquare,Split:T.Split,GitMerge:T.GitMerge,Zap:T.Zap,...K};function Re({isOpen:e,onClose:t,onSelect:o}){let[r,s]=(0,te.useState)(""),c=(0,te.useMemo)(()=>{let a={};Object.values(M).forEach(i=>{if(i.label.toLowerCase().includes(r.toLowerCase())||i.description&&i.description.toLowerCase().includes(r.toLowerCase())){let p=i.category||"other";a[p]||(a[p]=[]),a[p].push(i)}});let x=["trigger","logic","action","utility","integration"],y={};return x.forEach(i=>{a[i]&&(y[i]=a[i])}),Object.keys(a).forEach(i=>{x.includes(i)||(y[i]=a[i])}),y},[r]);return e?(0,f.jsxs)("div",{className:"absolute inset-0 z-[100] bg-black/20 backdrop-blur-sm flex items-start justify-center pt-20 animate-in fade-in duration-200",children:[(0,f.jsxs)("div",{className:"w-[600px] bg-white rounded-xl shadow-2xl border border-zinc-200 overflow-hidden flex flex-col max-h-[70vh] animate-in slide-in-from-bottom-4 duration-300",children:[(0,f.jsxs)("div",{className:"p-4 border-b border-zinc-100 flex items-center gap-3 bg-zinc-50/50",children:[(0,f.jsx)(T.Search,{className:"text-zinc-400",size:20}),(0,f.jsx)("input",{autoFocus:!0,type:"text",placeholder:"Search nodes...",className:"flex-1 bg-transparent border-none outline-none text-zinc-900 placeholder:text-zinc-400 text-lg",value:r,onChange:a=>s(a.target.value)}),(0,f.jsx)("div",{className:"px-2 py-1 bg-zinc-100 border border-zinc-200 rounded text-xs text-zinc-500 font-medium",children:"ESC"}),(0,f.jsx)("button",{onClick:t,className:"text-zinc-400 hover:text-zinc-700",children:(0,f.jsx)(T.X,{size:20})})]}),(0,f.jsxs)("div",{className:"overflow-y-auto p-4 space-y-2",children:[Object.entries(c).map(([a,x])=>{if(x.length===0)return null;let y=r.length>0;return(0,f.jsxs)("details",{open:!0,className:"group border border-zinc-200 rounded-lg bg-zinc-50/30 open:bg-white transition-all duration-200",children:[(0,f.jsxs)("summary",{className:"flex items-center justify-between p-3 cursor-pointer list-none text-zinc-600 font-medium hover:bg-zinc-50 select-none",children:[(0,f.jsxs)("div",{className:"flex items-center gap-2",children:[(0,f.jsx)("span",{className:"uppercase tracking-wider text-xs font-bold text-zinc-500",children:a}),(0,f.jsx)("span",{className:"text-xs bg-zinc-100 text-zinc-400 px-1.5 py-0.5 rounded-full",children:x.length})]}),(0,f.jsx)("div",{className:"text-zinc-400 group-open:rotate-180 transition-transform",children:(0,f.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,f.jsx)("path",{d:"m6 9 6 6 6-6"})})})]}),(0,f.jsx)("div",{className:"p-3 pt-0 border-t border-transparent group-open:border-zinc-100",children:(0,f.jsx)("div",{className:"grid grid-cols-2 gap-3 pt-2",children:x.map(i=>{let d=xt[i.icon]||K[i.icon]||T.Zap;return(0,f.jsxs)("button",{onClick:()=>o(i.type),className:"flex items-start gap-3 p-3 rounded-lg border border-zinc-100 bg-white hover:border-indigo-200 hover:shadow-md hover:bg-indigo-50/30 transition-all text-left group/btn",children:[(0,f.jsx)("div",{className:W("p-2 rounded-md transition-colors",`bg-${i.color}-50 text-${i.color}-600 group-hover/btn:bg-white`),children:(0,f.jsx)(d,{size:20})}),(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"font-semibold text-zinc-900 text-sm",children:i.label}),(0,f.jsx)("div",{className:"text-xs text-zinc-500 line-clamp-2 leading-relaxed",children:i.description})]})]},i.type)})})})]},a)}),Object.values(c).every(a=>a.length===0)&&(0,f.jsx)("div",{className:"text-center py-12 text-zinc-400",children:(0,f.jsxs)("p",{children:['No nodes found matching "',r,'"']})})]})]}),(0,f.jsx)("div",{className:"absolute inset-0 -z-10",onClick:t})]}):null}var oe=require("react"),V=require("lucide-react");var B=require("react/jsx-runtime");function Ie({message:e,type:t,isVisible:o,onClose:r}){let[s,c]=(0,oe.useState)(!1);return(0,oe.useEffect)(()=>{if(o){c(!0);let a=setTimeout(()=>{r()},4e3);return()=>clearTimeout(a)}else setTimeout(()=>c(!1),300)},[o,r]),!s&&!o?null:(0,B.jsxs)("div",{className:W("absolute bottom-6 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-3 px-4 py-3 rounded-lg shadow-xl border transition-all duration-300 transform",t==="success"?"bg-white border-emerald-100 text-emerald-800":"bg-white border-red-100 text-red-800",o?"translate-y-0 opacity-100 scale-100":"translate-y-4 opacity-0 scale-95"),children:[t==="success"?(0,B.jsx)(V.CheckCircle2,{size:20,className:"text-emerald-500"}):(0,B.jsx)(V.AlertCircle,{size:20,className:"text-red-500"}),(0,B.jsx)("span",{className:"font-medium text-sm",children:e}),(0,B.jsx)("button",{onClick:r,className:"ml-2 hover:opacity-70",children:(0,B.jsx)(V.X,{size:16,className:"text-zinc-400"})})]})}var Ge=require("reactflow");var be=xe(require("dagre")),Y=require("reactflow"),$=new be.default.graphlib.Graph;$.setDefaultEdgeLabel(()=>({}));var Oe=240,Le=150,Me=(e,t,o="LR")=>{let r=o==="LR";return $.setGraph({rankdir:o}),e.forEach(c=>{$.setNode(c.id,{width:Oe,height:Le})}),t.forEach(c=>{$.setEdge(c.source,c.target)}),be.default.layout($),{nodes:e.map(c=>{let a=$.node(c.id);return c.targetPosition=r?Y.Position.Left:Y.Position.Top,c.sourcePosition=r?Y.Position.Right:Y.Position.Bottom,c.position={x:a.x-Oe/2,y:a.y-Le/2},c}),edges:t}};var q=require("react");function Ue(e,t,o,r){let[s,c]=(0,q.useState)([{nodes:e,edges:t}]),[a,x]=(0,q.useState)(0),y=(0,q.useCallback)((p,v)=>{c(n=>{let g=n.slice(0,a+1);return g.push({nodes:p,edges:v}),g.length>50&&g.shift(),g}),x(n=>Math.min(n+1,50))},[a]),i=(0,q.useCallback)(()=>{if(a>0){let p=a-1,v=s[p];o(v.nodes),r(v.edges),x(p)}},[a,s,o,r]),d=(0,q.useCallback)(()=>{if(a<s.length-1){let p=a+1,v=s[p];o(v.nodes),r(v.edges),x(p)}},[a,s,o,r]);return{takeSnapshot:y,undo:i,redo:d,canUndo:a>0,canRedo:a<s.length-1}}function De(e,t){let o=[];if(e.length===0)return o.push({nodeId:"root",message:"Workflow is empty",severity:"warning"}),o;let r=new Set;return t.forEach(s=>{r.add(s.source),r.add(s.target)}),e.forEach(s=>{!r.has(s.id)&&e.length>1&&o.push({nodeId:s.id,message:"Node is disconnected",severity:"warning"}),s.type&&M[s.type],s.type==="http-request"&&(s.data.url||o.push({nodeId:s.id,field:"url",message:"URL is required",severity:"error"})),s.type}),o}var C=require("react/jsx-runtime"),Ae=[{id:"1",type:"webhook",position:{x:100,y:100},data:{method:"POST",path:"/start"}},{id:"2",type:"http-request",position:{x:100,y:300},data:{method:"POST",url:"https://api.example.com/data"}},{id:"3",type:"slack",position:{x:400,y:200},data:{message:"Workflow completed",webhookUrl:"https://hooks.slack.com/..."}}],We=[{id:"e1-2",source:"1",target:"2",type:"smoothstep",animated:!0,style:{stroke:"#6366f1",strokeWidth:2}},{id:"e2-3",source:"2",target:"3",type:"smoothstep",animated:!0,style:{stroke:"#6366f1",strokeWidth:2}}],me=e=>(0,C.jsx)(Ge.ReactFlowProvider,{children:(0,C.jsx)(vt,{...e})}),vt=({licenseKey:e,apiConfig:t,validationEndpoint:o,className:r,style:s})=>{let[c,a]=(0,w.useState)(null),[x,y]=(0,w.useState)(""),[i]=(0,w.useState)(()=>new ie({licenseKey:e,widgetVersion:"1.0.0",validationEndpoint:o||process.env.NEXT_PUBLIC_LICENSE_VALIDATION_URL||"http://localhost:3000/api/v1/license/validate"})),[d,p,v]=(0,L.useNodesState)(Ae),[n,g,k]=(0,L.useEdgesState)(We),[I,X]=(0,w.useState)(!1),[ae,he]=(0,w.useState)(!1),[F,_]=(0,w.useState)(null),{takeSnapshot:U,undo:Be,redo:je,canUndo:Fe,canRedo:He}=Ue(Ae,We,h=>p([...h]),h=>g([...h])),Nt=(0,w.useCallback)(()=>{U(d,n)},[d,n,U]),[qe,Z]=(0,w.useState)(null),Je=(0,w.useMemo)(()=>{let h={custom:ue};return Object.keys(M).forEach(b=>{h[b]=ue}),h},[]);(0,w.useEffect)(()=>{async function h(){let b=await i.validate();a(b.valid),b.valid||y(b.reason||"Invalid License")}h()},[i]);let Ve=(0,w.useCallback)(h=>{g(b=>{let N=(0,L.addEdge)({...h,type:"smoothstep",animated:!0,style:{stroke:"#6366f1",strokeWidth:2}},b);return U(d,N),N})},[g,d,U]),$e=(0,w.useCallback)((h,b)=>{Z(b.id)},[]),Xe=(0,w.useCallback)(()=>{Z(null)},[]),Ke=(0,w.useRef)(null),[G,Ye]=(0,w.useState)(null),[Ze,re]=(0,w.useState)(!1),Qe=(0,w.useCallback)(h=>{let b=`node-${Date.now()}`,N={x:250,y:250};G&&(N={x:100+Math.random()*200,y:100+Math.random()*200});let P={id:b,type:h,position:N,data:{}},E=d.concat(P);p(E),U(E,n),re(!1),Z(b)},[G,d,n,U,p]),et=(0,w.useCallback)(()=>{let{nodes:h,edges:b}=Me(d,n);p([...h]),g([...b]),U([...h],[...b]),setTimeout(()=>G==null?void 0:G.fitView(),100)},[d,n,p,g,U,G]),tt=(0,w.useCallback)(()=>{confirm("Are you sure you want to clear the canvas?")&&(p([]),g([]),U([],[]))},[p,g,U]),ot=(0,w.useCallback)(async()=>{if(ae)return;he(!0),_(null);let h=d.map(N=>({...N,data:{...N.data,executionStatus:void 0}}));p(h);let b=(N,P)=>{p(E=>E.map(A=>A.id===N?{...A,data:{...A.data,executionStatus:P}}:A))};try{let N={};n.forEach(E=>{N[E.source]||(N[E.source]=[]),N[E.source].push(E.target)});let P=d.filter(E=>["webhook","schedule","connector"].includes(E.type||"")||n.every(A=>A.target!==E.id)).map(E=>E.id);if(P.length===0&&d.length>0&&P.push(d[0].id),P.length===0)throw new Error("No start node found");for(let E of P){b(E,"running"),await new Promise(J=>setTimeout(J,800)),b(E,"success");let A=N[E]||[];for(let J of A)b(J,"running"),await new Promise(nt=>setTimeout(nt,800)),b(J,"success")}_({message:"Execution completed successfully",type:"success"})}catch(N){_({message:N.message||"Execution Success",type:"success"})}finally{he(!1)}},[d,n,ae,p]),at=async()=>{let h=De(d,n),b=h.filter(J=>J.severity==="error");if(b.length>0){_({message:`Cannot save: ${b[0].message}`,type:"error"});return}h.length>0&&_({message:`Saved with warnings: ${h[0].message}`,type:"success"}),X(!0);let N=new ne({...t,baseUrl:t.baseUrl||process.env.NEXT_PUBLIC_WIDGET_API_URL||""}),P={nodes:d,edges:n},A=!!await N.createWorkflow(P);X(!1),_(A?{message:"Workflow saved successfully",type:"success"}:{message:"Failed to save workflow",type:"error"})},rt=()=>{let h=le(d,n),b=new Blob([h],{type:"application/json"}),N=URL.createObjectURL(b),P=document.createElement("a");P.href=N,P.download=`workflow-${Date.now()}.json`,document.body.appendChild(P),P.click(),document.body.removeChild(P)},it=async h=>{try{let b=await h.text(),{nodes:N,edges:P}=de(b);p(N),g(P),U(N,P),setTimeout(()=>{G==null||G.fitView({padding:.2})},50)}catch(b){alert("Failed to import workflow. Invalid file."),console.error(b)}};return c===null?(0,C.jsx)("div",{className:"flex items-center justify-center h-[600px] w-full bg-zinc-50 rounded-xl border border-zinc-200",children:(0,C.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,C.jsx)("div",{className:"w-6 h-6 border-2 border-indigo-600 border-t-transparent rounded-full animate-spin"}),(0,C.jsx)("p",{className:"text-zinc-500 text-sm font-medium",children:"Verifying License..."})]})}):(0,C.jsxs)("div",{style:s,className:`relative w-full h-[800px] rounded-xl border border-zinc-200 shadow-sm overflow-hidden bg-zinc-50/50 group ${r||""}`,children:[!c&&(0,C.jsxs)("div",{className:"absolute inset-0 z-50 bg-white/80 backdrop-blur-md flex flex-col items-center justify-center p-8 text-center",children:[(0,C.jsx)("div",{className:"w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4",children:(0,C.jsx)("div",{className:"w-8 h-8 text-red-600",children:"\u26A0\uFE0F"})}),(0,C.jsx)("h2",{className:"text-2xl font-bold text-zinc-900 mb-2",children:"License Verification Failed"}),(0,C.jsxs)("p",{className:"text-zinc-600 max-w-md",children:[x,". Please update your license key to access the builder."]})]}),(0,C.jsx)(Se,{onSave:at,onExport:rt,onImport:it,onAddNode:()=>re(!0),onAutoLayout:et,onClear:tt,onRun:ot,isSaving:I,isRunning:ae,canUndo:Fe,canRedo:He,onUndo:Be,onRedo:je}),(0,C.jsx)(Ee,{selectedNodeId:qe||void 0,onClose:()=>Z(null)}),(0,C.jsx)(Re,{isOpen:Ze,onClose:()=>re(!1),onSelect:Qe}),(0,C.jsx)(Ie,{message:(F==null?void 0:F.message)||"",type:(F==null?void 0:F.type)||"success",isVisible:!!F,onClose:()=>_(null)}),(0,C.jsx)("div",{className:"w-full h-full",ref:Ke,children:(0,C.jsxs)(L.default,{nodes:d,edges:n,onNodesChange:v,onEdgesChange:k,onConnect:Ve,onNodeClick:$e,onPaneClick:Xe,onInit:Ye,nodeTypes:Je,fitView:!0,className:"bg-zinc-50",children:[(0,C.jsx)(L.Background,{variant:L.BackgroundVariant.Dots,gap:20,size:1,color:"#94a3b8",className:"bg-slate-50"}),(0,C.jsx)(L.Controls,{className:"!bg-white !border-slate-200 !shadow-xl !rounded-lg overflow-hidden [&>button]:!border-b-slate-100 [&>button]:!text-slate-600 hover:[&>button]:!bg-indigo-50 hover:[&>button]:!text-indigo-600 transition-colors"}),(0,C.jsx)(L.MiniMap,{className:"!bg-white !border-slate-200 !shadow-xl !rounded-lg !mb-8 !mr-8",maskColor:"rgba(241, 245, 249, 0.7)",nodeColor:h=>{var b;return(b=h.type)!=null&&b.includes("trigger")||h.type==="webhook"?"#818cf8":h.type==="action"?"#34d399":"#cbd5e1"},zoomable:!0,pannable:!0})]})})]})};var _e=require("react/jsx-runtime");function ge(e){return(0,_e.jsx)(me,{...e})}var ye=require("react"),j=require("lucide-react");var O=require("react/jsx-runtime");function wt({licenseKey:e,apiConfig:t,position:o="bottom-right",themeColor:r="#2563eb"}){let[s,c]=(0,ye.useState)(!1),[a,x]=(0,ye.useState)(!1),y=()=>c(!s),i=()=>x(!a),d={position:"fixed",bottom:"20px",[o==="bottom-right"?"right":"left"]:"20px",zIndex:9999,display:"flex",flexDirection:"column",alignItems:o==="bottom-right"?"flex-end":"flex-start",gap:"10px"},p=a?{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"white",zIndex:1e4,boxShadow:"0 0 20px rgba(0,0,0,0.2)",display:"flex",flexDirection:"column"}:{width:"800px",height:"600px",backgroundColor:"white",borderRadius:"12px",boxShadow:"0 4px 20px rgba(0,0,0,0.15)",border:"1px solid #e5e7eb",display:"flex",flexDirection:"column",overflow:"hidden"};return s?(0,O.jsx)("div",{style:a?{position:"fixed",top:0,left:0,zIndex:1e4}:d,children:(0,O.jsxs)("div",{style:p,children:[(0,O.jsxs)("div",{style:{padding:"12px 16px",borderBottom:"1px solid #eee",display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"#f9fafb",color:"black"},children:[(0,O.jsx)("h3",{style:{margin:0,fontSize:"16px",fontWeight:600},children:"Workflow Builder"}),(0,O.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,O.jsx)("button",{onClick:i,style:{background:"none",border:"none",cursor:"pointer",padding:4},children:a?(0,O.jsx)(j.Minimize2,{size:18}):(0,O.jsx)(j.Maximize2,{size:18})}),(0,O.jsx)("button",{onClick:y,style:{background:"none",border:"none",cursor:"pointer",padding:4},children:(0,O.jsx)(j.X,{size:18})})]})]}),(0,O.jsx)("div",{style:{flex:1,position:"relative"},children:(0,O.jsx)(ge,{licenseKey:e,apiConfig:t})})]})}):(0,O.jsx)("div",{style:d,children:(0,O.jsx)("button",{onClick:y,style:{width:"60px",height:"60px",borderRadius:"50%",backgroundColor:r,color:"white",border:"none",cursor:"pointer",boxShadow:"0 4px 12px rgba(0,0,0,0.2)",display:"flex",alignItems:"center",justifyContent:"center",transition:"transform 0.2s"},onMouseEnter:v=>v.currentTarget.style.transform="scale(1.05)",onMouseLeave:v=>v.currentTarget.style.transform="scale(1)",children:(0,O.jsx)(j.Settings,{size:28})})})}0&&(module.exports={ApiClient,EmbeddableWidget,LicenseManager,WorkflowBuilder,WorkflowSerializer,WorkflowWidget,createConnectorNode,deserialize,getConnectorDetails,nodeRegistry,registerConnector,serialize,standardConnectors});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|