var h=Object.defineProperty;var F=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var N=(t,i,l)=>i in t?h(t,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[i]=l,c=(t,i)=>{for(var l in i||(i={}))T.call(i,l)&&N(t,l,i[l]);if(F)for(var l of F(i))_.call(i,l)&&N(t,l,i[l]);return t};import{h as M,j as e,k,L as I}from"./main-406.js";import{k as S,_ as r,l as $,m as V}from"./bi.394.85.js";import{T as q}from"./bi.141.747.js";import{g as L}from"./bi.56.800.js";import{T as R}from"./bi.704.707.js";const P=(t,i,l)=>{const s=c({},i);s.field_map.splice(t,0,{}),l(c({},s))},E=(t,i,l)=>{const s=c({},i);s.field_map.length>1&&s.field_map.splice(t,1),l(c({},s))},y=(t,i,l,s)=>{const n=c({},l);n.field_map[i][t.target.name]=t.target.value,t.target.value==="custom"&&(n.field_map[i].customValue=""),s(c({},n))};function B({key:t,i,field:l,whatsAppConf:s,formFields:n,setWhatsAppConf:b,setSnackbar:u}){var j,v;if(((j=s==null?void 0:s.field_map)==null?void 0:j.length)===1&&l.whatsAppFormField===""){const a=c({},s),g=L(a);a.field_map=g,b(a)}const d=(s==null?void 0:s.whatsAppFields.filter(a=>a.required===!0))||[],x=(s==null?void 0:s.whatsAppFields.filter(a=>a.required===!1))||[],o=M(S),{isPro:m}=o;return e.jsx("div",{className:"flx mt-2 mb-2 btcbi-field-map",children:e.jsxs("div",{className:"pos-rel flx",children:[e.jsxs("div",{className:"flx integ-fld-wrp",children:[e.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:l.formField||"",onChange:a=>y(a,i,s,b),children:[e.jsx("option",{value:"",children:r("Select Field","bit-integrations")}),e.jsx("optgroup",{label:"Form Fields",children:n==null?void 0:n.map(a=>e.jsx("option",{value:a.name,children:a.label},`ff-rm-${a.name}`))}),e.jsx("option",{value:"custom",children:r("Custom...","bit-integrations")}),e.jsx("optgroup",{label:`General Smart Codes ${m?"":"(PRO)"}`,children:m&&((v=$)==null?void 0:v.map(a=>e.jsx("option",{value:a.name,children:a.label},`ff-rm-${a.name}`)))})]}),l.formField==="custom"&&e.jsx(R,{onChange:a=>V(a,i,s,b),label:r("Custom Value","bit-integrations"),className:"mr-2",type:"text",value:l.customValue,placeholder:r("Custom Value","bit-integrations"),formFields:n}),e.jsxs("select",{className:"btcd-paper-inp",disabled:i<d.length,name:"whatsAppFormField",value:i<d.length?d[i].key||"":l.whatsAppFormField||"",onChange:a=>y(a,i,s,b),children:[e.jsx("option",{value:"",children:r("Select Field","bit-integrations")}),i<d.length?e.jsx("option",{value:d[i].key,children:d[i].label},d[i].key):x.map(({key:a,label:g})=>e.jsx("option",{value:a,children:g},a))]})]}),i>=d.length&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>P(i,s,b),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),e.jsx("button",{onClick:()=>E(i,s,b),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:e.jsx("span",{className:"btcd-icn icn-trash-2"})})]})]})})}function K({formFields:t,handleInput:i,whatsAppConf:l,setWhatsAppConf:s,isLoading:n,setIsLoading:b,setSnackbar:u}){const{id:d}=k(),x=o=>{const m=c({},l);m.body=o,s(m)};return e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsxs("div",{className:"flx",children:[e.jsx("b",{className:"wdt-200 d-in-b",children:r("Message Type: ","bit-integrations")}),e.jsxs("select",{onChange:i,name:"messageTypeId",value:l.messageTypeId,className:"btcd-paper-inp w-5",children:[e.jsx("option",{value:"",children:r("Select Message Type","bit-integrations")}),l==null?void 0:l.messageType.map(({id:o,label:m})=>e.jsx("option",{value:o,children:m},o))]})]}),n&&e.jsx(I,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),e.jsx("br",{}),e.jsx("div",{className:"mt-5",children:e.jsx("b",{className:"wdt-100",children:r("Field Map","bit-integrations")})}),e.jsx("div",{className:"btcd-hr mt-1"}),e.jsxs("div",{className:"flx flx-around mt-2 mb-2 btcbi-field-map-label",children:[e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:r("Form Fields","bit-integrations")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:r("WhatsApp Fields","bit-integrations")})})]}),e.jsx("br",{}),l==null?void 0:l.field_map.map((o,m)=>e.jsx(B,{i:m,field:o,whatsAppConf:l,formFields:t,setWhatsAppConf:s,setSnackbar:u},`rp-m-${m+9}`)),(l==null?void 0:l.messageTypeId)==="2"&&e.jsxs("div",{children:[e.jsx("b",{className:"wdt-200 d-in-b mr-16 mb-4 mt-4",children:r("Messages: ","bit-integrations")}),e.jsx(q,{formFields:t,id:`telegram-message-${d}`,value:l.body,onChangeHandler:x,width:"100%",toolbarMnu:"bold italic underline strikethrough | link | code | addFormField | toggleCode"})]}),e.jsx("br",{}),e.jsx("br",{}),(l==null?void 0:l.messageTypeId)==="2"&&e.jsxs("div",{className:"flx mt-4",children:[e.jsx("b",{className:"wdt-200 d-in-b",children:r("Template Name: ","bit-integrations")}),e.jsx("textarea",{className:"w-5",onChange:i,name:"templateName",rows:"5",value:l.templateName})]})]})}export{K as W};
