(()=>{"use strict";var e={n:l=>{var t=l&&l.__esModule?()=>l.default:()=>l;return e.d(t,{a:t}),t},d:(l,t)=>{for(var s in t)e.o(t,s)&&!e.o(l,s)&&Object.defineProperty(l,s,{enumerable:!0,get:t[s]})},o:(e,l)=>Object.prototype.hasOwnProperty.call(e,l)};const l=window.wp.element,t=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-syllabus","title":"Course Syllabus","category":"llms-blocks","description":"Display the Course Syllabus for a specific 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,d=["course","lesson","llms_quiz"],p=function(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"name";const t=null==e?void 0:e.replace("llms_",""),s=t.charAt(0).toUpperCase()+t.slice(1);return"name"===l?t:s},m=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"course";const{posts:l,currentPostType:t}=(0,u.useSelect)((l=>{var t;return{posts:l("core").getEntityRecords("postType",e),currentPostType:null===(t=l("core/editor"))||void 0===t?void 0:t.getCurrentPostType()}}),[]),s=(p(e),[]);return d.includes(t)||s.push({label:(0,o.__)("Select course","lifterlms"),value:0}),null!=l&&l.length&&l.forEach((e=>{s.push({label:e.title.rendered+" (ID: "+e.id+")",value:e.id})})),d.includes(t)&&s.unshift({label:(0,o.sprintf)(
// Translators: %s = Post type name.
(0,o.__)("Inherit from current %s","lifterlms"),p(t)),value:0}),null!=s&&s.length||s.push({label:(0,o.__)("Loading","lifterlms"),value:0}),s},v=e=>{var t,r;let{attributes:n,setAttributes:i,postType:c="course",attribute:a="course_id"}=e;const u=m(c),d=p(c),v=p(c,"title"),b=(0,o.sprintf)(
// Translators: %s = Post type name.
(0,o.__)("Select the %s to associate with this block.","lifterlms"),d);return(0,l.createElement)(s.PanelRow,null,(0,l.createElement)(s.SelectControl,{label:v,help:b,value:null!==(t=null==n?void 0:n[a])&&void 0!==t?t:null==u||null===(r=u[0])||void 0===r?void 0:r.value,options:u,onChange:e=>{i({[a]:parseInt(e,10)})}}))};(0,t.registerBlockType)(c,{icon:()=>(0,l.createElement)(a.SVG,{className:"llms-block-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},(0,l.createElement)(a.Path,{d:"M152.1 38.2c9.9 8.9 10.7 24 1.8 33.9l-72 80c-4.4 4.9-10.6 7.8-17.2 7.9s-12.9-2.4-17.6-7L7 113C-2.3 103.6-2.3 88.4 7 79s24.6-9.4 33.9 0l22.1 22.1 55.1-61.2c8.9-9.9 24-10.7 33.9-1.8zm0 160c9.9 8.9 10.7 24 1.8 33.9l-72 80c-4.4 4.9-10.6 7.8-17.2 7.9s-12.9-2.4-17.6-7L7 273c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l22.1 22.1 55.1-61.2c8.9-9.9 24-10.7 33.9-1.8zM224 96c0-17.7 14.3-32 32-32H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H256c-17.7 0-32-14.3-32-32zm0 160c0-17.7 14.3-32 32-32H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H256c-17.7 0-32-14.3-32-32zM160 416c0-17.7 14.3-32 32-32H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H192c-17.7 0-32-14.3-32-32zM48 368a48 48 0 1 1 0 96 48 48 0 1 1 0-96z"})),edit:e=>{const{attributes:t,setAttributes:n}=e,a=(0,r.useBlockProps)(),p=(()=>{const e=(0,u.useSelect)((e=>{var l;return null===(l=e("core/editor"))||void 0===l?void 0:l.getCurrentPostType()}),[]);return d.includes(e)})(),b=m(),w=(0,l.useMemo)((()=>{var e,r;return(0,l.createElement)(i(),{block:c.name,attributes:{course_id:null!==(e=t.course_id)&&void 0!==e?e:null==b||null===(r=b[0])||void 0===r?void 0:r.value},LoadingResponsePlaceholder:()=>(0,l.createElement)(s.Spinner,null),ErrorResponsePlaceholder:()=>(0,l.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,l.createElement)("p",{className:"llms-block-empty"},(0,o.__)("No syllabus found for this course. This block will not be displayed.","lifterlms"))})}),[t]);var h;return t.course_id||p||n({course_id:null==b||null===(h=b[0])||void 0===h?void 0:h.value}),(0,l.createElement)(l.Fragment,null,(0,l.createElement)(r.InspectorControls,null,(0,l.createElement)(s.PanelBody,{title:(0,o.__)("Course Syllabus Settings","lifterlms")},(0,l.createElement)(v,{attributes:t,setAttributes:n}))),(0,l.createElement)("div",a,(0,l.createElement)(s.Disabled,null,w)))}})})();