var M=Object.defineProperty;var j=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var b=(c,s,a)=>s in c?M(c,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):c[s]=a,p=(c,s)=>{for(var a in s||(s={}))k.call(s,a)&&b(c,a,s[a]);if(j)for(var a of j(s))F.call(s,a)&&b(c,a,s[a]);return c};import{r as L,j as t,T,_ as i,d as _,H as A,e as H,f as S}from"./main-634.js";import{j as N,d as f}from"./bf-25-81.js";import{C as w}from"./bf-297-103.js";import{a as v,r as V}from"./bf-389-175.js";function B({formFields:c,telegramConf:s,setTelegramConf:a}){var r,h;const[m,o]=L.useState({show:!1}),u=typeof((r=s.actions)==null?void 0:r.attachments)=="string"?s.actions.attachments.split(","):(h=s.actions)==null?void 0:h.attachments,x=d=>{const n=A(s);d!==""?n.actions.attachments=d?d.split(","):[]:delete n.actions.attachments,a(p({},n))};return t.jsxs("div",{className:"pos-rel",children:[t.jsx("div",{className:"d-flx flx-wrp",children:t.jsx(T,{onChange:()=>o({show:"attachments"}),checked:"attachments"in s.actions,className:"wdt-400 mt-4 mr-2",value:"Attachment",title:i("Attachments or Signature field"),subTitle:i("Add attachments or Signature field from BitForm to send Telegram.")})}),t.jsxs(_,{className:"custom-conf-mdl",mainMdlCls:"o-v",btnClass:"blue",btnTxt:"Ok",show:m.show==="attachments",close:()=>o({show:!1}),action:()=>o({show:!1}),title:i("Select Attachment"),children:[t.jsx("div",{className:"btcd-hr mt-2"}),t.jsx("div",{className:"mt-2",children:i("Please select file upload or signature field")}),t.jsx(N,{options:c.filter(d=>v.includes(d.type)).map(d=>({label:d.name,value:d.key})),className:"btcd-paper-drpdwn w-10",defaultValue:u,onChange:d=>x(d)})]})]})}function P({formFields:c,telegramConf:s,setTelegramConf:a,isLoading:m,setisLoading:o,setSnackbar:u}){var n;const x=c.filter(e=>!v.includes(e.type)),r=e=>{const l=p({},s);l[e.target.name]=e.target.value,a(l)},h=e=>{a(l=>S(l,y=>{y.body=e}))},d=e=>{const l=p({},s);l!=null&&l.body&&(l.body=""),l.parse_mode=e.target.value,a(l)};return t.jsxs(t.Fragment,{children:[t.jsx("br",{}),t.jsxs("div",{className:"flx",children:[t.jsx("b",{className:"wdt-150 d-in-b",children:i("Chat List:")}),t.jsxs("select",{onChange:r,name:"chat_id",value:s.chat_id,className:"btcd-paper-inp w-5",children:[t.jsx("option",{value:"",children:i("Select Chat List")}),((n=s==null?void 0:s.default)==null?void 0:n.telegramChatLists)&&Object.keys(s.default.telegramChatLists).map(e=>t.jsx("option",{value:s.default.telegramChatLists[e].id,children:s.default.telegramChatLists[e].name},e))]}),t.jsx("button",{onClick:()=>V(s,a,o,u),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${i("Refresh Telegram List")}'`},type:"button",disabled:m,children:"↻"})]}),m&&t.jsx(H,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),(s==null?void 0:s.chat_id)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flx mt-4",children:[t.jsx("b",{className:"wdt-150 d-in-b",children:i("Parse Mode:")}),t.jsx(w,{radio:!0,onChange:e=>d(e),name:"HTML",title:t.jsx("small",{className:"txt-dp",children:i("HTML")}),checked:s.parse_mode==="HTML",value:"HTML"}),t.jsx(w,{radio:!0,onChange:e=>d(e),name:"MarkdownV2",title:t.jsx("small",{className:"txt-dp",children:i("Markdown v2")}),checked:s.parse_mode==="MarkdownV2",value:"MarkdownV2"})]}),t.jsxs("div",{className:"flx mt-4",children:[t.jsx("b",{className:"wdt-150 d-in-b",children:i("Messages:")}),(s==null?void 0:s.parse_mode)==="HTML"?t.jsx(f,{formFields:x,value:s.body,onChangeHandler:h,width:"100%",toolbarMnu:"bold italic underline strikethrough | link | code | addFormField | addSmartField"}):t.jsxs(t.Fragment,{children:[t.jsx("textarea",{className:"w-7",onChange:r,name:"body",rows:"5",value:s.body}),t.jsx(N,{options:x.map(e=>({label:e.name,value:`\${${e.key}}`})),className:"btcd-paper-drpdwn wdt-200 ml-2",singleSelect:!0,onChange:e=>h(e)})]})]}),t.jsx("div",{className:"mt-4",children:t.jsx("b",{className:"wdt-100",children:i("Actions")})}),t.jsx("div",{className:"btcd-hr mt-1"}),t.jsx(B,{telegramConf:s,setTelegramConf:a,formFields:c})]})]})}export{P as T};
