You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
10 lines
99 KiB
JavaScript
10 lines
99 KiB
JavaScript
7 months ago
|
(()=>{var e={4184:(e,t)=>{var r;!function(){"use strict";var o={}.hasOwnProperty;function n(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)){if(r.length){var s=n.apply(null,r);s&&e.push(s)}}else if("object"===i){if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]")){e.push(r.toString());continue}for(var a in r)o.call(r,a)&&r[a]&&e.push(a)}}}return e.join(" ")}e.exports?(n.default=n,e.exports=n):void 0===(r=function(){return n}.apply(t,[]))||(e.exports=r)}()},1474:(e,t,r)=>{var o,n;void 0===(n="function"==typeof(o=function(){var e="undefined"!=typeof window?window:this,t=e.Glider=function(t,r){var o=this;if(t._glider)return t._glider;if(o.ele=t,o.ele.classList.add("glider"),o.ele._glider=o,o.opt=Object.assign({},{slidesToScroll:1,slidesToShow:1,resizeLock:!0,duration:.5,easing:function(e,t,r,o,n){return o*(t/=n)*t+r}},r),o.animate_id=o.page=o.slide=0,o.arrows={},o._opt=o.opt,o.opt.skipTrack)o.track=o.ele.children[0];else for(o.track=document.createElement("div"),o.ele.appendChild(o.track);1!==o.ele.children.length;)o.track.appendChild(o.ele.children[0]);o.track.classList.add("glider-track"),o.init(),o.resize=o.init.bind(o,!0),o.event(o.ele,"add",{scroll:o.updateControls.bind(o)}),o.event(e,"add",{resize:o.resize})},r=t.prototype;return r.init=function(e,t){var r=this,o=0,n=0;r.slides=r.track.children,[].forEach.call(r.slides,(function(e,t){e.classList.add("glider-slide"),e.setAttribute("data-gslide",t)})),r.containerWidth=r.ele.clientWidth;var i=r.settingsBreakpoint();if(t||(t=i),"auto"===r.opt.slidesToShow||void 0!==r.opt._autoSlide){var s=r.containerWidth/r.opt.itemWidth;r.opt._autoSlide=r.opt.slidesToShow=r.opt.exactWidth?s:Math.max(1,Math.floor(s))}"auto"===r.opt.slidesToScroll&&(r.opt.slidesToScroll=Math.floor(r.opt.slidesToShow)),r.itemWidth=r.opt.exactWidth?r.opt.itemWidth:r.containerWidth/r.opt.slidesToShow,[].forEach.call(r.slides,(function(e){e.style.height="auto",e.style.width=r.itemWidth+"px",o+=r.itemWidth,n=Math.max(e.offsetHeight,n)})),r.track.style.width=o+"px",r.trackWidth=o,r.isDrag=!1,r.preventClick=!1,r.move=!1,r.opt.resizeLock&&r.scrollTo(r.slide*r.itemWidth,0),(i||t)&&(r.bindArrows(),r.buildDots(),r.bindDrag()),r.updateControls(),r.emit(e?"refresh":"loaded")},r.bindDrag=function(){var e=this;e.mouse=e.mouse||e.handleMouse.bind(e);var t=function(){e.mouseDown=void 0,e.ele.classList.remove("drag"),e.isDrag&&(e.preventClick=!0),e.isDrag=!1};const r=function(){e.move=!0};var o={mouseup:t,mouseleave:t,mousedown:function(t){t.preventDefault(),t.stopPropagation(),e.mouseDown=t.clientX,e.ele.classList.add("drag"),e.move=!1,setTimeout(r,300)},touchstart:function(t){e.ele.classList.add("drag"),e.move=!1,setTimeout(r,300)},mousemove:e.mouse,click:function(t){e.preventClick&&e.move&&(t.preventDefault(),t.stopPropagation()),e.preventClick=!1,e.move=!1}};e.ele.classList.toggle("draggable",!0===e.opt.draggable),e.event(e.ele,"remove",o),e.opt.draggable&&e.event(e.ele,"add",o)},r.buildDots=function(){var e=this;if(e.opt.dots){if("string"==typeof e.opt.dots?e.dots=document.querySelector(e.opt.dots):e.dots=e.opt.dots,e.dots){e.dots.innerHTML="",e.dots.setAttribute("role","tablist"),e.dots.classList.add("glider-dots");for(var t=0;t<Math.ceil(e.slides.length/e.opt.slidesToShow);++t){var r=document.createElement("button");r.dataset.index=t,r.setAttribute("aria-label","Page "+(t+1)),r.setAttribute("role","tab"),r.className="glider-dot "+(t?"":"active"),e.event(r,"add",{click:e.scrollItem.bind(e,t,!0)}),e.dots.appendChild(r)}}}else e.dots&&(e.dots.innerHTML="")},r.bindArrows=function(){var e=this;e.opt.arrows?["prev","next"].forEach((function(t){var r=e.opt.arrows[t];r&&("string"==typeof r&&(r=document.querySelector(r)),r&&(r._func=r._func||e.scrollItem.bind(e,t),e.event(r,"remove",{click:r._func}),e.event(r,"add",{click:r._func}),e.arrows[t]=r))})):Object.keys(e.arrows).forEach((function(t){var r=e.arrows[t];e.event(r,"remove",{click:r._func})}))},r.updateControls=function(e){var t=thi
|
||
|
(0,_.__)("The current poster image url is %s","web-stories"),l):(0,_.__)("There is no poster image currently selected","web-stories")),w&&y.createElement(Le.Button,{className:"web-stories-embed-poster-remove",onClick:f},(0,_.__)("Remove","web-stories"))))),y.createElement(Le.PanelRow,null,y.createElement(Le.BaseControl,{className:"web-stories-embed-size-control"},y.createElement(Le.BaseControl.VisualLabel,null,(0,_.__)("Story dimensions","web-stories")),y.createElement("div",{className:"web-stories-embed-size-control__row"},y.createElement(Le.TextControl,{type:"number",className:"web-stories-embed-size-control__width",label:(0,_.__)("Width","web-stories"),value:r||"",min:n,max:i,onChange:e=>d({width:parseInt(e)})}),y.createElement(Le.TextControl,{type:"number",className:"web-stories-embed-size-control__height",label:(0,_.__)("Height","web-stories"),value:o||"",min:s,max:a,onChange:e=>d({height:parseInt(e)})})))),y.createElement(Le.PanelRow,null,y.createElement(Le.BaseControl,null,y.createElement(Le.ToggleControl,{label:(0,_.__)("Display as preview","web-stories"),checked:u,onChange:b,help:(0,_.__)("Displays the story poster that opens the story in a lightbox on click","web-stories")}))))))},je=EmbedControls,ze=()=>y.createElement("div",{className:"wp-block-web-stories-embed is-loading"},y.createElement(Le.Spinner,null),y.createElement("p",null,(0,_.__)("Embedding…","web-stories"))),We=window.wp.url,De=window.wp.notices;__webpack_require__(7602),__webpack_require__(928),__webpack_require__(3476);const Fe=window.wp.date;const He=function ItemOverlay(e){let{isSelected:t,story:r,addSelectedStory:o,removeSelectedStory:n,isSelectable:i}=e;const s=(0,Te.useCallback)((e=>{e.preventDefault(),t||o(r)}),[o,r,t]),a=(0,Te.useCallback)((e=>{e.preventDefault(),t?n(r):o(r)}),[n,o,r,t]);return i?y.createElement("button",{type:"button",className:t?"web-stories-story-preview-card__overlay item-selected":"web-stories-story-preview-card__overlay",onClick:s},t&&y.createElement("div",{className:"item-selected-icon"},y.createElement(Le.Icon,{className:"item-selected-icon-check",icon:"saved"}),y.createElement(Le.Icon,{className:"item-selected-icon-minus",icon:"minus",onClick:a}),y.createElement(Le.VisuallyHidden,null,(0,_.__)("Deselect","web-stories")))):y.createElement("div",{className:"web-stories-story-preview-card__overlay"})},$e=()=>{};const Ve=function StoryPreview(e){let{story:t,isSelected:r,addSelectedStory:o=$e,removeSelectedStory:n=$e,isSelectable:i=!0}=e;const s=(0,Fe.getSettings)().formats.date,a=(0,Fe.dateI18n)(s,t.created),l=(0,Te.useMemo)((()=>{if(!a)return null;switch(t.status){case"publish":return(0,_.sprintf)(/* translators: %s: published date */
|
||
|
(0,_.__)("Published %s","web-stories"),a);case"future":return(0,_.sprintf)(/* translators: %s: future publish date */
|
||
|
(0,_.__)("Scheduled %s","web-stories"),a);default:return(0,_.sprintf)(/* translators: %s: last modified date */
|
||
|
(0,_.__)("Modified %s","web-stories"),a)}}),[t.status,a]),c=t.meta.web_stories_poster?.url,u=t._embedded?.["wp:featuredmedia"]?.[0]?.source_url,d=c||u,p=t.title.raw||t.title.rendered;return y.createElement("div",{className:"web-stories-story-preview-card"},y.createElement("div",{className:"web-stories-story-preview-card__poster"},y.createElement(He,{isSelected:r,story:t,addSelectedStory:o,removeSelectedStory:n,isSelectable:i}),d&&y.createElement("img",{src:d,alt:"",width:640,height:853})),y.createElement("div",{className:"web-stories-story-preview-card__label"},y.createElement("div",{className:"web-stories-story-preview-card__title"},y.createElement(Te.RawHTML,null,""===p?(0,_.__)("Untitled","web-stories"):p)),t._embedded?.author?.[0]?.name&&y.createElement("div",null,t._embedded?.author?.[0]?.name),y.createElement("div",null,l)))},qe=[{label:(0,_.__)("Name","web-stories"),value:"name"},{label:(0,_.__)("Date Created","web-stories"),value:"date"},{label:(0,_.__)("Last Modified","web-stories"),value:"modified"},{label:(0,_.__)("Created By","web-stories"),value:"author"}];function AuthorSearch(e){let{label:t,options:r,onFilterValueChange:o,onChange:n,value:i}=e;return y.createElement(Le.ComboboxControl,{label:t,options:r,onFilterValueChange:o,onChange:n,value:i,className:"web-stories-story-picker-filter__combobox"})}function KeywordSearch(e){let{label:t,options:r,onFilterValueChange:o,onChange:n,value:i}=e;return y.createElement(Le.ComboboxControl,{label:t,options:r,onFilterValueChange:o,onChange:n,value:i,className:"web-stories-story-picker-filter__combobox"})}const Ue=function SelectStories(e){let{stories:t=[],selectedStories:r=[],setSelectedStories:o,hasAllStories:n,isLoading:i,fetchStories:s,maxNumOfStories:a}=e;const[l,c]=(0,Te.useState)([]),[u,d]=(0,Te.useState)(""),[p,m]=(0,Te.useState)(""),[h,f]=(0,Te.useState)("desc"),[b,w]=(0,Te.useState)("modified"),g=(0,Te.useRef)(1),{authors:v}=(0,Ne.useSelect)((e=>{const{getUsers:t,getPostType:r}=e(Re.store),o=r("web-story")?.capabilities.edit_posts;return{authors:o?t({search:p,capabilities:o}):[]}}),[p]),S=(0,Te.useCallback)((()=>{s({author:l?.id||void 0,search:u||void 0,order:h,orderBy:b,page:g.current})}),[u,l,s,h,b]);(0,Te.useEffect)((()=>{g.current=1,S()}),[u,l,h,b,S]);const k=(0,Te.useCallback)((()=>{g.current++,S()}),[S]),x=(0,E.useDebounce)((e=>{d(e)}),300),C=(0,E.useDebounce)((e=>{m(e),c(""===e?null:v.find((t=>t.id===Number(e))))}),300),T=(0,Te.useCallback)((e=>{c(""===e?null:v.find((t=>t.id===Number(e))))}),[v,c]),O=(0,Te.useCallback)((e=>{w(e),f(["title","author"].includes(e)?"asc":"desc")}),[f,w]),L=(0,Te.useMemo)((()=>(v??[]).filter((e=>{let{name:t}=e;return Boolean(t?.trim().length)})).map((e=>{let{id:t,name:r}=e;return{label:r,value:t}}))),[v]),I=(0,Te.useMemo)((()=>t.filter((e=>{let{title:t}=e;return Boolean(t?.rendered?.trim()?.length)})).map((e=>{let{id:t,title:r}=e;return{label:r.rendered,value:t}}))),[t]),N=(0,Te.useMemo)((()=>r.map((e=>e.id))),[r]),M=(0,Te.useCallback)((e=>{N.includes(e.id)||(1!==a?r.length>=a||o([...r,e]):o([e]))}),[o,r,N,a]),R=(0,Te.useCallback)((e=>{o(r.filter((t=>t.id!==e.id)))}),[r,o]);return y.createElement(y.Fragment,null,y.createElement("div",{className:"web-stories-story-picker-filter"},y.createElement("div",{className:"web-stories-story-picker-filter__search-container"},y.createElement("div",{className:"web-stories-story-picker-filter__search-inner"},y.createElement(KeywordSearch,{label:(0,_.__)("Search Stories","web-stories"),options:I,onFilterValueChange:x,onChange:x,value:u})),y.createElement(AuthorSearch,{label:(0,_.__)("Search by Author","web-stories"),options:L,onFilterValueChange:C,onChange:T,value:l?.id}),y.createElement("div",null,y.createElement(Le.SelectControl,{label:(0,_.__)("Sort","web-stories"),options:qe,value:b,onChange:O})))),!t.length&&u&&y.createElement("p",null,(0,_.sprintf)(/* translators: %s: search term. */
|
||
|
(0,_.__)('Sorry, we couldn\'t find any results matching "%s"',"web-stories"),u)),!t.length&&!u&&y.createElement("p",null,(0,_.__)("Sorry, we couldn't find any results","web-stories")),t.length>=1&&y.createElement("div",{role:"list","aria-label":(0,_.__)("Viewing Stories","web-stories"),className:"web-stories-story-picker-filter__grid"},t.map((e=>{const t=N.includes(e.id);return y.createElement("div",{key:e.id,role:"listitem",className:"web-stories-story-picker-filter__grid_item"},y.createElement(Ve,{story:e,isSelected:t,addSelectedStory:M,removeSelectedStory:R}))}))),y.createElement("div",{className:"web-stories-story-picker-filter__load_more"},i&&y.createElement(Le.Spinner,null),!n&&t.length>0&&!i&&y.createElement(Le.Button,{variant:"primary",className:"is-primary",onClick:k},(0,_.__)("Load More","web-stories"))))};const Ge=function SortStories(e){let{selectedStories:t,setSelectedStories:r}=e;const[o,n]=(0,Te.useState)(),[i,s]=(0,Te.useState)(),a=(0,Te.useCallback)(((e,o)=>{const n=t.map((e=>e.id));n.splice(o,0,n.splice(e,1).pop()),r(n.map((e=>t.find((t=>t.id===e)))))}),[t,r]),l=(0,E.useThrottle)(((e,t)=>{e.preventDefault(),t.classList.add("web-stories-story-picker-show-drag-inserter");const r=t.getBoundingClientRect();Math.abs(e.clientX-r.x)>Math.abs(e.clientX-(r.x+r.width))?t.classList.add("web-stories-story-picker-show-drag-inserter-right"):t.classList.remove("web-stories-story-picker-show-drag-inserter-right");const o=Number(t.children[0].dataset.order);n(o)}));return y.createElement("div",{role:"list","aria-label":(0,_.__)("Sorting Stories","web-stories"),className:"web-stories-story-picker-filter__grid"},t.map(((e,r)=>y.createElement("div",{key:e.id,onDragOver:e=>{l(e,e.currentTarget)},onDragLeave:e=>{e.preventDefault(),l.cancel();e.target.closest(".droppable").classList.remove("web-stories-story-picker-show-drag-inserter","web-stories-story-picker-show-drag-inserter-right")},onDrop:e=>{if(e.preventDefault(),e.stopPropagation(),l.cancel(),i){const e=t.findIndex((e=>e.id===i));a(e,o)}e.target.closest(".droppable").classList.remove("web-stories-story-picker-show-drag-inserter","web-stories-story-picker-show-drag-inserter-right")},className:"droppable"},y.createElement("div",{"data-order":r,id:`draggable-story-${e.id}`},y.createElement(Le.Draggable,{elementId:`draggable-story-${e.id}`},(t=>{let{onDraggableStart:o,onDraggableEnd:n}=t;return y.createElement("div",{key:e.id,role:"listitem",className:"web-stories-story-picker-filter__grid_item",onDragStart:t=>{s(e.id),o(t)},onDragEnd:e=>{n(e)},"data-order":r,draggable:!0},y.createElement(Ve,{story:e,isSelectable:!1}))})))))))},{config:{api:{stories:Ze}}}=window.webStoriesBlockSettings;const Xe=function StoryPicker(e){let{selectedStories:t,setSelectedStories:r,closeStoryPicker:o,isSortingStories:n=!1,setIsSortingStories:i=(()=>{}),maxNumOfStories:s}=e;const{createErrorNotice:a}=(0,Ne.useDispatch)(De.store),[l,c]=(0,Te.useState)(t),[u,d]=(0,Te.useState)(!0),[p,m]=(0,Te.useState)("idle"),[h,f]=(0,Te.useState)([]),[b,w]=(0,Te.useState)([]),g=(0,Te.useCallback)((()=>{o(),r(l)}),[o,r,l]),v=(0,Te.useCallback)((async function(){let{orderby:e="modified",order:t="desc",search:r,author:o,page:n=1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const i={_embed:"author,wp:featuredmedia",context:"edit",_web_stories_envelope:!0,search:r,author:o,page:n,per_page:10,orderby:e,order:t,status:"publish"};try{m("loading");const e=await Oe({path:(0,We.addQueryArgs)(Ze,i)}),t=Number(e?.headers?.["X-WP-TotalPages"]);w(n===t),f((t=>1===n?e.body:[...t,...e.body]))}catch(e){m("error"),a((0,_.__)("Unable to load stories","web-stories"),{type:"snackbar"})}finally{m("idle"),d(!1)}}),[a]);(0,Te.useEffect)((()=>{u&&v()}),[u,v]);const E=1===s?(0,_.__)("Selected Story","web-stories"):(0,_.__)("Selected Stories","web-stories");return y.createElement(Le.Modal,{title:E,onRequestClose:o,shouldCloseOnClickOutside:!1,className:"web-stories-story-picker-modal"},y.createElement("div",{className:"web-stories-story-picker-modal__content"},u?y.createElement(Ae,null,(0,_.__)("Loading Stories…","web-sto
|
||
|
(0,_._n)("%1$d of %2$d story selected","%1$d of %2$d stories selected",s,"web-stories"),l.length,s))),y.createElement("div",{className:"web-stories-story-picker-modal__footer--right"},s>1&&(n?y.createElement(Le.Button,{onClick:()=>i(!1)},(0,_.__)("Select Stories","web-stories")):y.createElement(Le.Button,{onClick:()=>i(!0),disabled:l.length<2},(0,_.__)("Rearrange Stories","web-stories"))),y.createElement(Le.Button,{isPrimary:!0,disabled:!l.length,onClick:g},(0,_.__)("Update","web-stories")))))},Qe=window.wp.primitives,Ke=(0,y.createElement)(Qe.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24"},(0,y.createElement)(Qe.Path,{d:"M6.734 16.106l2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.157 1.093-1.027-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734z"})),Ye=e=>{let{url:t,onChange:r,onSubmit:o,onClose:n}=e;return y.createElement(Me.URLPopover,{onClose:n},y.createElement("form",{className:"block-editor-media-placeholder__url-input-form","data-testid":"embed-placeholder-form",onSubmit:o},y.createElement("input",{className:"block-editor-media-placeholder__url-input-field",type:"url","aria-label":(0,_.__)("Story URL","web-stories"),placeholder:(0,_.__)("Paste or type URL","web-stories"),onChange:r,value:t}),y.createElement(Le.Button,{className:"block-editor-media-placeholder__url-input-submit-button",icon:Ke,label:(0,_.__)("Embed","web-stories"),type:"submit"})))},Je=e=>{let{icon:t,label:r,value:o,onSubmit:n,cannotEmbed:i=!1,errorMessage:s,selectedStories:a=[],setSelectedStories:l}=e;const[c,u]=(0,Te.useState)(o),[d,p]=(0,Te.useState)(!1),[m,h]=(0,Te.useState)(!1),f=(0,Te.useCallback)((()=>{h(!1)}),[]),b=()=>p(!1),w=a.length>0;return y.createElement(y.Fragment,null,y.createElement(Le.Placeholder,{icon:y.createElement(Me.BlockIcon,{icon:t,showColors:!0}),label:r,className:"wp-block-web-stories-embed",instructions:(0,_.__)("Select an existing story from your site, or add one with a URL.","web-stories")},y.createElement(y.Fragment,null,y.createElement(Le.Button,{isPrimary:!0,onClick:()=>h(!0)},w?(0,_.__)("Replace Story","web-stories"):(0,_.__)("Select Story","web-stories")),y.createElement("div",{className:"block-editor-media-placeholder__url-input-container"},y.createElement(Le.Button,{className:"block-editor-media-placeholder__button",onClick:()=>p(!0),isPressed:d,variant:"tertiary"},!w&&o?(0,_.__)("Replace URL","web-stories"):(0,_.__)("Insert from URL","web-stories")),d&&y.createElement(Ye,{url:c,onChange:e=>{u(e.target.value)},onSubmit:e=>{e.preventDefault(),b(),n(c)},onClose:b}))),i&&y.createElement("div",{className:"components-placeholder__error"},y.createElement("div",{className:"components-placeholder__instructions"},(0,_.__)("Sorry, this content could not be embedded.","web-stories"),s&&y.createElement(y.Fragment,null," ",(0,_.sprintf)(/* translators: %s: error message. */
|
||
|
(0,_.__)("Reason: %s.","web-stories"),s))))),m&&y.createElement(Xe,{closeStoryPicker:f,maxNumOfStories:1,selectedStories:a,setSelectedStories:l}))};const et=(0,Te.forwardRef)((function StoryPlayer(e,t){let{url:r,title:o,poster:n,width:i,height:s}=e;return y.createElement("amp-story-player",{ref:t,style:{width:i?`${i}px`:void 0,height:s?`${s}px`:void 0},"data-testid":"amp-story-player"},y.createElement("a",{href:r},n?y.createElement("img",{alt:o,src:n,width:i,height:s,"data-amp-story-player-poster-img":!0}):o))}));const tt=(0,Te.forwardRef)((function EmbedPreview(e,t){let{url:r,title:o,poster:n,isSelected:i,width:s,height:a}=e;const[l,c]=(0,Te.useState)(!1);(0,Te.useEffect)((()=>{!i&&l&&c(!1)}),[i,l,c]);const u=(0,Te.useCallback)((()=>c(!0)),[c]);return y.createElement("div",{className:"web-stories-embed-preview wp-block-embed__wrapper",style:{"--aspect-ratio":0!==s?a/s:1,"--width":`${s}px`,"--height":`${a}px`}},y.createElement(et,{url:r,title:o,poster:n,ref:t,onFocus:u}),!l&&y.createElement("div",{className:"web-stories-embed-preview-overlay","data-testid":"embed-preview-overlay",onMouseUp:u}))}));const rt=function Singleton(e){let{title:t,poster:r,width:o,height:n}=e;return y.createElement("div",{className:"web-stories-singleton"},y.createElement("div",{className:"wp-block-embed__wrapper",style:{"--aspect-ratio":0!==n?o/n:1,"--width":`${o}px`,"--height":`${n}px`}},y.createElement("div",{className:"web-stories-singleton-poster"},r?y.createElement("img",{src:r,alt:t}):y.createElement("div",{className:"web-stories-singleton-poster-placeholder"},y.createElement("span",null,t))),y.createElement("div",{className:"web-stories-singleton-overlay"},t&&y.createElement(Te.RawHTML,{className:"story-content-overlay__title"},t))))};const ot=(0,Ie.withViewportMatch)({_isResizable:"medium"})((function StoryEmbedEdit(e){let{attributes:t,setAttributes:r,className:o,isSelected:n,_isResizable:i,context:s={}}=e;const{url:a="",width:l=360,height:c=600,align:u="none",poster:d,title:p,stories:m=[],previewOnly:h=!1}=t,{postId:f,queryId:b}=s,w=Number.isFinite(b),[v,S]=(0,Te.useState)(!1),[k,x]=(0,Te.useState)(w?void 0:a),[C,T]=(0,Te.useState)(!1),[O,L]=(0,Te.useState)(!1),[I,N]=(0,Te.useState)({}),[M,R]=(0,Te.useState)(!1),[A,P]=(0,Te.useState)(w?[f]:m),[B,j]=(0,Te.useState)([]),z=C,W=!k||!a||v||M,D=E.useViewportMatch?E.useViewportMatch("medium"):i,F=(0,Te.useRef)();(0,Te.useEffect)((()=>{t.stories.toString()!==A.toString()&&r({stories:A})}),[t.stories,r,A]),(0,Te.useEffect)((()=>{A.length&&!B.length&&L(!0)}),[A,B,L]),(0,Te.useEffect)((()=>{x(a),g("story_embedded")}),[a]),(0,Te.useEffect)((()=>{g("story_poster_changed")}),[d]),(0,Te.useEffect)((()=>{if(F.current&&window.AmpStoryPlayer){new window.AmpStoryPlayer(window,F.current).load()}}),[z,W,D,h]);const H=(0,Te.useCallback)((async e=>{if(e)try{T(!0);const t=encodeURIComponent(new URL(e).toString()),o=await Oe({path:`web-stories/v1/embed?url=${t}`});R(!("string"==typeof o?.title)),N(o),r({url:e})}catch(e){e instanceof TypeError||N(e),R(!0)}finally{T(!1)}}),[r]);(0,Te.useEffect)((()=>{(I?.title||I?.poster)&&r({title:I?.title,poster:I?.poster})}),[a,r,I?.title,I?.poster]);const $=(0,Te.useCallback)((e=>{j(e),P(e.map((e=>e.id)));const t=e?.[0],o=t?.link;N({title:t?.title?.rendered,poster:t?._embedded?.["wp:featuredmedia"]?.[0]?.source_url}),x(o),S(!1),R(!1),r({url:o})}),[j,r]),V=(0,Te.useCallback)((e=>{j([]),P([]),S(!1),R(!1),x(e),e!==a&&H(e)}),[a,H]),q=(0,Te.useCallback)((()=>{S(!0)}),[]),{isRTL:U,maxWidth:G}=(0,Ne.useSelect)((e=>{const{getSettings:t}=e(Me.store),r=t();return{isRTL:r.isRTL,maxWidth:r.maxWidth}}),[]),{toggleSelection:Z}=(0,Ne.useDispatch)(Me.store);if(z)return y.createElement(ze,null);const X=(0,_.__)("Single Story","web-stories");if(W)return O?y.createElement(Pe,{icon:y.createElement(BlockIcon,null),label:X,selectedStoryIds:A,setSelectedStories:$,setIsFetching:L}):y.createElement(Je,{icon:y.createElement(BlockIcon,null),label:X,value:k,onSubmit:V,cannotEmbed:M,errorMessage:I?.message,selectedStories:B,setSelectedStories:$});const Q=l/c,K=l<c?20:20*Q,Y=c<l?20:20/Q;if(!D)return y.c
|
||
|
(0,_.__)("By %s","web-stories"),n)),a&&y.createElement("time",{dateTime:(0,Fe.format)("c",i),className:"story-content-overlay__date"},(0,_.sprintf)(/* translators: %s: publish date. */
|
||
|
(0,_.__)("On %s","web-stories"),(0,Fe.dateI18n)(m,i)))))},{config:{archiveURL:Mt}}=window.webStoriesBlockSettings;const Rt=function StoriesPreview(e){const{attributes:{align:t,viewType:r,circleSize:o,imageAlignment:n,fieldState:i,numOfColumns:s},viewAllLabel:a,stories:l}=e,c=(0,Te.useRef)(null),u=(0,Te.useRef)(null),d=(0,Te.useRef)(null),p=nt({"is-style-default":!i.show_sharp_corners,"is-style-squared":i.show_sharp_corners,"is-carousel":mt===r||ht===r,[`is-view-type-${r}`]:r,[`columns-${s}`]:dt===r&&s,[`align${t}`]:t,"has-archive-link":i.show_archive_link},"web-stories-list"),StoriesLoop=()=>l.map((e=>{const t=e.meta.web_stories_poster?.url,r=e._embedded?.["wp:featuredmedia"]?.[0]?.source_url,s=t||r;return y.createElement(Nt,{key:e.id,url:e.link,title:e.title.rendered,excerpt:e.excerpt.rendered?e.excerpt.rendered:"",date:e.date_gmt,author:e._embedded.author[0].name,poster:s,imageAlignment:n,isShowingAuthor:i.show_author,isShowingDate:i.show_date,isShowingTitle:i.show_title,isShowingExcerpt:i.show_excerpt,circleSize:o})}));return(0,Te.useEffect)((()=>{if(!c.current)return;const e=c.current.querySelector(".web-stories-list__story");if(!e)return;const t=window.getComputedStyle(e),r=parseFloat(t.width)+(parseFloat(t.marginLeft)+parseFloat(t.marginRight)),o=new It(c.current,{slidesToShow:"auto",slidesToScroll:"auto",itemWidth:r,duration:.25,skipTrack:!0,scrollLock:!0,arrows:{prev:d.current,next:u.current}});o.resize();const n=r*l.length;o.trackWidth=n,o.track.style.width=`${n}px`}),[l.length,r,o]),y.createElement("div",{className:p,style:{"--ws-circle-size":"circles"===r&&o?`${o}px`:void 0}},y.createElement("div",{className:"web-stories-list__inner-wrapper"},mt===r||ht===r?y.createElement(y.Fragment,null,y.createElement("div",{className:"web-stories-list__carousel",ref:c},y.createElement("div",{className:"glider-track"},y.createElement(StoriesLoop,null))),y.createElement("div",{"aria-label":(0,_.__)("Previous","web-stories"),className:"glider-prev",ref:d}),y.createElement("div",{"aria-label":(0,_.__)("Next","web-stories"),className:"glider-next",ref:u})):y.createElement(StoriesLoop,null)),i.show_archive_link&&Mt&&y.createElement("div",{className:"web-stories-list__archive-link"},y.createElement("a",{target:"__blank",href:Mt},a)))};const At=function LatestStoriesEdit(e){let{attributes:t,setAttributes:r}=e;const{numOfStories:o,order:n,orderby:i,archiveLinkLabel:s,authors:a,taxQuery:l}=t,{isFetchingStories:c,fetchedStories:u}=(0,Ne.useSelect)((e=>{const{getEntityRecords:t,isResolving:r}=e(Re.store),o={per_page:20,_embed:"author,wp:featuredmedia",orderby:i||"modified",order:n||"desc",author:a||void 0,...l};return{fetchedStories:t("postType","web-story",o)||[],isFetchingStories:r("postType","web-story",o)||!1}}),[n,i,a,l]),d=s||(0,_.__)("View All Stories","web-stories"),p=u.length>o?u.slice(0,o):u;return y.createElement(y.Fragment,null,y.createElement(Tt,{attributes:t,setAttributes:r}),c&&y.createElement(Ot,null),!c&&Boolean(p?.length)&&y.createElement(Rt,{attributes:t,stories:p,viewAllLabel:d}),!c&&!p?.length&&y.createElement(Le.Placeholder,{icon:y.createElement(Me.BlockIcon,{icon:y.createElement(BlockIcon,null),showColors:!0}),label:(0,_.__)("Latest Stories","web-stories"),className:"wp-block-web-stories-embed",instructions:(0,_.__)("No stories found.","web-stories")},y.createElement(Le.Button,{href:(0,We.addQueryArgs)("post-new.php",{post_type:"web-story"}),isLink:!0},(0,_.__)("Create New Story","web-stories"))))},{config:{maxNumOfStories:Pt}}=window.webStoriesBlockSettings,Bt=e=>{let{icon:t,label:r,selectedStories:o,setSelectedStories:n}=e;const[i,s]=(0,Te.useState)(!1),[a,l]=(0,Te.useState)(!1),c=()=>s(!0),u=(0,Te.useCallback)((()=>{s(!1),l(!1)}),[]),d=(0,Te.useCallback)((()=>{l(!0),c()}),[]);return y.createElement(y.Fragment,null,y.createElement(Me.BlockControls,{group:"other"},Boolean(o?.length)&&(Le.ToolbarButton?y.createElement(y.Fragment,null,y.createElement(Le.ToolbarButton,{"aria-expanded":i,"aria-haspopup":"true",onClick:c},(0,_.__)("Select","web-stories")),y.createElement(Le.ToolbarButton,{"aria-expanded":i,"aria-ha
|