immer.cjs.production.min.js 15 KB

12
  1. function t(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];throw Error("[Immer] minified error nr: "+t+(r.length?" "+r.map((function(t){return"'"+t+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function n(t){return!!t&&!!t[H]}function r(t){return!!t&&(function(t){if(!t||"object"!=typeof t)return!1;var n=Object.getPrototypeOf(t);return!n||n===Object.prototype}(t)||Array.isArray(t)||!!t[G]||!!t.constructor[G]||c(t)||s(t))}function e(t,n,r){void 0===r&&(r=!1),0===i(t)?(r?Object.keys:Q)(t).forEach((function(e){r&&"symbol"==typeof e||n(e,t[e],t)})):t.forEach((function(r,e){return n(e,r,t)}))}function i(t){var n=t[H];return n?n.t>3?n.t-4:n.t:Array.isArray(t)?1:c(t)?2:s(t)?3:0}function u(t,n){return 2===i(t)?t.has(n):Object.prototype.hasOwnProperty.call(t,n)}function o(t,n){return 2===i(t)?t.get(n):t[n]}function f(t,n,r){var e=i(t);2===e?t.set(n,r):3===e?(t.delete(n),t.add(r)):t[n]=r}function a(t,n){return t===n?0!==t||1/t==1/n:t!=t&&n!=n}function c(t){return W&&t instanceof Map}function s(t){return X&&t instanceof Set}function v(t){return t.i||t.u}function p(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var n=T(t);delete n[H];for(var r=Q(n),e=0;e<r.length;e++){var i=r[e],u=n[i];!1===u.writable&&(u.writable=!0,u.configurable=!0),(u.get||u.set)&&(n[i]={configurable:!0,writable:!0,enumerable:u.enumerable,value:t[i]})}return Object.create(Object.getPrototypeOf(t),n)}function l(t,u){return void 0===u&&(u=!1),d(t)||n(t)||!r(t)?t:(i(t)>1&&(t.set=t.add=t.clear=t.delete=h),Object.freeze(t),u&&e(t,(function(t,n){return l(n,!0)}),!0),t)}function h(){t(2)}function d(t){return null==t||"object"!=typeof t||Object.isFrozen(t)}function _(n){var r=U[n];return r||t(18,n),r}function y(t,n){U[t]||(U[t]=n)}function b(){return J}function m(t,n){n&&(_("Patches"),t.o=[],t.s=[],t.v=n)}function j(t){O(t),t.p.forEach(w),t.p=null}function O(t){t===J&&(J=t.l)}function x(t){return J={p:[],l:J,h:t,_:!0,m:0}}function w(t){var n=t[H];0===n.t||1===n.t?n.j():n.O=!0}function S(n,e){e.m=e.p.length;var i=e.p[0],u=void 0!==n&&n!==i;return e.h.S||_("ES5").M(e,n,u),u?(i[H].P&&(j(e),t(4)),r(n)&&(n=M(e,n),e.l||g(e,n)),e.o&&_("Patches").g(i[H],n,e.o,e.s)):n=M(e,i,[]),j(e),e.o&&e.v(e.o,e.s),n!==B?n:void 0}function M(t,n,r){if(d(n))return n;var i=n[H];if(!i)return e(n,(function(e,u){return P(t,i,n,e,u,r)}),!0),n;if(i.A!==t)return n;if(!i.P)return g(t,i.u,!0),i.u;if(!i.R){i.R=!0,i.A.m--;var u=4===i.t||5===i.t?i.i=p(i.k):i.i;e(3===i.t?new Set(u):u,(function(n,e){return P(t,i,u,n,e,r)})),g(t,u,!1),r&&t.o&&_("Patches").F(i,r,t.o,t.s)}return i.i}function P(t,e,i,o,a,c){if(n(a)){var s=M(t,a,c&&e&&3!==e.t&&!u(e.D,o)?c.concat(o):void 0);if(f(i,o,s),!n(s))return;t._=!1}if(r(a)&&!d(a)){if(!t.h.K&&t.m<1)return;M(t,a),e&&e.A.l||g(t,a)}}function g(t,n,r){void 0===r&&(r=!1),t.h.K&&t._&&l(n,r)}function A(t,n){var r=t[H];return(r?v(r):t)[n]}function z(t,n){if(n in t)for(var r=Object.getPrototypeOf(t);r;){var e=Object.getOwnPropertyDescriptor(r,n);if(e)return e;r=Object.getPrototypeOf(r)}}function E(t){t.P||(t.P=!0,t.l&&E(t.l))}function R(t){t.i||(t.i=p(t.u))}function k(t,n,r){var e=c(n)?_("MapSet").$(n,r):s(n)?_("MapSet").C(n,r):t.S?function(t,n){var r=Array.isArray(t),e={t:r?1:0,A:n?n.A:b(),P:!1,R:!1,D:{},l:n,u:t,k:null,i:null,j:null,I:!1},i=e,u=V;r&&(i=[e],u=Y);var o=Proxy.revocable(i,u),f=o.revoke,a=o.proxy;return e.k=a,e.j=f,a}(n,r):_("ES5").J(n,r);return(r?r.A:b()).p.push(e),e}function F(u){return n(u)||t(22,u),function t(n){if(!r(n))return n;var u,a=n[H],c=i(n);if(a){if(!a.P&&(a.t<4||!_("ES5").N(a)))return a.u;a.R=!0,u=D(n,c),a.R=!1}else u=D(n,c);return e(u,(function(n,r){a&&o(a.u,n)===r||f(u,n,t(r))})),3===c?new Set(u):u}(u)}function D(t,n){switch(n){case 2:return new Map(t);case 3:return Array.from(t)}return p(t)}function K(){function t(t,n){var r=f[t];return r?r.enumerable=n:f[t]=r={configurable:!0,enumerable:n,get:function(){return V.get(this[H],t)},set:function(n){V.set(this[H],t,n)}},r}function r(t){for(var n=t.length-1;n>=0;n--){var r=t[n][H];if(!r.P)switch(r.t){case 5:o(r)&&E(r);break;case 4:i(r)&&E(r)}}}function i(t){for(var n=t.u,r=t.k,e=Q(r),i=e.length-1;i>=0;i--){var o=e[i];if(o!==H){var f=n[o];if(void 0===f&&!u(n,o))return!0;var c=r[o],s=c&&c[H];if(s?s.u!==f:!a(c,f))return!0}}var v=!!n[H];return e.length!==Q(n).length+(v?0:1)}function o(t){var n=t.k;if(n.length!==t.u.length)return!0;var r=Object.getOwnPropertyDescriptor(n,n.length-1);return!(!r||r.get)}var f={};y("ES5",{J:function(n,r){var e=Array.isArray(n),i=function(n,r){if(n){for(var e=Array(r.length),i=0;i<r.length;i++)Object.defineProperty(e,""+i,t(i,!0));return e}var u=T(r);delete u[H];for(var o=Q(u),f=0;f<o.length;f++){var a=o[f];u[a]=t(a,n||!!u[a].enumerable)}return Object.create(Object.getPrototypeOf(r),u)}(e,n),u={t:e?5:4,A:r?r.A:b(),P:!1,R:!1,D:{},l:r,u:n,k:i,i:null,O:!1,I:!1};return Object.defineProperty(i,H,{value:u,writable:!0}),i},M:function(t,i,f){f?n(i)&&i[H].A===t&&r(t.p):(t.o&&function t(n){if(n&&"object"==typeof n){var r=n[H];if(r){var i=r.u,f=r.k,a=r.D,c=r.t;if(4===c)e(f,(function(n){n!==H&&(void 0!==i[n]||u(i,n)?a[n]||t(f[n]):(a[n]=!0,E(r)))})),e(i,(function(t){void 0!==f[t]||u(f,t)||(a[t]=!1,E(r))}));else if(5===c){if(o(r)&&(E(r),a.length=!0),f.length<i.length)for(var s=f.length;s<i.length;s++)a[s]=!1;else for(var v=i.length;v<f.length;v++)a[v]=!0;for(var p=Math.min(f.length,i.length),l=0;l<p;l++)void 0===a[l]&&t(f[l])}}}}(t.p[0]),r(t.p))},N:function(t){return 4===t.t?i(t):o(t)}})}function $(){function f(t){if(!r(t))return t;if(Array.isArray(t))return t.map(f);if(c(t))return new Map(Array.from(t.entries()).map((function(t){return[t[0],f(t[1])]})));if(s(t))return new Set(Array.from(t).map(f));var n=Object.create(Object.getPrototypeOf(t));for(var e in t)n[e]=f(t[e]);return n}function a(t){return n(t)?f(t):t}var v="add";y("Patches",{W:function(n,r){return r.forEach((function(r){for(var e=r.path,u=r.op,a=n,c=0;c<e.length-1;c++){var s=i(a),p=e[c];0!==s&&1!==s||"__proto__"!==p&&"constructor"!==p||t(24),"function"==typeof a&&"prototype"===p&&t(24),"object"!=typeof(a=o(a,p))&&t(15,e.join("/"))}var l=i(a),h=f(r.value),d=e[e.length-1];switch(u){case"replace":switch(l){case 2:return a.set(d,h);case 3:t(16);default:return a[d]=h}case v:switch(l){case 1:return a.splice(d,0,h);case 2:return a.set(d,h);case 3:return a.add(h);default:return a[d]=h}case"remove":switch(l){case 1:return a.splice(d,1);case 2:return a.delete(d);case 3:return a.delete(r.value);default:return delete a[d]}default:t(17,u)}})),n},F:function(t,n,r,i){switch(t.t){case 0:case 4:case 2:return function(t,n,r,i){var f=t.u,c=t.i;e(t.D,(function(t,e){var s=o(f,t),p=o(c,t),l=e?u(f,t)?"replace":v:"remove";if(s!==p||"replace"!==l){var h=n.concat(t);r.push("remove"===l?{op:l,path:h}:{op:l,path:h,value:p}),i.push(l===v?{op:"remove",path:h}:"remove"===l?{op:v,path:h,value:a(s)}:{op:"replace",path:h,value:a(s)})}}))}(t,n,r,i);case 5:case 1:return function(t,n,r,e){var i=t.u,u=t.D,o=t.i;if(o.length<i.length){var f=[o,i];i=f[0],o=f[1];var c=[e,r];r=c[0],e=c[1]}for(var s=0;s<i.length;s++)if(u[s]&&o[s]!==i[s]){var p=n.concat([s]);r.push({op:"replace",path:p,value:a(o[s])}),e.push({op:"replace",path:p,value:a(i[s])})}for(var l=i.length;l<o.length;l++){var h=n.concat([l]);r.push({op:v,path:h,value:a(o[l])})}i.length<o.length&&e.push({op:"replace",path:n.concat(["length"]),value:i.length})}(t,n,r,i);case 3:return function(t,n,r,e){var i=t.u,u=t.i,o=0;i.forEach((function(t){if(!u.has(t)){var i=n.concat([o]);r.push({op:"remove",path:i,value:t}),e.unshift({op:v,path:i,value:t})}o++})),o=0,u.forEach((function(t){if(!i.has(t)){var u=n.concat([o]);r.push({op:v,path:u,value:t}),e.unshift({op:"remove",path:u,value:t})}o++}))}(t,n,r,i)}},g:function(t,n,r,e){r.push({op:"replace",path:[],value:n}),e.push({op:"replace",path:[],value:t.u})}})}function C(){function n(t,n){function r(){this.constructor=t}f(t,n),t.prototype=(r.prototype=n.prototype,new r)}function i(t){t.i||(t.D=new Map,t.i=new Map(t.u))}function u(t){t.i||(t.i=new Set,t.u.forEach((function(n){if(r(n)){var e=k(t.A.h,n,t);t.p.set(n,e),t.i.add(e)}else t.i.add(n)})))}function o(n){n.O&&t(3,JSON.stringify(v(n)))}var f=function(t,n){return(f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])})(t,n)},a=function(){function t(t,n){return this[H]={t:2,l:n,A:n?n.A:b(),P:!1,R:!1,i:void 0,D:void 0,u:t,k:this,I:!1,O:!1},this}n(t,Map);var u=t.prototype;return Object.defineProperty(u,"size",{get:function(){return v(this[H]).size}}),u.has=function(t){return v(this[H]).has(t)},u.set=function(t,n){var r=this[H];return o(r),v(r).has(t)&&v(r).get(t)===n||(i(r),E(r),r.D.set(t,!0),r.i.set(t,n),r.D.set(t,!0)),this},u.delete=function(t){if(!this.has(t))return!1;var n=this[H];return o(n),i(n),E(n),n.D.set(t,!1),n.i.delete(t),!0},u.clear=function(){var t=this[H];o(t),v(t).size&&(i(t),E(t),t.D=new Map,e(t.u,(function(n){t.D.set(n,!1)})),t.i.clear())},u.forEach=function(t,n){var r=this;v(this[H]).forEach((function(e,i){t.call(n,r.get(i),i,r)}))},u.get=function(t){var n=this[H];o(n);var e=v(n).get(t);if(n.R||!r(e))return e;if(e!==n.u.get(t))return e;var u=k(n.A.h,e,n);return i(n),n.i.set(t,u),u},u.keys=function(){return v(this[H]).keys()},u.values=function(){var t,n=this,r=this.keys();return(t={})[L]=function(){return n.values()},t.next=function(){var t=r.next();return t.done?t:{done:!1,value:n.get(t.value)}},t},u.entries=function(){var t,n=this,r=this.keys();return(t={})[L]=function(){return n.entries()},t.next=function(){var t=r.next();if(t.done)return t;var e=n.get(t.value);return{done:!1,value:[t.value,e]}},t},u[L]=function(){return this.entries()},t}(),c=function(){function t(t,n){return this[H]={t:3,l:n,A:n?n.A:b(),P:!1,R:!1,i:void 0,u:t,k:this,p:new Map,O:!1,I:!1},this}n(t,Set);var r=t.prototype;return Object.defineProperty(r,"size",{get:function(){return v(this[H]).size}}),r.has=function(t){var n=this[H];return o(n),n.i?!!n.i.has(t)||!(!n.p.has(t)||!n.i.has(n.p.get(t))):n.u.has(t)},r.add=function(t){var n=this[H];return o(n),this.has(t)||(u(n),E(n),n.i.add(t)),this},r.delete=function(t){if(!this.has(t))return!1;var n=this[H];return o(n),u(n),E(n),n.i.delete(t)||!!n.p.has(t)&&n.i.delete(n.p.get(t))},r.clear=function(){var t=this[H];o(t),v(t).size&&(u(t),E(t),t.i.clear())},r.values=function(){var t=this[H];return o(t),u(t),t.i.values()},r.entries=function(){var t=this[H];return o(t),u(t),t.i.entries()},r.keys=function(){return this.values()},r[L]=function(){return this.values()},r.forEach=function(t,n){for(var r=this.values(),e=r.next();!e.done;)t.call(n,e.value,e.value,this),e=r.next()},t}();y("MapSet",{$:function(t,n){return new a(t,n)},C:function(t,n){return new c(t,n)}})}var I;Object.defineProperty(exports,"__esModule",{value:!0});var J,N="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),W="undefined"!=typeof Map,X="undefined"!=typeof Set,q="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,B=N?Symbol.for("immer-nothing"):((I={})["immer-nothing"]=!0,I),G=N?Symbol.for("immer-draftable"):"__$immer_draftable",H=N?Symbol.for("immer-state"):"__$immer_state",L="undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator",Q="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Object.getOwnPropertyNames,T=Object.getOwnPropertyDescriptors||function(t){var n={};return Q(t).forEach((function(r){n[r]=Object.getOwnPropertyDescriptor(t,r)})),n},U={},V={get:function(t,n){if(n===H)return t;var e=v(t);if(!u(e,n))return function(t,n,r){var e,i=z(n,r);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(t.k):void 0}(t,e,n);var i=e[n];return t.R||!r(i)?i:i===A(t.u,n)?(R(t),t.i[n]=k(t.A.h,i,t)):i},has:function(t,n){return n in v(t)},ownKeys:function(t){return Reflect.ownKeys(v(t))},set:function(t,n,r){var e=z(v(t),n);if(null==e?void 0:e.set)return e.set.call(t.k,r),!0;if(!t.P){var i=A(v(t),n),o=null==i?void 0:i[H];if(o&&o.u===r)return t.i[n]=r,t.D[n]=!1,!0;if(a(r,i)&&(void 0!==r||u(t.u,n)))return!0;R(t),E(t)}return t.i[n]=r,t.D[n]=!0,!0},deleteProperty:function(t,n){return void 0!==A(t.u,n)||n in t.u?(t.D[n]=!1,R(t),E(t)):delete t.D[n],t.i&&delete t.i[n],!0},getOwnPropertyDescriptor:function(t,n){var r=v(t),e=Reflect.getOwnPropertyDescriptor(r,n);return e?{writable:!0,configurable:1!==t.t||"length"!==n,enumerable:e.enumerable,value:r[n]}:e},defineProperty:function(){t(11)},getPrototypeOf:function(t){return Object.getPrototypeOf(t.u)},setPrototypeOf:function(){t(12)}},Y={};e(V,(function(t,n){Y[t]=function(){return arguments[0]=arguments[0][0],n.apply(this,arguments)}})),Y.deleteProperty=function(t,n){return V.deleteProperty.call(this,t[0],n)},Y.set=function(t,n,r){return V.set.call(this,t[0],n,r,t[0])};var Z=function(){function e(t){this.S=q,this.K=!0,"boolean"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),this.produce=this.produce.bind(this),this.produceWithPatches=this.produceWithPatches.bind(this)}var i=e.prototype;return i.produce=function(n,e,i){if("function"==typeof n&&"function"!=typeof e){var u=e;e=n;var o=this;return function(t){var n=this;void 0===t&&(t=u);for(var r=arguments.length,i=Array(r>1?r-1:0),f=1;f<r;f++)i[f-1]=arguments[f];return o.produce(t,(function(t){var r;return(r=e).call.apply(r,[n,t].concat(i))}))}}var f;if("function"!=typeof e&&t(6),void 0!==i&&"function"!=typeof i&&t(7),r(n)){var a=x(this),c=k(this,n,void 0),s=!0;try{f=e(c),s=!1}finally{s?j(a):O(a)}return"undefined"!=typeof Promise&&f instanceof Promise?f.then((function(t){return m(a,i),S(t,a)}),(function(t){throw j(a),t})):(m(a,i),S(f,a))}if(!n||"object"!=typeof n){if((f=e(n))===B)return;return void 0===f&&(f=n),this.K&&l(f,!0),f}t(21,n)},i.produceWithPatches=function(t,n){var r,e,i=this;return"function"==typeof t?function(n){for(var r=arguments.length,e=Array(r>1?r-1:0),u=1;u<r;u++)e[u-1]=arguments[u];return i.produceWithPatches(n,(function(n){return t.apply(void 0,[n].concat(e))}))}:[this.produce(t,n,(function(t,n){r=t,e=n})),r,e]},i.createDraft=function(e){r(e)||t(8),n(e)&&(e=F(e));var i=x(this),u=k(this,e,void 0);return u[H].I=!0,O(i),u},i.finishDraft=function(t,n){var r=(t&&t[H]).A;return m(r,n),S(void 0,r)},i.setAutoFreeze=function(t){this.K=t},i.setUseProxies=function(n){n&&!q&&t(20),this.S=n},i.applyPatches=function(t,r){var e;for(e=r.length-1;e>=0;e--){var i=r[e];if(0===i.path.length&&"replace"===i.op){t=i.value;break}}var u=_("Patches").W;return n(t)?u(t,r):this.produce(t,(function(t){return u(t,r.slice(e+1))}))},e}(),tt=new Z,nt=tt.produce,rt=tt.produceWithPatches.bind(tt),et=tt.setAutoFreeze.bind(tt),it=tt.setUseProxies.bind(tt),ut=tt.applyPatches.bind(tt),ot=tt.createDraft.bind(tt),ft=tt.finishDraft.bind(tt);exports.Immer=Z,exports.applyPatches=ut,exports.castDraft=function(t){return t},exports.castImmutable=function(t){return t},exports.createDraft=ot,exports.current=F,exports.default=nt,exports.enableAllPlugins=function(){K(),C(),$()},exports.enableES5=K,exports.enableMapSet=C,exports.enablePatches=$,exports.finishDraft=ft,exports.freeze=l,exports.immerable=G,exports.isDraft=n,exports.isDraftable=r,exports.nothing=B,exports.original=function(r){return n(r)||t(23,r),r[H].u},exports.produce=nt,exports.produceWithPatches=rt,exports.setAutoFreeze=et,exports.setUseProxies=it;
  2. //# sourceMappingURL=immer.cjs.production.min.js.map