(()=>{"use strict";const e=window.wp.element,t=JSON.parse('{"u2":"mondiad/advertising"}'),n=window.React;function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},a.apply(this,arguments)}var l=function(e){return n.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",width:"1em",height:"1em",viewBox:"100 -100 666 666"},e),n.createElement("path",{d:"M3748.88 1053.41v2043.74l-895.12-1224.63h-104.34L1853.53 3067.4l-19.26 26.46v-624.48h-529.82v1395.25h606.09l878.99-1208.54 879.06 1208.54h610.12V1053.41h-529.83",style:{fill:"#3079c8",fillOpacity:1,fillRule:"evenodd",stroke:"none"},transform:"matrix(.17333 0 0 -.17333 0 666.667)"}),n.createElement("path",{d:"M1834.26 2250.69V1053.41h-529.81v666.42H639.352v530.86H1834.26",style:{fill:"#51c85d",fillOpacity:1,fillRule:"evenodd",stroke:"none"},transform:"matrix(.17333 0 0 -.17333 0 666.667)"}))};jQuery(document).ready((()=>{const{registerBlockType:n}=wp.blocks,{InspectorControls:a}=wp.blockEditor,{PanelBody:i,PanelRow:r,SelectControl:d,ButtonGroup:u,Button:o}=wp.components;n(t.u2,{icon:{background:"#ffffff",foreground:"#ffffff",src:l},attributes:{blockImage:{type:"string",default:"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiIHhtbDpzcGFjZT0icHJlc2VydmUiIHdpZHRoPSIxZW0iIGhlaWdodD0iMWVtIiB2aWV3Qm94PSIxMDAgLTEwMCA2NjYgNjY2Ij4KICA8ZyB0cmFuc2Zvcm09Im1hdHJpeCgxLjMzMzMzMzMsMCwwLC0xLjMzMzMzMzMsMCw2NjYuNjY2NjcpIj4KICAgIDxnIHRyYW5zZm9ybT0ic2NhbGUoMC4xMykiPgogICAgICA8cGF0aCBkPSJNIDM3NDguODgsMTA1My40MSBWIDMwOTcuMTUgTCAyODUzLjc2LDE4NzIuNTIgaCAtMTA0LjM0IGwgLTg5NS44OSwxMTk0Ljg4IC0xOS4yNiwyNi40NiB2IC02MjQuNDggaCAtNTI5LjgyIHYgMTM1Mi45NCA0Mi4zMSBoIDYwNi4wOSBsIDg3OC45OSwtMTIwOC41NCA4NzkuMDYsMTIwOC41NCBoIDYxMC4xMiBWIDEwNTMuNDEgaCAtNTI5LjgzIiBzdHlsZT0iZmlsbDojMzA3OWM4O2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpldmVub2RkO3N0cm9rZTpub25lIiAvPgogICAgICA8cGF0aCBkPSJNIDE4MzQuMjYsMjI1MC42OSBWIDEwNTMuNDEgaCAtNTI5LjgxIHYgNjY2LjQyIEggNjM5LjM1MiB2IDUzMC44NiBoIDQxMi44OTggMTU0LjM5IDYyNy42MiIgc3R5bGU9ImZpbGw6IzUxYzg1ZDtmaWxsLW9wYWNpdHk6MTtmaWxsLXJ1bGU6ZXZlbm9kZDtzdHJva2U6bm9uZSIgLz4KICAgIDwvZz4KICA8L2c+Cjwvc3ZnPgo="},uuid:{type:"string",default:""},type:{type:"string",default:"native"}},edit:t=>{const{attributes:n,setAttributes:l}=t,c=MONDIAD_PHP_VAR.nativeAds&&MONDIAD_PHP_VAR.nativeAds.length>0,s=MONDIAD_PHP_VAR.bannerAds&&MONDIAD_PHP_VAR.bannerAds.length>0,I=("native"===n.type&&c?"native":"banner"===n.type&&s&&"banner")||c&&"native"||s&&"banner"||null;null!==I&&n.type!==I&&l({...n,type:I});const M="No ads available. Please add at least one native or banner Ad Zone";let g=(0,e.createElement)(u,null,(0,e.createElement)(o,{variant:"native"===I?"primary":"secondary",disabled:!c,onClick:()=>l({...n,type:"native"})},"Native"),(0,e.createElement)(o,{variant:"banner"===I?"primary":"secondary",disabled:!s,onClick:()=>l({...n,type:"banner"})},"Banner"));null===I&&(g=(0,e.createElement)("div",null,M));const m=(MONDIAD_PHP_VAR.nativeAds||[]).map((e=>({value:e.adZoneUuidId,label:e.name}))).sort(((e,t)=>e.label.localeCompare(t.label))),b=(MONDIAD_PHP_VAR.bannerAds||[]).map((e=>({value:e.adZoneUuidId,label:e.name}))).sort(((e,t)=>e.label.localeCompare(t.label)));return n.uuid||null===I||("native"===I&&l({...n,uuid:m[0].value}),"banner"===I&&l({...n,uuid:b[0].value})),(0,e.createElement)("div",null,(0,e.createElement)(a,null,(0,e.createElement)(i,{title:"Mondiad settings",initialOpen:!0},(0,e.createElement)(r,null,g),"native"===I&&(0,e.createElement)(r,{key:"native"},(0,e.createElement)(d,{label:"Select native Ad",value:n.uuid,options:m,onChange:e=>l({...n,uuid:e})})),"banner"===I&&(0,e.createElement)(r,{key:"banner"},(0,e.createElement)(d,{label:"Select banner Ad",value:n.uuid,options:b,onChange:e=>l({...n,uuid:e})})))),null!==I&&n.uuid&&(0,e.createElement)("div",{style:{width:"200px",height:"100px",border:"1px dotted lightblue"}},"Mondiad ",I," ad will be here"),null!==I&&!n.uuid&&(0,e.createElement)("div",null,"Please select an ad"),null===I&&(0,e.createElement)("div",null,M))},save:t=>{const{attributes:n}=t,a=n.type||"native";return n.uuid?(0,e.createElement)("div",null,"[mondiad-",a,"-ad uuid='",n.uuid,"']"):""}})}))})();