(()=>{var e={184:(e,t)=>{var a;!function(){"use strict";var l={}.hasOwnProperty;function n(){for(var e=[],t=0;t<arguments.length;t++){var a=arguments[t];if(a){var o=typeof a;if("string"===o||"number"===o)e.push(a);else if(Array.isArray(a)){if(a.length){var r=n.apply(null,a);r&&e.push(r)}}else if("object"===o){if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]")){e.push(a.toString());continue}for(var c in a)l.call(a,c)&&a[c]&&e.push(c)}}}return e.join(" ")}e.exports?(n.default=n,e.exports=n):void 0===(a=function(){return n}.apply(t,[]))||(e.exports=a)}()}},t={};function a(l){var n=t[l];if(void 0!==n)return n.exports;var o=t[l]={exports:{}};return e[l](o,o.exports,a),o.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.wp.blocks,t=window.wp.element,l=window.wp.serverSideRender;var n=a.n(l),o=a(184),r=a.n(o);const c=window.wp.compose,i=window.wp.blockEditor,s=window.wp.components,p=window.wp.hooks,u=JSON.parse('{"u2":"automatic-youtube-gallery/block"}');(0,e.registerBlockType)(u.u2,{attributes:function(){var e,t,a={is_admin:{type:"boolean",default:!1},uid:{type:"string",default:""}};for(var l in ayg_block.options){var n=ayg_block.options[l].fields;for(var o in n)a[n[o].name]={type:(e=n[o].type,t=void 0,t="string","number"==e?t="number":"checkbox"==e&&(t="boolean"),t),default:n[o].value}}return a}(),edit:function(e){let{attributes:a,setAttributes:l,className:o,clientId:u}=e;a.uid=u;const[b,m]=(0,t.useState)(!1),[y,d]=(0,t.useState)(a),g=(0,t.useCallback)((()=>(0,t.createElement)(n(),{block:"automatic-youtube-gallery/block",attributes:Object.assign({},y,{is_admin:!0})})),[y]),k=(0,c.debounce)((()=>{m(!1),d({...a})}),1e3),v=e=>t=>{l({[e]:t})};(0,t.useEffect)((()=>{m(!0),k()}),[a]);const h=(0,t.useRef)();(0,t.useEffect)((()=>{h.current?(0,p.applyFilters)("ayg_block_init",a):h.current=!0}));const f=r()(o,{"is-loading":b}),_=(0,i.useBlockProps)({className:f});return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(i.InspectorControls,null,Object.keys(ayg_block.options).map(((e,n)=>(e=>{let t=!0;return"gallery"===e&&("video"!=a.type&&"livestream"!=a.type||(t=!1)),(0,p.applyFilters)("ayg_block_toggle_panels",t,e,a)})(e)&&(0,t.createElement)(s.PanelBody,{key:"automatic-youtube-gallery-block-panel-"+n,title:ayg_block.options[e].label,initialOpen:0==n,className:"automatic-youtube-gallery-block-panel"},Object.keys(ayg_block.options[e].fields).map(((n,o)=>((e,n)=>{if(!(e=>{let t=!0;switch(e){case"playlist":case"username":case"search":case"video":case"videos":e!=a.type&&(t=!1);break;case"channel":"channel"!=a.type&&"livestream"!=a.type&&(t=!1);break;case"order":case"limit":"search"!=a.type&&(t=!1);break;case"cache":case"player_title":case"player_description":case"loop":"livestream"==a.type&&(t=!1);break;case"autoadvance":"video"!=a.type&&"livestream"!=a.type||(t=!1);break;case"more_button_label":"pager"==a.pagination_type&&(t=!1);break;case"previous_button_label":case"next_button_label":"more"==a.pagination_type&&(t=!1);break;case"privacy_enhanced_mode":case"origin":t=!1}return(0,p.applyFilters)("ayg_block_toggle_controls",t,e,a)})(e.name))return"";const o=e.placeholder?e.placeholder:"",r=e.description?e.description:"";switch(e.type){case"number":return(0,t.createElement)(s.PanelRow,{key:n},(0,t.createElement)(s.RangeControl,{label:e.label,help:r,placeholder:o,value:a[e.name],min:e.min,max:e.max,onChange:v(e.name)}));case"textarea":return(0,t.createElement)(s.PanelRow,{key:n},(0,t.createElement)(s.TextareaControl,{label:e.label,help:r,placeholder:o,value:a[e.name],onChange:v(e.name)}));case"select":case"radio":let p=[];for(let t in e.options)p.push({label:e.options[t],value:t});return(0,t.createElement)(s.PanelRow,{key:n},(0,t.createElement)(s.SelectControl,{label:e.label,help:r,options:p,value:a[e.name],onChange:v(e.name)}));case"checkbox":return(0,t.createElement)(s.PanelRow,{key:n},(0,t.createElement)(s.ToggleControl,{label:e.label,help:r,checked:a[e.name],onChange:(c=e.name,e=>{l({[c]:e})})}));case"color":return(0,t.createElement)(s.PanelRow,{key:n},(0,t.createElement)(i.PanelColorSettings,{title:e.label,colorSettings:[{label:ayg_block.i18n.selected_color,value:a[e.name],onChange:v(e.name)}]}));default:return(0,t.createElement)(s.PanelRow,{key:n},(0,t.createElement)(s.TextControl,{label:e.label,help:r,placeholder:o,value:a[e.name],onChange:v(e.name)}))}var c})(ayg_block.options[e].fields[n],"automatic-youtube-gallery-block-control-"+o))))))),(0,t.createElement)("div",_,(0,t.createElement)(s.Disabled,null,(0,t.createElement)(g,null),b&&(0,t.createElement)("div",{className:"automatic-youtube-gallery-block-spinner"},(0,t.createElement)(s.Spinner,null),(0,t.createElement)("span",null,ayg_block.i18n.is_loading)))))}})})()})();