!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,o=window.nisje.components,l=window.nisje.format;function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}(0,a.registerCardRender)("nisje-retriever",{render:function(e){var t=e.bg,n=e.isDark,a=e.items,i=e.className,c=e.title;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,l.decodeEntities)(c)),(0,r.createElement)("ul",{className:"latest-retriever-list"},a.map((function(e){var t=e.id,n=e.title,a=e.link;return(0,r.createElement)(o.Flex,{key:"retriever-item-".concat(t),gap:4,as:"li",className:"latest-retriever-item"},(0,r.createElement)(o.FlexBlock,null,(0,r.createElement)(o.TextDeprecated,{as:"h2",variant:"medium"},(0,r.createElement)("a",{href:a},(0,l.decodeEntities)(n)))))}))))}});var u=window.lodash,s=window.React,d=window.moment,m=e.n(d),f=window.nisje.interface,v=window.nisje.data;function p(){var 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=".concat(e,"&per_page=24");return(0,u.isEmpty)(t)||(r+="&search=".concat(t)),(0,v.fetchMany)({path:r})}var g=function(){var e,t,a=(0,i.useParams)(),u=parseInt((null==a?void 0:a.page)||"1",10),d=(0,v.useQueryClient)(),g=(e=(0,i.useSearchQuery)("/retriever/"),t=3,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=r){var n,a,i=[],_n=!0,o=!1;try{for(r=r.call(e);!(_n=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);_n=!0);}catch(e){o=!0,a=e}finally{try{_n||null==r.return||r.return()}finally{if(o)throw a}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),w=g[0],y=g[1],E=g[2],h=(0,v.useQuery)(["retriever",u,w],(function(){return p(u,w)})),b=h.isLoading,j=h.data;return(0,s.useEffect)((function(){u!==(null==j?void 0:j.totalPages)&&d.prefetchQuery(["retriever",u+1,w],(function(){return p(u+1,w)}))}),[j,u,d,w]),(0,r.createElement)(r.Fragment,null,(0,r.createElement)(f.Header,{title:(0,n.__)("Retriever"),onSearch:y,searchValue:w}),(0,r.createElement)(o.FeedGrid,null,b&&(0,r.createElement)(o.BaseCardLoaders,null),j&&(0,r.createElement)(r.Fragment,null,j.items.map((function(e){var t=e.content,n=e.date,a=e.id,c=e.retriever.link,u=e.title;return(0,r.createElement)(o.BaseCard,{key:"item-".concat(a),url:(0,l.decodeEntities)(c)},(0,r.createElement)(o.Text,{as:"h2",variant:"title.medium",mt:.5,mb:.5},(0,r.createElement)(i.Link,{to:(0,l.decodeEntities)(c)},(0,l.decodeEntities)(u.rendered))),(0,r.createElement)(o.Text,{variant:"small"},m()(n).format("LL")),(0,r.createElement)(o.RawHTML,null,t.rendered))})))),j&&(0,r.createElement)(o.Pagination,{totalPages:j.totalPages,currentPage:u,path:"/retriever/",append:"?".concat(E)}))};(0,a.registerPlugin)("retriever",{render:function(){return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(i.PluginRoutes,null,(0,r.createElement)(i.Route,{path:"/retriever/(page)?/:page?",component:g,exact:!0})))}}),(window.nisje=window.nisje||{}).pluginRetriever=t}();