import{o as e}from"./rolldown-runtime-BTPm5ob3.js";import{i as t,n,r,t as i}from"./animations-BBry1XJJ.js";import{Ar as a,Gn as o,Gt as s,Ir as c,Jr as l,Ln as ee,Lt as te,Mt as ne,Nr as re,On as ie,Pr as ae,Qr as oe,Qt as u,Vr as se,Wr as ce,Xn as d,Zt as le,_r as ue,at as de,bn as fe,gt as pe,it as me,jn as he,kr as ge,ln as _e,lt as ve,mr as ye,pr as f,sn as be,vt as xe,xr as Se}from"./react-core-DZu2Qwle.js";import{u as p}from"./vendor-DE5lxjzu.js";import{$ as Ce,A as we,B as Te,C as Ee,E as m,L as De,O as h,Q as Oe,R as ke,T as g,V as Ae,c as je,ct as _,et as Me,f as Ne,g as v,it as y,j as Pe,l as Fe,nt as Ie,ot as b,st as x,tt as Le,w as Re,y as ze,z as Be}from"./index-OXd4Aieb.js";import{t as S}from"./searchable-select-RneZJ5TX.js";import{t as C}from"./multi-select-tagify-CzmpbAzV.js";import{t as Ve}from"./whatsapp-rule-config-K97boaaq.js";import{t as He}from"./personalization-dialog-CKBn1f6Z.js";var w=e(r(),1),T=t(),E=({className:e,size:t=24})=>(0,T.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,className:e,children:(0,T.jsx)(`path`,{d:`M7 0C7.55228 0 8 0.447715 8 1V3H16V1C16 0.447715 16.4477 0 17 0H19C19.5523 0 20 0.447715 20 1V3C22.2091 3 24 4.79086 24 7V17C24 19.2091 22.2091 21 20 21H17C17 21 14 24 12 24C10 24 7 21 7 21H4C1.79086 21 1.61067e-08 19.2091 0 17V7C0 4.79086 1.79086 3 4 3V1C4 0.447715 4.44772 0 5 0H7ZM4 5C2.89543 5 2 5.89543 2 7V17C2 18.1046 2.89543 19 4 19H20C21.1046 19 22 18.1046 22 17V7C22 5.89543 21.1046 5 20 5H4ZM9 9C9.55228 9 10 9.44772 10 10V14C10 14.5523 9.55228 15 9 15H7C6.44772 15 6 14.5523 6 14V10C6 9.44772 6.44772 9 7 9H9ZM17 9C17.5523 9 18 9.44772 18 10V14C18 14.5523 17.5523 15 17 15H15C14.4477 15 14 14.5523 14 14V10C14 9.44772 14.4477 9 15 9H17Z`,fill:`#004349`})}),Ue=`{أهلاً بك|مرحباً بك|يا هلا وغلا} يا {{user_name}}، ✨

يسعدنا جداً انضمامك إلينا في *{{sitename}}*! 🚀
تم تسجيل دخولك بنجاح إلى حسابك الخاص. نقدر ثقتك الكبيرة بنا ونسعى دائماً لتقديم أفضل تجربة تسوق وخدمات تليق بك.

هل تواجه أي صعوبة في تصفح حسابك أو تحتاج إلى أي مساعدة فنية سريعة؟

💬 لا تتردد بالرد مباشرة على هذه الرسالة وسيقوم فريق الدعم بمساعدتك !

تصفح حسابك من هنا: {{site_link}}

*مع أطيب التحيات،*
*فريق عمل {{sitename}}*

_إلغاء الاشتراك: أرسل STOP_`,We=`{Hello|Hi there|Greetings} {{user_name}}, ✨

We are absolutely thrilled to welcome you to *{{sitename}}*! 🚀
Your account has been successfully created. We appreciate your trust and are committed to delivering a seamless experience.

Are you having any trouble logging in, or is there anything we can help you with today?

💬 Reply directly to this message and our dedicated support team will assist you!

Access your account dashboard here:
{{site_link}}

*Warm regards,*
*{{sitename}} Team*

_Reply STOP to unsubscribe_`,D=`{مرحباً بك|أهلاً عميلنا العزيز|يا هلا وغلا} يا {{wc_billing_first_name}}، 🛍️

سعداء بإبلاغك أن حالة طلبك رقم *#{{id}}* في متجر *{{shop_name}}* قد تم تحديثها بنجاح إلى: *{{status}}*! 🎉

إجمالي الطلب: *{{order_total}} {{currency}}* 💰
فريقنا يعمل حالياً بكل حب لتجهيز طلبك وشحنه بأسرع وقت ممكن لكي يصلك في أفضل حال.

هل تود التحقق من تفاصيل الطلب كاملة أو تعديل أي بيانات خاصة بالشحن؟

🚚 يمكنك تتبع طلبك وإدارته في أي وقت عبر الرابط التالي:
{{order_link}}

*شكراً لتسوقك معنا،*
*فريق {{shop_name}}*

_إلغاء الاشتراك: أرسل STOP_`,O=`{Hello|Hi there|Greetings} {{wc_billing_first_name}}, 🛍️

We are pleased to inform you that your order *#{{id}}* at *{{shop_name}}* has been updated to: *{{status}}*! 🎉

Order Total: *{{order_total}} {{currency}}* 💰
Our team is currently preparing your package with care to ensure it reaches you in perfect condition.

Would you like to review your shipping details or modify any delivery preferences?

🚚 Track your order status in real-time here:
{{order_link}}

*Thanks for shopping,*
*{{shop_name}} Team*

_Reply STOP to unsubscribe_`,k=`{أهلاً بك|مرحباً بك عميلنا العزيز|يا هلا بك} يا {{wc_billing_first_name}}، 🛒

لقد لاحظنا أنك ترت المنتجات الرائعة في سلة تسوقك في *{{shop_name}}* قبل إتمام الشراء. 💔

لقد قمنا بحفظ منتجاتك بأمان لكي لا تضيع عليك، وهي بانتظارك الآن لتكمل رحلتك معنا!

هل واجهتك أي مشكلة أثناء الدفع أو تود الحصول على استشارة سريعة حول المنتجات؟

🎁 لإتمام عملية الشراء بنجاح والحصول على منتجاتك، يمكنك الضغط على رابط سلتك مباشرة من هنا:
{{cart_url}}

*يسعدنا دائماً خدمتك،*
*فريق {{shop_name}}*

_إلغاء الاشتراك: أرسل STOP_`,A=`{Hello|Hi there|Greetings} {{wc_billing_first_name}}, 🛒

We noticed you left some amazing items in your shopping cart at *{{shop_name}}*. 💔

We have saved your selection securely so you do not miss out on them, and they are waiting for you to complete your journey!

Did you encounter any technical issues during checkout, or do you have any questions about the products?

🎁 To complete your purchase and secure your items, click your direct cart link here:
{{cart_url}}

*Best regards,*
*{{shop_name}} Team*

_Reply STOP to unsubscribe_`,j=`Hello {user_name}, welcome to {sitename}!`,M=`Hello {{user_name}}, welcome to {{sitename}}!`,Ge=e=>{let t=(e||``).trim();return!t||t===j||t===M||t===Ue||t===We||t===D||t===O||t===k||t===A},Ke=(e,t=`en`)=>{let n=e||``,r=String(t||``).toLowerCase().startsWith(`ar`);return n===`abandoned_cart`||n===`potential_customer`||n===`shopping`?r?k:A:n.startsWith(`wc_`)||n.startsWith(`wc-`)?r?D:O:r?Ue:We};function N({data:e}){let[t,r]=(0,w.useState)(null),[D,O]=(0,w.useState)(null),[k,A]=(0,w.useState)(``),[j,M]=(0,w.useState)(`idle`),[N,P]=(0,w.useState)(!1),qe=(0,w.useRef)(D),Je=(0,w.useRef)(N);(0,w.useEffect)(()=>{qe.current=D},[D]),(0,w.useEffect)(()=>{Je.current=N},[N]);let[F,I]=(0,w.useState)(null),[L,R]=(0,w.useState)(1),[z,B]=(0,w.useState)(!1),[Ye,V]=(0,w.useState)(!1),[H,Xe]=(0,w.useState)(``),[U,Ze]=(0,w.useState)(``),[Qe,$e]=(0,w.useState)(!1),[W,G]=(0,w.useState)(null),[et,tt]=(0,w.useState)([]),[nt,rt]=(0,w.useState)([]),[K,it]=(0,w.useState)(new Set([1])),[at,ot]=(0,w.useState)(new Set),[st,ct]=(0,w.useState)(!1),[lt,ut]=(0,w.useState)({id:``,field:``,isAdmin:!1}),[dt,ft]=(0,w.useState)(``),[pt,mt]=(0,w.useState)(!1),ht=(0,w.useRef)(null);(0,w.useEffect)(()=>{pt&&ht.current&&ht.current.focus()},[pt]);let q=e.isFreeUser,[J,gt]=(0,w.useState)(!!e.features?.multilang?.enabled),[_t,vt]=(0,w.useState)(!1),[yt,Y]=(0,w.useState)(!1),bt=()=>{q?Y(!0):J?V(!0):Y(!0)},xt=e=>{if(!J&&e!==D?.main_language_code){bt();return}A(e)},St=async t=>{vt(!0);try{(await(await fetch(e.global?.settingsRestUrl||``,{method:`POST`,headers:{"Content-Type":`application/json`,"X-WP-Nonce":e.global?.wpRestNonce||``},body:JSON.stringify({settings:{wawp_multilang_enabled:+!!t}})})).json()).success?(gt(t),p.success(t?`Multilingual Automations enabled successfully!`:`Multilingual Automations disabled.`),window.dispatchEvent(new CustomEvent(`wawp-refresh-data`))):p.error(`Failed to update feature state.`)}catch{p.error(`Error connecting to site.`)}finally{vt(!1)}};(0,w.useEffect)(()=>{if(e?.notificationsData){let t=e.notificationsData,n=qe.current;if(n!==null&&(Je.current||JSON.stringify(n)===JSON.stringify(t.settings)))return;Promise.resolve().then(()=>{r({...t,isMultiLangActive:!0,isPro:!0}),O(JSON.parse(JSON.stringify(t.settings))),A(t.settings.main_language_code||Object.keys(t.settings.configured_languages)[0]),P(!1),t.initial_products&&tt(t.initial_products),t.initial_categories&&rt(t.initial_categories)})}},[e,qe,Je]),(0,w.useEffect)(()=>{if(F){let e=setTimeout(()=>{it(e=>new Set([...e,L]))},0);return()=>clearTimeout(e)}},[L,F]),(0,w.useEffect)(()=>{q&&F?.rule?.wa_driver===`meta`&&Promise.resolve().then(()=>{I(e=>e&&{...e,rule:{...e.rule,wa_driver:`instance`}})})},[q,F?.rule?.wa_driver]),(0,w.useEffect)(()=>{if(!F)return;let e=setTimeout(()=>{let e=F.rule,t=new Set;e.trigger_key&&t.add(1),(e.whatsapp_enabled||e.email_enabled||e.admin_whatsapp_enabled||e.admin_email_enabled)&&t.add(2),e.image_source_type&&t.add(3),(e.whatsapp_enabled&&e.whatsapp_message||e.email_enabled&&e.email_body)&&t.add(4),K.has(5)&&t.add(5),K.has(6)&&t.add(6),ot(t)},0);return()=>clearTimeout(e)},[F,K]);let Ct=async n=>{if(!n||n.length<1){t?.initial_products&&tt(t.initial_products);return}if(!(n.length<2))try{let t=await(await fetch(`${e.global?.apiRestUrl}/entities/search?entity_type=product&q=${encodeURIComponent(n)}`,{headers:{"X-WP-Nonce":e.global?.wpRestNonce||``}})).json();t.results&&tt(t.results)}catch{}},wt=async n=>{if(!n||n.length<1){t?.initial_categories&&rt(t.initial_categories);return}if(!(n.length<2))try{let t=await(await fetch(`${e.global?.apiRestUrl}/entities/search?entity_type=category&q=${encodeURIComponent(n)}`,{headers:{"X-WP-Nonce":e.global?.wpRestNonce||``}})).json();t.results&&rt(t.results)}catch{}},Tt=(e,t,n)=>{if(!F)return;let r=document.getElementById(e);if(r){let e=r.selectionStart||0,i=r.selectionEnd||0,a=String(F.rule[n]||``),o=a.substring(0,e)+t+a.substring(i);I({...F,rule:{...F.rule,[n]:o}}),setTimeout(()=>{r.focus(),r.setSelectionRange(e+t.length,e+t.length)},50)}else{let e=String(F.rule[n]||``);I({...F,rule:{...F.rule,[n]:e+t}})}},Et=(e,t)=>{if(F&&e.key===`Enter`){let n=e.currentTarget,r=n.value,i=n.selectionStart,a=r.lastIndexOf(`
`,i-1)+1,o=r.substring(a,i),s=o.match(/^(\* | - |> )/),c=o.match(/^(\d+)\. /);if(s||c){let l=s?s[0]:`${parseInt(c[1])+1}. `;if(o.trim()===l.trim().replace(/\d+/,``).replace(`.`,``)){e.preventDefault();let n=r.substring(0,a)+r.substring(i);I({...F,rule:{...F.rule,[t]:n}})}else{e.preventDefault();let a=r.substring(0,i)+`
`+l+r.substring(i);I({...F,rule:{...F.rule,[t]:a}}),setTimeout(()=>{n.setSelectionRange(i+1+l.length,i+1+l.length)},50)}}}},X=(0,w.useCallback)(async(t,n=!1)=>{M(`saving`);try{let n=await(await fetch(e.global?.settingsRestUrl||``,{method:`POST`,headers:{"Content-Type":`application/json`,"X-WP-Nonce":e.global?.wpRestNonce||``},body:JSON.stringify({settings:{wawp_notifications:t}})})).json();if(n.success){M(`saved`),window.dispatchEvent(new CustomEvent(`wawp-refresh-data`)),P(!1);let e=JSON.parse(JSON.stringify(t));return r(t=>t?{...t,settings:e}:null),O(e),setTimeout(()=>M(`idle`),3e3),!0}else throw Error(n.message||`Failed to save`)}catch(e){return M(`error`),n||p.error(`Save failed: `+e.message),!1}},[e.global]);(0,w.useEffect)(()=>{let e=e=>{N&&(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[N]),(0,w.useEffect)(()=>{if(!N||z)return;let e=setTimeout(()=>{X(D,!0)},2e3);return()=>clearTimeout(e)},[D,N,z,X]);let Z=(0,w.useCallback)((t,n)=>{let r=e.notificationsData?.i18n?.[t]||e.i18n?.[t]||window.wawpDashboardData?.i18n?.[t]||n;return typeof r==`string`?r:n},[e.notificationsData,e.i18n]),Dt=(0,w.useCallback)((e,t)=>{O(n=>{if(!n)return n;let r={...n};return r.configured_languages[e].notifications[t].enabled=!r.configured_languages[e].notifications[t].enabled,r}),P(!0)},[]),Q=(0,w.useCallback)((e,t,n)=>{let r=t.sender_type.includes(`meta`);I({lang:e,rule:{...t,wa_driver:r?`meta`:`instance`,admin_meta_message_type:t.admin_meta_message_type||`text`,admin_meta_template_name:t.admin_meta_template_name||``,admin_meta_template_lang:t.admin_meta_template_lang||``},index:n}),R(1),B(!0)},[]),Ot=async()=>{if(!F)return;let e=F.rule,t=e.whatsapp_enabled===1||e.email_enabled===1,n=e.admin_whatsapp_enabled===1||e.admin_email_enabled===1,r=`none`,i=e.wa_driver||`instance`;t&&n?r=(e.whatsapp_enabled||e.admin_whatsapp_enabled)&&(e.email_enabled||e.admin_email_enabled)?i===`meta`?`user_admin_meta_both`:`user_admin_both`:e.whatsapp_enabled||e.admin_whatsapp_enabled?i===`meta`?`user_admin_meta_whatsapp`:`user_admin_whatsapp`:`user_admin_email`:t?r=e.whatsapp_enabled&&e.email_enabled?i===`meta`?`user_meta_both`:`user_both`:e.whatsapp_enabled?i===`meta`?`user_meta_whatsapp`:`user_whatsapp`:`user_email`:n&&(r=e.admin_whatsapp_enabled&&e.admin_email_enabled?i===`meta`?`admin_meta_both`:`admin_both`:e.admin_whatsapp_enabled?i===`meta`?`admin_meta_whatsapp`:`admin_whatsapp`:`admin_email`);let a={...e,sender_type:r,whatsapp_media_url:e.image_source_type===`custom`?e.custom_image_url:``,admin_whatsapp_media_url:e.image_source_type===`custom`?e.custom_image_url:``,send_product_image:+(e.image_source_type===`product_image`)},o=JSON.parse(JSON.stringify(D));o.configured_languages[F.lang].notifications[F.index]=a,await X(o)&&B(!1)},kt=(0,w.useCallback)(e=>{if(!D)return;let t=D.configured_languages[e]?.notifications?.length||0;if(q&&t>=5){p.error(`Free plan is limited to 5 notifications. Upgrade to add more.`);return}let n=JSON.parse(JSON.stringify(D)),r={id:`rule_`+Date.now(),enabled:!0,trigger_key:`user_login`,sender_type:`user_whatsapp`,country_filter_enabled:0,product_filter_enabled:0,category_filter_enabled:0,payment_filter_enabled:0,billing_countries_whitelist:``,billing_countries_blocklist:``,payment_gateways:``,product_ids_whitelist:``,product_ids_blocklist:``,category_ids_whitelist:``,category_ids_blocklist:``,whatsapp_enabled:1,whatsapp_message:e.toLowerCase().startsWith(`ar`)?Ue:We,whatsapp_media_url:``,email_enabled:0,email_subject:Z(`defaultEmailSubject`,`Notification from {sitename}`),email_body:Z(`defaultEmailBody`,`Hello {user_name},

This is a notification regarding your account on {sitename}.`),admin_user_ids:``,admin_whatsapp_enabled:0,admin_whatsapp_message:``,admin_whatsapp_media_url:``,admin_email_enabled:0,admin_email_subject:``,admin_email_body:``,image_source_type:`none`,custom_image_url:``,send_product_image:0,send_timing:`instant`,delay_value:1,delay_unit:`minutes`,meta_message_type:`text`,meta_template_name:``,meta_template_lang:``,admin_meta_message_type:`text`,admin_meta_template_name:``,admin_meta_template_lang:``,email_template_id:``,wa_driver:`instance`};n.configured_languages[e].notifications.unshift(r),O(n),P(!0),Q(e,r,0)},[D,Q,q,Z]),At=async()=>{if(!U||!F){alert(`Please select a team member for the test.`);return}$e(!0),G(null);try{let t=await(await fetch(`${e.global?.apiRestUrl}/notifications/test`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-WP-Nonce":e.global?.wpRestNonce||``},body:JSON.stringify({test_admin_id:U,rule_data:F.rule})})).json();t.success?G({status:`success`,message:t.data.message||`Success!`}):G({status:`error`,message:t.message||`Error.`})}catch{G({status:`error`,message:`Network error.`})}finally{$e(!1)}},jt=(0,w.useCallback)((e,t)=>{window.confirm(Z(`confirmDeleteRule`,`Are you sure you want to delete this notification?`))&&(O(n=>{if(!n)return n;let r={...n};return r.configured_languages[e].notifications.splice(t,1),r}),P(!0),p.success(Z(`ruleRemoved`,`Rule removed.`)))},[Z]),Mt=(0,w.useCallback)((e,t)=>{if(!D)return;let n=D.configured_languages[e].notifications||[];if(q&&n.length>=5){p.error(`Free plan is limited to 5 notifications. Upgrade to add more.`);return}let r=JSON.parse(JSON.stringify(D)),i={...r.configured_languages[e].notifications[t],id:`rule_`+Date.now()};r.configured_languages[e].notifications.splice(t+1,0,i),O(r),P(!0),p.success(Z(`ruleDuplicated`,`Rule duplicated.`))},[D,Z,q]),Nt=async e=>{if(e===D.main_language_code||!window.confirm(`Are you sure you want to delete ${D.configured_languages[e].name} and all its notifications?`))return;let t={...D,configured_languages:{...D.configured_languages}};delete t.configured_languages[e],k===e&&A(D.main_language_code),O(t),await X(t)};if(!t||!D)return null;let $=e.rtl||window.wawpDashboardData?.rtl,Pt=async e=>{if(!D)return;if(D.configured_languages[e]){p.error(`This language is already configured.`);return}let n=t.availableTranslations[e],r={...D,configured_languages:{...D.configured_languages,[e]:{name:`${n.native_name} (${n.english_name})`,notifications:[]}}};O(r),A(e),V(!1),await X(r)&&p.success(`${n.english_name} added successfully!`)},Ft=e=>{let n=e.trigger_key;if(n===`user_login`)return Z(`descUserLogin`,`Sent automatically when a user logs into your site.`);if(n===`user_signup`)return Z(`descUserSignup`,`Sent automatically when a new user registers on your site.`);if(n===`wc_order_note_added`)return Z(`descWcOrderNoteAdded`,`Sent when a new customer note is added to an order.`);if(n&&n.startsWith(`wc_status_`)){let e=n.replace(`wc_status_`,``);return Z(`descWcStatusPrefix`,`Sent when an order status is updated to {status}.`).replace(`{status}`,e)}if(n&&n.startsWith(`wc_sub_status_`)){let e=n.replace(`wc_sub_status_`,``);return Z(`descWcSubStatusPrefix`,`Sent when a subscription is marked as {status}.`).replace(`{status}`,e)}return n===`wc_sub_renewal_payment_complete`?Z(`descWcSubRenewal`,`Sent when a subscription renewal payment is successfully processed.`):n===`wc_sub_note_added`?Z(`descWcSubNote`,`Sent when a note is added to a subscription by an administrator.`):Z(`descTriggerFallback`,`This notification triggers on the {event} event.`).replace(`{event}`,t.availableTriggers[n]?.label||`selected`)},It=Object.entries(t.availableTranslations).filter(([e])=>!D.configured_languages[e]).filter(([e,t])=>t.english_name.toLowerCase().includes(H.toLowerCase())||t.native_name.toLowerCase().includes(H.toLowerCase())||e.toLowerCase().includes(H.toLowerCase())),Lt=e=>{let t={wordpress:[],woocommerce:[],subscriptions:[],wawp:[],other:[]};return e.forEach((e,n)=>{let r=e.trigger_key||``,i={rule:e,originalIdx:n};r===`abandoned_cart`||r===`potential_customer`||r===`shopping`?t.wawp.push(i):r.startsWith(`wc_sub_`)?t.subscriptions.push(i):r.startsWith(`wc_status_`)||r===`wc_order_note_added`?t.woocommerce.push(i):r===`user_login`||r===`user_signup`||r.startsWith(`user_`)?t.wordpress.push(i):t.other.push(i)}),t};return(0,T.jsxs)(Pe,{children:[(0,T.jsx)(we,{title:Z(`pageTitle`,`Notifications Builder`),description:Z(`pageSubtitle`,`Unlimited notification options.`),children:(0,T.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[pt?(0,T.jsxs)(`div`,{className:`relative group/search animate-in fade-in slide-in-from-right-2 duration-300`,children:[(0,T.jsx)(`div`,{className:`absolute inset-y-0 flex items-center pointer-events-none text-slate-400 group-focus-within/search:text-[#004449] transition-colors`,style:{[$?`right`:`left`]:`12px`},children:(0,T.jsx)(u,{className:`w-3.5 h-3.5`,strokeWidth:2.5})}),(0,T.jsx)(`input`,{ref:ht,type:`text`,placeholder:Z(`searchRules`,`Search rules...`),className:`w-[180px] sm:w-[220px] bg-white border border-[#dcdcde] rounded-[5px] text-[12px] font-medium focus:ring-2 focus:ring-[#004449]/10 focus:border-[#004449]/50 transition-all outline-none h-8 animate-in fade-in duration-200`,style:{paddingLeft:`40px`,paddingRight:`40px`},value:dt,onChange:e=>ft(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(ft(``),mt(!1))}}),(0,T.jsx)(`button`,{onClick:()=>{ft(``),mt(!1)},className:`absolute inset-y-0 flex items-center text-slate-400 hover:text-slate-600 p-1`,style:{[$?`left`:`right`]:`8px`},children:(0,T.jsx)(de,{className:`w-3.5 h-3.5`,strokeWidth:2.5})})]}):(0,T.jsx)(g,{size:`icon`,className:`bg-white border-[#dcdcde] hover:border-[#004449]/30 hover:text-[#004449] group/sbtn`,onClick:()=>mt(!0),title:Z(`searchRules`,`Search rules`),children:(0,T.jsx)(u,{className:`w-4 h-4 text-slate-500 group-hover/sbtn:text-[#004449] transition-colors`,strokeWidth:2.5})}),(0,T.jsx)(Re,{saveStatus:j,hasUnsavedChanges:N,isSaving:j===`saving`,onSave:()=>X(D)}),(0,T.jsx)(g,{size:`icon`,className:`bg-white border-[#dcdcde] hover:border-[#004449]/30 hover:text-[#004449] group/dbtn shrink-0`,onClick:()=>window.open(`https://help.wawp.net/${$?`ar`:`en`}/articles/multi-language-notifications`,`_blank`),title:$?`دليل الإشعارات متعددة اللغات`:`Multi-Language Notifications Guide`,children:(0,T.jsx)(ce,{className:`w-4 h-4 text-slate-500 group-hover/dbtn:text-[#004449] transition-colors`,strokeWidth:2})})]})}),(0,T.jsx)(`div`,{className:`w-full space-y-4`,children:(()=>{let e=Object.keys(D.configured_languages).length>1;return(0,T.jsxs)(ke,{value:k,onValueChange:xt,className:`w-full`,children:[t.isMultiLangActive&&e&&(0,T.jsxs)(`div`,{className:`flex items-center justify-between pb-2`,children:[(0,T.jsx)(Te,{className:`bg-muted p-1 h-auto flex gap-1 rounded-md`,children:Object.keys(D.configured_languages).map(e=>(0,T.jsxs)(Ae,{value:e,className:`px-4 py-1.5 text-sm font-medium transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm rounded-sm flex items-center gap-2 group`,children:[D.configured_languages[e].name.split(` (`)[0],e===D.main_language_code?(0,T.jsx)(b,{variant:`secondary`,className:`px-1 py-0 h-4 text-[10px] bg-yellow-100 text-yellow-700 font-medium border-yellow-100 uppercase hover:bg-yellow-100`,children:Z(`main`,`Main`)}):(0,T.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[!J&&(0,T.jsx)(he,{className:`w-3 h-3 text-slate-400`}),(0,T.jsx)(`button`,{onClick:t=>{t.stopPropagation(),O({...D,main_language_code:e}),P(!0),p.info(`${Z(`mainLangUpdatedTo`,`Main language updated to`)} ${D.configured_languages[e].name.split(` (`)[0]}. ${Z(`rememberToSave`,`Remember to save changes!`)}`)},className:`opacity-0 group-hover:opacity-100 text-slate-400 hover:text-amber-500 transition-all flex items-center justify-center p-0.5`,title:Z(`setAsMainLanguage`,`Set as Main Language`),children:(0,T.jsx)(ne,{className:`w-3.5 h-3.5`})}),(0,T.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Nt(e)},className:`opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all flex items-center justify-center p-0.5`,title:Z(`deleteLanguage`,`Delete Language`),children:(0,T.jsx)(xe,{className:`w-3.5 h-3.5`})})]})]},e))}),(0,T.jsx)(`div`,{className:`ps-4`,children:(0,T.jsxs)(g,{onClick:bt,className:`text-muted-foreground border-none shadow-none bg-transparent hover:bg-muted`,children:[(0,T.jsx)(be,{className:`w-4 h-4 mr-2`}),` `,Z(`addLanguage`,`Add language`)]})})]}),Object.keys(D.configured_languages).map(n=>{let r=D.configured_languages[n].notifications||[],i=dt?r.filter((e,n)=>{let r=t.availableTriggers[e.trigger_key]?.label||e.trigger_key||``,i=Ft(e),a=dt.toLowerCase();return r.toLowerCase().includes(a)||i.toLowerCase().includes(a)||String(n).includes(a)}):r,o=Lt(i),s=r.length===0;return(0,T.jsxs)(Be,{value:n,className:`mt-6 space-y-8 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4 p-5 bg-white border border-slate-200 rounded-xl mb-6`,children:[(0,T.jsx)(m,{title:`${Z(`activeTriggerAutomations`,`Active Trigger Automations`)} (${i.length})`,description:Z(`rulesGroupedDesc`,`Rules are grouped by feature for easier management.`),icon:me,className:`mb-0`}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!e&&(0,T.jsx)(v,{onClick:bt,size:`icon`,className:`rounded-full hover:bg-slate-50 transition-all text-slate-400`,title:Z(`addLanguage`,`Add language`),children:(0,T.jsx)(d,{className:`w-5 h-5`})}),q&&r.length>=5?(0,T.jsxs)(`div`,{className:`flex items-center gap-2 px-3.5 py-2 bg-amber-50 border border-amber-200 rounded-xl`,children:[(0,T.jsx)(he,{className:`w-3.5 h-3.5 text-amber-600 shrink-0`}),(0,T.jsxs)(`span`,{className:`text-[12px] font-bold text-amber-700`,children:[r.length,`/`,5,` notifications used`]}),(0,T.jsxs)(`a`,{href:`https://wawp.net/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 ml-1 px-2.5 py-1 bg-amber-500 hover:bg-amber-600 text-white text-[11px] font-bold rounded-lg transition-colors`,style:{color:`#ffffff`},children:[(0,T.jsx)(f,{className:`w-3 h-3`}),` Upgrade`]})]}):(0,T.jsxs)(Fe,{onClick:()=>kt(n),className:`font-bold`,children:[(0,T.jsx)(be,{className:`w-4 h-4 mr-2`}),` `,Z(`newNotification`,`New Notification`)]})]})]}),s&&!dt?(0,T.jsxs)(`div`,{className:`rounded-md border bg-background p-20 text-center`,children:[(0,T.jsx)(`div`,{className:`w-16 h-16 bg-muted rounded-md flex items-center justify-center mx-auto mb-4`,children:(0,T.jsx)(a,{className:`w-8 h-8 text-muted-foreground`})}),(0,T.jsx)(`h4`,{className:`text-base font-semibold text-foreground`,children:Z(`noNotifsConfigured`,`No Notifications Configured`)}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:Z(`startByAddingTrigger`,`Start by adding your first trigger above to automate your store.`)})]}):(0,T.jsx)(`div`,{className:`space-y-10 pb-12`,children:[{id:`wordpress`,label:Z(`wordpressCoreEvents`,`WordPress Core Events`),data:o.wordpress,icon:t.iconBaseUrl+`wordpress.svg`},{id:`woocommerce`,label:Z(`woocommerceStoreAlerts`,`WooCommerce Store Alerts`),data:o.woocommerce,icon:t.iconBaseUrl+`woocommerce.svg`},{id:`subscriptions`,label:Z(`customerSubscriptions`,`Customer Subscriptions`),data:o.subscriptions,icon:t.iconBaseUrl+`features/woocommerce-subscription-notifications.svg`},{id:`wawp`,label:Z(`wawpAbandonedCartGroup`,`Wawp Abandoned Cart`),data:o.wawp,icon:t.iconBaseUrl+`wawp.svg`},{id:`other`,label:Z(`otherIntegrations`,`Other Integrations`),data:o.other,icon:t.iconBaseUrl+`bell.svg`}].map(e=>e.data.length>0&&(0,T.jsxs)(`section`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 px-2`,children:[e.id===`wawp`?(0,T.jsx)(E,{className:`w-4 h-4 opacity-50`}):(0,T.jsx)(`img`,{src:e.icon,className:`w-4 h-4 opacity-50`,alt:``}),(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-foreground uppercase tracking-wider`,children:e.label}),(0,T.jsx)(je,{className:`flex-1`}),(0,T.jsx)(b,{variant:`secondary`,className:`h-6 px-2.5 text-xs`,children:e.data.length})]}),(0,T.jsx)(`div`,{className:`rounded-md border bg-white overflow-hidden divide-y`,children:e.data.map(({rule:e,originalIdx:i})=>{let a=z&&F?.lang===n&&F?.index===i;return(0,T.jsxs)(`div`,{onClick:()=>Q(n,e,i),className:_(`flex items-center gap-4 px-6 py-4 cursor-pointer transition-colors`,a?`bg-muted`:`hover:bg-muted/50`,!e.enabled&&!a&&`opacity-60`),children:[(0,T.jsxs)(`div`,{className:_(`flex-shrink-0 w-10 h-10 rounded-md border flex items-center justify-center relative bg-background`),children:[t.availableTriggers[e.trigger_key]?.icon_file?.includes(`wawp`)?(0,T.jsx)(E,{className:`w-5 h-5 opacity-80`}):(0,T.jsx)(`img`,{src:t.iconBaseUrl+(t.availableTriggers[e.trigger_key]?.icon_file||`wordpress.svg`),className:`w-5 h-5 opacity-80`}),(0,T.jsxs)(`div`,{className:`absolute -top-1 -right-1 flex -space-x-1`,children:[e.whatsapp_enabled===1&&e.wa_driver!==`meta`&&(0,T.jsx)(`img`,{src:t.iconBaseUrl+`whatsapp.svg`,className:`w-3 h-3 border border-background rounded-full bg-background`}),e.whatsapp_enabled===1&&e.wa_driver===`meta`&&(0,T.jsx)(`img`,{src:t.iconBaseUrl+`meta.svg`,className:`w-3 h-3 border border-background rounded-full bg-background`}),e.email_enabled===1&&(0,T.jsx)(`img`,{src:t.iconBaseUrl+`email.svg`,className:`w-3 h-3 border border-background rounded-full bg-background`})]})]}),(0,T.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`font-semibold text-foreground truncate`,children:t.availableTriggers[e.trigger_key]?.label||`Trigger`}),!e.enabled&&(0,T.jsx)(b,{variant:`secondary`,className:`text-[10px] px-1.5 py-0`,children:Z(`pausedBadge`,`Paused`)}),a&&(0,T.jsx)(b,{variant:`secondary`,className:`text-[10px] px-1.5 py-0 bg-primary/10 text-primary hover:bg-primary/20`,children:`Editing`})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-3 text-muted-foreground mt-1 overflow-hidden`,children:[(0,T.jsx)(`span`,{className:`text-sm truncate flex-shrink min-w-0`,children:Ft(e)}),(0,T.jsx)(`span`,{className:`mx-1 flex-shrink-0`,children:`•`}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-xs flex-shrink-0`,children:[(0,T.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(te,{className:`w-3 h-3`}),` `,e.sender_type.includes(`user`)?Z(`user`,`User`):e.sender_type.includes(`admin`)?Z(`admins`,`Admins`):Z(`both`,`Both`)]}),(0,T.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(Se,{className:`w-3 h-3`}),` `,e.send_timing===`instant`?Z(`instantTiming`,`Instant`):`${e.delay_value} ${e.delay_unit===`minutes`?Z(`delayMins`,`Mins`):e.delay_unit===`hours`?Z(`delayHours`,`Hours`):Z(`delayDays`,`Days`)}`]}),(0,T.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(le,{className:`w-3 h-3 text-emerald-600/80`}),Z(`sentCount`,`%s sent`).replace(`%s`,String(e.sent_count||0))]})]})]})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[(0,T.jsx)(v,{onClick:()=>Q(n,e,i),className:`h-8`,icon:_e,children:Z(`edit`,`Edit`)}),!(q&&r.length>=5)&&(0,T.jsx)(v,{onClick:()=>Mt(n,i),size:`icon-sm`,className:`text-muted-foreground`,icon:ue,children:null}),(0,T.jsx)(Ne,{onClick:()=>jt(n,i),size:`sm`}),(0,T.jsx)(je,{orientation:`vertical`,className:`h-4 mx-2`}),(0,T.jsx)(x,{checked:e.enabled,onCheckedChange:()=>Dt(n,i)})]})]},e.id)})})]},e.id))})]},n)})]})})()}),(0,T.jsx)(n,{children:Ye&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>V(!1),className:`fixed inset-0 bg-black/40 z-[100000] backdrop-blur-sm`}),(0,T.jsx)(i.div,{initial:{x:$?`-100%`:`100%`},animate:{x:0},exit:{x:$?`-100%`:`100%`},transition:{type:`spring`,damping:28,stiffness:220},className:_(`fixed inset-y-0 w-full lg:max-w-[500px] bg-white z-[100001] shadow-xl flex flex-col`,$?`left-0 border-r`:`right-0 border-l`),children:(0,T.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,T.jsx)(`div`,{className:`px-6 py-4 border-b bg-white sticky top-0 z-20`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsx)(m,{title:Z(`addLanguageTitle`,`Add New Language`),description:Z(`addLanguageDesc`,`Select the language you want to translate your notifications to.`),icon:d,className:`mb-0`}),(0,T.jsx)(v,{onClick:()=>V(!1),size:`icon-sm`,className:`rounded-full hover:bg-slate-50 transition-all`,icon:de,children:null})]})}),(0,T.jsx)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar p-6`,children:(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`relative`,children:[(0,T.jsx)(u,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400`}),(0,T.jsx)(h,{label:Z(`searchLanguageLabel`,`Search Language`),placeholder:Z(`searchLanguagePlaceholder`,`Search for a language...`),className:`pl-10`,icon:u,value:H,onChange:e=>Xe(e)})]}),(0,T.jsx)(`div`,{className:`max-h-[600px] overflow-y-auto custom-scrollbar border border-slate-100 rounded-xl divide-y divide-slate-50`,children:It.length===0?(0,T.jsx)(`div`,{className:`p-8 text-center text-slate-400 text-sm font-medium`,children:Z(`noResultsForLang`,`No results found for "%s"`).replace(`%s`,H)}):It.map(([e,t])=>(0,T.jsxs)(`button`,{onClick:()=>Pt(e),className:`w-full text-left p-4 hover:bg-slate-50 flex items-center justify-between group transition-all border-none cursor-pointer`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`p`,{className:`font-bold text-slate-900 group-hover:text-[#004449] transition-colors m-0`,children:t.english_name}),(0,T.jsxs)(`p`,{className:`text-xs text-slate-400 font-medium m-0`,children:[t.native_name,` • `,e]})]}),(0,T.jsx)(re,{className:`w-4 h-4 text-slate-300 group-hover:text-[#004449] transition-all opacity-0 group-hover:opacity-100 transform group-hover:translate-x-1`})]},e))})]})}),(0,T.jsx)(`div`,{className:`p-4 bg-slate-50 border-t border-slate-100 flex justify-end`,children:(0,T.jsx)(v,{onClick:()=>V(!1),className:`font-bold text-slate-400 hover:text-slate-600`,children:Z(`cancel`,`Cancel`)})})]})})]})}),(0,T.jsx)(n,{children:z&&F&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(i.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>B(!1),className:`fixed inset-0 bg-black/40 z-[100000] backdrop-blur-sm`}),(0,T.jsx)(i.div,{initial:{x:$?`-100%`:`100%`},animate:{x:0},exit:{x:$?`-100%`:`100%`},transition:{type:`spring`,damping:28,stiffness:220},className:_(`fixed inset-y-0 w-full lg:max-w-[calc(100%-280px)] xl:max-w-[1200px] bg-white z-[100001] shadow-xl flex flex-col`,$?`left-0 border-r`:`right-0 border-l`),children:(0,T.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,T.jsxs)(`div`,{className:`px-6 pt-5 pb-4 bg-white border-b sticky top-0 z-20`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,T.jsx)(m,{title:Z(`editAutomationRule`,`Edit Automation Rule`),description:Z(`configureNotifFlow`,`Configure your notification flow`),icon:_e,className:`mb-0`}),(0,T.jsx)(v,{onClick:()=>B(!1),size:`icon-sm`,className:`rounded-full hover:bg-slate-50 transition-all`,icon:de,children:null})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,T.jsx)(`div`,{className:`flex-1 h-1.5 bg-slate-100 rounded-full overflow-hidden`,children:(0,T.jsx)(`div`,{className:`h-full bg-primary transition-all duration-500 ease-out`,style:{width:`${L/7*100}%`}})}),(0,T.jsxs)(`span`,{className:`text-[10px] font-semibold text-slate-400 tabular-nums`,children:[L,` / 7`]})]}),(0,T.jsx)(`div`,{className:`flex flex-wrap items-center gap-y-3 gap-x-1.5 py-2`,children:[{id:1,label:Z(`stepTrigger`,`Trigger`)},{id:2,label:Z(`stepChannels`,`Channels`)},{id:3,label:Z(`stepRecipients`,`Recipients`)},{id:4,label:Z(`stepMedia`,`Media`)},{id:5,label:Z(`stepMessage`,`Message`)},{id:6,label:Z(`stepFilters`,`Filters`)},{id:7,label:Z(`stepSimulator`,`Simulator`)}].map((e,t,n)=>{let r=at.has(e.id),i=K.has(e.id),a=L===e.id;return(0,T.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-shrink-0`,children:[(0,T.jsxs)(`button`,{onClick:()=>R(e.id),className:_(`flex items-center gap-1 transition-all outline-none`,a?`text-black scale-[1.02]`:i?`text-gray-500 hover:text-black`:`text-gray-300 hover:text-gray-400`),children:[(0,T.jsx)(`span`,{className:_(`text-[9px] uppercase tracking-[0.05em] font-bold`,a?`font-black`:i?`font-bold`:`font-semibold`),children:e.label}),(0,T.jsx)(`div`,{className:`relative flex items-center justify-center`,children:r?(0,T.jsx)(`div`,{className:`w-3 h-3 rounded-full bg-green-500 flex items-center justify-center border border-green-600/10`,children:(0,T.jsx)(c,{className:`w-2.5 h-2.5 text-white stroke-[4]`})}):i?(0,T.jsx)(Se,{className:`w-3 h-3 text-gray-400`}):(0,T.jsx)(`div`,{className:`w-3 h-3 rounded-full border border-gray-200 bg-white`})})]}),t<n.length-1&&(0,T.jsx)(re,{className:`w-2.5 h-2.5 text-gray-300 flex-shrink-0`})]},e.id)})})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-y-auto custom-scrollbar`,children:(0,T.jsxs)(`div`,{className:`p-6 sm:p-8`,children:[(0,T.jsx)(n,{mode:`wait`,children:(0,T.jsx)(i.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},className:`space-y-1 mb-8`,children:(0,T.jsx)(m,{title:L===1?Z(`titleStep1`,`Trigger & Automation Timing`):L===2?Z(`titleStep2`,`Customer Delivery Channels`):L===3?Z(`titleStep3`,`Configure Recipients`):L===4?Z(`titleStep4`,`Header Media Settings`):L===5?Z(`titleStep5`,`Message Content`):L===6?Z(`titleStep6`,`Audience Targeting Rules`):Z(`titleStep7`,`Simulation Engine`),description:L===1?Z(`descStep1`,`Choose the event category and the specific action that triggers this rule.`):L===2?Z(`descStep2`,`Select which channels to use for sending customer notifications.`):L===3?Z(`descStep3`,`Define who should receive these notifications.`):L===4?Z(`descStep4`,`Make your message standout with a header image.`):L===5?Z(`descStep5`,`Write professional messages for each channel.`):L===6?Z(`descStep6`,`Add specific conditions to filter your audience.`):Z(`descStep7`,`Test your configuration using a real site context.`),icon:L===1?me:L===2?te:L===3?ve:L===4?o:L===5?se:L===6?s:oe})},L)}),(0,T.jsx)(n,{mode:`wait`,children:(0,T.jsxs)(i.div,{initial:{opacity:0,y:10},animate:{opacity:1,x:0},exit:{opacity:0,y:-10},className:`space-y-8`,children:[L===1?(()=>{let n=!!e.wooStatus?.active,r=e.notificationsData?.availableTriggers?`wc_sub_renewal_payment_complete`in e.notificationsData.availableTriggers:!1,i=!!e.features?.abandonedCarts?.enabled,a=(()=>{let e=F.rule.trigger_key||``;return e===`user_login`||e===`user_signup`||e.startsWith(`user_`)?`wordpress`:e.startsWith(`wc_status_`)||e===`wc_order_note_added`?`woocommerce`:e.startsWith(`wc_sub_`)?`subscriptions`:e===`abandoned_cart`||e===`potential_customer`||e===`shopping`?`wawp`:`wordpress`})();return(0,T.jsxs)(`div`,{className:`space-y-6 animate-in fade-in zoom-in-95 duration-300`,children:[(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(y,{className:`text-xs font-semibold text-slate-500 uppercase tracking-wider`,children:Z(`eventCategory`,`Event Category`)}),(0,T.jsx)(S,{options:[{value:`wordpress`,label:Z(`wordpressLabel`,`WordPress`),description:Z(`wordpressDesc`,`Core system events`),icon:(0,T.jsx)(`img`,{src:t.iconBaseUrl+`wordpress.svg`,className:`w-4 h-4 shrink-0`})},{value:`woocommerce`,label:Z(`woocommerceLabel`,`WooCommerce`),description:n?Z(`woocommerceDescActive`,`Store & orders`):Z(`woocommerceDescInactive`,`Requires WooCommerce plugin to be installed and active`),icon:(0,T.jsx)(`img`,{src:t.iconBaseUrl+`woocommerce.svg`,className:`w-4 h-4 shrink-0`}),disabled:!n},{value:`subscriptions`,label:Z(`subscriptionsLabel`,`Subscriptions`),description:r?Z(`subscriptionsDescActive`,`Recurring payments`):n?Z(`subscriptionsDescInactive`,`Requires WooCommerce Subscriptions plugin to be active and Subscription Notifications enabled`):Z(`subscriptionsDescNoWoo`,`Requires WooCommerce plugin active first`),icon:(0,T.jsx)(`img`,{src:t.iconBaseUrl+`Woo-Subscriptions.svg`,className:`w-4 h-4 shrink-0`}),disabled:!r},{value:`wawp`,label:Z(`wawpAbandonedCartLabel`,`Wawp Abandoned Cart`),description:i?Z(`wawpAbandonedCartDescActive`,`Abandoned Cart recovery`):Z(`wawpAbandonedCartDescInactive`,`Requires Abandoned Carts feature to be enabled in Dashboard`),icon:(0,T.jsx)(E,{size:16}),disabled:!i}],value:a,onChange:e=>{let n=Object.entries(t.availableTriggers).find(([t])=>{let n=t||``;return e===`wordpress`?n===`user_login`||n===`user_signup`||n.startsWith(`user_`):e===`woocommerce`?n.startsWith(`wc_status_`)||n===`wc_order_note_added`:e===`subscriptions`?n.startsWith(`wc_sub_`):e===`wawp`?n===`abandoned_cart`||n===`potential_customer`||n===`shopping`:!1});n&&I({...F,rule:{...F.rule,trigger_key:n[0]}})},className:`h-11 bg-white border-slate-200 text-slate-700 font-bold text-[13px] hover:border-[#004449]/30 transition-all rounded-[5px]`})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(y,{className:`text-xs font-semibold text-slate-500 uppercase tracking-wider`,children:Z(`eventAction`,`Event Action`)}),(0,T.jsx)(S,{options:Object.entries(t.availableTriggers).filter(([e])=>{let t=e||``;return a===`wordpress`?t===`user_login`||t===`user_signup`||t.startsWith(`user_`):a===`woocommerce`?t.startsWith(`wc_status_`)||t===`wc_order_note_added`:a===`subscriptions`?t.startsWith(`wc_sub_`):a===`wawp`?t===`abandoned_cart`||t===`potential_customer`||t===`shopping`:!0}).map(([e,n])=>({value:e,label:n.label,icon:n.icon_file?.includes(`wawp`)?(0,T.jsx)(E,{size:16}):(0,T.jsx)(`img`,{src:t.iconBaseUrl+(n.icon_file||`wordpress.svg`),className:`w-4 h-4`})})),value:F.rule.trigger_key,onChange:e=>{let t=F.rule.whatsapp_message||``,n=Ge(t)?Ke(e,F.lang):t;I({...F,rule:{...F.rule,trigger_key:e,whatsapp_message:n}})},className:`h-11 bg-white border-slate-200 text-slate-700 font-bold text-[13px] hover:border-[#004449]/30 transition-all rounded-[5px]`})]}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(y,{className:`text-xs font-semibold text-slate-500 uppercase tracking-wider`,children:Z(`executionSchedule`,`Execution Schedule`)}),(0,T.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,T.jsx)(S,{options:[{value:`instant`,label:Z(`executeImmediately`,`Execute Immediately`)},{value:`delayed`,label:Z(`executeWithDelay`,`Execute with Delay`)}],value:F.rule.send_timing,onChange:e=>I({...F,rule:{...F.rule,send_timing:e}}),className:`h-11 bg-white border-slate-200 text-slate-700 font-bold text-[13px] hover:border-[#004449]/30 transition-all rounded-[5px] flex-1`}),F.rule.send_timing===`delayed`&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2 animate-in slide-in-from-right-4 duration-300`,children:[(0,T.jsx)(h,{type:`number`,label:Z(`delayValue`,`Delay Value`),labelHidden:!0,value:String(F.rule.delay_value),onChange:e=>I({...F,rule:{...F.rule,delay_value:parseInt(e)}}),className:`w-20`}),(0,T.jsx)(S,{options:[{value:`minutes`,label:Z(`delayMins`,`Mins`)},{value:`hours`,label:Z(`delayHours`,`Hours`)},{value:`days`,label:Z(`delayDays`,`Days`)}],value:F.rule.delay_unit,onChange:e=>I({...F,rule:{...F.rule,delay_unit:e}}),className:`h-11 w-24 bg-white border-slate-200 text-slate-700 font-bold text-[13px] hover:border-[#004449]/30 transition-all rounded-[5px]`})]})]})]})]})})():null,L===2&&(0,T.jsxs)(`div`,{className:`space-y-4 animate-in fade-in zoom-in-95 duration-300`,children:[(0,T.jsxs)(`div`,{className:`group transition-all duration-200 bg-white border border-slate-200 rounded-xl overflow-hidden hover:border-slate-300 hover:shadow-sm`,children:[(0,T.jsxs)(`div`,{className:`p-5 flex items-center justify-between gap-4`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,T.jsx)(`div`,{className:`w-12 h-12 rounded-lg bg-emerald-50 border border-emerald-100/50 flex items-center justify-center flex-shrink-0`,children:(0,T.jsx)(`img`,{src:(e.global?.pluginUrl||``)+`assets/img/senders/whatsapp.svg`,className:`w-7 h-7 object-contain`,alt:`WhatsApp`})}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h4`,{className:`text-[15px] font-bold text-slate-800 tracking-tight !m-0 !p-0 leading-tight`,children:Z(`whatsappNotif`,`WhatsApp Notification`)}),(0,T.jsx)(`p`,{className:`text-[13px] font-medium text-slate-500 !m-0 !p-0 leading-tight mt-0.5`,children:Z(`whatsappNotifDesc`,`System will send automated alerts and updates to the user's phone number.`)})]})]}),(0,T.jsx)(x,{checked:F.rule.whatsapp_enabled===1,onCheckedChange:e=>I({...F,rule:{...F.rule,whatsapp_enabled:+!!e}})})]}),F.rule.whatsapp_enabled===1&&(0,T.jsx)(`div`,{className:`px-5 pb-6 pt-2 border-t border-slate-50 space-y-4 animate-in fade-in slide-in-from-top-2 duration-300 bg-slate-50/30`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsx)(y,{className:`text-[10px] font-black text-slate-400 uppercase tracking-[0.1em] pl-0.5`,children:Z(`prefDeliveryMethod`,`Preferred Delivery Method`)}),(0,T.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[{id:`instance`,label:Z(`wawpInstance`,`Wawp Instance`),icon:()=>(0,T.jsx)(E,{size:24}),desc:Z(`wawpInstanceDesc`,`Personal Account`)},{id:`meta`,label:Z(`metaCloudAPI`,`Meta Cloud API`),iconPath:(e.global?.pluginUrl||``)+`assets/img/senders/meta.svg`,desc:q?Z(`metaCloudDesc`,`Paid subscription required to unlock`):Z(`officialAPIDesc`,`Official API`),disabled:q}].map(e=>(0,T.jsxs)(`div`,{className:`relative flex-1`,children:[(0,T.jsx)(ze,{active:F.rule.wa_driver===e.id,label:e.label,description:e.desc,icon:e.icon,iconPath:e.iconPath,disabled:e.disabled,onClick:()=>{e.disabled||I({...F,rule:{...F.rule,wa_driver:e.id}})}}),e.id===`meta`&&q&&(0,T.jsxs)(`span`,{className:`absolute top-2.5 right-2.5 px-2 py-0.5 bg-amber-500/10 border border-amber-500/20 text-amber-700 text-[9px] font-bold rounded-md flex items-center gap-1 shadow-sm select-none pointer-events-none`,children:[(0,T.jsx)(f,{className:`w-2.5 h-2.5 text-amber-600 animate-pulse`}),` Pro`]})]},e.id))})]})})]}),(0,T.jsx)(`div`,{className:`group transition-all duration-200 bg-white border border-slate-200 rounded-xl overflow-hidden hover:border-slate-300 hover:shadow-sm`,children:(0,T.jsxs)(`div`,{className:`p-5 flex items-center justify-between gap-4`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,T.jsx)(`div`,{className:`w-12 h-12 rounded-lg bg-blue-50 border border-blue-100/50 flex items-center justify-center flex-shrink-0`,children:(0,T.jsx)(`img`,{src:(e.global?.pluginUrl||``)+`assets/img/senders/gmail.svg`,className:`w-7 h-7 object-contain`,alt:`Email`})}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`h4`,{className:`text-[15px] font-bold text-slate-800 tracking-tight !m-0 !p-0 leading-tight`,children:Z(`emailSmtpTitle`,`Email SMTP (Site)`)}),(0,T.jsx)(`p`,{className:`text-[13px] font-medium text-slate-500 !m-0 !p-0 leading-tight mt-0.5`,children:Z(`emailSmtpDesc`,`Notifications will be delivered through your website's active SMTP server.`)})]})]}),(0,T.jsx)(x,{checked:F.rule.email_enabled===1,onCheckedChange:e=>I({...F,rule:{...F.rule,email_enabled:+!!e}})})]})})]}),L===3&&(0,T.jsxs)(`div`,{className:`space-y-8 animate-in fade-in duration-300`,children:[(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(y,{className:`text-sm font-bold text-gray-700 flex items-center gap-2`,children:[(0,T.jsx)(s,{className:`w-4 h-4 text-amber-600`}),Z(`enableInternalAdmin`,`1. Enable Internal Admin Channels`)]}),(0,T.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,T.jsx)(`div`,{className:_(`p-4 bg-background border rounded-md space-y-4 transition-all hover:border-amber-200`,F.rule.admin_whatsapp_enabled&&`border-amber-500/20 bg-amber-50/10`),children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsx)(`span`,{className:`text-xs font-bold text-gray-700`,children:Z(`whatsappAlert`,`WhatsApp Alert`)}),(0,T.jsx)(x,{checked:F.rule.admin_whatsapp_enabled===1,onCheckedChange:e=>I({...F,rule:{...F.rule,admin_whatsapp_enabled:+!!e}})})]})}),(0,T.jsx)(`div`,{className:_(`p-4 bg-background border rounded-md space-y-4 transition-all hover:border-blue-200`,F.rule.admin_email_enabled&&`border-blue-500/20 bg-blue-50/10`),children:(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsx)(`span`,{className:`text-xs font-bold text-gray-700`,children:Z(`emailAlert`,`Email Alert`)}),(0,T.jsx)(x,{checked:F.rule.admin_email_enabled===1,onCheckedChange:e=>I({...F,rule:{...F.rule,admin_email_enabled:+!!e}})})]})})]})]}),(F.rule.admin_whatsapp_enabled===1||F.rule.admin_email_enabled===1)&&(0,T.jsxs)(`div`,{className:`space-y-4 pt-4 border-t animate-in fade-in slide-in-from-top-4 duration-500`,children:[(0,T.jsxs)(y,{className:`text-sm font-medium flex items-center gap-2 mb-1`,children:[(0,T.jsx)(ve,{className:`w-4 h-4 text-muted-foreground`}),` `,Z(`selectStaffMembers`,`Select Staff Members to Notify`)]}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground pb-2`,children:Z(`selectStaffMembersDesc`,`Who in your team should get these critical internal alerts?`)}),(0,T.jsx)(`div`,{className:`max-h-[300px] overflow-y-auto p-4 bg-background border rounded-md divide-y`,children:(t.wpAdmins||[]).map(e=>{let t=String(F.rule.admin_user_ids||``).split(`,`).filter(Boolean),n=t.includes(e.ID.toString());return(0,T.jsxs)(`div`,{onClick:()=>{let n=new Set(t);n.has(e.ID.toString())?n.delete(e.ID.toString()):n.add(e.ID.toString()),I({...F,rule:{...F.rule,admin_user_ids:Array.from(n).join(`,`)}})},className:_(`flex items-center justify-between p-3 rounded-md cursor-pointer transition-colors hover:bg-muted/50 group`,n&&`bg-muted border-primary`),children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,T.jsx)(`div`,{className:_(`w-8 h-8 rounded-full flex items-center justify-center text-xs font-semibold`,n?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground`),children:(e.display_name||``).charAt(0)}),(0,T.jsxs)(`div`,{className:`flex flex-col text-left`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`text-sm font-semibold text-gray-800`,children:e.display_name}),e.wa_verified&&(0,T.jsx)(ge,{className:`w-3 h-3 text-green-500`})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`text-[10px] text-gray-400 font-bold`,children:e.user_email}),e.wa_number&&(0,T.jsxs)(`span`,{className:`text-[10px] text-primary/70 font-black bg-primary/5 px-2 py-0.5 rounded-full flex items-center gap-1`,children:[(0,T.jsx)(`span`,{className:`text-xs`,children:String(e.wa_number||``).startsWith(`20`)?`🇪🇬`:String(e.wa_number||``).startsWith(`966`)?`🇸🇦`:String(e.wa_number||``).startsWith(`971`)?`🇦🇪`:`🌐`}),e.wa_number]})]})]})]}),n&&(0,T.jsx)(`div`,{className:`w-6 h-6 bg-primary rounded-full flex items-center justify-center animate-in zoom-in duration-300`,children:(0,T.jsx)(c,{className:`w-3 h-3 text-white`,strokeWidth:5})})]},e.ID)})})]})]}),L===4&&(0,T.jsxs)(`div`,{className:`space-y-8 animate-in fade-in duration-300`,children:[(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsx)(y,{className:`text-sm font-medium`,children:Z(`displayHeaderImage`,`Display Header Image`)}),(0,T.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[{id:`none`,label:Z(`noImageLabel`,`No Image`),icon:(0,T.jsx)(l,{size:18}),desc:Z(`noImageDesc`,`Text-only`)},{id:`featured`,label:Z(`featuredImageLabel`,`Featured Image`),icon:(0,T.jsx)(o,{size:18}),desc:Z(`featuredImageDesc`,`Use WP Post image`)},{id:`custom`,label:Z(`customImageLabel`,`Custom Image`),icon:(0,T.jsx)(d,{size:18}),desc:Z(`customImageDesc`,`Custom Media URL`)}].map(e=>(0,T.jsx)(ze,{active:F.rule.image_source_type===e.id,onClick:()=>I({...F,rule:{...F.rule,image_source_type:e.id}}),label:e.label,description:e.desc,icon:()=>(0,T.jsx)(T.Fragment,{children:e.icon})},e.id))})]}),F.rule.image_source_type===`custom`&&(0,T.jsxs)(`div`,{className:`space-y-3 animate-in fade-in duration-300`,children:[(0,T.jsx)(y,{className:`text-xs font-bold text-gray-400 uppercase tracking-widest pl-1`,children:Z(`mediaUrlDirectLink`,`Media URL (Direct Link)`)}),(0,T.jsx)(h,{label:Z(`mediaUrlLabel`,`Media URL`),placeholder:`https://example.com/promo.jpg`,className:`h-12 bg-white rounded-md  border-gray-200`,icon:o,value:F.rule.custom_image_url,onChange:e=>I({...F,rule:{...F.rule,custom_image_url:e}})})]})]}),L===5&&(0,T.jsx)(`div`,{className:`space-y-6 animate-in fade-in duration-300`,children:(0,T.jsxs)(`div`,{className:`space-y-6`,children:[F.rule.whatsapp_enabled===1&&(0,T.jsx)(Ve,{type:`customer`,rule:F.rule,updateRule:e=>I({...F,rule:{...F.rule,...e}}),metaTemplates:t.metaTemplates,placeholders:t.placeholders,onOpenPersonalization:()=>{ut({id:`customer_wa_ed`,field:`whatsapp_message`,isAdmin:!1}),ct(!0)},onKeyDown:e=>Et(e,`whatsapp_message`)}),F.rule.email_enabled===1&&(0,T.jsxs)(`div`,{className:`border rounded-md bg-background overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`px-4 py-2.5 bg-muted/30 border-b flex items-center justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(d,{className:`w-4 h-4 text-muted-foreground`}),(0,T.jsx)(`span`,{className:`text-xs font-bold text-gray-700`,children:Z(`customerEmailLabel`,`Customer Email`)})]}),(0,T.jsx)(b,{variant:`outline`,className:`h-5 px-1.5 text-[9px] font-bold`,children:`SMTP`})]}),(0,T.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(y,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider pl-1`,children:Z(`subjectLabel`,`Subject`)}),(0,T.jsxs)(`div`,{className:`relative`,children:[(0,T.jsx)(h,{label:Z(`subjectLabel`,`Subject`),placeholder:``,className:$?`pl-20`:`pr-20`,icon:ie,value:F.rule.email_subject,onChange:e=>I({...F,rule:{...F.rule,email_subject:e}}),showEmoji:!0}),(0,T.jsx)(`div`,{className:_(`absolute top-1/2 -translate-y-1/2 flex items-center gap-0.5`,$?`left-1`:`right-1`),children:(0,T.jsx)(v,{size:`icon-sm`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>{ut({id:`email_subject_ed`,field:`email_subject`,isAdmin:!1}),ct(!0)},icon:se,children:null})})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(y,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider pl-1`,children:Z(`selectTemplateLabel`,`Select Template`)}),(0,T.jsx)(S,{options:(t.emailTemplates||[]).map(e=>({value:e.id.toString(),label:e.name})),value:F.rule.email_template_id||``,onChange:e=>I({...F,rule:{...F.rule,email_template_id:e}}),placeholder:Z(`chooseEmailTemplate`,`Choose email template...`),className:`h-11 bg-white border-slate-200 text-slate-700 font-bold text-[13px] hover:border-[#004449]/30 transition-all rounded-[5px]`})]})]})]}),(F.rule.admin_whatsapp_enabled===1||F.rule.admin_email_enabled===1)&&(0,T.jsxs)(`div`,{className:`space-y-4 pt-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,T.jsx)(`div`,{className:`flex-1 h-px bg-slate-100`}),(0,T.jsx)(`span`,{className:`text-[10px] font-semibold text-slate-300 uppercase tracking-widest whitespace-nowrap`,children:Z(`internalAlertsLabel`,`Internal Alerts`)}),(0,T.jsx)(`div`,{className:`flex-1 h-px bg-slate-100`})]}),F.rule.admin_whatsapp_enabled===1&&(0,T.jsx)(Ve,{type:`admin`,rule:F.rule,updateRule:e=>I({...F,rule:{...F.rule,...e}}),metaTemplates:t.metaTemplates,placeholders:t.placeholders,onOpenPersonalization:()=>{ut({id:`admin_wa_ed`,field:`admin_whatsapp_message`,isAdmin:!0}),ct(!0)},onKeyDown:e=>Et(e,`admin_whatsapp_message`)}),F.rule.admin_email_enabled===1&&(0,T.jsxs)(`div`,{className:`border rounded-md bg-background overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`px-4 py-2.5 bg-muted/30 border-b flex items-center justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(d,{className:`w-4 h-4 text-muted-foreground`}),(0,T.jsx)(`span`,{className:`text-xs font-bold text-gray-700`,children:Z(`adminEmailLabel`,`Admin Email`)})]}),(0,T.jsx)(b,{variant:`outline`,className:`h-5 px-1.5 text-[9px] font-bold`,children:`SMTP`})]}),(0,T.jsxs)(`div`,{className:`p-4 space-y-3`,children:[(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(y,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider pl-1`,children:Z(`subjectLabel`,`Subject`)}),(0,T.jsx)(h,{label:Z(`adminEmailSubject`,`Admin Email Subject`),placeholder:``,icon:ie,value:F.rule.admin_email_subject,onChange:e=>I({...F,rule:{...F.rule,admin_email_subject:e}}),showEmoji:!0})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(y,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider pl-1`,children:Z(`selectTemplateLabel`,`Select Template`)}),(0,T.jsx)(S,{options:(t.emailTemplates||[]).map(e=>({value:e.id.toString(),label:e.name})),value:F.rule.admin_email_template_id||``,onChange:e=>I({...F,rule:{...F.rule,admin_email_template_id:e}}),placeholder:Z(`chooseEmailTemplate`,`Choose email template...`),className:`h-11 bg-white border-slate-200 text-slate-700 font-bold text-[13px] hover:border-[#004449]/30 transition-all rounded-[5px]`})]})]})]})]})]})}),L===6&&(0,T.jsxs)(`div`,{className:`space-y-10 animate-in fade-in duration-300`,children:[q&&(0,T.jsxs)(`div`,{className:`p-6 bg-gradient-to-r from-amber-500/10 to-rose-500/10 border border-amber-200/60 rounded-2xl flex flex-col sm:flex-row items-center justify-between gap-6 shadow-sm mb-6 text-left`,children:[(0,T.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,T.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-amber-500/20 border border-amber-500/30 flex items-center justify-center shrink-0`,children:(0,T.jsx)(f,{className:`w-6 h-6 text-amber-600 animate-pulse`})}),(0,T.jsxs)(`div`,{className:`space-y-1 flex-1`,children:[(0,T.jsx)(`h4`,{className:`text-base font-bold text-slate-800`,children:Z(`audienceTargetingPro`,`Audience Targeting requires Pro Plan`)}),(0,T.jsx)(`p`,{className:`text-sm text-slate-600 font-medium leading-relaxed`,children:Z(`audienceTargetingProDesc`,`Advanced targeting rules (Country targeting, Product targeting, Category logic, and Payment targeting) are only available for paid subscription accounts.`)})]})]}),(0,T.jsxs)(`a`,{href:`https://wawp.net/pricing`,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-2 px-5 py-2.5 bg-amber-500 hover:bg-amber-600 text-white font-bold text-xs rounded-xl shadow-md transition-all duration-200 shrink-0`,style:{color:`#ffffff`},children:[(0,T.jsx)(f,{className:`w-3.5 h-3.5`}),` `,Z(`upgradePlanBtn`,`Upgrade Plan`),` `,(0,T.jsx)(re,{className:`w-3.5 h-3.5`})]})]}),(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(y,{className:`text-sm font-medium`,children:Z(`automationTriggerCond`,`Automation Trigger Conditions`)}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:Z(`onlyExecuteIfCond`,`Only execute this rule if the following conditions are met.`)})]}),(0,T.jsx)(`div`,{className:`grid grid-cols-1 gap-6`,children:[{id:`country_filter_enabled`,label:Z(`countrySpecificLabel`,`Country Specific`),icon:(0,T.jsx)(d,{className:`w-4 h-4`})},{id:`product_filter_enabled`,label:Z(`productTargetingLabel`,`Product Targeting`),icon:(0,T.jsx)(fe,{className:`w-4 h-4`}),orderOnly:!0},{id:`category_filter_enabled`,label:Z(`categoryLogicLabel`,`Category Logic`),icon:(0,T.jsx)(ee,{className:`w-4 h-4`}),orderOnly:!0},{id:`payment_filter_enabled`,label:Z(`paymentMethodLabel`,`Payment Method`),icon:(0,T.jsx)(ye,{className:`w-4 h-4`}),orderOnly:!0}].filter(e=>{if(!(`orderOnly`in e)||!e.orderOnly)return!0;let t=F.rule.trigger_key||``;return t.startsWith(`wc_status_`)||t===`wc_order_note_added`||t===`abandoned_cart`||t===`potential_customer`||t===`shopping`}).map(e=>{let n=!q&&F.rule[e.id]===1;return(0,T.jsxs)(`div`,{className:_(`p-4 bg-background border rounded-md transition-colors overflow-hidden`,n&&`border-primary bg-primary/5`,q&&`opacity-60 bg-slate-50 cursor-not-allowed select-none pointer-events-none`),children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 text-left`,children:[(0,T.jsx)(`div`,{className:_(`w-8 h-8 rounded-md flex items-center justify-center transition-colors shadow-sm`,n?`bg-primary text-white`:`bg-muted text-muted-foreground`,q&&`bg-slate-200 text-slate-400`),children:e.icon}),(0,T.jsx)(`span`,{className:_(`text-sm font-bold`,n?`text-gray-900`:`text-gray-700`),children:e.label})]}),(0,T.jsx)(x,{checked:n,disabled:q,onCheckedChange:t=>{q||I({...F,rule:{...F.rule,[e.id]:+!!t}})}})]}),n&&(0,T.jsxs)(`div`,{className:`mt-6 space-y-8 animate-in slide-in-from-top-2 duration-300 border-t pt-6`,children:[e.id===`country_filter_enabled`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`space-y-4`,children:(0,T.jsx)(C,{label:Z(`whitelistCountriesLabel`,`WHITELIST (Only send if...)`),options:Object.entries(t.wcCountries||{}).map(([e,t])=>({value:e,label:t})),selected:String(F.rule.billing_countries_whitelist||``).split(`,`).filter(Boolean),onChange:e=>I({...F,rule:{...F.rule,billing_countries_whitelist:e.join(`,`)}})})}),(0,T.jsx)(`div`,{className:`space-y-4`,children:(0,T.jsx)(C,{label:Z(`blocklistCountriesLabel`,`BLOCKLIST (Do NOT send if...)`),options:Object.entries(t.wcCountries||{}).map(([e,t])=>({value:e,label:t})),selected:String(F.rule.billing_countries_blocklist||``).split(`,`).filter(Boolean),onChange:e=>I({...F,rule:{...F.rule,billing_countries_blocklist:e.join(`,`)}})})})]}),e.id===`product_filter_enabled`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`space-y-4`,children:(0,T.jsx)(C,{label:Z(`allowedProductsLabel`,`ALLOWED PRODUCTS (IDs)`),options:[...et.map(e=>({value:String(e.id),label:e.text})),...t?.preloaded_entities?.product?Object.entries(t.preloaded_entities.product).map(([e,t])=>({value:String(e),label:t})):[]].filter((e,t,n)=>n.findIndex(t=>t.value===e.value)===t),selected:String(F.rule.product_ids_whitelist||``).split(`,`).filter(Boolean),onChange:e=>I({...F,rule:{...F.rule,product_ids_whitelist:e.join(`,`)}}),onSearch:Ct,searchPlaceholder:`Search products by name or SKU...`})}),(0,T.jsx)(`div`,{className:`space-y-4`,children:(0,T.jsx)(C,{label:Z(`restrictedProductsLabel`,`RESTRICTED PRODUCTS (IDs)`),options:[...et.map(e=>({value:String(e.id),label:e.text})),...t?.preloaded_entities?.product?Object.entries(t.preloaded_entities.product).map(([e,t])=>({value:String(e),label:t})):[]].filter((e,t,n)=>n.findIndex(t=>t.value===e.value)===t),selected:String(F.rule.product_ids_blocklist||``).split(`,`).filter(Boolean),onChange:e=>I({...F,rule:{...F.rule,product_ids_blocklist:e.join(`,`)}}),onSearch:Ct,searchPlaceholder:`Search products by name or SKU...`})})]}),e.id===`category_filter_enabled`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`space-y-4`,children:(0,T.jsx)(C,{label:Z(`allowedCategoriesLabel`,`ALLOWED CATEGORIES (IDs)`),options:[...nt.map(e=>({value:String(e.id),label:e.text})),...t?.preloaded_entities?.category?Object.entries(t.preloaded_entities.category).map(([e,t])=>({value:String(e),label:t})):[]].filter((e,t,n)=>n.findIndex(t=>t.value===e.value)===t),selected:String(F.rule.category_ids_whitelist||``).split(`,`).filter(Boolean),onChange:e=>I({...F,rule:{...F.rule,category_ids_whitelist:e.join(`,`)}}),onSearch:wt,searchPlaceholder:`Search categories...`})}),(0,T.jsx)(`div`,{className:`space-y-4`,children:(0,T.jsx)(C,{label:Z(`restrictedCategoriesLabel`,`RESTRICTED CATEGORIES (IDs)`),options:[...nt.map(e=>({value:String(e.id),label:e.text})),...t?.preloaded_entities?.category?Object.entries(t.preloaded_entities.category).map(([e,t])=>({value:String(e),label:t})):[]].filter((e,t,n)=>n.findIndex(t=>t.value===e.value)===t),selected:String(F.rule.category_ids_blocklist||``).split(`,`).filter(Boolean),onChange:e=>I({...F,rule:{...F.rule,category_ids_blocklist:e.join(`,`)}}),onSearch:wt,searchPlaceholder:`Search categories...`})})]}),e.id===`payment_filter_enabled`&&(0,T.jsx)(`div`,{className:`space-y-4`,children:(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(y,{className:`text-[10px] font-semibold text-blue-500 uppercase tracking-widest pl-1`,children:`ALLOWED PAYMENT GATEWAYS`}),(0,T.jsxs)(`p`,{className:`text-[9px] text-gray-400 font-bold mb-2`,children:[`Selected: `,F.rule.payment_gateways||`All`]}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Object.entries(t.paymentGateways).map(([e,t])=>{let n=String(F.rule.payment_gateways||``).split(`,`).filter(Boolean),r=n.includes(e);return(0,T.jsx)(b,{variant:r?`default`:`outline`,onClick:()=>{let t=r?n.filter(t=>t!==e):[...n,e];I({...F,rule:{...F.rule,payment_gateways:t.join(`,`)}})},className:_(`cursor-pointer px-3 py-1 rounded-lg text-[10px] font-bold border-gray-100 `,r&&`bg-primary border-primary`),children:t},e)})})]})})]})]},e.id)})})]})]}),L===7&&(0,T.jsx)(`div`,{className:`space-y-6`,children:(0,T.jsxs)(`div`,{className:`p-6 rounded-md bg-background border flex flex-col items-center text-center space-y-6 relative overflow-hidden`,children:[(0,T.jsx)(`div`,{className:`w-12 h-12 bg-muted rounded-md flex items-center justify-center mb-2`,children:(0,T.jsx)(oe,{className:`w-6 h-6 text-muted-foreground`})}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(`h3`,{className:`text-lg font-semibold text-foreground`,children:Z(`activeRuleSimulator`,`Active Rule Simulator`)}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-xs text-balance`,children:Z(`testConfigLiveContext`,`Test your configuration across User & Admin copies using live site contexts (Orders/Users).`)})]}),(0,T.jsxs)(`div`,{className:`w-full max-w-sm space-y-4 pt-4`,children:[(0,T.jsx)(S,{options:t.wpAdmins.filter(e=>String(F.rule.admin_user_ids||``).split(`,`).includes(e.ID.toString())||e.ID===(t.wpAdmins[0]?.ID||``)).map(e=>({value:e.ID.toString(),label:`${e.display_name} (Admin)`})),value:U,onChange:Ze,placeholder:Z(`selectTargetStaffSimulation`,`Select target staff for simulation...`),className:`h-11 bg-white border-slate-200 text-slate-700 font-bold text-[13px] hover:border-[#004449]/30 transition-all rounded-[5px]`}),(0,T.jsx)(Fe,{onClick:At,disabled:Qe||!U,className:`w-full`,loading:Qe,children:Qe?Z(`deployingSimulation`,`Deploying Simulation...`):Z(`fireTestNotif`,`Fire Test Notification`)})]}),W&&(0,T.jsxs)(i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:_(`w-full p-6 rounded-md border flex flex-col items-center gap-3`,W.status===`success`?`bg-green-50 border-green-100 text-green-700`:`bg-red-50 border-red-100 text-red-700`),children:[W.status===`success`?(0,T.jsx)(ge,{className:`w-8 h-8`}):(0,T.jsx)(pe,{className:`w-8 h-8`}),(0,T.jsx)(`div`,{className:`text-sm font-black text-slate-700 underline underline-offset-4 decoration-2 decoration-primary/20`,children:W.message})]})]})})]},L)})]})}),(0,T.jsxs)(`div`,{className:`p-6 border-t bg-white flex items-center justify-between sticky bottom-0 z-20`,children:[(0,T.jsx)(`div`,{className:`flex gap-2`,children:(0,T.jsx)(v,{onClick:()=>L>1?R(L-1):B(!1),className:`rounded-md font-bold text-gray-400 hover:bg-slate-50 transition-all px-6 shadow-none`,icon:L>1?ae:void 0,children:L>1?Z(`back`,`Back`):Z(`discard`,`Discard`)})}),L<7?(0,T.jsxs)(De,{className:`bg-primary hover:bg-primary/90 shadow-primary/20`,onClick:()=>R(L+1),children:[Z(`continueToStep`,`Continue to Step`),` `,L+1]}):(0,T.jsxs)(De,{onClick:Ot,children:[(0,T.jsx)(c,{className:`w-4 h-4 me-2`}),` `,Z(`applyTransformation`,`Apply Transformation`)]})]})]})})]})}),t&&(0,T.jsx)(He,{open:st,onOpenChange:ct,onInsert:e=>Tt(lt.id,e,lt.field),placeholders:t.placeholders,triggerKey:F?.rule.trigger_key,isAdmin:lt.isAdmin}),(0,T.jsx)(Oe,{open:yt,onOpenChange:Y,children:(0,T.jsxs)(Ce,{className:`sm:max-w-[480px] p-6 rounded-2xl border-none shadow-2xl bg-white font-sans overflow-hidden`,children:[(0,T.jsx)(Ie,{className:`sr-only`,children:Z(`multilingualAutomations`,`Multilingual Automations`)}),(0,T.jsx)(Me,{className:`sr-only`,children:`Manage translations`}),(0,T.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-4`,children:[(0,T.jsx)(`div`,{className:`w-14 h-14 bg-gradient-to-tr from-[#004449]/10 to-emerald-500/10 border border-[#004449]/20 rounded-2xl flex items-center justify-center shadow-sm`,children:(0,T.jsx)(d,{className:`w-7 h-7 text-[#004449]`})}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(`h3`,{className:`text-xl font-bold text-slate-800 tracking-tight`,children:Z(`multilingualAutomations`,`Multilingual Automations`)}),(0,T.jsx)(`p`,{className:`text-sm text-slate-500 font-medium leading-relaxed max-w-sm`,children:Z(`multilingualAutomationsDesc`,`Deliver notification templates automatically in the customer's preferred language.`)})]}),q?(0,T.jsxs)(`div`,{className:`w-full space-y-4 pt-2`,children:[(0,T.jsxs)(`div`,{className:`p-4 bg-amber-500/5 border border-amber-200/50 rounded-xl flex items-start gap-3 text-left`,children:[(0,T.jsx)(f,{className:`w-5 h-5 text-amber-600 shrink-0 mt-0.5 animate-pulse`}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(`span`,{className:`text-xs font-bold text-amber-800 block`,children:`Pro Feature Required`}),(0,T.jsx)(`span`,{className:`text-xs text-amber-700/80 font-medium leading-relaxed block`,children:`Adding translation rules and multilingual templates is a premium feature.`})]})]}),(0,T.jsxs)(`a`,{href:`https://wawp.net/pricing`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center justify-center gap-2 w-full h-11 bg-amber-500 hover:bg-amber-600 text-white font-bold text-sm rounded-xl shadow-md transition-all duration-200`,style:{color:`#ffffff`},children:[(0,T.jsx)(f,{className:`w-4 h-4`}),` Upgrade to Pro Plan`]})]}):(0,T.jsxs)(`div`,{className:`w-full space-y-4 pt-2`,children:[(0,T.jsxs)(`div`,{className:`p-4 bg-slate-50 border border-slate-200/60 rounded-xl flex items-center justify-between gap-4 text-left`,children:[(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(`span`,{className:`text-sm font-bold text-slate-800 block`,children:Z(`activateMultilingualSupport`,`Activate Multilingual Support`)}),(0,T.jsx)(`span`,{className:`text-xs text-slate-500 font-medium leading-relaxed block`,children:Z(`activateMultilingualSupportDesc`,`Enable translations and localization across notifications.`)})]}),(0,T.jsx)(x,{checked:J,disabled:_t,onCheckedChange:St})]}),J&&(0,T.jsxs)(De,{className:`w-full h-11 bg-primary hover:bg-primary/90 text-white font-bold text-sm rounded-xl shadow-md transition-all duration-200`,onClick:()=>{Y(!1),V(!0)},children:[(0,T.jsx)(be,{className:`w-4 h-4 mr-2`}),` `,Z(`addTranslationLanguage`,`Add Translation Language`)]})]})]}),(0,T.jsx)(Le,{className:`mt-6`,children:(0,T.jsx)(g,{onClick:()=>Y(!1),children:Z(`errorClose`,`Close`)})})]})}),(0,T.jsx)(Ee,{saveStatus:j,hasUnsavedChanges:N,isSaving:j===`saving`,onSave:()=>X(D),docsUrl:`https://help.wawp.net/${$?`ar`:`en`}/articles/multi-language-notifications`,docsTitle:$?`الإشعارات متعددة اللغات`:`Notifications in Multiple Languages`})]})}export{N as default};