|
1
|
|
-(()=>{"use strict";var e,t,n,o,a,i={114(e,t,n){n.d(t,{A:()=>a});const o=window.fcomEditorI18n||{};function a(e){return o[e]||e}},144(e,t,n){n.a(e,async(e,t)=>{try{var o=n(279),a=n(656),i=n(427),s=n(87),r=n(143),c=n(619),l=n(997),d=n(114),m=n(445),u=n(433),p=n(823),h=n(638),f=n(150),_=n(790);const w=parseInt(window.fcomEditorVars?.video_gate_default_threshold)||80,v=()=>{const[e,t]=(0,s.useState)(window.fcomMetaSettings||null);(0,s.useEffect)(()=>{const e=e=>{e.detail&&t({...e.detail})};return window.addEventListener("fcomMetaSettingsReady",e),()=>window.removeEventListener("fcomMetaSettingsReady",e)},[]);const[n,o]=(0,s.useState)(!!e&&"yes"===e.enable_media),r=(0,s.useRef)(e?e.enable_media:"no");(0,s.useEffect)(()=>{e&&e.enable_media!==r.current&&(r.current=e.enable_media,"yes"===e.enable_media&&o(!0))},[e]);const c=!(!e||"yes"!==e.enable_media||"fluent_player"!==e.media?.type),l=(e,n)=>{const o={...window.fcomMetaSettings,[e]:n};window.fcomMetaSettings=o,t({...o}),window.parent.postMessage({action:"META_UPDATED",content:o},"*")};return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(a.PluginPostStatusInfo,{children:e&&(0,_.jsxs)("div",{className:"fcom_feature_checkboxes",style:{width:"100%"},children:[(0,_.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Enable Video Embed"),checked:"yes"===e.enable_media,onChange:t=>{t||"fluent_player"!==e.media?.type||(0,f.dU)(),l("enable_media",t?"yes":"no")}}),(0,_.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Enable Comments"),checked:"yes"===e.enable_comments,onChange:e=>l("enable_comments",e?"yes":"no")}),(0,_.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Free Preview Lesson"),help:(0,d.A)("If enabled, public users can view this lesson without enrolling the course."),checked:"yes"===e.free_preview_lesson,onChange:e=>l("free_preview_lesson",e?"yes":"no")})]})}),(0,_.jsx)(a.PluginDocumentSettingPanel,{name:"fcom-media-embed",title:(0,d.A)("Media Embed"),className:e&&"yes"===e.enable_media?"":"fcom-panel-hidden",isOpen:n,onToggle:()=>o(!n),children:e&&"yes"===e.enable_media&&(0,_.jsx)(u.A,{media:e.media,videoLength:e.video_length,onUpdate:(e,t)=>l(e,t)})}),(0,_.jsx)(a.PluginDocumentSettingPanel,{name:"fcom-video-completion",title:(0,d.A)("Video Completion"),className:c?"":"fcom-panel-hidden",initialOpen:!1,children:c&&(0,_.jsxs)("div",{className:"fcom-video-gate",children:[(0,_.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Require video watch to complete"),help:(0,d.A)("Students must watch the video before they can mark this lesson as completed."),checked:"yes"===e.require_video_completion,onChange:e=>l("require_video_completion",e?"yes":"no")}),(0,_.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Auto-complete lesson when the video ends"),help:(0,d.A)("Marks the lesson complete a few seconds after the student watches the video to the end."),checked:"yes"===e.auto_complete_on_video_end,onChange:e=>l("auto_complete_on_video_end",e?"yes":"no")}),"yes"===e.require_video_completion&&(0,_.jsx)("div",{className:"fcom-video-gate__threshold",children:(0,_.jsx)(i.RangeControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Required watch percentage"),help:(0,d.A)("100% means the video must be watched to the end."),min:1,max:100,value:Math.min(100,Math.max(1,parseInt(e.video_completion_threshold)||w)),onChange:e=>l("video_completion_threshold",Math.min(100,Math.max(1,parseInt(e)||w)))})})]})}),(0,_.jsx)(a.PluginDocumentSettingPanel,{name:"fcom-documents",title:(0,d.A)("Documents & Files"),className:e?"":"fcom-panel-hidden",initialOpen:!1,children:e&&(0,_.jsx)(p.A,{})}),(0,_.jsx)(a.PluginDocumentSettingPanel,{name:"fcom-smartcodes",title:(0,d.A)("Smartcodes"),initialOpen:!1,children:(0,_.jsxs)("div",{className:"fcom_lesson_info_codes",children:[(0,_.jsx)("p",{children:(0,d.A)("You may use following smartcode in your lesson:")}),(0,_.jsxs)("ul",{children:[(0,_.jsxs)("li",{children:[(0,_.jsx)("b",{children:(0,d.A)("User's Name:")})," ",(0,_.jsx)("span",{children:"{{user.display_name|fallback}}"})]}),(0,_.jsxs)("li",{children:[(0,_.jsx)("b",{children:(0,d.A)("User's Email:")})," ",(0,_.jsx)("span",{children:"{{user.user_email|fallback}}"})]}),(0,_.jsxs)("li",{children:[(0,_.jsx)("b",{children:(0,d.A)("User's photo HTML:")})," ",(0,_.jsx)("span",{children:"{{user.photo_html.50px}}"})]}),(0,_.jsxs)("li",{children:[(0,_.jsx)("b",{children:(0,d.A)("User's Profile Link:")})," ",(0,_.jsx)("span",{children:"##user.profile_link##"})]})]})]})})]})};(0,o.registerPlugin)("fcom-document-settings",{render:v});let g=!1;const x=()=>(g||((0,r.select)("core/edit-post").isFeatureActive("welcomeGuide")&&(0,r.dispatch)("core/edit-post").toggleFeature("welcomeGuide"),(0,r.select)("core/edit-post").isFeatureActive("fullscreenMode")||(0,r.dispatch)("core/edit-post").toggleFeature("fullscreenMode"),"text"===(0,r.select)("core/edit-post").getEditorMode()&&(0,r.dispatch)("core/edit-post").switchEditorMode("visual"),(0,r.dispatch)("core/editor").lockPostSaving(),(0,r.dispatch)("core/editor").lockPostAutosaving(),g=!0),null);async function y(){await new Promise(e=>{const t=(0,r.subscribe)(()=>{((0,r.select)("core/editor").isCleanNewPost()||(0,r.select)("core/block-editor").getBlockCount()>0)&&(t(),e())})});const e=document.querySelector('[name="editor-canvas"]');return new Promise(t=>{e?e.loading?e.onload=()=>{t(e)}:t(e):t(null)})}(0,o.registerPlugin)("fluent-com-disable-gutenberg-features",{render:x}),(0,c.addFilter)("editor.DocumentBar","fluentcom-custom-document-bar",()=>null),(0,c.addFilter)("editor.BlockEdit","fluent_com/html_block_warning",h.A),(0,c.addFilter)("editor.Autocomplete.completers","fluent_com/add_autocmplete",function(e,t){return e=e.filter(e=>"users"!==e.name),[...e,m.A]}),window.addEventListener("beforeunload",function(e){e.stopImmediatePropagation()}),await y(),console.log("editor iframe is now ready");let b=!1,j=null,A=null;window.addEventListener("message",e=>{if("SYNC_META"===e.data?.type)return window.fcomMetaSettings=e.data.data,window.dispatchEvent(new CustomEvent("fcomMetaSettingsReady",{detail:e.data.data})),void window.dispatchEvent(new CustomEvent("fcomDocumentsUpdated"));if("UPDATE_EDITOR"!==e.data?.type)return;b=!1,A=null;const{content:t,title:n,featured_image_id:o,metaSettings:a}=e.data.data;console.log("UPDATE_EDITOR",a,e.data.data),a?(window.fcomMetaSettings=a,window.dispatchEvent(new CustomEvent("fcomMetaSettingsReady",{detail:a}))):window.fcomMetaSettings=null,t&&(0,r.dispatch)("core/block-editor").resetBlocks((0,l.parse)(t));let i=null;n&&(i={title:n}),o&&(i?i.featured_media=o:i={featured_media:o}),i&&(0,r.dispatch)("core/editor").editPost(i),clearTimeout(j),j=setTimeout(()=>{b=!0},1e3)});const M=()=>{const e=window.fcomMetaSettings;if(!e||"fluent_player"!==e.media?.type)return;if(!(0,f.VH)())return;if((0,f.G8)().length)return;const t={...e,media:{...u.U}};window.fcomMetaSettings=t,window.dispatchEvent(new CustomEvent("fcomMetaSettingsReady",{detail:t})),window.parent.postMessage({action:"META_UPDATED",content:t},"*")},k=()=>{const e=window.fcomMetaSettings;if(!e||"fluent_player"!==e.media?.type||!(0,f.VH)())return void(A=null);const t=(0,f._M)();null!==A?t!==A&&(A=t,t&&(0,f.fn)(t).then(({duration:e,image:n})=>{if(!e&&!n||!b||t!==A)return;const o=window.fcomMetaSettings;if(!o||"fluent_player"!==o.media?.type)return;const a={...o,media:{...o.media,image:n}};e&&(a.video_length=e),window.fcomMetaSettings=a,window.dispatchEvent(new CustomEvent("fcomMetaSettingsReady",{detail:a})),window.parent.postMessage({action:"META_UPDATED",content:a},"*")})):A=t};window._wpLoadBlockEditor.then(()=>{window.parent.postMessage({content:"ping",action:"EDITOR_READY"},"*");let e="",t="",n=null;(0,r.subscribe)(()=>{if(!b)return;M(),k();const o=(0,r.select)("core/editor").getEditedPostAttribute("title");o!=t&&(t=o,window.parent.postMessage({content:o,action:"TITLE_UPDATED"},"*"));const a=(0,r.select)("core/editor").getEditedPostAttribute("featured_media");n!=a&&(n=a,window.parent.postMessage({content:a,action:"FEATURED_MEDIA_UPDATED"},"*"));const i=(0,r.select)("core/block-editor").getBlocks(),s=(0,l.serialize)(i);e!=s&&(e=s,window.parent.postMessage({content:s,action:"EDITOR_UPDATED"},"*"))})}),t()}catch(E){t(E)}},1)},823(e,t,n){n.d(t,{A:()=>r});var o=n(427),a=n(87),i=n(114),s=n(790);const r=()=>{const[e,t]=(0,a.useState)(window.fcomMetaSettings&&Array.isArray(window.fcomMetaSettings.document_lists)?window.fcomMetaSettings.document_lists:[]);return(0,a.useEffect)(()=>{const e=e=>{e.detail&&Array.isArray(e.detail.document_lists)&&t([...e.detail.document_lists])};window.addEventListener("fcomMetaSettingsReady",e);const n=()=>{window.fcomMetaSettings&&Array.isArray(window.fcomMetaSettings.document_lists)&&t([...window.fcomMetaSettings.document_lists])};return window.addEventListener("fcomDocumentsUpdated",n),()=>{window.removeEventListener("fcomMetaSettingsReady",e),window.removeEventListener("fcomDocumentsUpdated",n)}},[]),(0,s.jsxs)("div",{className:"fcom-documents-panel",children:[e.length>0?(0,s.jsx)("ul",{className:"fcom-documents-list",children:e.map(e=>{return(0,s.jsxs)("li",{className:"fcom-document-item",children:[(0,s.jsx)("span",{className:"fcom-document-icon",children:(t=e.type,t?t.includes("pdf")?"📄":t.includes("image")?"🖼️":t.includes("video")?"🎥":t.includes("audio")?"🎵":t.includes("zip")||t.includes("rar")||t.includes("archive")?"🗜️":"📄":"📄")}),(0,s.jsx)("span",{className:"fcom-document-title",children:e.title}),e.url&&(0,s.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"fcom-document-view",title:(0,i.A)("View"),children:(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:(0,s.jsx)("path",{d:"M19.5 14.5v3c0 .8-.7 1.5-1.5 1.5H6c-.8 0-1.5-.7-1.5-1.5v-3H6v3h12v-3h1.5zM12 4.5C7.3 4.5 3.4 7.6 2 12c1.4 4.4 5.3 7.5 10 7.5s8.6-3.1 10-7.5c-1.4-4.4-5.3-7.5-10-7.5zm0 12.5c-2.8 0-5-2.2-5-5s2.2-5 5-5 5 2.2 5 5-2.2 5-5 5zm0-8c-1.7 0-3 1.3-3 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"})})})]},e.id);var t})}):(0,s.jsx)("p",{className:"fcom-documents-empty",children:(0,i.A)("No documents attached yet.")}),(0,s.jsx)(o.Button,{variant:"secondary",onClick:()=>{window.parent.postMessage({action:"MANAGE_DOCUMENTS",content:null},"*")},size:"compact",className:"fcom-documents-manage-btn",children:(0,i.A)("Manage Documents & Files")})]})}},638(e,t,n){n.d(t,{A:()=>c});const o=window.wp.compose;var a=n(427),i=n(114),s=n(790);const r=/<\s*\/?\s*(script|iframe|style|link|meta|object|embed|form|input|select|textarea|button|svg|canvas|noscript|base|frame|frameset|applet)\b|\son[a-z]+\s*=|javascript:/i,c=(0,o.createHigherOrderComponent)(e=>t=>{const n="yes"===window.fcomEditorVars?.can_unfiltered_html;return"core/html"!==t.name||n?(0,s.jsx)(e,{...t}):r.test(t.attributes?.content||"")?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e,{...t}),(0,s.jsx)(a.Notice,{status:"warning",isDismissible:!1,className:"fcom-html-block-warning",children:(0,i.A)("Your account cannot save custom HTML. Scripts, iframes and similar tags are removed on save.")})]}):(0,s.jsx)(e,{...t})},"withHtmlBlockWarning")},433(e,t,n){n.d(t,{A:()=>u,U:()=>d});var o=n(427),a=n(87),i=n(455),s=n.n(i),r=n(114),c=n(150),l=n(790);const d={type:"oembed",url:"",inner_html:"",content_type:"video",html:"",provider:"",title:"",author_name:"",image:""},m=e=>!(!e||!e.html&&"fluent_player"!==e.type),u=({media:e,videoLength:t,onUpdate:n})=>{const i=e&&"object"==typeof e?e:d,u=(0,c.VH)(),[p,h]=(0,a.useState)(m(i)?{...i}:null),[f,_]=(0,a.useState)(!1);(0,a.useEffect)(()=>{h(m(i)?{...i}:null)},[e]);const[w,v]=(0,a.useState)("oembed"),[g,x]=(0,a.useState)(""),[y,b]=(0,a.useState)(""),[j,A]=(0,a.useState)(!1),[M,k]=(0,a.useState)(""),E=parseInt(t)||0,[N,S]=(0,a.useState)(Math.floor(E/60)),[C,P]=(0,a.useState)(E%60);(0,a.useEffect)(()=>{S(Math.floor(E/60)),P(E%60)},[E]);const B=(e,t)=>{const o=Math.max(0,parseInt(e)||0),a=Math.min(59,Math.max(0,parseInt(t)||0));S(o),P(a),n("video_length",60*o+a)},D=e=>{n("media",{...e})},U=()=>{if(p){let e="iframe_html"===p.type?"iframe_html":"oembed";"fluent_player"===p.type&&u&&(e="fluent_player"),v(e),x("oembed"===e&&p.url||""),b("iframe_html"===e&&p.html||"")}else v("oembed"),x(""),b("");k(""),_(!0)},T=()=>{_(!1),k("")},F=e=>{v(e),x(""),b(""),k("")},R=()=>{g&&(A(!0),k(""),s()({path:`/fluent-community/v2/feeds/oembed?url=${encodeURIComponent(g)}`}).then(e=>{const t=e.oembed,n={type:t.type||"oembed",url:g,inner_html:"",content_type:"video",html:t.html,provider:t.provider||"",title:t.title||"",author_name:t.author_name||"",image:t.image||""};(0,c.dU)(),h(n),D(n),T()}).catch(()=>{k((0,r.A)("Failed to fetch embed. Please check the URL."))}).finally(()=>{A(!1)}))};return(0,l.jsxs)("div",{className:"fcom-media-embedder",children:[p?(0,l.jsxs)("div",{className:"fcom-media-preview",children:["fluent_player"===p.type?(0,l.jsx)("p",{className:"fcom-media-preview__meta",children:(0,r.A)("The feature video is managed by the FluentPlayer block in the editor.")}):"iframe_html"===p.type?(0,l.jsx)("div",{className:"fcom-media-iframe-preview",dangerouslySetInnerHTML:{__html:p.html},style:{width:"100%"}}):(0,l.jsxs)(l.Fragment,{children:[p.image&&(0,l.jsx)("img",{src:p.image,alt:p.title||(0,r.A)("Video thumbnail"),style:{width:"100%",borderRadius:"4px",display:"block"}}),p.title&&(0,l.jsx)("p",{className:"fcom-media-preview__title",children:p.title}),p.provider&&(0,l.jsxs)("p",{className:"fcom-media-preview__meta",children:[p.provider,p.author_name?` — ${p.author_name}`:""]}),!p.image&&!p.title&&(0,l.jsx)("p",{className:"fcom-media-preview__meta",children:(0,r.A)("Media embedded successfully")})]}),(0,l.jsxs)("div",{className:"fcom-media-preview__actions",children:[(0,l.jsx)(o.Button,{variant:"secondary",size:"compact",onClick:U,children:(0,r.A)("Edit media")}),(0,l.jsx)(o.Button,{variant:"tertiary",size:"compact",isDestructive:!0,onClick:()=>{p&&"fluent_player"===p.type&&(0,c.dU)(),h(null),D({...d})},children:(0,r.A)("Remove")})]})]}):(0,l.jsx)("div",{className:"fcom-media-empty",children:(0,l.jsx)(o.Button,{variant:"secondary",size:"compact",onClick:U,className:"fcom-media-add-btn",children:(0,r.A)("+ Add Media")})}),f&&(0,l.jsx)(o.Modal,{title:p?(0,r.A)("Edit Media"):(0,r.A)("Add Media"),onRequestClose:T,className:"fcom-media-modal",size:"medium",children:(0,l.jsxs)("div",{className:"fcom-media-modal__body",children:[(0,l.jsxs)(o.ButtonGroup,{className:"fcom-media-mode-toggle",children:[(0,l.jsx)(o.Button,{variant:"oembed"===w?"primary":"secondary",onClick:()=>F("oembed"),size:"compact",children:(0,r.A)("Oembed URL")}),(0,l.jsx)(o.Button,{variant:"iframe_html"===w?"primary":"secondary",onClick:()=>F("iframe_html"),size:"compact",children:(0,r.A)("Custom HTML")}),u&&(0,l.jsx)(o.Button,{variant:"fluent_player"===w?"primary":"secondary",onClick:()=>F("fluent_player"),size:"compact",children:(0,r.A)("FluentPlayer")})]}),"fluent_player"===w?(0,l.jsxs)("div",{className:"fcom-media-field",children:[(0,l.jsx)("p",{className:"fcom-media-help",children:(0,r.A)("A FluentPlayer block will be added at the top of the lesson content. Add or edit the video directly from that block in the editor.")}),(0,l.jsxs)("div",{className:"fcom-media-modal__footer",children:[(0,l.jsx)(o.Button,{variant:"tertiary",onClick:T,children:(0,r.A)("Cancel")}),(0,l.jsx)(o.Button,{variant:"primary",onClick:()=>{(0,c.X8)();const e={...d,type:"fluent_player"};h(e),D(e),T()},children:p&&"fluent_player"===p.type?(0,r.A)("Select Player Block"):(0,r.A)("Use FluentPlayer Block")})]})]}):"iframe_html"===w?(0,l.jsxs)("div",{className:"fcom-media-field",children:[(0,l.jsx)(o.TextareaControl,{__nextHasNoMarginBottom:!0,label:(0,r.A)("Custom HTML Code"),value:y,onChange:b,placeholder:(0,r.A)("Paste an iframe code"),rows:5}),M&&(0,l.jsx)("p",{className:"fcom-media-error",children:M}),(0,l.jsxs)("div",{className:"fcom-media-modal__footer",children:[(0,l.jsx)(o.Button,{variant:"tertiary",onClick:T,children:(0,r.A)("Cancel")}),(0,l.jsx)(o.Button,{variant:"primary",onClick:()=>{const e={...d,type:"iframe_html",html:y,content_type:"video"};(0,c.dU)(),h(e),D(e),T()},disabled:!y,children:(0,r.A)("Embed")})]})]}):(0,l.jsxs)("div",{className:"fcom-media-field",children:[(0,l.jsx)("label",{className:"fcom-media-url-label",children:(0,r.A)("Video URL")}),(0,l.jsx)("div",{className:"fcom-url-input-row",children:(0,l.jsx)("input",{type:"url",className:"components-text-control__input",value:g,onChange:e=>x(e.target.value),placeholder:(0,r.A)("Paste a URL to embed"),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),R())},autoFocus:!0})}),(0,l.jsx)("p",{className:"fcom-media-help",children:(0,r.A)("Supports Vimeo, YouTube, Wistia and more")}),M&&(0,l.jsx)("p",{className:"fcom-media-error",children:M}),(0,l.jsxs)("div",{className:"fcom-media-modal__footer",children:[(0,l.jsx)(o.Button,{variant:"tertiary",onClick:T,children:(0,r.A)("Cancel")}),(0,l.jsx)(o.Button,{variant:"primary",onClick:R,disabled:!g||j,isBusy:j,children:j?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.Spinner,{}),(0,r.A)("Embedding…")]}):(0,r.A)("Embed")})]})]})]})}),(0,l.jsxs)("div",{className:"fcom-duration-section",children:[(0,l.jsx)("p",{className:"fcom-duration-label",children:(0,r.A)("Lesson Duration")}),(0,l.jsxs)("div",{className:"fcom-duration-row",children:[(0,l.jsxs)("div",{className:"fcom-duration-field",children:[(0,l.jsx)("input",{type:"number",className:"components-text-control__input",value:N,onChange:e=>B(e.target.value,C),min:0,max:1444}),(0,l.jsx)("span",{className:"fcom-duration-unit",children:(0,r.A)("Minutes")})]}),(0,l.jsx)("span",{className:"fcom-duration-separator",children:":"}),(0,l.jsxs)("div",{className:"fcom-duration-field",children:[(0,l.jsx)("input",{type:"number",className:"components-text-control__input",value:C,onChange:e=>B(N,e.target.value),min:0,max:59}),(0,l.jsx)("span",{className:"fcom-duration-unit",children:(0,r.A)("Seconds")})]})]})]})]})}},445(e,t,n){n.d(t,{A:()=>i});var o=n(114),a=n(790);const i={name:"fcom_prefixed",className:"editor-autocompleters__fcom",triggerPrefix:"@",options:e=>[{code:"{{user.display_name|fallback}}",title:(0,o.A)("User's Name"),prefix:"user"},{code:"{{user.user_email|fallback}}",title:(0,o.A)("User's Email"),prefix:"user"},{code:"{{user.photo_html.50px}}",title:(0,o.A)("User's photo HTML"),prefix:"user"},{code:"##user.profile_link##",title:(0,o.A)("Profile Link"),prefix:"user"}],isDebounced:!0,getOptionKeywords:e=>[e.title,e.code],getOptionLabel:e=>[(0,a.jsx)("span",{className:"editor-autocompleters__user-name",children:e.title},"name")],getOptionCompletion:e=>e.code}},150(e,t,n){n.d(t,{G8:()=>l,VH:()=>c,X8:()=>p,_M:()=>m,dU:()=>d,fn:()=>u});var o=n(143),a=n(997),i=n(455),s=n.n(i);const r="fluent-player/media",c=()=>{const e=(0,a.getBlockType)(r);return!!(e&&e.attributes&&e.attributes.isFcomFeatureMedia)},l=()=>{const{getClientIdsWithDescendants:e,getBlock:t}=(0,o.select)("core/block-editor");return e().filter(e=>{const n=t(e);return n&&n.name===r&&n.attributes?.isFcomFeatureMedia})},d=()=>{const e=l();e.length&&(0,o.dispatch)("core/block-editor").removeBlocks(e)},m=()=>{const e=l();if(!e.length)return 0;const t=(0,o.select)("core/block-editor").getBlock(e[0]);return parseInt(t?.attributes?.mediaId)||0},u=e=>s()({path:`/fluent-player/v2/media/${e}`}).then(e=>{const t=(e.media||e)?.settings;let n=t?.posterSrc||"";return n.includes("/wp-includes/images/media/")&&(n=""),{duration:Math.round(parseFloat(t?.duration))||0,image:n}}).catch(()=>({duration:0,image:""})),p=()=>{const e=l();e.length?(0,o.dispatch)("core/block-editor").selectBlock(e[0]):(0,o.dispatch)("core/block-editor").insertBlock((0,a.createBlock)(r,{isFcomFeatureMedia:!0}),0)}},790(e){e.exports=window.ReactJSXRuntime},455(e){e.exports=window.wp.apiFetch},997(e){e.exports=window.wp.blocks},427(e){e.exports=window.wp.components},143(e){e.exports=window.wp.data},656(e){e.exports=window.wp.editor},87(e){e.exports=window.wp.element},619(e){e.exports=window.wp.hooks},279(e){e.exports=window.wp.plugins}},s={};function r(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return i[e](n,n.exports,r),n.exports}e="function"==typeof Symbol,t=e?Symbol("webpack queues"):"__webpack_queues__",n=e?Symbol("webpack exports"):"__webpack_exports__",o=e?Symbol("webpack error"):"__webpack_error__",a=e=>{e&&e.d<1&&(e.d=1,e.forEach(e=>e.r--),e.forEach(e=>e.r--?e.r++:e()))},r.a=(e,i,s)=>{var r;s&&((r=[]).d=-1);var c,l,d,m=new Set,u=e.exports,p=new Promise((e,t)=>{d=t,l=e});p[n]=u,p[t]=e=>(r&&e(r),m.forEach(e),p.catch(e=>{})),e.exports=p,i(e=>{var i;c=(e=>e.map(e=>{if(null!==e&&"object"==typeof e){if(e[t])return e;if(e.then){var i=[];i.d=0,e.then(e=>{s[n]=e,a(i)},e=>{s[o]=e,a(i)});var s={};return s[t]=e=>e(i),s}}var r={};return r[t]=e=>{},r[n]=e,r}))(e);var s=()=>c.map(e=>{if(e[o])throw e[o];return e[n]}),l=new Promise(e=>{(i=()=>e(s)).r=0;var n=e=>e!==r&&!m.has(e)&&(m.add(e),e&&!e.d&&(i.r++,e.push(i)));c.map(e=>e[t](n))});return i.r?l:s()},e=>(e?d(p[o]=e):l(u),a(r))),r&&r.d<0&&(r.d=0)},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(144)})(); |
|
1
|
+(()=>{"use strict";var e,t,o,a,n,i={114(e,t,o){o.d(t,{A:()=>n});const a=window.fcomEditorI18n||{};function n(e){return a[e]||e}},144(e,t,o){o.a(e,async(e,t)=>{try{var a=o(279),n=o(656),i=o(427),s=o(87),r=o(143),l=o(619),c=o(997),d=o(114),m=o(445),h=o(433),u=o(823),p=o(638),x=o(150),f=o(790);const g=parseInt(window.fcomEditorVars?.video_gate_default_threshold)||80,w=new URLSearchParams(window.location.search).get("context")||"",_=()=>{const[e,t]=(0,s.useState)(window.fcomMetaSettings||null);return(0,s.useEffect)(()=>{const e=e=>{e.detail&&t({...e.detail})};return window.addEventListener("fcomMetaSettingsReady",e),()=>window.removeEventListener("fcomMetaSettingsReady",e)},[]),[e,(e,o)=>{const a={...window.fcomMetaSettings,[e]:o};window.fcomMetaSettings=a,t({...a}),window.parent.postMessage({action:"META_UPDATED",content:a},"*")}]},b=()=>{const[e,t]=_(),[o,a]=(0,s.useState)(!!e&&"yes"===e.enable_media),r=(0,s.useRef)(e?e.enable_media:"no");(0,s.useEffect)(()=>{e&&e.enable_media!==r.current&&(r.current=e.enable_media,"yes"===e.enable_media&&a(!0))},[e]);const l=!(!e||"yes"!==e.enable_media||"fluent_player"!==e.media?.type);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(n.PluginPostStatusInfo,{children:e&&(0,f.jsxs)("div",{className:"fcom_feature_checkboxes",style:{width:"100%"},children:[(0,f.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Enable Video Embed"),checked:"yes"===e.enable_media,onChange:o=>{o||"fluent_player"!==e.media?.type||(0,x.dU)(),t("enable_media",o?"yes":"no")}}),(0,f.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Enable Comments"),checked:"yes"===e.enable_comments,onChange:e=>t("enable_comments",e?"yes":"no")}),(0,f.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Free Preview Lesson"),help:(0,d.A)("If enabled, public users can view this lesson without enrolling the course."),checked:"yes"===e.free_preview_lesson,onChange:e=>t("free_preview_lesson",e?"yes":"no")})]})}),(0,f.jsx)(n.PluginDocumentSettingPanel,{name:"fcom-media-embed",title:(0,d.A)("Media Embed"),className:e&&"yes"===e.enable_media?"":"fcom-panel-hidden",isOpen:o,onToggle:()=>a(!o),children:e&&"yes"===e.enable_media&&(0,f.jsx)(h.A,{media:e.media,videoLength:e.video_length,onUpdate:(e,o)=>t(e,o)})}),(0,f.jsx)(n.PluginDocumentSettingPanel,{name:"fcom-video-completion",title:(0,d.A)("Video Completion"),className:l?"":"fcom-panel-hidden",initialOpen:!1,children:l&&(0,f.jsxs)("div",{className:"fcom-video-gate",children:[(0,f.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Require video watch to complete"),help:(0,d.A)("Students must watch the video before they can mark this lesson as completed."),checked:"yes"===e.require_video_completion,onChange:e=>t("require_video_completion",e?"yes":"no")}),(0,f.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Auto-complete lesson when the video ends"),help:(0,d.A)("Marks the lesson complete a few seconds after the student watches the video to the end."),checked:"yes"===e.auto_complete_on_video_end,onChange:e=>t("auto_complete_on_video_end",e?"yes":"no")}),"yes"===e.require_video_completion&&(0,f.jsx)("div",{className:"fcom-video-gate__threshold",children:(0,f.jsx)(i.RangeControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Required watch percentage"),help:(0,d.A)("100% means the video must be watched to the end."),min:1,max:100,value:Math.min(100,Math.max(1,parseInt(e.video_completion_threshold)||g)),onChange:e=>t("video_completion_threshold",Math.min(100,Math.max(1,parseInt(e)||g)))})})]})}),(0,f.jsx)(n.PluginDocumentSettingPanel,{name:"fcom-documents",title:(0,d.A)("Documents & Files"),className:e?"":"fcom-panel-hidden",initialOpen:!1,children:e&&(0,f.jsx)(u.A,{})}),(0,f.jsx)(n.PluginDocumentSettingPanel,{name:"fcom-smartcodes",title:(0,d.A)("Smartcodes"),initialOpen:!1,children:(0,f.jsxs)("div",{className:"fcom_lesson_info_codes",children:[(0,f.jsx)("p",{children:(0,d.A)("You may use following smartcode in your lesson:")}),(0,f.jsxs)("ul",{children:[(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:(0,d.A)("User's Name:")})," ",(0,f.jsx)("span",{children:"{{user.display_name|fallback}}"})]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:(0,d.A)("User's Email:")})," ",(0,f.jsx)("span",{children:"{{user.user_email|fallback}}"})]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:(0,d.A)("User's photo HTML:")})," ",(0,f.jsx)("span",{children:"{{user.photo_html.50px}}"})]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:(0,d.A)("User's Profile Link:")})," ",(0,f.jsx)("span",{children:"##user.profile_link##"})]})]})]})})]})},y={unified:{surface:"sheet",container:"100%",titleWidth:"1016px",content:"1016px",wide:"1016px",padding:"32px 32px"},standard:{surface:"card",container:"1016px",titleWidth:"720px",content:"720px",wide:"900px",padding:"32px"},classic:{surface:"card",container:"680px",titleWidth:"680px",content:"680px",wide:"680px",padding:"24px"},full_width:{surface:"none",container:"1016px",titleWidth:"720px",content:"720px",wide:"900px",padding:"0px"}},v="unified",j="fcom-page-canvas-preview";let A=null,N=null;const k=()=>{const e=document.querySelector('iframe[name="editor-canvas"]');return e&&e.contentDocument&&e.contentDocument.head?e.contentDocument:document.querySelector(".editor-styles-wrapper")?document:null},M=()=>{const e=k();if(!e||!A)return!1;let t=e.getElementById(j);return t||(t=e.createElement("style"),t.setAttribute("id",j),e.head.appendChild(t)),t.textContent!==A.css&&(t.textContent=A.css),e.body&&(e.body.style.setProperty("--theme-block-max-width",A.content),e.body.style.setProperty("--theme-block-wide-max-width",A.wide)),!0},C=(e,t)=>{const o=y[e]||y[v],a=".editor-visual-editor__post-title-wrapper.editor-visual-editor__post-title-wrapper,.edit-post-visual-editor__post-title-wrapper.edit-post-visual-editor__post-title-wrapper",n=".editor-styles-wrapper .is-root-container.is-root-container",i="card"===o.surface,s="sheet"===o.surface,r="var(--fcom-primary-bg, #fff)",l=s?r:"var(--fcom-secondary-bg, #f0f2f5)",c=i?`background:${r};border:1px solid var(--fcom-primary-border, #e3e8ee);`:"background:transparent;border:0;",d=s?"0":"24px",m=`max-width:${o.container};box-sizing:border-box;display:flow-root;`,h=String(o.padding).trim().split(/\s+/)[0],u=[`.editor-styles-wrapper.editor-styles-wrapper{--wp--style--global--content-size:${o.content};--wp--style--global--wide-size:${o.wide};background:${l};${s?"width:100%;margin-block:0;":""}}`,`${a} .editor-post-title,${a} h1{max-width:${o.titleWidth};margin:0 auto;}`,`${a}{${m}${c}margin:${d} auto 0;margin-bottom:0 !important;padding:${o.padding};padding-top:${h} !important;padding-bottom:20px;border-bottom:0;border-radius:8px 8px 0 0;}`,`${n}{${m}${c}margin:0 auto ${d};padding:${o.padding};padding-top:0;border-top:0;border-radius:0 0 8px 8px;}`,`${n} > :not(.alignleft):not(.alignright):not(.alignfull):not(.alignwide){max-width:${o.content};}`,`${n} > .alignwide{max-width:${o.wide};}`];t||u.push(`${a} .editor-post-title,${a} h1{opacity:0.4;}`),A={css:u.join(""),content:o.content,wide:o.wide},M(),N||(N=setInterval(M,1e3))},S=({children:e})=>(0,f.jsxs)("svg",{viewBox:"0 0 100 70",className:"fcom-layout-thumb__svg","aria-hidden":"true",focusable:"false",children:[(0,f.jsx)("rect",{x:"0",y:"0",width:"100",height:"70",rx:"2",className:"fcom-thumb-page"}),(0,f.jsx)("rect",{x:"0",y:"0",width:"100",height:"9",className:"fcom-thumb-chrome"}),e]}),E={unified:(0,f.jsxs)(S,{children:[(0,f.jsx)("rect",{x:"0",y:"9",width:"100",height:"61",className:"fcom-thumb-sheet"}),(0,f.jsx)("rect",{x:"0",y:"9",width:"100",height:"15",className:"fcom-thumb-block"}),(0,f.jsx)("rect",{x:"30",y:"30",width:"40",height:"4",rx:"1",className:"fcom-thumb-title"}),(0,f.jsx)("rect",{x:"30",y:"40",width:"40",height:"2.5",rx:"1",className:"fcom-thumb-line"}),(0,f.jsx)("rect",{x:"30",y:"46",width:"40",height:"2.5",rx:"1",className:"fcom-thumb-line"}),(0,f.jsx)("rect",{x:"30",y:"52",width:"26",height:"2.5",rx:"1",className:"fcom-thumb-line"})]}),standard:(0,f.jsxs)(S,{children:[(0,f.jsx)("rect",{x:"8",y:"15",width:"84",height:"48",rx:"2",className:"fcom-thumb-card"}),(0,f.jsx)("rect",{x:"16",y:"21",width:"68",height:"11",rx:"1",className:"fcom-thumb-block"}),(0,f.jsx)("rect",{x:"16",y:"38",width:"68",height:"2.5",rx:"1",className:"fcom-thumb-line"}),(0,f.jsx)("rect",{x:"16",y:"44",width:"68",height:"2.5",rx:"1",className:"fcom-thumb-line"}),(0,f.jsx)("rect",{x:"16",y:"50",width:"44",height:"2.5",rx:"1",className:"fcom-thumb-line"})]}),classic:(0,f.jsxs)(S,{children:[(0,f.jsx)("rect",{x:"6",y:"15",width:"58",height:"48",rx:"2",className:"fcom-thumb-card"}),(0,f.jsx)("rect",{x:"12",y:"21",width:"46",height:"9",rx:"1",className:"fcom-thumb-block"}),(0,f.jsx)("rect",{x:"12",y:"36",width:"46",height:"2.5",rx:"1",className:"fcom-thumb-line"}),(0,f.jsx)("rect",{x:"12",y:"42",width:"46",height:"2.5",rx:"1",className:"fcom-thumb-line"}),(0,f.jsx)("rect",{x:"12",y:"48",width:"30",height:"2.5",rx:"1",className:"fcom-thumb-line"}),(0,f.jsx)("rect",{x:"70",y:"15",width:"24",height:"30",rx:"2",className:"fcom-thumb-card"}),(0,f.jsx)("rect",{x:"74",y:"20",width:"16",height:"2.5",rx:"1",className:"fcom-thumb-line"}),(0,f.jsx)("rect",{x:"74",y:"26",width:"16",height:"2.5",rx:"1",className:"fcom-thumb-line"}),(0,f.jsx)("rect",{x:"74",y:"32",width:"10",height:"2.5",rx:"1",className:"fcom-thumb-line"})]}),full_width:(0,f.jsxs)(S,{children:[(0,f.jsx)("rect",{x:"6",y:"15",width:"88",height:"18",rx:"1",className:"fcom-thumb-block"}),(0,f.jsx)("rect",{x:"6",y:"37",width:"42",height:"16",rx:"1",className:"fcom-thumb-line"}),(0,f.jsx)("rect",{x:"52",y:"37",width:"42",height:"16",rx:"1",className:"fcom-thumb-line"}),(0,f.jsx)("rect",{x:"6",y:"58",width:"88",height:"2.5",rx:"1",className:"fcom-thumb-line"})]})},P=(0,f.jsx)(S,{children:(0,f.jsx)("rect",{x:"20",y:"18",width:"60",height:"42",rx:"2",className:"fcom-thumb-card"})}),B=()=>{const e=window.fcomEditorVars?.page_layouts;return e&&Object.keys(e).length?e:{unified:{label:(0,d.A)("Unified")},standard:{label:(0,d.A)("Standard")},classic:{label:(0,d.A)("Classic")},full_width:{label:(0,d.A)("Full Width")}}},D=({meta:e,updateMeta:t})=>{const o=B(),a=o[e.layout]?e.layout:v,s="no"!==e.show_title;return(0,f.jsxs)(n.PluginDocumentSettingPanel,{name:"fcom-page-layout",title:(0,d.A)("Page Layout"),initialOpen:!0,children:[(0,f.jsx)("div",{className:"fcom-layout-picker",role:"radiogroup","aria-label":(0,d.A)("Page Layout"),children:Object.keys(o).map(e=>{const n=e===a;return(0,f.jsxs)("button",{type:"button",role:"radio","aria-checked":n,title:o[e]?.description||"",className:"fcom-layout-thumb"+(n?" is-active":""),onClick:()=>t("layout",e),children:[E[e]||P,(0,f.jsx)("span",{className:"fcom-layout-thumb__label",children:o[e]?.label||e})]},e)})}),o[a]?.description&&(0,f.jsx)("p",{className:"fcom-layout-picker__help",children:o[a].description}),(0,f.jsxs)("div",{className:"fcom-layout-picker__toggles",children:[(0,f.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Show the page title"),help:(0,d.A)("The title stays editable here and still names the page in the menu."),checked:s,onChange:e=>t("show_title",e?"yes":"no")}),(0,f.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Show the featured image"),help:(0,d.A)("The image still appears in search results and link previews."),checked:"yes"===e.show_featured_image,onChange:e=>t("show_featured_image",e?"yes":"no")})]})]})},U=()=>{const[e,t]=_(),o=B(),a=e&&o[e.layout]?e.layout:v,r=!e||"no"!==e.show_title;return(0,s.useEffect)(()=>{C(a,r)},[a,r]),e?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(n.PluginPostStatusInfo,{children:(0,f.jsxs)("div",{className:"fcom_page_settings",style:{width:"100%"},children:[(0,f.jsx)(i.SelectControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,d.A)("Who can view this page"),value:"members_only"===e.privacy?"members_only":"public",options:[{label:(0,d.A)("Everyone who can view the space"),value:"public"},{label:(0,d.A)("Space members only"),value:"members_only"}],onChange:e=>t("privacy",e)}),(0,f.jsx)(i.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,d.A)("URL Slug"),value:e.slug||"",help:(0,d.A)("Changing the slug will break existing links to this page."),onChange:e=>t("slug",e)}),(0,f.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Show in space menu"),checked:"yes"===e.show_in_nav,onChange:e=>t("show_in_nav",e?"yes":"no")}),"yes"===e.show_in_nav&&(0,f.jsx)(i.TextControl,{__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,label:(0,d.A)("Menu Label"),value:e.nav_label||"",help:(0,d.A)("Leave empty to use the page title."),onChange:e=>t("nav_label",e)}),(0,f.jsx)(i.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("Enable Comments"),checked:"yes"===e.enable_comments,onChange:e=>t("enable_comments",e?"yes":"no")})]})}),(0,f.jsx)(D,{meta:e,updateMeta:t}),(0,f.jsx)(n.PluginDocumentSettingPanel,{name:"fcom-page-seo",title:(0,d.A)("SEO"),initialOpen:!1,children:(0,f.jsx)(i.TextareaControl,{__nextHasNoMarginBottom:!0,label:(0,d.A)("SEO Description"),help:(0,d.A)("Used for search engines and link previews"),rows:3,value:e.seo_description||"",onChange:e=>t("seo_description",e)})})]}):null};(0,a.registerPlugin)("fcom-document-settings",{render:"space_page"===w?U:b});let T=!1;const L=()=>{if(T)return null;(0,r.select)("core/preferences").get("core/edit-post","welcomeGuide")&&(0,r.dispatch)("core/preferences").toggle("core/edit-post","welcomeGuide"),(0,r.select)("core/preferences").get("core/edit-post","fullscreenMode")||(0,r.dispatch)("core/preferences").toggle("core/edit-post","fullscreenMode");const e=(0,r.select)("core/editor"),t=(0,r.dispatch)("core/editor");return e.getEditorMode&&t.switchEditorMode?"text"===e.getEditorMode()&&t.switchEditorMode("visual"):"text"===(0,r.select)("core/edit-post").getEditorMode()&&(0,r.dispatch)("core/edit-post").switchEditorMode("visual"),(0,r.dispatch)("core/editor").lockPostSaving(),(0,r.dispatch)("core/editor").lockPostAutosaving(),T=!0,null};async function R(){await new Promise(e=>{const t=(0,r.subscribe)(()=>{((0,r.select)("core/editor").isCleanNewPost()||(0,r.select)("core/block-editor").getBlockCount()>0)&&(t(),e())})});const e=document.querySelector('[name="editor-canvas"]');return new Promise(t=>{e?e.loading?e.onload=()=>{t(e)}:t(e):t(null)})}(0,a.registerPlugin)("fluent-com-disable-gutenberg-features",{render:L}),(0,l.addFilter)("editor.DocumentBar","fluentcom-custom-document-bar",()=>null),(0,l.addFilter)("editor.BlockEdit","fluent_com/html_block_warning",p.A),(0,l.addFilter)("editor.Autocomplete.completers","fluent_com/add_autocmplete",function(e,t){return e=e.filter(e=>"users"!==e.name),[...e,m.A]}),window.addEventListener("beforeunload",function(e){e.stopImmediatePropagation()}),await R(),console.log("editor iframe is now ready");let H=!1,$=null,F=null;window.addEventListener("message",e=>{if("SYNC_META"===e.data?.type)return window.fcomMetaSettings=e.data.data,window.dispatchEvent(new CustomEvent("fcomMetaSettingsReady",{detail:e.data.data})),void window.dispatchEvent(new CustomEvent("fcomDocumentsUpdated"));if("UPDATE_EDITOR"!==e.data?.type)return;H=!1,F=null;const{content:t,title:o,featured_image_id:a,metaSettings:n}=e.data.data;console.log("UPDATE_EDITOR",n,e.data.data),n?(window.fcomMetaSettings=n,window.dispatchEvent(new CustomEvent("fcomMetaSettingsReady",{detail:n}))):window.fcomMetaSettings=null,t&&(0,r.dispatch)("core/block-editor").resetBlocks((0,c.parse)(t));let i=null;o&&(i={title:o}),a&&(i?i.featured_media=a:i={featured_media:a}),i&&(0,r.dispatch)("core/editor").editPost(i),clearTimeout($),$=setTimeout(()=>{H=!0},1e3)});const I=()=>{const e=window.fcomMetaSettings;if(!e||"fluent_player"!==e.media?.type)return;if(!(0,x.VH)())return;if((0,x.G8)().length)return;const t={...e,media:{...h.U}};window.fcomMetaSettings=t,window.dispatchEvent(new CustomEvent("fcomMetaSettingsReady",{detail:t})),window.parent.postMessage({action:"META_UPDATED",content:t},"*")},O=()=>{const e=window.fcomMetaSettings;if(!e||"fluent_player"!==e.media?.type||!(0,x.VH)())return void(F=null);const t=(0,x._M)();null!==F?t!==F&&(F=t,t&&(0,x.fn)(t).then(({duration:e,image:o})=>{if(!e&&!o||!H||t!==F)return;const a=window.fcomMetaSettings;if(!a||"fluent_player"!==a.media?.type)return;const n={...a,media:{...a.media,image:o}};e&&(n.video_length=e),window.fcomMetaSettings=n,window.dispatchEvent(new CustomEvent("fcomMetaSettingsReady",{detail:n})),window.parent.postMessage({action:"META_UPDATED",content:n},"*")})):F=t};window._wpLoadBlockEditor.then(()=>{window.parent.postMessage({content:"ping",action:"EDITOR_READY"},"*");let e="",t="",o=null;(0,r.subscribe)(()=>{if(!H)return;I(),O();const a=(0,r.select)("core/editor").getEditedPostAttribute("title");a!=t&&(t=a,window.parent.postMessage({content:a,action:"TITLE_UPDATED"},"*"));const n=(0,r.select)("core/editor").getEditedPostAttribute("featured_media");o!=n&&(o=n,window.fcomMetaSettings&&(window.fcomMetaSettings={...window.fcomMetaSettings,featured_image_id:n}),window.parent.postMessage({content:n,action:"FEATURED_MEDIA_UPDATED"},"*"));const i=(0,r.select)("core/block-editor").getBlocks(),s=(0,c.serialize)(i);e!=s&&(e=s,window.parent.postMessage({content:s,action:"EDITOR_UPDATED"},"*"))})}),t()}catch(z){t(z)}},1)},823(e,t,o){o.d(t,{A:()=>r});var a=o(427),n=o(87),i=o(114),s=o(790);const r=()=>{const[e,t]=(0,n.useState)(window.fcomMetaSettings&&Array.isArray(window.fcomMetaSettings.document_lists)?window.fcomMetaSettings.document_lists:[]);return(0,n.useEffect)(()=>{const e=e=>{e.detail&&Array.isArray(e.detail.document_lists)&&t([...e.detail.document_lists])};window.addEventListener("fcomMetaSettingsReady",e);const o=()=>{window.fcomMetaSettings&&Array.isArray(window.fcomMetaSettings.document_lists)&&t([...window.fcomMetaSettings.document_lists])};return window.addEventListener("fcomDocumentsUpdated",o),()=>{window.removeEventListener("fcomMetaSettingsReady",e),window.removeEventListener("fcomDocumentsUpdated",o)}},[]),(0,s.jsxs)("div",{className:"fcom-documents-panel",children:[e.length>0?(0,s.jsx)("ul",{className:"fcom-documents-list",children:e.map(e=>{return(0,s.jsxs)("li",{className:"fcom-document-item",children:[(0,s.jsx)("span",{className:"fcom-document-icon",children:(t=e.type,t?t.includes("pdf")?"📄":t.includes("image")?"🖼️":t.includes("video")?"🎥":t.includes("audio")?"🎵":t.includes("zip")||t.includes("rar")||t.includes("archive")?"🗜️":"📄":"📄")}),(0,s.jsx)("span",{className:"fcom-document-title",children:e.title}),e.url&&(0,s.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"fcom-document-view",title:(0,i.A)("View"),children:(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:(0,s.jsx)("path",{d:"M19.5 14.5v3c0 .8-.7 1.5-1.5 1.5H6c-.8 0-1.5-.7-1.5-1.5v-3H6v3h12v-3h1.5zM12 4.5C7.3 4.5 3.4 7.6 2 12c1.4 4.4 5.3 7.5 10 7.5s8.6-3.1 10-7.5c-1.4-4.4-5.3-7.5-10-7.5zm0 12.5c-2.8 0-5-2.2-5-5s2.2-5 5-5 5 2.2 5 5-2.2 5-5 5zm0-8c-1.7 0-3 1.3-3 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"})})})]},e.id);var t})}):(0,s.jsx)("p",{className:"fcom-documents-empty",children:(0,i.A)("No documents attached yet.")}),(0,s.jsx)(a.Button,{variant:"secondary",onClick:()=>{window.parent.postMessage({action:"MANAGE_DOCUMENTS",content:null},"*")},size:"compact",className:"fcom-documents-manage-btn",children:(0,i.A)("Manage Documents & Files")})]})}},638(e,t,o){o.d(t,{A:()=>l});const a=window.wp.compose;var n=o(427),i=o(114),s=o(790);const r=/<\s*\/?\s*(script|iframe|style|link|meta|object|embed|form|input|select|textarea|button|svg|canvas|noscript|base|frame|frameset|applet)\b|\son[a-z]+\s*=|javascript:/i,l=(0,a.createHigherOrderComponent)(e=>t=>{const o="yes"===window.fcomEditorVars?.can_unfiltered_html;return"core/html"!==t.name||o?(0,s.jsx)(e,{...t}):r.test(t.attributes?.content||"")?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e,{...t}),(0,s.jsx)(n.Notice,{status:"warning",isDismissible:!1,className:"fcom-html-block-warning",children:(0,i.A)("Your account cannot save custom HTML. Scripts, iframes and similar tags are removed on save.")})]}):(0,s.jsx)(e,{...t})},"withHtmlBlockWarning")},433(e,t,o){o.d(t,{A:()=>h,U:()=>d});var a=o(427),n=o(87),i=o(455),s=o.n(i),r=o(114),l=o(150),c=o(790);const d={type:"oembed",url:"",inner_html:"",content_type:"video",html:"",provider:"",title:"",author_name:"",image:""},m=e=>!(!e||!e.html&&"fluent_player"!==e.type),h=({media:e,videoLength:t,onUpdate:o})=>{const i=e&&"object"==typeof e?e:d,h=(0,l.VH)(),[u,p]=(0,n.useState)(m(i)?{...i}:null),[x,f]=(0,n.useState)(!1);(0,n.useEffect)(()=>{p(m(i)?{...i}:null)},[e]);const[g,w]=(0,n.useState)("oembed"),[_,b]=(0,n.useState)(""),[y,v]=(0,n.useState)(""),[j,A]=(0,n.useState)(!1),[N,k]=(0,n.useState)(""),M=parseInt(t)||0,[C,S]=(0,n.useState)(Math.floor(M/60)),[E,P]=(0,n.useState)(M%60);(0,n.useEffect)(()=>{S(Math.floor(M/60)),P(M%60)},[M]);const B=(e,t)=>{const a=Math.max(0,parseInt(e)||0),n=Math.min(59,Math.max(0,parseInt(t)||0));S(a),P(n),o("video_length",60*a+n)},D=e=>{o("media",{...e})},U=()=>{if(u){let e="iframe_html"===u.type?"iframe_html":"oembed";"fluent_player"===u.type&&h&&(e="fluent_player"),w(e),b("oembed"===e&&u.url||""),v("iframe_html"===e&&u.html||"")}else w("oembed"),b(""),v("");k(""),f(!0)},T=()=>{f(!1),k("")},L=e=>{w(e),b(""),v(""),k("")},R=()=>{_&&(A(!0),k(""),s()({path:`/fluent-community/v2/feeds/oembed?url=${encodeURIComponent(_)}`}).then(e=>{const t=e.oembed,o={type:t.type||"oembed",url:_,inner_html:"",content_type:"video",html:t.html,provider:t.provider||"",title:t.title||"",author_name:t.author_name||"",image:t.image||""};(0,l.dU)(),p(o),D(o),T()}).catch(()=>{k((0,r.A)("Failed to fetch embed. Please check the URL."))}).finally(()=>{A(!1)}))};return(0,c.jsxs)("div",{className:"fcom-media-embedder",children:[u?(0,c.jsxs)("div",{className:"fcom-media-preview",children:["fluent_player"===u.type?(0,c.jsx)("p",{className:"fcom-media-preview__meta",children:(0,r.A)("The feature video is managed by the FluentPlayer block in the editor.")}):"iframe_html"===u.type?(0,c.jsx)("div",{className:"fcom-media-iframe-preview",dangerouslySetInnerHTML:{__html:u.html},style:{width:"100%"}}):(0,c.jsxs)(c.Fragment,{children:[u.image&&(0,c.jsx)("img",{src:u.image,alt:u.title||(0,r.A)("Video thumbnail"),style:{width:"100%",borderRadius:"4px",display:"block"}}),u.title&&(0,c.jsx)("p",{className:"fcom-media-preview__title",children:u.title}),u.provider&&(0,c.jsxs)("p",{className:"fcom-media-preview__meta",children:[u.provider,u.author_name?` — ${u.author_name}`:""]}),!u.image&&!u.title&&(0,c.jsx)("p",{className:"fcom-media-preview__meta",children:(0,r.A)("Media embedded successfully")})]}),(0,c.jsxs)("div",{className:"fcom-media-preview__actions",children:[(0,c.jsx)(a.Button,{variant:"secondary",size:"compact",onClick:U,children:(0,r.A)("Edit Media")}),(0,c.jsx)(a.Button,{variant:"tertiary",size:"compact",isDestructive:!0,onClick:()=>{u&&"fluent_player"===u.type&&(0,l.dU)(),p(null),D({...d})},children:(0,r.A)("Remove")})]})]}):(0,c.jsx)("div",{className:"fcom-media-empty",children:(0,c.jsx)(a.Button,{variant:"secondary",size:"compact",onClick:U,className:"fcom-media-add-btn",children:(0,r.A)("+ Add Media")})}),x&&(0,c.jsx)(a.Modal,{title:u?(0,r.A)("Edit Media"):(0,r.A)("Add Media"),onRequestClose:T,className:"fcom-media-modal",size:"medium",children:(0,c.jsxs)("div",{className:"fcom-media-modal__body",children:[(0,c.jsxs)(a.ButtonGroup,{className:"fcom-media-mode-toggle",children:[(0,c.jsx)(a.Button,{variant:"oembed"===g?"primary":"secondary",onClick:()=>L("oembed"),size:"compact",children:(0,r.A)("Oembed URL")}),(0,c.jsx)(a.Button,{variant:"iframe_html"===g?"primary":"secondary",onClick:()=>L("iframe_html"),size:"compact",children:(0,r.A)("Custom HTML")}),h&&(0,c.jsx)(a.Button,{variant:"fluent_player"===g?"primary":"secondary",onClick:()=>L("fluent_player"),size:"compact",children:(0,r.A)("FluentPlayer")})]}),"fluent_player"===g?(0,c.jsxs)("div",{className:"fcom-media-field",children:[(0,c.jsx)("p",{className:"fcom-media-help",children:(0,r.A)("A FluentPlayer block will be added at the top of the lesson content. Add or edit the video directly from that block in the editor.")}),(0,c.jsxs)("div",{className:"fcom-media-modal__footer",children:[(0,c.jsx)(a.Button,{variant:"tertiary",onClick:T,children:(0,r.A)("Cancel")}),(0,c.jsx)(a.Button,{variant:"primary",onClick:()=>{(0,l.X8)();const e={...d,type:"fluent_player"};p(e),D(e),T()},children:u&&"fluent_player"===u.type?(0,r.A)("Select Player Block"):(0,r.A)("Use FluentPlayer Block")})]})]}):"iframe_html"===g?(0,c.jsxs)("div",{className:"fcom-media-field",children:[(0,c.jsx)(a.TextareaControl,{__nextHasNoMarginBottom:!0,label:(0,r.A)("Custom HTML Code"),value:y,onChange:v,placeholder:(0,r.A)("Paste an iframe code"),rows:5}),N&&(0,c.jsx)("p",{className:"fcom-media-error",children:N}),(0,c.jsxs)("div",{className:"fcom-media-modal__footer",children:[(0,c.jsx)(a.Button,{variant:"tertiary",onClick:T,children:(0,r.A)("Cancel")}),(0,c.jsx)(a.Button,{variant:"primary",onClick:()=>{const e={...d,type:"iframe_html",html:y,content_type:"video"};(0,l.dU)(),p(e),D(e),T()},disabled:!y,children:(0,r.A)("Embed")})]})]}):(0,c.jsxs)("div",{className:"fcom-media-field",children:[(0,c.jsx)("label",{className:"fcom-media-url-label",children:(0,r.A)("Video URL")}),(0,c.jsx)("div",{className:"fcom-url-input-row",children:(0,c.jsx)("input",{type:"url",className:"components-text-control__input",value:_,onChange:e=>b(e.target.value),placeholder:(0,r.A)("Paste a URL to embed"),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),R())},autoFocus:!0})}),(0,c.jsx)("p",{className:"fcom-media-help",children:(0,r.A)("Supports Vimeo, YouTube, Wistia and more")}),N&&(0,c.jsx)("p",{className:"fcom-media-error",children:N}),(0,c.jsxs)("div",{className:"fcom-media-modal__footer",children:[(0,c.jsx)(a.Button,{variant:"tertiary",onClick:T,children:(0,r.A)("Cancel")}),(0,c.jsx)(a.Button,{variant:"primary",onClick:R,disabled:!_||j,isBusy:j,children:j?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Spinner,{}),(0,r.A)("Embedding…")]}):(0,r.A)("Embed")})]})]})]})}),(0,c.jsxs)("div",{className:"fcom-duration-section",children:[(0,c.jsx)("p",{className:"fcom-duration-label",children:(0,r.A)("Lesson Duration")}),(0,c.jsxs)("div",{className:"fcom-duration-row",children:[(0,c.jsxs)("div",{className:"fcom-duration-field",children:[(0,c.jsx)("input",{type:"number",className:"components-text-control__input",value:C,onChange:e=>B(e.target.value,E),min:0,max:1444}),(0,c.jsx)("span",{className:"fcom-duration-unit",children:(0,r.A)("Minutes")})]}),(0,c.jsx)("span",{className:"fcom-duration-separator",children:":"}),(0,c.jsxs)("div",{className:"fcom-duration-field",children:[(0,c.jsx)("input",{type:"number",className:"components-text-control__input",value:E,onChange:e=>B(C,e.target.value),min:0,max:59}),(0,c.jsx)("span",{className:"fcom-duration-unit",children:(0,r.A)("Seconds")})]})]})]})]})}},445(e,t,o){o.d(t,{A:()=>i});var a=o(114),n=o(790);const i={name:"fcom_prefixed",className:"editor-autocompleters__fcom",triggerPrefix:"@",options:e=>[{code:"{{user.display_name|fallback}}",title:(0,a.A)("User's Name"),prefix:"user"},{code:"{{user.user_email|fallback}}",title:(0,a.A)("User's Email"),prefix:"user"},{code:"{{user.photo_html.50px}}",title:(0,a.A)("User's photo HTML"),prefix:"user"},{code:"##user.profile_link##",title:(0,a.A)("Profile Link"),prefix:"user"}],isDebounced:!0,getOptionKeywords:e=>[e.title,e.code],getOptionLabel:e=>[(0,n.jsx)("span",{className:"editor-autocompleters__user-name",children:e.title},"name")],getOptionCompletion:e=>e.code}},150(e,t,o){o.d(t,{G8:()=>c,VH:()=>l,X8:()=>u,_M:()=>m,dU:()=>d,fn:()=>h});var a=o(143),n=o(997),i=o(455),s=o.n(i);const r="fluent-player/media",l=()=>{const e=(0,n.getBlockType)(r);return!!(e&&e.attributes&&e.attributes.isFcomFeatureMedia)},c=()=>{const{getClientIdsWithDescendants:e,getBlock:t}=(0,a.select)("core/block-editor");return e().filter(e=>{const o=t(e);return o&&o.name===r&&o.attributes?.isFcomFeatureMedia})},d=()=>{const e=c();e.length&&(0,a.dispatch)("core/block-editor").removeBlocks(e)},m=()=>{const e=c();if(!e.length)return 0;const t=(0,a.select)("core/block-editor").getBlock(e[0]);return parseInt(t?.attributes?.mediaId)||0},h=e=>s()({path:`/fluent-player/v2/media/${e}`}).then(e=>{const t=(e.media||e)?.settings;let o=t?.posterSrc||"";return o.includes("/wp-includes/images/media/")&&(o=""),{duration:Math.round(parseFloat(t?.duration))||0,image:o}}).catch(()=>({duration:0,image:""})),u=()=>{const e=c();e.length?(0,a.dispatch)("core/block-editor").selectBlock(e[0]):(0,a.dispatch)("core/block-editor").insertBlock((0,n.createBlock)(r,{isFcomFeatureMedia:!0}),0)}},790(e){e.exports=window.ReactJSXRuntime},455(e){e.exports=window.wp.apiFetch},997(e){e.exports=window.wp.blocks},427(e){e.exports=window.wp.components},143(e){e.exports=window.wp.data},656(e){e.exports=window.wp.editor},87(e){e.exports=window.wp.element},619(e){e.exports=window.wp.hooks},279(e){e.exports=window.wp.plugins}},s={};function r(e){var t=s[e];if(void 0!==t)return t.exports;var o=s[e]={exports:{}};return i[e](o,o.exports,r),o.exports}e="function"==typeof Symbol,t=e?Symbol("webpack queues"):"__webpack_queues__",o=e?Symbol("webpack exports"):"__webpack_exports__",a=e?Symbol("webpack error"):"__webpack_error__",n=e=>{e&&e.d<1&&(e.d=1,e.forEach(e=>e.r--),e.forEach(e=>e.r--?e.r++:e()))},r.a=(e,i,s)=>{var r;s&&((r=[]).d=-1);var l,c,d,m=new Set,h=e.exports,u=new Promise((e,t)=>{d=t,c=e});u[o]=h,u[t]=e=>(r&&e(r),m.forEach(e),u.catch(e=>{})),e.exports=u,i(e=>{var i;l=(e=>e.map(e=>{if(null!==e&&"object"==typeof e){if(e[t])return e;if(e.then){var i=[];i.d=0,e.then(e=>{s[o]=e,n(i)},e=>{s[a]=e,n(i)});var s={};return s[t]=e=>e(i),s}}var r={};return r[t]=e=>{},r[o]=e,r}))(e);var s=()=>l.map(e=>{if(e[a])throw e[a];return e[o]}),c=new Promise(e=>{(i=()=>e(s)).r=0;var o=e=>e!==r&&!m.has(e)&&(m.add(e),e&&!e.d&&(i.r++,e.push(i)));l.map(e=>e[t](o))});return i.r?c:s()},e=>(e?d(u[a]=e):c(h),n(r))),r&&r.d<0&&(r.d=0)},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(144)})(); |