!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.app.router,o=window.nisje.components,s=window.nisje.app.components,c=window.nisje.app.utils;(0,window.nisje.app.api.registerCard)("nisje-retriever",(function(e){let{bg:t,isDark:n,items:a,className:i,title:l}=e;return(0,r.createElement)(o.BaseCard,{bg:t,isDark:n,className:i},(0,r.createElement)(o.TextDeprecated,{as:"h2",variant:"title-medium",className:"latest-retriever-title"},(0,c.decodeEntities)(l)),(0,r.createElement)("ul",{className:"latest-retriever-list"},a.map((e=>{let{id:t,title:n,link:a}=e;return(0,r.createElement)(s.Flex,{key:`retriever-item-${t}`,gap:4,as:"li",className:"latest-retriever-item"},(0,r.createElement)(s.FlexBlock,null,(0,r.createElement)(o.TextDeprecated,{as:"h2",variant:"medium"},(0,r.createElement)("a",{href:a},(0,c.decodeEntities)(n)))))}))))}));var d=window.lodash,u=window.React,m=window.moment,p=e.n(m),w=window.nisje.interface,g=window.nisje.app.hooks,v=window.nisje.app.query,E=window.nisje.app.fetch;function f(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1?arguments[1]:void 0,r=`/wp/v2/nisje-retriever?page=${e}&per_page=24`;return(0,d.isEmpty)(t)||(r+=`&search=${t}`),(0,E.apiFetchMany)({path:r})}var j=function(){const e=(0,l.useParams)(),t=parseInt(e?.page||"1",10),a=(0,v.useQueryClient)(),[i,d,m]=(0,g.useSearchQuery)("/retriever/"),{isLoading:E,data:j}=(0,v.useQuery)(["retriever",t,i],(()=>f(t,i)));return(0,u.useEffect)((()=>{j?.totalPages&&t!==j?.totalPages&&a.prefetchQuery(["retriever",t+1,i],(()=>f(t+1,i)))}),[j,t,a,i]),(0,r.createElement)(r.Fragment,null,(0,r.createElement)(w.Header,{title:(0,n.__)("Retriever","nisje"),onSearch:d,searchValue:i}),(0,r.createElement)(o.FeedGrid,null,E&&(0,r.createElement)(o.BaseCardLoaders,null),j&&(0,r.createElement)(r.Fragment,null,j.items.map((e=>{let{content:t,date:n,id:a,retriever:{link:i},title:l}=e;return(0,r.createElement)(o.BaseCard,{key:`item-${a}`,url:(0,c.decodeEntities)(i)},(0,r.createElement)(s.Text,{as:"h2",variant:"title.medium",mt:.5,mb:.5},(0,r.createElement)(s.Link,{to:(0,c.decodeEntities)(i)},(0,c.decodeEntities)(l.rendered))),(0,r.createElement)(s.Text,{variant:"small"},p()(n).format("LL")),(0,r.createElement)(s.RawHTML,null,t.rendered))})))),j&&(0,r.createElement)(o.Pagination,{totalPages:j.totalPages,currentPage:t,path:"/retriever/",append:`?${m}`}))};(0,a.registerPlugin)("retriever",{render:()=>(0,r.createElement)(r.Fragment,null,(0,r.createElement)(i.PluginRoutes,null,(0,r.createElement)(l.Route,{path:"/retriever/(page)?/:page?",component:j,exact:!0})))}),(window.nisje=window.nisje||{}).pluginRetriever=t}();