From 5ea0365c3e3ac6262d7fd438e4f5b96ec7c6a129 Mon Sep 17 00:00:00 2001 From: Andrei Telteu Date: Tue, 15 Oct 2024 12:54:38 +0300 Subject: [PATCH] hotfix remove json --- resources/dist/customberg.mjs | 11 ++--------- resources/dist/customberg.umd.js | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/resources/dist/customberg.mjs b/resources/dist/customberg.mjs index 071a90c..ff3aba2 100644 --- a/resources/dist/customberg.mjs +++ b/resources/dist/customberg.mjs @@ -8667,20 +8667,13 @@ window.CustombergEditFields = (u) => jC((i, r) => { })) } )), /* @__PURE__ */ Z.createElement("div", { class: "customberg-fields" }, u.fields.map((d, f) => /* @__PURE__ */ Z.createElement("div", { key: d.name + f, style: { padding: 4 } }, this.renderField(d, this.props.attributes[d.name], (h) => { - console.log( - "onchange", - { - value: h, - mm: d.multilanguage, - activeLang: a - } - ), d.multilanguage ? this.props.setAttributes({ + d.multilanguage ? this.props.setAttributes({ [d.name]: { ...this.props.attributes[d.name], [a]: h } }) : this.props.setAttributes({ [d.name]: h }); - }), d.type != "repeatable" && d.hint ? /* @__PURE__ */ Z.createElement("div", { style: { marginBottom: ".5rem", marginTop: "-0.3rem", fontSize: "15px" } }, d.hint) : null, d.type != "repeatable" && d.hint_html ? /* @__PURE__ */ Z.createElement("div", { style: { marginBottom: ".5rem", marginTop: "-0.3rem", fontSize: "15px" }, dangerouslySetInnerHTML: { __html: d.hint_html } }) : null))), /* @__PURE__ */ Z.createElement("pre", null, JSON.stringify(this.props.attributes, null, 2)))); + }), d.type != "repeatable" && d.hint ? /* @__PURE__ */ Z.createElement("div", { style: { marginBottom: ".5rem", marginTop: "-0.3rem", fontSize: "15px" } }, d.hint) : null, d.type != "repeatable" && d.hint_html ? /* @__PURE__ */ Z.createElement("div", { style: { marginBottom: ".5rem", marginTop: "-0.3rem", fontSize: "15px" }, dangerouslySetInnerHTML: { __html: d.hint_html } }) : null))))); } renderField(r, s, a) { let { activeLang: l } = this.props.attributes; diff --git a/resources/dist/customberg.umd.js b/resources/dist/customberg.umd.js index f1ab699..29e39aa 100644 --- a/resources/dist/customberg.umd.js +++ b/resources/dist/customberg.umd.js @@ -63,4 +63,4 @@ __p += '`),ve&&(W+=`' + function print() { __p += __j.call(arguments, '') } `:`; `)+W+`return __p -}`;var ge=qc(function(){return ye(p,z+"return "+W).apply(r,b)});if(ge.source=W,Ea(ge))throw ge;return ge}function JI(e){return we(e).toLowerCase()}function UI(e){return we(e).toUpperCase()}function jI(e,t,n){if(e=we(e),e&&(n||t===r))return sl(e);if(!e||!(t=vt(t)))return e;var s=Ft(e),c=Ft(t),p=ll(s,c),b=cl(s,c)+1;return cn(s,p,b).join("")}function QI(e,t,n){if(e=we(e),e&&(n||t===r))return e.slice(0,dl(e)+1);if(!e||!(t=vt(t)))return e;var s=Ft(e),c=cl(s,Ft(t))+1;return cn(s,0,c).join("")}function $I(e,t,n){if(e=we(e),e&&(n||t===r))return e.replace(Eu,"");if(!e||!(t=vt(t)))return e;var s=Ft(e),c=ll(s,Ft(t));return cn(s,c).join("")}function KI(e,t){var n=Ue,s=$e;if(De(t)){var c="separator"in t?t.separator:c;n="length"in t?fe(t.length):n,s="omission"in t?vt(t.omission):s}e=we(e);var p=e.length;if(Wn(e)){var b=Ft(e);p=b.length}if(n>=p)return e;var I=n-Nn(s);if(I<1)return s;var A=b?cn(b,0,I).join(""):e.slice(0,I);if(c===r)return A+s;if(b&&(I+=A.length-I),wa(c)){if(e.slice(I).search(c)){var B,_=A;for(c.global||(c=Mu(c.source,we(Bs.exec(c))+"g")),c.lastIndex=0;B=c.exec(_);)var W=B.index;A=A.slice(0,W===r?I:W)}}else if(e.indexOf(vt(c),I)!=I){var Z=A.lastIndexOf(c);Z>-1&&(A=A.slice(0,Z))}return A+s}function qI(e){return e=we(e),e&&ch.test(e)?e.replace(Gs,Tm):e}var eC=Xn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Ta=ec("toUpperCase");function Kc(e,t,n){return e=we(e),t=n?r:t,t===r?xm(e)?_m(e):pm(e):e.match(t)||[]}var qc=pe(function(e,t){try{return mt(e,r,t)}catch(n){return Ea(n)?n:new le(n)}}),tC=$t(function(e,t){return xt(t,function(n){n=Xt(n),jt(e,n,Aa(e[n],e))}),e});function nC(e){var t=e==null?0:e.length,n=ee();return e=t?Pe(e,function(s){if(typeof s[1]!="function")throw new Et(d);return[n(s[0]),s[1]]}):[],pe(function(s){for(var c=-1;++cNe)return[];var n=P,s=nt(e,P);t=ee(t),e-=P;for(var c=Lu(s,t);++n0||t<0)?new be(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=fe(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},be.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},be.prototype.toArray=function(){return this.take(P)},Zt(be.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),s=/^(?:head|last)$/.test(t),c=g[s?"take"+(t=="last"?"Right":""):t],p=s||/^find/.test(t);!c||(g.prototype[t]=function(){var b=this.__wrapped__,I=s?[1]:arguments,A=b instanceof be,B=I[0],_=A||ce(b),W=function(he){var ve=c.apply(g,rn([he],I));return s&&Z?ve[0]:ve};_&&n&&typeof B=="function"&&B.length!=1&&(A=_=!1);var Z=this.__chain__,z=!!this.__actions__.length,ne=p&&!Z,ge=A&&!z;if(!p&&_){b=ge?b:new be(this);var re=e.apply(b,I);return re.__actions__.push({func:wi,args:[W],thisArg:r}),new wt(re,Z)}return ne&&ge?e.apply(this,I):(re=this.thru(W),ne?s?re.value()[0]:re.value():re)})}),xt(["pop","push","shift","sort","splice","unshift"],function(e){var t=Qr[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",s=/^(?:pop|shift)$/.test(e);g.prototype[e]=function(){var c=arguments;if(s&&!this.__chain__){var p=this.value();return t.apply(ce(p)?p:[],c)}return this[n](function(b){return t.apply(ce(b)?b:[],c)})}}),Zt(be.prototype,function(e,t){var n=g[t];if(n){var s=n.name+"";Se.call(Vn,s)||(Vn[s]=[]),Vn[s].push({name:t,func:n})}}),Vn[bi(r,O).name]=[{name:"wrapper",func:r}],be.prototype.clone=qm,be.prototype.reverse=eb,be.prototype.value=tb,g.prototype.at=Bv,g.prototype.chain=_v,g.prototype.commit=Fv,g.prototype.next=Ov,g.prototype.plant=Nv,g.prototype.reverse=Pv,g.prototype.toJSON=g.prototype.valueOf=g.prototype.value=Dv,g.prototype.first=g.prototype.head,ar&&(g.prototype[ar]=Wv),g},Pn=Fm();bn?((bn.exports=Pn)._=Pn,Bu._=Pn):Ke._=Pn}).call(zn)})(Yt,Yt.exports);const{Component:Up,useState:jp}=window.Laraberg.wordpress.element,{InnerBlocks:zC,RichText:Qp}=window.Laraberg.wordpress.blockEditor,{ColorPicker:$p,Popover:Kp,Button:qp,Dashicon:Xr,DropdownMenu:eh}=window.Laraberg.wordpress.components,{withSelect:th}=window.Laraberg.wordpress.data;window.CustombergEditFields=u=>th((i,r)=>{let o=i("core/block-editor").isBlockSelected(r.clientId),a=i("core/block-editor").hasSelectedInnerBlock(r.clientId,!0);return{isSelected:o,isInnerSelected:a}})(class extends Up{constructor(){var r,o;super(...arguments);Ht(this,"componentDidUpdate",r=>{const o=["isSelected","isInnerSelected"];let a=!1;o.forEach(l=>{this.props[l]!=r[l]&&(a=!0)}),a&&this.forceUpdate()});this.default_language=((r=window.CustombergConfig)==null?void 0:r.default_language)||"en",this.props.attributes.activeLang=this.default_language,this.languages={},Object.entries(((o=window.CustombergConfig)==null?void 0:o.languages)||{}).forEach(([a,l])=>{this.languages[a]={code:a,name:l}})}componentDidMount(){const{activeLang:r}=this.props.attributes;let o=Yt.exports.cloneDeep(this.props.attributes);Object.keys(o).map(a=>{let l=u.fields.find(d=>d.name==a);l&&l.multilanguage&&typeof o[l.name]=="string"&&(o[a]={[r]:o[a]}),l&&l.type=="repeatable"&&o[l.name]&&Object.keys(o[l.name]).map(d=>{let f=l.fields.find(h=>h.name==d);f&&f.multilanguage&&typeof o[l.name][d]=="string"&&(o[a][d]={[r]:o[a][d]})})}),this.props.setAttributes(o)}changeLang(r){this.props.setAttributes({activeLang:r.code})}render(){var l;const{isSelected:r,isInnerSelected:o}=this.props,{activeLang:a}=this.props.attributes;return M.default.createElement("div",{className:this.props.className},M.default.createElement("h3",{style:{paddingTop:10}},"Block: ",u.name),!r&&!o?M.default.createElement(hf,{block:u,attributes:this.props.attributes}):M.default.createElement(M.default.Fragment,null,u.multilanguage&&M.default.createElement("div",{style:mn.langButtonsContainer},M.default.createElement(eh,{icon:null,label:"",toggleProps:{variant:"primary",style:{borderRadius:6},children:M.default.createElement("b",null,(l=this.languages[a])==null?void 0:l.name)},controls:Object.values(this.languages).map(d=>({title:d.name,onClick:()=>this.changeLang(d)}))})),M.default.createElement("div",{class:"customberg-fields"},u.fields.map((d,f)=>M.default.createElement("div",{key:d.name+f,style:{padding:4}},this.renderField(d,this.props.attributes[d.name],h=>{console.log("onchange",{value:h,mm:d.multilanguage,activeLang:a}),d.multilanguage?this.props.setAttributes({[d.name]:{...this.props.attributes[d.name],[a]:h}}):this.props.setAttributes({[d.name]:h})}),d.type!="repeatable"&&d.hint?M.default.createElement("div",{style:{marginBottom:".5rem",marginTop:"-0.3rem",fontSize:"15px"}},d.hint):null,d.type!="repeatable"&&d.hint_html?M.default.createElement("div",{style:{marginBottom:".5rem",marginTop:"-0.3rem",fontSize:"15px"},dangerouslySetInnerHTML:{__html:d.hint_html}}):null))),M.default.createElement("pre",null,JSON.stringify(this.props.attributes,null,2))))}renderField(r,o,a){let{activeLang:l}=this.props.attributes;if(r.multilanguage&&(typeof o=="string"||!o)&&(o={[l]:o}),r.type=="text"||r.type=="number"||r.type=="email"||r.type=="url")return M.default.createElement("label",{style:{width:"100%"}},M.default.createElement("div",null,r.label),M.default.createElement("input",{type:r.type,value:r.multilanguage?o[l]:o,placeholder:r.placeholder||void 0,onChange:d=>a(d.target.value),style:{width:"100%",padding:"5px 10px",borderRadius:6,border:"1px solid #ccc"}}));if(r.type=="checkbox")return M.default.createElement("label",{style:{width:"100%"}},M.default.createElement("input",{type:"checkbox",checked:r.multilanguage?o[l]:o,onChange:d=>a(d.target.checked),style:{marginRight:"10px"}}),M.default.createElement("span",null,r.label));if(r.type=="textarea")return M.default.createElement("label",{style:{width:"100%"}},M.default.createElement("div",null,r.label),M.default.createElement("textarea",{value:r.multilanguage?o[l]:o,onChange:d=>a(d.target.value),placeholder:r.placeholder||void 0,style:{width:"100%",padding:"5px 10px",resize:"none",height:"6rem",borderRadius:6,border:"1px solid #ccc"}}));if(r.type=="upload_image"||r.type=="upload_file")return M.default.createElement("div",{style:{width:"100%",marginBottom:"0.5rem"}},M.default.createElement("label",{style:{marginBottom:0}},r.label),M.default.createElement(Zi,{type:r.type=="upload_image"?"image":"file",value:o,onChange:d=>a(d),self_path:r.self_path,block_slug:u.slug,allowed_types:r.allowed_types,multiple:!!(r.type=="upload_file"&&r.multiple)}));if(r.type=="select"){let d=Object.keys((r==null?void 0:r.options)||[]).map(m=>({value:m,label:r.options[m]}));typeof o>"u"&&r.default&&(o=r.default);let f=o?r.multiple?o.map(m=>d.find(v=>v.value==m)):d.find(m=>m.value==o):null;const h=(m,v)=>{a(m?r.multiple?m.map(y=>y.value):m.value:null)};return M.default.createElement("label",{style:{width:"100%"},class:"customberg-field-select"},M.default.createElement("div",null,r.label),M.default.createElement(Jp,{value:f,options:d,onChange:h,placeholder:r.placeholder||null,isClearable:!0,isMulti:!!r.multiple,isDisabled:!!r.disabled}))}if(r.type=="rich_text")return M.default.createElement("label",{style:{width:"100%"},className:"customberg-field-rich-text"},M.default.createElement("div",null,r.label),M.default.createElement("div",{className:"rich-text-component"},M.default.createElement(Qp,{tagName:"div",value:r.multilanguage?o[l]:o,onChange:d=>a(d),inlineToolbar:!0,multiline:!0})));if(r.type=="color")return M.default.createElement("div",{style:{width:"100%",marginBottom:"0.5rem"},className:"customberg-field-color"},M.default.createElement("label",{style:{marginBottom:0}},r.label),M.default.createElement(nh,{value:o,onChange:a}));if(r.type=="custom")return M.default.createElement("div",{style:{width:"100%",marginBottom:"0.5rem"},className:"customberg-field-custom"},M.default.createElement("label",{style:{marginBottom:0}},r.label),M.default.createElement(pf,{js:r.js,props:{field:r,value:o,onChange:a,activeLang:l}}));if(r.type=="repeatable"){o||(o=[]);const d=()=>{let E=Yt.exports.cloneDeep(o||[]);E.push({}),a(E)},f=(E,T,w)=>{let S=Yt.exports.cloneDeep(o||[]);E.multilanguage?((typeof S[T][E.name]=="string"||!S[T][E.name])&&(S[T][E.name]={ro:S[T][E.name]}),S[T][E.name][this.props.attributes.activeLang]=w):S[T][E.name]=w,a(S)},h=E=>{let T=Yt.exports.cloneDeep(o||[]);T.splice(E,1),a(T)},m=(E,T)=>{let w=Yt.exports.cloneDeep(o||[]);w.splice(T,0,w.splice(E,1)[0]),a(w)},v=E=>{let T=Yt.exports.cloneDeep(o[E]),w=Yt.exports.cloneDeep(o||[]);w.splice(E+1,0,T),a(w)};let y=!1;return r.maxItems&&o.length>=r.maxItems&&(y=!0),M.default.createElement("div",null,M.default.createElement("label",{style:{marginBottom:0}},r.label),r.hint?M.default.createElement("div",{style:{marginBottom:"4px",fontSize:"15px"}},r.hint):null,r.hint_html?M.default.createElement("div",{style:{marginBottom:"4px",fontSize:"15px"},dangerouslySetInnerHTML:{__html:r.hint_html}}):null,M.default.createElement("div",null,o.map((E,T)=>M.default.createElement("div",{key:r.name+T,style:mn.repeatableItem},M.default.createElement("div",{style:mn.repeatableActions},M.default.createElement("button",{type:"button",onClick:()=>h(T),style:mn.repeatableActionBtn},M.default.createElement(Xr,{icon:"trash"})),M.default.createElement("button",{type:"button",onClick:()=>m(T,T-1),style:mn.repeatableActionBtn},M.default.createElement(Xr,{icon:"arrow-up-alt"})),M.default.createElement("button",{type:"button",onClick:()=>m(T,T+1),style:mn.repeatableActionBtn},M.default.createElement(Xr,{icon:"arrow-down-alt"})),M.default.createElement("button",{type:"button",onClick:()=>v(T),style:mn.repeatableActionBtn},M.default.createElement(Xr,{icon:"admin-page"}))),r.fields.map((w,S)=>M.default.createElement("div",{key:w.name+S,style:{padding:4}},this.renderField(w,E[w.name],R=>{f(w,T,R)}),w.type!="repeatable"&&w.hint?M.default.createElement("div",{style:{marginBottom:".5rem",marginTop:"-0.3rem",fontSize:"15px"}},w.hint):null,w.type!="repeatable"&&w.hint_html?M.default.createElement("div",{style:{marginBottom:".5rem",marginTop:"-0.3rem",fontSize:"15px"},dangerouslySetInnerHTML:{__html:w.hint_html}}):null))))),M.default.createElement("div",null,M.default.createElement(qp,{variant:"primary",style:{borderRadius:6},onClick:()=>!y&&d(),disabled:y},"Add item")))}}});function nh({value:u,onChange:i}){const[r,o]=jp(!1),a=({rgb:l})=>`rgba(${l.r}, ${l.g}, ${l.b}, ${l.a})`;return M.default.createElement(M.default.Fragment,null,M.default.createElement("div",{onClick:l=>{l.preventDefault(),l.stopPropagation(),o(!0)},style:{display:"flex",flexDirection:"row",alignContent:"center",marginTop:4}},M.default.createElement("div",{style:{position:"relative"}},M.default.createElement("div",{className:"components-color-picker__swatch"},M.default.createElement("div",{className:"components-color-picker__active",style:{backgroundColor:u,width:20,height:20,borderRadius:"100%",position:"absolute",right:10,top:"50%",transform:"translate(0, -50%)"}}),M.default.createElement("div",{style:{position:"absolute",right:24,top:"100%"}},r&&M.default.createElement(Kp,{noArrow:!1,onClose:()=>o(!1)},M.default.createElement($p,{color:u,onChangeComplete:l=>i(l?a(l):null)})))),M.default.createElement("input",{type:"text",value:u,style:{width:180,padding:"5px 10px",borderRadius:6,border:"1px solid #ccc",...r?{borderColor:"rgb(0, 124, 186)",boxShadow:"0 0 0 0.5px #007cba"}:{}}}))))}const mn={repeatableItem:{border:"1px solid #ccc",borderRadius:6,padding:10,paddingLeft:40,marginBottom:10,position:"relative"},repeatableActions:{position:"absolute",left:5,top:"50%",transform:"translateY(-50%)",width:26,display:"flex",flexDirection:"column",gap:6},repeatableActionBtn:{webkitAppearance:"none",background:"rgba(0, 0, 0, 0.07)",border:"none",height:26,width:26,padding:0,borderRadius:"100%",fontFamily:"monospace",fontSize:12,verticalAlign:"middle",textAlign:"center"},langButtonsContainer:{position:"absolute",top:10,right:10}};window.CustombergUploadAction=async(u,i={})=>{const r=new FormData,o=document.querySelector("meta[name=csrf-token]").getAttribute("content");o&&r.append("_token",o);for(var a=0;a=p)return e;var I=n-Nn(s);if(I<1)return s;var A=b?cn(b,0,I).join(""):e.slice(0,I);if(c===r)return A+s;if(b&&(I+=A.length-I),wa(c)){if(e.slice(I).search(c)){var B,_=A;for(c.global||(c=Mu(c.source,we(Bs.exec(c))+"g")),c.lastIndex=0;B=c.exec(_);)var W=B.index;A=A.slice(0,W===r?I:W)}}else if(e.indexOf(vt(c),I)!=I){var Z=A.lastIndexOf(c);Z>-1&&(A=A.slice(0,Z))}return A+s}function qI(e){return e=we(e),e&&ch.test(e)?e.replace(Gs,Tm):e}var eC=Xn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Ta=ec("toUpperCase");function Kc(e,t,n){return e=we(e),t=n?r:t,t===r?xm(e)?_m(e):pm(e):e.match(t)||[]}var qc=pe(function(e,t){try{return mt(e,r,t)}catch(n){return Ea(n)?n:new le(n)}}),tC=$t(function(e,t){return xt(t,function(n){n=Xt(n),jt(e,n,Aa(e[n],e))}),e});function nC(e){var t=e==null?0:e.length,n=ee();return e=t?Pe(e,function(s){if(typeof s[1]!="function")throw new Et(d);return[n(s[0]),s[1]]}):[],pe(function(s){for(var c=-1;++cNe)return[];var n=P,s=nt(e,P);t=ee(t),e-=P;for(var c=Lu(s,t);++n0||t<0)?new be(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=fe(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},be.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},be.prototype.toArray=function(){return this.take(P)},Zt(be.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),s=/^(?:head|last)$/.test(t),c=g[s?"take"+(t=="last"?"Right":""):t],p=s||/^find/.test(t);!c||(g.prototype[t]=function(){var b=this.__wrapped__,I=s?[1]:arguments,A=b instanceof be,B=I[0],_=A||ce(b),W=function(he){var ve=c.apply(g,rn([he],I));return s&&Z?ve[0]:ve};_&&n&&typeof B=="function"&&B.length!=1&&(A=_=!1);var Z=this.__chain__,z=!!this.__actions__.length,ne=p&&!Z,ge=A&&!z;if(!p&&_){b=ge?b:new be(this);var re=e.apply(b,I);return re.__actions__.push({func:wi,args:[W],thisArg:r}),new wt(re,Z)}return ne&&ge?e.apply(this,I):(re=this.thru(W),ne?s?re.value()[0]:re.value():re)})}),xt(["pop","push","shift","sort","splice","unshift"],function(e){var t=Qr[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",s=/^(?:pop|shift)$/.test(e);g.prototype[e]=function(){var c=arguments;if(s&&!this.__chain__){var p=this.value();return t.apply(ce(p)?p:[],c)}return this[n](function(b){return t.apply(ce(b)?b:[],c)})}}),Zt(be.prototype,function(e,t){var n=g[t];if(n){var s=n.name+"";Se.call(Vn,s)||(Vn[s]=[]),Vn[s].push({name:t,func:n})}}),Vn[bi(r,O).name]=[{name:"wrapper",func:r}],be.prototype.clone=qm,be.prototype.reverse=eb,be.prototype.value=tb,g.prototype.at=Bv,g.prototype.chain=_v,g.prototype.commit=Fv,g.prototype.next=Ov,g.prototype.plant=Nv,g.prototype.reverse=Pv,g.prototype.toJSON=g.prototype.valueOf=g.prototype.value=Dv,g.prototype.first=g.prototype.head,ar&&(g.prototype[ar]=Wv),g},Pn=Fm();bn?((bn.exports=Pn)._=Pn,Bu._=Pn):Ke._=Pn}).call(zn)})(Yt,Yt.exports);const{Component:Up,useState:jp}=window.Laraberg.wordpress.element,{InnerBlocks:zC,RichText:Qp}=window.Laraberg.wordpress.blockEditor,{ColorPicker:$p,Popover:Kp,Button:qp,Dashicon:Xr,DropdownMenu:eh}=window.Laraberg.wordpress.components,{withSelect:th}=window.Laraberg.wordpress.data;window.CustombergEditFields=u=>th((i,r)=>{let o=i("core/block-editor").isBlockSelected(r.clientId),a=i("core/block-editor").hasSelectedInnerBlock(r.clientId,!0);return{isSelected:o,isInnerSelected:a}})(class extends Up{constructor(){var r,o;super(...arguments);Ht(this,"componentDidUpdate",r=>{const o=["isSelected","isInnerSelected"];let a=!1;o.forEach(l=>{this.props[l]!=r[l]&&(a=!0)}),a&&this.forceUpdate()});this.default_language=((r=window.CustombergConfig)==null?void 0:r.default_language)||"en",this.props.attributes.activeLang=this.default_language,this.languages={},Object.entries(((o=window.CustombergConfig)==null?void 0:o.languages)||{}).forEach(([a,l])=>{this.languages[a]={code:a,name:l}})}componentDidMount(){const{activeLang:r}=this.props.attributes;let o=Yt.exports.cloneDeep(this.props.attributes);Object.keys(o).map(a=>{let l=u.fields.find(d=>d.name==a);l&&l.multilanguage&&typeof o[l.name]=="string"&&(o[a]={[r]:o[a]}),l&&l.type=="repeatable"&&o[l.name]&&Object.keys(o[l.name]).map(d=>{let f=l.fields.find(h=>h.name==d);f&&f.multilanguage&&typeof o[l.name][d]=="string"&&(o[a][d]={[r]:o[a][d]})})}),this.props.setAttributes(o)}changeLang(r){this.props.setAttributes({activeLang:r.code})}render(){var l;const{isSelected:r,isInnerSelected:o}=this.props,{activeLang:a}=this.props.attributes;return M.default.createElement("div",{className:this.props.className},M.default.createElement("h3",{style:{paddingTop:10}},"Block: ",u.name),!r&&!o?M.default.createElement(hf,{block:u,attributes:this.props.attributes}):M.default.createElement(M.default.Fragment,null,u.multilanguage&&M.default.createElement("div",{style:mn.langButtonsContainer},M.default.createElement(eh,{icon:null,label:"",toggleProps:{variant:"primary",style:{borderRadius:6},children:M.default.createElement("b",null,(l=this.languages[a])==null?void 0:l.name)},controls:Object.values(this.languages).map(d=>({title:d.name,onClick:()=>this.changeLang(d)}))})),M.default.createElement("div",{class:"customberg-fields"},u.fields.map((d,f)=>M.default.createElement("div",{key:d.name+f,style:{padding:4}},this.renderField(d,this.props.attributes[d.name],h=>{d.multilanguage?this.props.setAttributes({[d.name]:{...this.props.attributes[d.name],[a]:h}}):this.props.setAttributes({[d.name]:h})}),d.type!="repeatable"&&d.hint?M.default.createElement("div",{style:{marginBottom:".5rem",marginTop:"-0.3rem",fontSize:"15px"}},d.hint):null,d.type!="repeatable"&&d.hint_html?M.default.createElement("div",{style:{marginBottom:".5rem",marginTop:"-0.3rem",fontSize:"15px"},dangerouslySetInnerHTML:{__html:d.hint_html}}):null)))))}renderField(r,o,a){let{activeLang:l}=this.props.attributes;if(r.multilanguage&&(typeof o=="string"||!o)&&(o={[l]:o}),r.type=="text"||r.type=="number"||r.type=="email"||r.type=="url")return M.default.createElement("label",{style:{width:"100%"}},M.default.createElement("div",null,r.label),M.default.createElement("input",{type:r.type,value:r.multilanguage?o[l]:o,placeholder:r.placeholder||void 0,onChange:d=>a(d.target.value),style:{width:"100%",padding:"5px 10px",borderRadius:6,border:"1px solid #ccc"}}));if(r.type=="checkbox")return M.default.createElement("label",{style:{width:"100%"}},M.default.createElement("input",{type:"checkbox",checked:r.multilanguage?o[l]:o,onChange:d=>a(d.target.checked),style:{marginRight:"10px"}}),M.default.createElement("span",null,r.label));if(r.type=="textarea")return M.default.createElement("label",{style:{width:"100%"}},M.default.createElement("div",null,r.label),M.default.createElement("textarea",{value:r.multilanguage?o[l]:o,onChange:d=>a(d.target.value),placeholder:r.placeholder||void 0,style:{width:"100%",padding:"5px 10px",resize:"none",height:"6rem",borderRadius:6,border:"1px solid #ccc"}}));if(r.type=="upload_image"||r.type=="upload_file")return M.default.createElement("div",{style:{width:"100%",marginBottom:"0.5rem"}},M.default.createElement("label",{style:{marginBottom:0}},r.label),M.default.createElement(Zi,{type:r.type=="upload_image"?"image":"file",value:o,onChange:d=>a(d),self_path:r.self_path,block_slug:u.slug,allowed_types:r.allowed_types,multiple:!!(r.type=="upload_file"&&r.multiple)}));if(r.type=="select"){let d=Object.keys((r==null?void 0:r.options)||[]).map(m=>({value:m,label:r.options[m]}));typeof o>"u"&&r.default&&(o=r.default);let f=o?r.multiple?o.map(m=>d.find(v=>v.value==m)):d.find(m=>m.value==o):null;const h=(m,v)=>{a(m?r.multiple?m.map(y=>y.value):m.value:null)};return M.default.createElement("label",{style:{width:"100%"},class:"customberg-field-select"},M.default.createElement("div",null,r.label),M.default.createElement(Jp,{value:f,options:d,onChange:h,placeholder:r.placeholder||null,isClearable:!0,isMulti:!!r.multiple,isDisabled:!!r.disabled}))}if(r.type=="rich_text")return M.default.createElement("label",{style:{width:"100%"},className:"customberg-field-rich-text"},M.default.createElement("div",null,r.label),M.default.createElement("div",{className:"rich-text-component"},M.default.createElement(Qp,{tagName:"div",value:r.multilanguage?o[l]:o,onChange:d=>a(d),inlineToolbar:!0,multiline:!0})));if(r.type=="color")return M.default.createElement("div",{style:{width:"100%",marginBottom:"0.5rem"},className:"customberg-field-color"},M.default.createElement("label",{style:{marginBottom:0}},r.label),M.default.createElement(nh,{value:o,onChange:a}));if(r.type=="custom")return M.default.createElement("div",{style:{width:"100%",marginBottom:"0.5rem"},className:"customberg-field-custom"},M.default.createElement("label",{style:{marginBottom:0}},r.label),M.default.createElement(pf,{js:r.js,props:{field:r,value:o,onChange:a,activeLang:l}}));if(r.type=="repeatable"){o||(o=[]);const d=()=>{let E=Yt.exports.cloneDeep(o||[]);E.push({}),a(E)},f=(E,T,w)=>{let S=Yt.exports.cloneDeep(o||[]);E.multilanguage?((typeof S[T][E.name]=="string"||!S[T][E.name])&&(S[T][E.name]={ro:S[T][E.name]}),S[T][E.name][this.props.attributes.activeLang]=w):S[T][E.name]=w,a(S)},h=E=>{let T=Yt.exports.cloneDeep(o||[]);T.splice(E,1),a(T)},m=(E,T)=>{let w=Yt.exports.cloneDeep(o||[]);w.splice(T,0,w.splice(E,1)[0]),a(w)},v=E=>{let T=Yt.exports.cloneDeep(o[E]),w=Yt.exports.cloneDeep(o||[]);w.splice(E+1,0,T),a(w)};let y=!1;return r.maxItems&&o.length>=r.maxItems&&(y=!0),M.default.createElement("div",null,M.default.createElement("label",{style:{marginBottom:0}},r.label),r.hint?M.default.createElement("div",{style:{marginBottom:"4px",fontSize:"15px"}},r.hint):null,r.hint_html?M.default.createElement("div",{style:{marginBottom:"4px",fontSize:"15px"},dangerouslySetInnerHTML:{__html:r.hint_html}}):null,M.default.createElement("div",null,o.map((E,T)=>M.default.createElement("div",{key:r.name+T,style:mn.repeatableItem},M.default.createElement("div",{style:mn.repeatableActions},M.default.createElement("button",{type:"button",onClick:()=>h(T),style:mn.repeatableActionBtn},M.default.createElement(Xr,{icon:"trash"})),M.default.createElement("button",{type:"button",onClick:()=>m(T,T-1),style:mn.repeatableActionBtn},M.default.createElement(Xr,{icon:"arrow-up-alt"})),M.default.createElement("button",{type:"button",onClick:()=>m(T,T+1),style:mn.repeatableActionBtn},M.default.createElement(Xr,{icon:"arrow-down-alt"})),M.default.createElement("button",{type:"button",onClick:()=>v(T),style:mn.repeatableActionBtn},M.default.createElement(Xr,{icon:"admin-page"}))),r.fields.map((w,S)=>M.default.createElement("div",{key:w.name+S,style:{padding:4}},this.renderField(w,E[w.name],R=>{f(w,T,R)}),w.type!="repeatable"&&w.hint?M.default.createElement("div",{style:{marginBottom:".5rem",marginTop:"-0.3rem",fontSize:"15px"}},w.hint):null,w.type!="repeatable"&&w.hint_html?M.default.createElement("div",{style:{marginBottom:".5rem",marginTop:"-0.3rem",fontSize:"15px"},dangerouslySetInnerHTML:{__html:w.hint_html}}):null))))),M.default.createElement("div",null,M.default.createElement(qp,{variant:"primary",style:{borderRadius:6},onClick:()=>!y&&d(),disabled:y},"Add item")))}}});function nh({value:u,onChange:i}){const[r,o]=jp(!1),a=({rgb:l})=>`rgba(${l.r}, ${l.g}, ${l.b}, ${l.a})`;return M.default.createElement(M.default.Fragment,null,M.default.createElement("div",{onClick:l=>{l.preventDefault(),l.stopPropagation(),o(!0)},style:{display:"flex",flexDirection:"row",alignContent:"center",marginTop:4}},M.default.createElement("div",{style:{position:"relative"}},M.default.createElement("div",{className:"components-color-picker__swatch"},M.default.createElement("div",{className:"components-color-picker__active",style:{backgroundColor:u,width:20,height:20,borderRadius:"100%",position:"absolute",right:10,top:"50%",transform:"translate(0, -50%)"}}),M.default.createElement("div",{style:{position:"absolute",right:24,top:"100%"}},r&&M.default.createElement(Kp,{noArrow:!1,onClose:()=>o(!1)},M.default.createElement($p,{color:u,onChangeComplete:l=>i(l?a(l):null)})))),M.default.createElement("input",{type:"text",value:u,style:{width:180,padding:"5px 10px",borderRadius:6,border:"1px solid #ccc",...r?{borderColor:"rgb(0, 124, 186)",boxShadow:"0 0 0 0.5px #007cba"}:{}}}))))}const mn={repeatableItem:{border:"1px solid #ccc",borderRadius:6,padding:10,paddingLeft:40,marginBottom:10,position:"relative"},repeatableActions:{position:"absolute",left:5,top:"50%",transform:"translateY(-50%)",width:26,display:"flex",flexDirection:"column",gap:6},repeatableActionBtn:{webkitAppearance:"none",background:"rgba(0, 0, 0, 0.07)",border:"none",height:26,width:26,padding:0,borderRadius:"100%",fontFamily:"monospace",fontSize:12,verticalAlign:"middle",textAlign:"center"},langButtonsContainer:{position:"absolute",top:10,right:10}};window.CustombergUploadAction=async(u,i={})=>{const r=new FormData,o=document.querySelector("meta[name=csrf-token]").getAttribute("content");o&&r.append("_token",o);for(var a=0;a