import{a as S,g as C,i as H,aH as B,ap as M,aX as L,r as T,H as P,j as e,_ as m,h as n,M as U,f as g,bG as b,ba as k,m as _}from"./main-634.js";import{F as p}from"./bf-767-388.js";import{A as $}from"./bf-710-385.js";import{F as z,I as D}from"./bf-457-387.js";import{S as N}from"./bf-982-242.js";import{e as E}from"./bf-25-81.js";import"./bf-534-247.js";import"./bf-299-245.js";import"./bf-497-246.js";import"./bf-641-107.js";import"./bf-400-72.js";import"./bf-438-114.js";function te(){var f;const{css:s}=S(),{fieldKey:a}=C(),[c,h]=H(B),F=M(L),[y,u]=T.useState(!1);if(!a)return null;const t=P(c[a]),I=t.alt||"",w=d=>{const{value:l}=d.target;l===""?delete t.alt:t.alt=l.replace(/\\\\/g,"$_bf_$");const i=g(c,r=>{r[a]=t});h(i),b({event:`Field alt Change ${t.alt||a}`,type:"field_alt_change",state:{fields:i,fldKey:a}})},A=d=>{const{value:l}=d.target;l===""?delete t.bg_img:t.bg_img=l.replace(/\\\\/g,"$_bf_$");const i=g(c,r=>{r[a]=t});h(i),b({event:`Field Image Change ${t.bg_img||a}`,type:"field_img_change",state:{fields:i,fldKey:a}})},x=d=>{const{name:l,value:i}=d.target;t[l]=Number(i);const r=g(c,o=>{o[a]=t});h(r);const j=o=>`fields->${a}->classes->.${a}-fld-wrp->${o}`;b({event:`Field ${l} Change ${t.lbl||a}`,type:`field_${l}_change`,state:{fields:r,fldKey:a}}),k(),F(o=>g(o,v=>{_(v,j(l),`${Number(i)}px`),l==="height"&&_(v,j("max-height"),`${Number(i)}px`)}))};return e.jsxs(e.Fragment,{children:[e.jsxs(N,{id:"nam-stng",title:m("Background Image"),className:s(p.fieldSection),children:[e.jsx("div",{className:s(n.flxc,{jc:"end"}),children:e.jsx(E,{msg:"Change",children:e.jsx("button",{"data-testid":"img-edt-btn",type:"button",onClick:()=>u(!0),className:s(K.browseBtn),children:"Browse"})})}),e.jsx("div",{className:s({w:"97%",mx:5}),children:e.jsx($,{id:"fld-lbl-stng",ariaLabel:"Label input",changeAction:A,value:(f=t.bg_img)==null?void 0:f.replace(/\$_bf_\$/g,"\\"),placeholder:"e.g: https://ps.w.org/bit-form/assets/icon-256x256.png?rev=2376144"})}),e.jsxs("div",{className:s(n.flxcb,n.ml1),children:[e.jsx("label",{htmlFor:"alt",className:s(n.mr1),children:m("Width")}),e.jsx("input",{type:"number",name:"width","data-testid":"img-width","aria-label":"Image Width",placeholder:"auto",className:s(p.input,n.w4),value:t.width,onChange:x})]}),e.jsxs("div",{className:s(n.flxcb,n.ml1),children:[e.jsx("label",{htmlFor:"alt",className:s(n.mr1),children:m("Height")}),e.jsx("input",{type:"number",name:"height","data-testid":"img-height","aria-label":"Image Height",placeholder:"auto",className:s(p.input,n.w4),value:t.height,onChange:x})]})]}),e.jsx(z,{}),e.jsx(N,{id:"nam-stng",title:m("Image Alt Text"),className:s(p.fieldSection),children:e.jsx("div",{children:e.jsx("div",{className:s({w:"97%",mx:5}),children:e.jsx($,{id:"fld-lbl-stng",ariaLabel:"Label input",changeAction:w,value:I.replace(/\$_bf_\$/g,"\\"),placeholder:"Alternative Text"})})})}),e.jsxs(U,{md:!0,autoHeight:!0,show:y,setModal:u,className:"o-v",title:"Image",children:[e.jsx("div",{className:"pos-rel"}),e.jsx(D,{iconType:"bg_img",selected:"Upload Image",uploadLbl:"Upload Image",setModal:u,unsplash:!0})]})]})}const K={browseBtn:{b:"none",bd:"none",p:"5px 10px",tn:"all ease-in-out 0.2s","&:hover":{bd:"var(--b-79-96)",cr:"var(--b-50)",brs:"8px"}}};export{te as default};
