LocalCDN-Firefox-Chrome-Brave/resources/findify-bundle/7.1.57/initializer.jsm

1 line
66 KiB
JavaScript
Raw Normal View History

(self.findifyJsonp=self.findifyJsonp||[]).push([[407],{"PB1/":function(e,t,n){"use strict";n.d(t,{Agent:function(){return v}});var r=n("i7z3"),o=n("q5l8"),i=n("gNLg"),c=n("+OBi"),u=n("dApp"),a=n("Wc6y"),s=n("rj/w"),f=n("kIHr");function l(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||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.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function p(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var y=(0,i.fromJS)({}),m={filters:(0,i.fromJS)({})},v=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.type=r.Type.Search,this._defaults=y,this.state=y,this.response=y,this.handlers=[],this.set=function(e,t){var r=n.state.get(e),o=(0,s.isFunction)(t)&&t,c=o?(0,i.fromJS)(o(n.format(r))):(0,i.fromJS)(t);if("offset"!==e&&n.reset("offset"),o&&!c)return n;var a=(0,u.getChangedFields)(r,(0,i.isImmutable)(c)?c:(0,i.fromJS)(c));return!1===a||((0,i.isImmutable)(a)&&a.isEmpty()?n.reset(e):n.cache.set(e,a),n.fireEvent("set:"+e,a,(0,i.Map)())),n};var a,f,l,d,p=this.request.bind(this);this.config=(f=(a=t).debounce,l=a.onError,d=a.immutable,{debounce:f,onError:l,immutable:void 0!==d&&d}),this.onError=t.onError&&t.onError.bind(this),this.handleResponse=this.handleResponse.bind(this),this.provider=(0,o.init)(t),this.cache=new c.Cache(t.debounce?(0,s.debounce)(p,t.debounce):p)}var t,n,d;return t=e,(n=[{key:"defaults",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this._defaults=(0,f.default)(this._defaults,(0,i.fromJS)(e)),t||this.cache.resolve(),this}},{key:"on",value:function(e,t){var n=l(e.split(":")),r=n[0],o=n.slice(1);return this.handlers.push({handler:t,key:e,path:o,event:r}),this}},{key:"once",value:function(e,t){var n=this;return this.on(e,(function e(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];t(o),n.off(e)}))}},{key:"off",value:function(e){return e||(this.handlers=[]),this.handlers=this.handlers.filter((function(t){var n=t.key,r=t.handler;return((0,s.isFunction)(e)?r:n)!==e})),this}},{key:"reset",value:function(e){return this.state=e?m[e]?this.state.set("filters",m[e]):this.state.delete(e):y,this.cache.reset(e),this}},{key:"applyState",value:function(e){for(var t in this.reset(),e)this.set(t,e[t]);e.offset&&this.set("offset",e.offset)}},{key:"emit",value:function(e,t){var n=this.handlers.filter((function(t){return t.key===e}));if(n)for(var r=0;r<n.length;r++)n[r]&&n[r].handler(t)}},{key:"fireEvent",value:function(e,t,n){var r=this.handlers.filter((function(t){return t.key===e}));if(r)for(var o=0;o<r.length;o++)r[o]&&r[o].handler(this.format(t),this.format(n))}},{key:"handleChanges",value:function(e,t){for(var n=this.response,r=0;r<this.handlers.length;r++){if(!this.handlers[r])return;var o=this.handlers[r],i=o.path,c=o.handler;if("change"===o.event){var u=e.getIn(i),a=n.getIn(i);!u||a&&a.equals(u)||c(this.format(u),this.format(t))}}}},{key:"handleResponse",value:function(e){var t=(0,i.fromJS)(e),n=(0,a.queryToState)(this.state,t.get("meta"),this._defaults);this.handleChanges(t,t.get("meta")),this.fireEvent("change:query",n,t.get("meta")),this.state=n,this.response=t}},{key:"createRequestBody",value:function(e){this.state=(0,f.default)(this.state,e);var t=this._defaults.mergeDeep(this.state);return{params:(0,a.stateToQuery)(t).toJS(),type:this.typ