(()=>{"use strict";var e,t,a,r={58979:(e,t,a)=>{a.d(t,{useKeyDownEffect:()=>i});a(67294),a(41792);var r=a(69845),n=a(65583),l=a(90180);function o(e,t,a,o,i){const{keys:s}=(0,r.useContext)(n.default),c=(0,r.useBatchingCallback)(o,i||[]);(0,r.useEffect)((()=>{const r=(0,l.getNodeFromRefOrNode)(e);if(!r)return;if(r.nodeType!==Node.ELEMENT_NODE&&r.nodeType!==Node.DOCUMENT_NODE)throw new Error("only an element or a document node can be used");const n=(0,l.resolveKeySpec)(s,t);if(1===n.key.length&&""===n.key[0])return;const o=(0,l.getOrCreateMousetrap)(r),i=(0,l.createKeyHandler)(r,n,c);return o.bind(n.key,i,a),()=>{o.unbind(n.key,a)}}),[c,s])}function i(e,t,a,r){o(e,t,"keydown",a,r)}},90180:(e,t,a)=>{a.d(t,{createKeyHandler:()=>u,getNodeFromRefOrNode:()=>c,getOrCreateMousetrap:()=>s,prettifyShortcut:()=>f,resolveKeySpec:()=>d});a(41792);var r=a(42441),n=a.n(r);const l="__WEB_STORIES_MT__",o=["submit","button","checkbox","radio","image","file","range","reset","hidden"],i=["submit","button","checkbox","radio","image","file","reset"];function s(e){return e[l]||(e[l]=new(n())(e))}function c(e){return e&&"current"in e?e.current:e}function d(e,t){const a="string"==typeof t||Array.isArray(t)?{key:t}:t,{key:r,shift:n=!1,repeat:l=!0,clickable:o=!0,editable:i=!1,dialog:s=!1,allowDefault:c=!1}=a,d=function(e,t){if(!t)return e;return e.concat(e.map((e=>`shift+${e}`)))}((new Array).concat(r).map((t=>e[t]||t)).flat(),n);return{key:d,shift:n,clickable:o,repeat:l,editable:i,dialog:s,allowDefault:c}}function u(e,t,a){let{repeat:r,editable:n,clickable:l,dialog:s,allowDefault:c=!1}=t;return t=>{const{repeat:d,target:u}=t;if((r||!d)&&(n||!function(e){let{tagName:t,isContentEditable:a,type:r,...n}=e;if("readOnly"in n&&!0===n.readOnly)return!1;if(a||"TEXTAREA"===t)return!0;if("INPUT"===t)return!o.includes(r);return!1}(u))&&(l||!function(e){let{tagName:t,type:a}=e;if(["BUTTON","A"].includes(t))return!0;if("INPUT"===t)return i.includes(a);return!1}(u))&&(s||!function(e,t){if(1!==e.nodeType)return!1;const a=e.closest('dialog,[role="dialog"]');return a&&t!==a&&t.contains(a)}(u,e)))return a(t),c}}function p(){const{platform:e}=window.navigator;return e.includes("Mac")||["iPad","iPhone"].includes(e)}function m(e){const t=p();return{alt:t?"⌥":"Alt",ctrl:t?"^":"Ctrl",mod:t?"⌘":"Ctrl",cmd:"⌘",shift:t?"⇧":"Shift"}[e]||e}function f(e){const t=p()?"":"+";return e.toLowerCase().replace("alt",m("alt")).replace("ctrl",m("ctrl")).replace("mod",m("mod")).replace("cmd",m("cmd")).replace("shift",m("shift")).replace("left","←").replace("up","↑").replace("right","→").replace("down","↓").replace("delete","⌫").replace("enter","⏎").split("+").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(t)}},28395:(e,t,a)=>{a.d(t,{Placement:()=>n,PopupContainer:()=>o,RTL_PLACEMENT:()=>l});var r=a(12788);let n=function(e){return e.Top="top",e.TopStart="top-start",e.TopEnd="top-end",e.Bottom="bottom",e.BottomStart="bottom-start",e.BottomEnd="bottom-end",e.Right="right",e.RightStart="right-start",e.RightEnd="right-end",e.Left="left",e.LeftStart="left-start",e.LeftEnd="left-end",e}({});const l={[n.Top]:n.Top,[n.TopStart]:n.TopStart,[n.TopEnd]:n.TopEnd,[n.Bottom]:n.Bottom,[n.BottomEnd]:n.BottomEnd,[n.BottomStart]:n.BottomStart,[n.Right]:n.Left,[n.RightStart]:n.LeftStart,[n.RightEnd]:n.LeftEnd,[n.Left]:n.Right,[n.LeftStart]:n.RightStart,[n.LeftEnd]:n.RightEnd},o=r.default.div.withConfig({displayName:"constants__PopupContainer",componentId:"sc-1f3rwe8-0"})(["/*! @noflip */ "," /*! @noflip */ left:0px;top:0px;position:fixed;",";max-height:",";"],(e=>{let{$offset:{x:t,y:a,width:r},fillWidth:n,transforms:l="",zIndex:o,maxWidth:i}=e;const s={};return n&&(i?s.minWidth=`${r}px`:s.width=`${r}px`),i&&!s.width&&(s.maxWidth=`${i}px`),{transform:`translate(${t}px, ${a}px) ${l}`,...s,zIndex:o}}),(e=>{let{noOverFlow:t}=e;return t?"":"overflow-y: auto;"}),(e=>{let{topOffset:t=0}=e;return`calc(100vh - ${t}px)`}))},1782:(e,t,a)=>{a.d(t,{DEFAULT_ARIA_CLEAR_LABEL:()=>o,DEFAULT_ARIA_INPUT_LABEL:()=>i,DEFAULT_PLACEHOLDER:()=>l,DEFAULT_POPUP_FILL_WIDTH:()=>n,Z_INDEX:()=>s});var r=a(36823);const n=276,l=(0,r.__)("Search","web-stories"),o=(0,r.__)("Clear Search","web-stories"),i=(0,r.__)("Search","web-stories"),s={CLEAR_BUTTON:5}},67391:(e,t,a)=>{a.d(t,{fullSizeAbsolute:()=>n});var r=a(12788);const n=(0,r.css)(["position:absolute;top:0;right:0;bottom:0;left:0;"]);(0,r.css)(["position:relative;top:0;left:0;height:100%;width:100%;"])},69845:(e,t,a)=>{a.d(t,{Fragment:()=>l.Fragment,StrictMode:()=>l.StrictMode,cloneElement:()=>l.cloneElement,createContext:()=>n.createContext,createElement:()=>l.createElement,createPortal:()=>o.createPortal,createRef:()=>l.createRef,forwardRef:()=>l.forwardRef,identity:()=>n.identity,memo:()=>l.memo,render:()=>o.render,useBatchingCallback:()=>i.default,useCallback:()=>l.useCallback,useCombinedRefs:()=>s.default,useContext:()=>n.useContext,useContextReact:()=>l.useContext,useContextSelector:()=>c.default,useDebouncedCallback:()=>r.useDebouncedCallback,useEffect:()=>l.useEffect,useFocusOut:()=>d.default,useLayoutEffect:()=>l.useLayoutEffect,useMemo:()=>l.useMemo,usePrevious:()=>u.default,useReducer:()=>l.useReducer,useRef:()=>l.useRef,useResizeEffect:()=>p.default,useState:()=>l.useState});var r=a(24697),n=(a(49349),a(35389)),l=a(67294),o=a(73935),i=a(12439),s=a(81967),c=a(14714),d=a(94547),u=a(2780),p=a(13039);a(97762);a(52583)},36382:(e,t,a)=>{a.d(t,{disableTracking:()=>o,enableTracking:()=>n.default,getTimeTracker:()=>m.default,initializeTracking:()=>r.default,trackClick:()=>s.default,trackError:()=>c.default,trackEvent:()=>d.default,trackScreenView:()=>p});var r=a(49388),n=a(57714),l=a(60946);const o=function(){l.config.trackingEnabled=!1};var i=a(49379),s=a(36864),c=a(68729),d=a(5532);var u=a(87438);const p=async function(e){if(!await(0,i.default)())return Promise.resolve();const t={screen_name:e};return(0,u.default)("screen_view",t)};var m=a(26962)},12014:(e,t,a)=>{var r={};a.r(r),a.d(r,{createStoryFromTemplate:()=>_i,duplicateStory:()=>yi,fetchStories:()=>gi,getAuthors:()=>Ei,getProducts:()=>vi,getTaxonomies:()=>Si,getTaxonomyTerms:()=>wi,trashStory:()=>hi,updateStory:()=>bi});var n=a(67294);a.p=window.webStories.publicPath;var l=a(36823);for(const e of window?.webStories?.localeData||[])(0,l.setLocaleData)(e);var o=a(35575),i=a(56394),s=a(68114),c=a(5488),d=a(40132),u=a(97222),p=a(61265),m=a(12788),f=a(14194),g=a(87948),h=a(69845);const b=(0,h.createContext)({isRTL:!1,userId:0,locale:{},newStoryURL:"",cdnURL:"",version:"",capabilities:{},canViewDefaultTemplates:!1,flags:{},apiCallbacks:{},leftRailSecondaryNavigation:[],styleConstants:{topOffset:0,leftOffset:0},containerId:""});const _=function ConfigProvider(e){let{config:t,children:a}=e;return n.createElement(b.Provider,{value:t},a)};const y=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.identity;return(0,h.useContextSelector)(b,e)};a(67602),a(30005);var E=a(36382),S=a(38999);const w="creating_story_from_template",v="create_story_from_template_success",T="create_story_from_template_failure",C="loading_stories",I="fetch_stories_success",k="fetch_stories_failure",L="update_story",A="update_story_failure",x="trash_story",O="trash_story_failure",D="duplicate_story",N="duplicate_story_failure",P={error:{},isLoading:!1,stories:{},storiesOrderById:[],totalStoriesByStatus:{},totalPages:null};var R,B;a(53476),a(31107),a(15716),a(33442),a(61964),a(69878),a(52915),a(97895),a(22275);function M(){return M=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{title:t,titleId:a,...r}=e;return n.createElement("svg",M({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,R||(R=n.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:10,d:"M12.5 3v3M22 12.5h-3M12.5 22v-3M3 12.5h3M12.5 22a9.5 9.5 0 1 0 0-19 9.5 9.5 0 0 0 0 19Z"})),B||(B=n.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:10,d:"M15.851 8.492a.5.5 0 0 1 .657.657l-2.13 4.967a.5.5 0 0 1-.262.263L9.15 16.508a.5.5 0 0 1-.657-.657l2.13-4.967a.5.5 0 0 1 .262-.263l4.967-2.129Z"})))},U=(0,n.memo)(SvgCompass);var F,z;function G(){return G=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{title:t,titleId:a,...r}=e;return n.createElement("svg",G({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,F||(F=n.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:10,d:"M15.781 10.72a2.44 2.44 0 0 0-2.999-.367 2.493 2.493 0 0 0-.782.748 2.493 2.493 0 0 0-.782-.748 2.45 2.45 0 0 0-2.088-.21 2.47 2.47 0 0 0-1.443 1.375 2.476 2.476 0 0 0 .532 2.687L12 18l3.781-3.795a2.477 2.477 0 0 0 0-3.484Z"})),z||(z=n.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:10,d:"m1 11 10.367-8.482a1 1 0 0 1 1.266 0L23 11M4 9v12a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V9"})))},H=(0,n.memo)(SvgHomeWithHeart);var j;function V(){return V=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{title:t,titleId:a,...r}=e;return n.createElement("svg",V({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,j||(j=n.createElement("path",{fill:"currentColor",d:"M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"})))},$=(0,n.memo)(SvgMenu);var W;function K(){return K=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{title:t,titleId:a,...r}=e;return n.createElement("svg",K({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 4 16","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,W||(W=n.createElement("path",{fill:"currentColor",d:"M2 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2C.9 6 0 6.9 0 8s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})))},q=(0,n.memo)(SvgMoreVertical);var X=a(83057);const Y="open-in-editor-action",Z="rename-action",J="duplicate-action",Q="delete-story-action",ee="copy-story-link",te="open-story-link",ae=[{label:(0,l.__)("Open in editor","web-stories"),value:Y,isEnabled:e=>Boolean(e?.capabilities?.hasEditAction)},{label:(0,l.__)("Open in new tab","web-stories"),value:te,isEnabled:e=>Boolean(e?.previewLink)},{label:(0,l.__)("Copy Story URL","web-stories"),value:ee,isEnabled:e=>Boolean(e?.previewLink)},{label:(0,l.__)("Rename","web-stories"),value:Z,separator:"top",isEnabled:e=>Boolean(e?.capabilities?.hasEditAction)},{label:(0,l.__)("Duplicate","web-stories"),value:J,isEnabled:e=>Boolean(e?.capabilities?.hasEditAction)},{label:(0,l.__)("Delete Story","web-stories"),value:Q,separator:"top",isEnabled:e=>Boolean(e?.capabilities?.hasDeleteAction)}],re={ASC:"asc",DESC:"desc"},ne={NAME:"title",DATE_CREATED:"date",LAST_MODIFIED:"modified",CREATED_BY:"story_author"},le={orderby:ne,order:re},oe={[ne.NAME]:re.ASC,[ne.DATE_CREATED]:re.DESC,[ne.LAST_MODIFIED]:re.DESC,[ne.CREATED_BY]:re.ASC},ie=[{label:(0,l.__)("Name","web-stories"),value:ne.NAME},{label:(0,l.__)("Date Created","web-stories"),value:ne.DATE_CREATED},{label:(0,l.__)("Last Modified","web-stories"),value:ne.LAST_MODIFIED},{label:(0,l.__)("Created By","web-stories"),value:ne.CREATED_BY}],se={DRAFT:"draft",FUTURE:"future",PENDING:"pending",PUBLISH:"publish",PRIVATE:"private"},ce={ALL:Object.values(se).join(","),PUBLISHED_AND_FUTURE:[se.PUBLISH,se.FUTURE].join(","),...se},de={[ce.PUBLISH]:(0,l.__)("Published","web-stories"),[ce.PENDING]:(0,l.__)("Pending","web-stories"),[ce.FUTURE]:(0,l.__)("Scheduled","web-stories"),[ce.DRAFT]:(0,l.__)("Draft","web-stories"),[ce.PRIVATE]:(0,l.__)("Private","web-stories")},ue=[{label:(0,l.__)("All Stories","web-stories"),value:ce.ALL,status:"all"},{label:(0,l.__)("Drafts","web-stories"),value:ce.DRAFT,status:ce.DRAFT},{label:(0,l.__)("Pending","web-stories"),value:ce.PENDING,status:ce.PENDING},{label:(0,l.__)("Published","web-stories"),value:ce.PUBLISH,status:ce.PUBLISH},{label:(0,l.__)("Scheduled","web-stories"),value:ce.FUTURE,status:ce.FUTURE},{label:(0,l.__)("Private","web-stories"),value:ce.PRIVATE,status:ce.PRIVATE}],pe={[ce.ALL]:e=>(0,X.default)(/* translators: %d: number of stories in view */ (0,l._n)("Viewing %d story","Viewing all %d stories",e,"web-stories"),String(e)),[ce.DRAFT]:e=>(0,X.default)(/* translators: %d: number of draft stories in view */ (0,l._n)("Viewing %d draft","Viewing %d drafts",e,"web-stories"),String(e)),[ce.PUBLISH]:e=>(0,X.default)(/* translators: %d: number of stories */ (0,l._n)("Viewing %d published story","Viewing %d published stories",e,"web-stories"),String(e)),[ce.FUTURE]:e=>(0,X.default)(/* translators: %d: number of stories */ (0,l._n)("Viewing %d scheduled story","Viewing %d scheduled stories",e,"web-stories"),String(e)),[ce.PENDING]:e=>(0,X.default)(/* translators: %d: number of stories */ (0,l._n)("Viewing %d pending story","Viewing %d pending stories",e,"web-stories"),String(e)),[ce.PRIVATE]:e=>(0,X.default)(/* translators: %d: number of stories */ (0,l._n)("Viewing %d private story","Viewing %d private stories",e,"web-stories"),String(e))},me={filters:{status:ce.ALL},sort:{orderby:ne.LAST_MODIFIED,order:oe[ne.LAST_MODIFIED]}},fe="diy_crafts",ge="movies_tv",he="beauty_style",be="fitness_wellbeing",_e="food",ye="travel",Ee="music",Se="sports",we=((0,l._x)("DIY & Crafts","template vertical","web-stories"),(0,l._x)("Movies & TV","template vertical","web-stories"),(0,l._x)("Beauty & Style","template vertical","web-stories"),(0,l._x)("Fitness & Wellbeing","template vertical","web-stories"),(0,l._x)("Food","template vertical","web-stories"),(0,l._x)("Travel","template vertical","web-stories"),(0,l._x)("Music","template vertical","web-stories"),(0,l._x)("Sports","template vertical","web-stories"),"white"),ve="black",Te="gray",Ce="brown",Ie="red",ke="orange",Le="yellow",Ae="green",xe="blue",Oe="pink",De="purple",Ne=((0,l._x)("White","color","web-stories"),(0,l._x)("Black","color","web-stories"),(0,l._x)("Gray","color","web-stories"),(0,l._x)("Brown","color","web-stories"),(0,l._x)("Red","color","web-stories"),(0,l._x)("Orange","color","web-stories"),(0,l._x)("Yellow","color","web-stories"),(0,l._x)("Green","color","web-stories"),(0,l._x)("Blue","color","web-stories"),(0,l._x)("Pink","color","web-stories"),(0,l._x)("Purple","color","web-stories"),{ALL:"template"}),Pe={[Ne.ALL]:e=>(0,X.default)(/* translators: %d: number of templates in view */ (0,l._n)("Viewing %d template","Viewing all %d templates",e,"web-stories"),String(e))},Re={POPULAR:"popular",RECENT:"recent"},Be={orderby:Re,order:{ASC:"asc",DESC:"desc"}},Me={filters:{status:Ne.ALL},sort:{orderby:Re.POPULAR}},Ue=[{label:(0,l.__)("Popular","web-stories"),value:Re.POPULAR},{label:(0,l.__)("Recent","web-stories"),value:Re.RECENT}],Fe={template:(0,l.__)("See details","web-stories")},ze={MENU:"menu",PANEL:"panel",COLOR_PANEL:"color_panel"},Ge=[".jpg",".jpeg",".png",".gif"],He=288,je=1098,Ve={TABLET:"tablet",DESKTOP:"desktop",THUMBNAIL:"thumbnail"},$e={[Ve.TABLET]:200,[Ve.DESKTOP]:232,[Ve.THUMBNAIL]:33},We=24,Ke=32,qe=52,Xe=5,Ye={DASHBOARD:"/",TEMPLATES_GALLERY:"/templates-gallery",TEMPLATE_DETAIL:"template-detail"},Ze={[Ye.DASHBOARD]:(0,l.__)("Dashboard","web-stories"),[Ye.TEMPLATES_GALLERY]:(0,l.__)("Explore Templates","web-stories"),[`${Ye.TEMPLATES_GALLERY}/${Ye.TEMPLATE_DETAIL}`]:(0,l.__)("Template Details","web-stories"),DEFAULT:(0,l.__)("Dashboard","web-stories")},Je=[{value:Ye.DASHBOARD,label:Ze[Ye.DASHBOARD],Icon:H},{value:Ye.TEMPLATES_GALLERY,label:Ze[Ye.TEMPLATES_GALLERY],Icon:U}],Qe={GRID:"grid",LIST:"list"},et={[Qe.GRID]:(0,l.__)("Switch to List View","web-stories"),[Qe.LIST]:(0,l.__)("Switch to Grid View","web-stories")},tt="DASHBOARD",at="TEMPLATES_GALLERY",rt={[tt]:{...pe},[at]:{...Pe}},nt=24,lt=300,ot=853,it=640;const st=function(e,t){switch(t.type){case C:case w:return{...e,isLoading:t.payload};case T:case k:case A:case O:case N:return{...e,error:{...t.payload,id:Date.now()}};case v:return{...e,error:{}};case L:return{...e,error:{},stories:{...e.stories,[t.payload.id]:t.payload}};case x:{const a=t.payload.storyStatus===ce.DRAFT?ce.DRAFT:ce.PUBLISH;return{...e,error:{},storiesOrderById:e.storiesOrderById.filter((e=>e!==t.payload.id)),totalStoriesByStatus:{...e.totalStoriesByStatus,all:e.totalStoriesByStatus.all-1,[a]:e.totalStoriesByStatus[a]-1},stories:Object.keys(e.stories).reduce(((a,r)=>(parseInt(r)!==t.payload.id&&(a[r]=e.stories[r]),a)),{})}}case D:return{...e,error:{},storiesOrderById:[t.payload.id,...e.storiesOrderById],totalStoriesByStatus:{...e.totalStoriesByStatus,all:e.totalStoriesByStatus.all+1,[t.payload.status]:e.totalStoriesByStatus[t.payload.status]+1},stories:{...e.stories,[t.payload.id]:t.payload}};case I:{const{fetchedStoryIds:a,totalStoriesByStatus:r,totalPages:n,page:l,stories:o}=t.payload,{storiesOrderById:i,stories:s}=e,c=1===l?a:[...i,...a],d=[...new Set(c)];return{...e,error:{},storiesOrderById:d,stories:{...s,...o},totalPages:n||1,totalStoriesByStatus:r,allPagesFetched:l>=n}}default:return e}},ct={LOAD_STORIES:{MESSAGE:(0,l.__)("Unable to load stories","web-stories")},UPDATE_STORY:{MESSAGE:(0,l.__)("Unable to update story","web-stories")},DELETE_STORY:{MESSAGE:(0,l.__)("Unable to delete story","web-stories")},CREATE_STORY_FROM_TEMPLATE:{MESSAGE:(0,l.__)("Unable to create story from template","web-stories")},DUPLICATE_STORY:{MESSAGE:(0,l.__)("Unable to duplicate story","web-stories")},LOAD_TEMPLATES:{DEFAULT_MESSAGE:(0,l.__)("Cannot connect to data source","web-stories"),MESSAGE:(0,l.__)("Unable to load templates","web-stories")},RENDER_PREVIEW:{MESSAGE:(0,l.__)("Unable to render preview","web-stories")},LOAD_TEMPLATE:{DEFAULT_MESSAGE:(0,l.__)("Could not load the template","web-stories")}},dt=`${S.SESSION_STORAGE_PREFIX.LOCAL_AUTOSAVE_PREFIX}_auto-draft`,ut=()=>{const e=(0,h.useRef)(!0),t=(0,h.useMemo)((()=>new Map),[]),[a,r]=(0,h.useReducer)(st,P),{apiCallbacks:n}=y(),l=(0,h.useRef)(!1);(0,h.useEffect)((()=>(l.current=!0,()=>{l.current=!1})),[]);const o=(0,h.useCallback)((async a=>{r({type:C,payload:!0});const o=(0,E.getTimeTracker)("load_stories");try{const{stories:o,fetchedStoryIds:i,totalPages:s,totalStoriesByStatus:c}=await n.fetchStories(a);if(!l.current)return;e.current&&t.forEach((e=>{e(c)})),e.current=!1,r({type:I,payload:{stories:o,totalPages:s,totalStoriesByStatus:c,fetchedStoryIds:i,page:a.page}})}catch(e){r({type:k,payload:{message:ct.LOAD_STORIES.MESSAGE,code:e.code}})}finally{r({type:C,payload:!1}),o()}}),[n,t]),i=(0,h.useCallback)((async e=>{const t=(0,E.getTimeTracker)("load_update_story");try{const t=await n.updateStory(e);r({type:L,payload:t})}catch(e){r({type:A,payload:{message:ct.UPDATE_STORY.MESSAGE,code:e.code}})}finally{t()}}),[n]),s=(0,h.useCallback)((async e=>{const t=(0,E.getTimeTracker)("load_trash_story");try{await n.trashStory(e.id),r({type:x,payload:{id:e.id,storyStatus:e.status}})}catch(e){r({type:O,payload:{message:ct.DELETE_STORY.MESSAGE,code:e.code}})}finally{t()}}),[n]),c=(0,h.useCallback)((async e=>{r({type:w,payload:!0});try{const t=await n.createStoryFromTemplate(e);S.sessionStore.deleteItemByKey(dt),r({type:v}),window.location=t.editLink}catch(e){r({type:T,payload:{message:ct.CREATE_STORY_FROM_TEMPLATE.MESSAGE,code:e.code}})}finally{r({type:w,payload:!1})}}),[n]);return{stories:a,api:{duplicateStory:(0,h.useCallback)((async e=>{const t=(0,E.getTimeTracker)("load_duplicate_story");try{const t=await n.duplicateStory(e);r({type:D,payload:t})}catch(e){r({type:N,payload:{message:ct.DUPLICATE_STORY.MESSAGE,code:e.code}})}finally{t()}}),[n]),fetchStories:o,createStoryFromTemplate:c,trashStory:s,updateStory:i,addInitialFetchListener:(0,h.useCallback)((e=>{const a=Symbol();return t.set(a,e),()=>{t.delete(a)}}),[t])}}};a(41792),a(70560);var pt=a(17445),mt=a(38627),ft=a(40877),gt=(a(86290),a(51085)),ht=a(7694),bt=a(55965),_t=a(30776),yt=a(59452);const Et=function(e){if(!e)return"";const t=(0,mt.default)(e);if((0,gt.default)(t)){const{locale:e}=(0,_t.default)();return(0,ht.default)(t,{includeSeconds:!1,addSuffix:!0,locale:e})}return(0,bt.default)(t)?(0,l.__)("yesterday","web-stories"):(0,yt.default)(e)};const St=function(e){return(0,mt.default)(e,{timeZone:"+0000"})};const wt="loading_templates",vt="fetch_templates_success",Tt="fetch_templates_failure",Ct="placeholder",It={allPagesFetched:!1,error:{},isLoading:!1,templates:{},templatesByTag:{},templatesOrderById:[],totalTemplates:null,totalPages:null},kt=(e,t)=>e.reduce(((e,a)=>a[t]?(e[a[t]],e[a[t]]=a,e):e),{});const Lt=function(e,t){switch(t.type){case wt:return{...e,isLoading:t.payload};case Tt:return{...e,error:{...t.payload,id:Date.now()}};case vt:{const a=t.payload.templates.map((e=>{let{id:t}=e;return t})),r=1===t.payload.page?a:[...e.templatesOrderById,...a],n=[...new Set(r)];return{...e,error:{},templatesOrderById:n,templates:{...e.templates,...kt(t.payload.templates,"id")},isLoading:!1,totalPages:t.payload.totalPages,totalTemplates:t.payload.totalTemplates,allPagesFetched:t.payload.page>=t.payload.totalPages,templatesByTag:t.payload.templatesByTag}}case Ct:return It;default:return e}};const At=()=>{const[e,t]=(0,h.useReducer)(Lt,It),{cdnURL:r}=y(),n=(0,h.useCallback)((async()=>{t({type:wt,payload:!0});const e={},{getAllTemplates:n}=await Promise.all([a.e(649),a.e(4991)]).then(a.bind(a,82602)),l=(await n({cdnURL:r})).map((t=>{const a=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{id:a,slug:r,modified:n,creationDate:l}=e;return a&&r?{...e,id:a,slug:r,creationDate:(0,mt.default)(l,(0,_t.default)()),status:"template",modified:St(n),isLocal:t}:null}(t);return a.tags.forEach((t=>{e[t]?e[t].push(a.id):e[t]=[a.id]})),a})).sort(((e,t)=>(0,pt.default)(e.creationDate,t.creationDate)));t({type:vt,payload:{page:1,templates:l,totalPages:1,totalTemplates:l.length,templatesByTag:e}})}),[r]),l=(0,h.useCallback)((t=>e.templates[t]?Promise.resolve(e.templates[t]):Promise.reject(new Error)),[e]);return{templates:e,api:{fetchExternalTemplates:n,fetchExternalTemplateById:l}}};const xt=function(){const{apiCallbacks:{getAuthors:e}}=y();return{api:{getAuthors:e}}};const Ot=function(){const{apiCallbacks:{getTaxonomies:e,getTaxonomyTerms:t}}=y();return{api:{getTaxonomies:e,getTaxonomyTerms:t}}},Dt=(0,h.createContext)({state:{},actions:{}});function ApiProvider(e){let{children:t}=e;const{api:a}=xt(),{api:r}=Ot(),{templates:l,api:o}=At(),{stories:i,api:s}=ut(),c={state:{stories:i,templates:l},actions:{storyApi:s,templateApi:o,usersApi:a,taxonomyApi:r}};return n.createElement(Dt.Provider,{value:c},t)}var Nt=a(97959),Pt=a(45697),Rt=a.n(Pt),Bt=a(58228),Mt=a(5574);const Ut=(0,m.css)(["picture{display:block;& > img{display:block;height:100%;width:100%;object-fit:fill;border-radius:",";border:",";}}"],(e=>{let{theme:t}=e;return t.borders.radius.medium}),(e=>{let{theme:t}=e;return`1px solid ${t.colors.border.defaultNormal}`})),Ft=m.default.div.withConfig({displayName:"cardGallery__GalleryContainer",componentId:"sc-8jnrkn-0"})(["flex:1;display:flex;justify-content:space-between;align-items:start;"]),zt=m.default.div.withConfig({displayName:"cardGallery__DisplayPage",componentId:"sc-8jnrkn-1"})(["overflow:hidden;width:38.6%;margin-left:2.1%;"," @media screen and (min-width:1600px){width:45.2%;margin-left:2.4%;}"],Ut);zt.propTypes={$isThreeRows:Rt().bool};const Gt=m.default.div.withConfig({displayName:"cardGallery__Thumbnails",componentId:"sc-8jnrkn-2"})(["position:relative;display:grid;width:52.3%;grid-template-columns:repeat(3,1fr);column-gap:8px;row-gap:16px;margin-right:16px;@media screen and (min-width:1600px){width:59.3%;grid-template-columns:repeat(4,1fr);}"]),Ht=(0,m.default)(Bt.Button).attrs({type:Mt.ButtonType.Plain}).withConfig({displayName:"cardGallery__ThumbnailButton",componentId:"sc-8jnrkn-3"})(["display:block;height:100%;padding:0;border:none;background-color:transparent;position:relative;&:active{background-color:transparent;}"," ",";"],(e=>{let{$isSelected:t,theme:a}=e;return t&&(0,m.css)(["&:after{content:'';position:absolute;box-sizing:border-box;width:100%;height:100%;display:block;top:0;right:0;border-radius:",";border:4px solid ",";}"],a.borders.radius.medium,a.colors.interactiveBg.active)}),Ut);function jt(e){return(0,X.default)(/* translators: %s: page number. */ (0,l.__)("Poster of template page %s","web-stories"),e)}Ht.propTypes={$isSelected:Rt().bool};const Vt=function CardGallery(e){let{galleryPosters:t,isRTL:a,galleryLabel:r}=e;const[o,i]=(0,h.useState)(0),[s,c]=(0,h.useState)(),d=(0,h.useRef)(),u=(0,h.useRef)(),p=(0,h.useRef)({}),m=(0,h.useCallback)((e=>{i(e),c(e)}),[]),f=(0,h.useCallback)((e=>{c(e)}),[]);(0,h.useEffect)((()=>{t&&(i(0),c())}),[t]),(0,Nt.default)({containerRef:d,gridRef:u,itemRefs:p,isRTL:a,currentItemId:s,items:t});const g=(0,h.useMemo)((()=>t.map(((e,t)=>{const a=`gallery_item_${t}`,r=t+1,i=s?s===t:o===t;return n.createElement("div",{key:a,ref:e=>{p.current[t]=e},onFocus:()=>f(t)},n.createElement(Ht,{$isSelected:o===t,tabIndex:i?0:-1,onClick:()=>m(t),"aria-label":o===t?(0,X.default)(/* translators: %s: page number. */ (0,l.__)("Page %s (current page)","web-stories"),r):(0,X.default)(/* translators: %s: page number. */ (0,l.__)("Page %s","web-stories"),r)},n.createElement("picture",null,n.createElement("source",{srcSet:e.webp,type:"image/webp"}),n.createElement("source",{srcSet:e.png,type:"image/png"}),n.createElement("img",{src:e.png,decoding:"async",alt:jt(r),width:it,height:ot}))))}))),[t,o,s,f,m]);return n.createElement(Ft,{ref:d},n.createElement(Gt,{ref:u,role:"group","aria-label":r,"data-testid":"mini-cards-container"},g),n.createElement(zt,null,t[o]&&n.createElement("picture",null,n.createElement("source",{srcSet:t[o].webp,type:"image/webp"}),n.createElement("source",{srcSet:t[o].png,type:"image/png"}),n.createElement("img",{src:t[o].png,decoding:"async",alt:(0,X.default)(/* translators: %s: active preview page number */ (0,l.__)("Active Page Preview - Page %s","web-stories"),o+1),width:it,height:ot}))))};var $t=a(41708);const Wt=Rt().oneOf([...Object.values(ce),...Object.values(Ne)]),Kt=Rt().shape({id:Rt().number.isRequired,status:Wt,title:Rt().string.isRequired,modified:Rt().oneOfType([Rt().object,Rt().string]),author:Rt().object,capabilities:Rt().shape({hasDeleteAction:Rt().bool,hasEditAction:Rt().bool})}),qt=Rt().shape({id:Rt().number.isRequired,status:Wt,title:Rt().string.isRequired,pages:Rt().array,modified:Rt().object,colors:Rt().arrayOf(Rt().shape({label:Rt().string.isRequired,color:Rt().string.isRequired})),description:Rt().string,tags:Rt().arrayOf(Rt().string),createdBy:Rt().string,postersByPage:Rt().arrayOf(Rt().shape({webp:Rt().string,png:Rt().string,type:Rt().string}))}),Xt=(Rt().arrayOf(Kt),Rt().arrayOf(qt).isRequired,Rt().shape({duplicateStory:Rt().func,trashStory:Rt().func,updateStory:Rt().func}),Rt().shape({createStoryFromTemplate:Rt().func,handleDetailsToggle:Rt().func,switchToTemplateByOffset:Rt().func}),Rt().shape({all:Rt().number,draft:Rt().number,publish:Rt().number}),Rt().shape({width:Rt().number,height:Rt().number})),Yt=(Rt().shape({handleMenuToggle:Rt().func.isRequired,contextMenuId:Rt().number.isRequired,menuItems:Rt().arrayOf(Rt().shape({label:Rt().string,value:Rt().oneOfType([Rt().string,Rt().bool]),url:Rt().string,isEnabled:Rt().func,action:Rt().func}))}),Rt().shape({handleOnRenameStory:Rt().func,id:Rt().number,handleCancelRename:Rt().func}),m.default.div.withConfig({displayName:"cardGrid__DashboardGrid",componentId:"sc-1kbl74q-0"})(["display:grid;width:100%;grid-column-gap:","px;grid-row-gap:","px;grid-template-columns:",";grid-template-rows:",";scroll-margin-top:30vh;",";"],We,Ke,(e=>{let{columnWidth:t}=e;return`\n repeat(auto-fill, ${t}px)`}),(e=>{let{columnHeight:t}=e;return`minmax(${t}px, auto)`}),(e=>{let{theme:t}=e;return(0,m.css)(["&:focus-visible{",";}"],$t.focusCSS(t.colors.border.focus))})));Yt.propTypes={columnHeight:Rt().number,columnWidth:Rt().number};const Zt=(0,h.forwardRef)((function CardGrid(e,t){let{ariaLabel:a,children:r,pageSize:l}=e;return n.createElement(Yt,{ref:t,role:"list","data-testid":"dashboard-grid-list",tabIndex:0,"aria-label":a,columnWidth:l.width,columnHeight:l.height},r)}));var Jt=a(46710),Qt=a(67745),ea=a(18275),ta=a(8921),aa=a(16330);function ra(){return ra=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{theme:t}=e;return t.colors.fg.primary}),(e=>{let{theme:t}=e;return t.colors.interactiveBg.secondaryHover}),(e=>{let{theme:t}=e;return t.colors.interactiveBg.secondaryPress}));const la=function Link(e){let{id:t,onBlur:a,onClick:r,onFocus:l,openNewTab:o,...i}=e;const{focusedId:s,onDismiss:c,onMenuItemBlur:d,onMenuItemFocus:u}=(0,ta.default)((e=>{let{state:t,actions:a}=e;return{focusedId:t.focusedId,onDismiss:a.onDismiss,onMenuItemBlur:a.onMenuItemBlur,onMenuItemFocus:a.onMenuItemFocus}})),p=(0,h.useMemo)(Qt.default,[]),m=t||p,f=o?{target:"_blank",rel:"noreferrer"}:{};return n.createElement(na,ra({id:m,tabIndex:s===m?0:-1,role:"menuitem",onBlur:e=>{d(),a?.(e)},onClick:e=>{r?.(e),c(e.nativeEvent)},onFocus:e=>{u(m),l?.(e)}},f,i))};var oa=a(48652),ia=a(22728);const sa=m.default.button.withConfig({displayName:"storyMenu__MoreVerticalButton",componentId:"sc-1vaaobv-0"})(["display:flex;background:transparent;padding:0 8px;opacity:",";transition:opacity ease-in-out 300ms;cursor:pointer;color:",";& > svg{width:4px;max-height:100%;}border:0;border-radius:",";",";"],(e=>{let{menuOpen:t,isVisible:a}=e;return t||a?1:0}),(e=>{let{theme:t,$isInverted:a}=e;return a?t.colors.inverted.fg.primary:t.colors.interactiveFg.brandNormal}),(e=>{let{theme:t}=e;return t.borders.radius.small}),(e=>{let{theme:t,$isInverted:a}=e;return $t.focusableOutlineCSS(!1,!!a&&t.colors.standard.black)}));sa.propTypes={menuOpen:Rt().bool};const ca=m.default.div.withConfig({displayName:"storyMenu__MenuContainer",componentId:"sc-1vaaobv-1"})(["position:relative;align-self:",";text-align:right;"," & > div{margin:0;}"],(e=>{let{verticalAlign:t="flex-start"}=e;return t}),(e=>{let{$menuStyleOverrides:t}=e;return t}));function StoryMenu(e){let{contextMenuId:t,onMoreButtonSelected:a,storyId:r,verticalAlign:o,menuItems:i,itemActive:s,tabIndex:c,menuStyleOverrides:d,menuLabel:u,isInverted:p}=e;const m=t===r,f=(0,h.useCallback)((e=>a(e,-1)),[a]);return n.createElement(ca,{verticalAlign:o,"data-testid":`story-context-menu-${r}`,$menuStyleOverrides:d},n.createElement(sa,{"data-testid":`story-context-button-${r}`,tabIndex:c,menuOpen:m,isVisible:s,"aria-label":u||(0,l.__)("More Options","web-stories"),onClick:e=>a(e,m?-1:r),className:"context-menu-button",$isInverted:p},n.createElement(q,null)),n.createElement(Jt.default,{animate:!0,isOpen:m,onDismiss:f},i.map((e=>{let{label:t,separator:a,...r}=e;const l=r.href?la:oa.default;return n.createElement(h.Fragment,{key:t},"top"===a&&n.createElement(ia.default,null),n.createElement(l,r,t),"bottom"===a&&n.createElement(ia.default,null))}))))}ca.propTypes={verticalAlign:Rt().oneOf(["center","flex-start","flex-end"])};const da=m.default.div.attrs({role:"listitem"}).withConfig({displayName:"cardGridItem__CardGridItem",componentId:"sc-w3d579-0"})(["margin:0;width:100%;display:grid;grid-template-columns:100%;grid-template-rows:",";","{margin:12px 0;}&:hover ",",&:active ",",&:focus-within ","{opacity:1;}&:hover .card_buttons,&:active .card_buttons,&:focus-within .card_buttons{opacity:1;}"],(e=>{let{$posterHeight:t}=e;return`${t}px auto`}),sa,sa,sa,sa);da.propTypes={$posterHeight:Rt().number};const ua=da;var pa=a(80448);Rt().shape({label:Rt().string.isRequired,color:Rt().string.isRequired});const ma=m.default.ul.withConfig({displayName:"colorList__ColorContainer",componentId:"sc-uphoth-0"})(["display:flex;margin:0;"]),fa=m.default.li.withConfig({displayName:"colorList__Color",componentId:"sc-uphoth-1"})(["",""],(e=>{let{theme:t,$backgroundColor:a,color:r,size:n,spacing:l}=e;return`\n width: ${n}px;\n height: ${n}px;\n border-radius: 50%;\n margin-bottom: 0;\n background-color: rgb(${a});\n ${(e=>({"#fff":`border: solid 1px ${e}`,"#ffffff":`border: solid 1px ${e}`,white:`border: solid 1px ${e}`,"#fef9f1":`border: solid 1px ${e}`,"#fff8f2":`border: solid 1px ${e}`,"#f9f9f9":`border: solid 1px ${e}`,"#fcfcfc":`border: solid 1px ${e}`}))(t.colors.border.defaultNormal)[r]||""};\n\n & + & {\n margin-left: ${l||10}px;\n }\n `}));const ga=function ColorList(e){let{colors:t,size:a,spacing:r,...l}=e;return n.createElement(ma,l,t.map((e=>{let{label:t,color:l}=e;const{r:o,g:i,b:s}=(0,pa.default)(l).color,c=`${o}, ${i}, ${s}`;return n.createElement(fa,{key:l,size:a,spacing:r,color:l,$backgroundColor:c,title:t,ariaLabel:t,"data-testid":"detail-template-color"})})))},ha=m.default.div.withConfig({displayName:"contentGutter__StandardViewContentGutter",componentId:"sc-17seiz9-0"})(["margin:0 ","px;"],qe);var ba=a(39304);function _a(){return _a=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{onClose:t,onSecondary:a,onPrimary:r,primaryText:l,secondaryText:o,primaryRest:s,secondaryRest:c,actions:d,children:u,...p}=e;const f=(0,h.useMemo)((()=>l&&n.createElement(Bt.Button,_a({type:Mt.ButtonType.Primary,size:Mt.ButtonSize.Small,onClick:()=>r?.()},s),l)),[l,s,r]),g=(0,h.useMemo)((()=>o&&n.createElement(Bt.Button,_a({type:Mt.ButtonType.Tertiary,size:Mt.ButtonSize.Small,onClick:()=>a?.()||t()},c),o)),[o,c,a,t]);return n.createElement(m.ThemeProvider,{theme:i.theme},n.createElement(ba.default,_a({onClose:t},p,{actions:d||n.createElement(n.Fragment,null,g,f)}),u))};var Ea=a(31338),Sa=a(6992);const wa=(0,m.default)(Bt.Button).withConfig({displayName:"fileUpload__StyledButton",componentId:"sc-1egk7ci-0"})([":focus-within{","}"],(e=>{let{theme:t}=e;return $t.focusCSS(t.colors.border.focus)})),va=m.default.input.withConfig({displayName:"fileUpload__Input",componentId:"sc-1egk7ci-1"})(Ea.visuallyHidden),Ta=m.default.div.withConfig({displayName:"fileUpload__UploadFormArea",componentId:"sc-1egk7ci-2"})(["display:flex;flex-direction:column;align-items:center;position:relative;justify-content:flex-end;width:100%;min-height:153px;padding:40px 0;border-radius:4px;border:1px dashed ",";transition:border-color 300ms ease-in;"],(e=>{let{isDragging:t,theme:a}=e;return t?a.colors.border.focus:a.colors.border.defaultNormal})),Ca=(0,m.default)(Sa.Text.Paragraph).withConfig({displayName:"fileUpload__UploadHelperText",componentId:"sc-1egk7ci-3"})(["margin:0 auto 16px;padding:0 20%;text-align:center;color:",";"],(e=>{let{theme:t}=e;return t.colors.fg.tertiary})),Ia=m.default.div.withConfig({displayName:"fileUpload__LoadingIndicator",componentId:"sc-1egk7ci-4"})(["display:flex;align-items:center;justify-content:center;position:absolute;top:0;width:100%;height:100%;background-color:",";opacity:",";z-index:",";pointer-events:none;transition:opacity ease-in-out 300ms;p{font-style:italic;}"],(e=>{let{theme:t}=e;return t.colors.standard.white}),(e=>{let{isLoading:t}=e;return t?.6:0}),(e=>{let{isLoading:t}=e;return t?"100":"0"}));function ka(e){e.preventDefault(),e.stopPropagation()}const La=e=>{let{id:t,label:a,onSubmit:r,isLoading:o,isMultiple:i,ariaLabel:s,instructionalText:c=(0,l.__)("You can also drag your file here","web-stories"),acceptableFormats:d=Ge}=e;const u=(0,h.useRef)(null),p=(0,h.useRef)(null),[m,f]=(0,h.useState)(!1),g=(0,h.useCallback)((e=>{r(Object.values(e))}),[r]),b=(0,h.useCallback)((e=>{ka(e),g(e.target.files),p.current.value=null}),[g]),_=(0,h.useCallback)((e=>{ka(e);const t=e.dataTransfer.files;t&&g(t),f(!1)}),[g]),y=(0,h.useCallback)((e=>{ka(e),f((e=>!e)),m&&e.dataTransfer.clearData()}),[m]);return(0,h.useEffect)((()=>{if(!p?.current)return()=>{};const e=p.current;return e.addEventListener("change",b),()=>{e.removeEventListener("change",b)}}),[b]),n.createElement(Ta,{ref:u,isDragging:m,onDrop:_,onDragEnter:y,onDragLeave:y,onDragOver:ka,"data-testid":"file-upload-drop-area"},n.createElement(Ia,{isLoading:o},n.createElement("p",null,(0,l.__)("Loading…","web-stories"))),n.createElement(Ca,null,c),n.createElement(wa,{forwardedAs:"label",htmlFor:t,"aria-label":s,type:Mt.ButtonType.Primary,size:Mt.ButtonSize.Small},a,n.createElement(va,{ref:p,type:"file",id:t,"data-testid":"upload-file-input",accept:d.join(","),multiple:i,disabled:o,"aria-live":"polite","aria-busy":o})))};var Aa=a(99270);const xa=(0,m.default)(Aa.default).withConfig({displayName:"inlineInputForm__StyledInput",componentId:"sc-21xnmy-0"})(["div{height:auto;}",""],(e=>{let{$isInverted:t,theme:a}=e;return t&&(0,m.css)(["input{color:",";}"],a.colors.inverted.fg.primary)})),Oa=e=>{let{noAutoFocus:t,error:a,id:r,isInverted:l,label:o,onEditCancel:i,onEditComplete:s,placeholder:c,value:d}=e;const u=(0,h.useRef)(null),[p,m]=(0,h.useState)(d);(0,h.useEffect)((()=>{m(d)}),[d]),(0,h.useFocusOut)(u,(()=>{i()}),[i]),(0,h.useEffect)((()=>{!t&&u.current&&u.current.querySelector("input")?.focus()}),[t]);const f=(0,h.useCallback)((e=>{let{target:t}=e;m(t.value)}),[m]),g=(0,h.useCallback)((e=>{let{nativeEvent:t}=e;13===t.keyCode?s(p):27===t.keyCode&&i()}),[p,s,i]);return n.createElement("div",{ref:u},n.createElement(xa,{"aria-label":o,id:`${r}`,"data-testid":"inline-input-form",value:p,onKeyDown:g,onChange:f,placeholder:c,hasError:Boolean(a),hint:a,$isInverted:l}))},Da=(0,h.createContext)(null),Na=e=>{let{children:t}=e;const a=(0,h.useRef)(),r=(0,h.useRef)(null);(0,h.useEffect)((()=>{a.current=document?.getElementById("web-stories-dashboard")?.querySelector(["button","a"])}),[]);const l=(0,h.useCallback)((()=>{document.documentElement?.scrollTo?.({top:0,behavior:"smooth"}),a.current?.focus()}),[]),o=(0,h.useMemo)((()=>({state:{scrollFrameRef:r},actions:{scrollToTop:l}})),[l]);return n.createElement(Da.Provider,{value:o},t)},Pa=()=>{const e=(0,h.useContext)(Da);if(!e)throw new Error("useLayoutContext() must be used within a ");return e},Ra=m.default.div.withConfig({displayName:"scrollable__ScrollContent",componentId:"sc-17i1z8u-0"})([""]),Ba=e=>{let{children:t}=e;const{state:{scrollFrameRef:a}}=Pa();return n.createElement(Ra,{ref:a},t)},Ma=m.default.div.withConfig({displayName:"fixed__FixedContent",componentId:"sc-735v4o-0"})(["position:absolute;top:0;right:0;bottom:0;left:0;z-index:",";overflow:hidden;pointer-events:none;& > *{pointer-events:auto;}"],Xe),Ua={Provider:Na,Scrollable:Ba,Fixed:e=>{let{children:t}=e;return n.createElement(Ma,null,t)}};var Fa=a(85703);const za=m.default.div.withConfig({displayName:"pageStructureComponents__AppFrame",componentId:"sc-199ev3j-0"})(["width:100%;@media screen and (max-width:","px){width:","px;}"],je,je),Ga=m.default.div.withConfig({displayName:"pageStructureComponents__PageContent",componentId:"sc-199ev3j-1"})(["position:relative;padding-top:10px;width:",";left:",";@media screen and (max-width:","px){left:0;width:100%;}"],(e=>{let{fullWidth:t}=e;return t?"100%":"calc(100% - 288px)"}),(e=>{let{fullWidth:t}=e;return t?"0":"288px"}),je),Ha=m.default.nav.attrs({"data-testid":"dashboard-left-rail"}).withConfig({displayName:"pageStructureComponents__LeftRailContainer",componentId:"sc-199ev3j-2"})(["position:fixed;display:flex;justify-content:space-between;flex-direction:column;top:",";bottom:0;width:","px;background:",";z-index:",";transition:transform 0.25s ",",opacity 0.25s linear;@media screen and (max-width:","px){padding-left:0;opacity:",";visibility:",";transform:translateX(",");}"],(e=>{let{topOffset:t}=e;return`${t}px`}),He,(e=>{let{theme:t}=e;return t.colors.bg.primary}),Xe,Fa.BEZIER.outCubic,je,(e=>{let{isOpen:t}=e;return t?1:0}),(e=>{let{isOpen:t}=e;return t?"visible":"hidden"}),(e=>{let{isOpen:t}=e;return t?"none":"-100%"})),ja=m.default.div.withConfig({displayName:"pageStructureComponents__LoadingContainer",componentId:"sc-199ev3j-3"})(["display:flex;justify-content:center;align-items:center;min-height:550px;"]);var Va,$a,Wa,Ka;function qa(){return qa=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{title:t,titleId:a,...r}=e;return n.createElement("svg",qa({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 212 64","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,Va||(Va=n.createElement("circle",{cx:32,cy:32,r:32,fill:"url(#a)",transform:"rotate(-180 32 32)"})),$a||($a=n.createElement("g",{fill:"#fff",filter:"url(#b)"},n.createElement("path",{d:"M41.6 19.2a3.2 3.2 0 0 1 3.2 3.2v19.2a3.2 3.2 0 0 1-3.2 3.2V19.2zm-24 0a3.2 3.2 0 0 1 3.2-3.2h14.4a3.2 3.2 0 0 1 3.2 3.2v25.6a3.2 3.2 0 0 1-3.2 3.2H20.8a3.2 3.2 0 0 1-3.2-3.2V19.2zM48 22.4a2.4 2.4 0 0 1 2.4 2.4v14.4a2.4 2.4 0 0 1-2.4 2.4V22.4z"}))),Wa||(Wa=n.createElement("path",{fill:"#000",d:"m80.78 40.4-4.967-18.33h2.407l3.328 13.466.307 1.254h.102l.384-1.254 4.096-13.466h2.253l3.917 13.466.384 1.254h.102l3.61-14.72h2.406L94.17 40.4h-2.253l-3.892-13.261-.41-1.434h-.102l-.435 1.434-4.045 13.26H80.78zm24.747.41c-1.263 0-2.389-.3-3.379-.897a6.391 6.391 0 0 1-2.304-2.457c-.546-1.041-.82-2.227-.82-3.559 0-1.245.257-2.397.769-3.456.529-1.058 1.263-1.903 2.201-2.534.956-.649 2.074-.973 3.354-.973 1.297 0 2.406.29 3.328.87a5.53 5.53 0 0 1 2.15 2.356c.512 1.007.768 2.159.768 3.456 0 .12-.008.239-.025.358 0 .12-.009.222-.026.307h-10.342c.068 1.024.315 1.878.742 2.56.444.666.99 1.17 1.638 1.51a4.47 4.47 0 0 0 2.023.487c.956 0 1.741-.222 2.355-.665a5.278 5.278 0 0 0 1.51-1.69l1.844.896a6.603 6.603 0 0 1-2.202 2.458c-.956.648-2.15.972-3.584.972zm-.179-11.905c-1.058 0-1.937.333-2.637.999s-1.161 1.527-1.382 2.585h7.961c-.017-.495-.162-1.015-.435-1.561-.256-.563-.666-1.041-1.229-1.434-.563-.392-1.322-.589-2.278-.589zm15.423 11.904c-1.041 0-1.954-.239-2.739-.716-.785-.478-1.357-1.016-1.715-1.613h-.103v1.92h-2.073V22.07h2.176v5.402l-.103 1.817h.103c.358-.614.93-1.16 1.715-1.638s1.698-.717 2.739-.717c1.195 0 2.262.299 3.2.896.939.598 1.681 1.417 2.227 2.458.547 1.04.82 2.236.82 3.584 0 1.348-.273 2.543-.82 3.584-.546 1.04-1.288 1.86-2.227 2.457-.938.598-2.005.896-3.2.896zm-.23-1.97a3.98 3.98 0 0 0 2.099-.59c.666-.41 1.195-.99 1.587-1.74.41-.751.615-1.63.615-2.637 0-1.024-.205-1.903-.615-2.637-.392-.75-.921-1.323-1.587-1.715a3.857 3.857 0 0 0-2.099-.615c-.751 0-1.459.205-2.125.615-.648.392-1.178.964-1.587 1.715-.41.734-.615 1.613-.615 2.637s.205 1.911.615 2.662c.409.734.939 1.306 1.587 1.715a4.116 4.116 0 0 0 2.125.59zm19.73 1.97a6.608 6.608 0 0 1-2.637-.563 6.642 6.642 0 0 1-2.304-1.664c-.665-.734-1.152-1.647-1.459-2.739l2.074-.845c.29 1.058.819 1.946 1.587 2.663.768.716 1.698 1.075 2.79 1.075.683 0 1.306-.12 1.869-.359a3.286 3.286 0 0 0 1.382-1.1c.359-.478.538-1.059.538-1.741 0-.905-.341-1.622-1.024-2.15-.666-.547-1.655-1.05-2.97-1.511l-1.152-.41a13.954 13.954 0 0 1-2.048-.972 5.22 5.22 0 0 1-1.689-1.536c-.444-.649-.666-1.46-.666-2.432 0-.888.239-1.699.717-2.432.478-.734 1.135-1.323 1.971-1.767.837-.444 1.801-.665 2.893-.665 1.143 0 2.099.213 2.867.64.785.41 1.4.904 1.843 1.484.461.564.768 1.084.922 1.562l-2.022.87c-.103-.358-.299-.725-.589-1.1-.29-.393-.683-.717-1.178-.973-.478-.273-1.083-.41-1.817-.41-.598 0-1.161.12-1.69.359-.512.239-.93.571-1.254.998-.308.41-.461.887-.461 1.434 0 .768.307 1.373.921 1.817.615.444 1.443.845 2.484 1.203l1.203.41c.546.188 1.101.418 1.664.691.58.273 1.118.623 1.613 1.05.495.426.896.956 1.203 1.587.307.614.461 1.357.461 2.227 0 .939-.188 1.75-.564 2.432a4.746 4.746 0 0 1-1.433 1.639 5.972 5.972 0 0 1-1.971.921c-.7.205-1.391.307-2.074.307zm13.187-.204c-1.092 0-1.971-.316-2.636-.948-.666-.648-.999-1.544-.999-2.688v-7.654h-2.278v-1.971h2.278v-3.687h2.176v3.687h3.2v1.971h-3.2v7.117c0 .683.137 1.212.41 1.587.29.376.759.563 1.408.563.29 0 .555-.042.793-.128.239-.085.453-.187.64-.307v2.125c-.221.102-.469.179-.742.23-.256.069-.606.103-1.05.103zm9.799.204c-1.314 0-2.475-.307-3.482-.921a6.658 6.658 0 0 1-2.381-2.483c-.563-1.058-.844-2.236-.844-3.533 0-1.297.281-2.466.844-3.507a6.605 6.605 0 0 1 2.381-2.51c1.007-.614 2.168-.92 3.482-.92s2.474.315 3.481.946a6.418 6.418 0 0 1 2.356 2.51c.58 1.04.87 2.2.87 3.48 0 1.298-.29 2.475-.87 3.534a6.465 6.465 0 0 1-2.356 2.483c-1.007.614-2.167.921-3.481.921zm0-1.97a4.34 4.34 0 0 0 2.201-.59 4.462 4.462 0 0 0 1.69-1.69c.427-.75.64-1.646.64-2.687s-.213-1.929-.64-2.663c-.427-.75-.99-1.322-1.69-1.715a4.34 4.34 0 0 0-2.201-.589c-.785 0-1.528.197-2.227.59-.7.392-1.263.963-1.69 1.714-.427.734-.64 1.622-.64 2.663 0 1.04.213 1.937.64 2.688.427.734.99 1.297 1.69 1.69a4.48 4.48 0 0 0 2.227.588zm8.984 1.56V27.345h2.073v2.099h.103a3.05 3.05 0 0 1 .845-1.28 4.5 4.5 0 0 1 1.382-.87 4.02 4.02 0 0 1 1.562-.333c.392 0 .699.025.921.077.222.034.427.094.615.179v2.355c-.547-.273-1.161-.41-1.844-.41-.631 0-1.211.18-1.74.538a4.003 4.003 0 0 0-1.28 1.434 4.236 4.236 0 0 0-.461 1.97V40.4h-2.176zm10.88-15.462c-.427 0-.794-.153-1.101-.46a1.503 1.503 0 0 1-.461-1.101c0-.444.154-.81.461-1.101.307-.307.674-.46 1.101-.46.444 0 .81.153 1.101.46.307.29.46.657.46 1.1 0 .428-.153.794-.46 1.102a1.45 1.45 0 0 1-1.101.46zM182.046 40.4V27.344h2.176V40.4h-2.176zm11.256.41c-1.263 0-2.389-.3-3.379-.897a6.39 6.39 0 0 1-2.304-2.457c-.546-1.041-.819-2.227-.819-3.559 0-1.245.256-2.397.768-3.456.529-1.058 1.263-1.903 2.201-2.534.956-.649 2.074-.973 3.354-.973 1.297 0 2.406.29 3.328.87a5.523 5.523 0 0 1 2.15 2.356c.512 1.007.768 2.159.768 3.456 0 .12-.008.239-.025.358 0 .12-.009.222-.026.307h-10.342c.068 1.024.315 1.878.742 2.56.444.666.99 1.17 1.638 1.51a4.47 4.47 0 0 0 2.023.487c.956 0 1.741-.222 2.355-.665a5.278 5.278 0 0 0 1.51-1.69l1.844.896a6.603 6.603 0 0 1-2.202 2.458c-.956.648-2.15.972-3.584.972zm-.179-11.905c-1.058 0-1.937.333-2.637.999s-1.16 1.527-1.382 2.585h7.961c-.017-.495-.162-1.015-.435-1.561-.256-.563-.666-1.041-1.229-1.434-.563-.392-1.322-.589-2.278-.589zm13.475 11.904c-1.468 0-2.663-.34-3.584-1.024-.922-.7-1.562-1.527-1.92-2.483l1.945-.87c.342.785.828 1.39 1.459 1.817a3.75 3.75 0 0 0 2.1.64c.768 0 1.45-.162 2.048-.486.614-.324.921-.802.921-1.434 0-.58-.256-1.032-.768-1.356-.495-.325-1.194-.598-2.099-.82l-1.587-.41c-.615-.17-1.195-.409-1.741-.716s-.99-.7-1.331-1.178c-.324-.494-.487-1.092-.487-1.792 0-.785.231-1.459.692-2.022.46-.563 1.066-.99 1.817-1.28a6.294 6.294 0 0 1 2.407-.46c1.109 0 2.116.247 3.02.742.922.478 1.571 1.169 1.946 2.073l-1.894.87c-.325-.648-.76-1.1-1.306-1.356s-1.143-.384-1.792-.384c-.683 0-1.306.162-1.869.486-.546.307-.819.734-.819 1.28s.213.956.64 1.229c.444.273.981.495 1.613.666l1.894.486c2.577.666 3.866 1.929 3.866 3.789 0 .819-.231 1.527-.691 2.125-.461.597-1.084 1.058-1.869 1.382-.785.324-1.656.486-2.611.486z"})),Ka||(Ka=n.createElement("defs",null,n.createElement("linearGradient",{id:"a",x1:13.255,x2:35.289,y1:6.599,y2:62.791,gradientUnits:"userSpaceOnUse"},n.createElement("stop",{stopColor:"#79B3FF"}),n.createElement("stop",{offset:1,stopColor:"#CBACFF"})),n.createElement("filter",{id:"b",width:46.08,height:46.08,x:8.96,y:10.24,colorInterpolationFilters:"sRGB",filterUnits:"userSpaceOnUse"},n.createElement("feFlood",{floodOpacity:0,result:"BackgroundImageFix"}),n.createElement("feColorMatrix",{in:"SourceAlpha",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"}),n.createElement("feOffset",{dy:1.28}),n.createElement("feGaussianBlur",{stdDeviation:1.92}),n.createElement("feColorMatrix",{values:"0 0 0 0 0.423529 0 0 0 0 0.490196 0 0 0 0 0.733333 0 0 0 0.3 0"}),n.createElement("feBlend",{in2:"BackgroundImageFix",result:"effect1_dropShadow"}),n.createElement("feBlend",{in:"SourceGraphic",in2:"effect1_dropShadow",result:"shape"})))))},Xa=(0,n.memo)(SvgLogoWithTypeCircleColor);var Ya=a(72165),Za=(a(98858),a(61318),a(33228),a(55648));const Ja=(0,h.createContext)({state:{activeRoute:"",currentPath:"",queryParams:{},availableRoutes:[],defaultRoute:""},actions:{push:()=>{},replace:()=>{},setAvailableRoutes:()=>[]}});const Qa=function RouterProvider(e){let{children:t,...a}=e;const r=(0,h.useRef)(a.history||(0,Za.createHashHistory)()),[l,o]=(0,h.useState)(r.current.location.pathname),[i,s]=(0,h.useState)([]),c=Ye.DASHBOARD,d=(0,h.useMemo)((()=>(e=>{let{availableRoutes:t,currentPath:a,defaultRoute:r}=e;const n=t.filter((e=>a.startsWith(e)));return n.length<=1?r:a})({availableRoutes:i,currentPath:l,defaultRoute:c})),[i,l,c]),u=e=>{const t=new URLSearchParams(e);return Object.fromEntries(t)},[p,m]=(0,h.useState)(u(r.current.location.search));(0,h.useEffect)((()=>r.current.listen((e=>{let{location:t}=e;m(u(t.search)),o(t.pathname)}))),[]);const f=(0,h.useMemo)((()=>({state:{activeRoute:d,currentPath:l,queryParams:p,availableRoutes:i,defaultRoute:c},actions:{push:e=>r.current.push(e),replace:e=>r.current.replace(e),setAvailableRoutes:s}})),[d,i,l,c,p]);return n.createElement(Ja.Provider,{value:f},t)};const er=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.identity;return(0,h.useContextSelector)(Ja,e)};function tr(e){return e.toLowerCase().startsWith("http://")||e.toLowerCase().startsWith("https://")?e:e.startsWith("/")?`#${e}`:""===e?"#/":`${window.location.hash}/${e}`}const ar=function Route(e){let{component:t,path:a,exact:r=!1,isDefault:n=!1}=e;const{availableRoutes:l,currentPath:o,defaultRoute:i}=er((e=>{let{state:t}=e;return t})),s=function(e){let{currentPath:t,path:a,availableRoutes:r,defaultRoute:n,isDefault:l=!1,exact:o=!1}=e;const i=new RegExp(`^${a}`).exec(t);if(!i&&!l)return null;const s=i?.[0];if(l){const e=r.filter((e=>t.startsWith(e))).length<=1;if(e)return n}return o&&t!==s?null:s}({currentPath:o,availableRoutes:l,defaultRoute:i,path:a,exact:r,isDefault:n});return s?t:null},rr=(0,h.createContext)({actions:{},state:{}});function nr(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.identity;return(0,h.useContextSelector)(rr,e)}function NavProvider(e){let{children:t}=e;const[a,r]=(0,h.useState)(!1),l=(0,h.useCallback)((()=>{r(!a)}),[a]),o=(0,h.useMemo)((()=>({actions:{toggleSideBar:l},state:{sideBarVisible:a}})),[a,l]);return n.createElement(rr.Provider,{value:o},t)}var lr=a(49527);const or=m.default.div.withConfig({displayName:"navigationComponents__Content",componentId:"sc-6htb2i-0"})(["display:flex;flex-direction:column;margin:20px 0;> *{margin:20px 28px;}"]),ir=(0,m.default)(lr.Headline).withConfig({displayName:"navigationComponents__Header",componentId:"sc-6htb2i-1"})(["margin:42px 0px 72px;& > svg{margin:0 28px;height:64px;}"]),sr=m.default.ul.withConfig({displayName:"navigationComponents__NavList",componentId:"sc-6htb2i-2"})(["margin:0;padding:0;"]),cr=m.default.li.withConfig({displayName:"navigationComponents__NavListItem",componentId:"sc-6htb2i-3"})(["margin:10px 28px;padding:0;list-style-type:none;"]),dr=(0,m.css)(["span{color:",";}svg path{stroke:",";}"],(e=>{let{theme:t}=e;return t.colors.interactiveFg.brandPress}),(e=>{let{theme:t}=e;return t.colors.interactiveFg.brandPress})),ur=(0,m.default)(ea.Link).withConfig({displayName:"navigationComponents__NavLink",componentId:"sc-6htb2i-4"})((e=>{let{active:t,theme:a,isIconLink:r}=e;return(0,m.css)([""," color:",";*{transition:color 0.25s linear,stroke 0.25s linear;}",";:hover{",";}"],r&&(0,m.css)(["display:grid;grid-template-columns:1fr 4fr;grid-template-areas:'icon link link link link';"]),a.colors.fg.secondary,t&&dr,dr)})),pr=(0,m.default)(Sa.Text.Span).withConfig({displayName:"navigationComponents__PathName",componentId:"sc-6htb2i-5"})(["grid-area:link;"]),mr=(0,m.default)(Sa.Text.Paragraph).withConfig({displayName:"navigationComponents__AppInfo",componentId:"sc-6htb2i-6"})((e=>{let{theme:t}=e;return(0,m.css)(["color:",";"],t.colors.fg.secondary)}));function fr(){return fr=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{state:t}=e;return t.activeRoute})),{newStoryURL:t,version:a,leftRailSecondaryNavigation:r,canViewDefaultTemplates:o,styleConstants:{topOffset:i}}=y(),s=(0,h.useRef)(null),c=(0,h.useRef)(null),{state:{sideBarVisible:d},actions:{toggleSideBar:u}}=nr(),p=(0,h.useCallback)((e=>{let{target:t}=e;t!==s.current&&t!==c.current&&u()}),[u,s,c]),m=(0,h.useCallback)((()=>{d&&u()}),[u,d]);(0,h.useFocusOut)(s,m,[d]),(0,h.useLayoutEffect)((()=>{d&&s.current&&s.current.focus()}),[d]);const f=(0,h.useCallback)((()=>{(0,E.trackEvent)("create_new_story")}),[]),g=(0,h.useCallback)(((e,t)=>{(0,E.trackClick)(e,t.trackingEvent)}),[]);return n.createElement(Ha,{onClickCapture:p,ref:s,isOpen:d,topOffset:i,role:"navigation","aria-label":(0,l.__)("Main dashboard navigation","web-stories")},n.createElement("div",{ref:c},n.createElement(ir,{forwardedAs:"h2"},n.createElement(Xa,{title:(0,l.__)("Web Stories Dashboard","web-stories")})),n.createElement(or,null,n.createElement(Bt.ButtonAsLink,{type:Mt.ButtonType.Quaternary,size:Mt.ButtonSize.Small,href:t,onClick:f},(0,l.__)("Create New Story","web-stories"))),n.createElement(or,null,n.createElement(sr,null,Je.map((t=>{let{Icon:a,...r}=t;return r.value===Ye.TEMPLATES_GALLERY&&!o?null:n.createElement(cr,{key:r.value},n.createElement(ur,fr({active:e===r.value,href:tr(r.value),size:Ya.TextSize.Small,isBold:!0,isIconLink:Boolean(a),"aria-label":e===r.value?(0,X.default)(/* translators: %s: the current page, for example "Dashboard". */ (0,l.__)("%s (active view)","web-stories"),r.label):r.label},r.isExternal&&{rel:"noreferrer",target:"_blank",onClick:e=>g(e,r)}),n.createElement(gr,null,a&&n.createElement(a,{width:"22px"})),n.createElement(pr,{size:Ya.TextSize.Small,isBold:!0},r.label)))}))))),n.createElement(or,null,r&&n.createElement(sr,null,r.map((t=>n.createElement(cr,{key:t.value},n.createElement(ur,fr({active:e===t.value,href:tr(t.value),size:Ya.TextSize.Small,"aria-label":e===t.value?(0,X.default)(/* translators: %s: the current page, for example "Dashboard". */ (0,l.__)("%s (active view)","web-stories"),t.label):t.label},t.isExternal&&{rel:"noreferrer",target:"_blank",onClick:e=>g(e,t)}),n.createElement(Sa.Text.Span,{size:Ya.TextSize.Small,isBold:!0},t.label)))))),n.createElement(mr,{size:Ya.TextSize.XSmall},(0,X.default)(/* translators: 1: Current Year, 2: App Version */ (0,l.__)("© %1$s Google Version %2$s","web-stories"),(new Date).getFullYear(),a))))},br=(0,m.default)($).attrs({width:24,height:24}).withConfig({displayName:"menuButton__MenuIcon",componentId:"sc-ov12l5-0"})(["display:block;color:",";"],(e=>{let{theme:t}=e;return t.colors.interactiveFg.brandNormal})),_r=m.default.button.withConfig({displayName:"menuButton__TransparentButton",componentId:"sc-ov12l5-1"})(["display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;margin-right:16px;background:transparent;border:0;border-radius:",";"," ",""],(e=>{let{theme:t}=e;return t.borders.radius.small}),$t.focusableOutlineCSS,(e=>{let{showOnlyOnSmallViewport:t}=e;return t&&(0,m.css)(["display:none;@media screen and (max-width:","px){display:inline-block;}"],je)}));const yr=function NavMenuButton(e){let{showOnlyOnSmallViewport:t}=e;const{actions:a}=nr();return n.createElement(_r,{onClick:a.toggleSideBar,showOnlyOnSmallViewport:t,"aria-label":(0,l.__)("Toggle main navigation","web-stories")},n.createElement(br,{"aria-hidden":!0}))};var Er=a(99832);const Sr=(0,m.default)(Bt.Button).withConfig({displayName:"scrollToTop__StyledButton",componentId:"sc-o0u22z-0"})((e=>{let{$isVisible:t,theme:a}=e;return(0,m.css)(["position:fixed;right:40px;bottom:40px;height:50px;width:50px;display:flex;align-self:center;justify-content:space-around;align-items:center;contain:content;padding:8px;background-color:",";pointer-events:",";box-shadow:0px 4px 14px rgba(0,0,0,0.25);opacity:",";transition:opacity 300ms ease-in-out;"],a.colors.opacity.white64,t?"auto":"none",Number(t))})),wr=(0,m.default)(Er.default).withConfig({displayName:"scrollToTop__DropUpArrowIcon",componentId:"sc-o0u22z-1"})(["position:relative;transform:scale(2.4);"]),vr=()=>{const[e,t]=(0,h.useState)(!1),{actions:{scrollToTop:a}}=Pa(),r=(0,h.useDebouncedCallback)((()=>t(window.scrollY>0)),100);return(0,h.useEffect)((()=>(window.addEventListener("scroll",r,{passive:!0}),function(){window.removeEventListener("scroll",r,{passive:!0})})),[r]),n.createElement(Sr,{disabled:!e,"aria-label":(0,l.__)("Scroll back to top","web-stories"),"data-testid":"scroll-to-top-button",$isVisible:e,onClick:a,variant:Mt.ButtonVariant.Circle},n.createElement(wr,{"aria-hidden":!0}))};var Tr=a(38668);const Cr=m.default.table.withConfig({displayName:"table__Table",componentId:"sc-16y5cap-0"})([""," border-collapse:collapse;width:inherit;"],Tr.expandTextPreset(((e,t)=>{let{paragraph:a}=e,{Small:r}=t;return a[r]}))),Ir=m.default.tbody.withConfig({displayName:"table__TableBody",componentId:"sc-16y5cap-1"})([""]),kr=m.default.thead.withConfig({displayName:"table__TableHeader",componentId:"sc-16y5cap-2"})(["background:",";"],(e=>{let{theme:t}=e;return t.colors.bg.secondary})),Lr=(0,m.default)(kr).withConfig({displayName:"table__StickyTableHeader",componentId:"sc-16y5cap-3"})(["width:100%;border-top:0;border-bottom:0;th{height:100%;background:",";position:sticky;z-index:2;top:",";:first-child{border-top-left-radius:",";border-bottom-left-radius:",";}:last-child{border-top-right-radius:",";border-bottom-right-radius:",";}}"],(e=>{let{theme:t}=e;return t.colors.bg.secondary}),(e=>{let{topOffset:t}=e;return`${t}px`}),(e=>{let{theme:t}=e;return t.borders.radius.small}),(e=>{let{theme:t}=e;return t.borders.radius.small}),(e=>{let{theme:t}=e;return t.borders.radius.small}),(e=>{let{theme:t}=e;return t.borders.radius.small})),Ar=m.default.th.withConfig({displayName:"table__TableHeaderCell",componentId:"sc-16y5cap-4"})(["padding:16px;text-align:left;white-space:nowrap;"]),xr=(0,m.default)(Ar).withConfig({displayName:"table__TablePreviewHeaderCell",componentId:"sc-16y5cap-5"})(["padding-right:0;"]),Or=(0,m.default)(Ar).withConfig({displayName:"table__TableDateHeaderCell",componentId:"sc-16y5cap-6"})(["min-width:160px;"]),Dr=(0,m.default)(Ar).withConfig({displayName:"table__TableStatusHeaderCell",componentId:"sc-16y5cap-7"})(["display:table-cell;min-width:100px;@media ","{display:none;}"],(e=>{let{theme:t}=e;return t.breakpoint.tabletMax})),Nr=(0,m.default)(Ar).withConfig({displayName:"table__TableAuthorHeaderCell",componentId:"sc-16y5cap-8"})(["min-width:110px;"]),Pr=(0,m.default)(Ar).withConfig({displayName:"table__TableTitleHeaderCell",componentId:"sc-16y5cap-9"})(["padding-left:0;width:30%;min-width:135px;span{display:none;margin-right:5px;}"]),Rr=((0,m.default)(Ar).withConfig({displayName:"table__TableContentHeaderCell",componentId:"sc-16y5cap-10"})(["width:17.5%;min-width:150px;"]),m.default.tr.withConfig({displayName:"table__TableRow",componentId:"sc-16y5cap-11"})(["min-width:1250px;@media ","{min-width:0;}"],(e=>{let{theme:t}=e;return t.breakpoint.tabletMax}))),Br=m.default.td.withConfig({displayName:"table__TableCell",componentId:"sc-16y5cap-12"})(["padding:","px;font-weight:normal;word-break:break-word;height:","px;vertical-align:middle;span{color:",";line-height:20px;}"],16,82,(e=>{let{theme:t}=e;return t.colors.standard.black})),Mr=(0,m.default)(Br).withConfig({displayName:"table__TableStatusCell",componentId:"sc-16y5cap-13"})(["display:table-cell;span{color:",";}@media ","{display:none;}"],(e=>{let{theme:t}=e;return t.colors.fg.secondary}),(e=>{let{theme:t}=e;return t.breakpoint.tabletMax})),Ur=((0,m.default)(Br).withConfig({displayName:"table__TableTitleCell",componentId:"sc-16y5cap-14"})(["width:30%;word-wrap:break-word;"]),(0,m.default)(Br).withConfig({displayName:"table__TableContentCell",componentId:"sc-16y5cap-15"})(["width:17.5%;min-width:150px;word-wrap:break-word;"]),(0,m.default)(Br).withConfig({displayName:"table__TablePreviewCell",componentId:"sc-16y5cap-16"})(["width:","px;"],$e[Ve.THUMBNAIL]));var Fr,zr=a(28395),Gr=a(97783);function Hr(){return Hr=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{title:t,titleId:a,...r}=e;return n.createElement("svg",jr({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 32 32","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,Fr||(Fr=n.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M9.5 9A1.5 1.5 0 0 0 8 10.5v11A1.5 1.5 0 0 0 9.5 23h13a1.5 1.5 0 0 0 1.5-1.5v-11A1.5 1.5 0 0 0 22.5 9h-13Zm3 1h-3a.5.5 0 0 0-.5.5V13h3.5v-3ZM9 14v4h3.5v-4H9Zm0 5v2.5a.5.5 0 0 0 .5.5h3v-3H9Zm4.5 3h9a.5.5 0 0 0 .5-.5V19h-9.5v3Zm9.5-4v-4h-9.5v4H23Zm0-5v-2.5a.5.5 0 0 0-.5-.5h-9v3H23Z",clipRule:"evenodd"})))},Vr=(0,n.memo)(SvgTable);var $r=a(98477);const Wr=m.default.div.withConfig({displayName:"viewStyleBar__Container",componentId:"sc-17r9rf0-0"})(["display:flex;justify-content:flex-end;align-items:center;"]),Kr=m.default.button.withConfig({displayName:"viewStyleBar__ToggleButton",componentId:"sc-17r9rf0-1"})(["border:none;border-radius:",";"," padding:0;background:transparent;cursor:pointer;&:hover svg{color:",";}&:active svg{color:",";}"],(e=>{let{theme:t}=e;return t.borders.radius.small}),$t.focusableOutlineCSS,(e=>{let{theme:t}=e;return t.colors.interactiveFg.hover}),(e=>{let{theme:t}=e;return t.colors.interactiveFg.active}));function ViewStyleBar(e){let{onPress:t,layoutStyle:a}=e;return n.createElement(Wr,null,n.createElement(Tooltip,{title:et[a],placement:zr.Placement.BottomEnd,hasTail:!0},n.createElement(Kr,{"aria-label":et[a],onClick:t},a===Qe.GRID&&n.createElement(Vr,{height:"32px",width:"32px","data-testid":"list-icon"}),a===Qe.LIST&&n.createElement($r.default,{height:"32px",width:"32px","data-testid":"grid-icon"}))))}const qr=(0,m.createGlobalStyle)(["h1,h2,h3,h4,h5,h6,p,a{margin:0;}"]),Xr=e=>""===e?(0,l.__)("Untitled","web-stories"):e,Yr=(0,m.createGlobalStyle)(["*:focus{outline:none !important;}"]),Zr=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab"],Jr=()=>{const[e,t]=(0,h.useState)(!1),a=a=>{!e&&Zr.includes(a.key)&&t(!0)},r=()=>{e&&t(!1)};return(0,h.useEffect)((()=>(document.addEventListener("keydown",a),document.addEventListener("mousedown",r),function(){document.removeEventListener("keydown",a),document.removeEventListener("mousedown",r)}))),(0,h.useEffect)((()=>{document.body.classList.toggle("useskeyboard",e)}),[e]),e?null:n.createElement(Yr,null)};function Qr(e){let{isActiveSearch:t,currentFilter:a,totalResults:r,view:n}=e;return(0,h.useMemo)((()=>{const e=r??0,o=rt[n]?.[a]||"",i="function"==typeof o?o(e):o;return t?(0,X.default)(/* translators: %s: number of results. */ (0,l._n)("%s result","%s results",e,"web-stories"),(0,X.default)("%s",e)):i}),[t,r,n,a])}const en=e=>Math.round(e/.6666666666666666),tn=e=>e<=je?Ve.TABLET:Ve.DESKTOP,an=(e,t)=>{let{bp:a,respectSetWidth:r,availableContainerSpace:n}=t;if(r){return{width:e,height:en(e)}}a===Ve.DESKTOP&&(n-=He);const l=Math.floor(n/e),o=e+(n-(e*l+We*(l-1)+2*qe))/l;return{width:o,height:en(o)}},rn=e=>window.innerWidth0&&void 0!==arguments[0]?arguments[0]:{};const{thumbnailMode:t=!1,isGrid:a}=e,{containerId:r}=y(),n=(0,h.useRef)(document.getElementById(r)),[l,o]=(0,h.useState)(window.innerWidth),[i,s]=(0,h.useState)(tn(l)),[c,d]=(0,h.useState)(rn(n.current?.offsetWidth||window.innerWidth)),u=(0,h.useDebouncedCallback)((e=>{o(e)}),500);return(0,h.useEffect)((()=>{s(tn(l))}),[l]),(0,h.useResizeEffect)(n,(e=>{let{width:t}=e;d(rn(t)),window.innerWidth!==l&&u(window.innerWidth)}),[d,l,u]),(0,h.useMemo)((()=>({pageSize:an($e[t?Ve.THUMBNAIL:i],{respectSetWidth:!a||t,availableContainerSpace:c,bp:i})})),[i,a,t,c])}const ln=(e,t)=>{let{MIN:a,MAX:r}=t;return Math.min(Math.max(e,a),r)};Rt().shape({style:Rt().oneOf(Object.values(Qe)),toggleStyle:Rt().func,pageSize:Xt}),Rt().shape({filterId:Rt().number,toggleFilterId:Rt().func,queriedAuthors:Rt().arrayOf(Rt().shape({id:Rt().number,name:Rt().string})).isRequired,setQueriedAuthors:Rt().func}),Rt().shape({value:Rt().oneOfType([Rt().number,Rt().string]),set:Rt().func}),Rt().shape({value:Rt().oneOf(Object.values(ne)),set:Rt().func,direction:Rt().oneOf(Object.values(re)),setDirection:Rt().func}),Rt().shape({value:Rt().number,set:Rt().func,requestNextPage:Rt().func}),Rt().shape({keyword:Rt().string,setKeyword:Rt().func}),Rt().shape({current:Rt().bool});Rt().shape({style:Rt().oneOf(Object.values(Qe)),pageSize:Xt}),Rt().shape({value:Rt().oneOfType([Rt().number,Rt().string]),set:Rt().func}),Rt().shape({value:Rt().number,set:Rt().func,requestNextPage:Rt().func}),Rt().shape({keyword:Rt().string,setKeyword:Rt().func}),Rt().shape({value:Rt().oneOf(Object.values(Re)),set:Rt().func});const on=()=>{},sn=()=>({isRTL:!1,userId:1,locale:{locale:"en-US",dateFormat:"F j, Y",timeFormat:"g:i a",gmtOffset:"0",timezone:"",months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],weekdaysInitials:["S","M","T","W","T","F","S"],weekStartsOn:1},newStoryURL:"",cdnURL:"https://wp.stories.google/static/main/",version:"",capabilities:{canManageSettings:!1,canUploadFiles:!1},canViewDefaultTemplates:!1,flags:{},apiCallbacks:{},leftRailSecondaryNavigation:[],styleConstants:{topOffset:0,leftOffset:0}});Object.defineProperty(f.default,"name",{value:"stylisRTLPlugin"});const cn=function Dashboard(e){let{config:t,children:a}=e;const r=(0,o.default)(sn(),t),l={...i.theme,colors:s.light},{isRTL:h,flags:b,styleConstants:{leftOffset:y,topOffset:E}={}}=r;return n.createElement(g.FlagsProvider,{features:b},n.createElement(m.StyleSheetManager,{stylisPlugins:h?[f.default]:[]},n.createElement(m.ThemeProvider,{theme:l},n.createElement(c.Styles,null),n.createElement(d.ModalGlobalStyle,null),n.createElement(_,{config:r},n.createElement(ApiProvider,null,n.createElement(NavProvider,null,n.createElement(Qa,null,n.createElement(u.default,null,n.createElement(p.default,{value:{isRTL:h,leftOffset:y,topOffset:E}},n.createElement(qr,null),n.createElement(Jr,null),a)))))))))};var dn=a(13013),un=a(80125);a(70928);const pn="UPDATE_FILTER",mn="UPDATE_SORT",fn="REGISTER_FILTERS",gn=(e,t)=>{let{type:a,payload:r={}}=t;switch(a){case pn:{const t=["search","status"],{key:a,value:n}=r,l=e.filters.find((e=>e.key===a));if(!l)return e;if(n.filterId&&l?.filterId===n.filterId){if(t.includes(a))return e;n.filterId=null}const o=e.filters.indexOf(l),i=[...e.filters];i[o]={...l,...n};const s={};for(const e of i)e.filterId&&(s[e.key]=e.filterId);return{...e,filters:i,filtersObject:s}}case mn:{const{type:t,values:a}=r,n={},l="story"===t?le:Be;for(const t in a)t in l&&Object.values(l[t]).includes(a[t])&&e.sortObject[t]!==a[t]&&(n[t]=a[t]);return 0===Object.entries(n).length?e:{...e,sortObject:{...e.sortObject,...n}}}case fn:{const{value:t}=r,a=e.filters.map((e=>e.key)),n=t.filter((e=>!a.includes(e.key)));return n.length?{...e,filters:[...n,...e.filters]}:e}default:return e}};function hn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.identity;return(0,h.useContextSelector)(Dt,e)}const bn={};const _n=function(){const{getTaxonomies:e,getTaxonomyTerms:t}=hn((e=>{let{actions:{taxonomyApi:{getTaxonomies:t,getTaxonomyTerms:a}}}=e;return{getTaxonomies:t,getTaxonomyTerms:a}})),a=(0,h.useCallback)((async(e,a)=>{const{restBase:r,restPath:n}=e;return(await t(n,{search:a,per_page:-1})).map((e=>({...e,restBase:r,restPath:n})))}),[t]),r=(0,h.useCallback)((async e=>{const{restBase:t}=e;return bn[t]||(bn[t]=await a(e)),bn[t]}),[a]),n=(0,h.useCallback)((async()=>(await e({hierarchical:!0,show_ui:!0})).map((e=>({key:e.restBase,restPath:e.restPath,placeholder:e.labels.allItems,ariaLabel:e.labels.filterByItem,noMatchesFoundLabel:e.labels.notFound,searchPlaceholder:e.labels.searchItems,query:t=>a(e,t),getPrimaryOptions:()=>r(e)})))),[a,r,e]);return n};let yn=null;const En=function(){const{getAuthors:e}=hn((e=>{let{actions:{usersApi:{getAuthors:t}}}=e;return{getAuthors:t}})),t=(0,h.useCallback)((async t=>(await e(t)).map((e=>{let{id:t,name:a}=e;return{id:t,name:a}}))),[e]),a=(0,h.useCallback)((async()=>(yn||(yn=await t()),yn)),[t]);return(0,h.useCallback)((()=>({key:"author",ariaLabel:(0,l.__)("Filter stories by author","web-stories"),placeholder:(0,l.__)("All Authors","web-stories"),searchPlaceholder:(0,l.__)("Search Authors","web-stories"),noMatchesFoundLabel:(0,l.__)("No authors found","web-stories"),query:t,getPrimaryOptions:a})),[t,a])},Sn=(0,h.createContext)({state:{},actions:{}});function StoryFiltersProvider(e){let{children:t}=e;const a=_n(),r=En(),[l,o]=(0,h.useReducer)(gn,{filters:[],filtersObject:{},sortObject:{}}),i=(0,h.useCallback)((e=>{o({type:mn,payload:{type:"story",values:e}})}),[]),s=(0,h.useCallback)(((e,t)=>{o({type:pn,payload:{key:e,value:t}})}),[]),c=(0,h.useCallback)((e=>{o({type:fn,payload:{value:e}})}),[]),d=(0,h.useCallback)((async()=>{const e=[...await a(),r()].filter((e=>Boolean(e)));e.length&&c(e)}),[c,r,a]),u=(0,h.useMemo)((()=>({state:l,actions:{updateFilter:s,updateSort:i,registerFilters:c}})),[l,s,i,c]);return(0,h.useEffect)((()=>{d()}),[d]),n.createElement(Sn.Provider,{value:u},t)}function wn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.identity;return(0,h.useContextSelector)(Sn,e)}var vn=a(76274);const Tn=(0,m.default)(vn.default).withConfig({displayName:"sortDropDown__StyledDropDown",componentId:"sc-lqi6ue-0"})(["width:210px;"]);const Cn=function SortDropDown(e){let{pageSortOptions:t,pageSortDefaultOption:a,currentSort:r,handleSortChange:o}=e;const i=(0,h.useCallback)(((e,t)=>{o({orderby:t})}),[o]);return n.createElement(Tn,{ariaLabel:(0,l.__)("Choose sort option for display","web-stories"),options:t,type:ze.DropDown,selectedValue:r?.orderby||a,onMenuItemClick:i})},In=350,kn=m.default.div.withConfig({displayName:"bodyViewOptions__DisplayFormatContainer",componentId:"sc-x2ax3p-0"})(["display:grid;gap:1rem;min-height:76px;grid-template-columns:1fr auto auto;justify-content:start;align-items:center;margin-top:-10px;"]),Ln=m.default.div.withConfig({displayName:"bodyViewOptions__StorySortDropdownContainer",componentId:"sc-x2ax3p-1"})(["margin:auto 8px;align-self:flex-end;"]),An=m.default.div.withConfig({displayName:"bodyViewOptions__ControlsContainer",componentId:"sc-x2ax3p-2"})(["display:flex;flex-wrap:wrap;margin:1rem 0;row-gap:1rem;justify-self:end;"]),xn=m.default.div.withConfig({displayName:"bodyViewOptions__BodyViewOptionsHeader",componentId:"sc-x2ax3p-3"})([""]),On=(0,m.default)(un.default).withConfig({displayName:"bodyViewOptions__StyledDatalist",componentId:"sc-x2ax3p-4"})(["max-width:","px;"],In);function BodyViewOptions(e){let{handleLayoutSelect:t,resultsLabel:a,layoutStyle:r,pageSortOptions:o=[],pageSortDefaultOption:i,showGridToggle:s,showSortDropdown:c,filters:d=[],currentSort:u,handleSortChange:p}=e;const{updateFilter:f}=wn((e=>{let{actions:{updateFilter:t}}=e;return{updateFilter:t}}));return n.createElement(ha,null,n.createElement(xn,{id:"body-view-options-header"}),n.createElement(kn,null,n.createElement(Sa.Text.Span,{size:Ya.TextSize.Small},n.createElement(dn.default,null,a)),n.createElement(An,null,d?.length?d.map((e=>n.createElement(Ln,{key:e.key,title:e.placeholder},n.createElement(On,{hasSearch:!0,hasDropDownBorder:!0,searchResultsLabel:(0,l.__)("Search results","web-stories"),"aria-label":e.ariaLabel,onChange:t=>{let{id:a}=t;f(e.key,{filterId:a})},getOptionsByQuery:e.query,getPrimaryOptions:e.getPrimaryOptions,selectedId:e.filterId,placeholder:e.placeholder,noMatchesFoundLabel:e.noMatchesFoundLabel,searchPlaceholder:e.searchPlaceholder,offsetOverride:!0,maxWidth:In,containerStyleOverrides:(0,m.css)(["flex-direction:column;"])})))):null,c&&n.createElement(Ln,null,n.createElement(Cn,{pageSortOptions:o,pageSortDefaultOption:i,currentSort:u,handleSortChange:p}))),s&&n.createElement(ViewStyleBar,{layoutStyle:r,onPress:t})))}var Dn,Nn,Pn;function Rn(){return Rn=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{title:t,titleId:a,...r}=e;return n.createElement("svg",Rn({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 274 118","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,Dn||(Dn=n.createElement("path",{fill:"#F4F2EF",d:"M59.68 117.706 8.551 106.934C2.505 105.66-.951 99.261 1.3 93.506l1.18-3.019a10 10 0 0 1 7.987-6.268l78.794-10.544a10.003 10.003 0 0 0 2.525-.683l82.061-34.244a10 10 0 0 1 8.263.255l56.296 27.675c.436.215.886.397 1.349.545l26.84 8.637c9.132 2.939 9.287 15.804.228 18.962l-26.529 9.248c-.819.285-1.671.463-2.536.529L62.497 117.892a9.985 9.985 0 0 1-2.818-.186Z"})),Nn||(Nn=n.createElement("path",{fill:"#FBBC04",fillRule:"evenodd",d:"M224 26a4 4 0 0 1 4-4h2a4 4 0 0 1 4 4v31h4V44a2 2 0 0 1 2-2h1a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2h-7v17h-10V49h-7a2 2 0 0 1-2-2V31a2 2 0 0 1 2-2h1a2 2 0 0 1 2 2v13h4V26ZM120.857 53.178a2.143 2.143 0 0 1 4.286 0v14.25h1.714v-5.357a1.072 1.072 0 0 1 2.143 0V68.5a1.146 1.146 0 0 1-.048.319 1.073 1.073 0 0 1-1.023.753h-2.786v5.892h-4.286v-7.892h-2.786A1.073 1.073 0 0 1 117 66.5v-6.429a1.072 1.072 0 0 1 2.143 0v5.358h1.714v-12.25ZM64.786 8a8 8 0 0 1 8-8h.428a8 8 0 0 1 8 8v34.643h6.572V22a4 4 0 0 1 4-4H92a4 4 0 0 1 4 4v24.857a4 4 0 0 1-4 4H81.214v42.786H64.786V78.857H54a3.987 3.987 0 0 1-2.828-1.171A3.988 3.988 0 0 1 50 74.857V50a4 4 0 0 1 4-4h.214a4 4 0 0 1 4 4v20.643h6.572V8Z",clipRule:"evenodd"})),Pn||(Pn=n.createElement("circle",{cx:213,cy:72,r:13,fill:"#4285F4"})))},Bn=(0,n.memo)(SvgDesertColor),Mn=m.default.div.withConfig({displayName:"emptyContentMessage__Message",componentId:"sc-1wgc64w-0"})(["display:flex;flex-direction:column;align-items:center;max-width:400px;margin:20vh auto;& > *{text-align:center;margin:0 auto;}button,a{margin-top:48px;}"]),Un=(0,m.default)(Bn).withConfig({displayName:"emptyContentMessage__EmptyImage",componentId:"sc-1wgc64w-1"})(["margin-bottom:48px;"]);const Fn=function EmptyContentMessage(e){let{children:t}=e;return n.createElement(Mn,null,n.createElement(Un,{"aria-hidden":!0,width:274,height:118}),t)};var zn=a(97831);const Gn=m.default.h1.withConfig({displayName:"display__Display",componentId:"sc-1x3xqpc-0"})([""," ",""],zn.defaultTypographyStyle,(e=>{let{size:t=Ya.TextSize.Medium,theme:a}=e;return Tr.expandPresetStyles({preset:a.typography.presets.display[t],theme:a})}));var Hn=a(46315),jn=a(80852),Vn=a(59470);const $n=m.default.div.withConfig({displayName:"search__DropDownContainer",componentId:"sc-1i3s2c5-0"})(["display:flex;flex-direction:column;width:100%;"]),Wn=(0,m.default)(Sa.Text.Label).withConfig({displayName:"search__Label",componentId:"sc-1i3s2c5-1"})(["margin-bottom:8px;color:",";"],(e=>{let{theme:t,disabled:a}=e;return t.colors.fg[a?"disable":"primary"]})),Kn=(0,m.default)(Sa.Text.Paragraph).withConfig({displayName:"search__Hint",componentId:"sc-1i3s2c5-2"})(["margin-top:12px;padding-left:2px;color:",";"],(e=>{let{theme:t,hasError:a}=e;return t.colors.fg[a?"negative":"tertiary"]}));var qn=a(1782),Xn=a(38090),Yn=(a(49411),a(62488)),Zn=a(19574);function Jn(){return Jn=Object.assign?Object.assign.bind():function(e){for(var t=1;t`list-${(0,Qt.default)()}`),[]),w=(0,h.useMemo)((()=>`select-button-${(0,Qt.default)()}`),[]),v=(0,h.useMemo)((()=>`clear-button-${(0,Qt.default)()}`),[]),T=(0,h.useRef)(null),C=(0,h.useRef)(null),{activeOption:I,getActiveOption:k,inputState:L,setInputState:A,isMenuFocused:x,setIsMenuFocused:O,isOpen:D,setIsOpen:N,groups:P}=function(e){let{handleSearchValueChange:t,selectedValue:a,searchValue:r,options:n}=e;const o=(0,Zn.default)("assertive"),[i,s]=(0,h.useState)(!1),c=(0,h.useDebouncedCallback)(s,100),[d,u]=(0,h.useState)(!1),p=(0,h.useDebouncedCallback)(u,300,{leading:!0});(0,h.useEffect)((()=>{i||p(!1)}),[i,p]);const m=(0,h.useMemo)((()=>(0,Yn.getGroups)(n)),[n]),f=(0,h.useCallback)((e=>m.flatMap((e=>e.options)).find((t=>String(t.value).toLowerCase()===String(e).toLowerCase()))),[m]),g=(0,h.useMemo)((()=>{const e=a?String(a.value):r;return e&&0!==m.length?f(e):null}),[a,r,m,f]),[b,_]=(0,h.useState)(r),y=(0,h.useCallback)((e=>{_(e),void 0!==e&&t?.(e)}),[t]);return(0,h.useEffect)((()=>{void 0===b&&void 0!==a?.value&&y(a?.label||"")}),[b,y,a]),(0,h.useEffect)((()=>{if(i&&b?.length){const e=n.length?(0,X.default)(/* translators: %d: number of results. */ (0,l._n)("%d result found.","%d results found.",n.length,"web-stories"),String(n.length)):(0,l.__)("No results found.","web-stories");o(e)}}),[b,i,n.length,o]),{activeOption:g,getActiveOption:f,groups:m,inputState:b,setInputState:y,isMenuFocused:d,setIsMenuFocused:p,isOpen:i,setIsOpen:c}}({options:p,selectedValue:_,searchValue:y,handleSearchValueChange:o}),R=(0,h.useMemo)((()=>Boolean(r||!L?.length)),[r,L]),B=(0,h.useCallback)((()=>{N(!0),O(!1)}),[N,O]),M=(0,h.useCallback)((e=>{e.preventDefault(),N(!0)}),[N]),U=(0,h.useCallback)((e=>{v&&e?.currentTarget instanceof HTMLElement&&e.currentTarget.id===v||N(!1)}),[v,N]),F=(0,h.useCallback)(((e,t)=>{N(!1);const a=k(t)||{label:String(t),value:t};A(String(a.label)),d?.(e,a)}),[k,A,N,d]),z=(0,h.useCallback)((()=>T?.current?.focus()),[]),G=(0,h.useCallback)((e=>{let{target:t}=e;A(t.value),N(t.value.length>0)}),[A,N]),H=(0,h.useCallback)((()=>{A(""),u?.(),z?.()}),[z,A,u]),j=(0,h.useCallback)((()=>{N(!1),O(!1)}),[N,O]),V=(0,h.useCallback)((()=>O(!0)),[O]),$=(0,h.useCallback)((()=>{(R||0===L?.trim().length)&&(O(!1),N(!1))}),[L,O,R,N]),W=(0,h.useCallback)((e=>{const{key:t}=e;"Escape"===t?R||O(!1):"Tab"===t?$():"ArrowDown"===t?V():"Enter"===t&&L&&L.trim().length>0&&F(e.nativeEvent,String(L))}),[R,O,$,V,L,F]);return(0,h.useFocusOut)(C,$,[$]),n.createElement($n,null,c&&n.createElement(Wn,{size:Ya.TextSize.Small,disabled:r,isBold:!0},c),n.createElement(Qn,{ref:C},n.createElement(Xn.default,Jn({"aria-label":t,hasError:i,id:w,onChange:G,onClick:M,onFocus:B,onKeyDown:W,placeholder:m,ariaClearLabel:a,clearId:v,disabled:r,handleClearInput:H,handleTabClear:j,inputValue:L||"",isOpen:D,listId:S,ref:T},E))),!R&&n.createElement(Vn.default,{anchor:T,isOpen:D,placement:f,fillWidth:g,zIndex:b,ignoreMaxOffsetY:!0},n.createElement(jn.default,Jn({activeValue:I?.value,handleReturnToParent:z,isMenuFocused:x,listId:S,menuAriaLabel:(0,X.default)(/* translators: %s: dropdown aria label or general dropdown label if there is no specific aria label. */ (0,l.__)("%s Option List Selector","web-stories"),t),onDismissMenu:U,handleMenuItemSelect:F,groups:P,parentId:w},E))),s&&n.createElement(Kn,{hasError:i,size:Ya.TextSize.Small},s))},tl=(0,m.default)(ha).withConfig({displayName:"pageHeading__HeadingContainer",componentId:"sc-1ln7suo-0"})(["display:flex;align-items:center;flex-wrap:wrap;justify-content:space-between;margin-bottom:16px;padding-top:48px;border-bottom:1px solid ",";"],(e=>{let{theme:t}=e;return t.colors.divider.secondary})),al=(0,m.default)(Gn).withConfig({displayName:"pageHeading__StyledHeadline",componentId:"sc-1ln7suo-1"})(["display:flex;align-items:center;margin-right:28px;padding-bottom:24px;white-space:nowrap;"]),rl=m.default.div.withConfig({displayName:"pageHeading__HeadlineFilters",componentId:"sc-1ln7suo-2"})(["display:flex;align-items:center;margin:auto 0 auto 0;padding-bottom:24px;"]),nl=m.default.div.withConfig({displayName:"pageHeading__HeaderSearch",componentId:"sc-1ln7suo-3"})(["width:208px;max-width:208px;min-width:208px;margin:auto 0;padding-bottom:24px;"]),ll=e=>{let{children:t,heading:a,searchPlaceholder:r,searchOptions:o=[],showSearch:i,handleSearchChange:s,searchValue:c,onClear:d=Hn.noop}=e;return n.createElement(tl,null,n.createElement(al,{as:"h2",size:Ya.TextSize.Small},n.createElement(yr,{showOnlyOnSmallViewport:!0}),a),t&&n.createElement(rl,null,t),i&&n.createElement(nl,null,n.createElement(el,{placeholder:r,searchValue:c,options:o,handleSearchValueChange:s,onClear:d,emptyText:(0,l.__)("No options available","web-stories")})))};var ol,il=a(71028),sl=a(26707),cl=a(61736),dl=a(92414);function ul(){return ul=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{title:t,titleId:a,...r}=e;return n.createElement("svg",ul({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 32 32","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,ol||(ol=n.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"m16.5 21.282 4.645-4.704a.5.5 0 0 1 .711.702l-5.5 5.571a.5.5 0 0 1-.712 0l-5.5-5.57a.5.5 0 0 1 .712-.703l4.644 4.704V9.5a.5.5 0 0 1 1 0v11.782Z",clipRule:"evenodd"})))},pl=(0,n.memo)(SvgArrowDown),ml=e=>{let{menuItems:t,story:a,isLocked:r}=e;const n=t.default?()=>t.default(a):on;return t.filter((e=>void 0===e.isEnabled||e.isEnabled(a))).map((e=>{let{capability:l,value:o,...i}=e;const s=(e=>t.find((t=>t?.value===e)))(o),c={onClick:s?()=>s.action(a):n};switch(o){case Y:c.href=a.bottomTargetAction,c.openNewTab=!1;break;case te:c.href=a.previewLink,c.openNewTab=!0;break;case Z:case Q:c.disabled=r}return delete i?.action,{...i,...c}}))};var fl=a(37233);const gl=m.default.div.withConfig({displayName:"storyListItem__PreviewImage",componentId:"sc-1w22569-0"})(["display:inline-block;background:",";width:","px;height:","px;object-fit:contain;border-radius:",";"],(e=>{let{theme:t}=e;return t.colors.gradient.placeholder}),$e[Ve.THUMBNAIL],$e[Ve.THUMBNAIL]/(3/4),(e=>{let{theme:t}=e;return t.borders.radius.small})),hl=m.default.div.withConfig({displayName:"storyListItem__PreviewWrapper",componentId:"sc-1w22569-1"})(["position:relative;"]),bl=(0,m.default)(fl.default).withConfig({displayName:"storyListItem__LockIcon",componentId:"sc-1w22569-2"})(["position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);height:24px;display:block;margin:auto;background-color:",";color:",";border-radius:",";"],(e=>{let{theme:t}=e;return t.colors.interactiveBg.brandNormal}),(e=>{let{theme:t}=e;return t.colors.standard.white}),(e=>{let{theme:t}=e;return t.borders.radius.round})),_l=(0,m.default)(Rr).withConfig({displayName:"storyListItem__StyledTableRow",componentId:"sc-1w22569-3"})(["&:hover ",",&:focus-within ","{opacity:1;}"],sa,sa),yl=m.default.div.withConfig({displayName:"storyListItem__TitleTableCellContainer",componentId:"sc-1w22569-4"})(["display:flex;align-items:center;justify-content:flex-start;","{margin:10px auto;}&:hover ",",&:active ","{opacity:1;}"],sa,sa,sa);function El(e){window.getSelection().selectAllChildren(e.target)}function Sl(){window.getSelection().removeAllRanges()}const StoryListItem=e=>{let{story:t,renameStory:a,userId:r,storyMenu:o,storyStatus:i}=e;const s=(0,h.useMemo)((()=>t?.locked&&r!==t?.lockUser.id),[t,r]),c=Xr(t.title),d=(0,h.useMemo)((()=>ml({menuItems:o.menuItems,story:t,isLocked:s})),[o,t,s]),u=(0,h.useMemo)((()=>d.length?n.createElement(StoryMenu,{menuLabel:(0,X.default)(/* translators: %s: story title.*/ (0,l.__)("Context menu for %s","web-stories"),c),onMoreButtonSelected:(e,t)=>o.handleMenuToggle(t),contextMenuId:o.contextMenuId,storyId:t.id,menuItems:d,verticalAlign:"center"}):null),[d,c,o,t]);return n.createElement(_l,{"data-testid":`story-list-item-${t.id}`},n.createElement(Ur,null,n.createElement(Tooltip,{title:s&&t?.lockUser.name?(0,X.default)(/* translators: %s: user name */ (0,l.__)("%s is currently editing this story","web-stories"),t?.lockUser.name):""},n.createElement(hl,null,n.createElement(gl,t.featuredMediaUrl?{src:t.featuredMediaUrl,alt:(0,X.default)(/* translators: %s: Story title. */ (0,l.__)("%s Poster image","web-stories"),c),as:"img",decoding:"async"}:null),s&&n.createElement(bl,null)))),n.createElement(Br,null,n.createElement(yl,null,a.id===t.id?n.createElement(Oa,{onEditComplete:e=>a.handleOnRenameStory(t,e),onEditCancel:a.handleCancelRename,value:t.title,id:t.id,label:(0,l.__)("Rename story","web-stories")}):n.createElement(n.Fragment,null,n.createElement(lr.Headline,{tabIndex:0,onFocus:El,onBlur:Sl,size:Ya.TextSize.XXXSmall,as:"h3","aria-label":s?(0,X.default)(/* translators: 1: story title. 2: user currently editing the story. */ (0,l.__)("%1$s (locked by %2$s)","web-stories"),c,t?.lockUser.name):c},c),u))),n.createElement(Br,null,n.createElement(Sa.Text.Span,{size:Ya.TextSize.Small},t.author?.name||"—")),n.createElement(Br,null,n.createElement(Sa.Text.Span,{size:Ya.TextSize.Small},Et(t.createdGmt))),n.createElement(Br,null,n.createElement(Sa.Text.Span,{size:Ya.TextSize.Small},Et(t.modifiedGmt))),i!==ce.DRAFT&&n.createElement(Mr,null,n.createElement(Sa.Text.Span,{size:Ya.TextSize.Small},de[t?.status])))};var wl=a(75097);const{focusableOutlineCSS:vl}=wl,Tl=m.default.div.withConfig({displayName:"listView__ListView",componentId:"sc-15nl0r5-0"})(["width:100%;"]),Cl=m.default.div.withConfig({displayName:"listView__ArrowIcon",componentId:"sc-15nl0r5-1"})(["width:32px;height:100%;display:inline-grid;color:",";vertical-align:middle;svg{visibility:",";transition:transform 0.15s;",";}"],(e=>{let{theme:t}=e;return t.colors.fg.primary}),(e=>{let{active:t}=e;return t?"visible":"hidden"}),(e=>{let{asc:t}=e;return t&&(0,m.css)(["transform:rotate(180deg);"])})),Il=m.default.div.withConfig({displayName:"listView__EmptyIconSpace",componentId:"sc-15nl0r5-2"})(["height:32px;width:32px;"]),kl=(0,m.default)(Cl).withConfig({displayName:"listView__ArrowIconWithTitle",componentId:"sc-15nl0r5-3"})([""," position:absolute;top:16px;@media ","{margin-left:4px;}"],(e=>{let{active:t}=e;return!t&&"display: none;"}),(e=>{let{theme:t}=e;return t.breakpoint.mobile})),Ll=(0,m.default)(Sa.Text.Span).attrs({tabIndex:0,isBold:!0}).withConfig({displayName:"listView__SelectableTitle",componentId:"sc-15nl0r5-4"})(["color:",";cursor:pointer;",";"],(e=>{let{theme:t}=e;return t.colors.blue[70]}),(e=>{let{theme:t}=e;return vl(t.colors.border.focus,t.colors.bg.secondary)})),Al={[re.DESC]:re.ASC,[re.ASC]:re.DESC};function StoryListView(e){let{hideStoryList:t,renameStory:a,stories:r,storyMenu:o}=e;const{userId:i,styleConstants:{topOffset:s}}=y(),{filters:c,sortObject:d,updateSort:u}=wn((e=>{let{state:{filters:t,sortObject:a},actions:{updateSort:r}}=e;return{filters:t,sortObject:a,updateSort:r}})),[p,m]=(0,h.useMemo)((()=>[d?.orderby,d?.order]),[d]),f=(0,h.useMemo)((()=>c.filter((e=>{let{key:t}=e;return"status"===t})).filterId),[c]),g=(0,h.useCallback)((e=>{u(e!==p?{orderby:e,order:oe[e]}:{order:Al[m]})}),[u,p,m]),b=(0,h.useCallback)(((e,t)=>{let{key:a}=e;"Enter"===a&&g(t)}),[g]),_=(0,h.useMemo)((()=>!t&&r.map((e=>n.createElement(StoryListItem,{key:`story-${e.id}`,story:e,userId:i,renameStory:a,storyStatus:f,storyMenu:o})))),[t,a,r,f,o,i]);return n.createElement(Tl,{"data-testid":"story-list-view"},n.createElement(Cr,{"aria-label":(0,l.__)("List view of created stories","web-stories")},n.createElement(Lr,{topOffset:s},n.createElement(Rr,null,n.createElement(xr,{onClick:()=>g(ne.NAME),onKeyDown:e=>b(e,ne.NAME)},n.createElement(Ll,{"aria-label":(0,l.__)("Title, select to sort table by story title","web-stories"),size:Ya.TextSize.Small,isBold:!0},(0,l.__)("Title","web-stories"))),n.createElement(Pr,{onClick:()=>g(ne.NAME),onKeyDown:e=>b(e,ne.NAME)},n.createElement(Ll,{"aria-hidden":!0,active:p===ne.NAME,size:Ya.TextSize.Small,isBold:!0},(0,l.__)("Title","web-stories")),n.createElement(Cl,{active:p===ne.NAME,asc:m===re.ASC},n.createElement(pl,null))),n.createElement(Nr,null,n.createElement(Ll,{"aria-label":(0,l.__)("Author, select to sort table by story author","web-stories"),onClick:()=>g(ne.CREATED_BY),onKeyDown:e=>b(e,ne.CREATED_BY),active:p===ne.CREATED_BY,size:Ya.TextSize.Small,isBold:!0},(0,l.__)("Author","web-stories")),n.createElement(kl,{"aria-hidden":!0,active:p===ne.CREATED_BY,asc:m===re.ASC},p===ne.CREATED_BY?n.createElement(pl,null):n.createElement(Il,null))),n.createElement(Or,null,n.createElement(Ll,{"aria-label":(0,l.__)("Creation date, select to sort table by date story was created","web-stories"),onClick:()=>g(ne.DATE_CREATED),onKeyDown:e=>b(e,ne.DATE_CREATED),active:p===ne.DATE_CREATED,size:Ya.TextSize.Small,isBold:!0},(0,l.__)("Date Created","web-stories")),n.createElement(kl,{"aria-hidden":!0,active:p===ne.DATE_CREATED,asc:m===re.ASC},n.createElement(pl,null))),n.createElement(Or,null,n.createElement(Ll,{"aria-label":(0,l.__)("Modification date, select to sort table by date story was last modified","web-stories"),onClick:()=>g(ne.LAST_MODIFIED),onKeyDown:e=>b(e,ne.LAST_MODIFIED),active:p===ne.LAST_MODIFIED,size:Ya.TextSize.Small,isBold:!0},(0,l.__)("Last Modified","web-stories")),n.createElement(kl,{"aria-hidden":!0,active:p===ne.LAST_MODIFIED,asc:m===re.ASC},n.createElement(pl,null))),f!==ce.DRAFT&&n.createElement(Dr,null,n.createElement(Sa.Text.Span,{isBold:!0,size:Ya.TextSize.Small},(0,l.__)("Publish State","web-stories"))))),n.createElement(Ir,null,_)))}var xl=a(19269);const Ol=m.default.div.withConfig({displayName:"grid__Gradient",componentId:"sc-fbjjp8-0"})(["position:absolute;bottom:0;height:67%;width:100%;border-radius:",";background:",";"],(e=>{let{theme:t}=e;return t.borders.radius.medium}),(e=>{let{theme:t}=e;return t.colors.gradient.posterOverlay})),Dl=m.default.div.withConfig({displayName:"grid__Scrim",componentId:"sc-fbjjp8-1"})(["position:absolute;top:0;width:100%;height:100%;box-sizing:border-box;display:flex;flex-direction:column;justify-content:flex-end;border-radius:",";background:",";"],(e=>{let{theme:t}=e;return t.borders.radius.medium}),(e=>{let{theme:t}=e;return t.colors.opacity.black3})),Nl=m.default.div.withConfig({displayName:"grid__Container",componentId:"sc-fbjjp8-2"})(["position:relative;"]),Pl=m.default.div.withConfig({displayName:"grid__Poster",componentId:"sc-fbjjp8-3"})(["height:100%;width:100%;object-fit:cover;border-radius:",";background:",";"],(e=>{let{theme:t}=e;return t.borders.radius.medium}),(e=>{let{theme:t}=e;return t.colors.gradient.placeholder})),Rl=(0,m.default)(ua).withConfig({displayName:"storyGridItem__CustomCardGridItem",componentId:"sc-1vhey8s-0"})(["display:grid;grid-template-columns:100%;grid-template-rows:",";"],(e=>{let{$posterHeight:t}=e;return`${t}px auto`}));Rl.propTypes={$posterHeight:Rt().number};const Bl=m.default.div.withConfig({displayName:"storyGridItem__CardWrapper",componentId:"sc-1vhey8s-1"})(["position:absolute;height:100%;width:100%;"]),Ml=m.default.a.withConfig({displayName:"storyGridItem__ScrimAnchor",componentId:"sc-1vhey8s-2"})(["position:absolute;top:0;width:100%;height:100%;box-sizing:border-box;border-radius:",";&:hover,&:focus{box-shadow:none;border:",";}"],(e=>{let{theme:t}=e;return t.borders.radius.medium}),(e=>{let{theme:t}=e;return`4px solid ${t.colors.interactiveBg.active}`})),Ul=m.default.div.withConfig({displayName:"storyGridItem__StyledStoryDisplayContent",componentId:"sc-1vhey8s-3"})(["padding:20px 12px 8px 12px;display:flex;flex-direction:column;width:100%;"]),Fl=m.default.div.withConfig({displayName:"storyGridItem__Row",componentId:"sc-1vhey8s-4"})(["width:100%;display:flex;align-items:flex-end;flex-wrap:wrap;"]),zl=(0,m.default)(Fl).withConfig({displayName:"storyGridItem__LockedRow",componentId:"sc-1vhey8s-5"})(["position:absolute;top:8px;right:8px;justify-content:flex-end;align-items:center;"]),Gl=m.default.div.withConfig({displayName:"storyGridItem__CardDetailsGrid",componentId:"sc-1vhey8s-6"})(["display:grid;grid-template-columns:80% auto;margin-top:4px;"]),Hl=m.default.div.withConfig({displayName:"storyGridItem__CardDetailsColumn",componentId:"sc-1vhey8s-7"})(["display:flex;align-items:space-between;flex-direction:column;align-self:flex-end;"]),jl=(0,m.default)(lr.Headline).attrs({as:"h3",size:Ya.TextSize.XSmall}).withConfig({displayName:"storyGridItem__Title",componentId:"sc-1vhey8s-8"})(["overflow:hidden;text-overflow:ellipsis;color:",";margin:0;max-height:calc(1.2em * 3);display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;"],(e=>{let{theme:t}=e;return t.colors.inverted.fg.primary})),Vl=(0,m.default)(Sa.Text.Span).attrs({size:Ya.TextSize.XSmall}).withConfig({displayName:"storyGridItem__DetailCopy",componentId:"sc-1vhey8s-9"})(["color:",";margin:0;"],(e=>{let{theme:t}=e;return t.colors.inverted.fg.primary})),$l=m.default.img.withConfig({displayName:"storyGridItem__LockAvatar",componentId:"sc-1vhey8s-10"})(["height:40px;width:40px;border:",";border-radius:",";z-index:3;"],(e=>{let{theme:t}=e;return`2px solid ${t.colors.interactiveBg.brandNormal}`}),(e=>{let{theme:t}=e;return t.borders.radius.small})),Wl=(0,m.default)(fl.default).withConfig({displayName:"storyGridItem__LockIcon",componentId:"sc-1vhey8s-11"})(["color:",";display:inline;height:36px;width:36px;margin:-4px -4px -4px -10px;"],(e=>{let{theme:t}=e;return t.colors.inverted.fg.primary})),Kl=e=>{let{author:t,contextMenu:a,displayDate:r,editMode:o,formattedTitle:i,id:s,isLocked:c,lockUser:d={},onEditComplete:u,onEditCancel:p,status:m,title:f}=e;const g=(0,h.useMemo)((()=>{if(!r)return null;switch(m){case ce.PUBLISH:return(0,X.default)(/* translators: %s: published date */ (0,l.__)("Published %s","web-stories"),r);case ce.FUTURE:return(0,X.default)(/* translators: %s: future publish date */ (0,l.__)("Scheduled %s","web-stories"),r);default:return(0,X.default)(/* translators: %s: last modified date */ (0,l.__)("Modified %s","web-stories"),r)}}),[m,r]),{name:b,avatar:_}=d,y=c&&_&&n.createElement(zl,null,n.createElement(Tooltip,{position:zr.Placement.BottomStart,title:b&&(0,X.default)(/* translators: %s: user name */ (0,l.__)("%s is currently editing this story","web-stories"),b)},n.createElement($l,{src:_,alt:b,decoding:"async",height:24,width:24,"data-test-id":"lock-user-avatar"})));return n.createElement(Ul,null,y,o?n.createElement(Oa,{onEditComplete:u,onEditCancel:p,value:f,id:s,label:(0,l.__)("Rename story","web-stories"),isInverted:!0}):n.createElement(Fl,null,c&&n.createElement(Wl,null),n.createElement(jl,null,i)),n.createElement(Gl,null,n.createElement(Hl,null,m===ce.DRAFT&&n.createElement(Vl,{isBold:!0},(0,l.__)("Draft","web-stories")),m===ce.PENDING&&n.createElement(Vl,{isBold:!0},(0,l.__)("Pending","web-stories")),t?.name&&n.createElement(Vl,null,t?.name),n.createElement(Vl,{className:"dashboard-grid-item-date"},g)),n.createElement(Hl,null,a)))};function ql(){return ql=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{onFocus:a,isActive:r,pageSize:o,renameStory:i,story:s,storyMenu:c}=e;const{userId:d}=y(),u=r?0:-1,p=i?{editMode:i?.id===s?.id,onEditComplete:e=>i?.handleOnRenameStory(s,e),onEditCancel:i?.handleCancelRename}:{},f=(0,h.useMemo)((()=>s?.locked&&d!==s?.lockUser.id),[s,d]),g=(0,h.useMemo)((()=>ml({menuItems:c.menuItems,story:s,isLocked:f})),[c,s,f]),b=Et(s?.status===ce.DRAFT?s?.modifiedGmt:s?.createdGmt),_=Xr(s.title),E=(0,h.useMemo)((()=>g.length?n.createElement(StoryMenu,{menuLabel:f?(0,X.default)(/* translators: 1: story title. 2: user currently editing the story. */ (0,l.__)("Context menu for %1$s (locked by %2$s)","web-stories"),_,s?.lockUser.name):(0,X.default)(/* translators: %s: story title.*/ (0,l.__)("Context menu for %s","web-stories"),_),itemActive:r,tabIndex:u,onMoreButtonSelected:c.handleMenuToggle,contextMenuId:c.contextMenuId,storyId:s.id,isInverted:!0,menuItems:g,menuStyleOverrides:(0,m.css)(["margin:0 0 0 auto;"])}):null),[f,_,s?.lockUser?.name,s.id,r,u,c,g]);return n.createElement(Rl,{"data-testid":`story-grid-item-${s.id}`,onFocus:a,$posterHeight:o.height,ref:t,"aria-label":(0,X.default)(/* translators: %s: story title.*/ (0,l.__)("Details about %s","web-stories"),_)},n.createElement(Nl,null,n.createElement(Bl,null,n.createElement(Pl,ql({},s.featuredMediaUrl?{alt:(0,X.default)(/* translators: %s: Story title. */ (0,l.__)("%s Poster image","web-stories"),_),as:"img",src:s.featuredMediaUrl,decoding:"async"}:null,{width:it,height:ot})),n.createElement(Ol,null),n.createElement(Dl,null,s?.capabilities?.hasEditAction&&n.createElement(Ml,{className:"grid-item-anchor","data-testid":"story-editor-grid-link",tabIndex:u,href:s.editStoryLink},n.createElement(xl.VisuallyHidden,null,(0,X.default)(/* translators: %s: Story title. */ (0,l.__)("Open %s in Editor","web-stories"),_))),n.createElement(Kl,ql({author:s.author,contextMenu:E,displayDate:b,formattedTitle:_,id:s.id,isLocked:f,lockUser:s?.lockUser,status:s?.status,title:s.title},p))))))}));Xl.displayName="StoryGridItem";const Yl=Xl,Zl=(0,m.default)(Zt).withConfig({displayName:"storyGridView__StoryGrid",componentId:"sc-1fwq7hb-0"})(["width:calc(100% - ","px);"],qe),Jl=e=>{let{stories:t,pageSize:a,storyMenu:r,renameStory:o,returnStoryFocusId:i}=e;const{isRTL:s}=y(),c=(0,h.useRef)(),d=(0,h.useRef)(),u=(0,h.useRef)({}),[p,m]=(0,h.useState)(),f=(0,h.useRef)(),g=(0,h.useMemo)((()=>t.map((e=>{let{id:t}=e;return t}))),[t]);(0,Nt.default)({containerRef:c,gridRef:d,itemRefs:u,isRTL:s,currentItemId:p,items:t}),(0,h.useEffect)((()=>{if(!p&&i?.value&&!f.current){const e=i?.value;m(e);const t=u.current?.[e]?.querySelectorAll(["button","a"])?.[0];t?.focus()}}),[p,i]),(0,h.useEffect)((()=>{p&&(f.current=p)}),[p]);const b=(0,h.useCallback)(((e,t)=>{if(r.handleMenuToggle(t),t<0&&9===e?.keyCode){const t=!e?.shiftKey?g[g.indexOf(p)+1]:p;i.set(t),f.current=null,m(null)}}),[p,g,i,r]),_=(0,h.useCallback)((()=>{f.current=null,m(null),i.set(null)}),[i]);(0,h.useFocusOut)(c,(()=>m(null)),[]);const E=(0,h.useMemo)((()=>{const e=[Q,Z,J],t=r.menuItems.map((t=>{const a={...t};return e.includes(t?.value)&&(a.action=e=>{_(),t.action(e)}),a}));return{...r,handleMenuToggle:b,menuItems:t}}),[b,r,_]),S=(0,h.useMemo)((()=>t.map((e=>n.createElement(Yl,{onFocus:()=>m(e.id),isActive:p===e.id,ref:t=>{u.current[e.id]=t},key:e.id,pageSize:a,renameStory:o,story:e,storyMenu:E})))),[p,E,a,o,t]);return n.createElement("div",{ref:c},n.createElement(Zl,{pageSize:a,ref:d,role:"list",ariaLabel:(0,l.__)("Viewing stories","web-stories")},S))},Ql="DELETE_STORY";const eo=function StoriesView(e){let{loading:t,storyActions:a,stories:r,view:o}=e;const[i,s]=(0,h.useState)(-1),[c,d]=(0,h.useState)(-1),[u,p]=(0,h.useState)(""),[m,f]=(0,h.useState)(null),[g,b]=(0,h.useState)({}),[_,y]=(0,h.useState)(null),{showSnackbar:S}=(0,il.useSnackbar)(),w=u===Ql&&m,v=(0,h.useMemo)((()=>r.map((e=>{let{id:t}=e;return t}))),[r]);(0,h.useEffect)((()=>{if(g.id&&!_){const e=v.indexOf(g.id),t=e>0?-1:1,a=g.isDeleted?t:0,r=v[e+a];r&&y(r)}}),[g,_,v]),(0,h.useEffect)((()=>{u||f(null)}),[u,f]),(0,h.useEffect)((()=>{u&&(b({}),y(null))}),[u]);const T=(0,h.useCallback)(((e,t)=>{d(-1),(0,E.trackEvent)("rename_story"),a.updateStory({...e,title:{raw:t}})}),[a]),C=(0,h.useCallback)((()=>{(0,E.trackEvent)("delete_story"),a.trashStory(m),b({id:m.id,isDeleted:!0}),p("")}),[a,m]),I=(0,h.useCallback)((()=>{s(-1),(0,E.trackEvent)("open_in_editor")}),[]),k=(0,h.useCallback)((e=>{s(-1),d(e.id)}),[]),L=(0,h.useCallback)((e=>{s(-1),(0,E.trackEvent)("duplicate_story"),a.duplicateStory(e),b({id:e.id})}),[a]),A=(0,h.useCallback)((e=>{s(-1),f(e),p(Ql)}),[]),x=(0,h.useCallback)((e=>{s(-1),window.navigator.clipboard.writeText(e.link),S({message:(0,X.default)(/* translators: %s: story title. */ (0,l.__)("%s has been copied to your clipboard.","web-stories"),Xr(e.title)),dismissible:!0}),b({id:e.id})}),[S]),O=ae.map((e=>{switch(e?.value){case ee:e.action=x;break;case Q:e.action=A;break;case J:e.action=L;break;case te:e.action=I;break;case Z:e.action=k;break;default:e.action=()=>s(-1)}return e})),D=(0,h.useMemo)((()=>({handleMenuToggle:s,contextMenuId:i,menuItems:O})),[i,O,s]),N=(0,h.useMemo)((()=>({id:c,handleOnRenameStory:T,handleCancelRename:()=>d(-1)})),[T,d,c]),P=(0,h.useMemo)((()=>o.style===Qe.LIST?n.createElement(StoryListView,{hideStoryList:t?.isLoading&&!t?.showStoriesWhileLoading.current,pageSize:o.pageSize,renameStory:N,stories:r,storyMenu:D}):!t?.isLoading||t?.isLoading&&t?.showStoriesWhileLoading.current?n.createElement(Jl,{isLoading:t?.isLoading,pageSize:o.pageSize,renameStory:N,storyMenu:D,stories:r,returnStoryFocusId:{value:_,set:y}}):null),[t,N,_,r,D,o]);return n.createElement(n.Fragment,null,P,t?.isLoading&&!t?.showStoriesWhileLoading.current&&n.createElement(ja,null,n.createElement(dl.default,null)),w&&n.createElement(ya,{isOpen:!0,contentLabel:(0,l.__)("Dialog to confirm deleting a story","web-stories"),title:(0,l.__)("Delete Story","web-stories"),onClose:()=>{b({id:m.id}),p("")},secondaryText:(0,l.__)("Cancel","web-stories"),secondaryRest:{"aria-label":(0,X.default)(/* translators: %s: story title. */ (0,l.__)('Cancel deleting story "%s"',"web-stories"),Xr(m.title))},primaryText:(0,l.__)("Delete","web-stories"),onPrimary:C,primaryRest:{"aria-label":(0,X.default)(/* translators: %s: story title. */ (0,l.__)('Confirm deleting story "%s"',"web-stories"),Xr(m.title))}},n.createElement(Sa.Text.Paragraph,{size:Ya.TextSize.Small},(0,X.default)(/* translators: %s: story title. */ (0,l.__)('Are you sure you want to delete "%s"?',"web-stories"),Xr(m.title)))))};function NoAvailableContent(e){let{filtersObject:t}=e;const{search:a}=t;return a?(0,X.default)(/* translators: %s: search term. */ (0,l.__)('Sorry, we couldn\'t find any results matching "%s"',"web-stories"),a):0!==Object.keys(t).length?(0,l.__)("Sorry, we couldn't find any results","web-stories"):(0,l.__)("Start telling Stories.","web-stories")}NoAvailableContent.propTypes={filtersObject:Rt().object};const to=function(e){let{allPagesFetched:t,canViewDefaultTemplates:a,filtersObject:r={},loading:o,page:i,stories:s,storyActions:c,view:d}=e;return n.createElement(Ua.Scrollable,null,n.createElement(ha,null,s.length>0?n.createElement(n.Fragment,null,n.createElement(eo,{storyActions:c,stories:s,view:d,loading:o}),n.createElement(cl.default,{canLoadMore:!t,isLoading:o?.isLoading,allDataLoadedMessage:(0,l.__)("No more stories","web-stories"),allDataLoadedAriaMessage:(0,l.__)("All stories are loaded","web-stories"),loadingAriaMessage:(0,l.__)("Loading more stories","web-stories"),onLoadMore:i.requestNextPage})):!o?.isLoading&&n.createElement(Fn,null,n.createElement(lr.Headline,{size:Ya.TextSize.Small,as:"h3"},n.createElement(NoAvailableContent,{filtersObject:r})),0===Object.keys(r).length&&a&&n.createElement(Bt.ButtonAsLink,{type:Mt.ButtonType.Primary,size:Mt.ButtonSize.Medium,href:tr(Ye.TEMPLATES_GALLERY)},(0,l.__)("Explore Templates","web-stories")))))};const ao=function(e){return e.reduce(((e,t)=>!t.title||t?.title.trim().length<=0?e:[...e,{label:t.title,value:t.title}]),[])};var ro=a(85934);const no="VERTICAL",lo="COLOR",oo="TAG",io="TITLE";const so=function(e){const t=Object.values(e),a=t.flatMap((e=>e.colors)).map((e=>({label:e.family,value:e.family,type:lo}))),r=t.flatMap((e=>e.tags)).map((e=>({label:e,value:e,type:oo}))),n=t.map((e=>e.vertical)).map((e=>({label:e,value:e,type:no}))),l=t.map((e=>({label:e.title,value:e.title,type:io})));return[...(0,ro.default)(r,"label"),...(0,ro.default)(a,"label"),...(0,ro.default)(n,"label"),...(0,ro.default)(l,"label")]};a(28244);const co=function(e){return t=>!e||e.some((e=>{switch(e?.type){case oo:return t.tags.map((e=>e.toLowerCase())).includes(e.value.toLowerCase());case lo:return t.colors.map((e=>e.label.toLowerCase())).includes(e.value.toLowerCase());case no:return t.vertical.toLowerCase().includes(e.value.toLowerCase());case io:return t.title.toLowerCase().includes(e.value.toLowerCase());default:return!0}}))};var uo=a(50212);const po=(0,m.default)(uo.default).withConfig({displayName:"storyStatusToggle__StyledPill",componentId:"sc-141pqd7-0"})(["margin:0 2px;white-space:nowrap;& > span{padding-left:8px;color:",";}"],(e=>{let{theme:t,isActive:a}=e;return a?t.colors.gray[20]:t.colors.fg.tertiary}));const mo=function StoryStatusToggle(e){let{initialPageReady:t,totalStoriesByStatus:a,currentStatus:r}=e;const{updateFilter:o,registerFilters:i}=wn((e=>{let{actions:{updateFilter:t,registerFilters:a}}=e;return{updateFilter:t,registerFilters:a}})),s=(0,h.useCallback)((e=>{o("status",{filterId:e})}),[o]);(0,h.useEffect)((()=>{i([{key:"status",filterId:me.filters.status}])}),[i]);const c=(0,h.useMemo)((()=>Object.keys(a).reduce(((e,t)=>e+a[t]),0)),[a]),d=(0,h.useMemo)((()=>ue.filter((e=>{let{status:t}=e;return Boolean(t in a)&&a[t]>0||t===r})).map((e=>{let{label:t,status:n,value:o}=e;const i=a[n],s=Boolean(!i);return{ariaLabel:(0,X.default)(/* translators: %s is story status */ (0,l.__)("Filter stories by %s","web-stories"),t),disabled:s,isActive:r===o,value:o,label:t,count:i}}))),[a,r]);return!t||!c||a&&0===Object.keys(a).length?null:n.createElement(n.Fragment,null,d.map((e=>{let{ariaLabel:t,disabled:a,isActive:r,value:l,label:o,count:i}=e;return n.createElement(po,{key:l,onClick:()=>s(l),isActive:r,disabled:a,"aria-label":t},o,n.createElement("span",null,i))})))};const fo=(0,h.memo)((function(e){let{initialPageReady:t,stories:a,totalStoriesByStatus:r,view:o}=e;const i=(0,h.useMemo)((()=>ao(a)),[a]),{filters:s,sortObject:c,updateFilter:d,updateSort:u,registerFilters:p}=wn((e=>{let{state:{filters:t,sortObject:a},actions:{updateFilter:r,updateSort:n,registerFilters:l}}=e;return{filters:t,updateFilter:r,sortObject:a,updateSort:n,registerFilters:l}})),[m,f,g]=(0,h.useMemo)((()=>{const e=s.find((e=>{let{key:t}=e;return"status"===t})),t=s.find((e=>{let{key:t}=e;return"search"===t}));return[s.filter((e=>{let{key:t}=e;return!["status","search"].includes(t)})),e?.filterId,t?.filterId]}),[s]),b=(0,h.useMemo)((()=>(f?.split(",")||[]).reduce(((e,t)=>e+(r[t]||0)),0)),[f,r]),_=Qr({currentFilter:f,isActiveSearch:Boolean(g),totalResults:b,view:tt}),y=(0,h.useDebouncedCallback)((async e=>{await(0,E.trackEvent)("search",{search_type:"dashboard",search_term:e}),d("search",{filterId:e})}),lt);(0,h.useEffect)((()=>{p([{key:"search"}])}),[p]);const S=(0,h.useCallback)((()=>d("search",{filterId:null})),[d]);return n.createElement(n.Fragment,null,n.createElement(ll,{heading:(0,l.__)("Dashboard","web-stories"),searchPlaceholder:(0,l.__)("Search Stories","web-stories"),searchOptions:i,handleSearchChange:y,showSearch:t,searchValue:g,onClear:S},n.createElement(mo,{initialPageReady:t,totalStoriesByStatus:r,currentStatus:f})),n.createElement(BodyViewOptions,{showGridToggle:!0,filters:m,showSortDropdown:!0,resultsLabel:_,layoutStyle:o.style,handleLayoutSelect:o.toggleStyle,pageSortOptions:ie,pageSortDefaultOption:ne.LAST_MODIFIED,handleSortChange:u,currentSort:c}))}));function MyStoriesView(){const{duplicateStory:e,fetchStories:t,trashStory:a,updateStory:r,allPagesFetched:l,isLoading:o,stories:i,storiesOrderById:s,totalPages:c,totalStoriesByStatus:d}=hn((e=>{let{actions:{storyApi:{duplicateStory:t,fetchStories:a,trashStory:r,updateStory:n}},state:{stories:{allPagesFetched:l,isLoading:o,stories:i,storiesOrderById:s,totalPages:c,totalStoriesByStatus:d}}}=e;return{duplicateStory:t,fetchStories:a,trashStory:r,updateStory:n,allPagesFetched:l,isLoading:o,stories:i,storiesOrderById:s,totalPages:c,totalStoriesByStatus:d}})),{filtersObject:u,sortObject:p}=wn((e=>{let{state:{filtersObject:t,sortObject:a}}=e;return{filtersObject:t,sortObject:a}})),{apiCallbacks:m,canViewDefaultTemplates:f}=y(),g=(0,h.useRef)(!1);(0,h.useEffect)((()=>(g.current=!0,()=>{g.current=!1})),[]);const{page:b,view:_,showStoriesWhileLoading:S,initialPageReady:w}=function(e){let{filtersObject:t=me.filters,sortObject:a=me.sort,isLoading:r=!1,totalPages:n}=e;const[l,o]=(0,h.useState)(Qe.GRID),[i,s]=(0,h.useState)(a),[c,d]=(0,h.useState)(t),[u,p]=(0,h.useState)(1),m=(0,h.useRef)(!1),[f,g]=(0,h.useState)(!1),{pageSize:b}=nn({thumbnailMode:l===Qe.LIST,isGrid:l===Qe.GRID}),_=(0,h.useCallback)((e=>{p(ln(e,{MIN:1,MAX:n}))}),[n]),y=(0,h.useCallback)((e=>{s(e),_(1)}),[_]),S=(0,h.useCallback)((e=>{d(e),_(1)}),[_]),w=(0,h.useCallback)((()=>{const e=l===Qe.LIST?Qe.GRID:Qe.LIST;o(e)}),[l,o]),v=(0,h.useCallback)((()=>{m.current=!0,_(u+1)}),[u,_]);return(0,h.useEffect)((()=>{c?.search?.length&&(0,E.trackEvent)("search",{search_type:"dashboard_stories",search_term:c.search,search_filter:c.status,search_author_filter:c.author,search_order:i.order,search_orderby:i.orderby,search_view:l})}),[c,i,l]),(0,h.useEffect)((()=>{r||(m.current=!1)}),[r]),(0,h.useEffect)((()=>{n&&!f&&g(!0)}),[n,f]),(0,h.useEffect)((()=>{f&&S(t)}),[S,f,t]),(0,h.useEffect)((()=>{f&&y(a)}),[y,f,a]),(0,h.useMemo)((()=>({view:{style:l,toggleStyle:w,pageSize:b},sort:{value:i.orderby,direction:i.order,set:y},filters:{value:c,set:S},page:{value:u,set:p,requestNextPage:v},initialPageReady:f,showStoriesWhileLoading:m})),[l,w,b,i,y,c,S,f,u,v])}({filtersObject:u,sortObject:p,isLoading:o,totalPages:c});(0,h.useEffect)((()=>{t({page:b.value,filters:u,sort:p})}),[t,u,p,b.value,m]);const v=(0,h.useMemo)((()=>s.map((e=>i[e]))),[i,s]);return n.createElement(Ua.Provider,null,n.createElement(fo,{initialPageReady:w,stories:v,totalStoriesByStatus:d,view:_}),n.createElement(to,{allPagesFetched:l,canViewDefaultTemplates:f,filtersObject:u,loading:{isLoading:o,showStoriesWhileLoading:S},page:b,stories:v,storyActions:{duplicateStory:e,trashStory:a,updateStory:r},view:_}),n.createElement(Ua.Fixed,null,n.createElement(vr,null)))}function MyStories(){return n.createElement(StoryFiltersProvider,null,n.createElement(MyStoriesView,null))}const go=(0,h.createContext)({state:{},actions:{}}),{filters:ho,sort:bo}=Me;function TemplateFiltersProvider(e){let{children:t}=e;const[a,r]=(0,h.useReducer)(gn,{filters:[],filtersObject:ho,sortObject:bo}),l=(0,h.useCallback)(((e,t)=>{r({type:pn,payload:{key:e,value:t}})}),[]),o=(0,h.useCallback)((e=>{r({type:mn,payload:{type:"template",values:e}})}),[]),i=(0,h.useCallback)((e=>{r({type:fn,payload:{value:e}})}),[]),s=(0,h.useMemo)((()=>({state:a,actions:{updateSort:o,updateFilter:l,registerFilters:i}})),[a,o,l,i]);return n.createElement(go.Provider,{value:s},t)}function _o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:h.identity;return(0,h.useContextSelector)(go,e)}const yo=m.default.div.withConfig({displayName:"content__CardWrapper",componentId:"sc-1ilp1n2-0"})(["position:absolute;height:100%;width:100%;transition:opacity ease-in-out 300ms;&:hover{",",","{opacity:1;}}",",","{opacity:",";}"],Ol,Dl,Ol,Dl,(e=>{let{$isSelected:t}=e;return t?1:0})),Eo=m.default.div.withConfig({displayName:"content__TemplateDisplayContent",componentId:"sc-1ilp1n2-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:space-between;height:100%;padding-bottom:16px;a,button{margin:auto auto 0;}"]),So=(0,m.default)(Pl).attrs({as:"picture"}).withConfig({displayName:"content__PicturePoster",componentId:"sc-1ilp1n2-2"})(["display:block;& > img{height:100%;width:100%;object-fit:fill;border-radius:",";}"],(e=>{let{theme:t}=e;return t.borders.radius.medium})),wo="focus_template",vo=(0,m.default)(Bt.Button).attrs({type:Mt.ButtonType.Tertiary,size:Mt.ButtonSize.Small}).withConfig({displayName:"templateGridItem__SeeDetailsButton",componentId:"sc-fidkqe-0"})(["background-color:",";"],(e=>{let{theme:t}=e;return t.colors.standard.white})),To=(0,h.forwardRef)(((e,t)=>{let{onCreateStory:a,onFocus:r,height:o,id:i,isActive:s,posterSrc:c,slug:d,title:u,status:p,onSeeDetailsClick:m=Hn.noop}=e;const f=s?0:-1,g=(0,X.default)(/* translators: %s: Template title. */ (0,l.__)("First page of %s template","web-stories"),u);return n.createElement(ua,{ref:t,id:`template-grid-item-${i}`,className:"templateGridItem","data-testid":`template-grid-item-${i}`,$posterHeight:o,onFocus:r},n.createElement(Nl,null,n.createElement(yo,{$isSelected:s},n.createElement(So,null,n.createElement("source",{srcSet:c?.webp,type:"image/webp"}),n.createElement("source",{srcSet:c?.png,type:"image/png"}),n.createElement("img",{src:c?.png,alt:g,decoding:"async",width:it,height:ot})),n.createElement(Ol,null),n.createElement(Dl,{"data-testid":"card-action-container","data-template-slug":d},n.createElement(Eo,null,n.createElement(vo,{ariaLabel:(0,X.default)(/* translators: %s: template title.*/ (0,l.__)("Go to detail view of %s","web-stories"),u),onClick:()=>m(i,u),className:wo,tabIndex:f},Fe[p]),a&&n.createElement(Bt.Button,{size:Mt.ButtonSize.Small,type:Mt.ButtonType.Primary,onClick:a,tabIndex:f,ariaLabel:(0,X.default)(/* translators: %s: template title.*/ (0,l.__)("Create new story from %s","web-stories"),u)},(0,l.__)("Use template","web-stories")))))))}));To.displayName="TemplateGridItem";const Co=To;const Io=function TemplateGridView(e){let{pageSize:t,templates:a,templateActions:r}=e;const{isRTL:o,apiCallbacks:i}=y(),s=(0,h.useRef)(),c=(0,h.useRef)(),d=(0,h.useRef)({}),[u,p]=(0,h.useState)(null),{handleDetailsToggle:m,createStoryFromTemplate:f}=r||{},g=Boolean(i?.createStoryFromTemplate);(0,Nt.default)({containerRef:s,gridRef:c,itemRefs:d,isRTL:o,currentItemId:u,items:a}),(0,h.useEffect)((()=>{u&&d.current?.[u]?.querySelector(`.${wo}`)?.focus()}),[u]),(0,h.useFocusOut)(s,(()=>p(null)),[]);const b=(0,h.useMemo)((()=>a.map((e=>{let{id:a,slug:r,status:l,title:o,postersByPage:i}=e;const s=u===a,c=i?.[0];return n.createElement(Co,{onCreateStory:g?()=>f(a):on,onFocus:()=>{p(a)},onSeeDetailsClick:m,height:t.height,id:a,isActive:s,key:r,posterSrc:c,ref:e=>{d.current[a]=e},slug:r,status:l,title:o})}))),[a,u,g,m,t.height,f]);return n.createElement("div",{ref:s},n.createElement(Zt,{pageSize:t,role:"list",ref:c,ariaLabel:(0,l.__)("Viewing available templates","web-stories")},b))};const ko=function(e){let{allPagesFetched:t,isLoading:a,page:r,templates:o,view:i,totalTemplates:s,search:c,templateActions:d}=e;const{newStoryURL:u}=y(),p=(0,h.useMemo)((()=>a?n.createElement(ja,null,n.createElement(dl.default,null)):s>0?n.createElement(n.Fragment,null,n.createElement(Io,{templates:o,pageSize:i.pageSize,templateActions:d}),n.createElement(cl.default,{canLoadMore:!t,isLoading:a,allDataLoadedMessage:(0,l.__)("No more templates","web-stories"),allDataLoadedAriaMessage:(0,l.__)("All templates are loaded","web-stories"),loadingAriaMessage:(0,l.__)("Loading more templates","web-stories"),onLoadMore:r.requestNextPage})):n.createElement(Fn,null,n.createElement(lr.Headline,{size:Ya.TextSize.Small,as:"h3"},c?(0,X.default)(/* translators: %s: search term. */ (0,l.__)('Sorry, we couldn\'t find any results matching "%s"',"web-stories"),c):(0,l.__)("No templates currently available.","web-stories")),!c&&n.createElement(Bt.ButtonAsLink,{type:Mt.ButtonType.Primary,size:Mt.ButtonSize.Medium,href:u},(0,l.__)("Create New Story","web-stories")))),[t,a,u,r.requestNextPage,d,c,o,s,i.pageSize]);return n.createElement(Ua.Scrollable,null,n.createElement(ha,null,p))};const Lo=function(e){let{isLoading:t,totalTemplates:a,view:r,searchOptions:o=[]}=e;const i=(0,g.useFeature)("enableInProgressTemplateActions"),{filters:s,sortObject:c,updateFilter:d,updateSort:u,registerFilters:p}=_o((e=>{let{state:{filters:t,sortObject:a},actions:{updateFilter:r,updateSort:n,registerFilters:l}}=e;return{filters:t,sortObject:a,updateFilter:r,updateSort:n,registerFilters:l}})),[m,f]=(0,h.useMemo)((()=>{const e=s.find((e=>{let{key:t}=e;return"status"===t})),t=s.find((e=>{let{key:t}=e;return"search"===t}));return[e?.filterId,t?.filterId]}),[s]),b=(0,h.useDebouncedCallback)((e=>{d("search",{filterId:e})}),lt);(0,h.useEffect)((()=>{p([{key:"search"}]),p([{key:"status",filterId:Me.filters.status}])}),[p]);const _=(0,h.useCallback)((()=>d("search",{filterId:null})),[d]),y=Qr({totalResults:a,currentFilter:m,view:at});return n.createElement(n.Fragment,null,n.createElement(ll,{heading:(0,l.__)("Explore Templates","web-stories"),searchPlaceholder:(0,l.__)("Search Templates","web-stories"),showSearch:!0,searchOptions:o,searchValue:f,handleSearchChange:b,onClear:_}),n.createElement(BodyViewOptions,{resultsLabel:y,layoutStyle:r.style,handleLayoutSelect:r.toggleStyle,isLoading:t,pageSortOptions:Ue,pageSortDefaultOption:Re.POPULAR,currentSort:c,handleSortChange:u,showSortDropdown:i,sortDropdownAriaLabel:(0,l.__)("Choose sort option for display","web-stories")}))};var Ao,xo=a(95735);function Oo(){return Oo=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{title:t,titleId:a,...r}=e;return n.createElement("svg",Oo({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 32 32","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,Ao||(Ao=n.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M25.146 25.854a.5.5 0 0 0 .708-.708L16.707 16l9.147-9.146a.5.5 0 0 0-.708-.708L16 15.293 6.854 6.146a.5.5 0 1 0-.708.708L15.293 16l-9.147 9.146a.5.5 0 0 0 .708.708L16 16.707l9.146 9.147Z",clipRule:"evenodd"})))},Do=(0,n.memo)(SvgCrossLarge),No=m.default.nav.withConfig({displayName:"header__Nav",componentId:"sc-1wko3r4-0"})(["justify-content:space-between;align-items:center;display:flex;margin:48px auto;width:calc(76% + 121px);"]),Po=(0,m.default)(Bt.Button).attrs({type:Mt.ButtonType.Primary,size:Mt.ButtonSize.Small}).withConfig({displayName:"header__CTAButton",componentId:"sc-1wko3r4-1"})(["padding:10px 16px;"]);const Ro=function(e){let{templateTitle:t,templateId:a,templateActions:r,canCreateStory:o}=e;const{createStoryFromTemplate:i,handleDetailsToggle:s}=r||{};return n.createElement(No,null,n.createElement(Bt.Button,{type:Mt.ButtonType.Tertiary,variant:Mt.ButtonVariant.Square,size:Mt.ButtonSize.Small,"aria-label":(0,l.__)("Close","web-stories"),onClick:s},n.createElement(Do,null)),o&&n.createElement(Po,{onClick:()=>i(a),"aria-label":(0,X.default)(/* translators: %s: template title */ (0,l.__)("Use %s template to create new story","web-stories"),t)},(0,l.__)("Use template","web-stories")))};var Bo,Mo=a(63094),Uo=a(2039);function Fo(){return Fo=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{title:t,titleId:a,...r}=e;return n.createElement("svg",Fo({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 32 32","aria-labelledby":a},r),t?n.createElement("title",{id:a},t):null,Bo||(Bo=n.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M16.355 6.146a.5.5 0 1 0-.707.708l8.647 8.647H6.5a.5.5 0 1 0 0 1h17.795l-8.647 8.648a.5.5 0 0 0 .707.707l9.49-9.49a.498.498 0 0 0 0-.73l-9.49-9.49Z",clipRule:"evenodd"})))},zo=(0,n.memo)(SvgArrowRightLarge),Go=m.default.section.withConfig({displayName:"templateDetails__Panel",componentId:"sc-1cvs5jb-0"})(["padding:16vh 0 14vh 0;"]),Ho=m.default.div.withConfig({displayName:"templateDetails__Container",componentId:"sc-1cvs5jb-1"})(["position:relative;width:76%;max-width:","px;margin:0 auto;"],1459.2),jo=m.default.div.withConfig({displayName:"templateDetails__Inner",componentId:"sc-1cvs5jb-2"})(["display:flex;align-items:start;"]),Vo=m.default.section.attrs({"aria-label":(0,l.__)("Template Details","web-stories")}).withConfig({displayName:"templateDetails__DetailContainer",componentId:"sc-1cvs5jb-3"})(["padding:0 0 0 60px;margin-right:auto;"]),$o=m.default.div.withConfig({displayName:"templateDetails__TemplateDetails",componentId:"sc-1cvs5jb-4"})(["position:relative;display:flex;width:500px;"]),Wo=(m.default.section.attrs({"aria-label":(0,l.__)("Related Templates","web-stories")}).withConfig({displayName:"templateDetails__RowContainer",componentId:"sc-1cvs5jb-5"})(["display:flex;flex-wrap:wrap;padding-bottom:40px;margin:0 80px 0;& > h3{padding-bottom:32px;}& > div{width:100%;}"]),(0,m.default)(Go).withConfig({displayName:"content__StyledPanel",componentId:"sc-jxjpbh-0"})(["padding:0 0 48px 0;"])),Ko=(0,m.default)(Sa.Text.Paragraph).withConfig({displayName:"content__ByLineText",componentId:"sc-jxjpbh-1"})(["color:",";margin:8px 0 24px;"],(e=>{let{theme:t}=e;return t.colors.fg.tertiary})),qo=(0,m.default)(Sa.Text.Paragraph).withConfig({displayName:"content__DescriptionText",componentId:"sc-jxjpbh-2"})(["margin-bottom:24px;"]),Xo=m.default.div.withConfig({displayName:"content__PaginationContainer",componentId:"sc-jxjpbh-3"})(["position:absolute;top:","px;",""],235,(e=>{let{alignLeft:t}=e;return t?"\n left: 0;\n transform: translate(-187.5%, -50%);\n ":"\n right: 0;\n transform: translate(187.5%, -50%);\n "})),Yo=(0,m.default)(Mo.default).attrs({forwardedAs:"li"}).withConfig({displayName:"content__TemplateTag",componentId:"sc-jxjpbh-4"})(["margin-right:12px;margin-bottom:12px;> span{color:"," !important;}"],(e=>{let{theme:t}=e;return t.colors.fg.primary})),Zo=m.default.div.withConfig({displayName:"content__MetadataContainer",componentId:"sc-jxjpbh-5"})(["margin-bottom:24px;display:flex;flex-wrap:wrap;align-items:center;"]);const Jo=function DetailsContent(e){let{activeTemplateIndex:t,isRTL:a,filteredTemplatesLength:r,switchToTemplateByOffset:o,template:i}=e;const{postersByPage:s,title:c,description:d,tags:u,colors:p}=i||{},[m,f]=(0,h.useState)([]);(0,h.useEffect)((()=>{s&&f(Object.values(s).map(((e,t)=>({id:t,...e}))))}),[s]);const{NextButton:g,PrevButton:b}=(0,h.useMemo)((()=>{const e=a?t-1:t+1,i=a?t+1:t-1,s=a?!r||t===r-1:!r||0===t,c=a?!r||0===t:!r||t===r-1,d=n.createElement(Bt.Button,{type:Mt.ButtonType.Tertiary,size:Mt.ButtonSize.Small,variant:Mt.ButtonVariant.Square,"aria-label":(0,l.__)("View previous template","web-stories"),onClick:()=>{o(i),f([])},disabled:s},n.createElement(Uo.default,{height:32,width:32})),u=n.createElement(Bt.Button,{type:Mt.ButtonType.Tertiary,size:Mt.ButtonSize.Small,variant:Mt.ButtonVariant.Square,"aria-label":(0,l.__)("View next template","web-stories"),onClick:()=>{o(e),f([])},disabled:c},n.createElement(zo,{height:32,width:32}));return a?{NextButton:d,PrevButton:u}:{NextButton:u,PrevButton:d}}),[r,t,a,o]),_=i?(0,X.default)(/* translators: byline. %s: author name. */ (0,l.__)("By %s","web-stories"),i.createdBy):null;return n.createElement(Wo,null,n.createElement(Ho,null,n.createElement(Xo,{alignLeft:!0},b),n.createElement(jo,null,n.createElement(Vt,{galleryPosters:m,isRTL:a,galleryLabel:(0,l.__)("Template details by page","web-stories")}),n.createElement($o,null,n.createElement(Vo,null,n.createElement(Gn,{size:Ya.TextSize.Small,as:"h3","data-testid":"template-details-title"},c),n.createElement(Ko,{size:Ya.TextSize.Medium},_),n.createElement(qo,{size:Ya.TextSize.Medium},d),n.createElement(Zo,{role:"list","aria-label":(0,l.__)("Template tags","web-stories")},u.map((e=>n.createElement(Yo,{key:e,disabled:!0},e)))),n.createElement(Zo,null,n.createElement(ga,{colors:p,size:32,"aria-label":(0,l.__)("Template colors","web-stories")}))))),n.createElement(Xo,null,g)))};const Qo=function TemplateDetailsModal(e){let{activeTemplateIndex:t,activeTemplate:a,filteredTemplatesLength:r,isDetailsViewOpen:o,templateActions:s}=e;const{isRTL:c,apiCallbacks:d}=y(),u=Boolean(d?.createStoryFromTemplate),{handleDetailsToggle:p,switchToTemplateByOffset:m}=s||{};return n.createElement(xo.default,{isOpen:o,onClose:p,contentLabel:(0,X.default)(/* translators: %s: template title */ (0,l.__)("Template Details for %s","web-stories"),a?.title),overlayStyles:{backgroundColor:`${i.theme.colors.opacity.overlayDark}`},contentStyles:{display:"block",height:"90vh",width:"90vw",backgroundColor:`${i.theme.colors.standard.white}`}},n.createElement(Ro,{templateTitle:a?.title,templateId:a?.id,templateActions:s,canCreateStory:u}),n.createElement(Jo,{activeTemplateIndex:t,isRTL:c,filteredTemplatesLength:r,switchToTemplateByOffset:m,template:a}))};function ExploreTemplatesView(){const e=(0,Zn.default)(),[t,a]=(0,h.useState)(!1),[r,o]=(0,h.useState)(null),[i,s]=(0,h.useState)(0),{templateIdParam:c,replace:d}=er((e=>{let{actions:t,state:a}=e;return{templateIdParam:a.queryParams.id,replace:t.replace}})),u=(0,h.useRef)(c),{allPagesFetched:p,isLoading:m,templates:f,templatesOrderById:g,totalPages:b,totalTemplates:_,createStoryFromTemplate:y,fetchExternalTemplates:S}=hn((e=>{let{state:{templates:{allPagesFetched:t,isLoading:a,templates:r,templatesOrderById:n,totalPages:l,totalTemplates:o}},actions:{storyApi:{createStoryFromTemplate:i},templateApi:{fetchExternalTemplates:s}}}=e;return{allPagesFetched:t,isLoading:a,templates:r,templatesOrderById:n,totalPages:l,totalTemplates:o,createStoryFromTemplate:i,fetchExternalTemplates:s}})),{filters:w,sortObject:v,filtersObject:T}=_o((e=>{let{state:{filters:t,sortObject:a,filtersObject:r}}=e;return{filters:t,sortObject:a,filtersObject:r}})),{page:C,view:I}=function(e){let{totalPages:t,sortObject:a=Me.sort,filtersObject:r=Me.filters}=e;const[n,l]=(0,h.useState)(a),[o,i]=(0,h.useState)(r),[s,c]=(0,h.useState)(1),{pageSize:d}=nn({isGrid:!0}),u=(0,h.useCallback)((e=>{c(ln(e,{MIN:1,MAX:t}))}),[t]),p=(0,h.useCallback)((()=>u(s+1)),[s,u]),m=(0,h.useCallback)((e=>{l(e),u(1)}),[u]),f=(0,h.useCallback)((e=>{i(e),u(1)}),[u]);return(0,h.useMemo)((()=>({view:{style:Qe.GRID,pageSize:d},sort:{value:n.orderby,direction:n.order,set:m},filters:{value:o,set:f},page:{value:s,set:c,requestNextPage:p}})),[d,n,m,s,p,o,f])}({filtersObject:T,sortObject:v,totalPages:b}),[k]=(0,h.useMemo)((()=>{const e=w.find((e=>{let{key:t}=e;return"search"===t}));return[e?.filterId]}),[w]),L=(0,h.useMemo)((()=>so(f)),[f]),A=(0,h.useMemo)((()=>k?L.filter((e=>e.label.toLowerCase().includes(k.toLowerCase()))):L),[L,k]),x=(0,h.useMemo)((()=>g.map((e=>f[e])).filter(co(A))),[g,f,A]),O=(0,h.useMemo)((()=>_!==x.length?x.length:_),[x,_]),D=(0,h.useMemo)((()=>(0,ro.default)(A,"label")),[A]),N=(0,h.useCallback)((e=>{const t=f[e];(0,E.trackEvent)("use_template",{name:t.title,template_id:t.id}),y(t)}),[y,f]),P=(0,h.useCallback)((e=>{const t=x.find((t=>t.id===e));o(t),s(x.findIndex((t=>t.id===e))),u.current&&(u.current=void 0),d(`?id=${t.id}&isLocal=${t.isLocal}`)}),[d,x]),R=(0,h.useCallback)(((t,r)=>{a((a=>{const n=!a;return r&&(0,E.trackScreenView)(r),n&&t&&P(t),n||(d(""),e((0,l.__)("Exit detail templates view","web-stories"))),n}))}),[d,e,P]),B=(0,h.useCallback)((t=>{const a=x[t];o(a),s(t),d(`?id=${a.id}&isLocal=${a.isLocal}`),e((0,X.default)(/* translators: %s: template title */ (0,l.__)("Viewing %s","web-stories"),a.title))}),[x,d,e]),M=(0,h.useMemo)((()=>({createStoryFromTemplate:N,handleDetailsToggle:R,switchToTemplateByOffset:B})),[N,R,B]);return(0,h.useEffect)((()=>{S()}),[S]),(0,h.useEffect)((()=>{if(u.current&&x.length){if(!x.some((e=>e.id===parseInt(u.current))))return void d("");a(!0),P(parseInt(u.current))}}),[x,d,P]),n.createElement(Ua.Provider,null,n.createElement(Lo,{isLoading:m&&!_,totalTemplates:O,searchOptions:D,view:I}),n.createElement(ko,{isLoading:m,allPagesFetched:p,page:C,templates:x,totalTemplates:O,search:k,view:I,templateActions:M}),n.createElement(Ua.Fixed,null,n.createElement(vr,null)),n.createElement(Qo,{activeTemplate:r,activeTemplateIndex:i,isDetailsViewOpen:t,templateActions:M,filteredTemplatesLength:x.length}))}function ExploreTemplates(){return n.createElement(TemplateFiltersProvider,null,n.createElement(ExploreTemplatesView,null))}const ei=function(){const{storyError:e,templateError:t}=hn((e=>{let{state:{stories:{error:t},templates:{error:a}}}=e;return{storyError:t,templateError:a}})),{showSnackbar:a}=(0,il.useSnackbar)(),r=(0,h.useDebouncedCallback)((e=>a({message:e,dismissible:!0})),200);(0,h.useEffect)((()=>{e?.id&&r(e.message)}),[e,r]),(0,h.useEffect)((()=>{t?.id&&r(t.message)}),[t,r])};function ti(){return ti=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{additionalRoutes:t}=e;const{currentPath:a,templateId:r,availableRoutes:o}=er((e=>{let{state:t}=e;return{...t,templateId:t.queryParams.id}})),{push:i,setAvailableRoutes:s}=er((e=>{let{actions:t}=e;return t})),{canViewDefaultTemplates:c,leftRailSecondaryNavigation:d=[],documentTitleSuffix:u=(0,l.__)("Web Stories","web-stories")}=y(),{addInitialFetchListener:p}=hn((e=>{let{actions:{storyApi:{addInitialFetchListener:t}},state:{templates:{templates:a}}}=e;return{currentTemplate:void 0!==r?a[r]?.title:void 0,addInitialFetchListener:t}})),m=(0,h.useRef)(a===Ye.DASHBOARD),[f,g]=(0,h.useState)(!m.current);(0,h.useEffect)((()=>p?.((e=>{e?.all<=0&&m.current&&c&&(i(Ye.TEMPLATES_GALLERY),m.current=!1),g(!0)}))),[p,i,a,c]),(0,h.useEffect)((()=>{if(o.length>0)return;const e=t?t.map((e=>{let{path:t}=e;return t})):[];s([...Object.values(Ye),...e])}),[t,o.length,s]),(0,h.useEffect)((()=>{if(!f)return;const e=d.find((e=>e.value===a)),t=Ze[a]||e?.label||Ze.DEFAULT;document.title=(0,X.default)(/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */ (0,l.__)("%1$s ‹ %2$s","web-stories"),t,u),(0,E.trackScreenView)(t)}),[a,f,d,u]),ei();const{clearSnackbar:b,removeSnack:_,placement:S,currentSnacks:w}=(0,il.useSnackbar)(),v=(0,h.usePrevious)(a);return(0,h.useEffect)((()=>{a!==v&&b()}),[b,a,v]),n.createElement(n.Fragment,null,n.createElement(za,null,n.createElement(hr,null),n.createElement(Ga,null,o.length>0&&n.createElement(n.Fragment,null,n.createElement(ar,{exact:!0,isDefault:!0,path:Ye.DASHBOARD,component:n.createElement(MyStories,null)}),c&&n.createElement(ar,{path:Ye.TEMPLATES_GALLERY,component:n.createElement(ExploreTemplates,null)}),t&&t.map((e=>n.createElement(ar,ti({key:e.path},e))))))),n.createElement(sl.default,{notifications:w,onRemove:_,placement:S,max:1}))};var ri=a(15705),ni=a(19167),li=a(88272);window.wp.domReady;a(20691);function oi(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https";return/^(http:\/\/|https:\/\/|tel:|mailto:)/.test(e)?e:`${t}://${e}`}var ii=a(20886);const si=window.wp.apiFetch,ci=["id","title","status","date","date_gmt","modified","modified_gmt","story_poster","link","preview_link","edit_link","_links","_embedded","body","status","headers"].join(","),di=["id","title"],ui=["title","link"],pi="wp:lock,author",mi={EDIT:"wp:action-edit",DELETE:"wp:action-delete"};function fi(e){const{id:t,title:a,status:r,date:n,date_gmt:l,modified:o,modified_gmt:i,link:s,preview_link:c,edit_link:d,story_poster:u,_embedded:{author:p,"wp:lock":m}={},_links:f={}}=e;if(!t)return null;const{locked:g=!1,user:h={id:0,name:""}}=m?.[0]||{},b=p?.[0]||{id:0,name:""},_={hasEditAction:Object.prototype.hasOwnProperty.call(f,mi.EDIT),hasDeleteAction:Object.prototype.hasOwnProperty.call(f,mi.DELETE)};return{id:t,status:r,title:a.raw,created:n,createdGmt:`${l}Z`,modified:o,modifiedGmt:`${i}Z`,author:{id:b.id,name:b.name},locked:g,lockUser:{...h,avatar:h?.avatar?.[96]||null},bottomTargetAction:d,featuredMediaUrl:u?.url,editStoryLink:d,previewLink:c,link:s,capabilities:_}}function gi(e,t){const{page:a=1,perPage:r=nt,filters:n={},sort:l={}}=t,o={...{_embed:pi,context:"edit",_web_stories_envelope:!0,_fields:ci,...me.filters,...me.sort},page:a,per_page:r,...n,...l};return si({path:(0,ii.default)(e.api.stories,o)}).then((e=>{let{body:t,headers:a}=e;const r=a&&parseInt(a["X-WP-TotalPages"]),n=a&&JSON.parse(a["X-WP-TotalByStatus"]),l=[];return{stories:t.reduce(((e,t)=>t?(l.push(t.id),e[t.id]=fi(t),e):e),{}),fetchedStoryIds:l,totalPages:r,totalStoriesByStatus:n}}))}function hi(e,t){const a=(0,ii.default)(`${e.api.stories}${t}`,{_method:"DELETE"});return si({path:a,method:"POST"})}function bi(e,t){const a=(0,ii.default)(`${e.api.stories}${t.id}/`,{_embed:pi}),r={id:t.id,author:t.author.id,title:t.title?.raw||t.title};return si({path:a,data:r,method:"POST"}).then(fi)}const _i=(e,t)=>{const a=(0,ii.default)(e.api.stories,{_fields:"edit_link"}),{pages:r,version:n,colors:l}=t,o={featuredMedia:{id:0,url:""},publisherLogo:{url:""},title:""},i={pages:r,featuredMedia:o.featuredMedia,title:o.title,status:"auto-draft",meta:{web_stories_publisher_logo:o.publisherLogo.id}},s=l.map((e=>{let{color:t}=e;return(0,pa.default)(t)})),{globalPageDuration:c=7,globalAutoAdvance:d=!0}=e;return si({path:a,data:{...i,story_data:{pages:r,version:n,autoAdvance:d,defaultPageDuration:c,currentStoryStyles:{colors:s}}},method:"POST"}).then(ni.snakeToCamelCaseObjectKeys)};function yi(e,t){const a=(0,ii.default)(e.api.stories,{_embed:pi,_fields:ci});return si({path:a,data:{original_id:t.id,status:"draft"},method:"POST"}).then(fi)}function Ei(e,t){return si({path:(0,ii.default)(e.api.users,{per_page:"100",capabilities:e.editPostsCapabilityName,search:t})})}async function Si(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=await si({path:(0,ii.default)(e.api.taxonomies,{type:"web-story",context:"edit",...t})});return Object.values(a).map((e=>(e.restPath=e._links?.["wp:items"]?.[0]?.href,delete e._links,(0,ni.snakeToCamelCaseObjectKeys)(e,["capabilities","visibility"]))))}function wi(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return si({url:(0,ii.default)(t,a)})}function vi(e,t){return si({path:(0,ii.default)(e.api.products,{per_page:1,search:t})})}var Ti=a(64239),Ci=a(98075);const Ii={SETTINGS:{UPDATED:(0,l.__)("Setting saved.","web-stories")}},ki={UPLOAD_PUBLISHER_LOGO:{MESSAGE:(0,l.__)("Unable to add publisher logo","web-stories"),MESSAGE_PLURAL:(0,l.__)("Unable to add publisher logos","web-stories")},REMOVE_PUBLISHER_LOGO:{MESSAGE:(0,l.__)("Unable to remove publisher logo","web-stories")},REMOVE_FONT:{MESSAGE:(0,l.__)("Unable to remove font","web-stories")},UPDATE_PUBLISHER_LOGO:{MESSAGE:(0,l.__)("Unable to update publisher logo","web-stories")},LOAD_PUBLISHER_LOGOS:{MESSAGE:(0,l.__)("Unable to load publisher logos","web-stories")},LOAD_SETTINGS:{MESSAGE:(0,l.__)("Unable to load settings","web-stories")},UPDATE_EDITOR_SETTINGS:{MESSAGE:(0,l.__)("Unable to update settings data","web-stories")}},Li="/editor-settings",Ai=[{value:Li,label:(0,l.__)("Settings","web-stories")},{value:(0,l.__)("https://wordpress.org/support/plugin/web-stories/","web-stories"),label:(0,l.__)("Support","web-stories"),isExternal:!0,trackingEvent:"click_support_page"}],xi="none",Oi="adsense",Di="admanager",Ni="mgid",Pi={DEFAULT:"default",DISABLED:"disabled",CUSTOM:"custom"},Ri="none",Bi="woocommerce",Mi="shopify",Ui=(0,m.createGlobalStyle)(["body.web-story_page_stories-dashboard #wpbody{",";}.","{top:","px !important;left:","px !important;}body.folded .","{left:","px !important;}body.","{#adminmenuwrap,#adminmenuback{z-index:15;}}"],Ti.scrollbarCSS,Ci.OVERLAY_CLASS,32,160,Ci.OVERLAY_CLASS,36,Ci.BODY_CLASS);const Fi=function(){const{currentPath:e}=er((e=>{let{state:{currentPath:t}}=e;return{currentPath:t}}));(0,h.useEffect)((()=>{document.querySelectorAll('#menu-posts-web-story ul.wp-submenu li a[href$="page=stories-dashboard"]')?.forEach((e=>{e.setAttribute("href",e.getAttribute("href")+"#/")}))}),[]),(0,h.useEffect)((()=>{document.querySelectorAll("#menu-posts-web-story ul.wp-submenu li")?.forEach((t=>{t.classList.remove("current"),t.querySelector("a")?.classList.remove("current"),t.querySelector("a")?.removeAttribute("aria-current"),t.querySelector(`a[href$="#${e}"]`)&&(t.classList.add("current"),t.querySelector("a")?.classList.add("current"),t.querySelector("a")?.setAttribute("aria-current","page"))}))}),[e])},zi=(0,h.createContext)({state:{},actions:{}});const Gi=function(e){return(0,h.useContextSelector)(zi,e??h.identity)};const Hi={getItemByKey:function(e){let t=null;try{const a=localStorage.getItem(e);t=null!==a?JSON.parse(a):a}catch(e){e instanceof Error&&(0,E.trackError)("local_storage_read",e.message)}return t},setItemByKey:function(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(e){e instanceof Error&&(0,E.trackError)("local_storage_write",e.message)}}},ji="web_stories_tracking_optin_banner_closed";function Vi(){const e=localStorage.getItem(ji);return Boolean(JSON.parse(e))}function $i(){const{showSnackbar:e}=(0,il.useSnackbar)(),[t,a]=(0,h.useState)(Vi),[r,n]=(0,h.useState)(!1),{currentUser:l,toggleWebStoriesTrackingOptIn:o}=Gi((e=>{let{state:{currentUser:t},actions:{usersApi:{toggleWebStoriesTrackingOptIn:a}}}=e;return{currentUser:t,toggleWebStoriesTrackingOptIn:a}})),{currentPath:i}=er((e=>{let{state:{currentPath:t}}=e;return{currentPath:t}})),s=void 0!==l.data.meta?.webStoriesTrackingOptin,c=Boolean(l.data.meta?.webStoriesTrackingOptin);(0,h.useEffect)((()=>{c?(0,E.enableTracking)():(0,E.disableTracking)()}),[c]);const d=(0,h.useCallback)((()=>{o(),Hi.setItemByKey(ji,!0),n(!0),e({"aria-label":Ii.SETTINGS.UPDATED,message:Ii.SETTINGS.UPDATED,dismissible:!0})}),[e,o]),u=(0,h.useCallback)((()=>{a(!0),Hi.setItemByKey(ji,!0)}),[]);let p=!0;return(t||i===Li||!s||!r&&c)&&(p=!1),{bannerVisible:p,optedIn:c,disabled:l.isUpdating,closeBanner:u,toggleWebStoriesTrackingOptIn:d}}a(16054);var Wi=a(60298);const Ki=function(){const{settingsError:e,mediaError:t,settingSaved:a,publisherLogosError:r}=Gi((e=>{let{state:{settings:{error:t,settingSaved:a},media:{error:r},publisherLogos:{error:n,settingSaved:l}}}=e;return{settingsError:t,mediaError:r,settingSaved:a||l,publisherLogosError:n}})),{showSnackbar:n}=(0,il.useSnackbar)(),l=(0,h.useDebouncedCallback)((e=>n({"aria-label":e,message:e,dismissible:!0})),200);(0,h.useEffect)((()=>{e?.id&&l(e.message)}),[e,l]),(0,h.useEffect)((()=>{a&&l(Ii.SETTINGS.UPDATED)}),[l,a]),(0,h.useEffect)((()=>{t?.id&&l(t.message)}),[t,l]),(0,h.useEffect)((()=>{r?.id&&l(r.message)}),[r,l])},qi=m.default.div.withConfig({displayName:"editorSettings__Wrapper",componentId:"sc-1y9ilpk-0"})([""]),Xi=(0,m.default)(ha).withConfig({displayName:"editorSettings__Main",componentId:"sc-1y9ilpk-1"})(["display:flex;flex-direction:column;padding-top:36px;margin-top:20px;margin-bottom:56px;max-width:945px;"]),Yi=m.default.form.withConfig({displayName:"editorSettings__SettingForm",componentId:"sc-1y9ilpk-2"})(["display:grid;grid-template-columns:27% minmax(400px,1fr);column-gap:6.56%;padding-bottom:52px;@media ","{grid-template-columns:100%;row-gap:20px;}"],(e=>{let{theme:t}=e;return t.breakpoint.mobile})),Zi=(0,m.default)(lr.Headline).attrs({as:"h3"}).withConfig({displayName:"editorSettings__SettingHeading",componentId:"sc-1y9ilpk-3"})(["",";margin:8px 0;"],(e=>{let{theme:t}=e;return Tr.expandPresetStyles({preset:{...t.typography.presets.label[Ya.TextSize.Large]},theme:t})})),Ji=(0,m.default)(ea.Link).withConfig({displayName:"editorSettings__InlineLink",componentId:"sc-1y9ilpk-4"})(["display:inline-block;"]),Qi=(0,m.default)(Sa.Text.Paragraph).withConfig({displayName:"editorSettings__HelperText",componentId:"sc-1y9ilpk-5"})(["color:",";"],(e=>{let{theme:t}=e;return t.colors.fg.tertiary})),es=(0,m.default)(Sa.Text.Paragraph).withConfig({displayName:"editorSettings__ConnectionHelperText",componentId:"sc-1y9ilpk-6"})(["padding-top:12px;color:",";"],(e=>{let{hasError:t,theme:a}=e;return t?a.colors.fg.negative:a.colors.fg.tertiary})),ts=(0,m.default)(Sa.Text.Paragraph).withConfig({displayName:"editorSettings__CenterMutedText",componentId:"sc-1y9ilpk-7"})(["color:",";text-align:center;"],(e=>{let{theme:t}=e;return t.colors.fg.tertiary})),as=(0,m.default)(Qi).withConfig({displayName:"editorSettings__SettingSubheading",componentId:"sc-1y9ilpk-8"})(["padding:8px 0;"]),rs=(0,m.default)(Qi).withConfig({displayName:"editorSettings__TextInputHelperText",componentId:"sc-1y9ilpk-9"})(["padding-top:12px;"]),ns=(0,m.default)(Sa.Text.Label).withConfig({displayName:"editorSettings__CheckboxLabel",componentId:"sc-1y9ilpk-10"})(["display:flex;justify-content:flex-start;margin-top:8px;cursor:pointer;"]),ls=(0,m.default)(Qi).withConfig({displayName:"editorSettings__CheckboxLabelText",componentId:"sc-1y9ilpk-11"})(["margin-left:8px;"]),os=(0,m.default)(ts).withConfig({displayName:"editorSettings__Error",componentId:"sc-1y9ilpk-12"})(["padding-bottom:10px;color:",";"],(e=>{let{theme:t}=e;return t.colors.fg.negative})),is=m.default.div.withConfig({displayName:"editorSettings__UploadedContainer",componentId:"sc-1y9ilpk-13"})(["display:grid;grid-template-columns:repeat(auto-fill,102px);grid-auto-rows:102px;grid-column-gap:12px;grid-row-gap:20px;padding-bottom:20px;margin-bottom:4px;border:1px solid transparent;",";"],$t.focusableOutlineCSS),ss=m.default.div.withConfig({displayName:"editorSettings__GridItemContainer",componentId:"sc-1y9ilpk-14"})(["position:relative;",";&:hover,&:focus-within{button{opacity:1 !important;}}"],(e=>{let{active:t,theme:a}=e;return t&&(0,m.css)(["border:1px solid ",";border-radius:",";"],a.colors.border.defaultActive,a.borders.radius.small)})),cs=m.default.button.withConfig({displayName:"editorSettings__GridItemButton",componentId:"sc-1y9ilpk-15"})(["display:block;background-color:transparent;border:2px solid transparent;width:100%;height:100%;border-radius:4px;padding:0;",";"],$t.focusableOutlineCSS),ds=m.default.img.withConfig({displayName:"editorSettings__Logo",componentId:"sc-1y9ilpk-16"})(["object-fit:cover;width:100%;height:100%;border-radius:4px;"]),us=m.default.div.withConfig({displayName:"editorSettings__MenuContainer",componentId:"sc-1y9ilpk-17"})(["position:absolute;top:0;width:100%;height:100%;"]),ps=(0,m.default)(Bt.Button).attrs({size:Mt.ButtonSize.Small,type:Mt.ButtonType.Secondary,variant:Mt.ButtonVariant.Circle}).withConfig({displayName:"editorSettings__LogoMenuButton",componentId:"sc-1y9ilpk-18"})(["opacity:",";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);"],(e=>{let{isActive:t,menuOpen:a}=e;return a||t?1:0})),ms=(0,m.default)(Bt.Button).withConfig({displayName:"editorSettings__SaveButton",componentId:"sc-1y9ilpk-19"})(["height:36px;"]),fs=(0,m.default)(Bt.Button).withConfig({displayName:"editorSettings__TestConnectionButton",componentId:"sc-1y9ilpk-20"})(["height:36px;margin-top:12px;"]),gs=m.default.div.withConfig({displayName:"editorSettings__InlineForm",componentId:"sc-1y9ilpk-21"})(["display:flex;align-items:flex-start;"]),hs=m.default.label.withConfig({displayName:"editorSettings__VisuallyHiddenLabel",componentId:"sc-1y9ilpk-22"})(Ea.visuallyHidden),bs=(0,m.default)(Aa.default).withConfig({displayName:"editorSettings__SettingsTextInput",componentId:"sc-1y9ilpk-23"})(["margin-right:8px;"]),_s=(m.default.span.withConfig({displayName:"editorSettings__VisuallyHiddenDescription",componentId:"sc-1y9ilpk-24"})(Ea.visuallyHidden),(0,m.default)(Yi).withConfig({displayName:"editorSettings__MultilineForm",componentId:"sc-1y9ilpk-25"})(["margin-bottom:28px;","{margin-top:20px;}"],gs)),ys={SLOT_ID_LABEL:(0,l.__)("Monetization type","web-stories"),HELPER_MESSAGE_ADSENSE:(0,l.__)("Learn more about how to monetize your Web Stories using AdSense. Once configured, AdSense will determine where and how to insert ads into the story. Consult AdSense Help for any further assistance.","web-stories"),HELPER_MESSAGE_ADMANAGER:(0,l.__)("Learn how to enable programmatic demand in Web Stories through Ad Manager.","web-stories"),HELPER_MESSAGE_MGID:(0,l.__)("Learn how to start monetizing Web Stories with MGID Native Solution","web-stories"),HELPER_LINK_ADSENSE:(0,l.__)("https://support.google.com/adsense/answer/10175505","web-stories"),HELPER_LINK_ADSENSE_HELP:(0,l.__)("https://support.google.com/adsense/","web-stories"),HELPER_LINK_ADMANAGER:(0,l.__)("https://support.google.com/admanager/answer/9416436","web-stories"),HELPER_LINK_MGID:(0,l.__)("https://help.mgid.com/generate-revenue-with-amp-web-stories?utm_source=wp-plugin&utm_medium=web-stories-by-google","web-stories")},Es=[{label:(0,l._x)("None","ad network","web-stories"),value:xi},{label:(0,l.__)("Google AdSense","web-stories"),value:Oi},{label:(0,l.__)("Google Ad Manager","web-stories"),value:Di},{label:(0,l.__)("MGID","web-stories"),value:Ni}];const Ss=function AdNetworkSettings(e){let{adNetwork:t,handleUpdate:a}=e;const[r,l]=(0,h.useState)(t);(0,h.useEffect)((()=>l(t)),[t]);const o=(0,h.useMemo)((()=>Di===r?ys.HELPER_MESSAGE_ADMANAGER:Oi===r?ys.HELPER_MESSAGE_ADSENSE:Ni===r?ys.HELPER_MESSAGE_MGID:null),[r]),i=(0,h.useMemo)((()=>Di===r?ys.HELPER_LINK_ADMANAGER:Oi===r?ys.HELPER_LINK_ADSENSE:Ni===r?ys.HELPER_LINK_MGID:null),[r]),s=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_monetization_docs")),[]);return n.createElement(n.Fragment,null,n.createElement(vn.default,{ariaLabel:ys.SLOT_ID_LABEL,options:Es,selectedValue:r,onMenuItemClick:(e,t)=>a(t),fillWidth:!0}),o&&n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:i,rel:"noreferrer",target:"_blank",onClick:s,size:Ya.TextSize.Small}),help:n.createElement(Ji,{href:ys.HELPER_LINK_ADSENSE_HELP,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small})}},o)))},ws=/^\/\d+(,\d+)?(\/[\w\d_\-.*\\!<:()]{1,99}[^/])*$/;const vs={SLOT_ID_CONTEXT:(0,X.default)(/* translators: %s: example value. */ (0,l.__)("Example: %s","web-stories"),"/123456789/a4a/amp_story_dfp_example"),SLOT_ID_PLACEHOLDER:(0,l.__)("Enter your Slot ID","web-stories"),SLOT_ID_LABEL:(0,l.__)("Google Ad Manager Slot ID","web-stories"),INPUT_ERROR:(0,l.__)("Invalid ID format","web-stories"),SUBMIT_BUTTON:(0,l.__)("Save","web-stories")};const Ts=function GoogleAdManagerSettings(e){let{slotId:t,handleUpdate:a}=e;const[r,l]=(0,h.useState)(t),[o,i]=(0,h.useState)(""),s=r!==t&&!o,c=!s;(0,h.useEffect)((()=>{l(t)}),[t]);const d=(0,h.useCallback)((e=>{const{value:t}=e.target;l(t),0===t.length||function(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(ws))}(t)?i(""):i(vs.INPUT_ERROR)}),[]),u=(0,h.useCallback)((()=>{s&&a(r)}),[s,r,a]),p=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),u())}),[u]);return n.createElement(n.Fragment,null,n.createElement(gs,null,n.createElement(hs,{htmlFor:"adManagerSlotId"},vs.SLOT_ID_LABEL),n.createElement(bs,{id:"adManagerSlotId","aria-label":vs.SLOT_ID_LABEL,value:r,onChange:d,onKeyDown:p,placeholder:vs.SLOT_ID_PLACEHOLDER,hasError:Boolean(o),hint:o}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:c,onClick:u},vs.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},vs.SLOT_ID_CONTEXT))},Cs=/^(ca-)?pub-\d{16}$/;const Is=/^\d{10}$/;const ks={PUBLISHER_ID_CONTEXT:(0,X.default)(/* translators: 1: first example. 2: second example. */ (0,l.__)("Example: %1$s or %2$s. Find your AdSense Publisher ID.","web-stories"),"pub-1234567891234567","ca-pub-1234567891234567"),PUBLISHER_ID_CONTEXT_LINK:(0,l.__)("https://support.google.com/adsense/answer/105516","web-stories"),PUBLISHER_ID_PLACEHOLDER:(0,l.__)("Enter your Publisher ID","web-stories"),PUBLISHER_ID_LABEL:(0,l.__)("Google AdSense Publisher ID","web-stories"),SLOT_ID_CONTEXT:(0,X.default)(/* translators: %s: example value. */ (0,l.__)("Example: %s. Copy the slot ID from your ad unit’s code. The same ad unit will be used for all of your Web Stories.","web-stories"),"1234567890"),SLOT_ID_CONTEXT_LINK:(0,l.__)("https://support.google.com/adsense/answer/9274019","web-stories"),SLOT_ID_PLACEHOLDER:(0,l.__)("Enter your Slot ID","web-stories"),SLOT_ID_LABEL:(0,l.__)("Google AdSense Slot ID","web-stories"),INPUT_ERROR:(0,l.__)("Invalid ID format","web-stories"),SUBMIT_BUTTON:(0,l.__)("Save","web-stories")};const Ls=function GoogleAdSenseSettings(e){let{publisherId:t,slotId:a,handleUpdatePublisherId:r,handleUpdateSlotId:l}=e;const[o,i]=(0,h.useState)(t),[s,c]=(0,h.useState)(""),d=o!==t&&!s,u=!d,[p,m]=(0,h.useState)(a),[f,g]=(0,h.useState)(""),b=p!==a&&!f,_=!b;(0,h.useEffect)((()=>{i(t)}),[t]);const y=(0,h.useCallback)((e=>{const{value:t}=e.target;i(t),0===t.length||function(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(Cs))}(t)?c(""):c(ks.INPUT_ERROR)}),[]),S=(0,h.useCallback)((()=>{d&&r(o)}),[d,o,r]),w=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),S())}),[S]);(0,h.useEffect)((()=>{m(a)}),[a]);const v=(0,h.useCallback)((e=>{const{value:t}=e.target;m(t),0===t.length||function(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(Is))}(t)?g(""):g(ks.INPUT_ERROR)}),[]),T=(0,h.useCallback)((()=>{b&&l(p)}),[b,p,l]),C=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),T())}),[T]),I=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_adsense_publisher_id_docs")),[]);return n.createElement(n.Fragment,null,n.createElement(gs,null,n.createElement(hs,{htmlFor:"adSensePublisherId"},ks.PUBLISHER_ID_LABEL),n.createElement(bs,{"aria-label":ks.PUBLISHER_ID_LABEL,id:"adSensePublisherId",name:"adSensePublisherId","data-testid":"adSensePublisherId",value:o,onChange:y,onKeyDown:w,placeholder:ks.PUBLISHER_ID_PLACEHOLDER,hasError:Boolean(s),hint:s}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:u,onClick:S,"data-testid":"adSensePublisherIdButton"},ks.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:ks.PUBLISHER_ID_CONTEXT_LINK,rel:"noreferrer",target:"_blank",onClick:I,size:Ya.TextSize.Small})}},ks.PUBLISHER_ID_CONTEXT)),n.createElement(gs,null,n.createElement(hs,{htmlFor:"adSenseSlotId"},ks.SLOT_ID_LABEL),n.createElement(bs,{id:"adSenseSlotId","aria-label":ks.SLOT_ID_LABEL,name:"adSenseSlotId","data-testid":"adSenseSlotId",value:p,onChange:v,onKeyDown:C,placeholder:ks.SLOT_ID_PLACEHOLDER,hasError:Boolean(f),hint:f}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:_,onClick:T,"data-testid":"adSenseSlotIdButton"},ks.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:ks.SLOT_ID_CONTEXT_LINK,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small})}},ks.SLOT_ID_CONTEXT)))},As=/^\d{7,20}$/;const xs={WIDGET_ID_CONTEXT:(0,X.default)(/* translators: %s: example value. */ (0,l.__)("Example: %s","web-stories"),"1234567"),WIDGET_ID_PLACEHOLDER:(0,l.__)("Enter your MGID Widget ID","web-stories"),WIDGET_ID_LABEL:(0,l.__)("Widget ID","web-stories"),INPUT_ERROR:(0,l.__)("Invalid ID format","web-stories"),SUBMIT_BUTTON:(0,l.__)("Save","web-stories")};const Os=function MgidSettings(e){let{widgetId:t,handleUpdate:a}=e;const[r,l]=(0,h.useState)(t),[o,i]=(0,h.useState)(""),s=r!==t&&!o,c=!s;(0,h.useEffect)((()=>{l(t)}),[t]);const d=(0,h.useCallback)((e=>{const{value:t}=e.target;l(t),0===t.length||function(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(As))}(t)?i(""):i(xs.INPUT_ERROR)}),[]),u=(0,h.useCallback)((()=>{s&&a(r)}),[s,r,a]),p=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),u())}),[u]);return n.createElement(n.Fragment,null,n.createElement(gs,null,n.createElement(hs,{htmlFor:"mgidWidgetId"},xs.WIDGET_ID_LABEL),n.createElement(bs,{id:"mgidWidgetId","aria-label":xs.WIDGET_ID_LABEL,value:r,onChange:d,onKeyDown:p,placeholder:xs.WIDGET_ID_PLACEHOLDER,hasError:Boolean(o),hint:o}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:c,onClick:u},xs.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},xs.WIDGET_ID_CONTEXT))},Ds={SECTION_HEADING:(0,l.__)("Monetization","web-stories"),HELPER_MESSAGE_NONE:(0,l.__)("Monetize your content by showing ads in your Web Stories. Learn more.","web-stories"),HELPER_LINK_NONE:(0,l.__)("https://amp.dev/documentation/guides-and-tutorials/develop/advertise_amp_stories/","web-stories"),SITE_KIT_NOT_INSTALLED:(0,l.__)("Install Site Kit by Google to easily enable Google AdSense for Web Stories.","web-stories"),SITE_KIT_INSTALLED:(0,l.__)("Use Site Kit by Google to easilyactivate Google AdSense for Web Stories.","web-stories"),SITE_KIT_IN_USE:(0,l.__)("Site Kit by Google has already enabled Google AdSense for your Web Stories, all changes to your ad configuration should occur there.","web-stories")};const Ns=function AdManagement(e){let{updateSettings:t,adNetwork:a,publisherId:r,adSenseSlotId:l,adManagerSlotId:o,mgidWidgetId:i,siteKitStatus:s}=e;const{adsenseActive:c,installed:d,adsenseLink:u}=s,p=(0,h.useCallback)((e=>(0,E.trackClick)(e,"monetization","dashboard",Ds.HELPER_LINK_NONE)),[]),m=(0,h.useCallback)((e=>t({adSensePublisherId:e})),[t]),f=(0,h.useCallback)((e=>t({adSenseSlotId:e})),[t]),g=(0,h.useCallback)((e=>t({adManagerSlotId:e})),[t]),b=(0,h.useCallback)((e=>t({mgidWidgetId:e})),[t]),_=(0,h.useCallback)((e=>{t({adNetwork:e}),(0,E.trackEvent)("change_ad_network",{name:e})}),[t]),y=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_site_kit_link")),[]),S=(0,h.useMemo)((()=>c?null:n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:u,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small,onClick:y})}},d?Ds.SITE_KIT_INSTALLED:Ds.SITE_KIT_NOT_INSTALLED)),[c,d,u,y]);return n.createElement(_s,{onSubmit:e=>e.preventDefault()},n.createElement("div",null,n.createElement(Zi,null,Ds.SECTION_HEADING),n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:Ds.HELPER_LINK_NONE,rel:"noreferrer",target:"_blank",onClick:p,size:Ya.TextSize.Small})}},Ds.HELPER_MESSAGE_NONE)),n.createElement(as,{size:Ya.TextSize.Small},S)),c?n.createElement("div",null,n.createElement(rs,{size:Ya.TextSize.Small},Ds.SITE_KIT_IN_USE)):n.createElement("div",null,n.createElement(Ss,{handleUpdate:_,adNetwork:a}),Oi===a&&n.createElement(Ls,{handleUpdatePublisherId:m,handleUpdateSlotId:f,publisherId:r,slotId:l,siteKitStatus:s}),Di===a&&n.createElement(Ts,{handleUpdate:g,slotId:o}),Ni===a&&n.createElement(Os,{handleUpdate:b,widgetId:i})))};var Ps=a(25252);Pt.shape({value:Pt.number,set:Pt.func}).isRequired,Pt.number,Pt.bool,Pt.arrayOf(Pt.shape({disabled:Pt.bool,href:Pt.string,label:Pt.string.isRequired,openNewTab:Pt.bool,onClick:Pt.func,onFocus:Pt.func})).isRequired,Pt.func.isRequired,Pt.shape({url:Pt.string,title:Pt.string,id:Pt.number,active:Pt.bool}).isRequired;const Rs=function PopoverLogoContextMenu(e){let{isActive:t,idx:a,publisherLogo:r,contextMenuId:o,onMenuItemToggle:i,items:s}=e;const c=o.value===r.id,d=t?0:-1,u=(0,h.useCallback)((e=>o.set(e)),[o]),p=(0,h.useCallback)((()=>u(-1)),[u]);return n.createElement(us,null,n.createElement(ps,{tabIndex:d,isActive:t,menuOpen:c,"data-testid":`publisher-logo-context-menu-button-${a}`,"aria-label":(0,X.default)(/* translators: %s: logo title */ (0,l.__)("Publisher logo menu for %s","web-stories"),r.title),onClick:e=>{e.preventDefault(),i(c?null:r.id),u(c?-1:r.id)},onFocus:()=>{i(c?null:r.id)}},n.createElement(Ps.default,{"aria-hidden":"true"})),n.createElement(Jt.default,{animate:!0,isOpen:c,"data-testid":`publisher-logo-context-menu-${a}`,onDismiss:p},s.map((e=>{let{label:t,separator:a,...r}=e;const l=r.href?la:oa.default;return n.createElement(h.Fragment,{key:t},"top"===a&&n.createElement(ia.default,null),n.createElement(l,r,t),"bottom"===a&&n.createElement(ia.default,null))}))))},Bs=(0,h.forwardRef)(((e,t)=>{let{contextMenuId:a,index:r,onMenuItemToggle:o,onRemoveLogo:i,onUpdateDefaultLogo:s,publisherLogo:c,setFocusedPublisherLogoId:d,showLogoContextMenu:u,isFocused:p}=e;const m=[{label:(0,l.__)("Set as Default","web-stories"),onClick:e=>{e.preventDefault(),s(c)},disabled:c.active},{label:(0,l.__)("Delete","web-stories"),onClick:e=>{e.preventDefault(),i(c,r)}}];return n.createElement(ss,{ref:t,role:"listitem",active:c.active,"data-testid":`publisher-logo-${r}`},n.createElement(cs,{onFocus:()=>{d(c.id)},"data-testid":`uploaded-publisher-logo-${r}`,isSelected:p,tabIndex:p?0:-1,onClick:e=>{e.preventDefault(),d(c.id)},"aria-label":(0,X.default)(/* translators: %s: logo title.*/ (0,l.__)("Publisher Logo %s","web-stories"),c.title)},n.createElement(ds,{src:c.url,alt:c.title})),c.active&&n.createElement(ts,{size:Ya.TextSize.XSmall},(0,l.__)("Default","web-stories")),u&&n.createElement(Rs,{isActive:p,idx:r,items:m,publisherLogo:c,onMenuItemToggle:o,contextMenuId:a}))}));Bs.displayName="GridItem";const Ms={SECTION_HEADING:(0,l.__)("Publisher Logo","web-stories"),UPLOAD_CONTEXT:(0,l.__)("Upload your logos here and they will become available to any stories you create.","web-stories"),CLICK_CONTEXT:(0,l.__)("Click on logo to set as default if you want that logo to be used on default logo for all your stories.","web-stories"),REMOVAL:(0,l.__)("Removing a logo from your settings won't remove it from any stories using that logo.","web-stories"),INSTRUCTIONS:(0,l.__)("Avoid vector files, such as svg or eps. Logos should be at least 96x96 pixels and a perfect square. The background should not be transparent.","web-stories"),SUBMIT:(0,l.__)("Upload logo","web-stories"),ARIA_LABEL:(0,l.__)("Click to upload a new logo","web-stories"),HELPER_UPLOAD:(0,l.__)("Drag a jpg, png, or static gif in this box. Or click “Upload logo” below.","web-stories")};const Us=function PublisherLogoSettings(e){let{canUploadFiles:t,onAddLogos:a,onRemoveLogo:r,onUpdateDefaultLogo:o,isLoading:i,publisherLogos:s,uploadError:c}=e;const{isRTL:d,allowedImageMimeTypes:u}=y(),p=(0,h.useRef)(),m=(0,h.useRef)(),f=(0,h.useRef)({}),[g,b]=(0,h.useState)(null),[_,E]=(0,h.useState)(null),[S,w]=(0,h.useState)(null),v=1===s.length,T=(0,h.useRef)(s.length),C=(0,h.useCallback)(((e,t)=>{w(-1),r?.(e),E(t),T.current=s.length}),[r,s.length]),I=(0,h.useCallback)((e=>{w(-1),o?.(e)}),[o]);(0,h.useEffect)((()=>{if(Boolean(_?.toString())&&s.length!==T.current){if(0===s.length)return p.current?.getElementsByTagName("input")[0].focus();const e=_>0?s[_-1]:s[0];return b(e.id),f.current[e.id].firstChild.focus(),E(null)}}),[_,s,b]),(0,Nt.default)({containerRef:p,gridRef:m,itemRefs:f,isRTL:d,currentItemId:g,items:s});const k=(0,h.useCallback)((e=>{b(e)}),[]);return(0,h.useFocusOut)(p,(()=>{b(null),w(null)}),[]),n.createElement(Yi,null,n.createElement("div",null,n.createElement(Zi,null,Ms.SECTION_HEADING),n.createElement(as,{size:Ya.TextSize.Small},Ms.UPLOAD_CONTEXT),n.createElement(as,{size:Ya.TextSize.Small},Ms.CLICK_CONTEXT),n.createElement(as,{size:Ya.TextSize.Small},Ms.REMOVAL)),n.createElement("div",{ref:p,"data-testid":"publisher-logos-container"},s.length>0&&n.createElement(is,{tabIndex:0,ref:m,role:"list","aria-label":(0,l.__)("Viewing existing publisher logos","web-stories")},s.map(((e,t)=>n.createElement(Bs,{key:e.id,ref:t=>{f.current[e.id]=t},contextMenuId:{set:w,value:S},index:t,isFocused:g===e.id,onMenuItemToggle:k,onRemoveLogo:C,onUpdateDefaultLogo:I,publisherLogo:e,setFocusedPublisherLogoId:b,showLogoContextMenu:!v})))),c&&n.createElement(os,{role:"alert"},c),t&&n.createElement(n.Fragment,null,n.createElement(La,{onSubmit:a,id:"settings_publisher_logos",isLoading:i,label:Ms.SUBMIT,isMultiple:!0,ariaLabel:Ms.ARIA_LABEL,instructionalText:Ms.HELPER_UPLOAD,acceptableFormats:Object.values(u)}),n.createElement(as,{size:Ya.TextSize.Small},Ms.INSTRUCTIONS))))};var Fs=a(45431),zs=a(83308);function TelemetrySettings(e){let{selected:t,onCheckboxSelected:a,disabled:r}=e;const o=(0,h.useMemo)((()=>`telemetry-opt-in-${(0,Fs.default)()}`),[]);return n.createElement(Yi,null,n.createElement("div",null,n.createElement(Zi,null,(0,l.__)("Data Sharing Opt-in","web-stories"))),n.createElement("div",null,n.createElement(ns,{htmlFor:o},n.createElement(zs.default,{id:o,"data-testid":"telemetry-settings-checkbox",disabled:r,onChange:a,checked:Boolean(t)}),n.createElement(ls,{size:Ya.TextSize.Small,"aria-checked":Boolean(t)},n.createElement(dn.default,{mapping:{a:n.createElement("a",{href:(0,l.__)("https://policies.google.com/privacy","web-stories"),rel:"noreferrer",target:"_blank","aria-label":(0,l.__)("Learn more by visiting Google Privacy Policy","web-stories")})}},(0,l.__)("Check the box to help us improve the Web Stories plugin by allowing tracking of product usage stats. All data are treated in accordance with Google Privacy Policy.","web-stories"))))))}function MediaOptimizationSettings(e){let{selected:t,onCheckboxSelected:a,disabled:r}=e;const o=(0,h.useMemo)((()=>`media-optimization-${(0,Fs.default)()}`),[]);return n.createElement(Yi,null,n.createElement("div",null,n.createElement(Zi,null,(0,l.__)("Video Optimization","web-stories"))),n.createElement("div",null,n.createElement(ns,{htmlFor:o},n.createElement(zs.default,{id:o,"data-testid":"media-optimization-settings-checkbox",disabled:r,onChange:a,checked:Boolean(t)}),n.createElement(ls,{size:Ya.TextSize.Small,"aria-checked":Boolean(t)},(0,l.__)("Automatically optimize videos used in Web Stories. We recommend enabling this feature. Video files that are too large or have an unsupported format (like .mov) will otherwise not display properly.","web-stories")))))}function VideoCacheSettings(e){let{isEnabled:t=!1,updateSettings:a}=e;const r=(0,h.useMemo)((()=>`video-cache-${(0,Fs.default)()}`),[]),o=(0,h.useCallback)((()=>a({videoCache:!t})),[a,t]);return n.createElement(Yi,null,n.createElement("div",null,n.createElement(Zi,null,(0,l.__)("Video Cache","web-stories"))),n.createElement("div",null,n.createElement(ns,{htmlFor:r},n.createElement(zs.default,{id:r,"data-testid":"video-cache-settings-checkbox",onChange:o,checked:Boolean(t)}),n.createElement(ls,{size:Ya.TextSize.Small,"aria-checked":Boolean(t)},(0,l.__)("Reduce hosting costs and improve user experience by serving videos from the Google cache.","web-stories")))))}function DataRemovalSettings(e){let{isEnabled:t=!1,updateSettings:a}=e;const r=(0,h.useCallback)((()=>a({dataRemoval:!t})),[a,t]);return n.createElement(Yi,null,n.createElement("div",null,n.createElement(Zi,null,(0,l.__)("Plugin Uninstall","web-stories"))),n.createElement("div",null,n.createElement(ns,{htmlFor:"data-removal-settings"},n.createElement(zs.default,{id:"data-removal-settings","data-testid":"data-removal-settings-checkbox",onChange:r,checked:Boolean(t)}),n.createElement(ls,{size:Ya.TextSize.Small,"aria-checked":Boolean(t)},(0,l.__)("Remove all data including stories and saved templates when uninstalling the Web Stories plugin.","web-stories")))))}const Gs={LABEL:(0,l.__)("Stories Archives","web-stories"),SECTION_HEADING:(0,l.__)("Stories Archives","web-stories"),ARCHIVE_CONTENT:(0,l.__)("By default WordPress automatically creates an archive page, displaying your latest stories in your theme's layout.","web-stories"),ARCHIVE_CONTENT_2:(0,l.__)("You can customize or disable this behavior.","web-stories"),SUB_TEXT_CUSTOM:(0,l.__)("Choose a page to serve as your Web Stories archive. Use the Web Stories block to add stories to this page.","web-stories")},Hs=[{label:(0,l._x)("Default","archive type","web-stories"),value:Pi.DEFAULT},{label:(0,l.__)("Disabled","web-stories"),value:Pi.DISABLED},{label:(0,l.__)("Create your own","web-stories"),value:Pi.CUSTOM}],js=m.default.div.withConfig({displayName:"archive__SearchWrapper",componentId:"sc-u9kj1r-0"})(["padding-top:12px;"]);function ArchiveSettings(e){let{archive:t=Pi.DEFAULT,archiveURL:a,defaultArchiveURL:r,archivePageId:o,updateSettings:i,searchPages:s,getPageById:c}=e;const[d,u]=(0,h.useState)(a),[p,m]=(0,h.useState)(o?{value:o}:void 0),[f,g]=(0,h.useState)([]),b=(0,h.useCallback)(((e,t)=>{u(a);const r=t===Pi.CUSTOM?o:0;m(r),i({archive:t,archivePageId:r})}),[i,o,a]),_=(0,h.useCallback)(((e,t)=>{const a=Number(t.value);a!==o&&(m(a?{value:a}:void 0),i({archivePageId:a}))}),[o,i]);(0,h.useEffect)((()=>{let e=!0;return o&&Pi.CUSTOM===t&&(async()=>{const{title:t,link:a}=await c(o);if(e&&t){const e={value:o,label:t};g((t=>[e,...t])),m(e),u(a)}})(),()=>{e=!1}}),[t,o,c]);const y=(0,h.useDebouncedCallback)((async e=>{await(0,E.trackEvent)("archive_page_search",{search_type:"dashboard",search_term:e}),g(await s(e))}),lt);return n.createElement(Yi,null,n.createElement("div",null,n.createElement(Zi,null,Gs.SECTION_HEADING),n.createElement(rs,{size:Ya.TextSize.Small},Gs.ARCHIVE_CONTENT),n.createElement(rs,{size:Ya.TextSize.Small},Gs.ARCHIVE_CONTENT_2)),n.createElement("div",null,n.createElement(vn.default,{ariaLabel:Gs.LABEL,options:Hs,selectedValue:t,onMenuItemClick:b,fillWidth:!0}),Pi.DISABLED===t&&n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{code:n.createElement("code",null)}},(0,X.default)(/* translators: %s: archive url. */ (0,l.__)("Turn off the default archive page at %s. Users will see a 404 Not Found page when trying to access the default archive page.","web-stories"),d))),Pi.CUSTOM===t&&n.createElement(rs,{size:Ya.TextSize.Small},Gs.SUB_TEXT_CUSTOM),Pi.CUSTOM===t&&n.createElement(js,null,n.createElement(el,{placeholder:(0,l.__)("Select page","web-stories"),selectedValue:p,options:f,handleSearchValueChange:y,emptyText:(0,l.__)("No pages available","web-stories"),onMenuItemClick:_})),Pi.DISABLED!==t&&n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:d,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small}),code:n.createElement("code",null)}},o&&d!==r?(0,X.default)(/* translators: 1. current archive url, 2. default archive url. */ (0,l.__)("Visit archive page at %1$s. %2$s will automatically redirect to this page.","web-stories"),d,r):(0,X.default)(/* translators: %s: archive url. */ (0,l.__)("Visit archive page at %1$s.","web-stories"),d)))))}var Vs=a(37169),$s=a(48068);const Ws=/^ua-\d+-\d+|g-\w+$/;const Ks=(0,m.default)(Vs.default).withConfig({displayName:"googleAnalytics__StyledNotificationBubble",componentId:"sc-svg62t-0"})(["display:inline-block;margin-left:10px;"]),qs={CONTEXT:(0,l.__)("The story editor will append a default, configurable AMP analytics configuration to your story. If you’re interested in going beyond what the default configuration, read this article.","web-stories"),CONTEXT_LINK:"https://blog.amp.dev/2019/08/28/analytics-for-your-amp-stories/",SECTION_HEADING:(0,l.__)("Google Analytics","web-stories"),PLACEHOLDER:(0,l.__)("Enter your Google Analytics Measurement ID","web-stories"),ARIA_LABEL:(0,l.__)("Enter your Google Analytics Measurement ID","web-stories"),INPUT_ERROR:(0,l.__)("Invalid ID format","web-stories"),SUBMIT_BUTTON:(0,l.__)("Save","web-stories"),SITE_KIT_NOT_INSTALLED:(0,l.__)("Install Site Kit by Google to easily enable Google Analytics for Web Stories.","web-stories"),SITE_KIT_INSTALLED:(0,l.__)("Use Site Kit by Google to easilyactivate Google Analytics for Web Stories.","web-stories"),SITE_KIT_IN_USE:(0,l.__)("Site Kit by Google has already enabled Google Analytics for your Web Stories, all changes to your analytics tracking should occur there.","web-stories")},Xs=m.default.div.withConfig({displayName:"googleAnalytics__WarningContainer",componentId:"sc-svg62t-1"})(["display:flex;gap:8px;margin:14px auto;border:1px solid ",";border-radius:",";padding:8px;"],(e=>{let{theme:t}=e;return t.colors.border.defaultNormal}),(e=>{let{theme:t}=e;return t.borders.radius.small})),Ys=(0,m.default)($s.default).withConfig({displayName:"googleAnalytics__WarningIcon",componentId:"sc-svg62t-2"})(["width:32px;height:100%;color:",";"],(e=>{let{theme:t}=e;return t.colors.status.warning})),Zs=(0,m.default)(Sa.Text.Paragraph).attrs({size:Ya.TextSize.Small}).withConfig({displayName:"googleAnalytics__Message",componentId:"sc-svg62t-3"})(["max-width:calc(100% - 40px);"]);const Js=function GoogleAnalyticsSettings(e){let{googleAnalyticsId:t,handleUpdateAnalyticsId:a,usingLegacyAnalytics:r,handleMigrateLegacyAnalytics:o,siteKitStatus:i={}}=e;const[s,c]=(0,h.useState)(t),[d,u]=(0,h.useState)(""),p=s!==t&&!d,m=!p,{analyticsActive:f,installed:g,analyticsLink:b}=i;(0,h.useEffect)((()=>{c(t)}),[t]);const _=(0,h.useCallback)((e=>{const{value:t}=e.target;c(t),0===t.length||function(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(Ws))}(t)?u(""):u(qs.INPUT_ERROR)}),[]),y=(0,h.useCallback)((()=>{p&&a(s)}),[p,s,a]),S=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),y())}),[y]),w=(0,h.useCallback)((e=>{e.preventDefault(),o(),(0,E.trackEvent)("migrate_story_auto_analytics")}),[o]),v=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_auto_analytics_link")),[]),T=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_site_kit_link")),[]),C=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_analytics_docs")),[]),I=(0,h.useMemo)((()=>f?null:n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:b,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small,onClick:T})}},g?qs.SITE_KIT_INSTALLED:qs.SITE_KIT_NOT_INSTALLED)),[f,g,b,T]);return n.createElement(Yi,{onSubmit:e=>e.preventDefault()},n.createElement("div",null,n.createElement(Zi,{htmlFor:"gaTrackingID",as:"h3"},qs.SECTION_HEADING,r&&n.createElement(Ks,{notificationCount:1,isSmall:!0})),n.createElement(as,{size:Ya.TextSize.Small},I),r&&n.createElement(n.Fragment,null,n.createElement(as,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:"https://wp.stories.google/docs/seo/",rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small,onClick:v})}},(0,l.__)("An improved analytics configuration is now available. Learn more.","web-stories"))),n.createElement(as,{size:Ya.TextSize.Small},n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,onClick:w},(0,l.__)("Migrate","web-stories"))))),n.createElement("div",null,f?n.createElement(rs,{size:Ya.TextSize.Small},qs.SITE_KIT_IN_USE):n.createElement(n.Fragment,null,n.createElement(gs,null,n.createElement(hs,{htmlFor:"gaTrackingId"},qs.ARIA_LABEL),n.createElement(bs,{"aria-label":qs.ARIA_LABEL,id:"gaTrackingId",value:s,onChange:_,onKeyDown:S,placeholder:qs.PLACEHOLDER,hasError:Boolean(d),hint:d,disabled:f}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:m,onClick:y},qs.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:qs.CONTEXT_LINK,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small,onClick:C})}},qs.CONTEXT)),!t||t.startsWith("UA-")?n.createElement(Xs,null,n.createElement(Ys,{"aria-hidden":!0}),n.createElement(Zs,null,n.createElement(dn.default,{mapping:{a:n.createElement(ea.Link,{href:(0,l.__)("https://support.google.com/analytics/answer/11583528?hl=en","web-stories"),rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small,onClick:e=>(0,E.trackClick)(e,"click_ua_deprecation_docs")}),a2:n.createElement(ea.Link,{href:(0,l.__)("https://support.google.com/analytics/answer/10089681?hl=en","web-stories"),rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small,onClick:e=>(0,E.trackClick)(e,"click_ga4_docs")})}},(0,l.__)("As previously announced, Universal Analytics will stop processing new visits starting July 1, 2023. We recommend switching to Google Analytics 4 (GA4), our analytics product of record.","web-stories")))):null)))};var Qs=a(30385),ec=a(96921);const tc=function ConfirmationDialog(e){let{onClose:t,onPrimary:a}=e;return n.createElement(m.ThemeProvider,{theme:i.theme},n.createElement(ba.default,{isOpen:!0,onClose:t,title:(0,l.__)("Delete Font","web-stories"),actions:n.createElement(n.Fragment,null,n.createElement(Bt.Button,{type:Mt.ButtonType.Tertiary,size:Mt.ButtonSize.Small,onClick:()=>t()},(0,l.__)("Cancel","web-stories")),n.createElement(Bt.Button,{type:Mt.ButtonType.Primary,size:Mt.ButtonSize.Small,onClick:()=>a()},(0,l.__)("Delete Font","web-stories")))},n.createElement(Sa.Text.Paragraph,{size:Ya.TextSize.Small},(0,l.__)("Deleting a font will delete it from every previous story it’s in. Would you like to proceed?","web-stories"))))};const ac=async function(e){const{load:t}=await Promise.all([a.e(4422),a.e(2794)]).then(a.bind(a,44422)),r=await t(e);return{name:r.names.fullName.en,family:r.names.fullName.en,weights:[400],styles:["regular"],variants:[[0,400]],service:"custom",fallbacks:["sans-serif"],metrics:{upm:r.unitsPerEm,asc:r.ascender,des:r.descender,tAsc:r.tables.os2.sTypoAscender,tDes:r.tables.os2.sTypoDescender,tLGap:r.tables.os2.sTypoLineGap,wAsc:r.tables.os2.usWinAscent,wDes:r.tables.os2.usWinDescent,xH:r.tables.os2.sxHeight,capH:r.tables.os2.sCapHeight,yMin:r.tables.head.yMin,yMax:r.tables.head.yMax,hAsc:r.tables.hhea.ascender,hDes:r.tables.hhea.descender,lGap:r.tables.hhea.lineGap}}},rc={ADD_CONTEXT:(0,l.__)("Add and manage your custom and brand fonts via link here. They’ll appear in your font list in the editor.","web-stories"),REMOVAL:(0,l.__)("Removing a font from this settings page will remove it from your font list in all stories.","web-stories"),SECTION_HEADING:(0,l.__)("Custom Fonts","web-stories"),LABEL:(0,l.__)("Insert Font URL","web-stories"),INPUT_CONTEXT:(0,l.__)("Insert a public URL to a font file. Allowed formats are .otf, .ttf, .woff.","web-stories"),INPUT_ERROR:(0,l.__)("Invalid URL format","web-stories"),SUBMIT_BUTTON:(0,l.__)("Add Font","web-stories"),FONTS_HEADING:(0,l.__)("Current Fonts","web-stories"),FONTS_CONTEXT:(0,l.__)("Deleting fonts will delete them from your in-editor font list and all previous stories.","web-stories")},nc=(0,m.default)(ms).withConfig({displayName:"customFonts__AddButton",componentId:"sc-4md0nd-0"})(["min-width:90px;margin-top:32px;"]),lc=m.default.div.withConfig({displayName:"customFonts__InputsWrapper",componentId:"sc-4md0nd-1"})(["margin-top:8px;"]),oc=m.default.div.withConfig({displayName:"customFonts__FontsWrapper",componentId:"sc-4md0nd-2"})(["margin-top:34px;"]),ic=(0,m.default)(Sa.Text.Span).withConfig({displayName:"customFonts__ListHeading",componentId:"sc-4md0nd-3"})(["margin-bottom:10px;display:inline-block;"]),sc=m.default.div.withConfig({displayName:"customFonts__FontsList",componentId:"sc-4md0nd-4"})(["padding:12px 0;border:",";:focus-within{","}"],(e=>{let{theme:t}=e;return`1px solid ${t.colors.divider.primary}`}),(e=>{let{theme:t}=e;return $t.focusCSS(t.colors.border.focus)})),cc=(0,m.default)(Bt.Button).withConfig({displayName:"customFonts__DeleteButton",componentId:"sc-4md0nd-5"})(["visibility:hidden;opacity:0;transition:visibility 0s,opacity ease-in-out 300ms;&:focus{","}"],(e=>{let{theme:t}=e;return $t.focusCSS(t.colors.border.focus)})),dc=m.default.div.withConfig({displayName:"customFonts__FontRow",componentId:"sc-4md0nd-6"})(["padding:0 12px;display:flex;height:32px;width:100%;justify-content:space-between;transition:background-color ease-in-out 300ms;&[aria-selected='true'],&:hover,&:focus{background-color:",";button{visibility:visible;opacity:1;}}"],(e=>{let{theme:t}=e;return t.colors.bg.secondary})),uc=m.default.div.withConfig({displayName:"customFonts__FontData",componentId:"sc-4md0nd-7"})(["line-height:32px;white-space:nowrap;display:flex;font-size:14px;max-width:calc(100% - 32px);align-items:center;"]),pc=(0,m.default)(Sa.Text.Paragraph).attrs({as:"span"}).withConfig({displayName:"customFonts__StyledText",componentId:"sc-4md0nd-8"})([""]),mc=(0,m.default)(pc).withConfig({displayName:"customFonts__FontUrl",componentId:"sc-4md0nd-9"})(["color:",";white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"],(e=>{let{theme:t}=e;return t.colors.fg.tertiary})),fc=m.default.div.withConfig({displayName:"customFonts__Divider",componentId:"sc-4md0nd-10"})(["width:4px;height:4px;background-color:",";border-radius:",";margin:0 6px;align-self:center;"],(e=>{let{theme:t}=e;return t.colors.standard.black}),(e=>{let{theme:t}=e;return t.borders.radius.round})),gc=[".otf",".ttf",".woff"];const hc=function CustomFontsSettings(e){let{customFonts:t=[],addCustomFont:a,deleteCustomFont:r}=e;const o=(0,Zn.default)(),[i,s]=(0,h.useState)(""),[c,d]=(0,h.useState)(""),[u,p]=(0,h.useState)(!1),[m,f]=(0,h.useState)(null),g=!c&&i,b=(0,h.useRef)(null),_=(0,h.useRef)([]),[y,S]=(0,h.useState)(0),[w,v]=(0,h.useState)(),{showSnackbar:T}=(0,il.useSnackbar)(),C=(0,h.useCallback)((e=>{const{value:t}=e.target;s(t),0===t.length||function(e){try{return new URL(e),!0}catch{return!1}}(oi(t))?d(""):d(rc.INPUT_ERROR)}),[]),I=(0,h.useCallback)((async()=>{try{await r(m),o((0,l.__)("Font deleted","web-stories"))}catch(e){(0,E.trackError)("remove_custom_font",e?.message),T({"aria-label":ki.REMOVE_FONT.MESSAGE,message:ki.REMOVE_FONT.MESSAGE,dismissible:!0})}finally{f(null),p(!1),d("")}}),[r,m,T,o]),k=(0,h.useCallback)((async()=>{if(g){const e=oi(i);try{await fetch(e,{method:"HEAD"})}catch(e){return(0,E.trackError)("add_custom_font",e?.message),void d((0,l.__)("Please ensure correct CORS settings for allowing font usage on this site.","web-stories"))}let t;try{if((0,E.trackEvent)("add_custom_font",{url:e}),t=await ac(e),!t.family)return void d((0,l.__)("Something went wrong, please try again.","web-stories"))}catch(e){return(0,E.trackError)("add_custom_font",e?.message),void d((0,X.default)(/* translators: %s: list of allowed font types. */ (0,l.__)("Getting font data failed, please ensure the URL points directly to a %s file.","web-stories"),(0,Qs.default)(gc)))}try{await a({...t,url:e}),s("")}catch(e){(0,E.trackError)("add_custom_font",e?.message),d((0,X.default)(/* translators: %s: font name. */ (0,l.__)("A font with the name %s already exists.","web-stories"),t.family))}}}),[a,g,i]),L=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),k())}),[k]);(0,h.useEffect)((()=>{const e=_.current[`row-${y}`];e&&(e.focus(),v(e.id))}),[y]);const A=e=>y===e,x=(0,h.useCallback)((e=>{const{key:a}=e;"ArrowUp"===a?(e.preventDefault(),S((e=>Math.max(0,e-1)))):"ArrowDown"===a&&(e.preventDefault(),S((e=>Math.min(t.length-1,e+1))))}),[t]);return n.createElement(Yi,{onSubmit:e=>e.preventDefault()},n.createElement("div",null,n.createElement(Zi,{as:"h3"},rc.SECTION_HEADING),n.createElement(as,{size:Ya.TextSize.Small},rc.ADD_CONTEXT),n.createElement(as,{size:Ya.TextSize.Small},rc.REMOVAL)),n.createElement(lc,null,n.createElement(gs,null,n.createElement(bs,{value:i,onChange:C,onKeyDown:L,hasError:Boolean(c),hint:c,label:rc.LABEL}),n.createElement(nc,{type:Mt.ButtonType.Primary,size:Mt.ButtonSize.Small,disabled:!g,onClick:k},rc.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},rc.INPUT_CONTEXT),t?.length>0&&n.createElement(oc,null,n.createElement(ic,null,rc.FONTS_HEADING),n.createElement(sc,{ref:b,role:"listbox",tabIndex:0,onKeyDown:x,"aria-activedescendant":w||t[0]?.id},t.map(((e,t)=>{let{id:a,family:r,url:o}=e;return n.createElement(dc,{id:`font-${a}`,ref:e=>_.current[`row-${t}`]=e,key:r,role:"option",onClick:()=>{S(t)},"aria-selected":A(t)},n.createElement(uc,null,n.createElement(pc,null,r),n.createElement(fc,null),n.createElement(mc,null,o)),n.createElement(Tooltip,{hasTail:!0,title:(0,l.__)("Delete font","web-stories")},n.createElement(cc,{"aria-label":(0,X.default)(/*translators: %s: font family. */ (0,l.__)("Delete %s","web-stories"),r),type:Mt.ButtonType.Tertiary,size:Mt.ButtonSize.Small,variant:Mt.ButtonVariant.Square,onClick:()=>{f(a),p(!0)}},n.createElement(ec.default,null))))}))),n.createElement(rs,{size:Ya.TextSize.Small},rc.FONTS_CONTEXT))),u&&n.createElement(tc,{onClose:()=>p(!1),onPrimary:I}))};var bc=a(40918);const _c=/[\w-]+\.myshopify\.com/i;function yc(){return Boolean((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().match(_c))}const Ec=m.default.div.withConfig({displayName:"shopify__Loading",componentId:"sc-ur0gaq-0"})(["position:relative;margin-top:10px;"]),Sc=m.default.div.withConfig({displayName:"shopify__Spinner",componentId:"sc-ur0gaq-1"})(["position:absolute;top:0;"]),wc={HOST_CONTEXT:(0,X.default)(/* translators: 1: first example. 2: second example. */ (0,l.__)("Without %1$s or %2$s. Example: %3$s. Find your URL.","web-stories"),"https://","www.","yourstore.myshopify.com"),HOST_CONTEXT_LINK:(0,l.__)("https://help.shopify.com/en/manual/domains","web-stories"),HOST_PLACEHOLDER:(0,l.__)("Enter your .myshopify.com domain","web-stories"),HOST_LABEL:(0,l.__)("Shopify Domain","web-stories"),ACCESS_TOKEN_CONTEXT:(0,l.__)("Learn how to get one.","web-stories"),ACCESS_TOKEN_CONTEXT_LINK:(0,l.__)("https://help.shopify.com/en/manual/apps/custom-apps#get-the-api-credentials-for-a-custom-app","web-stories"),ACCESS_TOKEN_PLACEHOLDER:(0,l.__)("Enter your API access token","web-stories"),ACCESS_TOKEN_LABEL:(0,l.__)("Storefront API Access Token","web-stories"),INPUT_ERROR:(0,l.__)("Invalid format","web-stories"),SUBMIT_BUTTON:(0,l.__)("Save","web-stories"),CONNECTION_TEST_BUTTON:(0,l.__)("Test connection","web-stories"),CONNECTION_CHECKING:(0,l.__)("Testing connection…","web-stories"),CONNECTION_SUCCESS:(0,l.__)("Connection successful","web-stories"),CONNECTION_ERROR_DEFAULT:(0,l.__)("Connection failed. Please try again.","web-stories")};const vc=function ShopifySettings(e){let{host:t,accessToken:a,handleUpdateHost:r,handleUpdateAccessToken:o}=e;const i=(0,Zn.default)(),[s,c]=(0,h.useState)(t),[d,u]=(0,h.useState)(""),p=s!==t&&!d,m=!p,[f,g]=(0,h.useState)(a),[b,_]=(0,h.useState)(""),S=f!==a&&!b,w=!S,{apiCallbacks:{getProducts:v}}=y(),[T,C]=(0,h.useState)(!1),[I,k]=(0,h.useState)(""),[L,A]=(0,h.useState)(!1);(0,h.useEffect)((()=>{c(t)}),[t]),(0,h.useEffect)((()=>{g(a)}),[a]);const x=(0,h.useCallback)((e=>{const{value:t}=e.target;c(t),0===t.length||yc(t)?u(""):u(wc.INPUT_ERROR)}),[]),O=(0,h.useCallback)((e=>{const{value:t}=e.target;yc(t)&&c(t.match(_c)[0])}),[]),D=(0,h.useCallback)((()=>{p&&r(s)}),[p,s,r]),N=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),D())}),[D]),P=(0,h.useCallback)((e=>{const{value:t}=e.target;_(""),g(t)}),[]),R=(0,h.useCallback)((()=>{S&&o(f)}),[S,f,o]),B=(0,h.useCallback)((e=>{"Enter"===e.key&&(e.preventDefault(),R())}),[R]),M=(0,h.useCallback)((async()=>{A(!1),C(!0),i(wc.CONNECTION_CHECKING),(0,E.trackEvent)("test_shopping_connection");try{await v((new Date).getTime()),k(wc.CONNECTION_SUCCESS),i(wc.CONNECTION_SUCCESS)}catch(e){(0,E.trackError)("test_shopping_connection",e?.message),A(!0),k(wc.CONNECTION_ERROR_DEFAULT),i(wc.CONNECTION_ERROR_DEFAULT)}finally{C(!1)}}),[v,i]),U=s&&!d&&f&&!b&&!T,F=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_shopify_docs")),[]);return n.createElement(n.Fragment,null,n.createElement(gs,null,n.createElement(hs,{htmlFor:"shopifyHost"},wc.HOST_LABEL),n.createElement(bs,{"aria-label":wc.HOST_LABEL,id:"shopifyHost",name:"shopifyHost","data-testid":"shopifyHost",value:s,onChange:x,onKeyDown:N,onBlur:O,placeholder:wc.HOST_PLACEHOLDER,hasError:Boolean(d),hint:d}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:m,onClick:D,"data-testid":"shopifyHostButton"},wc.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:wc.HOST_CONTEXT_LINK,rel:"noreferrer",target:"_blank",onClick:F,size:Ya.TextSize.Small})}},wc.HOST_CONTEXT)),n.createElement(gs,null,n.createElement(hs,{htmlFor:"shopifyAccessToken"},wc.ACCESS_TOKEN_LABEL),n.createElement(bs,{id:"shopifyAccessToken","aria-label":wc.ACCESS_TOKEN_LABEL,name:"shopifyAccessToken","data-testid":"shopifyAccessToken",value:f,onChange:P,onKeyDown:B,placeholder:wc.ACCESS_TOKEN_PLACEHOLDER,hasError:Boolean(b),hint:b}),n.createElement(ms,{type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:w,onClick:R,"data-testid":"shopifyAccessTokenButton"},wc.SUBMIT_BUTTON)),n.createElement(rs,{size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:wc.ACCESS_TOKEN_CONTEXT_LINK,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small})}},wc.ACCESS_TOKEN_CONTEXT)),n.createElement(fs,{onFocus:()=>k(""),type:Mt.ButtonType.Secondary,size:Mt.ButtonSize.Small,disabled:!U,onClick:M},T?wc.CONNECTION_CHECKING:wc.CONNECTION_TEST_BUTTON),T&&n.createElement(Ec,null,n.createElement(Sc,null,n.createElement(bc.default,{size:24}))),I&&n.createElement(es,{"data-testid":"api-status","aria-label":(0,l.__)("API connection status","web-stories"),hasError:L,size:Ya.TextSize.Small},I))},Tc={SLOT_ID_LABEL:(0,l.__)("Shopping provider","web-stories")};const Cc=function ShoppingProviderDropDown(e){let{vendors:t,shoppingProvider:a,handleUpdate:r}=e;const l=[];return Object.entries(t).forEach((e=>{let[t,a]=e;return l.push({label:a,value:t})})),n.createElement(vn.default,{ariaLabel:Tc.SLOT_ID_LABEL,options:l,selectedValue:a,onMenuItemClick:(e,t)=>r(t),fillWidth:!0})},Ic={SECTION_HEADING:(0,l.__)("Shopping","web-stories"),SHOPPING_PROVIDER_HELPER_MESSAGE:(0,l.__)("Once configured you can add products from this provider.","web-stories"),HELPER_MESSAGE:(0,l.__)("Connect your store so you can easily add products to your stories.","web-stories"),WOOCOMMERCE_INSTALL:(0,l.__)("Install WooCommerce to easily add shoppable products to Web Stories.","web-stories"),WOOCOMMERCE_ACTIVE:(0,l.__)("Activate WooCommerce to easily add shoppable products to Web Stories.","web-stories"),WOOCOMMERCE_MANAGE:(0,l.__)("Manage products in WooCommerce to make them available in Web Stories.","web-stories")};const kc=function Shopping(e){let{updateSettings:t,shoppingProvider:a,shopifyHost:r,shopifyAccessToken:l,vendors:o,woocommerce:i}=e;const s=(0,h.useCallback)((e=>{t({shoppingProvider:e}),(0,E.trackEvent)("change_shopping_provider",{name:e})}),[t]),c=(0,h.useCallback)((e=>t({shopifyHost:e})),[t]),d=(0,h.useCallback)((e=>t({shopifyAccessToken:e})),[t]),u=(0,h.useCallback)((e=>(0,E.trackClick)(e,"click_woocommerce_link")),[]),{canManage:p,installed:m,active:f,link:g}=i;let b;return!1===m?b=Ic.WOOCOMMERCE_INSTALL:!1===f?b=Ic.WOOCOMMERCE_ACTIVE:!0===p&&(b=Ic.WOOCOMMERCE_MANAGE),n.createElement(_s,{onSubmit:e=>e.preventDefault()},n.createElement("div",null,n.createElement(Zi,null,Ic.SECTION_HEADING),n.createElement(rs,{size:Ya.TextSize.Small},Ic.HELPER_MESSAGE),a===Bi&&b&&g&&n.createElement(rs,{"data-testid":"woocommerceMessage",size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(Ji,{href:g,rel:"noreferrer",target:"_blank",size:Ya.TextSize.Small,onClick:u})}},b))),n.createElement("div",null,n.createElement(Cc,{vendors:o,shoppingProvider:a,handleUpdate:s}),n.createElement(rs,{size:Ya.TextSize.Small},Ic.SHOPPING_PROVIDER_HELPER_MESSAGE),a===Mi&&n.createElement(vc,{handleUpdateHost:c,handleUpdateAccessToken:d,host:r,accessToken:l})))};var Lc=a(33773),Ac=a(31119);const xc={MIN:1,MAX:20},Oc={CONTEXT:(0,l.__)("All new stories will be set to this page advancement setting. Control whether a story auto-advances between pages, or whether the reader has to manually tap to advance.","web-stories"),SECTION_HEADING:(0,l.__)("Default Page Advancement","web-stories"),LABEL_AUTO:(0,l.__)("Auto","web-stories"),LABEL_MANUAL:(0,l.__)("Manual","web-stories"),SWITCH_LABEL:(0,l.__)("Page Advancement","web-stories"),INPUT_LABEL:(0,l.__)("Default page duration in seconds","web-stories"),INPUT_SUFFIX:(0,l.__)("Duration","web-stories"),INPUT_HELPER:(0,X.default)(/* translators: 1: minimum duration. 2: maximum duration. */ (0,l._n)("Duration between %1$d and %2$d second.","Duration between %1$d and %2$d seconds.",xc.MAX,"web-stories"),xc.MIN,xc.MAX)},Dc=m.default.div.withConfig({displayName:"pageAdvancement__InputsWrapper",componentId:"sc-9snl1y-0"})(["margin-top:8px;"]),Nc=(0,m.default)(Lc.default).withConfig({displayName:"pageAdvancement__StyledSwitch",componentId:"sc-9snl1y-1"})(["width:186px;"]);const Pc=function PageAdvancementSettings(e){let{updateSettings:t,autoAdvance:a,defaultPageDuration:r}=e;const[o,i]=(0,h.useState)(a),s=(0,h.useCallback)((()=>{(0,E.trackEvent)("change_auto_advance",{value:!a}),i(!a),t({autoAdvance:!a})}),[a,t]);(0,h.useEffect)((()=>{i(a)}),[a]);const c=(0,h.useCallback)(((e,a)=>{t({defaultPageDuration:a}),(0,E.trackEvent)("change_default_page_duration",{value:a})}),[t]);return n.createElement(_s,{onSubmit:e=>e.preventDefault()},n.createElement("div",null,n.createElement(Zi,{as:"h3"},Oc.SECTION_HEADING),n.createElement(as,{size:Ya.TextSize.Small},Oc.CONTEXT)),n.createElement(Dc,null,n.createElement(gs,null,n.createElement(Nc,{groupLabel:Oc.SWITCH_LABEL,name:"page-advancement-switch",value:o,onLabel:Oc.LABEL_AUTO,offLabel:Oc.LABEL_MANUAL,onChange:s,darkTheme:!1})),o&&n.createElement(n.Fragment,null,n.createElement(gs,null,n.createElement(Ac.default,{unit:` ${(0,l.__)("seconds","web-stories")}`,suffix:Oc.INPUT_SUFFIX,value:r,onChange:c,"aria-label":Oc.INPUT_SUFFIX,min:xc.MIN,max:xc.MAX})),n.createElement(rs,{size:Ya.TextSize.Small},Oc.INPUT_HELPER))))},Rc=m.default.div.withConfig({displayName:"editorSettings__BodyViewOptionsHeader",componentId:"sc-1yxjpva-0"})([""]);const Bc=function EditorSettings(){const{fetchSettings:e,updateSettings:t,googleAnalyticsId:a,usingLegacyAnalytics:r,adSensePublisherId:o,adSenseSlotId:i,adManagerSlotId:s,mgidWidgetId:c,adNetwork:d,uploadMedia:u,newlyCreatedMediaIds:p,isMediaLoading:m,videoCache:f,dataRemoval:g,archive:b,archivePageId:_,searchPages:S,getPageById:w,customFonts:v,addCustomFont:T,deleteCustomFont:C,fetchCustomFonts:I,publisherLogos:k,addPublisherLogo:L,fetchPublisherLogos:A,removePublisherLogo:x,setPublisherLogoAsDefault:O,shoppingProvider:D,shopifyHost:N,shopifyAccessToken:P,autoAdvance:R,defaultPageDuration:B}=Gi((e=>{let{actions:{fontsApi:{addCustomFont:t,deleteCustomFont:a,fetchCustomFonts:r},settingsApi:{fetchSettings:n,updateSettings:l},pagesApi:{searchPages:o,getPageById:i},mediaApi:{uploadMedia:s},publisherLogosApi:{fetchPublisherLogos:c,addPublisherLogo:d,removePublisherLogo:u,setPublisherLogoAsDefault:p}},state:{settings:{googleAnalyticsId:m,usingLegacyAnalytics:f,adSensePublisherId:g,adSenseSlotId:h,adManagerSlotId:b,mgidWidgetId:_,adNetwork:y,videoCache:E,dataRemoval:S,archive:w,archivePageId:v,shoppingProvider:T,shopifyHost:C,shopifyAccessToken:I,autoAdvance:k,defaultPageDuration:L},media:{isLoading:A,newlyCreatedMediaIds:x},publisherLogos:{publisherLogos:O},customFonts:D}}=e;return{fetchSettings:n,updateSettings:l,googleAnalyticsId:m,usingLegacyAnalytics:f,adSensePublisherId:g,adSenseSlotId:h,adManagerSlotId:b,mgidWidgetId:_,adNetwork:y,uploadMedia:s,isMediaLoading:A,newlyCreatedMediaIds:x,videoCache:E,dataRemoval:S,archive:w,archivePageId:v,searchPages:o,getPageById:i,customFonts:D,addCustomFont:t,deleteCustomFont:a,fetchCustomFonts:r,fetchPublisherLogos:c,addPublisherLogo:d,removePublisherLogo:u,setPublisherLogoAsDefault:p,publisherLogos:O,shoppingProvider:T,shopifyHost:C,shopifyAccessToken:I,autoAdvance:k,defaultPageDuration:L}})),{capabilities:{canUploadFiles:M,canManageSettings:U}={},plugins:{siteKit:F={},woocommerce:z={}},maxUpload:G,maxUploadFormatted:H,allowedImageMimeTypes:j,archiveURL:V,defaultArchiveURL:$,vendors:W}=y(),{disabled:K,toggleWebStoriesTrackingOptIn:q,optedIn:Y}=$i(),{disabled:Z,toggleWebStoriesMediaOptimization:J,mediaOptimization:Q}=function(){const{showSnackbar:e}=(0,il.useSnackbar)(),{currentUser:t,toggleWebStoriesMediaOptimization:a}=Gi((e=>{let{state:{currentUser:t},actions:{usersApi:{toggleWebStoriesMediaOptimization:a}}}=e;return{currentUser:t,toggleWebStoriesMediaOptimization:a}})),r=Boolean(t.data.meta?.webStoriesMediaOptimization),n=(0,h.useCallback)((()=>{a(),(0,E.trackEvent)("video_optimization_optin",{status:r?"off":"on"}),e({"aria-label":Ii.SETTINGS.UPDATED,message:Ii.SETTINGS.UPDATED,dismissible:!0})}),[r,e,a]);return{mediaOptimization:r,disabled:t.isUpdating,toggleWebStoriesMediaOptimization:n}}(),[ee,te]=(0,h.useState)("");(0,h.useEffect)((()=>{U&&(e(),A(),I())}),[e,A,U,I]),(0,h.useEffect)((()=>{p.length>0&&L(p)}),[p,L]),Ki();const ae=(0,h.useCallback)((e=>t({googleAnalyticsId:e})),[t]),re=(0,h.useCallback)((()=>t({usingLegacyAnalytics:!1})),[t]),ne=(0,h.useCallback)((async e=>{let t=!0,a=!0,r=!1;const n=[];if(e.forEach((e=>{t=t&&e.size<=G;const r=j.includes(e.type);a=a&&r,r||n.push((0,Wi.default)({src:URL.createObjectURL(e)}))})),!t){const t=1===e.length?(0,X.default)(/* translators: %s: max upload size for media */ (0,l.__)("Sorry, this file is too big. Make sure your logo is under %s.","web-stories"),H):(0,X.default)(/* translators: %s: max upload size for media */ (0,l.__)("Sorry, one or more of these files are too big. Make sure your logos are all under %s.","web-stories"),H);return te(t)}if(!a){const t=1===e.length?(0,l.__)("Sorry, this file type is not supported. Only jpg, png, and static gifs are supported for publisher logos.","web-stories"):(0,l.__)("Sorry, one or more of these files are of an unsupported file type. Only jpg, png, and static gifs are supported for publisher logos.","web-stories");return te(t)}const o=await Promise.all(n).catch((()=>{r=!0}));if(r){const t=1===e.length?(0,l.__)("Sorry, there was an error processing your upload. Please try again.","web-stories"):(0,l.__)("Sorry, there was an error processing one or more of your uploads. Please try again.","web-stories");return te(t)}if(!o.every((e=>{let{height:t,width:a}=e;return t>=96&&a>=96}))){const t=1===e.length?(0,X.default)(/* translators: 1 = minimum width, 2 = minimum height */ (0,l.__)("Sorry, this file is too small. Make sure your logo is larger than %s.","web-stories"),(0,X.default)("%1$dx%2$dpx",96,96)):(0,X.default)(/* translators: %s: image dimensions in pixels. */ (0,l.__)("Sorry, one or more files are too small. Make sure your logos are all larger than %s.","web-stories"),(0,X.default)("%1$dx%2$dpx",96,96));return te(t)}return te(""),u(e)}),[G,H,u,j]),le=(0,h.useCallback)((e=>{x(e.id)}),[x]),oe=(0,h.useCallback)((e=>O(e.id)),[O]);return n.createElement(Ua.Provider,null,n.createElement(qi,{"data-testid":"editor-settings"},n.createElement(ll,{heading:(0,l.__)("Settings","web-stories")}),n.createElement(ha,null,n.createElement(Rc,{id:"body-view-options-header"})),n.createElement(Ua.Scrollable,null,n.createElement(Xi,null,U&&n.createElement(n.Fragment,null,n.createElement(Js,{googleAnalyticsId:a,handleUpdateAnalyticsId:ae,usingLegacyAnalytics:r,handleMigrateLegacyAnalytics:re,siteKitStatus:F}),n.createElement(Us,{onAddLogos:ne,onRemoveLogo:le,onUpdateDefaultLogo:oe,publisherLogos:k,canUploadFiles:M,isLoading:m,uploadError:ee})),n.createElement(hc,{customFonts:v,addCustomFont:T,deleteCustomFont:C}),n.createElement(TelemetrySettings,{disabled:K,onCheckboxSelected:q,selected:Y}),M&&n.createElement(MediaOptimizationSettings,{disabled:Z,onCheckboxSelected:J,selected:Q}),U&&n.createElement(n.Fragment,null,n.createElement(VideoCacheSettings,{isEnabled:f,updateSettings:t}),n.createElement(DataRemovalSettings,{isEnabled:g,updateSettings:t}),n.createElement(ArchiveSettings,{archive:b,archiveURL:V,defaultArchiveURL:$,updateSettings:t,searchPages:S,archivePageId:_,getPageById:w}),n.createElement(Ns,{updateSettings:t,adNetwork:d,publisherId:o,adSenseSlotId:i,adManagerSlotId:s,mgidWidgetId:c,siteKitStatus:F}),n.createElement(kc,{updateSettings:t,shoppingProvider:D,shopifyHost:N,shopifyAccessToken:P,vendors:W,woocommerce:z}),n.createElement(Pc,{updateSettings:t,autoAdvance:R,defaultPageDuration:B}))))))};function Mc(){const[e,t]=(0,h.useState)({}),[a,r]=(0,h.useState)(!1),{api:{currentUser:n}}=y();(0,h.useEffect)((()=>{var a;Object.keys(e).length||(a=n,si({path:a}).then(ni.snakeToCamelCaseObjectKeys)).then(t)}),[n,e]);return{api:{toggleWebStoriesTrackingOptIn:(0,h.useCallback)((async()=>{r(!0);try{t(await function(e,t){return si({path:e,data:{meta:{web_stories_tracking_optin:!t.meta.webStoriesTrackingOptin}},method:"POST"}).then(ni.snakeToCamelCaseObjectKeys)}(n,e))}finally{r(!1)}}),[n,e]),toggleWebStoriesMediaOptimization:(0,h.useCallback)((async()=>{r(!0);try{t(await function(e,t){return si({path:e,data:{meta:{web_stories_media_optimization:!t.meta.webStoriesMediaOptimization}},method:"POST"}).then(ni.snakeToCamelCaseObjectKeys)}(n,e))}finally{r(!1)}}),[n,e])},currentUser:{data:e,isUpdating:a}}}const Uc={LOADING_MEDIA:"loading_media",ADD_MEDIA_SUCCESS:"add_media_success",ADD_MEDIA_FAILURE:"add_media_failure"},Fc={error:{},isLoading:!1,newlyCreatedMediaIds:[]};const zc=function(e,t){switch(t.type){case Uc.LOADING_MEDIA:return{...e,isLoading:!0,newlyCreatedMediaIds:[]};case Uc.ADD_MEDIA_FAILURE:return{...e,error:{...t.payload,id:Date.now()},isLoading:!1};case Uc.ADD_MEDIA_SUCCESS:return{...e,error:{},isLoading:!1,newlyCreatedMediaIds:t.payload.newlyCreatedMediaIds||e.newlyCreatedMediaIds};default:return e}};function Gc(){const[e,t]=(0,h.useReducer)(zc,Fc),{api:{media:a}}=y();return{media:e,api:{uploadMedia:(0,h.useCallback)((async e=>{t({type:Uc.LOADING_MEDIA});try{const r=await function(e,t){return Promise.all(Object.values(t).map((t=>{const a=new window.FormData;return a.append("file",t,t.name||t.type.replace("/",".")),si({path:e,body:a,method:"POST"}).then(ni.snakeToCamelCaseObjectKeys)})))}(a,e);t({type:Uc.ADD_MEDIA_SUCCESS,payload:{media:r,newlyCreatedMediaIds:r.map((e=>{let{id:t}=e;return t}))}})}catch(a){t({type:Uc.ADD_MEDIA_FAILURE,payload:{message:ki.UPLOAD_PUBLISHER_LOGO[e.length>1?"MESSAGE_PLURAL":"MESSAGE"]}})}}),[a])}}}const Hc={UPDATE_SETTINGS_SUCCESS:"update_settings_success",UPDATE_SETTINGS_FAILURE:"update_settings_failure",SETTING_SAVED:"setting_saved",FETCH_SETTINGS_SUCCESS:"fetch_settings_success",FETCH_SETTINGS_FAILURE:"fetch_settings_failure"},jc={error:{},googleAnalyticsId:"",usingLegacyAnalytics:!1,adSensePublisherId:"",adSenseSlotId:"",adManagerSlotId:"",mgidWidgetId:"",adNetwork:xi,archive:Pi.DEFAULT,archivePageId:0,videoCache:!1,dataRemoval:!1,settingSaved:!1,shoppingProvider:Ri,shopifyHost:"",shopifyAccessToken:"",autoAdvance:!0,defaultPageDuration:7};const Vc=function(e,t){switch(t.type){case Hc.SETTING_SAVED:return{...e,settingSaved:t.payload};case Hc.UPDATE_SETTINGS_FAILURE:case Hc.FETCH_SETTINGS_FAILURE:return{...e,error:{...t.payload,id:Date.now()}};case Hc.FETCH_SETTINGS_SUCCESS:case Hc.UPDATE_SETTINGS_SUCCESS:return{...e,error:{},googleAnalyticsId:t.payload.googleAnalyticsId,usingLegacyAnalytics:t.payload.usingLegacyAnalytics,adSensePublisherId:t.payload.adSensePublisherId,adSenseSlotId:t.payload.adSenseSlotId,adManagerSlotId:t.payload.adManagerSlotId,mgidWidgetId:t.payload.mgidWidgetId,adNetwork:t.payload.adNetwork,videoCache:t.payload.videoCache,dataRemoval:t.payload.dataRemoval,archive:t.payload.archive,archivePageId:t.payload.archivePageId,shoppingProvider:t.payload.shoppingProvider,shopifyHost:t.payload.shopifyHost,shopifyAccessToken:t.payload.shopifyAccessToken,autoAdvance:t.payload.autoAdvance,defaultPageDuration:t.payload.defaultPageDuration};default:return e}},$c=e=>({googleAnalyticsId:e.web_stories_ga_tracking_id,usingLegacyAnalytics:e.web_stories_using_legacy_analytics,adSensePublisherId:e.web_stories_adsense_publisher_id,adSenseSlotId:e.web_stories_adsense_slot_id,adManagerSlotId:e.web_stories_ad_manager_slot_id,mgidWidgetId:e.web_stories_mgid_widget_id,adNetwork:e.web_stories_ad_network,videoCache:e.web_stories_video_cache,dataRemoval:e.web_stories_data_removal,archive:e.web_stories_archive,archivePageId:e.web_stories_archive_page_id,shoppingProvider:e.web_stories_shopping_provider,shopifyHost:e.web_stories_shopify_host,shopifyAccessToken:e.web_stories_shopify_access_token,autoAdvance:Boolean(e.web_stories_auto_advance),defaultPageDuration:e.web_stories_default_page_duration});function Wc(){const[e,t]=(0,h.useReducer)(Vc,jc),{api:{settings:a}}=y();return{settings:e,api:{fetchSettings:(0,h.useCallback)((async()=>{try{const r=await(e=a,si({path:e}).then($c));t({type:Hc.FETCH_SETTINGS_SUCCESS,payload:r})}catch(e){t({type:Hc.FETCH_SETTINGS_FAILURE,payload:{message:ki.LOAD_SETTINGS.MESSAGE}})}var e}),[a]),updateSettings:(0,h.useCallback)((async e=>{t({type:Hc.SETTING_SAVED});try{const r=await function(e,t){const{googleAnalyticsId:a,usingLegacyAnalytics:r,adSensePublisherId:n,adSenseSlotId:l,adManagerSlotId:o,mgidWidgetId:i,adNetwork:s,videoCache:c,dataRemoval:d,archive:u,archivePageId:p,shoppingProvider:m,shopifyHost:f,shopifyAccessToken:g,autoAdvance:h,defaultPageDuration:b}=t,_={};void 0!==a&&(_.web_stories_ga_tracking_id=a),void 0!==r&&(_.web_stories_using_legacy_analytics=r),void 0!==n&&(_.web_stories_adsense_publisher_id=n),void 0!==l&&(_.web_stories_adsense_slot_id=l),void 0!==o&&(_.web_stories_ad_manager_slot_id=o),void 0!==i&&(_.web_stories_mgid_widget_id=i),void 0!==s&&(_.web_stories_ad_network=s),void 0!==c&&(_.web_stories_video_cache=Boolean(c)),void 0!==d&&(_.web_stories_data_removal=Boolean(d)),void 0!==u&&(_.web_stories_archive=u),void 0!==p&&(_.web_stories_archive_page_id=p),void 0!==m&&(_.web_stories_shopping_provider=m),void 0!==f&&(_.web_stories_shopify_host=f),void 0!==g&&(_.web_stories_shopify_access_token=g),void 0!==h&&(_.web_stories_auto_advance=Boolean(h)),void 0!==b&&(_.web_stories_default_page_duration=b);const y=(0,ii.default)(e,_);return si({path:y,method:"POST"}).then($c)}(a,e);t({type:Hc.UPDATE_SETTINGS_SUCCESS,payload:r}),t({type:Hc.SETTING_SAVED,payload:!0})}catch(e){t({type:Hc.UPDATE_SETTINGS_FAILURE,payload:{message:ki.UPDATE_EDITOR_SETTINGS.MESSAGE}})}}),[a])}}}const Kc=document.createElement("div");function qc(e){return Kc.innerHTML=e,Kc.textContent||""}document.createElement("div");function Xc(){const{api:{pages:e}}=y(),t=(0,h.useCallback)((async t=>{try{const{title:a,link:r}=await function(e,t){const a=(0,ii.default)(`${e}${t}/`,{_fields:ui});return si({path:a})}(e,t);return{title:qc(a.rendered),link:r}}catch(e){return null}}),[e]);return{api:{searchPages:(0,h.useCallback)((async t=>{try{const a=await function(e,t){const a=(0,ii.default)(e,{per_page:100,search:t,_fields:di});return si({path:a})}(e,t);return a.map((e=>{let{id:t,title:a}=e;return{value:t,label:qc(a.rendered)}}))}catch(e){return[]}}),[e]),getPageById:t}}}const Yc={LOADING:"loading",UPDATE_FAILURE:"update_failure",UPDATE_SUCCESS:"update_success",FETCH_FAILURE:"fetch_failure",FETCH_SUCCESS:"fetch_success",REMOVE_FAILURE:"remove_failure",REMOVE_SUCCESS:"remove_success",ADD_FAILURE:"add_failure",ADD_SUCCESS:"add_success"},Zc={error:{},isLoading:!1,publisherLogos:[],settingSaved:!1};const Jc=function(e,t){switch(t.type){case Yc.LOADING:return{...e,isLoading:!0,settingSaved:!1};case Yc.ADD_FAILURE:case Yc.UPDATE_FAILURE:case Yc.REMOVE_FAILURE:case Yc.FETCH_FAILURE:return{...e,error:{...t.payload,id:Date.now()},isLoading:!1,settingSaved:!1};case Yc.FETCH_SUCCESS:return{...e,error:{},isLoading:!1,publisherLogos:[...t.payload.publisherLogos]};case Yc.ADD_SUCCESS:{const a=[...e.publisherLogos,t.payload.publisherLogo];return{...e,error:{},isLoading:!1,settingSaved:!0,publisherLogos:a}}case Yc.UPDATE_SUCCESS:{const a=[...e.publisherLogos].map((e=>(e.active=e.id===t.payload.publisherLogo.id,e)));return{...e,error:{},isLoading:!1,settingSaved:!0,publisherLogos:a}}case Yc.REMOVE_SUCCESS:{const a=e.publisherLogos.some((e=>{let{id:a,active:r}=e;return a===t.payload.id&&r})),r=[...e.publisherLogos].filter((e=>{let{id:a}=e;return a!==t.payload.id})).map(((e,t)=>(e.active=a?0===t:e.active,e)));return{...e,error:{},isLoading:!1,settingSaved:!0,publisherLogos:r}}default:return e}};function Qc(){const[e,t]=(0,h.useReducer)(Jc,Zc),{api:{publisherLogos:a}}=y(),r=(0,h.useCallback)((async()=>{t({type:Yc.LOADING});try{const r=await(e=a,si({path:e}));Array.isArray(r)?t({type:Yc.FETCH_SUCCESS,payload:{publisherLogos:r}}):t({type:Yc.FETCH_FAILURE,payload:{message:ki.LOAD_PUBLISHER_LOGOS.MESSAGE}})}catch(e){t({type:Yc.FETCH_FAILURE,payload:{message:ki.LOAD_PUBLISHER_LOGOS.MESSAGE}})}var e}),[a]),n=(0,h.useCallback)((async e=>{t({type:Yc.LOADING});try{await function(e,t){const a=(0,ii.default)(`${e}${t}/`,{_method:"DELETE"});return si({path:a,method:"POST"})}(a,e),t({type:Yc.REMOVE_SUCCESS,payload:{id:e}})}catch(e){t({type:Yc.FETCH_FAILURE,payload:{message:ki.REMOVE_PUBLISHER_LOGO.MESSAGE}})}}),[a]),l=(0,h.useCallback)((async e=>{t({type:Yc.LOADING});try{const l=await(r=a,n=e,si({path:r,data:{id:n},method:"POST"})),o=Array.isArray(l)?l:[l];for(const e of o)t({type:Yc.ADD_SUCCESS,payload:{publisherLogo:e}})}catch(e){t({type:Yc.ADD_FAILURE,payload:{message:ki.UPLOAD_PUBLISHER_LOGO.MESSAGE}})}var r,n}),[a]);return{publisherLogos:e,api:{fetchPublisherLogos:r,addPublisherLogo:l,removePublisherLogo:n,setPublisherLogoAsDefault:(0,h.useCallback)((async e=>{t({type:Yc.LOADING});try{const l=await(r=a,n=e,si({path:`${r}${n}/`,data:{active:!0},method:"POST"}));t({type:Yc.UPDATE_SUCCESS,payload:{publisherLogo:l}})}catch(e){t({type:Yc.FETCH_FAILURE,payload:{message:ki.UPDATE_PUBLISHER_LOGO.MESSAGE}})}var r,n}),[a])}}}function ed(){const{api:{fonts:e}}=y(),[t,a]=(0,h.useState)(null),r=(0,h.useCallback)((async()=>{try{const t=(await function(e){const t=(0,ii.default)(e,{per_page:100,service:"custom"});return si({path:t})}(e)).map((e=>{let{id:t,family:a,url:r}=e;return{id:t,family:a,url:r}}));return a(t),t}catch{return null}}),[e]),n=(0,h.useCallback)((async r=>{const n=await function(e,t){const a=(0,ii.default)(`${e}${t}/`,{_method:"DELETE"});return si({path:a,method:"POST"})}(e,r),l=t.filter((e=>e.id!==r));return a(l),n}),[t,e]),l=(0,h.useCallback)((async r=>{const n=await function(e,t){return si({path:e,data:t,method:"POST"})}(e,r),{id:l,family:o,url:i}=n,s={id:l,family:o,url:i};return a([s,...t]),s}),[t,e]);return{customFonts:t,api:{addCustomFont:l,deleteCustomFont:n,fetchCustomFonts:r}}}const td=function EditorSettingsProvider(e){let{children:t}=e;const{customFonts:a,api:r}=ed(),{currentUser:l,api:o}=Mc(),{media:i,api:s}=Gc(),{settings:c,api:d}=Wc(),{api:u}=Xc(),{publisherLogos:p,api:m}=Qc(),f={state:{media:i,settings:c,currentUser:l,customFonts:a,publisherLogos:p},actions:{fontsApi:r,mediaApi:s,settingsApi:d,usersApi:o,pagesApi:u,publisherLogosApi:m}};return n.createElement(zi.Provider,{value:f},t)};var ad=a(18969);function rd(){return rd=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{theme:t}=e;return t.colors.gray[5]}),(e=>{let{theme:t}=e;return t.borders.radius.medium}),nd,ld),cd=(0,h.forwardRef)(((e,t)=>{let{children:a,closeButtonLabel:r,title:l,onClose:o,...i}=e;return n.createElement(sd,rd({ref:t},i),n.createElement(nd,{as:"h2",size:Ya.TextSize.XSmall},l),o?n.createElement(od,{type:Mt.ButtonType.Tertiary,variant:Mt.ButtonVariant.Square,size:Mt.ButtonSize.Small,"aria-label":r,onClick:o},n.createElement(ad.default,{"aria-hidden":!0})):n.createElement(id,null),n.createElement(ld,null,a))}));function dd(){return dd=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let{theme:t}=e;return t.colors.fg.secondary})),md=(0,m.default)(Sa.Text.Span).withConfig({displayName:"telemetryBanner__VisitSettingsText",componentId:"sc-inh4j2-2"})(["color:",";"],(e=>{let{theme:t}=e;return t.colors.fg.tertiary})),fd=(0,m.default)(ea.Link).withConfig({displayName:"telemetryBanner__NavLink",componentId:"sc-inh4j2-3"})(["display:inline-block;margin:0;"]),gd=(0,h.forwardRef)(((e,t)=>{let{visible:a=!0,disabled:r=!1,onChange:o=(()=>{}),onClose:i=(()=>{}),checked:s=!1}=e;const c=(0,h.useRef)(),d=(0,h.useRef)(!1),u=s?(0,l.__)("Your selection has been updated. Thank you for helping to improve the editor!","web-stories"):(0,l.__)("Help improve the editor!","web-stories");return(0,h.useEffect)((()=>{d.current&&c.current.focus()})),a?n.createElement(cd,{closeButtonLabel:(0,l.__)("Dismiss telemetry banner","web-stories"),onClose:i,title:u,ref:t},n.createElement(ud,null,n.createElement(zs.default,{id:"telemetry-banner-opt-in",checked:s,disabled:r,onChange:()=>{o(),d.current=!0},onBlur:()=>{d.current=!1},ref:c}),n.createElement(pd,{"aria-checked":s,size:Ya.TextSize.Small},n.createElement(dn.default,{mapping:{a:n.createElement(fd,{size:Ya.TextSize.Small,href:(0,l.__)("https://policies.google.com/privacy","web-stories"),rel:"noreferrer",target:"_blank","aria-label":(0,l.__)("Learn more by visiting Google Privacy Policy","web-stories")})}},(0,l.__)("Check the box to help us improve the Web Stories plugin by allowing tracking of product usage stats. All data are treated in accordance with Google Privacy Policy.","web-stories")))),n.createElement(md,{size:Ya.TextSize.XSmall},n.createElement(dn.default,{mapping:{a:n.createElement(fd,{size:Ya.TextSize.XSmall,href:tr(Li),"aria-label":(0,l.__)("Settings","web-stories")})}},(0,l.__)("You can update your selection later by visiting Settings.","web-stories")))):null}));function TelemetryBannerContainer(e){const{bannerVisible:t,closeBanner:a,optedIn:r,disabled:l,toggleWebStoriesTrackingOptIn:o}=$i(),i=(0,h.useRef)(),s=(0,h.useRef)(t);return(0,h.useLayoutEffect)((()=>{t&&!1===s.current&&i.current?s.current=!0:!t&&s.current&&(s.current=!1)}),[t]),n.createElement(gd,dd({ref:i,visible:t,checked:r,disabled:l,onChange:o,onClose:a},e))}function TelemetryBanner(){const{currentPath:e,hasAvailableRoutes:t}=er((e=>{let{state:t}=e;return{currentPath:t.currentPath,hasAvailableRoutes:t.availableRoutes.length>0}})),a=(0,h.useRef)(null),[,r]=(0,h.useState)(!1);return(0,h.useEffect)((()=>{t&&[Ye.DASHBOARD,Ye.TEMPLATES_GALLERY].includes(e)&&(a.current=document.getElementById("body-view-options-header"),r((e=>!e)))}),[e,t]),a.current?(0,h.createPortal)(n.createElement(TelemetryBannerContainer,null),a.current):null}gd.displayName="TelemetryOptInBanner";const hd=(0,m.default)(cd).withConfig({displayName:"updateBanner__StyledBanner",componentId:"sc-1lpd8jt-0"})(["background:",";"],(e=>{let{theme:t}=e;return t.colors.interactiveBg.brandNormal})),bd=(0,m.default)(ea.Link).withConfig({displayName:"updateBanner__StyledLink",componentId:"sc-1lpd8jt-1"})(["color:",";text-decoration:underline;&:hover{color:",";}&:focus{color:",";}"],(e=>{let{theme:t}=e;return t.colors.interactiveFg.brandNormal}),(e=>{let{theme:t}=e;return t.colors.interactiveFg.brandHover}),(e=>{let{theme:t}=e;return t.colors.interactiveFg.brandPress}));function NoLink(e){let{children:t}=e;return t}const _d="web_stories_update_banner_closed";function UpdateBannerContainer(){const{bannerVisible:e}=$i(),{plugins:{"web-stories":t={}}}=y(),{needsUpdate:a,updateLink:r}=t,o=(0,h.useRef)(),[i,s]=(0,h.useState)(!1);(0,h.useEffect)((()=>{s(function(){const e=Hi.getItemByKey(_d);return!e||(new Date).getTime()>e&&(Hi.setItemByKey(_d,null),!0)}()&&a)}),[a]);const c=(0,h.useCallback)((()=>{const e=(new Date).getTime()+1728e5;Hi.setItemByKey(_d,e),s(!1)}),[]);if(!i)return null;if(e)return null;const d=r?bd:NoLink;return n.createElement(hd,{closeButtonLabel:(0,l.__)("Dismiss update notification","web-stories"),onClose:c,title:(0,l.__)("Update available.","web-stories"),ref:o},n.createElement(Sa.Text.Paragraph,null,n.createElement(dn.default,{mapping:{a:n.createElement(d,{href:r})}},(0,l.__)("A new version of the plugin is available. Please update now.","web-stories"))))}function UpdateBanner(){const{currentPath:e,hasAvailableRoutes:t}=er((e=>{let{state:t}=e;return{currentPath:t.currentPath,hasAvailableRoutes:t.availableRoutes.length>0}})),a=(0,h.useRef)(null),[,r]=(0,h.useState)(!1);return(0,h.useEffect)((()=>{t&&[Ye.DASHBOARD,Ye.TEMPLATES_GALLERY,Li].includes(e)&&(a.current=document.getElementById("body-view-options-header"),r((e=>!e)))}),[e,t]),a.current?(0,h.createPortal)(n.createElement(UpdateBannerContainer,null),a.current):null}const yd=(0,m.default)(cd).withConfig({displayName:"ga4Banner__StyledBanner",componentId:"sc-jq5r9t-0"})(["background:",";"],(e=>{let{theme:t}=e;return t.colors.interactiveBg.brandNormal})),Ed=(0,m.default)(ea.Link).withConfig({displayName:"ga4Banner__StyledLink",componentId:"sc-jq5r9t-1"})(["color:",";text-decoration:underline;&:hover{color:",";}&:focus{color:",";}"],(e=>{let{theme:t}=e;return t.colors.interactiveFg.brandNormal}),(e=>{let{theme:t}=e;return t.colors.interactiveFg.brandHover}),(e=>{let{theme:t}=e;return t.colors.interactiveFg.brandPress}));function GoogleAnalytics4BannerContainer(){const{plugins:{siteKit:e={}}}=y(),t=Gi((e=>{let{state:{settings:{googleAnalyticsId:t}}}=e;return t?.toLowerCase().startsWith("ua-")})),{currentPath:a}=er((e=>{let{state:{currentPath:t}}=e;return{currentPath:t}})),r=(0,h.useRef)();return e.analyticsActive?null:t?a===Li?null:n.createElement(yd,{title:(0,l.__)("Update your Google Analytics configuration.","web-stories"),ref:r},n.createElement(Sa.Text.Paragraph,null,n.createElement(dn.default,{mapping:{a:n.createElement(ea.Link,{href:(0,l.__)("https://support.google.com/analytics/answer/11583528?hl=en","web-stories"),rel:"noreferrer",target:"_blank",onClick:e=>(0,E.trackClick)(e,"click_ua_deprecation_docs")}),a2:n.createElement(ea.Link,{href:(0,l.__)("https://support.google.com/analytics/answer/10089681?hl=en","web-stories"),rel:"noreferrer",target:"_blank",onClick:e=>(0,E.trackClick)(e,"click_ga4_docs")})}},(0,l.__)("As previously announced, Universal Analytics will stop processing new visits starting July 1, 2023. We recommend switching to Google Analytics 4 (GA4), our analytics product of record.","web-stories"))),n.createElement(Sa.Text.Paragraph,null,n.createElement(dn.default,{mapping:{a:n.createElement(Ed,{href:tr(Li)})}},(0,l.__)("Update your settings now.","web-stories")))):null}function GoogleAnalytics4Banner(){const{currentPath:e,hasAvailableRoutes:t}=er((e=>{let{state:t}=e;return{currentPath:t.currentPath,hasAvailableRoutes:t.availableRoutes.length>0}})),a=(0,h.useRef)(null),[,r]=(0,h.useState)(!1);return(0,h.useEffect)((()=>{t&&[Ye.DASHBOARD,Ye.TEMPLATES_GALLERY,Li].includes(e)&&(a.current=document.getElementById("body-view-options-header"),r((e=>!e)))}),[e,t]),a.current?(0,h.createPortal)(n.createElement(GoogleAnalytics4BannerContainer,null),a.current):null}const Sd=function(){return Fi(),n.createElement(td,null,n.createElement(ai,{additionalRoutes:[{path:Li,component:n.createElement(Bc,null)}]}),n.createElement(TelemetryBanner,null),n.createElement(UpdateBanner,null),n.createElement(GoogleAnalytics4Banner,null))};window.webStories=window.webStories||{},window.webStories.initializeStoryDashboard=(e,t)=>{const a=document.getElementById(e);(0,ri.setAppElement)(a),(0,ft.updateSettings)(t.locale),(0,E.initializeTracking)("Dashboard",!1);const o={...t,apiCallbacks:(0,li.default)(r,t),leftRailSecondaryNavigation:Ai,documentTitleSuffix:(0,l.__)("Web Stories − WordPress","web-stories"),styleConstants:{topOffset:32,leftOffset:36},containerId:"wpbody"};(0,h.render)(n.createElement(h.StrictMode,null,n.createElement(cn,{config:o},n.createElement(Ui,null),n.createElement(Sd,null))),a)}}},n={};function __webpack_require__(e){var t=n[e];if(void 0!==t)return t.exports;var a=n[e]={exports:{}};return r[e].call(a.exports,a,a.exports,__webpack_require__),a.exports}__webpack_require__.m=r,e=[],__webpack_require__.O=(t,a,r,n)=>{if(!a){var l=1/0;for(c=0;c=n)&&Object.keys(__webpack_require__.O).every((e=>__webpack_require__.O[e](a[i])))?a.splice(i--,1):(o=!1,n0&&e[c-1][2]>n;c--)e[c]=e[c-1];e[c]=[a,r,n]},__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var a in t)__webpack_require__.o(t,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},__webpack_require__.f={},__webpack_require__.e=e=>Promise.all(Object.keys(__webpack_require__.f).reduce(((t,a)=>(__webpack_require__.f[a](e,t),t)),[])),__webpack_require__.u=e=>649===e?"649.js":({8:"chunk-web-stories-template-5",69:"chunk-web-stories-template-60-metaData",274:"chunk-web-stories-template-56",354:"chunk-web-stories-template-19",410:"chunk-web-stories-template-24",533:"chunk-web-stories-template-42-metaData",824:"chunk-web-stories-template-36",827:"chunk-web-stories-template-27-metaData",884:"chunk-web-stories-template-18-metaData",907:"chunk-web-stories-template-57",1049:"chunk-web-stories-template-37",1066:"chunk-web-stories-template-44-metaData",1231:"chunk-web-stories-template-12",1340:"chunk-web-stories-template-30-metaData",1380:"chunk-web-stories-template-33-metaData",1403:"chunk-web-stories-template-37-metaData",1738:"chunk-web-stories-template-32",1789:"chunk-web-stories-template-43",1813:"chunk-web-stories-template-10-metaData",1847:"chunk-web-stories-template-12-metaData",1858:"chunk-web-stories-template-1",1970:"chunk-web-stories-template-22-metaData",2068:"chunk-web-stories-template-46",2167:"chunk-web-stories-template-32-metaData",2191:"chunk-web-stories-template-49-metaData",2235:"chunk-web-stories-template-51-metaData",2246:"chunk-web-stories-template-45-metaData",2319:"chunk-web-stories-template-31-metaData",2338:"chunk-web-stories-template-25",2374:"chunk-web-stories-template-2-metaData",2454:"chunk-web-stories-template-6",2558:"chunk-web-stories-template-53-metaData",2776:"chunk-web-stories-template-9-metaData",2794:"chunk-opentype",2830:"chunk-web-stories-template-36-metaData",2880:"chunk-web-stories-template-8",2894:"chunk-web-stories-template-34-metaData",3041:"chunk-web-stories-template-15-metaData",3194:"chunk-web-stories-template-29-metaData",3245:"chunk-web-stories-template-28",3289:"chunk-web-stories-template-43-metaData",3304:"chunk-web-stories-template-49",3441:"chunk-web-stories-template-45",3529:"chunk-web-stories-template-39",3710:"chunk-web-stories-template-35",3772:"chunk-web-stories-template-60",3777:"chunk-web-stories-template-34",3864:"chunk-web-stories-template-4-metaData",3969:"chunk-web-stories-template-9",4051:"chunk-web-stories-template-40-metaData",4142:"chunk-web-stories-template-29",4178:"chunk-web-stories-template-24-metaData",4386:"chunk-web-stories-template-41",4585:"chunk-web-stories-template-38-metaData",4874:"chunk-web-stories-template-35-metaData",4991:"chunk-web-stories-templates",5016:"chunk-web-stories-template-21-metaData",5040:"chunk-web-stories-template-16",5157:"chunk-web-stories-template-33",5312:"chunk-web-stories-template-14",5372:"chunk-web-stories-template-6-metaData",5397:"chunk-web-stories-template-8-metaData",5432:"chunk-web-stories-template-26",5535:"chunk-web-stories-template-15",5543:"chunk-web-stories-template-31",5553:"chunk-web-stories-template-20-metaData",5570:"chunk-web-stories-template-54-metaData",5573:"chunk-web-stories-template-52-metaData",5748:"chunk-web-stories-template-54",5835:"chunk-web-stories-template-30",6053:"chunk-web-stories-template-16-metaData",6188:"chunk-web-stories-template-42",6204:"chunk-web-stories-template-0-metaData",6271:"chunk-web-stories-template-39-metaData",6305:"chunk-web-stories-template-5-metaData",6311:"chunk-web-stories-template-23-metaData",6353:"chunk-web-stories-template-1-metaData",6406:"chunk-web-stories-template-4",6428:"chunk-web-stories-template-13",6500:"chunk-web-stories-template-0",6517:"chunk-web-stories-template-52",6539:"chunk-web-stories-template-58-metaData",6592:"chunk-web-stories-template-51",6641:"chunk-web-stories-template-28-metaData",6766:"chunk-web-stories-template-19-metaData",6841:"chunk-web-stories-template-58",6852:"chunk-web-stories-template-27",7131:"chunk-web-stories-template-20",7314:"chunk-web-stories-template-25-metaData",7343:"chunk-web-stories-template-47",7346:"chunk-web-stories-template-7",7399:"chunk-web-stories-template-38",7441:"chunk-web-stories-template-48",7502:"chunk-web-stories-template-23",7528:"chunk-web-stories-template-14-metaData",7586:"chunk-web-stories-template-40",7588:"chunk-web-stories-template-55-metaData",7685:"chunk-web-stories-template-59",7798:"chunk-web-stories-template-50-metaData",7799:"chunk-web-stories-template-3",7863:"chunk-web-stories-template-47-metaData",7952:"chunk-web-stories-template-3-metaData",8022:"chunk-web-stories-template-26-metaData",8189:"chunk-web-stories-template-56-metaData",8203:"chunk-web-stories-template-44",8257:"chunk-web-stories-template-22",8344:"chunk-web-stories-template-10",8422:"chunk-web-stories-template-41-metaData",8551:"chunk-web-stories-template-18",8768:"chunk-web-stories-template-11-metaData",8856:"chunk-web-stories-template-48-metaData",9074:"chunk-web-stories-template-7-metaData",9233:"chunk-web-stories-template-53",9288:"chunk-web-stories-template-55",9302:"chunk-web-stories-template-17-metaData",9375:"chunk-web-stories-template-57-metaData",9393:"chunk-web-stories-template-59-metaData",9557:"chunk-web-stories-template-13-metaData",9591:"chunk-web-stories-template-50",9603:"chunk-web-stories-template-17",9607:"chunk-web-stories-template-2",9700:"chunk-web-stories-template-11",9738:"chunk-web-stories-template-46-metaData",9811:"chunk-web-stories-template-21"}[e]||e)+".js?v="+{8:"276e03078e9dc7df6e50",69:"99dfc81b95df5b9bb04b",274:"c6d1b4af7a57f831628b",354:"c6e29abaaa5418d056ca",410:"1b9062e0975031ace3dd",533:"f2b86bddf09ce94df427",824:"7128450e3c6434bddfc1",827:"ad283995f235c6c76cc9",884:"8fd2a3229a9f5722f745",907:"95992466886fa5bb512e",1049:"a55f54202bfbd9027c0a",1066:"cd3ff0d9335544474da3",1231:"c164da726e3bfb9e4733",1340:"b47a0051385b343ef391",1380:"6cf60c41097de5480da9",1403:"5289c868cd1c0e23fd35",1738:"871d2d5d35fd5bd4167f",1789:"3e54ef801a2e22a9c4eb",1813:"9870b38cfe43b88b602b",1847:"8184d3dfcdcc4d5ecac7",1858:"6d8d1d86106bee7d9871",1970:"05e032d2a9e73956041d",2068:"918b54419cada53719fb",2167:"78b0076115e4da2c597b",2191:"ce551dbf7b38546d4fac",2235:"af236ca54882764bafa6",2246:"ca4baea922ef44ac7026",2319:"e9f6006becbac14d0fe1",2338:"19db03ea1be44adcd88a",2374:"2224c9b088ddbb8029c6",2454:"5dd975a203020043f27f",2558:"3368b0c62aa4bc4c4d24",2776:"72d338b09ddc5680fd94",2794:"f96dcadc68adde4ccdff",2830:"f63296033f92679579a4",2880:"1e346b899fdcff8e65d2",2894:"615e21da064c1b3e273a",3041:"29aeee32f0f97f85534a",3194:"7cb0d40f462c290b1087",3245:"e8d0c09f4a0ae44a0fb4",3289:"8c2f3486ca517882c2fa",3304:"c6fab271b656735dee4b",3441:"169ec871e937bdf9e839",3529:"435d88991ef772b98fd0",3710:"b5692d77ad90cbca60da",3772:"552a65243772e4136a9d",3777:"feb96bb6880add86c9f1",3864:"42130f114e60931f3958",3969:"95a27c3821843a25b879",4051:"43d2cedcf85e4e287cb9",4142:"48f971acea335e7041bd",4178:"7090c7e642709cf4e7a6",4386:"ebf3bde79f2db3338738",4422:"d22cc6023c7242a432c2",4585:"0519a8fa98f10534eaf2",4874:"b867ba48775c55b8c9f7",4991:"21f8f0312d282237d517",5016:"16a31e37684ad9c8776f",5040:"fb5f2ae5b0e12caae1f3",5157:"c3d9ebd90069de267484",5312:"fdd69a0c5984751d5a94",5372:"d4dcda69183d6e5b0420",5397:"61263ce987f167c7c162",5432:"4f619d5ab8494b0f40f6",5535:"cbc54e66706e4c720b4a",5543:"c2fddbc19305765be2b0",5553:"a5753d181d89c4df5de3",5570:"2b718539fb68e3eb6945",5573:"dc8d1fa89d67a219d0c1",5748:"03163fd6b25229eaffe2",5835:"fa287e98a83b891becd9",6053:"a84b13f4b64fdf78751d",6188:"1de9fce08eb4828390a3",6204:"a08fc44f4d1cd11a7292",6271:"570ed0a2a31e154633b2",6305:"3f7f6edf89c82924cdce",6311:"364a9b72c56a92fe1e6a",6353:"857ed3a7c09c86715da8",6406:"df642751c2871871bf00",6428:"13f16923fe0227ee6585",6500:"5bbfdb2b36aa7eb4a960",6517:"c0a67fc9a720ce11bdce",6539:"1997ffdb0f7fb94c2587",6592:"134cfab0ea9fe8ae7a30",6641:"f432dd0973aea1d4b2bb",6766:"cd6488c0cde6ef791ca4",6841:"580cb2aa31c3b4251899",6852:"287ce89bcd67c65761f8",7131:"0f31608a85464bd407f8",7314:"7e85ccea961c0606df1d",7343:"21a67c9fcec28c27c16c",7346:"f295b40d03be5f2e16de",7399:"50851b2921eab3c56b5d",7441:"3f2635971cc4faafd0c5",7502:"08dc3fc554f59aec3b5f",7528:"059bafb3c3d61c645a41",7586:"0160026b3943ff665049",7588:"ad76b2f24b98a8b5d555",7685:"caebd98f147083e0ff29",7798:"e7466353ab300d8fa355",7799:"49dfeef03a2b96bfbe5b",7863:"84feb1786ef9f74add28",7952:"d5a72d9a90a87a9c8197",8022:"679fdc7ebca47434f5d6",8189:"67b57e2ca8f57669dea3",8203:"e30c0238e2a189d75918",8257:"6a24457b3e42cd9f55bc",8344:"a2018746f383d65b4139",8422:"604c560335294e7eb302",8551:"1557163e61b90f36e701",8768:"a002f30778b548d7c7fa",8856:"64156c4302896f690a15",9074:"581735e0e09857c0891d",9233:"16e6bf26192b65e3a97c",9288:"bd4a745671205a8d09c4",9302:"dc7fb27225b90e945735",9375:"0e847231a59ee6f9b7b5",9393:"d152933a9d60dde1330f",9557:"cee6078176667f0e1e8e",9591:"6f9f21fdc2056ea2ef11",9603:"a819f3f745f989e4aae4",9607:"78152c1c9bf3091ec630",9700:"07fcbc55a6901445d103",9738:"d84fcb02558d69526e32",9811:"1d9cd2391f3002087ff5"}[e],__webpack_require__.miniCssF=e=>{},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},a="web-stories-wp:",__webpack_require__.l=(e,r,n,l)=>{if(t[e])t[e].push(r);else{var o,i;if(void 0!==n)for(var s=document.getElementsByTagName("script"),c=0;c{o.onerror=o.onload=null,clearTimeout(p);var n=t[e];if(delete t[e],o.parentNode&&o.parentNode.removeChild(o),n&&n.forEach((e=>e(r))),a)return a(r)},p=setTimeout(u.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=u.bind(null,o.onerror),o.onload=u.bind(null,o.onload),i&&document.head.appendChild(o)}},__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.p="",(()=>{var e={8156:0};__webpack_require__.f.j=(t,a)=>{var r=__webpack_require__.o(e,t)?e[t]:void 0;if(0!==r)if(r)a.push(r[2]);else{var n=new Promise(((a,n)=>r=e[t]=[a,n]));a.push(r[2]=n);var l=__webpack_require__.p+__webpack_require__.u(t),o=new Error;__webpack_require__.l(l,(a=>{if(__webpack_require__.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var n=a&&("load"===a.type?"missing":a.type),l=a&&a.target&&a.target.src;o.message="Loading chunk "+t+" failed.\n("+n+": "+l+")",o.name="ChunkLoadError",o.type=n,o.request=l,r[1](o)}}),"chunk-"+t,t)}},__webpack_require__.O.j=t=>0===e[t];var t=(t,a)=>{var r,n,[l,o,i]=a,s=0;if(l.some((t=>0!==e[t]))){for(r in o)__webpack_require__.o(o,r)&&(__webpack_require__.m[r]=o[r]);if(i)var c=i(__webpack_require__)}for(t&&t(a);s__webpack_require__(12014)));l=__webpack_require__.O(l)})();