(()=>{"use strict";var e={n:o=>{var l=o&&o.__esModule?()=>o.default:()=>o;return e.d(l,{a:l}),l},d:(o,l)=>{for(var t in l)e.o(l,t)&&!e.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:l[t]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o)};const o=window.wp.data,l=window.wp.components,t=window.wp.blockEditor,a=window.wp.serverSideRender;var n=e.n(a);const r=window.wp.blocks,i=window.wp.element,b=window.ReactJSXRuntime;(0,r.registerBlockType)("jb-block/jb-jobs-list",{edit:e=>{const a=(0,t.useBlockProps)(),{attributes:r,setAttributes:d}=e,{user_id:s,per_page:p,no_logo:c,hide_filled:_,hide_expired:j,hide_search:w,hide_location_search:u,hide_filters:g,hide_job_types:h,no_jobs_text:x="",no_job_search_text:y="",load_more_text:C="",orderby:v,order:m,type:f,category:S,filled_only:k}=r,T=(0,o.useSelect)(e=>e("core").getEntityRecords("root","user",{per_page:-1,_fields:["id","name","username"]}),[]),E=(0,o.useSelect)(e=>e("core").getEntityRecords("taxonomy","jb-job-type",{per_page:-1,_fields:["id","name"]}),[]),B=(0,o.useSelect)(e=>e("core").getEntityRecords("taxonomy","jb-job-category",{per_page:-1,_fields:["id","name"]}),[]),H=(0,i.useMemo)(()=>({users:[{label:"",value:""}].concat(T?T.map(({id:e,name:o})=>({label:o,value:e})):[]),types:E?E.map(({id:e,name:o})=>({label:o,value:e})):[],categories:B?B.map(({id:e,name:o})=>({label:o,value:e})):[]}),[T,E,B]),P=(0,i.useCallback)((e,o)=>{d({[e]:o})},[d]);return T&&E&&B?(0,b.jsxs)("div",{...a,children:[(0,b.jsx)(n(),{block:"jb-block/jb-jobs-list",attributes:r}),(0,b.jsx)(t.InspectorControls,{children:(0,b.jsxs)(l.PanelBody,{title:wp.i18n.__("Jobs list","jobboardwp"),children:[(0,b.jsx)(l.SelectControl,{label:wp.i18n.__("Select employer","jobboardwp"),value:s,options:[{label:wp.i18n.__("Select a User","jobboardwp"),value:""},...T?T.map(e=>({label:e.name||e.username,value:e.id})):[]],onChange:e=>P("user_id",e)}),(0,b.jsx)(l.TextControl,{label:wp.i18n.__("Per page","jobboardwp"),type:"number",min:1,value:p,onChange:e=>P("per_page",e||1)}),(0,b.jsx)(l.ToggleControl,{label:wp.i18n.__("Hide logo","jobboardwp"),checked:c,onChange:e=>P("no_logo",e)}),(0,b.jsx)(l.ToggleControl,{label:wp.i18n.__("Hide filled","jobboardwp"),checked:_,onChange:e=>P("hide_filled",e)}),(0,b.jsx)(l.ToggleControl,{label:wp.i18n.__("Hide expired","jobboardwp"),checked:j,onChange:e=>P("hide_expired",e)}),(0,b.jsx)(l.ToggleControl,{label:wp.i18n.__("Hide search","jobboardwp"),checked:w,onChange:e=>P("hide_search",e)}),(0,b.jsx)(l.ToggleControl,{label:wp.i18n.__("Hide location search","jobboardwp"),checked:u,onChange:e=>P("hide_location_search",e)}),(0,b.jsx)(l.ToggleControl,{label:wp.i18n.__("Hide filters","jobboardwp"),checked:g,onChange:e=>P("hide_filters",e)}),(0,b.jsx)(l.ToggleControl,{label:wp.i18n.__("Hide job types","jobboardwp"),checked:h,onChange:e=>P("hide_job_types",e)}),(0,b.jsx)(l.TextControl,{label:wp.i18n.__("No jobs text","jobboardwp"),value:x,onChange:e=>P("no_jobs_text",e)}),(0,b.jsx)(l.TextControl,{label:wp.i18n.__("No job search text","jobboardwp"),value:y,onChange:e=>P("no_job_search_text",e)}),(0,b.jsx)(l.TextControl,{label:wp.i18n.__("Load more text","jobboardwp"),value:C,onChange:e=>P("load_more_text",e)}),(0,b.jsx)(l.SelectControl,{label:wp.i18n.__("Select category","jobboardwp"),value:S,options:H.categories,multiple:!0,onChange:e=>P("category",e)}),(0,b.jsx)(l.SelectControl,{label:wp.i18n.__("Select type","jobboardwp"),value:f,options:H.types,multiple:!0,onChange:e=>P("type",e)}),(0,b.jsx)(l.SelectControl,{label:wp.i18n.__("Select order by","jobboardwp"),value:v,options:[{label:wp.i18n.__("Date","jobboardwp"),value:"date"},{label:wp.i18n.__("Title","jobboardwp"),value:"title"}],onChange:e=>P("orderby",e)}),(0,b.jsx)(l.SelectControl,{label:wp.i18n.__("Select order","jobboardwp"),value:m,options:[{label:wp.i18n.__("Ascending","jobboardwp"),value:"ASC"},{label:wp.i18n.__("Descending","jobboardwp"),value:"DESC"}],onChange:e=>P("order",e)}),(0,b.jsx)(l.ToggleControl,{label:wp.i18n.__("Filled only","jobboardwp"),checked:k,onChange:e=>P("filled_only",e)})]})})]}):(0,b.jsxs)("p",{children:[(0,b.jsx)(l.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").each(function(){wp.JB.jobs_list.objects.wrapper=jQuery(".jb-jobs"),wp.JB.jobs_list.objects.wrapper.length&&wp.JB.jobs_list.objects.wrapper.each(function(){wp.JB.jobs_list.ajax(jQuery(this))});const e=document.querySelector(".jb-jobs");e&&e.addEventListener("click",o=>{o.target!==e&&(o.preventDefault(),o.stopPropagation())})}),jQuery(e.addedNodes).find(".jb").each(function(){jb_responsive();const e=document.querySelector(".jb-jobs");e&&e.addEventListener("click",o=>{o.target!==e&&(o.preventDefault(),o.stopPropagation())})})})}).observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0})})})();