(()=>{"use strict";const e=JSON.parse('{"name":"jsf-grid-block/listing","title":"JSF Listing","category":"jet-smart-filters","icon":"layout","supports":{"html":false},"attributes":{"listing_id":{"type":"string","default":""},"_element_id":{"type":"string","default":""}},"render":"file:./render.php"}');function t(e,r){let s=Object.prototype.toString.call(e);if(s!==Object.prototype.toString.call(r))return!1;if(["[object Array]","[object Object]"].indexOf(s)<0)return!1;let n="[object Array]"===s?e.length:Object.keys(e).length;if(n!==("[object Array]"===s?r.length:Object.keys(r).length))return!1;let l=function(e,r){let s=Object.prototype.toString.call(e);if(["[object Array]","[object Object]"].indexOf(s)>=0){if(!t(e,r))return!1}else{if(s!==Object.prototype.toString.call(r))return!1;if("[object Function]"===s){if(e.toString()!==r.toString())return!1}else if(e!==r)return!1}};if("[object Array]"===s){for(let t=0;t<n;t++)if(!1===l(e[t],r[t]))return!1}else for(let t in e)if(e.hasOwnProperty(t)&&!1===l(e[t],r[t]))return!1;return!0}const r=window.ReactJSXRuntime,{__}=wp.i18n,{debounce:s}=lodash,{addQueryArgs:n}=wp.url,l=wp.apiFetch,{Component:i,RawHTML:o}=wp.element,{Placeholder:c,Spinner:d}=wp.components;class a extends i{constructor(e){super(e),this.state={response:null}}componentDidMount(){this.isStillMounted=!0,this.fetch(),this.fetch=s(this.fetch,500)}componentWillUnmount(){this.isStillMounted=!1}componentDidUpdate(e){this.shouldFetch(e,this.props)&&this.fetch()}shouldFetch(e,r){if(!e||!r)return!0;const s={...e.attributes||{}},n={...r.attributes||{}};return delete s.crocoblock_styles,delete n.crocoblock_styles,!t(s,n)}fetch(){if(!this.isStillMounted)return;null!==this.state.response&&this.setState({response:null});const e=this.rendererPath(),{onSuccess:t=()=>{},onError:r=()=>{}}=this.props,s=this.currentFetchRequest=l({path:e}).then(e=>{this.isStillMounted&&s===this.currentFetchRequest&&e&&(this.setState({response:e.rendered}),setTimeout(()=>{t(window.ReactDOM.findDOMNode(this))},100))}).catch(e=>{this.isStillMounted&&s===this.currentFetchRequest&&(this.setState({response:{error:!0,errorMsg:e.message}}),r())});return s}rendererPath(){const{block:e,attributes:t=null}=this.props;return n(`/wp/v2/block-renderer/${e}`,{context:"edit",...null!==t?{attributes:t}:{}})}EmptyResponsePlaceholder(){return(0,r.jsx)(c,{children:__("Block rendered as empty.")})}ErrorResponsePlaceholder(e){const t=sprintf(
// translators: %s: error message describing the problem
__("Error loading block: %s"),e.errorMsg);return(0,r.jsx)(c,{children:t})}LoadingResponsePlaceholder(){return(0,r.jsx)(c,{children:(0,r.jsx)(d,{})})}render(){const e=this.state.response,{EmptyResponsePlaceholder:t,ErrorResponsePlaceholder:s,LoadingResponsePlaceholder:n}=this;return""===e?(0,r.jsx)(t,{}):e?e.error?(0,r.jsx)(s,{response:e}):(0,r.jsx)(o,{children:e},"html"):(0,r.jsx)(n,{})}}const{InspectorControls:h,InspectorAdvancedControls:p}=wp.editor,{Fragment:u}=wp.element,{PanelBody:C,SelectControl:f,TextControl:j}=wp.components,g=JetSmartFilterListingBlockData.listings_options;g.unshift({label:"Select listing...",value:""});const{registerBlockType:x}=wp.blocks;x(e.name,{...e,icon:{src:(0,r.jsxs)("svg",{width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M16 17H4C2.89543 17 2 17.8954 2 19V31C2 32.1046 2.89543 33 4 33H16C17.1046 33 18 32.1046 18 31V19C18 17.8954 17.1046 17 16 17ZM4 15C1.79086 15 0 16.7909 0 19V31C0 33.2091 1.79086 35 4 35H16C18.2091 35 20 33.2091 20 31V19C20 16.7909 18.2091 15 16 15H4Z",fill:"#0F172A"}),(0,r.jsx)("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M38 17H26C24.8954 17 24 17.8954 24 19V31C24 32.1046 24.8954 33 26 33H38C39.1046 33 40 32.1046 40 31V19C40 17.8954 39.1046 17 38 17ZM26 15C23.7909 15 22 16.7909 22 19V31C22 33.2091 23.7909 35 26 35H38C40.2091 35 42 33.2091 42 31V19C42 16.7909 40.2091 15 38 15H26Z",fill:"#0F172A"}),(0,r.jsx)("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M60 17H48C46.8954 17 46 17.8954 46 19V31C46 32.1046 46.8954 33 48 33H60C61.1046 33 62 32.1046 62 31V19C62 17.8954 61.1046 17 60 17ZM48 15C45.7909 15 44 16.7909 44 19V31C44 33.2091 45.7909 35 48 35H60C62.2091 35 64 33.2091 64 31V19C64 16.7909 62.2091 15 60 15H48Z",fill:"#0F172A"}),(0,r.jsx)("path",{d:"M2 40C2 39.4477 2.44772 39 3 39H17C17.5523 39 18 39.4477 18 40C18 40.5523 17.5523 41 17 41H3C2.44772 41 2 40.5523 2 40Z",fill:"#0F172A"}),(0,r.jsx)("path",{d:"M2 44C2 43.4477 2.44772 43 3 43H17C17.5523 43 18 43.4477 18 44C18 44.5523 17.5523 45 17 45H3C2.44772 45 2 44.5523 2 44Z",fill:"#0F172A"}),(0,r.jsx)("path",{d:"M2 48C2 47.4477 2.44772 47 3 47H9C9.55228 47 10 47.4477 10 48C10 48.5523 9.55228 49 9 49H3C2.44772 49 2 48.5523 2 48Z",fill:"#0F172A"}),(0,r.jsx)("path",{d:"M24 40C24 39.4477 24.4477 39 25 39H39C39.5523 39 40 39.4477 40 40C40 40.5523 39.5523 41 39 41H25C24.4477 41 24 40.5523 24 40Z",fill:"#0F172A"}),(0,r.jsx)("path",{d:"M24 44C24 43.4477 24.4477 43 25 43H39C39.5523 43 40 43.4477 40 44C40 44.5523 39.5523 45 39 45H25C24.4477 45 24 44.5523 24 44Z",fill:"#0F172A"}),(0,r.jsx)("path",{d:"M24 48C24 47.4477 24.4477 47 25 47H31C31.5523 47 32 47.4477 32 48C32 48.5523 31.5523 49 31 49H25C24.4477 49 24 48.5523 24 48Z",fill:"#0F172A"}),(0,r.jsx)("path",{d:"M46 40C46 39.4477 46.4477 39 47 39H61C61.5523 39 62 39.4477 62 40C62 40.5523 61.5523 41 61 41H47C46.4477 41 46 40.5523 46 40Z",fill:"#0F172A"}),(0,r.jsx)("path",{d:"M46 44C46 43.4477 46.4477 43 47 43H61C61.5523 43 62 43.4477 62 44C62 44.5523 61.5523 45 61 45H47C46.4477 45 46 44.5523 46 44Z",fill:"#0F172A"}),(0,r.jsx)("path",{d:"M46 48C46 47.4477 46.4477 47 47 47H53C53.5523 47 54 47.4477 54 48C54 48.5523 53.5523 49 53 49H47C46.4477 49 46 48.5523 46 48Z",fill:"#0F172A"})]})},edit:function({attributes:e,setAttributes:t}){return(0,r.jsxs)(u,{children:[(0,r.jsx)(h,{children:(0,r.jsx)(C,{title:"General",children:(0,r.jsx)(f,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:"Listing",value:e.listing_id,options:g,onChange:e=>{t({listing_id:e})}})})},"inspector"),(0,r.jsx)(p,{children:(0,r.jsx)(j,{label:"CSS ID",value:e._element_id,onChange:e=>t({_element_id:e})})}),(0,r.jsx)(a,{block:"jsf-grid-block/listing",attributes:e})]})},save:function(){return null}})})();