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