(()=>{"use strict";var e={n:n=>{var l=n&&n.__esModule?()=>n.default:()=>n;return e.d(l,{a:l}),l},d:(n,l)=>{for(var a in l)e.o(l,a)&&!e.o(n,a)&&Object.defineProperty(n,a,{enumerable:!0,get:l[a]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)};const n=window.wp.blocks,l=window.wp.serverSideRender;var a=e.n(l);const o=window.wp.components,t=window.wp.blockEditor,r=window.wp.element,i=window.wp.hooks,s=window.wp.data;function c(e){var n="string";return"categories"==e?n="array":"number"==e?n="number":"checkbox"==e&&(n="boolean"),n}function u(e,n=[],l=""){for(var a=0;a<e.length;a+=1)n.push({label:l+e[a].name,value:e[a].id}),e[a].children.length>0&&u(e[a].children,n,l.trim()+"—");return n}const p=window.ReactJSXRuntime,d=JSON.parse('{"UU":"aiovg/videos"}');(0,n.registerBlockType)(d.UU,{attributes:function(){var e={};for(var n in aiovg_blocks.videos){var l=aiovg_blocks.videos[n].fields;for(var a in l)e[l[a].name]={type:c(l[a].type),default:l[a].value}}return e}(),edit:function({attributes:e,setAttributes:n}){const l=aiovg_blocks.videos,c=(0,s.useSelect)(e=>{const n=e("core").getEntityRecords("taxonomy","aiovg_categories",{per_page:-1});let l=[];if(n&&n.length>0){let e=function(e){for(var n,l={},a=[],o=0;o<e.length;o+=1)l[e[o].id]=o,e[o].children=[];for(o=0;o<e.length;o+=1)0==(n=e[o]).parent?a.push(n):l.hasOwnProperty(n.parent)&&e[l[n.parent]].children.push(n);return a}(n),a=u(e);l=[...l,...a]}return l}),d=(0,s.useSelect)(e=>{const n=e("core").getEntityRecords("taxonomy","aiovg_tags",{per_page:-1});let l=[];if(n)for(let e=0;e<n.length;e+=1)l.push({label:n[e].name,value:n[e].id});return l}),g=e=>l=>{n({[e]:l})},h=(0,r.useRef)();return(0,r.useEffect)(()=>{h.current?(0,i.applyFilters)("aiovg_block_init",e):h.current=!0}),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(t.InspectorControls,{children:Object.keys(l).map((a,r)=>{return s=a,(0,i.applyFilters)("aiovg_block_toggle_panels",!0,s,e)&&(0,p.jsx)(o.PanelBody,{title:l[a].title,initialOpen:0==r,className:"aiovg-block-panel",children:Object.keys(l[a].fields).map((r,s)=>((l,a)=>{if(!(n=>{let l=!0;return"show_more"!=n&&"more_label"!=n&&"more_link"!=n||(l=!1),(0,i.applyFilters)("aiovg_block_toggle_controls",l,n,e)})(l.name))return"";const r=l.placeholder?l.placeholder:"",s=l.description?l.description:"";switch(l.type){case"header":return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)("h3",{className:"aiovg-no-margin",children:l.label})},a);case"categories":return(0,p.jsx)(o.PanelRow,{className:"aiovg-block-multiselect",children:(0,p.jsx)(o.SelectControl,{multiple:!0,label:l.label,help:s,options:c,value:e[l.name],onChange:g(l.name),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})},a);case"tags":return(0,p.jsx)(o.PanelRow,{className:"aiovg-block-multiselect",children:(0,p.jsx)(o.SelectControl,{multiple:!0,label:l.label,help:s,options:d,value:e[l.name],onChange:g(l.name),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})},a);case"number":return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(o.RangeControl,{label:l.label,help:s,placeholder:r,value:e[l.name],min:l.min,max:l.max,onChange:g(l.name),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})},a);case"textarea":return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(o.TextareaControl,{label:l.label,help:s,placeholder:r,value:e[l.name],onChange:g(l.name),__nextHasNoMarginBottom:!0})},a);case"select":case"radio":let i=[];for(let e in l.options)i.push({label:l.options[e],value:e});return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(o.SelectControl,{label:l.label,help:s,options:i,value:e[l.name],onChange:g(l.name),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})},a);case"checkbox":return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(o.ToggleControl,{label:l.label,help:s,checked:e[l.name],onChange:(u=l.name,e=>{n({[u]:e})}),__nextHasNoMarginBottom:!0})},a);case"color":return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(t.PanelColorSettings,{title:l.label,colorSettings:[{label:aiovg_blocks.i18n.select_color,value:e[l.name],onChange:g(l.name)}]})},a);default:return(0,p.jsx)(o.PanelRow,{children:(0,p.jsx)(o.TextControl,{label:l.label,help:s,placeholder:r,value:e[l.name],onChange:g(l.name),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})},a)}var u})(l[a].fields[r],"aiovg-block-control-"+s))},"aiovg-block-panel-"+r);var s})}),(0,p.jsx)("div",{...(0,t.useBlockProps)(),children:(0,p.jsx)(o.Disabled,{children:(0,p.jsx)(a(),{block:"aiovg/videos",attributes:e})})})]})}})})();