(()=>{"use strict";var e={n:o=>{var t=o&&o.__esModule?()=>o.default:()=>o;return e.d(t,{a:t}),t},d:(o,t)=>{for(var n in t)e.o(t,n)&&!e.o(o,n)&&Object.defineProperty(o,n,{enumerable:!0,get:t[n]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o)};const o=window.wp.data,t=window.wp.components,n=window.wp.blockEditor,r=window.wp.serverSideRender;var a=e.n(r);const l=window.wp.blocks,i=window.wp.element,b=window.ReactJSXRuntime;(0,l.registerBlockType)("jb-block/jb-recent-jobs",{edit:e=>{const r=(0,n.useBlockProps)(),{attributes:l,setAttributes:d}=e,{number:s,no_logo:c,hide_filled:p,no_job_types:w,orderby:j,type:u,category:y,remote_only:_}=l,g=(0,o.useSelect)(e=>e("core").getEntityRecords("taxonomy","jb-job-type",{per_page:-1,_fields:["id","name"]}),[]),m=(0,o.useSelect)(e=>e("core").getEntityRecords("taxonomy","jb-job-category",{per_page:-1,_fields:["id","name"]}),[]),h=(0,i.useMemo)(()=>({types:g?g.map(({id:e,name:o})=>({label:o,value:e})):[],categories:m?m.map(({id:e,name:o})=>({label:o,value:e})):[]}),[g,m]),v=(0,i.useCallback)((e,o)=>d({[e]:o}),[d]);return g&&m?(0,b.jsxs)("div",{...r,children:[(0,b.jsx)(a(),{block:"jb-block/jb-recent-jobs",attributes:l}),(0,b.jsx)(n.InspectorControls,{children:(0,b.jsxs)(t.PanelBody,{title:wp.i18n.__("Recent jobs","jobboardwp"),children:[(0,b.jsx)(t.TextControl,{label:wp.i18n.__("Number","jobboardwp"),type:"number",min:1,value:s,onChange:e=>v("number",e||1)}),(0,b.jsx)(t.ToggleControl,{label:wp.i18n.__("Hide logo","jobboardwp"),checked:c,onChange:e=>v("no_logo",e)}),(0,b.jsx)(t.ToggleControl,{label:wp.i18n.__("Hide filled","jobboardwp"),checked:p,onChange:e=>v("hide_filled",e)}),(0,b.jsx)(t.ToggleControl,{label:wp.i18n.__("Hide job types","jobboardwp"),checked:w,onChange:e=>v("no_job_types",e)}),(0,b.jsx)(t.SelectControl,{label:wp.i18n.__("Select category","jobboardwp"),value:Array.isArray(y)?y:[],options:h.categories,multiple:!0,onChange:e=>v("category",Array.isArray(e)?e:[e])}),(0,b.jsx)(t.SelectControl,{label:wp.i18n.__("Select type","jobboardwp"),value:Array.isArray(u)?u:[],options:h.types,multiple:!0,onChange:e=>v("type",Array.isArray(e)?e:[e])}),(0,b.jsx)(t.SelectControl,{label:wp.i18n.__("Select order by","jobboardwp"),value:j,options:[{label:wp.i18n.__("Posting date","jobboardwp"),value:"date"},{label:wp.i18n.__("Expiry date","jobboardwp"),value:"expiry_date"}],onChange:e=>v("orderby",e)}),(0,b.jsx)(t.ToggleControl,{label:wp.i18n.__("Remote only","jobboardwp"),checked:_,onChange:e=>v("remote_only",e)})]})})]}):(0,b.jsxs)("p",{children:[(0,b.jsx)(t.Spinner,{}),wp.i18n.__("Loading...","jobboardwp")]})},save:()=>null}),jQuery(window).on("load",function(e){new MutationObserver(function(e){e.forEach(function(e){jQuery(e.addedNodes).find(".jb-jobs-widget").each(function(){const e=document.querySelector(".jb-jobs-widget");e&&e.addEventListener("click",o=>{o.target!==e&&(o.preventDefault(),o.stopPropagation())})})})}).observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0})})})();