import{k as y,f as M,j as e,_ as c,s as k}from"./main.2.8.10.js";import{a9 as N,u as w}from"./Note.DalStCGz.js";import{u as A}from"./CopyIcn.BnhKHfEP.js";import{c as u,g as S}from"./ProUtilHelpers.CtRYkgop.js";import{a as g,b as I}from"./Integrations.BFhED4ck.js";import{m as $,g as P,a as V}from"./AsgarosForumCommonFunc.B8Ec_x02.js";import{T as q}from"./TagifyInput.C4ilRm4k.js";import{h as _,a as R,b as T,d as D}from"./GlobalIntegrationHelper.Belqr4OT.js";function L({i:l,formFields:i,field:s,asgarosForumConf:d,setAsgarosForumConf:p}){var h,m,n;const r=y(M),{isPro:b}=r,a=((h=d==null?void 0:d.asgarosForumFields)==null?void 0:h.filter(t=>t.required===!0))||[],x=((m=d==null?void 0:d.asgarosForumFields)==null?void 0:m.filter(t=>(t==null?void 0:t.required)===!1))||[];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:s.formField||"",onChange:t=>_(t,l,d,p),children:[e.jsx("option",{value:"",children:c("Select Field","bit-integrations")}),e.jsx("optgroup",{label:c("Form Fields","bit-integrations"),children:i==null?void 0:i.map(t=>e.jsx("option",{value:t.name,children:t.label},`ff-asgaros-${t.name}`))}),e.jsx("option",{value:"custom",children:c("Custom...","bit-integrations")}),e.jsx("optgroup",{label:k(c("General Smart Codes %s","bit-integrations"),b?"":`(${c("Pro","bit-integrations")})`),children:b&&((n=g)==null?void 0:n.map(t=>e.jsx("option",{value:t.name,children:t.label},`ff-asgaros-smart-${t.name}`)))})]}),s.formField==="custom"&&e.jsx(q,{onChange:t=>R(t,l,d,p),label:c("Custom Value","bit-integrations"),className:"mr-2",type:"text",value:s.customValue,placeholder:c("Custom Value","bit-integrations"),formFields:i}),e.jsxs("select",{className:"btcd-paper-inp",disabled:l<a.length,name:"asgarosForumField",value:l<a.length?a[l].key||"":s.asgarosForumField||"",onChange:t=>_(t,l,d,p),children:[e.jsx("option",{value:"",children:c("Select Field","bit-integrations")}),l<a.length?e.jsx("option",{value:a[l].key,children:a[l].label},a[l].key):x.map(({key:t,label:j})=>e.jsx("option",{value:t,children:j},t))]})]}),l>=a.length&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>T(l,d,p),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),e.jsx("button",{onClick:()=>D(l,d,p),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:l,asgarosForumConf:i,setAsgarosForumConf:s}){var b,a,x,h,m;const d=y(M),{isPro:p}=d,r=n=>{const t=V(n);s(j=>w(j,v=>{v.mainAction=n,v.asgarosForumFields=t,v.field_map=P(t)}))};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:c("Action:","bit-integrations")}),e.jsx(A,{title:"mainAction",defaultValue:(b=i==null?void 0:i.mainAction)!=null?b:null,className:"mt-2 w-5",onChange:n=>r(n),options:(a=$)==null?void 0:a.map(n=>({label:u(p,n.is_pro)?n.label:S(n.label),value:n.name,disabled:!u(p,n.is_pro)})),singleSelect:!0,closeOnSelect:!0})]}),!!((x=i==null?void 0:i.asgarosForumFields)!=null&&x.length)&&!!((h=i==null?void 0:i.field_map)!=null&&h.length)&&e.jsxs("div",{className:"mt-4",children:[e.jsx("b",{className:"wdt-100",children:c("Map Fields","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:c("Form Fields","bit-integrations")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:c("Asgaros Forum Fields","bit-integrations")})})]}),(m=i==null?void 0:i.field_map)==null?void 0:m.map((n,t)=>e.jsx(L,{i:t,field:n,asgarosForumConf:i,formFields:l,setAsgarosForumConf:s},`asgaros-forum-m-${t+1}`)),e.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:e.jsx("button",{onClick:()=>I(i.field_map.length,i,s),className:"icn-btn sh-sm",type:"button",children:"+"})})]}),["create_topic","post_reply_in_topic"].includes(i==null?void 0:i.mainAction)&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx(N,{note:c("Author ID is optional. If empty, the current logged-in user will be used.","bit-integrations")})]}),(i==null?void 0:i.mainAction)==="create_forum"&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx(N,{note:c("Use a valid parent/category ID. Otherwise, root forum will be created.","bit-integrations")})]})]})}export{K as A};
