!function(){"use strict";var e=window.wp.i18n,t=window.wp.blocks,s=window.wp.element,o=window.wp.data;const r=e=>{let t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||""},n=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"display",n="",a="",i="",l="";if(t=parseInt(t)?parseInt(t):0,s=parseInt(s)?parseInt(s):0,o=parseInt(o)?parseInt(o):0,"schema"===r)a=t?`${t}D`:"",i=s?`${s}H`:"",l=o?`${o}M`:"",n=`${t>0||s>0||o>0?"P":""}${a}${s>0||o>0?"T":""}${i}${l}`;else{
/* translators: %1$s: number of days */
a=t>0?(0,e.sprintf)((0,e._n)("%1$s day","%1$s days",t,"wp-seopress-pro"),t):"",
/* translators: %1$s: number of hours */
i=s>0?(0,e.sprintf)((0,e._n)("%1$s hour","%1$s hours",s,"wp-seopress-pro"),s):"",
/* translators: %1$s: number of minutes */
l=o>0?(0,e.sprintf)((0,e._n)("%1$s minute","%1$s minutes",o,"wp-seopress-pro"),o):"";const r=[a,i,l].filter((e=>""!==e));n=r.length?r.join(", "):""}return n};var a=window.wp.url,i=window.wp.blockEditor,l=JSON.parse('{"u2":"wpseopress/how-to-step"}');(0,t.registerBlockType)(l.u2,{title:(0,e.__)("How To Step","wp-seopress-pro"),description:(0,e.__)("Display a tutorial step.","wp-seopress-pro"),edit:function(t){let{attributes:n,setAttributes:l}=t,{title:c,description:p,schema:d}=n;const u=(e,t)=>{const s={...d,"@type":"HowToStep"};switch(e){case"title":s.name=t,s.url=(0,o.select)("core/editor").getPermalink()+"#"+(0,a.cleanForSlug)(t);break;case"description":s.text=r(t);const e=t.match(/src="(.*?)"/);e&&e[1]&&(s.image=e[1])}l({schema:s,[e]:t})};return(0,s.createElement)("li",(0,i.useBlockProps)(),(0,s.createElement)(i.RichText,{tagName:"strong",value:c,className:"wpseopress-how-to-step-title",onChange:e=>u("title",e),placeholder:(0,e.__)("Type a title","wp-seopress-pro")}),(0,s.createElement)(i.RichText,{tagName:"div",value:p,multiline:!0,className:"wpseopress-how-to-step-description",onChange:e=>u("description",e),placeholder:(0,e.__)("Type a description","wp-seopress-pro")}))},save:function(e){let{attributes:t}=e;const{title:o,description:r}=t;return(0,s.createElement)("li",i.useBlockProps.save(),o&&(0,s.createElement)(i.RichText.Content,{tagName:"strong",id:(0,a.cleanForSlug)(o),value:o,className:"wpseopress-how-to-step-title"}),(0,s.createElement)(i.RichText.Content,{tagName:"div",value:r,className:"wpseopress-how-to-step-description"}))}});var c=window.wp.components,p=t=>{let{attributes:o,updateField:r}=t;const{durationDays:n,durationHours:a,durationMinutes:l,estimatedCost:p,unorderedList:d}=o;return(0,s.createElement)(i.InspectorControls,null,(0,s.createElement)(c.PanelBody,{title:(0,e.__)("Block settings","wp-seopress-pro")},(0,s.createElement)(c.PanelRow,null,(0,s.createElement)(c.CheckboxControl,{label:(0,e.__)("Display as unordered list.","wp-seopress-pro"),checked:d,onChange:e=>r("unorderedList",e)})),(0,s.createElement)(c.PanelRow,null,(0,s.createElement)(c.TextControl,{label:(0,e.__)("Estimated cost","wp-seopress-pro"),value:p,onChange:e=>r("estimatedCost",e)})),(0,s.createElement)(c.PanelRow,{className:"totalTime-controls"},(0,s.createElement)(c.TextControl,{type:"number",min:"0",label:(0,e.__)("Days","wp-seopress-pro"),value:n,onChange:e=>r("durationDays",e)}),(0,s.createElement)(c.TextControl,{type:"number",min:"0",label:(0,e.__)("Hours","wp-seopress-pro"),value:a,onChange:e=>r("durationHours",e)}),(0,s.createElement)(c.TextControl,{type:"number",min:"0",label:(0,e.__)("Minutes","wp-seopress-pro"),value:l,onChange:e=>r("durationMinutes",e)}))))},d=t=>(0,s.createElement)(i.Inserter,{rootClientId:t.clientId,renderToggle:t=>{let{onToggle:o,disabled:r}=t;return(0,s.createElement)(c.Button,{className:"add-step-button",onClick:o,disabled:r,text:(0,e.__)("Add step","wp-seopress-pro"),icon:"insert"})},isAppender:!0}),u=t=>{let{estimatedCost:o}=t;
/* translators: %1$s: Estimated cost */return o?(0,s.createElement)("p",{className:"wpseopress-how-to-estimated-cost"},(0,e.sprintf)((0,e.__)("Estimated cost: %1$s","wp-seopress-pro"),o)):""},m=t=>{let{durationDays:o,durationHours:r,durationMinutes:a}=t;const i=n(o,r,a,"display");return i?(0,s.createElement)("p",{className:"wpseopress-how-to-total-time"},(0,e.sprintf)("Total time: %1$s",i)):""},w=JSON.parse('{"u2":"wpseopress/how-to"}');(0,t.registerBlockType)(w.u2,{title:(0,e.__)("How to","wp-seopress-pro"),description:(0,e.__)("Display a tutorial block.","wp-seopress-pro"),keywords:[(0,e.__)("How to","wp-seopress-pro"),(0,e.__)("Tutorial","wp-seopress-pro")],edit:function(t){let{attributes:a,setAttributes:l,clientId:c}=t;const{description:w,schema:h,durationDays:g,durationHours:E,durationMinutes:_,unorderedList:b,estimatedCost:T}=a,y=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const s={...h,"@context":"https://schema.org","@type":"HowTo",name:(0,o.select)("core/editor").getEditedPostAttribute("title")},a=(0,o.select)("core/editor").getEditedPostAttribute("featured_media");if(a){const e=(0,o.select)("core").getMedia(a),t=e&&e.source_url?e.source_url:"";delete s.image,t&&(s.image=t)}switch(e){case"description":s.description=r(t),""===s.description&&delete s.description;break;case"durationDays":s.totalTime=n(t,E,_,"schema"),s.totalTime||delete s.totalTime;break;case"durationHours":s.totalTime=n(g,t,_,"schema"),s.totalTime||delete s.totalTime;break;case"durationMinutes":s.totalTime=n(g,E,t,"schema"),s.totalTime||delete s.totalTime;break;case"estimatedCost":s.estimatedCost=t,s.estimatedCost||delete s.estimatedCost}l({schema:s,[e]:t})},C=()=>{const e=(0,o.select)("core/block-editor").getBlock(c).innerBlocks||[];let t=[];return e.length&&(t=e.reduce(((e,t)=>(void 0!==t.attributes.schema&&e.push(t.attributes.schema),e)),[])),t},v=(0,o.subscribe)((e=>{const t=(0,o.select)("core/editor").isSavingPost();if((0,o.select)("core/editor").isAutosavingPost()||t)return;const s=(0,o.select)("core/block-editor").isBlockSelected(c),r=(0,o.select)("core/block-editor").hasSelectedInnerBlock(c);(s||r)&&(v(),(()=>{v();const e={...h,"@context":"https://schema.org","@type":"HowTo",name:(0,o.select)("core/editor").getEditedPostAttribute("title"),step:C()};JSON.stringify(h.step)!==JSON.stringify(e.step)&&(v(),l({schema:e}))})())})),k=b?"ul":"ol";return(0,s.createElement)("div",(0,i.useBlockProps)(),(0,s.createElement)(p,{attributes:a,updateField:y}),(0,s.createElement)(i.RichText,{tagName:"div",value:w,multiline:!0,className:"wpseopress-how-to-description",onChange:e=>y("description",e),placeholder:(0,e.__)("Type in a tutorial description or introduction","wp-seopress-pro")}),(0,s.createElement)(u,{estimatedCost:T}),(0,s.createElement)(m,{durationDays:g,durationHours:E,durationMinutes:_}),(0,s.createElement)(k,{className:"wpseopress-how-to-steps"},(0,s.createElement)(i.InnerBlocks,{allowedBlocks:["wpseopress/how-to-step"],renderAppender:()=>(0,s.createElement)(d,{clientId:c})})))},save:function(e){let{attributes:t}=e;const{description:o,schema:r,unorderedList:n,durationDays:a,durationHours:l,durationMinutes:c,estimatedCost:p}=t,d=n?"ul":"ol";return(0,s.createElement)("div",i.useBlockProps.save(),o&&(0,s.createElement)(i.RichText.Content,{tagName:"div",value:o,className:"wpseopress-how-to-description"}),(0,s.createElement)(u,{estimatedCost:p}),(0,s.createElement)(m,{durationDays:a,durationHours:l,durationMinutes:c}),(0,s.createElement)(d,{className:"wpseopress-how-to-steps"},(0,s.createElement)(i.InnerBlocks.Content,null)),(0,s.createElement)("script",{type:"application/ld+json"},JSON.stringify(r)))}})}();