import{c as F,r as w,j as s,F as T,_ as M,a as m,S as A,B as v,L as I,n as O,z as y,t as q,l as B,i as R}from"./main-tangy-colts-beg.js";import{q as _,N as C}from"./_applist-tangy-colts-beg-36.js";import{N as $}from"./appheade-tangy-colts-beg-249.js";import{L as D,o as P,n as G,v as L,d as H,C as J,E as K}from"./index-tangy-colts-beg-916.js";import{M as j}from"./index-tangy-colts-beg-123.js";import{S as k}from"./index-tangy-colts-beg-596.js";import{F as Q}from"./index-tangy-colts-beg-987.js";import{R as U,C as N,T as z}from"./index-tangy-colts-beg-131.js";import"./lodash-tangy-colts-beg-516.js";import"./index-tangy-colts-beg-827.js";import"./usebreak-tangy-colts-beg-501.js";import"./exporthe-tangy-colts-beg-840.js";import"./index-tangy-colts-beg-660.js";import"./index-tangy-colts-beg-73.js";import"./import-tangy-colts-beg-35.js";import"./index-tangy-colts-beg-216.js";import"./dropdown-tangy-colts-beg-845.js";import"./index-tangy-colts-beg-4.js";import"./index.es-tangy-colts-beg-4.js";import"./paginati-tangy-colts-beg-302.js";import"./index-tangy-colts-beg-26.js";import"./index-tangy-colts-beg-245.js";import"./utilscss-tangy-colts-beg-788.js";import"./index-tangy-colts-beg-472.js";import"./index-tangy-colts-beg-837.js";import"./usedebou-tangy-colts-beg-721.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(o,n){return this.cache.has(o)?this.cache.get(o):(this.cache.set(o,n),n)}};var V={name:"19hpbzq",styles:"margin:6px 0 !important"},W={name:"1dftezk",styles:"max-width:150px;min-width:150px"},X={name:"ozd7xs",styles:"flex-shrink:0"},Y={name:"6dhm9o",styles:"visibility:hidden"};function Z({conditionId:o,nodeId:n}){const[d,c]=F(_(n)),x=()=>{var i,e;const t=(e=(i=d==null?void 0:d.states)==null?void 0:i.conditions)==null?void 0:e.find(r=>r.id===o);return!t||t.type===C.defaultConditionLogic?[]:t.condition},g=w.useMemo(x,[d,o]),h=(t,i,e)=>{c(r=>y(r,l=>{var E,b;const a=(b=(E=l.states)==null?void 0:E.conditions)==null?void 0:b.find(S=>S.id===o);if(!a||a.type===C.defaultConditionLogic)return;const p=a.condition[i];p.type==="logical-operator"?p.value=t:e==="leftExp"?p.leftExp=t:e==="operator"?p.operator=t:e==="rightExp"&&(p.rightExp=t)}))},u=t=>()=>{c(i=>y(i,e=>{var l,a;const r=(a=(l=e.states)==null?void 0:l.conditions)==null?void 0:a.find(p=>p.id===o);!r||r.type===C.defaultConditionLogic||r.condition.splice(t+1,0,{id:L(),...G},{id:L(),...H})}))},f=t=>()=>{c(i=>y(i,e=>{var l,a;const r=(a=(l=e.states)==null?void 0:l.conditions)==null?void 0:a.find(p=>p.id===o);!r||r.type===C.defaultConditionLogic||r.condition.splice(t-1,2)}))};return o?s(T,{children:g.map((t,i)=>m("div",{children:[t.type==="logical-operator"&&s(k,{css:V,onChange:e=>h(e,i,"logicalOperator"),options:D,value:t.value}),t.type==="logic"&&m(Q,{align:"middle",gap:6,children:[s(j,{onChange:e=>h(e,i,"leftExp"),value:t.leftExp,wrapperClassName:"w-100"}),s(k,{css:W,dropdownStyle:{width:300},onChange:e=>h(e,i,"operator"),options:P,showSearch:!0,value:t.operator}),s(j,{onChange:e=>h(e,i,"rightExp"),value:t.rightExp,wrapperClassName:"w-100"}),m(A,{css:X,size:6,children:[s(v,{icon:s(I,{}),onClick:u(i),shape:"circle"}),i===0?s(v,{css:Y}):s(v,{danger:!0,icon:s(O,{}),onClick:f(i),shape:"circle"})]})]})]},t.id))}):s(T,{children:M("Condition ID Missing")})}globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(o,n){return this.cache.has(o)?this.cache.get(o):(this.cache.set(o,n),n)}};const kt=w.memo(tt);function tt({conditionId:o,nodeId:n}){var u;const{token:d}=q.useToken(),[c,x]=F(_(n)),g=w.useMemo(()=>{var f,t;return((t=(f=c==null?void 0:c.states)==null?void 0:f.conditions)==null?void 0:t.find(i=>i.id===o))||{}},[o,(u=c==null?void 0:c.states)==null?void 0:u.conditions]),h=f=>{x(t=>y(t,i=>{var r,l;const e=(l=(r=i.states)==null?void 0:r.conditions)==null?void 0:l.find(a=>a.id===o);e&&(e.title=f)}))};return m(T,{children:[m("div",{className:"mb-4",children:[s($,{}),m(U,{align:"middle",gutter:15,children:[s(N,{flex:"none",children:s("div",{className:B(["flex size-12 items-center justify-center rounded-md bg-slate-200 dark:bg-gray-900"]),children:s(J,{size:"2.5rem",stroke:1})})}),m(N,{flex:"auto",children:[s(z.Title,{className:"mb-0",editable:{icon:s(K,{css:R({color:d.colorText},"","")}),onChange:h,triggerType:["icon","text"]},level:5,children:g==null?void 0:g.title}),s(z.Text,{type:"secondary",children:M("Conditional Logic")})]})]})]}),s(Z,{conditionId:o,nodeId:n})]})}export{kt as default};
