flarum-ext-search/js/dist/forum.js

3 lines
9.5 KiB
JavaScript

/*! For license information please see forum.js.LICENSE.txt */
(()=>{var t={163(t){t.exports=function(t,e){this.v=t,this.k=e},t.exports.__esModule=!0,t.exports.default=t.exports},110(t,e,r){var n=r(397);function o(){var e,r,u="function"==typeof Symbol?Symbol:{},s=u.iterator||"@@iterator",a=u.toStringTag||"@@toStringTag";function i(t,o,u,s){var a=o&&o.prototype instanceof p?o:p,i=Object.create(a.prototype);return n(i,"_invoke",function(t,n,o){var u,s,a,i=0,p=o||[],l=!1,f={p:0,n:0,v:e,a:m,f:m.bind(e,4),d:function(t,r){return u=t,s=0,a=e,f.n=r,c}};function m(t,n){for(s=t,a=n,r=0;!l&&i&&!o&&r<p.length;r++){var o,u=p[r],m=f.p,d=u[2];t>3?(o=d===n)&&(a=u[(s=u[4])?5:(s=3,3)],u[4]=u[5]=e):u[0]<=m&&((o=t<2&&m<u[1])?(s=0,f.v=n,f.n=u[1]):m<d&&(o=t<3||u[0]>n||n>d)&&(u[4]=t,u[5]=n,f.n=d,s=0))}if(o||t>1)return c;throw l=!0,n}return function(o,p,d){if(i>1)throw TypeError("Generator is already running");for(l&&1===p&&m(p,d),s=p,a=d;(r=s<2?e:a)||!l;){u||(s?s<3?(s>1&&(f.n=-1),m(s,a)):f.n=a:f.v=a);try{if(i=2,u){if(s||(o="next"),r=u[o]){if(!(r=r.call(u,a)))throw TypeError("iterator result is not an object");if(!r.done)return r;a=r.value,s<2&&(s=0)}else 1===s&&(r=u.return)&&r.call(u),s<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),s=1);u=e}else if((r=(l=f.n<0)?a:t.call(n,f))!==c)break}catch(t){u=e,s=1,a=t}finally{i=1}}return{value:r,done:l}}}(t,u,s),!0),i}var c={};function p(){}function l(){}function f(){}r=Object.getPrototypeOf;var m=[][s]?r(r([][s]())):(n(r={},s,function(){return this}),r),d=f.prototype=p.prototype=Object.create(m);function v(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,n(t,a,"GeneratorFunction")),t.prototype=Object.create(d),t}return l.prototype=f,n(d,"constructor",f),n(f,"constructor",l),l.displayName="GeneratorFunction",n(f,a,"GeneratorFunction"),n(d),n(d,a,"Generator"),n(d,s,function(){return this}),n(d,"toString",function(){return"[object Generator]"}),(t.exports=o=function(){return{w:i,m:v}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},996(t,e,r){var n=r(312);t.exports=function(t,e,r,o,u){var s=n(t,e,r,o,u);return s.next().then(function(t){return t.done?t.value:s.next()})},t.exports.__esModule=!0,t.exports.default=t.exports},312(t,e,r){var n=r(110),o=r(166);t.exports=function(t,e,r,u,s){return new o(n().w(t,e,r,u),s||Promise)},t.exports.__esModule=!0,t.exports.default=t.exports},166(t,e,r){var n=r(163),o=r(397);t.exports=function t(e,r){function u(t,o,s,a){try{var i=e[t](o),c=i.value;return c instanceof n?r.resolve(c.v).then(function(t){u("next",t,s,a)},function(t){u("throw",t,s,a)}):r.resolve(c).then(function(t){i.value=t,s(i)},function(t){return u("throw",t,s,a)})}catch(t){a(t)}}var s;this.next||(o(t.prototype),o(t.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),o(this,"_invoke",function(t,e,n){function o(){return new r(function(e,r){u(t,n,e,r)})}return s=s?s.then(o,o):o()},!0)},t.exports.__esModule=!0,t.exports.default=t.exports},397(t){function e(r,n,o,u){var s=Object.defineProperty;try{s({},"",{})}catch(r){s=0}t.exports=e=function(t,r,n,o){function u(r,n){e(t,r,function(t){return this._invoke(r,n,t)})}r?s?s(t,r,{value:n,enumerable:!o,configurable:!o,writable:!o}):t[r]=n:(u("next",0),u("throw",1),u("return",2))},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n,o,u)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},766(t){t.exports=function(t){var e=Object(t),r=[];for(var n in e)r.unshift(n);return function t(){for(;r.length;)if((n=r.pop())in e)return t.value=n,t.done=!1,t;return t.done=!0,t}},t.exports.__esModule=!0,t.exports.default=t.exports},24(t,e,r){var n=r(163),o=r(110),u=r(996),s=r(312),a=r(166),i=r(766),c=r(760);function p(){"use strict";var e=o(),r=e.m(p),l=(Object.getPrototypeOf?Object.getPrototypeOf(r):r.__proto__).constructor;function f(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))}var m={throw:1,return:2,break:3,continue:3};function d(t){var e,r;return function(n){e||(e={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(t,e){return r(n.a,m[t],e)},delegateYield:function(t,o,u){return e.resultName=o,r(n.d,c(t),u)},finish:function(t){return r(n.f,t)}},r=function(t,r,o){n.p=e.prev,n.n=e.next;try{return t(r,o)}finally{e.next=n.n}}),e.resultName&&(e[e.resultName]=n.v,e.resultName=void 0),e.sent=n.v,e.next=n.n;try{return t.call(this,e)}finally{n.p=e.prev,n.n=e.next}}}return(t.exports=p=function(){return{wrap:function(t,r,n,o){return e.w(d(t),r,n,o&&o.reverse())},isGeneratorFunction:f,mark:e.m,awrap:function(t,e){return new n(t,e)},AsyncIterator:a,async:function(t,e,r,n,o){return(f(e)?s:u)(d(t),e,r,n,o)},keys:i,values:c}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=p,t.exports.__esModule=!0,t.exports.default=t.exports},760(t,e,r){var n=r(735).default;t.exports=function(t){if(null!=t){var e=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}throw new TypeError(n(t)+" is not iterable")},t.exports.__esModule=!0,t.exports.default=t.exports},735(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},183(t,e,r){var n=r(24)();t.exports=n;try{regeneratorRuntime=n}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var u=e[n]={exports:{}};return t[n](u,u.exports,r),u.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";const t=flarum.core.compat["forum/app"];var e=r.n(t);const n=flarum.core.compat["forum/components/Search"];var o=r.n(n);const u=flarum.core.compat["common/extend"];function s(t,e,r,n,o,u,s){try{var a=t[u](s),i=a.value}catch(t){return void r(t)}a.done?e(i):Promise.resolve(i).then(n,o)}function a(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var u=t.apply(e,r);function a(t){s(u,n,o,a,i,"next",t)}function i(t){s(u,n,o,a,i,"throw",t)}a(void 0)})}}var i=r(183),c=r.n(i);const p=flarum.core.compat["common/helpers/highlight"];var l=r.n(p);const f=flarum.core.compat["common/components/LinkButton"];var d=r.n(f);const v=flarum.core.compat["common/components/Link"];var h=r.n(v),x=function(){function t(){this.results=new Map,this.type="discussions"}var r=t.prototype;return r.search=function(){var t=a(c().mark(function t(r){var n,o,u,s;return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=r.toLowerCase(),this.results.set(r,[]),n={filter:{q:r},page:{limit:3},include:"mostRelevantPost"},o=e().forum.attribute("apiUrl")+"/blomstra/search/"+this.type,t.next=6,e().request({params:n,url:o,method:"GET"});case 6:u=t.sent,s=e().store.pushPayload(u),this.results.set(r,s);case 9:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}(),r.view=function(t){var r=this;t=t.toLowerCase();var n=(this.results.get(t)||[]).map(function(n){var o=n.mostRelevantPost();return m("li",{className:"DiscussionSearchResult","data-index":""+r.type+n.id()},m(h(),{href:e().route.discussion(n,o&&o.number())},m("div",{className:"DiscussionSearchResult-title"},l()(n.title(),t)),!!o&&m("div",{className:"DiscussionSearchResult-excerpt"},l()(o.contentPlain(),t,100))))});return[m("li",{className:"Dropdown-header"},e().translator.trans("core.forum.search.discussions_heading")),m("li",null,m(d(),{icon:"fas fa-search",href:e().route("index",{q:t,sort:"latest"})},e().translator.trans("core.forum.search.all_discussions_button",{query:t})))].concat(n)},t}();function y(){return y=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},y.apply(null,arguments)}const b=flarum.core.compat["forum/states/DiscussionListState"];var _=r.n(b);e().initializers.add("blomstra-search",function(){(0,u.extend)(o().prototype,"sourceItems",function(t){var r=e().forum.attribute("blomstraSearchMinLength")||o().MIN_SEARCH_LEN;r!==o().MIN_SEARCH_LEN&&(o().MIN_SEARCH_LEN=r),t.replace("discussions",new x)})}),e().initializers.add("blomstra-search-early",function(){(0,u.override)(_().prototype,"loadPage",function(){var t=a(c().mark(function t(r,n){var o,u,s,a,i;return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===n&&(n=1),!e().data.apiDocument&&null!=(o=this.requestParams())&&null!=(u=o.filter)&&u.q){t.next=4;break}return t.abrupt("return",r.call(this,n));case 4:return(s=this.requestParams()).page=y({offset:this.pageSize*(n-1)},s.page),s.sort||(s.sort="-lastPostedAt"),Array.isArray(s.include)&&(s.include=s.include.join(",")),a=e().forum.attribute("apiUrl")+"/blomstra/search/"+this.type,t.next=11,e().request({params:s,url:a,method:"GET"});case 11:return i=t.sent,t.abrupt("return",e().store.pushPayload(i));case 13:case"end":return t.stop()}},t,this)}));return function(e,r,n){return t.apply(this,arguments)}}())},999999)})(),module.exports={}})();
//# sourceMappingURL=forum.js.map