(()=>{"use strict";const e=window.wp.blocks,t=window.wp.components,i=window.wp.blockEditor,r=window.wp.element,n=window.wp.i18n,o=window.wp.serverSideRender,s=JSON.parse('{"UU":"sabaiapps/drts-directory-recent-listings"}'),a=window.ReactJSXRuntime;(0,e.registerBlockType)(s.UU,{edit:function({attributes:e,setAttributes:c}){const[l,d]=(0,r.useState)(drts_wordpress_block_editor_vars_directory_recent_listings.directories||[]),[_,p]=(0,r.useState)(!1),u=drts_wordpress_block_editor_vars_directory_recent_listings.cache_options||[],w=e.directory&&""!==e.directory;return(0,r.useEffect)(()=>{d(e=>[{value:"",label:(0,n.__)("Select a directory","directories-pro")},...e]),p(!0)},[]),(0,r.useEffect)(()=>{_&&c({cacheLifetime:0})},[e.directory]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.InspectorControls,{children:(0,a.jsxs)(t.PanelBody,{title:(0,n.__)("Settings","directories-pro"),children:[(0,a.jsx)(t.SelectControl,{label:(0,n.__)("Directory","directories-pro"),value:e.directory,options:l,onChange:e=>c({directory:e})}),w&&u.length>0&&(0,a.jsx)(t.SelectControl,{label:(0,n.__)("Cache output","directories-pro"),value:e.cacheLifetime,options:u,onChange:e=>c({cacheLifetime:""!==e?parseInt(e,10):void 0})})]})}),(0,a.jsx)("div",{...(0,i.useBlockProps)(),children:w?(0,a.jsx)(t.Disabled,{children:(0,a.jsx)(o.ServerSideRender,{block:s.UU,attributes:e})}):(0,a.jsx)(t.SelectControl,{value:e.directory,options:l,onChange:e=>c({directory:e})})})]})}})})();