!function(){"use strict";var e={n:function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,{a:r}),r},d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t);var r=window.wp.element,n=window.wp.i18n,a=window.nisje.settings,i=window.nisje.router,l=window.nisje.components,o=window.nisje.format;(0,a.registerCardRender)("nisje-retriever",{render:function({bg:e,isDark:t,items:n,className:a,title:i}){return(0,r.createElement)(l.BaseCard,{bg:e,isDark:t,className:a},(0,r.createElement)(l.TextDeprecated,{as:"h2",variant:"title-medium",className:"latest-retriever-title"},(0,o.decodeEntities)(i)),(0,r.createElement)("ul",{className:"latest-retriever-list"},n.map((({id:e,title:t,link:n})=>(0,r.createElement)(l.Flex,{key:`retriever-item-${e}`,gap:4,as:"li",className:"latest-retriever-item"},(0,r.createElement)(l.FlexBlock,null,(0,r.createElement)(l.TextDeprecated,{as:"h2",variant:"medium"},(0,r.createElement)("a",{href:n},(0,o.decodeEntities)(t)))))))))}});var s=window.lodash,c=window.React,d=window.moment,u=e.n(d),m=window.nisje.interface,p=window.nisje.data;function w(e=1,t){let r=`/wp/v2/nisje-retriever?page=${e}&per_page=24`;return(0,s.isEmpty)(t)||(r+=`&search=${t}`),(0,p.fetchMany)({path:r})}var v=function(){const e=(0,i.useParams)(),t=parseInt((null==e?void 0:e.page)||"1",10),a=(0,p.useQueryClient)(),[s,d,v]=(0,i.useSearchQuery)("/retriever/"),{isLoading:g,data:E}=(0,p.useQuery)(["retriever",t,s],(()=>w(t,s)));return(0,c.useEffect)((()=>{null!=E&&E.totalPages&&t!==(null==E?void 0:E.totalPages)&&a.prefetchQuery(["retriever",t+1,s],(()=>w(t+1,s)))}),[E,t,a,s]),(0,r.createElement)(r.Fragment,null,(0,r.createElement)(m.Header,{title:(0,n.__)("Retriever"),onSearch:d,searchValue:s}),(0,r.createElement)(l.FeedGrid,null,g&&(0,r.createElement)(l.BaseCardLoaders,null),E&&(0,r.createElement)(r.Fragment,null,E.items.map((({content:e,date:t,id:n,retriever:{link:a},title:s})=>(0,r.createElement)(l.BaseCard,{key:`item-${n}`,url:(0,o.decodeEntities)(a)},(0,r.createElement)(l.Text,{as:"h2",variant:"title.medium",mt:.5,mb:.5},(0,r.createElement)(i.Link,{to:(0,o.decodeEntities)(a)},(0,o.decodeEntities)(s.rendered))),(0,r.createElement)(l.Text,{variant:"small"},u()(t).format("LL")),(0,r.createElement)(l.RawHTML,null,e.rendered)))))),E&&(0,r.createElement)(l.Pagination,{totalPages:E.totalPages,currentPage:t,path:"/retriever/",append:`?${v}`}))};(0,a.registerPlugin)("retriever",{render:()=>(0,r.createElement)(r.Fragment,null,(0,r.createElement)(i.PluginRoutes,null,(0,r.createElement)(i.Route,{path:"/retriever/(page)?/:page?",component:v,exact:!0})))}),(window.nisje=window.nisje||{}).pluginRetriever=t}();