| 1 |
!function(){"use strict";var e={n:function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,{a:o}),o},d:function(t,o){for(var a in o)e.o(o,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:o[a]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.wp.element,o=window.React,a=e.n(o);const n=(...e)=>e.filter((e,t,o)=>Boolean(e)&&""!==e.trim()&&o.indexOf(e)===t).join(" ").trim();var r={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const i=(0,o.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:i,className:s="",children:l,iconNode:d,...c},m)=>(0,o.createElement)("svg",{ref:m,...r,width:t,height:t,stroke:e,strokeWidth:i?24*Number(a)/Number(t):a,className:n("lucide",s),...c},[...d.map(([e,t])=>(0,o.createElement)(e,t)),...Array.isArray(l)?l:[l]])),s=(e,t)=>{const a=(0,o.forwardRef)(({className:a,...r},s)=>{return(0,o.createElement)(i,{ref:s,iconNode:t,className:n(`lucide-${l=e,l.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,a),...r});var l});return a.displayName=`${e}`,a},l=s("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),d=s("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),c=s("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),m=s("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);function p(e){var t,o,a="";if("string"==typeof e||"number"==typeof e)a+=e;else if("object"==typeof e)if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(o=p(e[t]))&&(a&&(a+=" "),a+=o)}else for(o in e)e[o]&&(a&&(a+=" "),a+=o);return a}const u=e=>{const t=b(e),{conflictingClassGroups:o,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:e=>{const o=e.split("-");return""===o[0]&&1!==o.length&&o.shift(),g(o,t)||h(e)},getConflictingClassGroupIds:(e,t)=>{const n=o[e]||[];return t&&a[e]?[...n,...a[e]]:n}}},g=(e,t)=>{if(0===e.length)return t.classGroupId;const o=e[0],a=t.nextPart.get(o),n=a?g(e.slice(1),a):void 0;if(n)return n;if(0===t.validators.length)return;const r=e.join("-");return t.validators.find(({validator:e})=>e(r))?.classGroupId},x=/^\[(.+)\]$/,h=e=>{if(x.test(e)){const t=x.exec(e)[1],o=t?.substring(0,t.indexOf(":"));if(o)return"arbitrary.."+o}},b=e=>{const{theme:t,prefix:o}=e,a={nextPart:new Map,validators:[]};return v(Object.entries(e.classGroups),o).forEach(([e,o])=>{f(o,a,e,t)}),a},f=(e,t,o,a)=>{e.forEach(e=>{if("string"!=typeof e)return"function"==typeof e?w(e)?void f(e(a),t,o,a):void t.validators.push({validator:e,classGroupId:o}):void Object.entries(e).forEach(([e,n])=>{f(n,y(t,e),o,a)});(""===e?t:y(t,e)).classGroupId=o})},y=(e,t)=>{let o=e;return t.split("-").forEach(e=>{o.nextPart.has(e)||o.nextPart.set(e,{nextPart:new Map,validators:[]}),o=o.nextPart.get(e)}),o},w=e=>e.isThemeGetter,v=(e,t)=>t?e.map(([e,o])=>[e,o.map(e=>"string"==typeof e?t+e:"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,o])=>[t+e,o])):e)]):e,_=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,o=new Map,a=new Map;const n=(n,r)=>{o.set(n,r),t++,t>e&&(t=0,a=o,o=new Map)};return{get(e){let t=o.get(e);return void 0!==t?t:void 0!==(t=a.get(e))?(n(e,t),t):void 0},set(e,t){o.has(e)?o.set(e,t):n(e,t)}}},k=e=>{const{separator:t,experimentalParseClassName:o}=e,a=1===t.length,n=t[0],r=t.length,i=e=>{const o=[];let i,s=0,l=0;for(let d=0;d<e.length;d++){let c=e[d];if(0===s){if(c===n&&(a||e.slice(d,d+r)===t)){o.push(e.slice(l,d)),l=d+r;continue}if("/"===c){i=d;continue}}"["===c?s++:"]"===c&&s--}const d=0===o.length?e:e.substring(l),c=d.startsWith("!");return{modifiers:o,hasImportantModifier:c,baseClassName:c?d.substring(1):d,maybePostfixModifierPosition:i&&i>l?i-l:void 0}};return o?e=>o({className:e,parseClassName:i}):i},j=e=>{if(e.length<=1)return e;const t=[];let o=[];return e.forEach(e=>{"["===e[0]?(t.push(...o.sort(),e),o=[]):o.push(e)}),t.push(...o.sort()),t},N=/\s+/;function C(){let e,t,o=0,a="";for(;o<arguments.length;)(e=arguments[o++])&&(t=S(e))&&(a&&(a+=" "),a+=t);return a}const S=e=>{if("string"==typeof e)return e;let t,o="";for(let a=0;a<e.length;a++)e[a]&&(t=S(e[a]))&&(o&&(o+=" "),o+=t);return o};function A(e,...t){let o,a,n,r=function(s){const l=t.reduce((e,t)=>t(e),e());return o=(e=>({cache:_(e.cacheSize),parseClassName:k(e),...u(e)}))(l),a=o.cache.get,n=o.cache.set,r=i,i(s)};function i(e){const t=a(e);if(t)return t;const r=((e,t)=>{const{parseClassName:o,getClassGroupId:a,getConflictingClassGroupIds:n}=t,r=[],i=e.trim().split(N);let s="";for(let e=i.length-1;e>=0;e-=1){const t=i[e],{modifiers:l,hasImportantModifier:d,baseClassName:c,maybePostfixModifierPosition:m}=o(t);let p=Boolean(m),u=a(p?c.substring(0,m):c);if(!u){if(!p){s=t+(s.length>0?" "+s:s);continue}if(u=a(c),!u){s=t+(s.length>0?" "+s:s);continue}p=!1}const g=j(l).join(":"),x=d?g+"!":g,h=x+u;if(r.includes(h))continue;r.push(h);const b=n(u,p);for(let e=0;e<b.length;++e){const t=b[e];r.push(x+t)}s=t+(s.length>0?" "+s:s)}return s})(e,o);return n(e,r),r}return function(){return r(C.apply(null,arguments))}}const P=e=>{const t=t=>t[e]||[];return t.isThemeGetter=!0,t},I=/^\[(?:([a-z-]+):)?(.+)\]$/i,T=/^\d+\/\d+$/,B=new Set(["px","full","screen"]),M=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,F=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,W=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,D=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,L=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,R=e=>O(e)||B.has(e)||T.test(e),E=e=>Z(e,"length",ee),O=e=>Boolean(e)&&!Number.isNaN(Number(e)),H=e=>Z(e,"number",O),U=e=>Boolean(e)&&Number.isInteger(Number(e)),G=e=>e.endsWith("%")&&O(e.slice(0,-1)),V=e=>I.test(e),$=e=>M.test(e),z=new Set(["length","size","percentage"]),q=e=>Z(e,z,te),J=e=>Z(e,"position",te),K=new Set(["image","url"]),Y=e=>Z(e,K,ae),X=e=>Z(e,"",oe),Q=()=>!0,Z=(e,t,o)=>{const a=I.exec(e);return!!a&&(a[1]?"string"==typeof t?a[1]===t:t.has(a[1]):o(a[2]))},ee=e=>F.test(e)&&!W.test(e),te=()=>!1,oe=e=>D.test(e),ae=e=>L.test(e),ne=A((Symbol.toStringTag,()=>{const e=P("colors"),t=P("spacing"),o=P("blur"),a=P("brightness"),n=P("borderColor"),r=P("borderRadius"),i=P("borderSpacing"),s=P("borderWidth"),l=P("contrast"),d=P("grayscale"),c=P("hueRotate"),m=P("invert"),p=P("gap"),u=P("gradientColorStops"),g=P("gradientColorStopPositions"),x=P("inset"),h=P("margin"),b=P("opacity"),f=P("padding"),y=P("saturate"),w=P("scale"),v=P("sepia"),_=P("skew"),k=P("space"),j=P("translate"),N=()=>["auto",V,t],C=()=>[V,t],S=()=>["",R,E],A=()=>["auto",O,V],I=()=>["","0",V],T=()=>[O,V];return{cacheSize:500,separator:":",theme:{colors:[Q],spacing:[R,E],blur:["none","",$,V],brightness:T(),borderColor:[e],borderRadius:["none","","full",$,V],borderSpacing:C(),borderWidth:S(),contrast:T(),grayscale:I(),hueRotate:T(),invert:I(),gap:C(),gradientColorStops:[e],gradientColorStopPositions:[G,E],inset:N(),margin:N(),opacity:T(),padding:C(),saturate:T(),scale:T(),sepia:I(),skew:T(),space:C(),translate:C()},classGroups:{aspect:[{aspect:["auto","square","video",V]}],container:["container"],columns:[{columns:[$]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",V]}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[x]}],"inset-x":[{"inset-x":[x]}],"inset-y":[{"inset-y":[x]}],start:[{start:[x]}],end:[{end:[x]}],top:[{top:[x]}],right:[{right:[x]}],bottom:[{bottom:[x]}],left:[{left:[x]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",U,V]}],basis:[{basis:N()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",V]}],grow:[{grow:I()}],shrink:[{shrink:I()}],order:[{order:["first","last","none",U,V]}],"grid-cols":[{"grid-cols":[Q]}],"col-start-end":[{col:["auto",{span:["full",U,V]},V]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[Q]}],"row-start-end":[{row:["auto",{span:[U,V]},V]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",V]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",V]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal","start","end","center","between","around","evenly","stretch"]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[f]}],px:[{px:[f]}],py:[{py:[f]}],ps:[{ps:[f]}],pe:[{pe:[f]}],pt:[{pt:[f]}],pr:[{pr:[f]}],pb:[{pb:[f]}],pl:[{pl:[f]}],m:[{m:[h]}],mx:[{mx:[h]}],my:[{my:[h]}],ms:[{ms:[h]}],me:[{me:[h]}],mt:[{mt:[h]}],mr:[{mr:[h]}],mb:[{mb:[h]}],ml:[{ml:[h]}],"space-x":[{"space-x":[k]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[k]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",V,t]}],"min-w":[{"min-w":[V,t,"min","max","fit"]}],"max-w":[{"max-w":[V,t,"none","full","min","max","fit","prose",{screen:[$]},$]}],h:[{h:[V,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[V,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[V,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[V,t,"auto","min","max","fit"]}],"font-size":[{text:["base",$,E]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",H]}],"font-family":[{font:[Q]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",V]}],"line-clamp":[{"line-clamp":["none",O,H]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",R,V]}],"list-image":[{"list-image":["none",V]}],"list-style-type":[{list:["none","disc","decimal",V]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","none","wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",R,E]}],"underline-offset":[{"underline-offset":["auto",R,V]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",V]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",V]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top",J]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",q]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Y]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[g]}],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[u]}],"gradient-via":[{via:[u]}],"gradient-to":[{to:[u]}],rounded:[{rounded:[r]}],"rounded-s":[{"rounded-s":[r]}],"rounded-e":[{"rounded-e":[r]}],"rounded-t":[{"rounded-t":[r]}],"rounded-r":[{"rounded-r":[r]}],"rounded-b":[{"rounded-b":[r]}],"rounded-l":[{"rounded-l":[r]}],"rounded-ss":[{"rounded-ss":[r]}],"rounded-se":[{"rounded-se":[r]}],"rounded-ee":[{"rounded-ee":[r]}],"rounded-es":[{"rounded-es":[r]}],"rounded-tl":[{"rounded-tl":[r]}],"rounded-tr":[{"rounded-tr":[r]}],"rounded-br":[{"rounded-br":[r]}],"rounded-bl":[{"rounded-bl":[r]}],"border-w":[{border:[s]}],"border-w-x":[{"border-x":[s]}],"border-w-y":[{"border-y":[s]}],"border-w-s":[{"border-s":[s]}],"border-w-e":[{"border-e":[s]}],"border-w-t":[{"border-t":[s]}],"border-w-r":[{"border-r":[s]}],"border-w-b":[{"border-b":[s]}],"border-w-l":[{"border-l":[s]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:["solid","dashed","dotted","double","none","hidden"]}],"divide-x":[{"divide-x":[s]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[s]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:["solid","dashed","dotted","double","none"]}],"border-color":[{border:[n]}],"border-color-x":[{"border-x":[n]}],"border-color-y":[{"border-y":[n]}],"border-color-s":[{"border-s":[n]}],"border-color-e":[{"border-e":[n]}],"border-color-t":[{"border-t":[n]}],"border-color-r":[{"border-r":[n]}],"border-color-b":[{"border-b":[n]}],"border-color-l":[{"border-l":[n]}],"divide-color":[{divide:[n]}],"outline-style":[{outline:["","solid","dashed","dotted","double","none"]}],"outline-offset":[{"outline-offset":[R,V]}],"outline-w":[{outline:[R,E]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:S()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[R,E]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",$,X]}],"shadow-color":[{shadow:[Q]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],filter:[{filter:["","none"]}],blur:[{blur:[o]}],brightness:[{brightness:[a]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",$,V]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[m]}],saturate:[{saturate:[y]}],sepia:[{sepia:[v]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[o]}],"backdrop-brightness":[{"backdrop-brightness":[a]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[m]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"backdrop-sepia":[{"backdrop-sepia":[v]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",V]}],duration:[{duration:T()}],ease:[{ease:["linear","in","out","in-out",V]}],delay:[{delay:T()}],animate:[{animate:["none","spin","ping","pulse","bounce",V]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[U,V]}],"translate-x":[{"translate-x":[j]}],"translate-y":[{"translate-y":[j]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",V]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",V]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",V]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[R,E,H]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}}));function re(...e){return ne(function(){for(var e,t,o=0,a="",n=arguments.length;o<n;o++)(e=arguments[o])&&(t=p(e))&&(a&&(a+=" "),a+=t);return a}(e))}var ie=window.ReactJSXRuntime;const se=o.forwardRef(({className:e,type:t,...o},a)=>(0,ie.jsx)("input",{type:t,className:re("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),ref:a,...o}));se.displayName="Input";const le=[{id:"wordpress",name:"WordPress",icon:"W",iconBg:"bg-blue-600",categories:[{id:"triggers",name:"Triggers",actions:[{id:"wp_user_register",name:"User register"},{id:"wp_user_login",name:"User login"},{id:"wp_user_logout",name:"User logout"},{id:"wp_post_publish",name:"Post / Page publish"},{id:"wp_post_update",name:"Post / Page update"},{id:"wp_comment_added",name:"Comment added"},{id:"wp_media_upload",name:"Media upload"}]},{id:"user_management",name:"User Management",actions:[{id:"wp_create_user",name:"Create New User"},{id:"wp_update_user",name:"Update User"},{id:"wp_delete_user",name:"Delete User"}]},{id:"user_retrieval",name:"User Retrieval",actions:[{id:"wp_get_all_users",name:"Get All Users"},{id:"wp_get_users_by_role",name:"Get All Users by Role"},{id:"wp_get_user_by_id",name:"Get User by Id"},{id:"wp_get_user_by_email",name:"Get User by Email"},{id:"wp_get_user_by_field",name:"Get User by Field"}]},{id:"user_metadata",name:"User Metadata",actions:[{id:"wp_get_user_meta_all",name:"Get User Metadata (All)"},{id:"wp_get_user_meta_single",name:"Get User Metadata (Single)"},{id:"wp_update_user_meta",name:"Update User Metadata"}]},{id:"role_management",name:"Role Management",actions:[{id:"wp_create_role",name:"Create Role"},{id:"wp_delete_role",name:"Delete Role"},{id:"wp_add_user_role",name:"Add User Role"},{id:"wp_remove_user_role",name:"Remove User Role"},{id:"wp_update_user_role",name:"Update User Role"},{id:"wp_get_all_roles",name:"Get All Roles"}]},{id:"capabilities_management",name:"Capabilities Management",actions:[{id:"wp_get_all_caps",name:"Get All Capabilities"},{id:"wp_get_role_caps",name:"Get Role Capabilities"},{id:"wp_add_role_caps",name:"Add Role Capabilities"},{id:"wp_remove_role_caps",name:"Remove Role Capabilities"},{id:"wp_get_user_caps",name:"Get User Capabilities"},{id:"wp_add_user_caps",name:"Add User Capabilities"},{id:"wp_remove_user_caps",name:"Remove User Capabilities"}]},{id:"post_management",name:"Post Management",actions:[{id:"wp_create_post",name:"Create New Post",fields:[{id:"post_title",name:"Post Title",type:"text",placeholder:"Enter post title"},{id:"post_content",name:"Post Content",type:"textarea",placeholder:"Enter post content (or use {response})"},{id:"post_status",name:"Post Status",type:"select",options:[{id:"publish",name:"Publish"},{id:"draft",name:"Draft"},{id:"pending",name:"Pending"},{id:"private",name:"Private"}],defaultValue:"publish"},{id:"categories",name:"Categories / Topics",type:"text",placeholder:"Category IDs or names (comma separated)"}]},{id:"wp_create_page",name:"Create New Page",fields:[{id:"post_title",name:"Page Title",type:"text",placeholder:"Enter page title"},{id:"post_content",name:"Page Content",type:"textarea",placeholder:"Enter page content (or use {response})"},{id:"post_status",name:"Page Status",type:"select",options:[{id:"publish",name:"Publish"},{id:"draft",name:"Draft"},{id:"pending",name:"Pending"},{id:"private",name:"Private"}],defaultValue:"publish"}]},{id:"wp_update_post",name:"Update Post"},{id:"wp_update_post_status",name:"Update Post Status"},{id:"wp_delete_post",name:"Delete Post"},{id:"wp_get_posts_all",name:"Get Post (All)"},{id:"wp_get_post_single",name:"Get Post (Single)"},{id:"wp_get_posts_by_type",name:"Get Posts By Post Type"},{id:"wp_get_posts_by_meta",name:"Get Posts by Metadata"},{id:"wp_get_post_meta_all",name:"Get Post Metadata (All)"},{id:"wp_get_post_meta_single",name:"Get Post Metadata (Single)"},{id:"wp_get_post_permalink",name:"Get Post Permalink"},{id:"wp_get_post_content",name:"Get Post Content"},{id:"wp_get_post_excerpt",name:"Get Post Excerpt"},{id:"wp_get_post_status",name:"Get Post Status"},{id:"wp_ai_generated_post",name:"AI Generated Post",description:"Generate a WordPress post using AI based on your instructions.",fields:[{id:"ai_provider",name:"AI Provider",type:"select",options:[{id:"openai",name:"OpenAI"},{id:"gemini",name:"Gemini"},{id:"claude",name:"Claude"}],defaultValue:"openai"},{id:"api_key",name:"API Key",type:"text",placeholder:"Enter API Key"},{id:"model",name:"Model",type:"select",options:[{id:"gpt-4o",name:"GPT-4o (OpenAI)"},{id:"gpt-4o-mini",name:"GPT-4o Mini (OpenAI)"},{id:"gpt-4-turbo",name:"GPT-4 Turbo (OpenAI)"},{id:"gpt-3.5-turbo",name:"GPT-3.5 Turbo (OpenAI)"},{id:"gemini-1.5-flash",name:"Gemini 1.5 Flash (Google)"},{id:"gemini-1.5-pro",name:"Gemini 1.5 Pro (Google)"},{id:"claude-3-5-sonnet-20240620",name:"Claude 3.5 Sonnet (Anthropic)"},{id:"claude-3-haiku-20240307",name:"Claude 3 Haiku (Anthropic)"}],defaultValue:"gpt-3.5-turbo"},{id:"prompt_instructions",name:"Instructions for AI",type:"textarea",placeholder:"e.g., Write a 500-word blog post about the history of coffee."},{id:"post_title",name:"Post Title",type:"text",placeholder:"Enter post title (Leave empty to let AI generate it)"},{id:"post_status",name:"Post Status",type:"select",options:[{id:"publish",name:"Publish"},{id:"draft",name:"Draft"},{id:"pending",name:"Pending"}],defaultValue:"publish"},{id:"categories",name:"Categories / Topics",type:"text",placeholder:"Category IDs or names (comma separated)"}]},{id:"wp_ai_generate_social_posts",name:"Generate Social Media Posts (Facebook & Telegram)",description:"Generate optimized posts for Facebook and Telegram from content.",fields:[{id:"ai_provider",name:"AI Provider",type:"select",options:[{id:"openai",name:"OpenAI"},{id:"gemini",name:"Gemini"},{id:"claude",name:"Claude"}],defaultValue:"openai"},{id:"api_key",name:"API Key",type:"text",placeholder:"Enter API Key"},{id:"model",name:"Model",type:"select",options:[{id:"gpt-4o",name:"GPT-4o (OpenAI)"},{id:"gpt-4o-mini",name:"GPT-4o Mini (OpenAI)"},{id:"gemini-1.5-flash",name:"Gemini 1.5 Flash (Google)"},{id:"claude-3-5-sonnet-20240620",name:"Claude 3.5 Sonnet (Anthropic)"}],defaultValue:"gpt-4o-mini"},{id:"source_content",name:"Source Content",type:"textarea",placeholder:"Map {post_content} or enter text"},{id:"additional_instructions",name:"Additional Instructions",type:"textarea",placeholder:"e.g., Use emojis, formal tone, etc."},{id:"generate_image",name:"Generate AI Image?",type:"checkbox",defaultValue:!1},{id:"image_model",name:"Image Model",type:"select",options:[{id:"dall-e-3",name:"DALL-E 3 (OpenAI)"},{id:"dall-e-2",name:"DALL-E 2 (OpenAI)"}],defaultValue:"dall-e-3"},{id:"image_size",name:"Image Size",type:"select",options:[{id:"1024x1024",name:"1024x1024"},{id:"1024x1792",name:"1024x1792 (Tall)"},{id:"1792x1024",name:"1792x1024 (Wide)"}],defaultValue:"1024x1024"},{id:"image_style",name:"Image Style",type:"select",options:[{id:"vivid",name:"Vivid"},{id:"natural",name:"Natural"}],defaultValue:"vivid"}]},{id:"wp_ai_generate_social_posts_pro",name:"Generate Social Media Posts (Insta, WhatsApp, LinkedIn)",description:"Generate optimized posts for Instagram, WhatsApp, and LinkedIn from content.",isPro:!0,fields:[{id:"ai_provider",name:"AI Provider",type:"select",options:[{id:"openai",name:"OpenAI"},{id:"gemini",name:"Gemini"},{id:"claude",name:"Claude"}],defaultValue:"openai"},{id:"api_key",name:"API Key",type:"text",placeholder:"Enter API Key"},{id:"model",name:"Model",type:"select",options:[{id:"gpt-4o",name:"GPT-4o (OpenAI)"},{id:"gpt-4o-mini",name:"GPT-4o Mini (OpenAI)"},{id:"gemini-1.5-flash",name:"Gemini 1.5 Flash (Google)"},{id:"claude-3-5-sonnet-20240620",name:"Claude 3.5 Sonnet (Anthropic)"}],defaultValue:"gpt-4o-mini"},{id:"source_content",name:"Source Content",type:"textarea",placeholder:"Map {post_content} or enter text"},{id:"additional_instructions",name:"Additional Instructions",type:"textarea",placeholder:"e.g., Use emojis, formal tone, etc."},{id:"generate_image",name:"Generate AI Image?",type:"checkbox",defaultValue:!1},{id:"image_model",name:"Image Model",type:"select",options:[{id:"dall-e-3",name:"DALL-E 3 (OpenAI)"},{id:"dall-e-2",name:"DALL-E 2 (OpenAI)"}],defaultValue:"dall-e-3"},{id:"image_size",name:"Image Size",type:"select",options:[{id:"1024x1024",name:"1024x1024"},{id:"1024x1792",name:"1024x1792 (Tall)"},{id:"1792x1024",name:"1792x1024 (Wide)"}],defaultValue:"1024x1024"},{id:"image_style",name:"Image Style",type:"select",options:[{id:"vivid",name:"Vivid"},{id:"natural",name:"Natural"}],defaultValue:"vivid"}]}]},{id:"comment_management",name:"Comment Management",actions:[{id:"wp_get_comments_all",name:"Get Post Comments (All)"},{id:"wp_get_comments_single",name:"Get Post Comments (Single Post)"},{id:"wp_get_user_comments",name:"Get User Comments"},{id:"wp_get_user_comments_email",name:"Get User Comments (By Email)"},{id:"wp_get_comment_meta_all",name:"Get Comment Metadata (All)"},{id:"wp_get_comment_meta_single",name:"Get Comment Metadata (Single)"},{id:"wp_create_comment",name:"Create New Comment",fields:[{id:"post_id",name:"Post ID",type:"number",placeholder:"Enter Post ID (ID of the post to comment on)"},{id:"comment_content",name:"Comment Content",type:"textarea",placeholder:"Enter your comment here..."}]},{id:"wp_reply_comment",name:"Reply To Comment",fields:[{id:"parent_id",name:"Parent Comment ID",type:"number",placeholder:"Enter Comment ID to reply to (leave empty to use trigger context)"},{id:"comment_content",name:"Reply Content",type:"textarea",placeholder:"Enter your reply content here..."}]},{id:"wp_ai_reply_comment",name:"AI Comment Reply",description:"Automatically reply to a comment using AI.",fields:[{id:"ai_provider",name:"AI Provider",type:"select",options:[{id:"openai",name:"OpenAI"},{id:"gemini",name:"Gemini"},{id:"claude",name:"Claude"}],defaultValue:"openai"},{id:"api_key",name:"API Key",type:"text",placeholder:"Enter API Key"},{id:"model",name:"Model",type:"select",options:[{id:"gpt-4o",name:"GPT-4o (OpenAI)"},{id:"gpt-4o-mini",name:"GPT-4o Mini (OpenAI)"},{id:"gpt-4-turbo",name:"GPT-4 Turbo (OpenAI)"},{id:"gpt-3.5-turbo",name:"GPT-3.5 Turbo (OpenAI)"},{id:"gemini-2.0-flash-exp",name:"Gemini 2.0 Flash exp (Google)"},{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash (Google)"},{id:"gemini-1.5-pro",name:"Gemini 1.5 Pro (Google)"},{id:"claude-3-5-sonnet-20240620",name:"Claude 3.5 Sonnet (Anthropic)"},{id:"claude-3-haiku-20240307",name:"Claude 3 Haiku (Anthropic)"}],defaultValue:"gpt-3.5-turbo"},{id:"prompt_instructions",name:"Instructions for AI",type:"textarea",placeholder:"e.g., Be helpful and polite. Answer any questions asked."},{id:"parent_id",name:"Parent Comment ID",type:"number",placeholder:"Leave empty to use trigger context"}]},{id:"wp_delete_comment",name:"Delete Comment"}]},{id:"post_type_management",name:"Post Type Management",actions:[{id:"wp_get_post_type_all",name:"Get Post Type (All)"},{id:"wp_get_post_type_single",name:"Get Post Type (Single Post)"},{id:"wp_register_post_type",name:"Register Post Type"},{id:"wp_unregister_post_type",name:"Unregister Post Type"},{id:"wp_add_post_type_features",name:"Add Post Type Features (Support)"}]},{id:"post_tag_management",name:"Post Tag Management",actions:[{id:"wp_create_tag",name:"Create Post Tag"},{id:"wp_update_tag",name:"Update Post Tag"},{id:"wp_delete_tag",name:"Delete Post Tag"},{id:"wp_add_tags_to_post",name:"Add Tags to Post"},{id:"wp_remove_tags_from_post",name:"Remove Tags From Post"},{id:"wp_get_tags_all",name:"Get Post Tag (All)"},{id:"wp_get_tag_single",name:"Get Post Tag (Single)"}]},{id:"media_management",name:"Media Management",actions:[{id:"wp_add_media",name:"Add New Image To Media Library"},{id:"wp_delete_media",name:"Delete Media From Media Library"},{id:"wp_rename_media",name:"Rename Media"},{id:"wp_get_media_all",name:"Get Media (All)"},{id:"wp_get_media_by_title",name:"Get Media (By Title)"},{id:"wp_get_media_by_id",name:"Get Media (By Id)"}]},{id:"term_management",name:"Term Management",actions:[{id:"wp_get_terms_all",name:"Get Term (All)"},{id:"wp_get_term_single",name:"Get Term (Single)"},{id:"wp_get_terms_by_tax",name:"Get Term by Taxonomy"},{id:"wp_get_term_by_field",name:"Get Term by Field"},{id:"wp_create_term",name:"Create New Term"},{id:"wp_update_term",name:"Update Term"},{id:"wp_delete_term",name:"Delete Term"}]},{id:"taxonomy_management",name:"Taxonomy Management",actions:[{id:"wp_register_tax",name:"Register Taxonomy"},{id:"wp_unregister_tax",name:"Unregister Taxonomy"},{id:"wp_get_tax_all",name:"Get Taxonomy (All)"},{id:"wp_get_tax_single",name:"Get Taxonomy (Single)"},{id:"wp_add_tax_to_post",name:"Add Taxonomy to Post"},{id:"wp_remove_tax_from_post",name:"Remove Taxonomy From Post"}]},{id:"category_management",name:"Category Management",actions:[{id:"wp_create_cat",name:"Create Category"},{id:"wp_update_cat",name:"Update Category"},{id:"wp_delete_cat",name:"Delete Category"},{id:"wp_add_cat_to_post",name:"Add Category To Post"},{id:"wp_get_cats_all",name:"Get Category (All)"},{id:"wp_get_cat_single",name:"Get Category (Single)"}]},{id:"product_tag_management",name:"Product Tag Management",actions:[{id:"wc_create_product_tag",name:"Create Product Tag"},{id:"wc_update_product_tag",name:"Update Product Tag"},{id:"wc_delete_product_tag",name:"Delete Product Tag"},{id:"wc_get_product_tags_all",name:"Get Product Tag (All)"},{id:"wc_get_product_tag_single",name:"Get Product Tag (Single)"}]},{id:"product_category_management",name:"Product Category Management",actions:[{id:"wc_create_product_cat",name:"Create Product Category"},{id:"wc_update_product_cat",name:"Update Product Category"},{id:"wc_delete_product_cat",name:"Delete Product Category"},{id:"wc_get_product_cats_all",name:"Get Product Category (All)"},{id:"wc_get_product_cat_single",name:"Get Product Category (Single)"}]},{id:"product_type_management",name:"Product Type Management",actions:[{id:"wc_create_product_type",name:"Create Product Type"},{id:"wc_update_product_type",name:"Update Product Type"},{id:"wc_delete_product_type",name:"Delete Product Type"},{id:"wc_get_product_types_all",name:"Get Product Type (All)"},{id:"wc_get_product_type_single",name:"Get Product Type (Single)"}]},{id:"plugin_management",name:"Plugin Management",actions:[{id:"wp_check_plugin_status",name:"Check Plugin Activation Status"},{id:"wp_activate_plugin",name:"Activate Plugin"}]}]},{id:"woocommerce",name:"WooCommerce",isTrigger:!0,icon:"WC",iconBg:"bg-purple-600",actions:[{id:"wc_order_created",name:"Order created",fields:[{id:"product_id",name:"Specific Product",type:"select",optionsUrl:"/products",placeholder:"Select a product (optional)"}]},{id:"wc_order_status_change",name:"Order status change",fields:[{id:"new_status",name:"Only when status changes to",type:"select",options:[{id:"",name:"Any status"},{id:"completed",name:"Completed"},{id:"processing",name:"Processing"},{id:"on-hold",name:"On Hold"},{id:"refunded",name:"Refunded"},{id:"cancelled",name:"Cancelled"},{id:"failed",name:"Failed"}],placeholder:"Any status (leave empty to trigger on any)"},{id:"product_id",name:"Specific Product",type:"select",optionsUrl:"/products",placeholder:"Select a product (optional)"}]},{id:"wc_payment_completed",name:"Payment completed",fields:[{id:"product_id",name:"Specific Product",type:"select",optionsUrl:"/products",placeholder:"Select a product (optional)"}]},{id:"wc_product_added",name:"Product added"}]},{id:"wpforms",name:"WPForms",isTrigger:!0,icon:"F",iconBg:"bg-orange-500",actions:[{id:"wpforms_submit",name:"Form submitted",fields:[{id:"form_id",name:"Specific Form",type:"select",optionsUrl:"/wpforms-forms",placeholder:"All forms (leave empty to trigger on any)"},{id:"specific_fields",name:"Map Specific Fields",type:"text",isPro:!0,placeholder:"e.g., your-name, your-email (comma-separated field keys)"}]}]},{id:"cf7",name:"Contact Form 7",isTrigger:!0,icon:"C7",iconBg:"bg-black",actions:[{id:"cf7_submit",name:"Form submitted",fields:[{id:"form_id",name:"Specific Form",type:"select",optionsUrl:"/cf7-forms",placeholder:"All forms (leave empty to trigger on any)"},{id:"specific_fields",name:"Map Specific Fields",type:"text",isPro:!0,placeholder:"e.g., your-name, your-email (comma-separated field keys)"}]}]},{id:"mail",name:"Mail",icon:"M",iconBg:"bg-gray-700",actions:[{id:"send_email",name:"Send Email",description:"To send email through your website.Need to configure your site SMTP.",fields:[{id:"from_email",name:"From Email",type:"text",placeholder:"Email address that will be used to send the email."},{id:"from_name",name:"From Name",type:"text",placeholder:"Name that will be used to send the email."},{id:"to_email",name:"To",type:"text",placeholder:"Email address to which the email will be sent. Multiple emails separated by commas."},{id:"cc_email",name:"CC",type:"text",placeholder:"Email address to which a copy will be sent. Multiple emails separated by commas."},{id:"bcc_email",name:"BCC",type:"text",placeholder:"Email address to which a blind copy will be sent. Multiple emails separated by commas."},{id:"reply_to",name:"Reply To",type:"text",placeholder:"Email address to which replies will be sent."},{id:"subject",name:"Subject",type:"text",placeholder:"Subject of the email."},{id:"body",name:"Body",type:"textarea",placeholder:"Content of the email. You can map an HTML field here."},{id:"template_id",name:"Email Template (Optional)",type:"select",optionsUrl:"/email-templates",placeholder:"Select an email template (Overrides body if selected)"},{id:"is_html",name:"Is this email in HTML format?",type:"checkbox",defaultValue:!0}]}]},{id:"webhook",name:"Webhook",isTrigger:!0,icon:"W",iconBg:"bg-violet-600",categories:[{id:"triggers",name:"Triggers",actions:[{id:"incoming_webhook",name:"Incoming Webhook",description:"Starts workflow when an HTTP request is received."}]},{id:"actions",name:"Actions",actions:[{id:"outgoing_webhook",name:"Outgoing Webhook",description:"Send data to another URL.",fields:[{id:"url",name:"Request URL",type:"text",placeholder:"https://example.com/api"},{id:"method",name:"Method",type:"select",options:[{id:"GET",name:"GET"},{id:"POST",name:"POST"},{id:"PUT",name:"PUT"},{id:"DELETE",name:"DELETE"}],defaultValue:"POST"},{id:"headers",name:"Headers",type:"keyvalue",placeholder:"Add Header"},{id:"params",name:"Query Params",type:"keyvalue",placeholder:"Add Param"},{id:"body",name:"Body",type:"textarea",placeholder:'JSON Body (e.g., {"key": "{{token}}"})'}]}]}]},{id:"facebook",name:"Facebook",icon:"fb",iconBg:"bg-blue-600",credentialConfig:{fields:[{id:"page_access_token",name:"Page Access Token",type:"text",placeholder:"Enter long-lived Page Access Token"}]},categories:[{id:"triggers",name:"Triggers",actions:[{id:"facebook_lead_ads",name:"Facebook Lead Ads",description:"Starts workflow when a new lead is submitted on Facebook.",fields:[{id:"hub_verify_token",name:"Verify Token",type:"text",placeholder:"Custom verification token for webhook"},{id:"page_access_token",name:"Page Access Token",type:"text",placeholder:"Enter Facebook Page Access Token (Legacy)"}]}]},{id:"actions",name:"Actions",actions:[{id:"fb_create_post",name:"Create a Page Post",description:"Publish a new post to your Facebook Page directly.",fields:[{id:"credential",name:"Credential",type:"credential"},{id:"page_id",name:"Page ID",type:"text",placeholder:"Enter your Facebook Page ID"},{id:"message",name:"Message",type:"textarea",placeholder:"What's on your mind? Use {post_content} to send post body, {post_title} for title, {post_url} for link."},{id:"link",name:"Link URL (Optional)",type:"text",placeholder:"https://example.com"}]}]}]},{id:"api",name:"API",icon:"A",iconBg:"bg-slate-700",actions:[{id:"api_request",name:"API Request",description:"Make an HTTP request to an external API.",fields:[{id:"url",name:"API URL",type:"text",placeholder:"https://api.example.com/data"},{id:"method",name:"Method",type:"select",options:[{id:"GET",name:"GET"},{id:"POST",name:"POST"},{id:"PUT",name:"PUT"},{id:"DELETE",name:"DELETE"}],defaultValue:"GET"},{id:"headers",name:"Headers",type:"keyvalue",placeholder:"Add Header"},{id:"params",name:"Query Params",type:"keyvalue",placeholder:"Add Param"},{id:"body",name:"Body",type:"textarea",placeholder:"Request Body (JSON, text, etc.)"}]}]},{id:"mailboxlayer",name:"MailboxLayer",icon:"ML",iconBg:"bg-blue-600",actions:[{id:"validate_email",name:"Validate Email Address",description:"Check if an email address exists and is deliverable using MailboxLayer.",fields:[{id:"api_key",name:"API Access Key",type:"text",placeholder:"Enter MailboxLayer API Access Key"},{id:"email",name:"Email to Validate",type:"text",placeholder:"Select or enter the dynamic {{email}} variable"}]},{id:"test_connection",name:"Test Connection",description:"Verify your API key is valid.",fields:[{id:"api_key",name:"API Access Key",type:"text",placeholder:"Enter MailboxLayer API Access Key"}]}]},{id:"fluentcrm",name:"FluentCRM",icon:"FC",iconBg:"bg-blue-700",actions:[{id:"create_contact",name:"Create/Update Contact",description:"Add a new contact or update an existing one in FluentCRM.",fields:[{id:"email",name:"Email Address",type:"text",placeholder:"e.g., {{fields.your-email}} or {email}"},{id:"first_name",name:"First Name",type:"text",placeholder:"e.g., {{fields.your-name}} or {first_name}"},{id:"last_name",name:"Last Name",type:"text",placeholder:"e.g., {last_name}"},{id:"status",name:"Status",type:"select",options:[{id:"subscribed",name:"Subscribed"},{id:"pending",name:"Pending"},{id:"unsubscribed",name:"Unsubscribed"}],defaultValue:"subscribed"}]}]},{id:"openai",name:"OpenAI",icon:"OA",iconBg:"bg-emerald-600",actions:[{id:"chat_completion",name:"Chat Completion",description:"Generate text using OpenAI models.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"sk-..."},{id:"model",name:"Model",type:"select",options:[{id:"gpt-3.5-turbo",name:"GPT-3.5 Turbo"},{id:"gpt-4",name:"GPT-4"},{id:"gpt-4o",name:"GPT-4o"}],defaultValue:"gpt-3.5-turbo"},{id:"prv_retrn_resp",name:"Preview Response in Logs",type:"checkbox",defaultValue:!0},{id:"prompt",name:"Prompt",type:"textarea",placeholder:"Enter your prompt here"},{id:"max_tokens",name:"Max Tokens",type:"number",defaultValue:1e3},{id:"temperature",name:"Temperature",type:"number",defaultValue:.7}]},{id:"test_connection",name:"Test Connection",description:"Verify your API key is valid.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"sk-..."}]}]},{id:"claude",name:"Claude",icon:"CL",iconBg:"bg-amber-700",actions:[{id:"chat_completion",name:"Chat Completion",description:"Generate text using Anthropic Claude models.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"sk-ant-..."},{id:"model",name:"Model",type:"select",options:[{id:"claude-3-5-sonnet-20240620",name:"Claude 3.5 Sonnet"},{id:"claude-3-opus-20240229",name:"Claude 3 Opus"},{id:"claude-3-haiku-20240307",name:"Claude 3 Haiku"}],defaultValue:"claude-3-5-sonnet-20240620"},{id:"prompt",name:"Prompt",type:"textarea",placeholder:"Enter your prompt here"},{id:"max_tokens",name:"Max Tokens",type:"number",defaultValue:1e3},{id:"temperature",name:"Temperature",type:"number",defaultValue:.7}]},{id:"test_connection",name:"Test Connection",description:"Verify your API key is valid.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"sk-ant-..."}]}]},{id:"gemini",name:"Gemini",icon:"GE",iconBg:"bg-blue-500",actions:[{id:"chat_completion",name:"Chat Completion",description:"Generate text using Google Gemini models.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"AIza..."},{id:"model",name:"Model",type:"select",options:[{id:"gemini-1.5-flash",name:"Gemini 1.5 Flash"},{id:"gemini-1.5-pro",name:"Gemini 1.5 Pro"},{id:"gemini-1.5-flash-8b",name:"Gemini 1.5 Flash-8B"},{id:"gemini-2.0-flash",name:"Gemini 2.0 Flash"}],defaultValue:"gemini-1.5-flash"},{id:"prv_retrn_resp",name:"Preview Response in Logs ( put the '$response' variable to use the Preview Response )",type:"checkbox",defaultValue:!0},{id:"prompt",name:"Prompt",type:"textarea",placeholder:"Enter your prompt here"},{id:"temperature",name:"Temperature",type:"number",defaultValue:.7}]},{id:"test_connection",name:"Test Connection",description:"Verify your API key is valid.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"AIza..."}]}]},{id:"mistral",name:"Mistral AI",icon:"MI",iconBg:"bg-orange-600",actions:[{id:"chat_completion",name:"Chat Completion",description:"Generate text using Mistral AI models.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"Enter Mistral API Key"},{id:"model",name:"Model",type:"select",options:[{id:"mistral-tiny",name:"Mistral Tiny"},{id:"mistral-small",name:"Mistral Small"},{id:"mistral-medium",name:"Mistral Medium"},{id:"mistral-large-latest",name:"Mistral Large"}],defaultValue:"mistral-tiny"},{id:"prompt",name:"Prompt",type:"textarea",placeholder:"Enter your prompt here"},{id:"max_tokens",name:"Max Tokens",type:"number",defaultValue:1e3},{id:"temperature",name:"Temperature",type:"number",defaultValue:.7}]},{id:"test_connection",name:"Test Connection",description:"Verify your API key is valid.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"Enter Mistral API Key"}]}]},{id:"grok",name:"Grok AI",icon:"GK",iconBg:"bg-slate-900",actions:[{id:"chat_completion",name:"Chat Completion",description:"Generate text using xAI Grok models.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"xai-..."},{id:"model",name:"Model",type:"select",options:[{id:"grok-2-1212",name:"Grok-2"},{id:"grok-2-latest",name:"Grok-2 (Latest)"},{id:"grok-beta",name:"Grok Beta"}],defaultValue:"grok-2-1212"},{id:"prompt",name:"Prompt",type:"textarea",placeholder:"Enter your prompt here"},{id:"max_tokens",name:"Max Tokens",type:"number",defaultValue:1e3},{id:"temperature",name:"Temperature",type:"number",defaultValue:.7}]},{id:"test_connection",name:"Test Connection",description:"Verify your xAI API key is valid.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"xai-..."}]}]},{id:"openrouter",name:"OpenRouter",icon:"OR",iconBg:"bg-indigo-600",actions:[{id:"chat_completion",name:"Chat Completion",description:"Generate text using OpenRouter models.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"sk-or-..."},{id:"model",name:"Model",type:"text",placeholder:"e.g., openai/gpt-3.5-turbo",defaultValue:"openai/gpt-3.5-turbo"},{id:"prompt",name:"Prompt",type:"textarea",placeholder:"Enter your prompt here"},{id:"max_tokens",name:"Max Tokens",type:"number",defaultValue:1e3},{id:"temperature",name:"Temperature",type:"number",defaultValue:.7}]},{id:"test_connection",name:"Test Connection",description:"Verify your API key is valid.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"sk-or-..."}]}]},{id:"fluentcrm",name:"FluentCRM",icon:"FC",iconBg:"bg-blue-600",actions:[{id:"test_connection1",name:"Test Connection",description:"Verify your API key is valid.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"sk-or-..."},{id:"model",name:"Model",type:"text",placeholder:"e.g., openai/gpt-3.5-turbo",defaultValue:"openai/gpt-3.5-turbo"},{id:"prompt",name:"Prompt",type:"textarea",placeholder:"Enter your prompt here"},{id:"max_tokens",name:"Max Tokens",type:"number",defaultValue:1e3},{id:"temperature",name:"Temperature",type:"number",defaultValue:.7}]},{id:"test_connection",name:"Test Connection",description:"Verify your API key is valid.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"sk-or-..."}]}]},{id:"google_sheets",name:"Google Sheets",icon:"GS",iconBg:"bg-green-600",actions:[{id:"gs_add_row",name:"Add Row (Save Form Data)",description:"Append a new row of data to a spreadsheet.",fields:[{id:"service_account_json",name:"Service Account JSON",type:"textarea",placeholder:"Paste the entire contents of your Google Service Account JSON key file here"},{id:"spreadsheet_id",name:"Spreadsheet ID",type:"text",placeholder:"e.g., 1BxiMVs0XRYFgPNmi...",description:"The long random string in the middle of your Google Sheet URL"},{id:"sheet_name",name:"Sheet Name",type:"text",placeholder:"e.g., Sheet1 or tab name (Leave empty for Sheet1)"},{id:"row_data",name:"Row Data (Optional)",type:"textarea",placeholder:"Leave empty to automatically add all form fields as columns.",description:"Provide the values for each column. Separate with commas or new lines. If left empty, all submitted form fields will be added automatically."}]},{id:"gs_update_row",name:"Update Row",description:"Update an existing row in your spreadsheet by row number.",fields:[{id:"service_account_json",name:"Service Account JSON",type:"textarea",placeholder:"Paste the entire contents of your Google Service Account JSON key file here"},{id:"spreadsheet_id",name:"Spreadsheet ID",type:"text",placeholder:"e.g., 1BxiMVs0XRYFgPNmi..."},{id:"sheet_name",name:"Sheet Name",type:"text",placeholder:"e.g., Sheet1"},{id:"row_number",name:"Row Number",type:"number",placeholder:"e.g., 2"},{id:"row_data",name:"Row Data",type:"textarea",placeholder:"Enter updated values on a new line or separated by commas.",description:"New values for this row. Use commas or new lines to separate columns."}]},{id:"gs_clear_range",name:"Clear Range",description:"Clear data from a specific range.",fields:[{id:"service_account_json",name:"Service Account JSON",type:"textarea",placeholder:"Paste the entire contents of your Service Account JSON key"},{id:"spreadsheet_id",name:"Spreadsheet ID",type:"text",placeholder:"e.g., 1BxiMVs0XRYFgPNmi..."},{id:"range",name:"Range to Clear",type:"text",placeholder:"e.g., Sheet1!A2:E10"}]},{id:"gs_get_values",name:"Get Values (Read Data)",description:"Read values from a specific range.",fields:[{id:"service_account_json",name:"Service Account JSON",type:"textarea",placeholder:"Paste the entire contents of your Service Account JSON key"},{id:"spreadsheet_id",name:"Spreadsheet ID",type:"text",placeholder:"e.g., 1BxiMVs0XRYFgPNmi..."},{id:"range",name:"Range to Read",type:"text",placeholder:"e.g., Sheet1!A2:C5"}]}]},{id:"iterator",name:"Iterator",icon:"↻",iconBg:"bg-amber-500",actions:[{id:"iterator_loop",name:"Loop (Iterator)",description:"Loop through each item in an array (e.g., order items). Connect to Iterator End to close the loop.",fields:[{id:"array_key",name:"Array Key",type:"text",placeholder:"e.g., items — the trigger data key holding the array to loop over"}]}]},{id:"iterator_end",name:"Iterator End",icon:"⏹",iconBg:"bg-amber-700",actions:[{id:"iterator_end",name:"Loop End",description:"Marks the end of an Iterator loop. Actions after this will run once, after all items have been processed."}]},{id:"telegram",name:"Telegram",icon:"Tg",iconBg:"bg-blue-500",credentialConfig:{fields:[{id:"bot_token",name:"Bot Token",type:"text",placeholder:"123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"}]},actions:[{id:"tg_send_message",name:"Send a text message",description:"Send a text message via Telegram Bot API.",fields:[{id:"credential",name:"Credential",type:"credential"},{id:"chat_id",name:"Chat ID",type:"text",placeholder:"e.g., -1001234567890 or @channelname"},{id:"text",name:"Text",type:"textarea",placeholder:"Enter message text here"}]}]},{id:"whatsapp",name:"WhatsApp",icon:"WA",iconBg:"bg-green-500",credentialConfig:{fields:[{id:"access_token",name:"Access Token",type:"textarea",placeholder:"Your Meta/WhatsApp Business access token"}]},actions:[{id:"wa_send_message",name:"Send Message",isPro:!0,description:"Send a text message via the WhatsApp Cloud API (Meta).",fields:[{id:"credential",name:"Credential",type:"credential"},{id:"phone_number_id",name:"Sender Phone Number ID",type:"text",placeholder:"WhatsApp business phone number ID"},{id:"to",name:"Recipient Phone",type:"text",placeholder:"e.g., {billing_phone} or 601234567890 (country code, no +)"},{id:"message",name:"Text Body",type:"textarea",placeholder:"Hello {billing_name}, your order #{order_id} has been received."}]},{id:"wa_send_template",name:"Send Template Message",isPro:!0,description:"Send a pre-approved WhatsApp template message.",fields:[{id:"credential",name:"Credential",type:"credential"},{id:"phone_number_id",name:"Sender Phone Number ID",type:"text",placeholder:"WhatsApp business phone number ID"},{id:"to",name:"Recipient Phone",type:"text",placeholder:"e.g., {billing_phone} or 601234567890"},{id:"template_name",name:"Template Name",type:"text",placeholder:"e.g., order_confirmation"},{id:"language_code",name:"Language Code",type:"text",placeholder:"e.g., en_US"},{id:"body_parameters",name:"Body Parameters",type:"textarea",placeholder:"One value per line"}]}]},{id:"instagram",name:"Instagram",icon:"Ig",iconBg:"bg-pink-500",credentialConfig:{fields:[{id:"access_token",name:"Access Token",type:"textarea",placeholder:"Your Instagram/Facebook Graph API access token"}]},actions:[{id:"ig_publish_photo",name:"Publish Photo",isPro:!0,description:"Publish a photo to an Instagram Business account.",fields:[{id:"credential",name:"Credential",type:"credential"},{id:"ig_account_id",name:"Instagram Account ID",type:"text",placeholder:"17841400000000000"},{id:"image_url",name:"Image URL",type:"text",placeholder:"https://example.com/image.jpg OR Use {featured_image_url} for post thumbnail or enter a direct URL"},{id:"caption",name:"Caption",type:"textarea",placeholder:"Check out this awesome photo! OR Use {post_content} for post body, {post_title} for title, {post_url} for link"}]}]},{id:"linkedin",name:"LinkedIn",icon:"In",iconBg:"bg-sky-600",credentialConfig:{fields:[{id:"access_token",name:"Access Token",type:"textarea",placeholder:"Your LinkedIn developer token"}]},actions:[{id:"li_create_post",name:"Create Text Post",isPro:!0,description:"Create a simple text post on a LinkedIn profile or organization page.",fields:[{id:"credential",name:"Credential",type:"credential"},{id:"author",name:"Author URN",type:"text",placeholder:"urn:li:person:1234567 or urn:li:organization:1234567"},{id:"text",name:"Message",type:"textarea",placeholder:"Excited to share this new update!..."}]}]},{id:"data_trsformer",name:"Data Transformer",icon:"DT",iconBg:"bg-purple-500",description:"Perform common data transformations like encoding, hashing, and stripping HTML tags.",actions:[{id:"data_transformer",name:"Data Transformer",fields:[{id:"Action",name:"Action",type:"select",options:[{id:"html_encode",name:"HTML Encode"},{id:"html_decode",name:"HTML Decode"},{id:"base64_encode",name:"Base64 Encode"},{id:"base64_decode",name:"Base64 Decode"},{id:"sha256",name:"SHA256 Hash"},{id:"sha1",name:"SHA1 Hash"},{id:"sha512",name:"SHA512 Hash"},{id:"hmac_sha256",name:"HMAC SHA256 (requires secret key)"},{id:"md5",name:"MD5 Hash"},{id:"strip_tags",name:"Strip HTML Tags"}],defaultValue:"html_encode"},{id:"input",name:"Input value",type:"textarea",placeholder:"Enter the data you want to transform. You can use dynamic variables here."},{id:"secret_key",name:"Secret Key (for HMAC SHA256)",type:"text",placeholder:"Enter secret key for HMAC SHA256",dependsOn:{field:"Action",value:"hmac_sha256"}}]}]},{id:"text_formatter",name:"Text Formatter",icon:"T",iconBg:"bg-teal-600",actions:[{id:"extract_pattern",name:"Extract Pattern",description:"Provide regular expression to extract string/text",fields:[{id:"text",name:"Text",type:"textarea",placeholder:"Input text"},{id:"pattern",name:"Pattern (Regex)",type:"text",placeholder:"/(pattern)/i"}]},{id:"find_text",name:"Find in Text",description:"Search text in the given content",fields:[{id:"text",name:"Text",type:"textarea",placeholder:"Input text"},{id:"search",name:"Search For",type:"text",placeholder:"Text to find"}]},{id:"replace_text",name:"Replace Text",description:"Search and replace text in the given content",fields:[{id:"text",name:"Text",type:"textarea",placeholder:"Input text"},{id:"search",name:"Search For",type:"text",placeholder:"Text to find"},{id:"replace",name:"Replace With",type:"text",placeholder:"Replacement text"}]},{id:"split_text",name:"Split Text",description:"Split the text on a character or word and return a segment",fields:[{id:"text",name:"Text",type:"textarea",placeholder:"Input text"},{id:"delimiter",name:"Separator",type:"text",placeholder:","},{id:"segment_index",name:"Segment Index",type:"number",placeholder:"0 for first, -1 for last",defaultValue:0}]},{id:"default_value",name:"Default Value",description:"Return a default value if the text is empty",fields:[{id:"text",name:"Text",type:"textarea",placeholder:"Input text"},{id:"default",name:"Default Value",type:"text",placeholder:"Fallback text"}]},{id:"truncate",name:"Truncate",description:"Limit your text to a specific character length, and delete anything over that",fields:[{id:"text",name:"Text",type:"textarea",placeholder:"Input text"},{id:"length",name:"Max Length",type:"number",placeholder:"100"},{id:"suffix",name:"Suffix",type:"text",placeholder:"...",defaultValue:"..."}]},{id:"url_encode",name:"URL Encode",description:"Encodes text for use in URLs",fields:[{id:"text",name:"Text",type:"textarea",placeholder:"Input text"}]},{id:"url_decode",name:"URL Decode",description:"Decodes text from URL string",fields:[{id:"text",name:"Text",type:"textarea",placeholder:"Input text"}]},{id:"join_lines",name:"Join Lines",description:"Join multiline text into a single line with a chosen separator",fields:[{id:"text",name:"Text",type:"textarea",placeholder:"Input text"},{id:"separator",name:"Separator",type:"text",placeholder:", ",defaultValue:", "}]},{id:"html_to_markdown",name:"HTML to Markdown",description:"Convert HTML content to Markdown format",fields:[{id:"text",name:"HTML Text",type:"textarea",placeholder:"<p>Hello</p>"},{id:"save_media",name:"Save Media to Media Library?",type:"checkbox",defaultValue:!1}]},{id:"markdown_to_html",name:"Markdown to HTML",description:"Convert Markdown text to HTML",fields:[{id:"text",name:"Markdown Text",type:"textarea",placeholder:"# Hello"}]},{id:"generate_slug",name:"Generate Slug",description:"Convert text to a URL-friendly slug",fields:[{id:"text",name:"Text",type:"textarea",placeholder:"Input text"}]}]},{id:"xml_parser",name:"XML Parser",icon:"XML",iconBg:"bg-amber-600",actions:[{id:"parse_xml_file",name:"Parse XML File",description:"Fetch and parse an XML file URL into JSON data.",fields:[{id:"xml_url",name:"XML File URL",type:"text",placeholder:"https://example.com/data.xml"}]}]},{id:"email_parser",name:"Email Parser",icon:"EP",iconBg:"bg-indigo-500",actions:[{id:"parse_email_content",name:"Parse Email Content",isPro:!0,description:"Parse raw email text to extract emails and URLs.",fields:[{id:"email_content",name:"Email Content",type:"textarea",placeholder:"Pass the raw email content here"}]},{id:"fetch_emails_imap",name:"Fetch Emails (IMAP)",isPro:!0,description:"Fetch emails from an IMAP server.",fields:[{id:"host",name:"IMAP Host",type:"text",placeholder:"imap.gmail.com"},{id:"port",name:"Port",type:"number",placeholder:"993",defaultValue:993},{id:"encryption",name:"Encryption",type:"select",options:[{id:"/imap/ssl",name:"SSL"},{id:"/imap/tls",name:"TLS"},{id:"/imap",name:"None"}],defaultValue:"/imap/ssl"},{id:"username",name:"Username",type:"text",placeholder:"[email protected]"},{id:"password",name:"Password",type:"password",placeholder:"Your password or app password"},{id:"folder",name:"Folder",type:"text",placeholder:"INBOX",defaultValue:"INBOX"},{id:"search",name:"Search Criteria",type:"text",placeholder:"UNSEEN",defaultValue:"UNSEEN"},{id:"limit",name:"Limit",type:"number",placeholder:"5",defaultValue:5}]}]},{id:"curl_importer",name:"cURL Importer",icon:">_",iconBg:"bg-slate-800",actions:[{id:"execute_curl",name:"Execute cURL Command",isPro:!0,description:"Parse and execute a raw cURL command and return the JSON response.",fields:[{id:"curl_command",name:"cURL Command",type:"textarea",placeholder:"curl -X POST https://api.example.com -H 'Content-Type: application/json' -d '{\"key\":\"value\"}'"}]}]},{id:"json_parser",name:"JSON Parser",icon:"{}",iconBg:"bg-yellow-600",actions:[{id:"parse_json_url",name:"Parse JSON from URL",isPro:!0,description:"Fetch and parse a JSON file from a URL into structured data.",fields:[{id:"json_url",name:"JSON File URL",type:"text",placeholder:"https://example.com/data.json"}]},{id:"parse_json_text",name:"Parse JSON Text",isPro:!0,description:"Parse raw JSON text into structured data.",fields:[{id:"json_text",name:"JSON Text",type:"textarea",placeholder:'{"key":"value"}'}]}]},{id:"webpage_parser",name:"Webpage Parser",icon:"🌐",iconBg:"bg-teal-500",actions:[{id:"parse_webpage_url",name:"Parse Webpage URL",isPro:!0,description:"Fetch a URL and parse its title, description, and raw text content.",fields:[{id:"webpage_url",name:"Webpage URL",type:"text",placeholder:"https://example.com"}]}]},{id:"csv_parser",name:"CSV Parser",icon:"CSV",iconBg:"bg-green-700",actions:[{id:"parse_csv_url",name:"Parse CSV from URL",isPro:!0,description:"Fetch and parse a CSV file from a URL into structured row data.",fields:[{id:"csv_url",name:"CSV File URL",type:"text",placeholder:"https://example.com/data.csv"},{id:"delimiter",name:"Delimiter",type:"text",placeholder:"e.g. , or ; or \\t",defaultValue:","},{id:"has_header",name:"First row is header?",type:"checkbox",defaultValue:!0},{id:"row_limit",name:"Row Limit (0 = unlimited)",type:"number",placeholder:"0",defaultValue:0}]},{id:"parse_csv_text",name:"Parse CSV Text",isPro:!0,description:"Parse raw CSV text (e.g. from a previous action) into structured row data.",fields:[{id:"csv_text",name:"CSV Text",type:"textarea",placeholder:"name,email,phone\nJohn,[email protected],123456"},{id:"delimiter",name:"Delimiter",type:"text",placeholder:"e.g. , or ; or \\t",defaultValue:","},{id:"has_header",name:"First row is header?",type:"checkbox",defaultValue:!0},{id:"row_limit",name:"Row Limit (0 = unlimited)",type:"number",placeholder:"0",defaultValue:0}]}]},{id:"unit_converter",name:"Unit Converter",icon:"U",iconBg:"bg-indigo-500",actions:[{id:"length_conversion",name:"Length Conversion",description:"Convert between meters, feet, inches, kilometers, miles, yards, centimeters, millimeters, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"mm",name:"Millimeter"},{id:"cm",name:"Centimeter"},{id:"m",name:"Meter"},{id:"km",name:"Kilometer"},{id:"in",name:"Inch"},{id:"ft",name:"Foot"},{id:"yd",name:"Yard"},{id:"mi",name:"Mile"}],defaultValue:"m"},{id:"to",name:"To Unit",type:"select",options:[{id:"mm",name:"Millimeter"},{id:"cm",name:"Centimeter"},{id:"m",name:"Meter"},{id:"km",name:"Kilometer"},{id:"in",name:"Inch"},{id:"ft",name:"Foot"},{id:"yd",name:"Yard"},{id:"mi",name:"Mile"}],defaultValue:"ft"}]},{id:"weight_conversion",name:"Weight Conversion",description:"Convert between kilograms, pounds, ounces, grams, tons, milligrams, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"mg",name:"Milligram"},{id:"g",name:"Gram"},{id:"kg",name:"Kilogram"},{id:"ton",name:"Ton"},{id:"oz",name:"Ounce"},{id:"lb",name:"Pound"}],defaultValue:"kg"},{id:"to",name:"To Unit",type:"select",options:[{id:"mg",name:"Milligram"},{id:"g",name:"Gram"},{id:"kg",name:"Kilogram"},{id:"ton",name:"Ton"},{id:"oz",name:"Ounce"},{id:"lb",name:"Pound"}],defaultValue:"lb"}]},{id:"temperature_conversion",name:"Temperature Conversion",description:"Convert between Celsius, Fahrenheit, and Kelvin.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"c",name:"Celsius"},{id:"f",name:"Fahrenheit"},{id:"k",name:"Kelvin"}],defaultValue:"c"},{id:"to",name:"To Unit",type:"select",options:[{id:"c",name:"Celsius"},{id:"f",name:"Fahrenheit"},{id:"k",name:"Kelvin"}],defaultValue:"f"}]},{id:"volume_conversion",name:"Volume Conversion",description:"Convert between liters, gallons, milliliters, fluid ounces, cups, pints, quarts, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"ml",name:"Milliliter"},{id:"l",name:"Liter"},{id:"gal",name:"Gallon"},{id:"floz",name:"Fluid Ounce"},{id:"cup",name:"Cup"},{id:"pt",name:"Pint"},{id:"qt",name:"Quart"}],defaultValue:"l"},{id:"to",name:"To Unit",type:"select",options:[{id:"ml",name:"Milliliter"},{id:"l",name:"Liter"},{id:"gal",name:"Gallon"},{id:"floz",name:"Fluid Ounce"},{id:"cup",name:"Cup"},{id:"pt",name:"Pint"},{id:"qt",name:"Quart"}],defaultValue:"gal"}]},{id:"area_conversion",name:"Area Conversion",description:"Convert between square meters, square feet, acres, hectares, square kilometers, square miles, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"sqm",name:"Square Meter"},{id:"sqft",name:"Square Foot"},{id:"ac",name:"Acre"},{id:"ha",name:"Hectare"},{id:"sqkm",name:"Square Kilometer"},{id:"sqmi",name:"Square Mile"}],defaultValue:"sqm"},{id:"to",name:"To Unit",type:"select",options:[{id:"sqm",name:"Square Meter"},{id:"sqft",name:"Square Foot"},{id:"ac",name:"Acre"},{id:"ha",name:"Hectare"},{id:"sqkm",name:"Square Kilometer"},{id:"sqmi",name:"Square Mile"}],defaultValue:"ac"}]},{id:"speed_conversion",name:"Speed Conversion",description:"Convert between km/h, mph, m/s, knots, ft/s, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"kmh",name:"km/h"},{id:"mph",name:"mph"},{id:"ms",name:"m/s"},{id:"knot",name:"Knots"},{id:"fts",name:"ft/s"}],defaultValue:"kmh"},{id:"to",name:"To Unit",type:"select",options:[{id:"kmh",name:"km/h"},{id:"mph",name:"mph"},{id:"ms",name:"m/s"},{id:"knot",name:"Knots"},{id:"fts",name:"ft/s"}],defaultValue:"mph"}]},{id:"pressure_conversion",name:"Pressure Conversion",description:"Convert between pascals, bars, psi, atmospheres, torr, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"pa",name:"Pascal"},{id:"bar",name:"Bar"},{id:"psi",name:"PSI"},{id:"atm",name:"Atmosphere"},{id:"torr",name:"Torr"}],defaultValue:"pa"},{id:"to",name:"To Unit",type:"select",options:[{id:"pa",name:"Pascal"},{id:"bar",name:"Bar"},{id:"psi",name:"PSI"},{id:"atm",name:"Atmosphere"},{id:"torr",name:"Torr"}],defaultValue:"bar"}]},{id:"energy_conversion",name:"Energy Conversion",description:"Convert between joules, calories, kilowatt-hours, BTU, electron volts, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"j",name:"Joule"},{id:"cal",name:"Calorie"},{id:"kwh",name:"Kilowatt-hour"},{id:"btu",name:"BTU"},{id:"ev",name:"Electron Volt"}],defaultValue:"j"},{id:"to",name:"To Unit",type:"select",options:[{id:"j",name:"Joule"},{id:"cal",name:"Calorie"},{id:"kwh",name:"Kilowatt-hour"},{id:"btu",name:"BTU"},{id:"ev",name:"Electron Volt"}],defaultValue:"cal"}]},{id:"power_conversion",name:"Power Conversion",description:"Convert between watts, kilowatts, horsepower, BTU/hour, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"w",name:"Watt"},{id:"kw",name:"Kilowatt"},{id:"hp",name:"Horsepower"},{id:"btuh",name:"BTU/hour"}],defaultValue:"w"},{id:"to",name:"To Unit",type:"select",options:[{id:"w",name:"Watt"},{id:"kw",name:"Kilowatt"},{id:"hp",name:"Horsepower"},{id:"btuh",name:"BTU/hour"}],defaultValue:"kw"}]},{id:"data_size_conversion",name:"Data Size Conversion",description:"Convert between bytes, KB, MB, GB, TB, PB, bits, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"bit",name:"Bit"},{id:"b",name:"Byte"},{id:"kb",name:"Kilobyte (KB)"},{id:"mb",name:"Megabyte (MB)"},{id:"gb",name:"Gigabyte (GB)"},{id:"tb",name:"Terabyte (TB)"},{id:"pb",name:"Petabyte (PB)"}],defaultValue:"mb"},{id:"to",name:"To Unit",type:"select",options:[{id:"bit",name:"Bit"},{id:"b",name:"Byte"},{id:"kb",name:"Kilobyte (KB)"},{id:"mb",name:"Megabyte (MB)"},{id:"gb",name:"Gigabyte (GB)"},{id:"tb",name:"Terabyte (TB)"},{id:"pb",name:"Petabyte (PB)"}],defaultValue:"gb"}]},{id:"angle_conversion",name:"Angle Conversion",description:"Convert between degrees, radians, gradians, arc minutes, arc seconds, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"deg",name:"Degree"},{id:"rad",name:"Radian"},{id:"grad",name:"Gradian"},{id:"min",name:"Arc Minute"},{id:"sec",name:"Arc Second"}],defaultValue:"deg"},{id:"to",name:"To Unit",type:"select",options:[{id:"deg",name:"Degree"},{id:"rad",name:"Radian"},{id:"grad",name:"Gradian"},{id:"min",name:"Arc Minute"},{id:"sec",name:"Arc Second"}],defaultValue:"rad"}]},{id:"frequency_conversion",name:"Frequency Conversion",description:"Convert between hertz, kilohertz, megahertz, gigahertz, RPM, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"hz",name:"Hertz"},{id:"khz",name:"Kilohertz"},{id:"mhz",name:"Megahertz"},{id:"ghz",name:"Gigahertz"},{id:"rpm",name:"RPM"}],defaultValue:"hz"},{id:"to",name:"To Unit",type:"select",options:[{id:"hz",name:"Hertz"},{id:"khz",name:"Kilohertz"},{id:"mhz",name:"Megahertz"},{id:"ghz",name:"Gigahertz"},{id:"rpm",name:"RPM"}],defaultValue:"khz"}]},{id:"fuel_economy_conversion",name:"Fuel Economy Conversion",description:"Convert between MPG, L/100km, km/L, miles/gallon, etc.",fields:[{id:"value",name:"Value",type:"text",placeholder:"e.g., 10 or {{token}}"},{id:"from",name:"From Unit",type:"select",options:[{id:"mpg",name:"MPG (US)"},{id:"mpg_imp",name:"MPG (Imperial)"},{id:"l100",name:"L/100km"},{id:"kml",name:"km/L"}],defaultValue:"mpg"},{id:"to",name:"To Unit",type:"select",options:[{id:"mpg",name:"MPG (US)"},{id:"mpg_imp",name:"MPG (Imperial)"},{id:"l100",name:"L/100km"},{id:"kml",name:"km/L"}],defaultValue:"l100"}]}]},{id:"fluent_forms",name:"Fluent Forms",isTrigger:!0,icon:"FF",iconBg:"bg-green-600",actions:[{id:"ff_form_submit",name:"Form submitted"}]},{id:"mailrefine",name:"MailRefine",icon:"MR",iconBg:"bg-violet-600",actions:[{id:"mr_verify_email",name:"Verify Email",description:"Verify if an email address is valid and deliverable using MailRefine.",fields:[{id:"api_key",name:"API Key",type:"text",placeholder:"Enter MailRefine API Key"},{id:"email",name:"Email to Verify",type:"text",placeholder:"e.g., {email} or {{fields.email}}"}]}]},{id:"filters",name:"Filters",icon:"FT",iconBg:"bg-yellow-500",actions:[{id:"filter_condition",name:"Filter / Condition",description:"Only continue the workflow if the specified condition is met.",fields:[{id:"field",name:"Field",type:"text",placeholder:"e.g., {email_valid} or {{status}}"},{id:"operator",name:"Operator",type:"select",options:[{id:"equals",name:"Equals"},{id:"not_equals",name:"Not Equals"},{id:"contains",name:"Contains"},{id:"not_contains",name:"Does Not Contain"},{id:"is_true",name:"Is True"},{id:"is_false",name:"Is False"}],defaultValue:"equals"},{id:"value",name:"Value",type:"text",placeholder:"e.g., true or valid"}]}]},{id:"csv_creator",name:"CSV Creator",icon:"CSV",iconBg:"bg-emerald-700",categories:[{id:"files",name:"File Actions",actions:[{id:"csv_from_table",name:"Create CSV from Table",description:"Export records from a custom table to a CSV file saved in the media library. Returns {csv_url}, {csv_attachment_id}, {csv_filename}, {csv_row_count}.",fields:[{id:"table_id",name:"Table",type:"select",optionsUrl:"/tables",placeholder:"Select a table…"},{id:"filter_col",name:"Filter Column (optional)",type:"text",placeholder:"column_slug — leave blank to export all rows"},{id:"filter_val",name:"Filter Value (optional)",type:"text",placeholder:"e.g. active or {status}"},{id:"filename",name:"Filename (optional)",type:"text",placeholder:"orders_2024.csv — leave blank for auto"}]},{id:"csv_from_json",name:"Create CSV from JSON",description:"Convert a JSON array of objects to a CSV file. Pipe {response} from an AI or API action. Returns {csv_url}, {csv_attachment_id}, {csv_filename}, {csv_row_count}.",fields:[{id:"json_data",name:"JSON Data",type:"textarea",placeholder:'[{"name":"Alice","email":"[email protected]"},{"name":"Bob","email":"[email protected]"}]\n\nTip: use {response} to pipe output from an AI or API action.'},{id:"filename",name:"Filename (optional)",type:"text",placeholder:"report.csv — leave blank for auto"}]},{id:"csv_from_array",name:"Create CSV from Array",description:"Convert a JSON array of arrays to a CSV file with optional custom headers. Returns {csv_url}, {csv_attachment_id}, {csv_filename}, {csv_row_count}.",fields:[{id:"array_data",name:"Array Data (JSON)",type:"textarea",placeholder:'[["Alice","[email protected]"],["Bob","[email protected]"]]\n\nTip: use {response} or {items} to pipe data from a previous action.'},{id:"headers",name:"Column Headers (comma-separated, optional)",type:"text",placeholder:"Name, Email, Phone — leave blank for no header row"},{id:"filename",name:"Filename (optional)",type:"text",placeholder:"export.csv — leave blank for auto"}]}]}]},{id:"tables",name:"Tables",icon:"TB",iconBg:"bg-indigo-600",isTrigger:!0,categories:[{id:"triggers",name:"Triggers",actions:[{id:"trigger_button",name:"Trigger Workflow Button Clicked",description:"Fires when the 'Trigger Workflow' button is clicked in a table shortcode. Available tokens: {table_id}, {table_name}, {record_id}, and all column values."},{id:"new_record",name:"New Record",description:"Fires when a new row is inserted into a table. Available tokens: {table_id}, {table_name}, {record_id}, and all column values."},{id:"updated_record",name:"Updated Record",description:"Fires when a row is updated. Available tokens: {table_id}, {table_name}, {record_id}, new column values, and {old_<column_slug>} for previous values."},{id:"deleted_record",name:"Deleted Record",description:"Fires when a row is deleted. Available tokens: {table_id}, {table_name}, {record_id}, and the last known column values."},{id:"updated_cell",name:"Updated Cell",description:"Fires once per changed cell when a row is updated. Available tokens: {table_id}, {table_name}, {record_id}, {column_slug}, {old_value}, {new_value}."}]},{id:"records",name:"Records",actions:[{id:"tables_insert_record",name:"Insert Record",description:"Insert a new row into one of your custom tables.",fields:[{id:"table_id",name:"Table",type:"select",optionsUrl:"/tables",placeholder:"Select a table…"},{id:"record_data",name:"Field Values",type:"table_columns_mapper",tableIdField:"table_id"}]},{id:"tables_update_record",name:"Update Record",description:"Update an existing row in one of your custom tables.",fields:[{id:"table_id",name:"Table",type:"select",optionsUrl:"/tables",placeholder:"Select a table…"},{id:"row_id",name:"Record ID",type:"text",placeholder:"Row to update — use {record_id} or a number"},{id:"record_data",name:"Field Values",type:"table_columns_mapper",tableIdField:"table_id"}]}]}]},{id:"workflow",name:"Workflows",icon:"WF",iconBg:"bg-teal-600",isTrigger:!0,categories:[{id:"triggers",name:"Triggers",actions:[{id:"sub_workflow_trigger",name:"Sub-Workflow Trigger",description:"Starts the workflow when called from another workflow. Use this to create reusable modular workflows."}]},{id:"actions",name:"Actions",actions:[{id:"call_sub_workflow",name:"Call Sub-Workflow",description:"Execute another workflow and use its returned data.",fields:[{id:"workflow_id",name:"Select Sub-Workflow",type:"select",optionsUrl:"/workflows",placeholder:"Choose a workflow to call…"},{id:"inputs",name:"Map Inputs",type:"keyvalue",placeholder:"Add Input (e.g. email: {customer_email})"}]},{id:"return_values",name:"Return Values",description:"Stop the current sub-workflow and return specified values to the parent workflow.",fields:[{id:"values",name:"Return Values",type:"keyvalue",placeholder:"Add Value (e.g. status: success)"}]}]}]},{id:"delay",name:"Delay",icon:"⏱",iconBg:"bg-slate-500",description:"Pause the workflow for a set duration before continuing to the next step.",actions:[{id:"delay_execution",name:"Wait / Delay",description:"Pause workflow execution for a configurable time (minutes, hours, or days) before continuing.",fields:[{id:"delay_amount",name:"Delay Amount",type:"number",placeholder:"e.g., 5"},{id:"delay_unit",name:"Unit",type:"select",options:[{id:"minutes",name:"Minutes"},{id:"hours",name:"Hours"},{id:"days",name:"Days"}],defaultValue:"days"}]}]},{id:"wpbot",name:"WPBot",isTrigger:!0,icon:"WB",iconBg:"bg-blue-500",categories:[{id:"triggers",name:"Triggers",actions:[{id:"wpbot_chat_session_saved",name:"WPBot Chat Session Saved"},{id:"conversationalforms_submit",name:"Conversational Forms Submitted",fields:[{id:"form_id",name:"Specific Form",type:"select",optionsUrl:"/conversational-forms",placeholder:"All forms (leave empty to trigger on any)"},{id:"specific_fields",name:"Map Specific Fields",type:"text",isPro:!0,placeholder:"e.g., your-name, your-email (comma-separated field keys)"}]}]},{id:"actions",name:"Actions",actions:[{id:"delete_session",name:"Delete Chat Session",fields:[{id:"session_id",name:"Session ID",type:"text",placeholder:"Enter Session ID"}]},{id:"get_chat_sessions",name:"Get Chat Sessions",description:"Retrieves chat sessions within a specified date range. Returns an array of sessions.",fields:[{id:"start_date",name:"Start Date",type:"text",placeholder:"e.g., YYYY-MM-DD or {yesterday}"},{id:"end_date",name:"End Date",type:"text",placeholder:"e.g., YYYY-MM-DD or {today}"}]}]}]}],de=[{id:"t3",name:"Webhook",icon:"W",iconBg:"bg-violet-600"}];var ce=function({onZoomIn:e,onZoomOut:t,onAddRouter:a,onAddNode:n}){const[r,i]=(0,o.useState)(""),[s,p]=(0,o.useState)("apps"),[u,g]=(0,o.useState)(null),x=("apps"===s?le:de).filter(e=>e.name.toLowerCase().includes(r.toLowerCase())),h=(e,t)=>{g(t.id),e.dataTransfer.setData("application/json",JSON.stringify(t)),e.dataTransfer.effectAllowed="copy"},b=()=>{g(null)};return(0,ie.jsxs)("div",{className:"w-64 bg-sidebar border-r border-sidebar-border flex flex-col h-full",children:[(0,ie.jsx)("div",{className:"p-3",children:(0,ie.jsxs)("div",{className:"relative",children:[(0,ie.jsx)(l,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,ie.jsx)(se,{placeholder:"Search",value:r,onChange:e=>i(e.target.value),className:"pl-9 bg-input border-border"})]})}),(0,ie.jsxs)("div",{className:"flex border-b border-sidebar-border",children:[(0,ie.jsx)("button",{onClick:()=>p("apps"),className:"flex-1 py-2 text-sm font-medium transition-colors "+("apps"===s?"text-sidebar-foreground border-b-2 border-sidebar-primary":"text-muted-foreground hover:text-sidebar-foreground"),children:"Apps"}),(0,ie.jsx)("button",{onClick:()=>p("tools"),className:"flex-1 py-2 text-sm font-medium transition-colors "+("tools"===s?"text-sidebar-foreground border-b-2 border-sidebar-primary":"text-muted-foreground hover:text-sidebar-foreground"),children:"Tools"})]}),(0,ie.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,ie.jsxs)("div",{onClick:a,draggable:!0,onDragStart:e=>h(e,{id:"router",name:"Router",type:"router"}),onDragEnd:b,className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-sidebar-accent transition-colors text-left border-b border-sidebar-border cursor-grab active:cursor-grabbing "+("router"===u?"opacity-50":""),children:[(0,ie.jsx)("div",{className:"w-8 h-8 rounded-lg bg-slate-500 flex items-center justify-center text-white",children:(0,ie.jsx)(d,{className:"w-4 h-4"})}),(0,ie.jsx)("span",{className:"text-sm text-sidebar-foreground",children:"Add Router"})]}),x.map(e=>(0,ie.jsxs)("div",{onClick:()=>n(e),draggable:!0,onDragStart:t=>h(t,e),onDragEnd:b,className:"w-full flex items-center gap-3 px-3 py-2.5 hover:bg-sidebar-accent transition-colors text-left cursor-grab active:cursor-grabbing "+(u===e.id?"opacity-50":""),children:[(0,ie.jsx)("div",{className:`w-8 h-8 rounded-lg ${e.iconBg} flex items-center justify-center text-white text-xs font-semibold`,children:e.icon}),(0,ie.jsx)("span",{className:"text-sm text-sidebar-foreground truncate",children:e.name})]},e.id))]}),(0,ie.jsxs)("div",{className:"p-3 border-t border-sidebar-border flex items-center gap-2",children:[(0,ie.jsx)("button",{onClick:e,className:"p-2 hover:bg-sidebar-accent rounded-md transition-colors",title:"Zoom In",children:(0,ie.jsx)(c,{className:"h-4 w-4 text-muted-foreground"})}),(0,ie.jsx)("button",{onClick:t,className:"p-2 hover:bg-sidebar-accent rounded-md transition-colors",title:"Zoom Out",children:(0,ie.jsx)(m,{className:"h-4 w-4 text-muted-foreground"})})]})]})};const me=s("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),pe=s("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),ue=s("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),ge=s("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),xe=(e="default",t="default",o="")=>{const a={default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},n={default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9 flex items-center justify-center","icon-sm":"size-8 flex items-center justify-center","icon-lg":"size-10 flex items-center justify-center"};return`inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive ${a[e]||a.default} ${n[t]||n.default} ${o}`},he=o.forwardRef(({className:e,variant:t,size:o,asChild:a=!1,...n},r)=>(0,ie.jsx)("button",{className:xe(t,o,e),ref:r,...n}));he.displayName="Button";var be=function({workflowName:e,onNameChange:t,onBack:o,onSave:a,onToggleLogs:n}){return(0,ie.jsxs)("header",{className:"h-14 bg-card border-b border-border flex items-center justify-between px-4",children:[(0,ie.jsxs)("div",{className:"flex items-center gap-4",children:[(0,ie.jsx)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:(0,ie.jsx)("input",{type:"text",value:e,onChange:e=>t(e.target.value),className:"font-medium text-card-foreground bg-transparent border-none focus:outline-none focus:ring-1 focus:ring-primary rounded px-1",placeholder:"Untitled Flow"})}),(0,ie.jsxs)(he,{variant:"outline",size:"sm",className:"gap-2 bg-transparent",onClick:o,children:[(0,ie.jsx)(me,{className:"h-4 w-4"}),"Back"]}),(0,ie.jsxs)(he,{size:"sm",className:"gap-2 bg-primary text-primary-foreground hover:bg-primary/90",onClick:a,children:[(0,ie.jsx)(pe,{className:"h-4 w-4"}),"Save Flow"]}),(0,ie.jsx)("div",{className:"flex items-center gap-1",children:(0,ie.jsx)("div",{className:"w-4 h-4 rounded-full border-2 border-muted-foreground/30"})})]}),(0,ie.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ie.jsxs)(he,{variant:"outline",size:"sm",className:"gap-2 bg-transparent",children:["Try Pro",(0,ie.jsx)(ue,{className:"h-3 w-3"})]}),(0,ie.jsxs)(he,{variant:"outline",size:"sm",className:"gap-2 bg-transparent",onClick:n,children:[(0,ie.jsx)(ge,{className:"h-4 w-4"}),"Logs"]})]})]})};const fe=s("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function ye({node:e,scale:t,onDragStart:o,onConnectionStart:a,onConnectionEnd:n,onDelete:r,isSelected:i,onClick:s}){const l=(()=>{switch(e.type){case"trigger":return{label:"Trigger",color:"text-emerald-600"};case"router":return{label:"Router",color:"text-slate-500"};default:return{label:"Action",color:"text-primary"}}})(),d=(t,o)=>{t.stopPropagation(),a(e.id,o)},c=(t,o)=>{t.stopPropagation(),n(e.id,o)};return(0,ie.jsxs)("div",{className:"absolute select-none group",style:{left:e.position.x*t,top:e.position.y*t,transform:`scale(${t})`,transformOrigin:"top left"},children:[(0,ie.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,ie.jsx)("span",{className:`text-xs font-medium ${l.color}`,children:l.label}),void 0!==e.actionNumber&&(0,ie.jsx)("span",{className:"text-xs text-muted-foreground",children:e.actionNumber})]}),(0,ie.jsxs)("div",{className:"relative",children:[(0,ie.jsx)("div",{className:"absolute left-0 top-1/2 -translate-x-1/2 -translate-y-1/2 w-4 h-4 rounded-full border-2 border-foreground/30 bg-card z-10 cursor-crosshair hover:border-primary hover:bg-primary/20 transition-colors",onMouseDown:e=>d(e,"left"),onMouseUp:e=>c(e,"left")}),(0,ie.jsx)("button",{onClick:t=>{t.stopPropagation(),r(e.id)},className:"absolute -top-2 -right-2 w-5 h-5 rounded-full bg-destructive text-destructive-foreground flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-20 hover:bg-destructive/90",children:(0,ie.jsx)(fe,{className:"w-3 h-3"})}),(0,ie.jsxs)("div",{className:`flex items-center gap-3 px-4 py-3 bg-card rounded-lg border shadow-sm min-w-[180px] cursor-move transition-all ${i?"border-primary ring-2 ring-primary/20":"border-border"} ${e.hasError?"ring-2 ring-destructive":""}`,onMouseDown:t=>o(t,e.id),onClick:e=>{e.stopPropagation(),s()},children:[(0,ie.jsx)("div",{className:`w-9 h-9 rounded-lg ${e.iconBg||"bg-primary"} flex items-center justify-center text-white text-sm font-semibold flex-shrink-0`,children:e.icon||"⚙️"}),(0,ie.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,ie.jsx)("div",{className:"text-sm font-medium text-card-foreground truncate",children:e.title||e.label}),(0,ie.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:e.subtitle||e.description||"Configure action"})]})]}),(0,ie.jsx)("div",{className:"absolute right-0 top-1/2 translate-x-1/2 -translate-y-1/2 w-4 h-4 rounded-full border-2 border-foreground/30 bg-card z-10 cursor-crosshair hover:border-primary hover:bg-primary/20 transition-colors",onMouseDown:e=>d(e,"right"),onMouseUp:e=>c(e,"right")}),e.hasError&&(0,ie.jsx)("div",{className:"absolute -top-2 -left-2 w-5 h-5 rounded-full bg-destructive flex items-center justify-center text-destructive-foreground text-xs font-bold z-20",children:"1"})]})]})}function we({connections:e,nodes:t,scale:o,onDeleteConnection:a,connectingFrom:n,mousePos:r,panOffset:i}){const s=(e,a="right")=>{const n=t.find(t=>t.id===e);if(!n)return{x:0,y:0};let r=n.position.x*o,i=(n.position.y+24)*o;return"left"===a||(r+=180*o),i+=56*o/2,{x:r,y:i}},l=(e,t)=>{const o=Math.abs(t.x-e.x),a=Math.min(.5*o,100);return`M ${e.x} ${e.y} C ${e.x+a} ${e.y}, ${t.x-a} ${t.y}, ${t.x} ${t.y}`},d=n?{from:s(n.nodeId,n.handle),to:{x:r.x-i.x,y:r.y-i.y}}:null;return(0,ie.jsxs)("svg",{className:"absolute inset-0 pointer-events-none overflow-visible",style:{width:"100%",height:"100%",minWidth:"2000px",minHeight:"2000px"},children:[(0,ie.jsxs)("defs",{children:[(0,ie.jsx)("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"10",refX:"8",refY:"5",orient:"auto",children:(0,ie.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"currentColor",className:"text-foreground/50"})}),(0,ie.jsx)("marker",{id:"arrowhead-active",markerWidth:"10",markerHeight:"10",refX:"8",refY:"5",orient:"auto",children:(0,ie.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary"})})]}),e.map(e=>{const t=s(e.from,e.fromHandle||"right"),o=s(e.to,e.toHandle||"left"),n=l(t,o);return(0,ie.jsxs)("g",{className:"group/connection",children:[(0,ie.jsx)("path",{d:n,fill:"none",stroke:"transparent",strokeWidth:20,className:"pointer-events-auto cursor-pointer",onClick:()=>a(e.id)}),(0,ie.jsx)("path",{d:n,fill:"none",stroke:"currentColor",strokeWidth:2,className:"text-foreground/40 pointer-events-none",markerEnd:"url(#arrowhead)"}),(0,ie.jsx)("path",{d:n,fill:"none",stroke:"currentColor",strokeWidth:3,className:"text-destructive opacity-0 group-hover/connection:opacity-100 transition-opacity pointer-events-none",markerEnd:"url(#arrowhead)"})]},e.id)}),d&&(0,ie.jsx)("path",{d:l(d.from,d.to),fill:"none",stroke:"currentColor",strokeWidth:2,strokeDasharray:"5,5",className:"text-primary",markerEnd:"url(#arrowhead-active)"})]})}function ve({scale:e,setScale:t,nodes:a,setNodes:n,connections:r,setConnections:i,selectedNodeId:s,onNodeClick:l}){const[d,c]=(0,o.useState)(!1),[m,p]=(0,o.useState)({x:0,y:0}),[u,g]=(0,o.useState)(null),[x,h]=(0,o.useState)({x:0,y:0}),[b,f]=(0,o.useState)(null),[y,w]=(0,o.useState)({x:0,y:0}),v=(0,o.useRef)(null),_=(0,o.useCallback)(e=>{(e.target===v.current||e.target.closest("[data-grid]"))&&c(!0)},[]),k=(0,o.useCallback)((t,o)=>{t.stopPropagation(),g(o);const n=a.find(e=>e.id===o);n&&h({x:t.clientX-(n.position.x*e+m.x),y:t.clientY-(n.position.y*e+m.y)})},[a,e,m]),j=(0,o.useCallback)((e,t)=>{f({nodeId:e,handle:t})},[]),N=(0,o.useCallback)((e,t)=>{if(b&&b.nodeId!==e){const t={id:`conn-${Date.now()}`,from:"right"===b.handle?b.nodeId:e,to:"right"===b.handle?e:b.nodeId,fromHandle:"right",toHandle:"left"};i(e=>[...e,t])}f(null)},[b,i]),C=(0,o.useCallback)(t=>{const o=v.current?.getBoundingClientRect();if(o&&w({x:t.clientX-o.left,y:t.clientY-o.top}),d)p(e=>({x:e.x+t.movementX,y:e.y+t.movementY}));else if(u){const o=(t.clientX-x.x-m.x)/e,a=(t.clientY-x.y-m.y)/e;n(e=>e.map(e=>e.id===u?{...e,position:{x:o,y:a}}:e))}},[d,u,x,e,m,n]),S=(0,o.useCallback)(()=>{c(!1),g(null),f(null)},[]),A=(0,o.useCallback)(t=>{t.preventDefault();const o=t.dataTransfer.getData("application/json");if(!o)return;const r=JSON.parse(o),i=v.current?.getBoundingClientRect();if(!i)return;const s=(t.clientX-i.left-m.x)/e,l=(t.clientY-i.top-m.y)/e;let d="trigger";(r.id.startsWith("t")||a.some(e=>"trigger"===e.type))&&(d="action");const c={id:`node-${Date.now()}`,type:d,title:r.name,subtitle:"Configure action",position:{x:s,y:l},icon:r.icon,iconBg:r.iconBg,actionNumber:a.length+1,appData:r};n(e=>[...e,c])},[m,e,a.length,n]),P=(0,o.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy"},[]),I=(0,o.useCallback)(o=>{if(o.ctrlKey||o.metaKey){o.preventDefault();const a=o.deltaY>0?-.1:.1,n=Math.min(Math.max(e+a,.5),2);if(n!==e){const a=v.current?.getBoundingClientRect();if(a){const r=o.clientX-a.left,i=o.clientY-a.top,s=(r-m.x)/e,l=(i-m.y)/e;p({x:r-s*n,y:i-l*n}),t(n)}}}},[e,t,m]),T=(0,o.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e))},[i]),B=(0,o.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e)),i(t=>t.filter(t=>t.from!==e&&t.to!==e))},[n,i]);return(0,ie.jsxs)("div",{ref:v,className:"flex-1 bg-canvas relative overflow-hidden cursor-grab active:cursor-grabbing",onMouseDown:_,onMouseMove:C,onMouseUp:S,onMouseLeave:S,onDrop:A,onDragOver:P,onWheel:I,children:[(0,ie.jsx)("div",{"data-grid":!0,className:"absolute inset-0 opacity-30 pointer-events-none",style:{backgroundImage:"radial-gradient(circle, var(--sidebar-border) 1px, transparent 1px)",backgroundSize:`${20*e}px ${20*e}px`,backgroundPosition:`${m.x}px ${m.y}px`}}),(0,ie.jsxs)("div",{className:"absolute",style:{transform:`translate(${m.x}px, ${m.y}px)`},children:[(0,ie.jsx)(we,{connections:r,nodes:a,scale:e,onDeleteConnection:T,connectingFrom:b,mousePos:y,panOffset:m}),a.map(t=>(0,ie.jsx)(ye,{node:t,scale:e,onDragStart:k,onConnectionStart:j,onConnectionEnd:N,onDelete:B,isSelected:t.id===s,onClick:()=>l(t.id)},t.id))]})]})}const _e=s("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),ke=s("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]),je=s("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Ne=s("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),Ce=s("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);function Se({isOpen:e,onClose:t,title:a,children:n,maxWidth:r="max-w-2xl"}){return(0,o.useEffect)(()=>{const o=e=>{"Escape"===e.key&&t()};return e&&(document.addEventListener("keydown",o),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",o),document.body.style.overflow="unset"}},[e,t]),e?(0,ie.jsxs)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",children:[(0,ie.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm animate-in fade-in duration-300",onClick:t}),(0,ie.jsxs)("div",{className:`relative w-full ${r} bg-sidebar border border-sidebar-border rounded-xl shadow-2xl animate-in zoom-in-95 fade-in duration-300 flex flex-col max-h-[90vh]`,onClick:e=>e.stopPropagation(),children:[(0,ie.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-sidebar-border bg-card/30 rounded-t-xl",children:[(0,ie.jsx)("h3",{className:"text-lg font-bold text-foreground",children:a}),(0,ie.jsx)("button",{onClick:t,className:"p-1.5 hover:bg-sidebar-accent rounded-lg transition-colors text-muted-foreground hover:text-foreground",children:(0,ie.jsx)(fe,{className:"w-5 h-5"})})]}),(0,ie.jsx)("div",{className:"flex-1 overflow-y-auto p-6",children:n})]})]}):null}function Ae({node:e,isOpen:t,onClose:a,onUpdateNode:n}){const[r,i]=(0,o.useState)(1),[s,d]=(0,o.useState)(""),[c,m]=(0,o.useState)(null),[p,u]=(0,o.useState)({}),[g,x]=(0,o.useState)({}),[h,b]=(0,o.useState)({}),[f,y]=(0,o.useState)(!1),[w,v]=(0,o.useState)(null),[_,k]=(0,o.useState)([]),[j,N]=(0,o.useState)(!1),[C,S]=(0,o.useState)(!1),[A,P]=(0,o.useState)({name:"",data:{}}),[I,T]=(0,o.useState)(!1);(0,o.useEffect)(()=>{if(t)if(i(1),d(""),v(null),e?.data?.actionId){let t=null;e.appData?.categories?e.appData.categories.forEach(o=>{const a=o.actions.find(t=>t.id===e.data.actionId);a&&(t=a)}):e.appData?.actions&&(t=e.appData.actions.find(t=>t.id===e.data.actionId)),m(t),u(e.data?.config||{})}else m(null),u({})},[t,e]),(0,o.useEffect)(()=>{if(t&&e?.appData?.id){const t=async()=>{N(!0);try{const t=await fetch(`${window.wpbotAutomator.apiUrl}/credentials?app_id=${e.appData.id}`,{headers:{"X-WP-Nonce":window.wpbotAutomator.nonce}}),o=await t.json();Array.isArray(o)&&k(o)}catch(e){console.error("Failed to fetch credentials:",e)}finally{N(!1)}};S(!1),P({name:"",data:{}}),t()}},[t,e?.appData?.id]);const B=async()=>{try{if(!A.name)return void alert("Validation Error: Please enter a typical Name for this credential.");T(!0);const t={name:A.name,app_id:e.appData.id,data:A.data},o=await fetch(`${window.wpbotAutomator.apiUrl}/credentials`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpbotAutomator.nonce},body:JSON.stringify(t)}),a=await o.json();if(a.success){if(k(e=>[...e,a.credential]),c){const e=c.fields?.find(e=>"credential"===e.type);e&&F(e.id,a.credential.id)}S(!1),P({name:"",data:{}}),alert("Credential saved successfully!")}else alert("Failed to save credential on server: "+(a.message||JSON.stringify(a)))}catch(e){console.error("Error saving credential:",e),alert("Error saving credential. Check your browser console: "+e.message)}finally{T(!1)}};(0,o.useEffect)(()=>{c?.fields&&c.fields.forEach(e=>{"select"===e.type&&e.optionsUrl&&!g[e.id]&&M(e)})},[c]);const M=async e=>{b(t=>({...t,[e.id]:!0}));try{const t=window.wpbotAutomator.apiUrl.replace(/\/$/,""),o=await fetch(`${t}${e.optionsUrl}`,{headers:{"X-WP-Nonce":window.wpbotAutomator.nonce}}),a=await o.json();x(t=>({...t,[e.id]:Array.isArray(a)?a:[]}))}catch(t){console.error(`Error fetching options for ${e.id}:`,t)}finally{b(t=>({...t,[e.id]:!1}))}};if(!e)return null;const F=(e,t)=>{u(o=>({...o,[e]:t}))},W=({field:e})=>{const t=p[e.tableIdField]||"",o=g[e.tableIdField]||[],a=o.find(e=>String(e.id)===String(t)),n=a?.columns||[];let r={};try{r=JSON.parse(p[e.id]||"{}")||{}}catch{}return t?0===n.length?(0,ie.jsx)("div",{className:"p-3 rounded-lg bg-muted/40 border border-border text-xs text-muted-foreground",children:0===o.length?"Loading table columns…":"This table has no columns."}):(0,ie.jsxs)("div",{className:"space-y-2.5",children:[n.map(t=>(0,ie.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,ie.jsxs)("div",{className:"w-28 shrink-0",children:[(0,ie.jsxs)("p",{className:"text-xs font-semibold text-foreground truncate",title:t.name,children:[t.name,t.required&&(0,ie.jsx)("span",{className:"text-rose-500 ml-0.5",children:"*"})]}),(0,ie.jsx)("p",{className:"text-[10px] text-muted-foreground/60",children:t.type})]}),(0,ie.jsx)("input",{type:"text",className:"flex-1 bg-input border border-border rounded-lg py-2 px-3 text-xs outline-none focus:ring-2 focus:ring-primary/20 transition-all",placeholder:`{${t.slug}} or a fixed value`,value:r[t.slug]||"",onChange:o=>((t,o)=>{const a={...r,[t]:o};F(e.id,JSON.stringify(a))})(t.slug,o.target.value)})]},t.slug)),(0,ie.jsxs)("p",{className:"text-[10px] text-muted-foreground pl-1 pt-0.5",children:["Use ",(0,ie.jsx)("code",{className:"bg-muted px-1 py-0.5 rounded font-mono",children:"{token}"})," to map values from the trigger."]})]}):(0,ie.jsx)("div",{className:"p-3 rounded-lg bg-muted/40 border border-border text-xs text-muted-foreground text-center",children:"Select a table above to see its fields."})},D=({values:e,onChange:t,placeholder:o})=>{const a=e?"string"==typeof e?JSON.parse(e):e:[{key:"",value:""}],n=(e,o,n)=>{const r=[...a];r[e]={...r[e],key:o,value:n},t(r)};return(0,ie.jsxs)("div",{className:"space-y-2",children:[a.map((e,o)=>(0,ie.jsxs)("div",{className:"flex gap-2",children:[(0,ie.jsx)("input",{className:"flex-1 bg-input border border-border rounded-lg py-2 px-3 text-xs outline-none focus:ring-2 focus:ring-primary/20",placeholder:"Key",value:e.key,onChange:t=>n(o,t.target.value,e.value)}),(0,ie.jsx)("input",{className:"flex-1 bg-input border border-border rounded-lg py-2 px-3 text-xs outline-none focus:ring-2 focus:ring-primary/20",placeholder:"Value",value:e.value,onChange:t=>n(o,e.key,t.target.value)}),(0,ie.jsx)("button",{onClick:()=>(e=>{if(1===a.length)t([{key:"",value:""}]);else{const o=a.filter((t,o)=>o!==e);t(o)}})(o),className:"p-2 text-rose-500 hover:bg-rose-50 rounded-lg transition-colors",children:(0,ie.jsx)(je,{className:"w-4 h-4 rotate-45"})})]},o)),(0,ie.jsxs)("button",{onClick:()=>{t([...a,{key:"",value:""}])},className:"flex items-center gap-2 text-xs font-bold text-primary hover:text-primary/80 transition-colors pl-1",children:["+ ",o||"Add Pair"]})]})};return(0,ie.jsx)(Se,{isOpen:t,onClose:a,title:1===r?`Configure ${e.title}`:c?.name,maxWidth:"max-w-xl",children:1===r?(()=>{const t=e.appData?.categories||(e.appData?.actions?[{id:"main",name:"Actions",actions:e.appData.actions}]:[]);return(0,ie.jsxs)("div",{className:"space-y-6",children:[(0,ie.jsxs)("div",{className:"relative",children:[(0,ie.jsx)(l,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,ie.jsx)("input",{placeholder:"Search actions...",className:"w-full pl-10 bg-input border border-border rounded-lg py-2.5 text-sm outline-none focus:ring-2 focus:ring-primary/20 transition-all",value:s,onChange:e=>d(e.target.value)})]}),(0,ie.jsx)("div",{className:"space-y-8 max-h-[50vh] overflow-y-auto pr-2 custom-scrollbar",children:t.map(e=>{const t=e.actions.filter(e=>e.name.toLowerCase().includes(s.toLowerCase()));return 0===t.length?null:(0,ie.jsxs)("div",{className:"space-y-3",children:[(0,ie.jsx)("h4",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider px-1",children:e.name}),(0,ie.jsx)("div",{className:"grid grid-cols-1 gap-2",children:t.map(e=>{const t=e.isPro&&!window.wpbotAutomator.isProActive;return(0,ie.jsxs)("button",{onClick:()=>!t&&(e=>{m(e),i(2)})(e),className:"flex items-center justify-between p-3 rounded-xl border transition-all text-left group "+(t?"opacity-75 cursor-not-allowed bg-sidebar-accent/30":c?.id===e.id?"bg-primary/10 border-primary text-primary shadow-sm":"bg-card border-border hover:border-muted-foreground/30 hover:shadow-sm"),children:[(0,ie.jsxs)("div",{className:"flex items-center gap-3",children:[(0,ie.jsx)("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold ${c?.id===e.id?"bg-primary text-white":"bg-sidebar-accent text-muted-foreground group-hover:bg-primary/20 group-hover:text-primary"} transition-colors`,children:t?(0,ie.jsx)(_e,{className:"w-4 h-4"}):(0,ie.jsx)(ke,{className:"w-4 h-4"})}),(0,ie.jsx)("span",{className:"text-sm font-medium",children:e.name}),t&&(0,ie.jsx)("span",{className:"text-[10px] px-2 py-0.5 bg-amber-500/10 text-amber-500 rounded-full font-bold ml-2",children:"PRO"}),e.isPro&&window.wpbotAutomator.isProActive&&(0,ie.jsx)("span",{className:"text-[10px] px-2 py-0.5 bg-green-500/10 text-green-600 rounded-full font-bold ml-2",children:"PRO"})]}),(0,ie.jsx)(je,{className:"w-4 h-4 transition-transform "+(c?.id===e.id?"translate-x-1":"text-muted-foreground group-hover:translate-x-1")})]},e.id)})})]},e.id)})})]})})():(0,ie.jsxs)("div",{className:"space-y-6 animate-in slide-in-from-right-4 duration-300",children:[(0,ie.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-primary/5 border border-primary/10 rounded-xl",children:[(0,ie.jsx)("div",{className:"w-10 h-10 rounded-xl bg-primary flex items-center justify-center text-white shadow-lg shadow-primary/20",children:(0,ie.jsx)(ke,{className:"w-5 h-5"})}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("h4",{className:"text-sm font-bold text-foreground leading-tight",children:c?.name}),(0,ie.jsx)("p",{className:"text-xs text-muted-foreground",children:"Configure the details for this action"}),(0,ie.jsx)("p",{children:c?.description})]})]}),"trigger"===e.type&&"incoming_webhook"===c?.id&&(0,ie.jsxs)("div",{className:"p-4 bg-violet-500/5 border border-violet-500/10 rounded-xl space-y-2",children:[(0,ie.jsx)("label",{className:"text-xs font-bold text-violet-600 uppercase tracking-wider",children:"Your Webhook URL"}),(0,ie.jsxs)("div",{className:"flex gap-2",children:[(0,ie.jsx)("input",{readOnly:!0,className:"flex-1 bg-white/50 border border-violet-500/20 rounded-lg py-2 px-3 text-xs font-mono text-violet-700 outline-none",value:`${window.location.origin}/wp-json/wpbot-automator/v1/webhook/${e.id.replace("node-","")}`}),(0,ie.jsx)("button",{onClick:()=>navigator.clipboard.writeText(`${window.location.origin}/wp-json/wpbot-automator/v1/webhook/${e.id.replace("node-","")}`),className:"px-3 py-2 bg-violet-600 text-white rounded-lg text-xs font-bold hover:bg-violet-700 transition-colors",children:"Copy"})]}),(0,ie.jsx)("p",{className:"text-[10px] text-muted-foreground italic",children:"Use this URL to send GET or POST requests to trigger this workflow."})]}),"trigger"===e.type&&"facebook_lead_ads"===c?.id&&(0,ie.jsxs)("div",{className:"p-4 bg-blue-500/5 border border-blue-500/10 rounded-xl space-y-2",children:[(0,ie.jsx)("label",{className:"text-xs font-bold text-blue-600 uppercase tracking-wider",children:"Your Facebook Webhook URL"}),(0,ie.jsxs)("div",{className:"flex gap-2",children:[(0,ie.jsx)("input",{readOnly:!0,className:"flex-1 bg-white/50 border border-blue-500/20 rounded-lg py-2 px-3 text-xs font-mono text-blue-700 outline-none",value:`${window.location.origin}/wp-json/wpbot-automator/v1/facebook-lead-ads/${e.id.replace("node-","")}`}),(0,ie.jsx)("button",{onClick:()=>navigator.clipboard.writeText(`${window.location.origin}/wp-json/wpbot-automator/v1/facebook-lead-ads/${e.id.replace("node-","")}`),className:"px-3 py-2 bg-blue-600 text-white rounded-lg text-xs font-bold hover:bg-blue-700 transition-colors",children:"Copy"})]}),(0,ie.jsx)("p",{className:"text-[10px] text-muted-foreground italic",children:"Use this URL in your Facebook Developer App configuration."})]}),(0,ie.jsxs)("div",{className:"space-y-4",children:[(0,ie.jsxs)("label",{className:"flex items-center gap-2 text-xs font-bold text-muted-foreground uppercase tracking-wider",children:[(0,ie.jsx)(ge,{className:"w-4 h-4"}),"Settings & Options"]}),c?.fields?(0,ie.jsx)("div",{className:"space-y-4",children:c.fields.map(t=>{const o=t.isPro&&!window.wpbotAutomator?.isProActive;return(0,ie.jsxs)("div",{className:"space-y-1.5",children:[(0,ie.jsxs)("label",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider pl-1 pb-2 flex items-center gap-2",children:[t.name,t.isPro&&(0,ie.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wide bg-amber-100 text-amber-700 border border-amber-300 rounded px-1.5 py-0.5",children:"PRO"})]}),o?(0,ie.jsxs)("div",{className:"space-y-1",children:[(0,ie.jsxs)("div",{className:"w-full flex items-center gap-2 bg-muted/40 border border-border rounded-lg py-2.5 px-3 cursor-not-allowed select-none",children:[(0,ie.jsx)(_e,{className:"w-4 h-4 text-amber-500 shrink-0"}),(0,ie.jsx)("span",{className:"text-sm text-muted-foreground",children:t.placeholder||"Pro feature"})]}),(0,ie.jsxs)("p",{className:"text-xs text-muted-foreground pl-1",children:[(0,ie.jsx)("a",{href:"https://wpbot.pro",target:"_blank",rel:"noopener noreferrer",className:"text-amber-600 underline hover:text-amber-800",children:"Upgrade to Pro"})," to unlock this field."]})]}):"credential"===t.type?(0,ie.jsx)("div",{className:"space-y-3",children:C?(0,ie.jsxs)("div",{className:"p-4 bg-muted/30 border border-border rounded-xl space-y-4 shadow-sm",children:[(0,ie.jsxs)("div",{className:"flex items-center justify-between pb-2 border-b border-border",children:[(0,ie.jsxs)("h4",{className:"text-sm font-bold flex items-center gap-2",children:[(0,ie.jsx)(_e,{className:"w-4 h-4 text-primary"})," Add New Credential"]}),(0,ie.jsx)("button",{type:"button",onClick:()=>S(!1),className:"text-muted-foreground hover:text-foreground text-xs font-semibold px-2 py-1 rounded bg-black/5 dark:bg-white/5 transition-colors",children:"Cancel"})]}),(0,ie.jsxs)("div",{className:"space-y-4",children:[(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider pl-1",children:"Credential Name"}),(0,ie.jsx)("input",{type:"text",placeholder:"e.g., My Personal Bot, Company Page",className:"w-full mt-1.5 bg-input border border-border rounded-lg py-2.5 px-3 text-sm focus:ring-2 focus:ring-primary/20 outline-none transition-all",value:A.name,onChange:e=>P(t=>({...t,name:e.target.value}))})]}),e.appData?.credentialConfig?.fields?.map(e=>(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider pl-1",children:e.name}),"textarea"===e.type?(0,ie.jsx)("textarea",{placeholder:e.placeholder,className:"w-full mt-1.5 bg-input border border-border rounded-lg py-2.5 px-3 text-sm min-h-[80px] focus:ring-2 focus:ring-primary/20 outline-none transition-all",value:A.data[e.id]||"",onChange:t=>P(o=>({...o,data:{...o.data,[e.id]:t.target.value}}))}):(0,ie.jsx)("input",{type:"text",placeholder:e.placeholder,className:"w-full mt-1.5 bg-input border border-border rounded-lg py-2.5 px-3 text-sm focus:ring-2 focus:ring-primary/20 outline-none transition-all",value:A.data[e.id]||"",onChange:t=>P(o=>({...o,data:{...o.data,[e.id]:t.target.value}}))})]},e.id)),(0,ie.jsx)("button",{type:"button",onClick:B,disabled:I,className:"w-full py-2.5 bg-primary text-primary-foreground font-bold rounded-lg text-sm hover:bg-primary/90 transition-colors shadow-sm disabled:opacity-50 flex items-center justify-center gap-2",children:I?"Saving...":"Save Credential"})]})]}):(0,ie.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,ie.jsxs)("select",{className:"flex-1 bg-input border border-border rounded-lg py-2.5 px-3 text-sm outline-none focus:ring-2 focus:ring-primary/20 appearance-none cursor-pointer",value:p[t.id]||"",onChange:e=>F(t.id,e.target.value),disabled:j,children:[(0,ie.jsx)("option",{value:"",children:j?"Loading credentials...":"Select a credential..."}),_.map(e=>(0,ie.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,ie.jsx)("button",{type:"button",onClick:()=>S(!0),className:"px-4 py-2.5 bg-sidebar-accent text-foreground font-semibold rounded-lg text-sm hover:bg-sidebar-accent/80 transition-colors border shadow-sm shrink-0",children:"Set up credential"})]})}):"select"===t.type?(0,ie.jsxs)("select",{className:"w-full bg-input border border-border rounded-lg py-2.5 px-3 text-sm outline-none focus:ring-2 focus:ring-primary/20 transition-all appearance-none cursor-pointer disabled:opacity-60",value:p[t.id]||"",onChange:e=>F(t.id,e.target.value),disabled:h[t.id]||t.optionsUrl&&!g[t.id],children:[(0,ie.jsx)("option",{value:"",children:h[t.id]||t.optionsUrl&&!g[t.id]?"Loading…":t.placeholder||"Select option"}),(Array.isArray(t.options)?t.options:Array.isArray(g[t.id])?g[t.id]:[])?.map(e=>(0,ie.jsx)("option",{value:e.id,children:e.name},e.id))]}):"textarea"===t.type?(0,ie.jsx)("textarea",{placeholder:t.placeholder,className:"w-full bg-input border border-border rounded-lg py-2.5 px-3 text-sm outline-none focus:ring-2 focus:ring-primary/20 transition-all min-h-[100px]",value:p[t.id]||"",onChange:e=>F(t.id,e.target.value)}):"checkbox"===t.type?(0,ie.jsxs)("label",{className:"flex items-center gap-3 p-3 bg-input border border-border rounded-lg cursor-pointer hover:bg-sidebar-accent/50 transition-colors",children:[(0,ie.jsx)("input",{type:"checkbox",className:"w-4 h-4 rounded border-border text-primary focus:ring-primary/20",checked:void 0!==p[t.id]?p[t.id]:t.defaultValue||!1,onChange:e=>F(t.id,e.target.checked)}),(0,ie.jsx)("span",{className:"text-sm font-medium",children:t.placeholder||"Enable this option"})]}):"table_columns_mapper"===t.type?(0,ie.jsx)(W,{field:t}):"keyvalue"===t.type?(0,ie.jsx)(D,{values:p[t.id],onChange:e=>F(t.id,e),placeholder:t.placeholder}):(0,ie.jsx)("input",{type:t.type||"text",placeholder:t.placeholder,className:"w-full bg-input border border-border rounded-lg py-2.5 px-3 text-sm outline-none focus:ring-2 focus:ring-primary/20 transition-all",value:p[t.id]||"",onChange:e=>F(t.id,e.target.value)}),t.variables&&t.variables.length>0&&(0,ie.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:t.variables.map(e=>(0,ie.jsxs)("button",{type:"button",onClick:()=>{const o=p[t.id]||"";F(t.id,o+e.token)},className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-semibold bg-primary/10 text-primary border border-primary/20 rounded-md hover:bg-primary/20 transition-colors cursor-pointer",title:`Click to insert ${e.token}`,children:[(0,ie.jsx)("span",{className:"opacity-60",children:"{ }"})," ",e.label]},e.token))})]},t.id)})}):(0,ie.jsxs)("div",{className:"p-8 border-2 border-dashed border-border rounded-2xl bg-card/30 flex flex-col items-center justify-center text-center space-y-3",children:[(0,ie.jsx)("div",{className:"w-12 h-12 rounded-full bg-sidebar-accent flex items-center justify-center",children:(0,ie.jsx)(Ne,{className:"w-6 h-6 text-muted-foreground opacity-30"})}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Next phase details"}),(0,ie.jsx)("p",{className:"text-xs text-muted-foreground max-w-[200px] mt-1",children:"Specific options for this action will appear here in the final implementation."})]})]})]}),w&&(0,ie.jsxs)("div",{className:`p-4 rounded-xl border ${w.success?"bg-emerald-500/5 border-emerald-500/10":"bg-rose-500/5 border-rose-500/10"} space-y-2 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,ie.jsxs)("div",{className:"flex items-center justify-between",children:[(0,ie.jsxs)("span",{className:"text-xs font-bold uppercase tracking-wider "+(w.success?"text-emerald-600":"text-rose-600"),children:[w.success?"Success":"Failed",w.code&&` (Status: ${w.code})`]}),(0,ie.jsx)("button",{onClick:()=>v(null),className:"text-[10px] text-muted-foreground hover:text-foreground underline",children:"Clear"})]}),w.body&&(0,ie.jsx)("div",{className:"max-h-[150px] overflow-y-auto bg-card/50 rounded-lg p-2 border border-border/50",children:(0,ie.jsx)("pre",{className:"text-[10px] font-mono text-muted-foreground whitespace-pre-wrap break-all",children:"string"==typeof w.body?w.body:JSON.stringify(w.body,null,2)})}),w.message&&!w.body&&(0,ie.jsx)("p",{className:"text-xs text-muted-foreground",children:w.message})]}),(0,ie.jsxs)("div",{className:"flex items-center gap-3 pt-4 border-t border-sidebar-border",children:[(0,ie.jsxs)("button",{onClick:()=>i(1),className:"flex-1 flex items-center justify-center gap-2 py-2.5 px-4 bg-sidebar-accent hover:bg-sidebar-accent/80 text-foreground rounded-xl text-sm font-semibold transition-all border border-transparent hover:border-border",children:[(0,ie.jsx)(Ce,{className:"w-4 h-4"}),"Change Action"]}),c?.id&&(c.id.includes("webhook")||c.id.includes("api")||"google_sheets"===e.appData.id||"openai"===e.appData.id||"claude"===e.appData.id||"gemini"===e.appData.id||"mistral"===e.appData.id||"groq"===e.appData.id||"openrouter"===e.appData.id)&&"trigger"!==e.type&&(0,ie.jsxs)("button",{onClick:async()=>{y(!0),v(null);try{const t=await fetch(`${window.wpbotAutomator.apiUrl}/test-action`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpbotAutomator.nonce},body:JSON.stringify({appId:e.appData.id,actionId:c.id,config:p})}),o=await t.json();v(o)}catch(e){console.error("Test Run error:",e),v({success:!1,message:"Request failed. Check your connection or URL."})}finally{y(!1)}},disabled:f,className:"flex-1 py-2.5 px-4 bg-secondary text-secondary-foreground hover:bg-secondary/80 rounded-xl text-sm font-semibold transition-all border border-border flex items-center justify-center gap-2 disabled:opacity-50",children:[f?(0,ie.jsx)("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}):(0,ie.jsx)(ke,{className:"w-4 h-4"}),"Test Run"]}),(0,ie.jsx)("button",{onClick:()=>{n({...e,subtitle:c?c.name:"Configure action",data:{...e.data,actionId:c?.id,config:p}}),a()},className:"flex-1 py-2.5 px-4 bg-primary text-white hover:bg-primary/90 rounded-xl text-sm font-bold transition-all shadow-lg shadow-primary/20 hover:scale-[1.02] active:scale-[0.98]",children:"Save Configuration"})]})]})})}const Pe=s("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);var Ie=({isOpen:e,onClose:t,workflowId:a})=>{const[n,r]=(0,o.useState)([]),[i,s]=(0,o.useState)(!1),l=async()=>{s(!0);try{let e=`${window.wpbotAutomator.apiUrl}/logs`;a&&(e+=`?workflow_id=${a}`);const t=await fetch(e,{headers:{"X-WP-Nonce":window.wpbotAutomator.nonce}}),o=await t.json();r(o.logs||(Array.isArray(o)?o:[]))}catch(e){console.error("Error fetching logs:",e)}finally{s(!1)}};return(0,o.useEffect)(()=>{e&&l()},[e]),e?(0,ie.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:(0,ie.jsxs)("div",{className:"bg-background w-full max-w-4xl h-[80vh] rounded-lg shadow-lg flex flex-col font-sans",children:[(0,ie.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[(0,ie.jsx)("h2",{className:"text-lg font-semibold",children:"Execution Logs"}),(0,ie.jsxs)("div",{className:"flex items-center gap-2",children:[(0,ie.jsxs)(he,{variant:"outline",size:"sm",onClick:l,disabled:i,children:[(0,ie.jsx)(Pe,{className:"h-4 w-4 mr-2 "+(i?"animate-spin":"")}),"Refresh"]}),(0,ie.jsx)(he,{variant:"ghost",size:"icon",onClick:t,children:(0,ie.jsx)(fe,{className:"h-4 w-4"})})]})]}),(0,ie.jsx)("div",{className:"flex-1 overflow-auto p-4",children:(0,ie.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,ie.jsx)("thead",{className:"bg-muted/50 text-muted-foreground uppercase text-xs",children:(0,ie.jsxs)("tr",{children:[(0,ie.jsx)("th",{className:"px-4 py-2 w-48",children:"Date"}),(0,ie.jsx)("th",{className:"px-4 py-2",children:"Workflow"}),(0,ie.jsx)("th",{className:"px-4 py-2 w-32",children:"Type"}),(0,ie.jsx)("th",{className:"px-4 py-2 w-24",children:"Status"}),(0,ie.jsx)("th",{className:"px-4 py-2",children:"Message"})]})}),(0,ie.jsx)("tbody",{className:"divide-y divide-border",children:0===n.length?(0,ie.jsx)("tr",{children:(0,ie.jsx)("td",{colSpan:"5",className:"px-4 py-8 text-center text-muted-foreground",children:i?"Loading logs...":"No logs found."})}):n.map(e=>(0,ie.jsxs)("tr",{className:"hover:bg-muted/10",children:[(0,ie.jsx)("td",{className:"px-4 py-2 text-muted-foreground font-mono text-xs",children:e.created_at}),(0,ie.jsx)("td",{className:"px-4 py-2 font-medium",children:e.workflow_name||`Workflow #${e.workflow_id}`}),(0,ie.jsx)("td",{className:"px-4 py-2",children:e.trigger_type}),(0,ie.jsx)("td",{className:"px-4 py-2",children:(0,ie.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium "+("success"===e.status?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400"),children:e.status})}),(0,ie.jsx)("td",{className:"px-4 py-2 text-muted-foreground",children:e.error_message||e.log_data||"-"})]},e.id))})]})})]})}):null},Te=({workflow:e,onBack:t})=>{const[a,n]=(0,o.useState)(1),[r,i]=(0,o.useState)([]),[s,l]=(0,o.useState)([]),[d,c]=(0,o.useState)(e?e.id:null),[m,p]=(0,o.useState)(e?e.name:"New Workflow"),[u,g]=(0,o.useState)(null),[x,h]=(0,o.useState)(!1);(0,o.useEffect)(()=>{e&&e.workflow_data&&(i(e.workflow_data.nodes||[]),l(e.workflow_data.connections||[]))},[e]);const b=(0,o.useCallback)(()=>{const e={id:`router-${Date.now()}`,type:"router",title:"Router",subtitle:"Branch workflow",position:{x:300,y:200},icon:"🔀",iconBg:"bg-slate-500",actionNumber:r.length+1};i(t=>[...t,e])},[r.length]),f=(0,o.useCallback)(e=>{let t="action";e.isTrigger?t="trigger":e.id.startsWith("t")?t="action":r.some(e=>"trigger"===e.type)||(t="trigger");const o={id:`node-${Date.now()}`,type:t,title:e.name,subtitle:"Configure action",position:{x:300,y:200},icon:e.icon,iconBg:e.iconBg,actionNumber:r.length+1,appData:e};i(e=>[...e,o])},[r]),y=(0,o.useCallback)(async()=>{const e={nodes:r,connections:s},t=d?"PUT":"POST",o=d?`${window.wpbotAutomator.apiUrl}/workflows/${d}`:`${window.wpbotAutomator.apiUrl}/workflows`;try{const a=await fetch(o,{method:t,headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpbotAutomator.nonce},body:JSON.stringify({name:m,description:"Created via builder",workflow_data:e,status:"active"})}),n=await a.json();n.success?(!d&&n.id&&c(n.id),alert("Workflow saved successfully!")):alert("Failed to save workflow.")}catch(e){console.error("Error saving workflow:",e),alert("An error occurred while saving.")}},[r,s,d,m]);return(0,ie.jsxs)("div",{className:"h-screen flex flex-col overflow-hidden bg-background text-foreground",children:[(0,ie.jsx)(be,{workflowName:m,onNameChange:p,onBack:t,onSave:y,onToggleLogs:()=>h(!0)}),(0,ie.jsxs)("div",{className:"flex flex-1 overflow-hidden",children:[(0,ie.jsx)(ce,{onZoomIn:()=>{n(e=>Math.min(e+.1,2))},onZoomOut:()=>{n(e=>Math.max(e-.1,.5))},onAddRouter:b,onAddNode:f}),(0,ie.jsx)(ve,{scale:a,setScale:n,nodes:r,setNodes:i,connections:s,setConnections:l,selectedNodeId:u,onNodeClick:g}),(0,ie.jsx)(Ae,{isOpen:!!u,node:r.find(e=>e.id===u),onClose:()=>g(null),onUpdateNode:e=>{i(t=>t.map(t=>t.id===e.id?e:t))}}),(0,ie.jsx)(Ie,{isOpen:x,onClose:()=>h(!1),workflowId:d})]})]})};const Be=s("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Me=s("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),Fe=s("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);function We({isOpen:e,onClose:t}){const[a,n]=(0,o.useState)(window.wpbotAutomator?.userEmail||""),[r,i]=(0,o.useState)(""),[s,l]=(0,o.useState)(!1),[d,c]=(0,o.useState)(null),[m,p]=(0,o.useState)("");return(0,ie.jsx)(Se,{isOpen:e,onClose:t,title:"WPBot Automator Support Request",maxWidth:"max-w-md",children:"success"===d?(0,ie.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[(0,ie.jsx)(Be,{className:"w-16 h-16 text-green-500 mb-4"}),(0,ie.jsx)("h4",{className:"text-xl font-semibold mb-2",children:"Message Sent!"}),(0,ie.jsx)("p",{className:"text-muted-foreground",children:"We have received your support request and will get back to you shortly."})]}):(0,ie.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),l(!0),c(null);try{const e=await fetch(`${window.wpbotAutomator.apiUrl}/support/send`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpbotAutomator.nonce},body:JSON.stringify({from_email:a,message:r})}),o=await e.json();e.ok&&o.success?(c("success"),i(""),setTimeout(()=>{t(),c(null)},3e3)):(c("error"),p(o.message||"An error occurred while sending your request."))}catch(e){console.error("Support request error:",e),c("error"),p("A network error occurred. Please try again later.")}finally{l(!1)}},className:"space-y-4",children:["error"===d&&(0,ie.jsxs)("div",{className:"p-3 bg-red-50 text-red-700 rounded-md flex items-start text-sm",children:[(0,ie.jsx)(Me,{className:"w-5 h-5 mr-2 shrink-0"}),(0,ie.jsx)("span",{children:m})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{htmlFor:"fromEmail",className:"block text-sm font-medium mb-1",children:"From Email"}),(0,ie.jsx)("input",{id:"fromEmail",type:"email",value:a,onChange:e=>n(e.target.value),className:"w-full px-3 py-2 border border-input bg-transparent rounded-md focus:outline-none focus:ring-2 focus:ring-ring",required:!0})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{htmlFor:"message",className:"block text-sm font-medium mb-1",children:"Message"}),(0,ie.jsx)("textarea",{id:"message",value:r,onChange:e=>i(e.target.value),rows:5,className:"w-full px-3 py-2 border border-input bg-transparent rounded-md focus:outline-none focus:ring-2 focus:ring-ring resize-y",required:!0,placeholder:"Describe your feature request or bug..."})]}),(0,ie.jsxs)("div",{className:"flex justify-end pt-2 space-x-2",children:[(0,ie.jsx)("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm text-foreground bg-secondary hover:bg-secondary/80 rounded-md transition-colors",disabled:s,children:"Cancel"}),(0,ie.jsx)("button",{type:"submit",disabled:s,className:"px-4 py-2 text-sm bg-primary text-primary-foreground rounded-md hover:bg-primary/90 flex items-center justify-center min-w-[100px] transition-colors",children:s?(0,ie.jsx)(Fe,{className:"w-4 h-4 animate-spin"}):"Send Message"})]})]})})}const De=e=>le.find(t=>t.id===e),Le=[{id:"wpforms-to-sheets",name:"WPForms to Google Sheets",description:"Automatically save WPForms submissions to a Google Spreadsheet.",icon:"F",iconBg:"bg-orange-500",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WPForms",subtitle:"Form submitted",position:{x:100,y:200},icon:"F",iconBg:"bg-orange-500",actionNumber:1,appData:De("wpforms")},{id:"node-action-1",type:"action",title:"Google Sheets",subtitle:"Add Row (Save Form Data)",position:{x:500,y:200},icon:"GS",iconBg:"bg-green-600",actionNumber:2,appData:De("google_sheets")}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"}]}},{id:"cf7-to-sheets",name:"Contact Form 7 to Google Sheets",description:"Automatically save Contact Form 7 submissions to a Google Spreadsheet.",icon:"C7",iconBg:"bg-black",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Contact Form 7",subtitle:"Form submitted",position:{x:100,y:200},icon:"C7",iconBg:"bg-black",actionNumber:1,appData:De("cf7")},{id:"node-action-1",type:"action",title:"Google Sheets",subtitle:"Add Row (Save Form Data)",position:{x:500,y:200},icon:"GS",iconBg:"bg-green-600",actionNumber:2,appData:De("google_sheets")}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"}]}},{id:"woocommerce-to-sheets-whatsapp",name:"WooCommerce Orders to Google Sheet + WhatsApp",description:"Save each WooCommerce order item to Google Sheets and notify the customer on WhatsApp.",isPro:!0,icon:"WC",iconBg:"bg-purple-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WooCommerce",subtitle:"Order created",position:{x:100,y:200},icon:"WC",iconBg:"bg-purple-600",actionNumber:1,appData:De("woocommerce")},{id:"node-action-1",type:"action",title:"Iterator",subtitle:"Loop through order items",position:{x:340,y:200},icon:"↻",iconBg:"bg-amber-500",actionNumber:2,appData:De("iterator")},{id:"node-action-2",type:"action",title:"Google Sheets",subtitle:"Add Row (Order Item)",position:{x:580,y:200},icon:"GS",iconBg:"bg-green-600",actionNumber:3,appData:De("google_sheets")},{id:"node-action-3",type:"action",title:"Iterator End",subtitle:"End loop",position:{x:820,y:200},icon:"⏹",iconBg:"bg-amber-700",actionNumber:4,appData:De("iterator_end")},{id:"node-action-4",type:"action",title:"WhatsApp",subtitle:"Send Message to Customer",position:{x:1060,y:200},icon:"WA",iconBg:"bg-green-500",actionNumber:5,appData:De("whatsapp")}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-2",to:"node-action-3",fromHandle:"right",toHandle:"left"},{id:"conn-4",from:"node-action-3",to:"node-action-4",fromHandle:"right",toHandle:"left"}]}},{id:"facebook-leads-to-sheets",name:"Facebook Lead Ads to Google Sheets",description:"Add a new row to Google Spreadsheets for every new lead from Facebook Lead Ads.",icon:"fb",iconBg:"bg-blue-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Facebook",subtitle:"Facebook Lead Ads",position:{x:100,y:200},icon:"fb",iconBg:"bg-blue-600",actionNumber:1,appData:De("facebook")},{id:"node-action-1",type:"action",title:"Google Sheets",subtitle:"Add Row (Lead Data)",position:{x:500,y:200},icon:"GS",iconBg:"bg-green-600",actionNumber:2,appData:De("google_sheets")}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"}]}},{id:"fluent-forms-mailrefine-sheets",name:"Fluent Forms + MailRefine to Google Sheets",description:"Verify email submitted in Fluent Forms using MailRefine, then add the details to Google Sheets.",icon:"FF",iconBg:"bg-green-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Fluent Forms",subtitle:"Form submitted",position:{x:100,y:200},icon:"FF",iconBg:"bg-green-600",actionNumber:1,appData:De("fluent_forms")},{id:"node-action-1",type:"action",title:"MailRefine",subtitle:"Verify Email",position:{x:400,y:200},icon:"MR",iconBg:"bg-violet-600",actionNumber:2,appData:De("mailrefine")},{id:"node-action-2",type:"action",title:"Google Sheets",subtitle:"Add Row (Form Data)",position:{x:700,y:200},icon:"GS",iconBg:"bg-green-600",actionNumber:3,appData:De("google_sheets")}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"}]}},{id:"cf7-to-fluentcrm-sheets",name:"Contact Form 7 to FluentCRM + Google Sheets",description:"Create a new contact in FluentCRM and add a row in Google Sheets on every Contact Form 7 submission.",icon:"C7",iconBg:"bg-black",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Contact Form 7",subtitle:"Form submitted",position:{x:100,y:200},icon:"C7",iconBg:"bg-black",actionNumber:1,appData:De("cf7")},{id:"node-action-1",type:"action",title:"FluentCRM",subtitle:"Create/Update Contact",position:{x:400,y:200},icon:"FC",iconBg:"bg-blue-700",actionNumber:2,appData:De("fluentcrm")},{id:"node-action-2",type:"action",title:"Google Sheets",subtitle:"Add Row (Form Data)",position:{x:700,y:200},icon:"GS",iconBg:"bg-green-600",actionNumber:3,appData:De("google_sheets")}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"}]}},{id:"wpforms-mailrefine-filters-sheets",name:"WPForms + MailRefine + Filters to Google Sheets",description:"Validate the email from a WPForms submission with MailRefine, filter on the result, then add a row to Google Sheets.",icon:"F",iconBg:"bg-orange-500",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WPForms",subtitle:"Form submitted",position:{x:100,y:200},icon:"F",iconBg:"bg-orange-500",actionNumber:1,appData:De("wpforms")},{id:"node-action-1",type:"action",title:"MailRefine",subtitle:"Verify Email",position:{x:380,y:200},icon:"MR",iconBg:"bg-violet-600",actionNumber:2,appData:De("mailrefine")},{id:"node-action-2",type:"action",title:"Filters",subtitle:"Filter / Condition",position:{x:660,y:200},icon:"FT",iconBg:"bg-yellow-500",actionNumber:3,appData:De("filters")},{id:"node-action-3",type:"action",title:"Google Sheets",subtitle:"Add Row (Form Data)",position:{x:940,y:200},icon:"GS",iconBg:"bg-green-600",actionNumber:4,appData:De("google_sheets")}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-2",to:"node-action-3",fromHandle:"right",toHandle:"left"}]}},{id:"wp-post-to-social-media",name:"WP Post to FB, Insta, LinkedIn + Google Sheets + Telegram",description:"On WordPress post publish: generate AI-optimised posts for each platform, publish to Facebook, Instagram, LinkedIn and Telegram, then save post info to Google Sheets.",isPro:!0,icon:"W",iconBg:"bg-blue-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WordPress",subtitle:"Post / Page published",position:{x:100,y:320},icon:"W",iconBg:"bg-blue-600",actionNumber:1,appData:De("wordpress")},{id:"node-action-1",type:"action",title:"WordPress",subtitle:"Generate Social Posts (FB & Telegram)",position:{x:380,y:320},icon:"W",iconBg:"bg-blue-600",actionNumber:2,appData:De("wordpress")},{id:"node-action-2",type:"action",title:"Facebook",subtitle:"Create Page Post",position:{x:680,y:80},icon:"fb",iconBg:"bg-blue-600",actionNumber:3,appData:De("facebook")},{id:"node-action-3",type:"action",title:"Telegram",subtitle:"Send Message",position:{x:680,y:240},icon:"Tg",iconBg:"bg-blue-500",actionNumber:4,appData:De("telegram")},{id:"node-action-4",type:"action",title:"WordPress",subtitle:"Generate Social Posts (Insta, WhatsApp, LinkedIn)",position:{x:680,y:400},icon:"W",iconBg:"bg-blue-600",actionNumber:5,appData:De("wordpress")},{id:"node-action-5",type:"action",title:"Instagram",subtitle:"Publish Photo",position:{x:980,y:240},icon:"Ig",iconBg:"bg-pink-500",actionNumber:6,appData:De("instagram")},{id:"node-action-6",type:"action",title:"LinkedIn",subtitle:"Create Text Post",position:{x:980,y:400},icon:"In",iconBg:"bg-sky-600",actionNumber:7,appData:De("linkedin")},{id:"node-action-7",type:"action",title:"Google Sheets",subtitle:"Add Row (Post Info)",position:{x:980,y:560},icon:"GS",iconBg:"bg-green-600",actionNumber:8,appData:De("google_sheets")}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-1",to:"node-action-3",fromHandle:"right",toHandle:"left"},{id:"conn-4",from:"node-action-1",to:"node-action-4",fromHandle:"right",toHandle:"left"},{id:"conn-5",from:"node-action-4",to:"node-action-5",fromHandle:"right",toHandle:"left"},{id:"conn-6",from:"node-action-4",to:"node-action-6",fromHandle:"right",toHandle:"left"},{id:"conn-7",from:"node-action-4",to:"node-action-7",fromHandle:"right",toHandle:"left"}]}},{id:"sub-workflow-email-validation",name:"Sub-Workflow: Extract Email",description:"A reusable sub-workflow that extracts an email address from text using regex and returns it.",icon:"WF",iconBg:"bg-teal-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Workflows",subtitle:"Sub-Workflow Trigger",position:{x:100,y:200},icon:"WF",iconBg:"bg-teal-600",actionNumber:1,appData:De("workflow")},{id:"node-action-1",type:"action",title:"Text Formatter",subtitle:"Extract Email",position:{x:400,y:200},icon:"T",iconBg:"bg-teal-600",actionNumber:2,appData:De("text_formatter"),data:{actionId:"extract_pattern",config:{text:"{raw_text}",pattern:"/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/i"}}},{id:"node-action-2",type:"action",title:"Workflows",subtitle:"Return Values",position:{x:700,y:200},icon:"WF",iconBg:"bg-teal-600",actionNumber:3,appData:De("workflow"),data:{actionId:"return_values",config:{values:[{key:"email",value:"{node-action-1.output}"},{key:"is_valid",value:"true"}]}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"}]}},{id:"parent-workflow-google-forms",name:"Google Forms to MailChimp via Sub-Workflow",description:"Calls a sub-workflow to extract email from form data, then adds the subscriber to MailChimp.",icon:"WF",iconBg:"bg-teal-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Webhook",subtitle:"Incoming Webhook",position:{x:100,y:200},icon:"W",iconBg:"bg-violet-600",actionNumber:1,appData:De("webhook")},{id:"node-action-1",type:"action",title:"Workflows",subtitle:"Call Sub-Workflow",position:{x:400,y:200},icon:"WF",iconBg:"bg-teal-600",actionNumber:2,appData:De("workflow"),data:{actionId:"call_sub_workflow",config:{inputs:[{key:"raw_text",value:"{contact_field}"}]}}},{id:"node-action-2",type:"action",title:"Filters",subtitle:"Only if Valid",position:{x:700,y:200},icon:"FT",iconBg:"bg-yellow-500",actionNumber:3,appData:De("filters"),data:{actionId:"filter_condition",config:{field:"{node-action-1.is_valid}",operator:"equals",value:"true"}}},{id:"node-action-3",type:"action",title:"MailChimp",subtitle:"Add Subscriber",position:{x:1e3,y:200},icon:"MC",iconBg:"bg-yellow-400",actionNumber:4,appData:De("mailchimp"),data:{actionId:"add_subscriber",config:{email:"{node-action-1.email}"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-2",to:"node-action-3",fromHandle:"right",toHandle:"left"}]}},{id:"wc-review-followup-whatsapp",name:"Post-Purchase Review Follow-up (WhatsApp)",description:"5 days after an order is marked Completed, automatically send a WhatsApp template message asking the customer for a product review.",isPro:!0,icon:"WA",iconBg:"bg-green-500",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WooCommerce",subtitle:"Order Status → Completed",position:{x:100,y:200},icon:"WC",iconBg:"bg-purple-600",actionNumber:1,appData:De("woocommerce"),data:{actionId:"wc_order_status_change",config:{new_status:"completed"}}},{id:"node-action-1",type:"action",title:"Delay",subtitle:"Wait 5 Days",position:{x:380,y:200},icon:"⏱",iconBg:"bg-slate-500",actionNumber:2,appData:De("delay"),data:{actionId:"delay_execution",config:{delay_amount:"5",delay_unit:"days"}}},{id:"node-action-2",type:"action",title:"WhatsApp",subtitle:"Send Template Message",position:{x:660,y:200},icon:"WA",iconBg:"bg-green-500",actionNumber:3,appData:De("whatsapp"),data:{actionId:"wa_send_template",config:{phone_number_id:"",to:"{billing_phone}",template_name:"order_review_request",language_code:"en_US",body_parameters:"{billing_name}\n{order_id}"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"}]}},{id:"wc-order-completed-whatsapp-message",name:"Order Completed – WhatsApp Thank You + Tracking",description:"Instantly send a personalised WhatsApp message with order details and a thank-you note when an order is marked Completed.",isPro:!0,icon:"WA",iconBg:"bg-green-500",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WooCommerce",subtitle:"Order Status → Completed",position:{x:100,y:200},icon:"WC",iconBg:"bg-purple-600",actionNumber:1,appData:De("woocommerce"),data:{actionId:"wc_order_status_change",config:{new_status:"completed"}}},{id:"node-action-1",type:"action",title:"WhatsApp",subtitle:"Send Thank You + Tracking Message",position:{x:420,y:200},icon:"WA",iconBg:"bg-green-500",actionNumber:2,appData:De("whatsapp"),data:{actionId:"wa_send_message",config:{phone_number_id:"",to:"{billing_phone}",message:"Hi {billing_name} 👋\n\nThank you for your order! 🎉\n\nYour order *#{order_id}* has been completed and is on its way.\n\n📦 *Order Summary:*\n{items}\n\n💰 *Total:* {total} {currency}\n\nIf you have any questions, just reply to this message. We appreciate your business! 🙏\n\n— Your Store Team"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"}]}},{id:"wc-order-completed-whatsapp-template",name:"Order Completed – WhatsApp Template Message (Tracking)",description:"Send a pre-approved WhatsApp template message with tracking info and a thank-you note the moment an order is completed. Best for high-volume stores requiring Meta compliance.",isPro:!0,icon:"WA",iconBg:"bg-green-500",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WooCommerce",subtitle:"Order Status → Completed",position:{x:100,y:200},icon:"WC",iconBg:"bg-purple-600",actionNumber:1,appData:De("woocommerce"),data:{actionId:"wc_order_status_change",config:{new_status:"completed"}}},{id:"node-action-1",type:"action",title:"WhatsApp",subtitle:"Send Template: Order Completed",position:{x:420,y:200},icon:"WA",iconBg:"bg-green-500",actionNumber:2,appData:De("whatsapp"),data:{actionId:"wa_send_template",config:{phone_number_id:"",to:"{billing_phone}",template_name:"order_completed_notification",language_code:"en_US",body_parameters:"{billing_name}\n{order_id}\n{total} {currency}"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"}]}},{id:"wpforms-lead-to-whatsapp-alert",name:"WPForms Lead to WhatsApp Alert + User Creation",description:"When a high-priority lead submits a WPForms form, instantly alert the sales team via WhatsApp and optionally create a new WordPress user.",isPro:!0,icon:"F",iconBg:"bg-orange-500",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WPForms",subtitle:"Form submitted",position:{x:100,y:200},icon:"F",iconBg:"bg-orange-500",actionNumber:1,appData:De("wpforms"),data:{actionId:"wpforms_submit",config:{form_id:""}}},{id:"node-action-1",type:"action",title:"Filters",subtitle:"High-Priority Lead Check",position:{x:380,y:200},icon:"FT",iconBg:"bg-yellow-500",actionNumber:2,appData:De("filters"),data:{actionId:"filter_condition",config:{field:"{service_type}",operator:"contains",value:"enterprise"}}},{id:"node-action-2",type:"action",title:"WhatsApp",subtitle:"Alert Sales Team",position:{x:660,y:120},icon:"WA",iconBg:"bg-green-500",actionNumber:3,appData:De("whatsapp"),data:{actionId:"wa_send_template",config:{phone_number_id:"",to:"{admin_whatsapp_number}",template_name:"new_lead_alert",language_code:"en_US",body_parameters:"{your-name}\n{your-email}\n{service_type}\n{budget}"}}},{id:"node-action-3",type:"action",title:"WordPress",subtitle:"Create New User",position:{x:660,y:300},icon:"W",iconBg:"bg-blue-600",actionNumber:4,appData:De("wordpress"),data:{actionId:"wp_create_user",config:{user_email:"{your-email}",user_login:"{your-email}",first_name:"{your-name}",role:"subscriber"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-1",to:"node-action-3",fromHandle:"right",toHandle:"left"}]}},{id:"webhook-json-woocommerce-sync",name:"External Inventory & Price Sync via JSON Webhook",description:"Receive a supplier JSON payload via webhook, parse it with JSON Parser, and automatically update the matching WooCommerce product's price or stock.",isPro:!0,icon:"{}",iconBg:"bg-yellow-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Webhook",subtitle:"Incoming Webhook",position:{x:100,y:200},icon:"W",iconBg:"bg-violet-600",actionNumber:1,appData:De("webhook"),data:{actionId:"incoming_webhook",config:{}}},{id:"node-action-1",type:"action",title:"JSON Parser",subtitle:"Parse Supplier Payload",position:{x:380,y:200},icon:"{}",iconBg:"bg-yellow-600",actionNumber:2,appData:De("json_parser"),data:{actionId:"parse_json_text",config:{json_text:"{body}"}}},{id:"node-action-2",type:"action",title:"WooCommerce",subtitle:"Update Product Price / Stock",position:{x:660,y:200},icon:"WC",iconBg:"bg-purple-600",actionNumber:3,appData:De("woocommerce"),data:{actionId:"wc_update_product",config:{product_id:"{product_id}",regular_price:"{price}",stock_quantity:"{stock}"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"}]}},{id:"scrape-to-wp-post",name:"Scrape Webpage & Publish AI-Rewritten WordPress Post",description:"Triggered by an incoming webhook with a URL, fetches and parses the webpage, rewrites the content with AI, then saves it as a WordPress draft post.",isPro:!0,icon:"🌐",iconBg:"bg-teal-500",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Webhook",subtitle:"Incoming Webhook (with URL)",position:{x:100,y:200},icon:"W",iconBg:"bg-violet-600",actionNumber:1,appData:De("webhook"),data:{actionId:"incoming_webhook",config:{}}},{id:"node-action-1",type:"action",title:"Webpage Parser",subtitle:"Fetch & Parse URL",position:{x:380,y:200},icon:"🌐",iconBg:"bg-teal-500",actionNumber:2,appData:De("webpage_parser"),data:{actionId:"parse_webpage_url",config:{webpage_url:"{url}"}}},{id:"node-action-2",type:"action",title:"OpenAI",subtitle:"Rewrite Content",position:{x:660,y:200},icon:"OA",iconBg:"bg-emerald-600",actionNumber:3,appData:De("openai"),data:{actionId:"chat_completion",config:{model:"gpt-4o-mini",prompt:'You are a professional content writer. Rewrite the following article in your own words, ensuring it is original, SEO-friendly, and engaging. Return a JSON object with two keys: "title" (a compelling post title) and "content" (the full HTML body of the rewritten article).\n\nOriginal Title: {node-action-1.title}\n\nOriginal Content:\n{node-action-1.content}',max_tokens:2e3,temperature:.7}}},{id:"node-action-3",type:"action",title:"WordPress",subtitle:"Create Draft Post",position:{x:940,y:200},icon:"W",iconBg:"bg-blue-600",actionNumber:4,appData:De("wordpress"),data:{actionId:"wp_create_post",config:{post_title:"{node-action-2.title}",post_content:"{node-action-2.content}",post_status:"draft"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-2",to:"node-action-3",fromHandle:"right",toHandle:"left"}]}},{id:"smart-lead-qualifier-crm-router",name:"Smart Lead Qualifier & CRM Router (AI)",description:"WPForms lead submission is analysed by AI to determine lead value. High-value leads get a VIP tag in FluentCRM and an instant WhatsApp alert; low-value leads are added to a nurture sequence.",isPro:!0,icon:"OA",iconBg:"bg-emerald-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WPForms",subtitle:"Form submitted",position:{x:100,y:260},icon:"F",iconBg:"bg-orange-500",actionNumber:1,appData:De("wpforms"),data:{actionId:"wpforms_submit",config:{form_id:""}}},{id:"node-action-1",type:"action",title:"OpenAI",subtitle:"Qualify Lead Intent & Value",position:{x:380,y:260},icon:"OA",iconBg:"bg-emerald-600",actionNumber:2,appData:De("openai"),data:{actionId:"chat_completion",config:{model:"gpt-4o-mini",prompt:'Analyse this lead submission and respond with ONLY a JSON object (no markdown) containing two keys:\n- "tier": either "high" or "low"\n- "budget": the numeric budget mentioned (0 if not stated)\n\nLead Message: {message}\nBudget Field: {budget}\nService: {service_type}',max_tokens:100,temperature:.2}}},{id:"node-action-2",type:"action",title:"Filters",subtitle:"High-Value Lead?",position:{x:660,y:140},icon:"FT",iconBg:"bg-yellow-500",actionNumber:3,appData:De("filters"),data:{actionId:"filter_condition",config:{field:"{node-action-1.tier}",operator:"equals",value:"high"}}},{id:"node-action-3",type:"action",title:"FluentCRM",subtitle:"Add VIP Tag & Create Contact",position:{x:940,y:80},icon:"FC",iconBg:"bg-blue-700",actionNumber:4,appData:De("fluentcrm"),data:{actionId:"create_contact",config:{email:"{your-email}",first_name:"{your-name}",status:"subscribed",tags:"VIP, high-value"}}},{id:"node-action-4",type:"action",title:"WhatsApp",subtitle:"Alert Sales Team (VIP Lead)",position:{x:940,y:220},icon:"WA",iconBg:"bg-green-500",actionNumber:5,appData:De("whatsapp"),data:{actionId:"wa_send_message",config:{phone_number_id:"",to:"{admin_whatsapp_number}",message:"🔥 *VIP Lead Alert!*\n\nName: {your-name}\nEmail: {your-email}\nService: {service_type}\nBudget: {node-action-1.budget}\n\nRespond within 1 hour for best conversion!"}}},{id:"node-action-5",type:"action",title:"Filters",subtitle:"Low-Value Lead?",position:{x:660,y:380},icon:"FT",iconBg:"bg-yellow-500",actionNumber:6,appData:De("filters"),data:{actionId:"filter_condition",config:{field:"{node-action-1.tier}",operator:"equals",value:"low"}}},{id:"node-action-6",type:"action",title:"FluentCRM",subtitle:"Add to Nurture Sequence",position:{x:940,y:380},icon:"FC",iconBg:"bg-blue-700",actionNumber:7,appData:De("fluentcrm"),data:{actionId:"create_contact",config:{email:"{your-email}",first_name:"{your-name}",status:"subscribed",tags:"nurture, follow-up"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-2",to:"node-action-3",fromHandle:"right",toHandle:"left"},{id:"conn-4",from:"node-action-2",to:"node-action-4",fromHandle:"right",toHandle:"left"},{id:"conn-5",from:"node-action-1",to:"node-action-5",fromHandle:"right",toHandle:"left"},{id:"conn-6",from:"node-action-5",to:"node-action-6",fromHandle:"right",toHandle:"left"}]}},{id:"multilingual-support-auto-responder",name:"Multilingual Support Auto-Responder (AI)",description:"Contact Form 7 submission is analysed by AI which detects the language, translates it to English for the admin, and drafts a contextual reply in the customer's original language — sent via email and WhatsApp.",isPro:!0,icon:"OA",iconBg:"bg-emerald-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Contact Form 7",subtitle:"Form submitted",position:{x:100,y:260},icon:"C7",iconBg:"bg-black",actionNumber:1,appData:De("cf7"),data:{actionId:"cf7_submit",config:{form_id:""}}},{id:"node-action-1",type:"action",title:"OpenAI",subtitle:"Detect Language & Translate",position:{x:380,y:260},icon:"OA",iconBg:"bg-emerald-600",actionNumber:2,appData:De("openai"),data:{actionId:"chat_completion",config:{model:"gpt-4o-mini",prompt:'You are a multilingual support assistant. Given the customer message below, respond with ONLY a JSON object (no markdown) with these keys:\n- "detected_language": the full language name (e.g. "Spanish")\n- "english_translation": the full message translated to English\n- "customer_reply": a friendly, helpful support reply written in the SAME language as the original message\n\nCustomer Name: {your-name}\nCustomer Message: {your-message}',max_tokens:800,temperature:.5}}},{id:"node-action-2",type:"action",title:"Mail",subtitle:"Notify Admin (English Translation)",position:{x:660,y:140},icon:"M",iconBg:"bg-gray-700",actionNumber:3,appData:De("mail"),data:{actionId:"send_email",config:{to_email:"{admin_email}",subject:"New Support Request ({node-action-1.detected_language}) from {your-name}",body:"<h3>New Multilingual Support Request</h3><p><strong>Customer:</strong> {your-name} ({your-email})</p><p><strong>Language:</strong> {node-action-1.detected_language}</p><p><strong>Original Message:</strong><br>{your-message}</p><p><strong>English Translation:</strong><br>{node-action-1.english_translation}</p>",is_html:!0}}},{id:"node-action-3",type:"action",title:"WhatsApp",subtitle:"Send Reply to Customer",position:{x:660,y:320},icon:"WA",iconBg:"bg-green-500",actionNumber:4,appData:De("whatsapp"),data:{actionId:"wa_send_message",config:{phone_number_id:"",to:"{your-phone}",message:"{node-action-1.customer_reply}"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-1",to:"node-action-3",fromHandle:"right",toHandle:"left"}]}},{id:"support-to-knowledge-base",name:"Automated Support → Knowledge Base Post (AI)",description:"When a FluentCRM contact note is updated, AI anonymises the data, extracts the core problem and solution, and creates a clean FAQ draft as a WordPress post.",isPro:!0,icon:"OA",iconBg:"bg-emerald-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Webhook",subtitle:"FluentCRM Note Updated (Webhook)",position:{x:100,y:200},icon:"W",iconBg:"bg-violet-600",actionNumber:1,appData:De("webhook"),data:{actionId:"incoming_webhook",config:{}}},{id:"node-action-1",type:"action",title:"OpenAI",subtitle:"Anonymise & Extract FAQ",position:{x:380,y:200},icon:"OA",iconBg:"bg-emerald-600",actionNumber:2,appData:De("openai"),data:{actionId:"chat_completion",config:{model:"gpt-4o-mini",prompt:'You are a technical writer. Given the support interaction below, respond with ONLY a JSON object (no markdown) with these keys:\n- "faq_title": a concise FAQ-style question (the core problem)\n- "faq_content": a clean HTML answer (the solution), fully anonymised with no personal data\n- "should_publish": true if the resolution quality is good enough to publish, false otherwise\n\nSupport Note:\n{note_content}',max_tokens:1e3,temperature:.4}}},{id:"node-action-2",type:"action",title:"Filters",subtitle:"Only if Quality is Good",position:{x:660,y:200},icon:"FT",iconBg:"bg-yellow-500",actionNumber:3,appData:De("filters"),data:{actionId:"filter_condition",config:{field:"{node-action-1.should_publish}",operator:"is_true",value:""}}},{id:"node-action-3",type:"action",title:"WordPress",subtitle:"Create FAQ Draft Post",position:{x:940,y:200},icon:"W",iconBg:"bg-blue-600",actionNumber:4,appData:De("wordpress"),data:{actionId:"wp_create_post",config:{post_title:"{node-action-1.faq_title}",post_content:"{node-action-1.faq_content}",post_status:"draft",categories:"FAQ, Knowledge Base"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-2",to:"node-action-3",fromHandle:"right",toHandle:"left"}]}},{id:"wc-review-sentiment-shield",name:"WooCommerce Review Sentiment Shield (AI)",description:"When a WooCommerce product review is created, AI analyses the sentiment. Negative reviews trigger a personalised apology via WhatsApp and a discount coupon email; positive reviews are approved automatically.",isPro:!0,icon:"OA",iconBg:"bg-emerald-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Webhook",subtitle:"WooCommerce Product Review Created",position:{x:100,y:260},icon:"W",iconBg:"bg-violet-600",actionNumber:1,appData:De("webhook"),data:{actionId:"incoming_webhook",config:{}}},{id:"node-action-1",type:"action",title:"OpenAI",subtitle:"Analyse Review Sentiment",position:{x:380,y:260},icon:"OA",iconBg:"bg-emerald-600",actionNumber:2,appData:De("openai"),data:{actionId:"chat_completion",config:{model:"gpt-4o-mini",prompt:'Analyse this product review and respond with ONLY a JSON object (no markdown) with these keys:\n- "sentiment": either "positive" or "negative"\n- "complaint_type": if negative, either "shipping" or "product_quality" or "other"; if positive use "none"\n- "apology_message": if negative, a personalised, empathetic WhatsApp message (2-3 sentences) addressing the specific complaint and offering a 10% discount code SAVE10\n\nReview Rating: {rating}\nReview Text: {review_content}\nProduct: {product_name}',max_tokens:400,temperature:.6}}},{id:"node-action-2",type:"action",title:"Filters",subtitle:"Is Negative Review?",position:{x:660,y:160},icon:"FT",iconBg:"bg-yellow-500",actionNumber:3,appData:De("filters"),data:{actionId:"filter_condition",config:{field:"{node-action-1.sentiment}",operator:"equals",value:"negative"}}},{id:"node-action-3",type:"action",title:"WhatsApp",subtitle:"Send Apology + Coupon",position:{x:940,y:100},icon:"WA",iconBg:"bg-green-500",actionNumber:4,appData:De("whatsapp"),data:{actionId:"wa_send_message",config:{phone_number_id:"",to:"{reviewer_phone}",message:"{node-action-1.apology_message}"}}},{id:"node-action-4",type:"action",title:"Mail",subtitle:"Email Discount Coupon",position:{x:940,y:240},icon:"M",iconBg:"bg-gray-700",actionNumber:5,appData:De("mail"),data:{actionId:"send_email",config:{to_email:"{reviewer_email}",subject:"We're sorry — here's 10% off your next order",body:"<p>Dear {reviewer_name},</p><p>We sincerely apologise for your experience with <strong>{product_name}</strong>. As a token of our appreciation for your feedback, please use code <strong>SAVE10</strong> for 10% off your next order.</p><p>Thank you for helping us improve!</p>",is_html:!0}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-2",to:"node-action-3",fromHandle:"right",toHandle:"left"},{id:"conn-4",from:"node-action-2",to:"node-action-4",fromHandle:"right",toHandle:"left"}]}},{id:"price-monitor-updater",name:"AI Price Monitor & WooCommerce Auto-Updater",description:"Receive supplier pricing data via webhook, let AI compare it against your current margins, and automatically update WooCommerce sale prices or trigger a low-margin alert.",isPro:!0,icon:"OA",iconBg:"bg-emerald-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Webhook",subtitle:"Supplier Price Feed (Incoming)",position:{x:100,y:200},icon:"W",iconBg:"bg-violet-600",actionNumber:1,appData:De("webhook"),data:{actionId:"incoming_webhook",config:{}}},{id:"node-action-1",type:"action",title:"JSON Parser",subtitle:"Parse Supplier Feed",position:{x:380,y:200},icon:"{}",iconBg:"bg-yellow-600",actionNumber:2,appData:De("json_parser"),data:{actionId:"parse_json_text",config:{json_text:"{body}"}}},{id:"node-action-2",type:"action",title:"OpenAI",subtitle:"Evaluate Pricing Decision",position:{x:660,y:200},icon:"OA",iconBg:"bg-emerald-600",actionNumber:3,appData:De("openai"),data:{actionId:"chat_completion",config:{model:"gpt-4o-mini",prompt:'You are a pricing strategist. Given the supplier cost and the current store price, respond with ONLY a JSON object (no markdown) with these keys:\n- "action": either "update_price", "low_margin_alert", or "no_change"\n- "new_sale_price": the recommended sale price (number, 0 if no change)\n- "margin_percent": the calculated profit margin percentage\n- "reason": a one-sentence explanation\n\nSupplier Cost: {node-action-1.supplier_cost}\nCurrent Store Price: {node-action-1.current_price}\nTarget Margin: 30%',max_tokens:200,temperature:.2}}},{id:"node-action-3",type:"action",title:"Filters",subtitle:"Should Update Price?",position:{x:940,y:120},icon:"FT",iconBg:"bg-yellow-500",actionNumber:4,appData:De("filters"),data:{actionId:"filter_condition",config:{field:"{node-action-2.action}",operator:"equals",value:"update_price"}}},{id:"node-action-4",type:"action",title:"WooCommerce",subtitle:"Update Product Sale Price",position:{x:1220,y:80},icon:"WC",iconBg:"bg-purple-600",actionNumber:5,appData:De("woocommerce"),data:{actionId:"wc_update_product",config:{product_id:"{node-action-1.product_id}",sale_price:"{node-action-2.new_sale_price}"}}},{id:"node-action-5",type:"action",title:"Filters",subtitle:"Low Margin Alert?",position:{x:940,y:300},icon:"FT",iconBg:"bg-yellow-500",actionNumber:6,appData:De("filters"),data:{actionId:"filter_condition",config:{field:"{node-action-2.action}",operator:"equals",value:"low_margin_alert"}}},{id:"node-action-6",type:"action",title:"Mail",subtitle:"Send Margin Warning Email",position:{x:1220,y:300},icon:"M",iconBg:"bg-gray-700",actionNumber:7,appData:De("mail"),data:{actionId:"send_email",config:{to_email:"{admin_email}",subject:"⚠️ Low Margin Alert: Product #{node-action-1.product_id}",body:"<h3>Inventory Margin Warning</h3><p>Product <strong>#{node-action-1.product_id}</strong> has dropped below the 30% margin threshold.</p><p><strong>Supplier Cost:</strong> {node-action-1.supplier_cost}<br><strong>Current Price:</strong> {node-action-1.current_price}<br><strong>Margin:</strong> {node-action-2.margin_percent}%</p><p><strong>Recommendation:</strong> {node-action-2.reason}</p>",is_html:!0}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-2",to:"node-action-3",fromHandle:"right",toHandle:"left"},{id:"conn-4",from:"node-action-3",to:"node-action-4",fromHandle:"right",toHandle:"left"},{id:"conn-5",from:"node-action-2",to:"node-action-5",fromHandle:"right",toHandle:"left"},{id:"conn-6",from:"node-action-5",to:"node-action-6",fromHandle:"right",toHandle:"left"}]}},{id:"news-aggregator-to-blog",name:"Automated News Aggregator → AI Blog Post",description:"Triggered by an incoming webhook with article URLs, AI fetches and blends multiple news sources into a single original blog post saved as a WordPress draft ready for editorial review.",isPro:!0,icon:"OA",iconBg:"bg-emerald-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"Webhook",subtitle:"Incoming Webhook (Article URLs)",position:{x:100,y:200},icon:"W",iconBg:"bg-violet-600",actionNumber:1,appData:De("webhook"),data:{actionId:"incoming_webhook",config:{}}},{id:"node-action-1",type:"action",title:"Webpage Parser",subtitle:"Fetch First Article",position:{x:380,y:120},icon:"🌐",iconBg:"bg-teal-500",actionNumber:2,appData:De("webpage_parser"),data:{actionId:"parse_webpage_url",config:{webpage_url:"{url_1}"}}},{id:"node-action-2",type:"action",title:"Webpage Parser",subtitle:"Fetch Second Article",position:{x:380,y:280},icon:"🌐",iconBg:"bg-teal-500",actionNumber:3,appData:De("webpage_parser"),data:{actionId:"parse_webpage_url",config:{webpage_url:"{url_2}"}}},{id:"node-action-3",type:"action",title:"OpenAI",subtitle:"Blend & Write Original Article",position:{x:700,y:200},icon:"OA",iconBg:"bg-emerald-600",actionNumber:4,appData:De("openai"),data:{actionId:"chat_completion",config:{model:"gpt-4o",prompt:'You are a professional journalist and content writer. Read the following articles and blend them into a single, original, engaging blog post. Do NOT copy — summarise the key takeaways and present them in a fresh perspective. Respond with ONLY a JSON object (no markdown) with two keys:\n- "title": a compelling, SEO-friendly blog post title\n- "content": the full HTML body of the article (600-900 words, with proper headings)\n\nArticle 1 Title: {node-action-1.title}\nArticle 1 Content: {node-action-1.content}\n\nArticle 2 Title: {node-action-2.title}\nArticle 2 Content: {node-action-2.content}',max_tokens:2500,temperature:.75}}},{id:"node-action-4",type:"action",title:"WordPress",subtitle:"Save as Draft Post",position:{x:980,y:200},icon:"W",iconBg:"bg-blue-600",actionNumber:5,appData:De("wordpress"),data:{actionId:"wp_create_post",config:{post_title:"{node-action-3.title}",post_content:"{node-action-3.content}",post_status:"draft",categories:"News, Industry Updates"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-trigger-1",to:"node-action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"node-action-1",to:"node-action-3",fromHandle:"right",toHandle:"left"},{id:"conn-4",from:"node-action-2",to:"node-action-3",fromHandle:"right",toHandle:"left"},{id:"conn-5",from:"node-action-3",to:"node-action-4",fromHandle:"right",toHandle:"left"}]}},{id:"ai-product-description-enhancer",name:"AI Product Description Enhancer (WooCommerce)",description:"When a WooCommerce product is created or updated, AI reads the basic attributes and generates an SEO-optimised meta title, meta description, and a compelling long-form product description.",isPro:!0,icon:"OA",iconBg:"bg-emerald-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WooCommerce",subtitle:"Product Added",position:{x:100,y:200},icon:"WC",iconBg:"bg-purple-600",actionNumber:1,appData:De("woocommerce"),data:{actionId:"wc_product_added",config:{}}},{id:"node-action-1",type:"action",title:"OpenAI",subtitle:"Generate SEO Content",position:{x:380,y:200},icon:"OA",iconBg:"bg-emerald-600",actionNumber:2,appData:De("openai"),data:{actionId:"chat_completion",config:{model:"gpt-4o-mini",prompt:'You are an expert eCommerce copywriter and SEO specialist. Given the product details below, respond with ONLY a JSON object (no markdown) with these keys:\n- "meta_title": an SEO-optimised meta title (max 60 characters)\n- "meta_description": a compelling meta description (max 160 characters)\n- "long_description": a full HTML product description (300-500 words) with bullet points for key features, benefits, and a call-to-action\n\nProduct Name: {product_name}\nProduct Category: {product_category}\nProduct Price: {product_price}\nExisting Short Description: {product_short_description}\nProduct Attributes: {product_attributes}',max_tokens:1200,temperature:.65}}},{id:"node-action-2",type:"action",title:"WooCommerce",subtitle:"Update Product Description & SEO",position:{x:700,y:200},icon:"WC",iconBg:"bg-purple-600",actionNumber:3,appData:De("woocommerce"),data:{actionId:"wc_update_product",config:{product_id:"{product_id}",description:"{node-action-1.long_description}",meta_title:"{node-action-1.meta_title}",meta_description:"{node-action-1.meta_description}"}}}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"}]}},{id:"wpbot-to-sheets",name:"WPBot Session to Google Sheet",description:"Automatically save WPBot chat session details (Name, Email, Phone) to a Google Sheet.",icon:"WB",iconBg:"bg-blue-500",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WPBot",subtitle:"Chat Session Saved",position:{x:100,y:200},icon:"WB",iconBg:"bg-blue-500",actionNumber:1,appData:De("wpbot")},{id:"node-action-1",type:"action",title:"Google Sheets",subtitle:"Add Row",position:{x:500,y:200},icon:"GS",iconBg:"bg-green-600",actionNumber:2,appData:De("google_sheets")}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"}]}},{id:"wpbot-ai-sheets",name:"WPBot AI Email Extractor to Google Sheets",description:"Chat sessions are sent to AI for analysis to extract email addresses, which are then saved in a Google Sheet.",icon:"OA",iconBg:"bg-emerald-600",workflow_data:{nodes:[{id:"node-trigger-1",type:"trigger",title:"WPBot",subtitle:"Chat Session Saved",position:{x:100,y:200},icon:"WB",iconBg:"bg-blue-500",actionNumber:1,appData:De("wpbot")},{id:"node-action-1",type:"action",title:"OpenAI",subtitle:"Extract Emails",position:{x:420,y:200},icon:"OA",iconBg:"bg-emerald-600",actionNumber:2,appData:De("openai"),data:{actionId:"chat_completion",config:{model:"gpt-4o-mini",prompt:"Extract any email addresses from the following chat transcript. If none are found, return 'No Email'. Return ONLY the email addresses comma-separated, with no other text.\n\nTranscript: {{wpbot.wpbot_chat_session_saved.conversation}}",max_tokens:100,temperature:.1}}},{id:"node-action-2",type:"action",title:"Google Sheets",subtitle:"Add Row",position:{x:740,y:200},icon:"GS",iconBg:"bg-green-600",actionNumber:3,appData:De("google_sheets")}],connections:[{id:"conn-1",from:"node-trigger-1",to:"node-action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"node-action-1",to:"node-action-2",fromHandle:"right",toHandle:"left"}]}},{id:"conversational-form-to-sheet-ai-email",name:"Conversational Form to Sheet, AI & Email",description:"Saves conversational form data to Google Sheets, generates an AI summary, and emails the response.",icon:"F",iconBg:"bg-orange-500",workflow_data:{nodes:[{id:"trigger-1",type:"trigger",title:"Chatbot Form Builder",subtitle:"Conversational Forms Submitted",position:{x:100,y:100},icon:"WB",iconBg:"bg-blue-500",actionNumber:1,appData:De("wpbot"),data:{actionId:"conversationalforms_submit",config:{}}},{id:"action-1",type:"action",title:"Google Sheets",subtitle:"Add row to Google Sheet",position:{x:400,y:100},icon:"GS",iconBg:"bg-green-600",actionNumber:2,appData:De("google_sheets"),data:{actionId:"add_row",config:{sheet_id:"your_google_sheet_id_here",worksheet:"Sheet1",row_data:["{{wpbot.conversationalforms_submit.name}}","{{wpbot.conversationalforms_submit.email}}"]}}},{id:"action-2",type:"action",title:"OpenAI",subtitle:"Generate Summary",position:{x:700,y:100},icon:"OA",iconBg:"bg-emerald-600",actionNumber:3,appData:De("openai"),data:{actionId:"chat_completion",config:{model:"gpt-4o-mini",prompt:"Summarize the following form submission: Name: {{wpbot.conversationalforms_submit.name}}, Email: {{wpbot.conversationalforms_submit.email}}",max_tokens:"150",temperature:"0.7"}}},{id:"action-3",type:"action",title:"Mail",subtitle:"Send Email Response",position:{x:1e3,y:100},icon:"M",iconBg:"bg-gray-700",actionNumber:4,appData:De("mail"),data:{actionId:"send_email",config:{to_email:"{{wpbot.conversationalforms_submit.email}}",subject:"Thank you for your submission",body:"Hello {{wpbot.conversationalforms_submit.name}},\n\nHere is a summary of your submission:\n{{openai.chat_completion.response}}",is_html:!1}}}],connections:[{id:"conn-1",from:"trigger-1",to:"action-1",fromHandle:"right",toHandle:"left"},{id:"conn-2",from:"action-1",to:"action-2",fromHandle:"right",toHandle:"left"},{id:"conn-3",from:"action-2",to:"action-3",fromHandle:"right",toHandle:"left"}]}}],Re=s("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]),Ee=s("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),Oe=s("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),He="wpbot_ai_gen_settings",Ue=e=>le.find(t=>t.id===e),Ge=(e,t)=>{const o=Ue(e);if(!o)return t;if(o.categories)for(const e of o.categories){const o=e.actions?.find(e=>e.id===t);if(o)return o.name}if(o.actions){const e=o.actions.find(e=>e.id===t);if(e)return e.name}return t},Ve={wordpress:{title:"WordPress",icon:"W",iconBg:"bg-blue-600"},woocommerce:{title:"WooCommerce",icon:"WC",iconBg:"bg-purple-600"},wpforms:{title:"WPForms",icon:"F",iconBg:"bg-orange-500"},cf7:{title:"Contact Form 7",icon:"C7",iconBg:"bg-black"},fluent_forms:{title:"Fluent Forms",icon:"FF",iconBg:"bg-green-600"},webhook:{title:"Webhook",icon:"Wh",iconBg:"bg-violet-600"},facebook:{title:"Facebook",icon:"fb",iconBg:"bg-blue-600"},google_sheets:{title:"Google Sheets",icon:"GS",iconBg:"bg-green-600"},mail:{title:"Mail",icon:"M",iconBg:"bg-gray-700"},telegram:{title:"Telegram",icon:"Tg",iconBg:"bg-blue-500"},whatsapp:{title:"WhatsApp",icon:"WA",iconBg:"bg-green-500"},instagram:{title:"Instagram",icon:"Ig",iconBg:"bg-pink-500"},linkedin:{title:"LinkedIn",icon:"In",iconBg:"bg-sky-600"},openai:{title:"OpenAI",icon:"OA",iconBg:"bg-emerald-600"},claude:{title:"Claude",icon:"CL",iconBg:"bg-amber-700"},gemini:{title:"Gemini",icon:"GE",iconBg:"bg-blue-500"},grok:{title:"Grok AI",icon:"GK",iconBg:"bg-slate-900"},mistral:{title:"Mistral AI",icon:"MI",iconBg:"bg-orange-600"},openrouter:{title:"OpenRouter",icon:"OR",iconBg:"bg-indigo-600"},fluentcrm:{title:"FluentCRM",icon:"FC",iconBg:"bg-blue-700"},filters:{title:"Filters",icon:"FT",iconBg:"bg-yellow-500"},iterator:{title:"Iterator",icon:"↻",iconBg:"bg-amber-500"},iterator_end:{title:"Iterator End",icon:"⏹",iconBg:"bg-amber-700"},api:{title:"API",icon:"A",iconBg:"bg-slate-700"},mailboxlayer:{title:"MailboxLayer",icon:"ML",iconBg:"bg-blue-600"},mailrefine:{title:"MailRefine",icon:"MR",iconBg:"bg-violet-600"}},$e=[{id:"openai",name:"OpenAI",models:["gpt-4o-mini","gpt-4o","gpt-4-turbo"]},{id:"claude",name:"Claude",models:["claude-3-5-sonnet-20240620","claude-3-haiku-20240307"]},{id:"gemini",name:"Gemini",models:["gemini-1.5-flash","gemini-2.0-flash","gemini-1.5-pro"]}];function ze(e){const{nodes:t,connections:o}=e,a=function(e,t){const o={};t.forEach(({from:e,to:t})=>{o[e]||(o[e]=[]),o[e].push(t)});const a={},n=new Set,r=[{idx:0,x:100,y:200}];for(;r.length;){const{idx:e,x:t,y:i}=r.shift();if(n.has(e))continue;n.add(e),a[e]={x:t,y:i};const s=o[e]||[],l=160*(s.length-1);s.forEach((e,o)=>{n.has(e)||r.push({idx:e,x:t+300,y:i-l/2+160*o})})}return a}(0,o);return{nodes:t.map((e,t)=>{const o=Ve[e.appId]||{title:e.appId,icon:"?",iconBg:"bg-gray-500"};return{id:0===t?"node-trigger-1":`node-action-${t}`,type:e.type,title:o.title,subtitle:Ge(e.appId,e.actionId),position:a[t]||{x:100+300*t,y:200},icon:o.icon,iconBg:o.iconBg,actionNumber:t+1,appData:Ue(e.appId)||null}}),connections:o.map((e,t)=>({id:`conn-${t+1}`,from:0===e.from?"node-trigger-1":`node-action-${e.from}`,to:0===e.to?"node-trigger-1":`node-action-${e.to}`,fromHandle:"right",toHandle:"left"}))}}var qe=({onSelect:e})=>{const[t,a]=(0,o.useState)(()=>{try{return JSON.parse(localStorage.getItem(He)||"{}")}catch{return{}}}),[n,r]=(0,o.useState)(""),[i,s]=(0,o.useState)(!1),[l,d]=(0,o.useState)(""),[c,m]=(0,o.useState)(null),p=t.provider||"openai",u=t.api_key||"",g=$e.find(e=>e.id===p)?.models||[],x=t.model&&g.includes(t.model)?t.model:g[0],h=e=>{const o={...t,...e};a(o),localStorage.setItem(He,JSON.stringify(o))};return(0,ie.jsxs)("div",{className:"space-y-4",children:[(0,ie.jsx)("p",{className:"text-sm text-muted-foreground -mt-1",children:"Describe your automation in plain English and AI will build the workflow for you."}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"block text-sm font-medium mb-1.5",children:"Describe your automation"}),(0,ie.jsx)("textarea",{rows:4,value:n,onChange:e=>r(e.target.value),placeholder:"e.g. When a WPForms form is submitted, save the data to Google Sheets and send a welcome email to the user",className:"w-full border border-border rounded-lg px-3 py-2.5 text-sm bg-background resize-none focus:outline-none focus:ring-2 focus:ring-primary/30",disabled:i})]}),(0,ie.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"AI Provider"}),(0,ie.jsx)("select",{value:p,onChange:e=>h({provider:e.target.value,model:""}),disabled:i,className:"w-full border border-border rounded-lg px-2.5 py-2 text-sm bg-background focus:outline-none",children:$e.map(e=>(0,ie.jsx)("option",{value:e.id,children:e.name},e.id))})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"Model"}),(0,ie.jsx)("select",{value:x,onChange:e=>h({model:e.target.value}),disabled:i,className:"w-full border border-border rounded-lg px-2.5 py-2 text-sm bg-background focus:outline-none",children:g.map(e=>(0,ie.jsx)("option",{value:e,children:e},e))})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"API Key"}),(0,ie.jsx)("input",{type:"password",value:u,onChange:e=>h({api_key:e.target.value}),placeholder:"sk-...",disabled:i,className:"w-full border border-border rounded-lg px-2.5 py-2 text-sm bg-background focus:outline-none"})]})]}),l&&(0,ie.jsx)("p",{className:"text-sm text-rose-600 bg-rose-50 border border-rose-200 rounded-lg px-3 py-2",children:l}),!c&&(0,ie.jsx)("button",{onClick:async()=>{if(n.trim())if(u.trim()){d(""),m(null),s(!0);try{const e=await fetch(`${window.wpbotAutomator.apiUrl}/generate-workflow`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpbotAutomator.nonce},body:JSON.stringify({provider:p,api_key:u,model:x,prompt:n.trim()})}),t=await e.json();if(!e.ok||!t.success)return void d(t.message||t.code||"Failed to generate. Please try again.");m(t.workflow)}catch{d("Network error. Please try again.")}finally{s(!1)}}else d("Please enter your API key.");else d("Please describe your workflow.")},disabled:i,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-primary text-primary-foreground rounded-lg font-medium text-sm hover:bg-primary/90 transition-colors disabled:opacity-60",children:i?(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(Fe,{className:"w-4 h-4 animate-spin"})," Generating..."]}):(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(Re,{className:"w-4 h-4"})," Generate Workflow"]})}),c&&(0,ie.jsxs)("div",{className:"border border-border rounded-xl overflow-hidden",children:[(0,ie.jsxs)("div",{className:"bg-muted/40 px-4 py-3 border-b border-border",children:[(0,ie.jsx)("p",{className:"font-semibold text-sm",children:c.name}),c.description&&(0,ie.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:c.description})]}),(0,ie.jsx)("div",{className:"px-4 py-3 space-y-2.5",children:c.nodes?.map((e,t)=>{const o=Ve[e.appId]||{icon:"?",iconBg:"bg-gray-500",title:e.appId};return(0,ie.jsxs)("div",{className:"flex items-center gap-3",children:[t>0&&(0,ie.jsx)("div",{className:"absolute ml-3.5 -mt-4 w-px h-3 bg-border",style:{marginTop:"-10px",position:"relative",left:"13px",top:"-8px",height:"8px"}}),(0,ie.jsx)("div",{className:`w-8 h-8 rounded-lg ${o.iconBg} flex items-center justify-center text-white text-[10px] font-bold shrink-0`,children:o.icon}),(0,ie.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,ie.jsx)("span",{className:"text-xs font-semibold text-foreground",children:o.title}),(0,ie.jsx)("span",{className:"text-xs text-muted-foreground ml-1.5",children:Ge(e.appId,e.actionId)})]}),0===t&&(0,ie.jsx)("span",{className:"text-[10px] bg-primary/10 text-primary font-semibold px-1.5 py-0.5 rounded shrink-0",children:"Trigger"})]},t)})}),(0,ie.jsxs)("div",{className:"flex gap-2 px-4 py-3 border-t border-border bg-muted/20",children:[(0,ie.jsxs)("button",{onClick:()=>m(null),className:"flex items-center gap-1.5 px-3 py-2 text-sm border border-border rounded-lg hover:bg-muted transition-colors",children:[(0,ie.jsx)(Ee,{className:"w-3.5 h-3.5"})," Regenerate"]}),(0,ie.jsxs)("button",{onClick:()=>{c&&e({id:null,name:c.name,description:c.description,workflow_data:ze(c)})},className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-2 text-sm bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors",children:["Use This Workflow ",(0,ie.jsx)(Oe,{className:"w-3.5 h-3.5"})]})]})]})]})},Je=({isOpen:e,onClose:t,onSelect:a,isProActive:n})=>{const[r,i]=(0,o.useState)("templates"),s=e=>{i("templates"),a(e)};return(0,ie.jsx)(Se,{isOpen:e,onClose:t,title:"Create New Workflow",maxWidth:"max-w-4xl",children:(0,ie.jsxs)("div",{className:"space-y-5",children:[(0,ie.jsxs)("div",{className:"flex gap-1 bg-muted/40 border border-border rounded-lg p-1 w-fit -mt-1",children:[(0,ie.jsx)("button",{onClick:()=>i("templates"),className:"px-4 py-1.5 text-sm font-medium rounded-md transition-colors "+("templates"===r?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:"Templates"}),(0,ie.jsxs)("button",{onClick:()=>i("ai"),className:"flex items-center gap-1.5 px-4 py-1.5 text-sm font-medium rounded-md transition-colors "+("ai"===r?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,ie.jsx)(Re,{className:"w-3.5 h-3.5"}),"AI Generator"]})]}),"templates"===r?(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)("p",{className:"text-sm text-muted-foreground -mt-2",children:"Start with a pre-configured workflow or start from scratch."}),(0,ie.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-2 gap-4",children:[(0,ie.jsxs)("div",{onClick:()=>s(null),className:"flex flex-col items-center justify-center p-6 border-2 border-dashed border-border rounded-xl hover:border-primary hover:bg-primary/5 cursor-pointer transition-all group text-center",children:[(0,ie.jsx)("div",{className:"w-12 h-12 rounded-full bg-muted flex items-center justify-center text-muted-foreground group-hover:bg-primary group-hover:text-primary-foreground transition-colors mb-3",children:(0,ie.jsx)(c,{className:"w-6 h-6"})}),(0,ie.jsx)("h3",{className:"font-bold text-lg text-foreground",children:"Start from Scratch"}),(0,ie.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Begin with an empty canvas and build your own workflow."})]}),Le.map(e=>{const t=e.isPro&&!n;return(0,ie.jsxs)("div",{onClick:()=>!t&&s(e),className:"relative flex flex-col p-6 border rounded-xl transition-all bg-card/50 group "+(t?"border-border opacity-60 cursor-not-allowed select-none":"border-border hover:border-primary hover:shadow-lg cursor-pointer"),children:[e.isPro&&(0,ie.jsxs)("span",{className:"absolute top-3 right-3 flex items-center gap-1 text-[10px] font-bold uppercase tracking-wide bg-amber-100 text-amber-700 border border-amber-300 rounded px-1.5 py-0.5",children:[t&&(0,ie.jsx)(_e,{className:"w-2.5 h-2.5"}),"PRO"]}),(0,ie.jsxs)("div",{className:"flex items-center space-x-4 mb-4",children:[(0,ie.jsx)("div",{className:`w-24 h-12 rounded-xl ${e.iconBg} flex items-center justify-center text-white text-sm font-bold shadow-sm ${t?"":"group-hover:scale-110"} transition-transform`,children:e.icon}),(0,ie.jsxs)("div",{className:"pr-8",children:[(0,ie.jsx)("h3",{className:"font-bold text-foreground leading-tight",children:e.name}),(0,ie.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Prebuilt"})]})]}),(0,ie.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-3",children:e.description}),t?(0,ie.jsxs)("div",{className:"mt-6 flex items-center text-xs font-medium text-amber-600",children:[(0,ie.jsx)(_e,{className:"w-3.5 h-3.5 mr-1.5"}),(0,ie.jsx)("span",{children:"Requires Pro license"}),(0,ie.jsx)("a",{href:"https://wpbot.pro",target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"ml-1 underline hover:text-amber-800",children:"Upgrade"})]}):(0,ie.jsxs)("div",{className:"mt-6 flex items-center text-xs font-medium text-primary opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,ie.jsx)("span",{children:"Use this template"}),(0,ie.jsxs)("svg",{className:"ml-2 w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,ie.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),(0,ie.jsx)("polyline",{points:"12 5 19 12 12 19"})]})]})]},e.id)})]})]}):(0,ie.jsx)(qe,{onSelect:s}),(0,ie.jsx)("div",{className:"flex justify-end pt-2",children:(0,ie.jsx)(he,{variant:"ghost",onClick:t,children:"Close"})})]})})},Ke=()=>{const[e,t]=(0,o.useState)("list"),[a,n]=(0,o.useState)([]),[r,i]=(0,o.useState)(null),[s,l]=(0,o.useState)(!0),[d,c]=(0,o.useState)(!1),[m,p]=(0,o.useState)(!1),[u,g]=(0,o.useState)(null),x=(0,o.useRef)(null);(0,o.useEffect)(()=>{h()},[]);const h=async()=>{l(!0);try{const e=await fetch(`${window.wpbotAutomator.apiUrl}/workflows`,{headers:{"X-WP-Nonce":window.wpbotAutomator.nonce}}),t=await e.json();n(t||[])}catch(e){console.error("Error fetching workflows:",e)}finally{l(!1)}},b=(e,t)=>{const o=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),a=URL.createObjectURL(o),n=document.createElement("a");n.href=a,n.download=t,n.click(),URL.revokeObjectURL(a)};return"creator"===e?(0,ie.jsx)(Te,{workflow:r,onBack:()=>{t("list"),h()}}):(0,ie.jsxs)("div",{className:"p-8 bg-background min-h-screen text-foreground",children:[(0,ie.jsxs)("div",{className:"max-w-6xl mx-auto",children:[u&&(0,ie.jsxs)("div",{className:"rounded-lg p-3 mb-6 flex items-center justify-between text-sm "+("success"===u.type?"bg-emerald-50 border border-emerald-200 text-emerald-800":"bg-rose-50 border border-rose-200 text-rose-800"),children:[(0,ie.jsx)("span",{children:u.message}),(0,ie.jsx)("button",{onClick:()=>g(null),className:"ml-4 opacity-60 hover:opacity-100 transition-opacity",children:(0,ie.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,ie.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,ie.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),(0,ie.jsxs)("div",{className:"flex justify-between items-center mb-8",children:[(0,ie.jsx)("h1",{className:"text-2xl font-bold",children:"Workflows"}),(0,ie.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,ie.jsx)("input",{ref:x,type:"file",accept:".json,application/json",style:{display:"none"},onChange:e=>{const t=e.target.files&&e.target.files[0];if(!t)return;const o=new FileReader;o.onload=async e=>{let t;try{t=JSON.parse(e.target.result)}catch{return void g({type:"error",message:"Invalid JSON file. Please select a valid export file."})}if(t.workflows&&Array.isArray(t.workflows))try{const e=await fetch(`${window.wpbotAutomator.apiUrl}/workflows/import`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpbotAutomator.nonce},body:JSON.stringify({workflows:t.workflows})}),o=await e.json();if(o.success||o.imported>0){const e=`Successfully imported ${o.imported} workflow${1!==o.imported?"s":""}.`+(o.errors&&o.errors.length?` (${o.errors.length} skipped)`:"");g({type:"success",message:e}),h()}else{const e=o.errors&&o.errors.join(" ")||"Import failed. No workflows were imported.";g({type:"error",message:e})}}catch(e){console.error("Error importing workflows:",e),g({type:"error",message:"Network error during import. Please try again."})}else g({type:"error",message:'Invalid file format. Expected a "workflows" array.'})},o.readAsText(t),e.target.value=""}}),(0,ie.jsxs)("button",{onClick:()=>{g(null),x.current&&x.current.click()},title:"Import workflows from a JSON file",className:"flex items-center space-x-1.5 px-3 py-2 border border-border text-sm rounded-md hover:bg-muted transition-colors",children:[(0,ie.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,ie.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,ie.jsx)("polyline",{points:"17 8 12 3 7 8"}),(0,ie.jsx)("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),(0,ie.jsx)("span",{children:"Import"})]}),a.length>0&&(0,ie.jsxs)("button",{onClick:async()=>{try{const e=await fetch(`${window.wpbotAutomator.apiUrl}/workflows/export`,{headers:{"X-WP-Nonce":window.wpbotAutomator.nonce}}),t=await e.json();b(t,"wpbot-workflows-all.json")}catch(e){console.error("Error exporting all workflows:",e),alert("Failed to export workflows.")}},title:"Export all workflows as JSON",className:"flex items-center space-x-1.5 px-3 py-2 border border-border text-sm rounded-md hover:bg-muted transition-colors",children:[(0,ie.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,ie.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,ie.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,ie.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),(0,ie.jsx)("span",{children:"Export All"})]}),(0,ie.jsx)("button",{onClick:()=>{p(!0)},className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",children:"Create New Workflow"})]})]}),s?(0,ie.jsx)("div",{className:"text-center py-12 text-muted-foreground",children:"Loading workflows..."}):0===a.length?(0,ie.jsx)("div",{className:"text-center py-12 border-2 border-dashed border-border rounded-lg text-muted-foreground",children:"No workflows found. Create your first one!"}):(0,ie.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:a.map(e=>(0,ie.jsxs)("div",{className:"group relative p-6 bg-card border border-border rounded-lg shadow-sm hover:shadow-md transition-shadow cursor-pointer",onClick:()=>(e=>{i(e),t("creator")})(e),children:[(0,ie.jsxs)("div",{className:"flex justify-between items-start mb-2",children:[(0,ie.jsx)("h3",{className:"text-lg font-semibold",children:e.name}),(0,ie.jsxs)("div",{className:"flex space-x-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,ie.jsx)("button",{onClick:t=>(async(e,t)=>{e.stopPropagation();const o="active"===t.status?"inactive":"active";try{const e=await fetch(`${window.wpbotAutomator.apiUrl}/workflows/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpbotAutomator.nonce},body:JSON.stringify({...t,status:o})});(await e.json()).success?h():alert("Failed to update workflow status.")}catch(e){console.error("Error updating workflow status:",e)}})(t,e),title:"active"===e.status?"Deactivate":"Activate",className:"p-1.5 rounded-md transition-colors "+("active"===e.status?"text-amber-600 hover:bg-amber-50":"text-emerald-600 hover:bg-emerald-50"),children:"active"===e.status?(0,ie.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,ie.jsx)("rect",{x:"6",y:"4",width:"4",height:"16"}),(0,ie.jsx)("rect",{x:"14",y:"4",width:"4",height:"16"})]}):(0,ie.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,ie.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})})}),(0,ie.jsx)("button",{onClick:t=>(async(e,t)=>{e.stopPropagation();try{const e=await fetch(`${window.wpbotAutomator.apiUrl}/workflows/export?id=${t.id}`,{headers:{"X-WP-Nonce":window.wpbotAutomator.nonce}}),o=await e.json(),a=t.name.replace(/[^a-z0-9_-]/gi,"_").toLowerCase();b(o,`wpbot-workflow-${a}.json`)}catch(e){console.error("Error exporting workflow:",e),alert("Failed to export workflow.")}})(t,e),title:"Export workflow as JSON",className:"p-1.5 text-blue-600 hover:bg-blue-50 rounded-md transition-colors",children:(0,ie.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,ie.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,ie.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,ie.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),(0,ie.jsx)("button",{onClick:t=>(async(e,t)=>{if(e.stopPropagation(),window.confirm("Are you sure you want to delete this workflow?"))try{const e=await fetch(`${window.wpbotAutomator.apiUrl}/workflows/${t}`,{method:"DELETE",headers:{"X-WP-Nonce":window.wpbotAutomator.nonce}});(await e.json()).success?h():alert("Failed to delete workflow.")}catch(e){console.error("Error deleting workflow:",e)}})(t,e.id),title:"Delete",className:"p-1.5 text-rose-600 hover:bg-rose-50 rounded-md transition-colors",children:(0,ie.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,ie.jsx)("path",{d:"M3 6h18"}),(0,ie.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,ie.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),(0,ie.jsx)("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),(0,ie.jsx)("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})})]})]}),(0,ie.jsx)("p",{className:"text-sm text-muted-foreground mb-4 line-clamp-2",children:e.description||"No description"}),(0,ie.jsxs)("div",{className:"flex justify-between items-center mt-auto",children:[(0,ie.jsx)("span",{className:"px-2 py-1 text-xs font-medium rounded-full "+("active"===e.status?"bg-emerald-100/80 text-emerald-700":"bg-slate-100/80 text-slate-700"),children:e.status.charAt(0).toUpperCase()+e.status.slice(1)}),(0,ie.jsxs)("span",{className:"text-xs text-muted-foreground",children:["ID: ",e.id]})]})]},e.id))})]}),(0,ie.jsx)(We,{isOpen:d,onClose:()=>c(!1)}),(0,ie.jsx)(Je,{isOpen:m,onClose:()=>p(!1),onSelect:e=>{p(!1),i(e?{id:null,name:e.name,description:e.description,workflow_data:e.workflow_data,status:"active"}:null),t("creator")},isProActive:!!window.wpbotAutomator?.isProActive})]})};const Ye=s("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]),Xe=s("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),Qe=s("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);var Ze=({templates:e,onCreateNew:t,onEdit:o,onDelete:n,isProActive:r,freeLimit:i})=>{const[s,l]=a().useState(""),d=!r&&e.length>=i,m=(Array.isArray(e)?e:[]).filter(e=>e.name&&e.name.toLowerCase().includes(s.toLowerCase()));return Array.isArray(e)?(0,ie.jsxs)("div",{children:[(0,ie.jsxs)("div",{className:"flex justify-between items-center mb-8",children:[(0,ie.jsxs)("div",{children:[(0,ie.jsx)("h1",{className:"text-3xl font-bold tracking-tight",children:"Email Templates"}),(0,ie.jsx)("p",{className:"text-muted-foreground mt-1",children:"Manage and design your transactional and automated emails."})]}),(0,ie.jsx)("div",{className:"flex flex-col items-end gap-2",children:d?(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsxs)("div",{className:"flex items-center space-x-2 px-6 py-2.5 bg-muted text-muted-foreground rounded-lg border border-border font-medium cursor-not-allowed select-none",children:[(0,ie.jsx)(_e,{className:"w-4 h-4"}),(0,ie.jsx)("span",{children:"Create New Template"}),(0,ie.jsx)("span",{className:"ml-1 text-xs font-semibold bg-amber-100 text-amber-700 border border-amber-300 rounded px-1.5 py-0.5",children:"PRO"})]}),(0,ie.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Free plan includes ",i," templates."," ",(0,ie.jsx)("a",{href:"https://wpbot.pro",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline font-medium",children:"Upgrade to Pro"})," ","for unlimited."]})]}):(0,ie.jsxs)("div",{className:"flex flex-col items-end gap-1",children:[(0,ie.jsxs)("button",{onClick:t,className:"flex items-center space-x-2 px-6 py-2.5 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-all shadow-sm font-medium",children:[(0,ie.jsx)(c,{className:"w-5 h-5"}),(0,ie.jsx)("span",{children:"Create New Template"})]}),!r&&(0,ie.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.length," / ",i," free templates used"]})]})})]}),(0,ie.jsxs)("div",{className:"bg-card border border-border rounded-xl shadow-sm overflow-hidden",children:[(0,ie.jsx)("div",{className:"p-4 border-b border-border bg-muted/30 flex items-center",children:(0,ie.jsx)("div",{className:"relative flex-1 max-w-sm",children:(0,ie.jsx)("input",{type:"text",placeholder:"Search templates...",value:s,onChange:e=>l(e.target.value),className:"w-full pl-10 pr-4 py-2 border border-border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-primary/20 transition-all text-sm"})})}),0===m.length?(0,ie.jsxs)("div",{className:"py-20 text-center",children:[(0,ie.jsx)("div",{className:"w-16 h-16 bg-muted rounded-full flex items-center justify-center mx-auto mb-4",children:(0,ie.jsx)(Ye,{className:"w-8 h-8 text-muted-foreground opacity-50"})}),(0,ie.jsx)("h3",{className:"text-lg font-medium",children:"No templates found"}),(0,ie.jsx)("p",{className:"text-muted-foreground max-w-xs mx-auto mt-1",children:s?`No templates matching "${s}"`:"You haven't created any email templates yet."}),!s&&!d&&(0,ie.jsx)("button",{onClick:t,className:"mt-6 text-primary hover:underline text-sm font-medium",children:"Create your first template"})]}):(0,ie.jsx)("div",{className:"divide-y divide-border",children:m.map(e=>(0,ie.jsxs)("div",{className:"p-6 flex items-center justify-between hover:bg-muted/30 transition-colors group",children:[(0,ie.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,ie.jsx)("div",{className:"w-12 h-12 bg-primary/10 rounded-lg flex items-center justify-center text-primary",children:(0,ie.jsx)(Ye,{className:"w-6 h-6"})}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("h3",{className:"font-semibold text-lg hover:text-primary cursor-pointer transition-colors",onClick:()=>o(e),children:e.name}),(0,ie.jsxs)("p",{className:"text-sm text-muted-foreground flex items-center mt-0.5",children:[(0,ie.jsx)("span",{className:"inline-block w-2 h-2 rounded-full bg-emerald-500 mr-2"}),"ID: ",e.id]})]})]}),(0,ie.jsxs)("div",{className:"flex items-center space-x-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,ie.jsx)("button",{onClick:()=>o(e),className:"p-2.5 text-blue-600 hover:bg-blue-50 rounded-lg transition-colors border border-transparent hover:border-blue-100",title:"Edit Template",children:(0,ie.jsx)(Xe,{className:"w-5 h-5"})}),(0,ie.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to delete this template?"))try{const t=await fetch(`${window.wpbotAutomator.apiUrl}/email-templates/${e}`,{method:"DELETE",headers:{"X-WP-Nonce":window.wpbotAutomator.nonce}});(await t.json()).success?n():alert("Failed to delete template.")}catch(e){console.error("Error deleting template:",e)}})(e.id),className:"p-2.5 text-rose-600 hover:bg-rose-50 rounded-lg transition-colors border border-transparent hover:border-rose-100",title:"Delete Template",children:(0,ie.jsx)(Qe,{className:"w-5 h-5"})})]})]},e.id))})]})]}):null};const et=s("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]),tt=s("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]),ot=s("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),at=s("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]),nt=s("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),rt=s("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),it=s("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);var st=({template:e,onBack:t})=>{const[a,n]=(0,o.useState)(e?.name||"Untitled Template"),[r,i]=(0,o.useState)(e?.subject||""),[s,l]=(0,o.useState)(()=>{if(e?.body_json)try{return JSON.parse(e.body_json)}catch(e){console.error("Failed to parse body_json:",e)}return[{id:"1",type:"text",content:"<h1>Welcome to our Newsletter!</h1><p>Start designing your beautiful email here.</p>"}]}),[d,p]=(0,o.useState)(null),[u,g]=(0,o.useState)(!1),[x,h]=(0,o.useState)(!1),[b,f]=(0,o.useState)(null),[y,w]=(0,o.useState)(!1),v=[{type:"text",icon:et,label:"Text Block"},{type:"button",icon:tt,label:"Button"},{type:"image",icon:ot,label:"Image"},{type:"divider",icon:m,label:"Divider"},{type:"spacer",icon:at,label:"Spacer"}],_=(e,t)=>{l(s.map(o=>o.id===e?{...o,...t}:o))},k=()=>{let e='\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset="utf-8">\n <style>\n body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0; background-color: #f4f7f9; }\n .container { max-width: 600px; margin: 40px auto; background: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }\n .content { padding: 40px; }\n .btn { display: inline-block; text-decoration: none; font-weight: bold; text-align: center; }\n img { max-width: 100%; height: auto; display: block; }\n @media only screen and (max-width: 600px) { .container { margin: 0; border-radius: 0; } }\n </style>\n </head>\n <body>\n <div class="container">\n <div class="content">\n ';return s.forEach(t=>{switch(t.type){case"text":e+=`<div class="block-text">${t.content}</div>`;break;case"button":const o=t.styles;e+=`<div style="text-align: center; margin: 20px 0;"><a href="${o.url}" class="btn" style="background-color: ${o.backgroundColor}; color: ${o.color}; padding: ${o.padding}; border-radius: ${o.borderRadius};">${t.content}</a></div>`;break;case"image":e+=`<div style="margin: 20px 0;"><img src="${t.content}" alt="Image"></div>`;break;case"divider":e+=`<hr style="border: none; border-top: ${t.styles.borderTop}; margin: ${t.styles.margin};">`;break;case"spacer":e+=`<div style="height: ${t.styles.height};"></div>`}}),e+=`\n </div>\n <div style="background: #f9fafb; padding: 20px; text-align: center; font-size: 12px; color: #6b7280; border-top: 1px solid #f3f4f6;">\n Sent by ${window.wpbotAutomator.blogname||"Our Website"}\n </div>\n </div>\n </body>\n </html>\n `,e},j=s.find(e=>e.id===d);return(0,ie.jsxs)("div",{className:"flex flex-col h-[calc(100vh-100px)]",children:[(0,ie.jsxs)("div",{className:"flex justify-between items-center mb-6 bg-card p-4 rounded-xl border border-border shadow-sm",children:[(0,ie.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,ie.jsx)("button",{onClick:t,className:"p-2 hover:bg-muted rounded-full transition-colors",children:(0,ie.jsx)(Ce,{className:"w-5 h-5"})}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("input",{value:a,onChange:e=>n(e.target.value),className:"text-xl font-bold bg-transparent border-none focus:ring-0 p-0 hover:bg-muted/50 rounded px-2 cursor-text transition-colors"}),(0,ie.jsxs)("div",{className:"flex items-center mt-0.5 px-2",children:[(0,ie.jsx)("span",{className:"text-xs text-muted-foreground mr-2 font-medium",children:"Subject:"}),(0,ie.jsx)("input",{value:r,onChange:e=>i(e.target.value),placeholder:"Enter email subject...",className:"text-xs text-primary bg-transparent border-none focus:ring-0 p-0 w-64 placeholder:text-muted-foreground/50"})]})]})]}),(0,ie.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,ie.jsxs)("button",{onClick:()=>w(!y),className:"flex items-center space-x-2 px-4 py-2 border border-border rounded-lg hover:bg-muted transition-colors text-sm font-medium",children:[y?(0,ie.jsx)(at,{className:"w-4 h-4"}):(0,ie.jsx)(nt,{className:"w-4 h-4"}),(0,ie.jsx)("span",{children:y?"Editor":"Preview"})]}),(0,ie.jsxs)("button",{onClick:async()=>{g(!0);const o=k(),n={name:a,subject:r,body_html:o,body_json:JSON.stringify(s)};try{const o=window.wpbotAutomator.apiUrl.replace(/\/$/,""),a=e?.id?`${o}/email-templates/${e.id}`:`${o}/email-templates`,r=await fetch(a,{method:e?.id?"PUT":"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpbotAutomator.nonce},body:JSON.stringify(n)}),i=await r.json();i.success?(alert("Template saved successfully!"),e?.id||t()):alert(i.message||"Failed to save template.")}catch(e){console.error("Error saving template:",e)}finally{g(!1)}},disabled:u,className:"flex items-center space-x-2 px-6 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-all font-medium disabled:opacity-50 shadow-sm",children:[u?(0,ie.jsx)(c,{className:"w-4 h-4 animate-spin"}):(0,ie.jsx)(rt,{className:"w-4 h-4"}),(0,ie.jsx)("span",{children:u?"Saving...":"Save Template"})]})]})]}),y?(0,ie.jsx)("div",{className:"flex-1 overflow-auto p-8 bg-muted/30 rounded-xl border border-border",children:(0,ie.jsx)("div",{className:"max-w-[600px] mx-auto shadow-2xl rounded-lg overflow-hidden bg-white",children:(0,ie.jsx)("iframe",{title:"Email Preview",srcDoc:k(),className:"w-full h-[800px] border-none"})})}):(0,ie.jsxs)("div",{className:"flex flex-1 space-x-6 overflow-hidden",children:[(0,ie.jsx)("div",{className:"flex-1 bg-muted/20 border border-border rounded-xl overflow-y-auto p-12 designer-canvas",children:(0,ie.jsxs)("div",{className:"max-w-[600px] mx-auto bg-white shadow-lg rounded-lg min-h-[600px] flex flex-col p-10 border border-border/50",children:[(0,ie.jsx)("div",{className:"space-y-4",children:s.map(e=>(0,ie.jsxs)("div",{onClick:()=>p(e.id),className:"relative group cursor-pointer border-2 rounded-lg transition-all "+(d===e.id?"border-primary ring-4 ring-primary/10 shadow-md":"border-transparent hover:border-primary/30"),children:[(0,ie.jsxs)("div",{className:"p-4",children:["text"===e.type&&(0,ie.jsx)("div",{dangerouslySetInnerHTML:{__html:e.content}}),"button"===e.type&&(0,ie.jsx)("div",{className:"text-center my-4",children:(0,ie.jsx)("span",{style:{backgroundColor:e.styles.backgroundColor,color:e.styles.color,padding:e.styles.padding,borderRadius:e.styles.borderRadius,display:"inline-block",fontWeight:"bold"},children:e.content})}),"image"===e.type&&(0,ie.jsx)("div",{className:"my-4",children:(0,ie.jsx)("img",{src:e.content,alt:"Block",className:"mx-auto rounded-md shadow-sm"})}),"divider"===e.type&&(0,ie.jsx)("hr",{style:e.styles}),"spacer"===e.type&&(0,ie.jsx)("div",{style:e.styles})]}),d===e.id&&(0,ie.jsx)("div",{className:"absolute -right-12 top-0 flex flex-col space-y-2",children:(0,ie.jsx)("button",{onClick:t=>{var o;t.stopPropagation(),o=e.id,l(s.filter(e=>e.id!==o)),d===o&&p(null)},className:"p-2 bg-rose-500 text-white rounded-lg shadow-lg hover:bg-rose-600 transition-colors",children:(0,ie.jsx)(Qe,{className:"w-4 h-4"})})})]},e.id))}),0===s.length&&(0,ie.jsxs)("div",{className:"flex flex-col items-center justify-center flex-1 text-muted-foreground opacity-50 space-y-4",children:[(0,ie.jsx)(at,{className:"w-12 h-12"}),(0,ie.jsx)("p",{className:"text-sm font-medium",children:"Your canvas is empty. Drag or click blocks to start."})]})]})}),(0,ie.jsxs)("div",{className:"w-80 flex flex-col space-y-6",children:[(0,ie.jsxs)("div",{className:"bg-card border border-border rounded-xl p-5 shadow-sm",children:[(0,ie.jsxs)("h3",{className:"text-sm font-bold uppercase tracking-wider text-muted-foreground mb-4 flex items-center",children:[(0,ie.jsx)(c,{className:"w-4 h-4 mr-2"}),"Add Blocks"]}),(0,ie.jsx)("div",{className:"grid grid-cols-2 gap-3",children:v.map(e=>(0,ie.jsxs)("button",{onClick:()=>(e=>{let t="",o={};switch(e){case"text":t="<p>Enter your text here...</p>";break;case"button":t="Click Me",o={backgroundColor:"#3b82f6",color:"#ffffff",padding:"12px 24px",borderRadius:"6px",url:"#"};break;case"image":t="https://via.placeholder.com/600x300?text=Your+Image";break;case"divider":t="",o={borderTop:"1px solid #e5e7eb",margin:"20px 0"};break;case"spacer":o={height:"30px"}}const a={id:Math.random().toString(36).substr(2,9),type:e,content:t,styles:o};l([...s,a]),p(a.id)})(e.type),className:"flex flex-col items-center justify-center p-4 border border-border rounded-xl hover:bg-primary hover:text-primary-foreground hover:scale-105 hover:shadow-md transition-all group",children:[(0,ie.jsx)(e.icon,{className:"w-6 h-6 mb-2 group-hover:animate-pulse"}),(0,ie.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-tight",children:e.label})]},e.type))})]}),(0,ie.jsxs)("div",{className:"bg-card border border-border rounded-xl flex-1 p-5 shadow-sm overflow-y-auto",children:[(0,ie.jsxs)("h3",{className:"text-sm font-bold uppercase tracking-wider text-muted-foreground mb-4 flex items-center border-b border-border pb-2",children:[(0,ie.jsx)(it,{className:"w-4 h-4 mr-2"}),"Settings"]}),j?(0,ie.jsxs)("div",{className:"space-y-6",children:[(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"Content"}),"text"===j.type?(0,ie.jsx)("textarea",{value:j.content,onChange:e=>_(j.id,{content:e.target.value}),className:"w-full p-3 border border-border rounded-lg bg-background text-sm min-h-[150px] focus:ring-2 focus:ring-primary/20 transition-all font-mono",placeholder:"Supports HTML..."}):(0,ie.jsx)("input",{value:j.content,onChange:e=>_(j.id,{content:e.target.value}),className:"w-full p-3 border border-border rounded-lg bg-background text-sm focus:ring-2 focus:ring-primary/20 transition-all"})]}),"image"===j.type&&(0,ie.jsxs)("div",{className:"space-y-4",children:[(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"Upload Image"}),(0,ie.jsx)("input",{type:"file",accept:"image/*",onChange:async e=>{const t=e.target.files?.[0];t&&(await(async e=>{if(!e)return null;h(!0),f(null);try{const t=new FormData;t.append("file",e);const o=await fetch((()=>{if(!window.wpbotAutomator?.apiUrl)return"/wp-json/wp/v2/media";try{const e=new URL(window.wpbotAutomator.apiUrl),t=e.pathname.replace(/\/wpbot-automator\/v1\/?$/,"/wp/v2/");return`${e.origin}${t}media`}catch(e){return"/wp-json/wp/v2/media"}})(),{method:"POST",headers:{"X-WP-Nonce":window.wpbotAutomator.nonce},body:t}),a=await o.json();if(!o.ok||!a?.source_url)throw new Error(a?.message||"Failed to upload image");return d&&_(d,{content:a.source_url}),a.source_url}catch(e){return console.error("Image upload failed:",e),f(e.message||"Failed to upload image."),null}finally{h(!1)}})(t),e.target.value="")},className:"w-full p-2 border border-border rounded-lg bg-background text-sm"}),x&&(0,ie.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:"Uploading image…"}),b&&(0,ie.jsx)("p",{className:"text-xs text-rose-500 mt-2",children:b})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"Image URL"}),(0,ie.jsx)("input",{value:j.content,onChange:e=>_(j.id,{content:e.target.value}),placeholder:"Paste image URL or upload a file",className:"w-full p-3 border border-border rounded-lg bg-background text-sm focus:ring-2 focus:ring-primary/20 transition-all"})]})]}),"button"===j.type&&(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"Target URL"}),(0,ie.jsx)("input",{value:j.styles.url,onChange:e=>_(j.id,{styles:{...j.styles,url:e.target.value}}),className:"w-full p-3 border border-border rounded-lg bg-background text-sm font-mono"})]}),(0,ie.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"BG Color"}),(0,ie.jsx)("input",{type:"color",value:j.styles.backgroundColor,onChange:e=>_(j.id,{styles:{...j.styles,backgroundColor:e.target.value}}),className:"w-full h-10 p-1 border border-border rounded-lg bg-background"})]}),(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"Text Color"}),(0,ie.jsx)("input",{type:"color",value:j.styles.color,onChange:e=>_(j.id,{styles:{...j.styles,color:e.target.value}}),className:"w-full h-10 p-1 border border-border rounded-lg bg-background"})]})]})]}),"spacer"===j.type&&(0,ie.jsxs)("div",{children:[(0,ie.jsx)("label",{className:"text-xs font-bold text-muted-foreground uppercase mb-2 block",children:"Height (px)"}),(0,ie.jsx)("input",{type:"number",value:parseInt(j.styles.height),onChange:e=>_(j.id,{styles:{...j.styles,height:e.target.value+"px"}}),className:"w-full p-3 border border-border rounded-lg bg-background text-sm"})]})]}):(0,ie.jsxs)("div",{className:"py-20 text-center opacity-40",children:[(0,ie.jsx)(tt,{className:"w-10 h-10 mx-auto mb-3"}),(0,ie.jsx)("p",{className:"text-xs font-bold",children:"Select a block to edit its properties"})]})]})]})]})]})},lt=()=>{const[e,t]=(0,o.useState)("list"),[a,n]=(0,o.useState)([]),[r,i]=(0,o.useState)(!0),[s,l]=(0,o.useState)(null),d=!!window.wpbotAutomator?.isProActive;(0,o.useEffect)(()=>{c()},[]);const c=async()=>{i(!0);try{const e=window.wpbotAutomator.apiUrl.replace(/\/$/,""),t=await fetch(`${e}/email-templates`,{headers:{"X-WP-Nonce":window.wpbotAutomator.nonce}}),o=await t.json();n(Array.isArray(o)?o:[])}catch(e){console.error("Error fetching templates:",e)}finally{i(!1)}};return r&&"list"===e?(0,ie.jsx)("div",{className:"flex items-center justify-center min-h-[400px]",children:(0,ie.jsx)(Fe,{className:"w-8 h-8 animate-spin text-primary"})}):(0,ie.jsx)("div",{className:"p-8 bg-background min-h-screen text-foreground font-sans",children:(0,ie.jsx)("div",{className:"max-w-6xl mx-auto",children:"list"===e?(0,ie.jsx)(Ze,{templates:a,onCreateNew:()=>{!d&&a.length>=3||(l(null),t("designer"))},onEdit:async e=>{i(!0);try{const o=window.wpbotAutomator.apiUrl.replace(/\/$/,""),a=await fetch(`${o}/email-templates/${e.id}`,{headers:{"X-WP-Nonce":window.wpbotAutomator.nonce}}),n=await a.json();l(n),t("designer")}catch(e){console.error("Error fetching template details:",e),alert("Failed to load template data.")}finally{i(!1)}},onDelete:c,isProActive:d,freeLimit:3}):(0,ie.jsx)(st,{template:s,onBack:()=>{t("list"),c()}})})})};const dt=s("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]),ct=s("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),mt=s("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),pt=s("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),ut=s("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);var gt=()=>{const[e,t]=(0,o.useState)([]),[n,r]=(0,o.useState)({total:0,success:0,failed:0,last_run:null}),[i,s]=(0,o.useState)([]),[l,d]=(0,o.useState)(!0),[c,m]=(0,o.useState)({status:"",workflow_id:""}),[p,u]=(0,o.useState)(1),[g,x]=(0,o.useState)(1),[h,b]=(0,o.useState)(0),[f,y]=(0,o.useState)(null),[w,v]=(0,o.useState)(!1),_=(0,o.useRef)(p),k=(0,o.useRef)(c),j=(0,o.useRef)(null);(0,o.useEffect)(()=>{_.current=p},[p]),(0,o.useEffect)(()=>{k.current=c},[c]);const N=()=>window.wpbotAutomator.apiUrl.replace(/\/$/,""),C=()=>({"X-WP-Nonce":window.wpbotAutomator.nonce}),S=async()=>{try{const e=await fetch(`${N()}/logs/summary`,{headers:C()}),t=await e.json();r(t)}catch(e){console.error(e)}},A=async(e,o)=>{d(!0);try{const a=new URLSearchParams({per_page:25,page:e});o.status&&a.set("status",o.status),o.workflow_id&&a.set("workflow_id",o.workflow_id);const n=await fetch(`${N()}/logs?${a}`,{headers:C()}),r=await n.json();t(r.logs||[]),b(r.total||0),x(r.total_pages||1)}catch(e){console.error(e)}finally{d(!1)}};(0,o.useEffect)(()=>{(async()=>{try{const e=await fetch(`${N()}/workflows`,{headers:C()}),t=await e.json();s(Array.isArray(t)?t:[])}catch(e){console.error(e)}})(),S(),A(1,{status:"",workflow_id:""})},[]),(0,o.useEffect)(()=>{if(clearInterval(j.current),w)return j.current=setInterval(()=>{S(),A(_.current,k.current)},1e4),()=>clearInterval(j.current)},[w]);const P=(e,t)=>{const o={...k.current,[e]:t};m(o),u(1),S(),A(1,o)},I=e=>{u(e),A(e,k.current)},T=e=>{if(!e)return"-";const t=new Date(e.replace(" ","T")+"Z"),o=Math.floor((Date.now()-t)/1e3);return o<60?`${o}s ago`:o<3600?`${Math.floor(o/60)}m ago`:o<86400?`${Math.floor(o/3600)}h ago`:t.toLocaleDateString()},B=e=>e?new Date(e.replace(" ","T")+"Z").toLocaleString():"",M=e=>e?e.replace(/[_-]/g," ").replace(/\b\w/g,e=>e.toUpperCase()):"-",F=e=>{if(!e)return"-";const t=e.split(":");return M(t[t.length-1])},W=n.total>0?Math.round(n.success/n.total*100):null,D=c.status||c.workflow_id;return(0,ie.jsx)("div",{className:"p-8 bg-background min-h-screen text-foreground font-sans",children:(0,ie.jsxs)("div",{className:"max-w-7xl mx-auto",children:[(0,ie.jsxs)("div",{className:"flex items-center justify-between mb-8",children:[(0,ie.jsxs)("div",{children:[(0,ie.jsxs)("h1",{className:"text-3xl font-bold tracking-tight flex items-center gap-3",children:[(0,ie.jsx)(ke,{className:"w-8 h-8 text-primary"}),"Activity Log"]}),(0,ie.jsx)("p",{className:"text-muted-foreground mt-1",children:"Real-time view of every workflow execution — what ran, what succeeded, and what failed."})]}),(0,ie.jsxs)("div",{className:"flex items-center gap-3",children:[(0,ie.jsxs)("label",{className:"flex items-center gap-2 text-sm text-muted-foreground cursor-pointer select-none",children:[(0,ie.jsx)("div",{onClick:()=>v(e=>!e),className:"w-9 h-5 rounded-full relative cursor-pointer transition-colors "+(w?"bg-primary":"bg-border"),children:(0,ie.jsx)("div",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform "+(w?"translate-x-4":"translate-x-0.5")})}),"Auto-refresh"]}),(0,ie.jsxs)("button",{onClick:()=>{S(),A(_.current,k.current)},disabled:l,className:"flex items-center gap-2 px-3 py-2 border border-border rounded-lg hover:bg-muted transition-colors text-sm",children:[(0,ie.jsx)(Pe,{className:"w-4 h-4 "+(l?"animate-spin":"")}),"Refresh"]}),(0,ie.jsxs)("button",{onClick:async()=>{window.confirm("Clear all logs? This cannot be undone.")&&(await fetch(`${N()}/logs`,{method:"DELETE",headers:C()}),r({total:0,success:0,failed:0,last_run:null}),t([]),b(0),x(1),u(1))},className:"flex items-center gap-2 px-3 py-2 border border-rose-200 text-rose-600 rounded-lg hover:bg-rose-50 transition-colors text-sm",children:[(0,ie.jsx)(Qe,{className:"w-4 h-4"}),"Clear All"]})]})]}),(0,ie.jsxs)("div",{className:"grid grid-cols-3 gap-4 mb-6",children:[(0,ie.jsxs)("div",{className:"bg-card border border-border rounded-xl p-5",children:[(0,ie.jsx)("div",{className:"text-sm text-muted-foreground mb-1",children:"Total Runs"}),(0,ie.jsx)("div",{className:"text-3xl font-bold",children:n.total.toLocaleString()}),(0,ie.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:n.last_run?`Last run: ${T(n.last_run)}`:"No runs yet"})]}),(0,ie.jsxs)("div",{className:"bg-card border border-emerald-200 rounded-xl p-5",children:[(0,ie.jsx)("div",{className:"text-sm text-emerald-600 mb-1 font-medium",children:"Successful"}),(0,ie.jsx)("div",{className:"text-3xl font-bold text-emerald-600",children:n.success.toLocaleString()}),(0,ie.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:null!==W?`${W}% success rate`:"No data yet"})]}),(0,ie.jsxs)("div",{className:"bg-card border border-rose-200 rounded-xl p-5",children:[(0,ie.jsx)("div",{className:"text-sm text-rose-600 mb-1 font-medium",children:"Failed"}),(0,ie.jsx)("div",{className:"text-3xl font-bold text-rose-600",children:n.failed.toLocaleString()}),(0,ie.jsx)("div",{className:"text-xs text-muted-foreground mt-2",children:null!==W?100-W+"% failure rate":"No data yet"})]})]}),(0,ie.jsxs)("div",{className:"flex items-center gap-3 mb-4 flex-wrap",children:[(0,ie.jsx)(dt,{className:"w-4 h-4 text-muted-foreground shrink-0"}),(0,ie.jsxs)("select",{value:c.status,onChange:e=>P("status",e.target.value),className:"border border-border rounded-lg px-3 py-1.5 text-sm bg-background focus:outline-none focus:ring-2 focus:ring-primary/20",children:[(0,ie.jsx)("option",{value:"",children:"All Statuses"}),(0,ie.jsx)("option",{value:"success",children:"Success"}),(0,ie.jsx)("option",{value:"failed",children:"Failed"})]}),(0,ie.jsxs)("select",{value:c.workflow_id,onChange:e=>P("workflow_id",e.target.value),className:"border border-border rounded-lg px-3 py-1.5 text-sm bg-background focus:outline-none focus:ring-2 focus:ring-primary/20",children:[(0,ie.jsx)("option",{value:"",children:"All Workflows"}),i.map(e=>(0,ie.jsx)("option",{value:e.id,children:e.name},e.id))]}),D&&(0,ie.jsx)("button",{onClick:()=>{const e={status:"",workflow_id:""};m(e),u(1),A(1,e)},className:"text-xs text-primary hover:underline",children:"Clear filters"}),(0,ie.jsxs)("span",{className:"ml-auto text-sm text-muted-foreground",children:[h.toLocaleString()," ",1===h?"entry":"entries"]})]}),(0,ie.jsx)("div",{className:"bg-card border border-border rounded-xl shadow-sm overflow-hidden",children:l&&0===e.length?(0,ie.jsxs)("div",{className:"py-24 text-center text-muted-foreground",children:[(0,ie.jsx)(Pe,{className:"w-8 h-8 mx-auto mb-3 animate-spin opacity-40"}),"Loading logs…"]}):0===e.length?(0,ie.jsxs)("div",{className:"py-24 text-center",children:[(0,ie.jsx)(ct,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground opacity-25"}),(0,ie.jsxs)("p",{className:"font-medium text-muted-foreground",children:["No logs found",D?" for this filter":""]}),(0,ie.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:D?"Try clearing the filters.":"Logs appear here automatically when your workflows run."})]}):(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsxs)("table",{className:"w-full text-sm",children:[(0,ie.jsx)("thead",{className:"bg-muted/40 border-b border-border",children:(0,ie.jsxs)("tr",{children:[(0,ie.jsx)("th",{className:"w-6 px-3 py-3"}),(0,ie.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Time"}),(0,ie.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Workflow"}),(0,ie.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Trigger"}),(0,ie.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Action"}),(0,ie.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Status"}),(0,ie.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Message"})]})}),(0,ie.jsx)("tbody",{className:"divide-y divide-border",children:e.map(e=>{const t=f===e.id,o=(e=>{if(!e)return null;try{return JSON.parse(e)}catch{return e}})(e.log_data),n="success"!==e.status;return(0,ie.jsxs)(a().Fragment,{children:[(0,ie.jsxs)("tr",{onClick:()=>y(t?null:e.id),className:`cursor-pointer transition-colors hover:bg-muted/20 ${t?"bg-muted/10":""} ${n?"border-l-2 border-l-rose-400":""}`,children:[(0,ie.jsx)("td",{className:"px-3 py-3 text-muted-foreground",children:t?(0,ie.jsx)(mt,{className:"w-3.5 h-3.5"}):(0,ie.jsx)(je,{className:"w-3.5 h-3.5"})}),(0,ie.jsx)("td",{className:"px-4 py-3",children:(0,ie.jsx)("span",{className:"text-xs font-mono text-muted-foreground",title:B(e.created_at),children:T(e.created_at)})}),(0,ie.jsx)("td",{className:"px-4 py-3 font-medium max-w-[160px] truncate",children:e.workflow_name||`Workflow #${e.workflow_id}`}),(0,ie.jsx)("td",{className:"px-4 py-3",children:(0,ie.jsx)("span",{className:"bg-muted/70 text-muted-foreground px-2 py-0.5 rounded text-xs font-mono",children:F(e.trigger_type)})}),(0,ie.jsx)("td",{className:"px-4 py-3",children:e.action_id?(0,ie.jsx)("span",{className:"bg-blue-50 text-blue-700 border border-blue-100 px-2 py-0.5 rounded text-xs",children:M(e.action_id)}):(0,ie.jsx)("span",{className:"text-muted-foreground text-xs",children:"—"})}),(0,ie.jsx)("td",{className:"px-4 py-3",children:n?(0,ie.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-rose-100 text-rose-700",children:[(0,ie.jsx)(pt,{className:"w-3 h-3"})," Failed"]}):(0,ie.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium bg-emerald-100 text-emerald-700",children:[(0,ie.jsx)(ut,{className:"w-3 h-3"})," Success"]})}),(0,ie.jsx)("td",{className:"px-4 py-3 text-muted-foreground text-xs max-w-[220px] truncate",children:e.error_message||o&&o.message||"—"})]}),t&&(0,ie.jsx)("tr",{className:"bg-muted/5",children:(0,ie.jsx)("td",{colSpan:"7",className:"px-6 py-4",children:(0,ie.jsxs)("div",{className:"space-y-3 max-w-4xl",children:[(0,ie.jsxs)("div",{className:"flex flex-wrap gap-x-6 gap-y-1 text-xs text-muted-foreground",children:[(0,ie.jsxs)("span",{children:[(0,ie.jsx)("strong",{className:"text-foreground",children:"Log ID:"})," ",e.id]}),(0,ie.jsxs)("span",{children:[(0,ie.jsx)("strong",{className:"text-foreground",children:"Time:"})," ",B(e.created_at)]}),(0,ie.jsxs)("span",{children:[(0,ie.jsx)("strong",{className:"text-foreground",children:"Workflow:"})," ",e.workflow_name||`#${e.workflow_id}`]}),(0,ie.jsxs)("span",{children:[(0,ie.jsx)("strong",{className:"text-foreground",children:"Trigger:"})," ",e.trigger_type||"—"]}),e.action_id&&(0,ie.jsxs)("span",{children:[(0,ie.jsx)("strong",{className:"text-foreground",children:"Action:"})," ",e.action_id]})]}),e.error_message&&(0,ie.jsxs)("div",{className:"bg-rose-50 border border-rose-200 rounded-lg p-3",children:[(0,ie.jsx)("div",{className:"text-xs font-bold text-rose-700 mb-1",children:"Error"}),(0,ie.jsx)("div",{className:"text-xs text-rose-600 font-mono break-all",children:e.error_message})]}),o&&(0,ie.jsxs)("div",{className:"bg-muted/50 border border-border rounded-lg p-3",children:[(0,ie.jsx)("div",{className:"text-xs font-bold text-muted-foreground mb-2",children:"Result Data"}),(0,ie.jsx)("pre",{className:"text-xs font-mono text-foreground/80 overflow-auto max-h-48 whitespace-pre-wrap break-all",children:"object"==typeof o?JSON.stringify(o,null,2):o})]})]})})})]},e.id)})})]}),g>1&&(0,ie.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-border",children:[(0,ie.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Page ",p," of ",g," — ",h.toLocaleString()," total entries"]}),(0,ie.jsxs)("div",{className:"flex items-center gap-1",children:[(0,ie.jsx)("button",{onClick:()=>I(1),disabled:1===p,className:"px-2 py-1 text-xs border border-border rounded hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed",children:"«"}),(0,ie.jsx)("button",{onClick:()=>I(p-1),disabled:1===p,className:"px-2 py-1 text-xs border border-border rounded hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed",children:"‹"}),Array.from({length:Math.min(5,g)},(e,t)=>{const o=Math.max(1,Math.min(p-2,g-4))+t;return o<=g?(0,ie.jsx)("button",{onClick:()=>I(o),className:"px-2.5 py-1 text-xs border rounded transition-colors "+(o===p?"bg-primary text-primary-foreground border-primary":"border-border hover:bg-muted"),children:o},o):null}),(0,ie.jsx)("button",{onClick:()=>I(p+1),disabled:p===g,className:"px-2 py-1 text-xs border border-border rounded hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed",children:"›"}),(0,ie.jsx)("button",{onClick:()=>I(g),disabled:p===g,className:"px-2 py-1 text-xs border border-border rounded hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed",children:"»"})]})]})]})})]})})};const xt=[{id:"text",label:"Text",badge:"T"},{id:"textarea",label:"Long Text",badge:"¶"},{id:"number",label:"Number",badge:"#"},{id:"email",label:"Email",badge:"@"},{id:"url",label:"URL",badge:"🔗"},{id:"date",label:"Date",badge:"� |