(()=>{"use strict";var e={n:t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},d:(t,l)=>{for(var s in l)e.o(l,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:l[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.element,l=window.wp.blocks,s=window.wp.components,r=window.wp.blockEditor,o=window.wp.i18n,n=window.wp.serverSideRender;var i=e.n(n);const c=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"llms/course-reviews","title":"Course Reviews","category":"llms-blocks","description":"Display reviews and review form for a LifterLMS Course.","textdomain":"lifterlms","attributes":{"course_id":{"type":"integer"},"llms_visibility":{"type":"string"},"llms_visibility_in":{"type":"string"},"llms_visibility_posts":{"type":"string"}},"supports":{"align":["wide","full"]},"editorScript":"file:./index.js"}'),a=window.wp.primitives,u=window.wp.data,p=["course","lesson","llms_quiz"],d=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"name";const l=null==e?void 0:e.replace("llms_",""),s=l.charAt(0).toUpperCase()+l.slice(1);return"name"===t?l:s},m=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"course";const{posts:t,currentPostType:l}=(0,u.useSelect)((t=>{var l;return{posts:t("core").getEntityRecords("postType",e),currentPostType:null===(l=t("core/editor"))||void 0===l?void 0:l.getCurrentPostType()}}),[]),s=(d(e),[]);return p.includes(l)||s.push({label:(0,o.__)("Select course","lifterlms"),value:0}),null!=t&&t.length&&t.forEach((e=>{s.push({label:e.title.rendered+" (ID: "+e.id+")",value:e.id})})),p.includes(l)&&s.unshift({label:(0,o.sprintf)(
// Translators: %s = Post type name.
(0,o.__)("Inherit from current %s","lifterlms"),d(l)),value:0}),null!=s&&s.length||s.push({label:(0,o.__)("Loading","lifterlms"),value:0}),s},w=e=>{var l,r;let{attributes:n,setAttributes:i,postType:c="course",attribute:a="course_id"}=e;const u=m(c),p=d(c),w=d(c,"title"),v=(0,o.sprintf)(
// Translators: %s = Post type name.
(0,o.__)("Select the %s to associate with this block.","lifterlms"),p);return(0,t.createElement)(s.PanelRow,null,(0,t.createElement)(s.SelectControl,{label:w,help:v,value:null!==(l=null==n?void 0:n[a])&&void 0!==l?l:null==u||null===(r=u[0])||void 0===r?void 0:r.value,options:u,onChange:e=>{i({[a]:parseInt(e,10)})}}))};(0,l.registerBlockType)(c,{icon:()=>(0,t.createElement)(a.SVG,{className:"llms-block-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512"},(0,t.createElement)(a.Path,{d:"M320 376.4l.1-.1 26.4 14.1 85.2 45.5-16.5-97.6-4.8-28.7 20.7-20.5 70.1-69.3-96.1-14.2-29.3-4.3-12.9-26.6L320.1 86.9l-.1 .3V376.4zm175.1 98.3c2 12-3 24.2-12.9 31.3s-23 8-33.8 2.3L320.1 439.8 191.8 508.3C181 514 167.9 513.1 158 506s-14.9-19.3-12.9-31.3L169.8 329 65.6 225.9c-8.6-8.5-11.7-21.2-7.9-32.7s13.7-19.9 25.7-21.7L227 150.3 291.4 18c5.4-11 16.5-18 28.8-18s23.4 7 28.8 18l64.3 132.3 143.6 21.2c12 1.8 22 10.2 25.7 21.7s.7 24.2-7.9 32.7L470.5 329l24.6 145.7z"})),edit:e=>{const{attributes:l}=e,n=(0,r.useBlockProps)(),a=m(),u=(0,t.useMemo)((()=>{let e=(0,o.__)("No reviews found for this course. This block will not be displayed.","lifterlms");return!l.course_id&&a.length>0&&(e=(0,o.__)("No course selected. Please choose a Course from the block sidebar panel.","lifterlms")),(0,t.createElement)(i(),{block:c.name,attributes:l,LoadingResponsePlaceholder:()=>(0,t.createElement)(s.Spinner,null),ErrorResponsePlaceholder:()=>(0,t.createElement)("p",{className:"llms-block-error"},(0,o.__)("Error loading content. Please check block settings are valid. This block will not be displayed.","lifterlms")),EmptyResponsePlaceholder:()=>(0,t.createElement)("p",{className:"llms-block-empty"},e)})}),[l]);return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(r.InspectorControls,null,(0,t.createElement)(s.PanelBody,{title:(0,o.__)("Course Reviews Settings","lifterlms")},(0,t.createElement)(w,e))),(0,t.createElement)("div",n,(0,t.createElement)(s.Disabled,null,u)))}})})();