(()=>{"use strict";const e=window.wp.blocks,t=window.wp.i18n,o=JSON.parse('{"UU":"mine-cloudvod/user"}'),n=window.wp.components,l=window.wp.blockEditor,s=window.wp.element,r=window.ReactJSXRuntime,i=({update:e,add:o,remove:l,sortno:i,title:u,url:d})=>{const[c,a]=(0,s.useState)(i),[x,m]=(0,s.useState)(u),[p,w]=(0,s.useState)(d);return(0,r.jsxs)(n.Flex,{align:"center",direction:"column",children:[(0,r.jsxs)(n.Flex,{align:"center",children:[(0,r.jsx)(n.FlexItem,{children:(0,r.jsx)(n.TextControl,{style:{width:"40px"},placeholder:(0,t.__)("Sort No","mine-cloudvod"),value:c,onChange:e=>a(e),onBlur:()=>{let t=(e=>{let t=e+"";return t=t.replace(/[^\d]/g,""),t?(t=parseInt(t),t):"0"})(c);e({sortno:t}),a(t)},autoComplete:"off"})}),(0,r.jsx)(n.FlexBlock,{children:(0,r.jsx)(n.TextControl,{placeholder:(0,t.__)("Title","mine-cloudvod"),value:x,onChange:t=>{m(t),e({title:t})},autoComplete:"off"})})]}),(0,r.jsxs)(n.Flex,{align:"center",children:[(0,r.jsx)(n.FlexBlock,{children:(0,r.jsx)(n.TextControl,{placeholder:(0,t.__)("URL","mine-cloudvod"),value:p||"",onChange:t=>{w(t),e({url:t})},autoComplete:"off"})}),(0,r.jsxs)(n.FlexItem,{children:[l&&(0,r.jsx)(n.Button,{icon:"minus",style:{marginBottom:"8px"},label:(0,t.__)("Remove","mine-cloudvod"),onClick:l}),o&&(0,r.jsx)(n.Button,{icon:"plus-alt",label:wp.i18n.__("Add Menu","mine-cloudvod"),style:{marginBottom:"8px"},onClick:()=>{o(),a(""),m(""),w("")}})]})]})]})},u=({setAttributes:e,attributes:t})=>{const{submenus:o}=t;let[n,l]=(0,s.useState)({title:"",url:"",sortno:""});return(0,r.jsxs)("div",{children:[(o||[]).sort((function(e,t){return parseInt(e.sortno)-parseInt(t.sortno)})).map(((t,n)=>(0,r.jsx)(i,{sortno:t.sortno,title:t.title,url:t.url,update:n=>{((t,n={})=>{let l=o.indexOf(t),s=o.map(((e,t)=>t!==l?e:{...e,...n}));e({submenus:s})})(t,n)},remove:()=>{(t=>{let n=o.indexOf(t);e({submenus:o.filter(((e,t)=>t!==n))})})(t)}},`${n}-${t.sortno}`))),(0,r.jsx)(i,{sortno:n.sortno,title:n.title,url:n.url,update:e=>{l({...n,...e})},add:()=>{n.sortno&&n.title&&(e({submenus:[...o||[],{sortno:n.sortno,title:n.title}]}),l({title:"",sortno:""}))}})]})},d={edit:(0,n.withNotices)((({attributes:e,setAttributes:o})=>{const i=(0,s.useRef)(),d=(0,l.useBlockProps)({ref:i});return(0,r.jsxs)(s.Fragment,{children:[(0,r.jsx)(l.InspectorControls,{children:(0,r.jsx)(n.PanelBody,{title:wp.i18n.__("Add Submenu","mine-cloudvod"),children:(0,r.jsx)(u,{attributes:e,setAttributes:o})})}),(0,r.jsx)("figure",{...d,children:(0,r.jsx)("a",{children:(0,t.__)("Log out")})})]})})),save:function(){return null}};"site-editor"==window.pagenow&&(0,e.registerBlockType)(o.UU,d)})();