partial.lenses.cjs.js 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var I = require('infestines');
  4. var LENGTH = 'length';
  5. var addU = function addU(x, y) {
  6. return x + y;
  7. };
  8. var multiplyU = function multiplyU(x, y) {
  9. return x * y;
  10. };
  11. var add = /*#__PURE__*/I.curry(addU);
  12. var multiply = /*#__PURE__*/I.curry(multiplyU);
  13. var divideBy = /*#__PURE__*/I.curry(function (d, n) {
  14. return n / d;
  15. });
  16. var negate = function negate(x) {
  17. return -x;
  18. };
  19. var ltU = function ltU(x, y) {
  20. return x < y;
  21. };
  22. var gtU = function gtU(x, y) {
  23. return x > y;
  24. };
  25. var isInstanceOf = /*#__PURE__*/I.curry(I.isInstanceOfU);
  26. var protoless = function protoless(o) {
  27. return I.assign(I.create(null), o);
  28. };
  29. var protoless0 = /*#__PURE__*/I.freeze( /*#__PURE__*/protoless(I.object0));
  30. var replace = /*#__PURE__*/I.curry(function (p, r, s) {
  31. return s.replace(p, r);
  32. });
  33. function isPrimitiveData(x) {
  34. switch (typeof x) {
  35. case 'boolean':
  36. case 'number':
  37. case 'string':
  38. return true;
  39. default:
  40. return false;
  41. }
  42. }
  43. var iterator = Symbol.iterator;
  44. var dep = function dep(xs2xsyC) {
  45. return function (xsy) {
  46. return I.arityN(xsy[LENGTH], I.defineNameU(function () {
  47. return xs2xsyC.apply(undefined, arguments)(xsy).apply(undefined, arguments);
  48. }, xsy.name));
  49. };
  50. };
  51. var fn = function fn(xsC, yC) {
  52. return function (xsy) {
  53. return I.arityN(xsy[LENGTH], I.defineNameU(function () {
  54. for (var _len = arguments.length, xs = Array(_len), _key = 0; _key < _len; _key++) {
  55. xs[_key] = arguments[_key];
  56. }
  57. return yC(xsy.apply(null, xsC(xs)));
  58. }, xsy.name));
  59. };
  60. };
  61. var res = function res(yC) {
  62. return fn(I.id, yC);
  63. };
  64. var args = function args(xsC) {
  65. return fn(xsC, I.id);
  66. };
  67. var nth = function nth(i, xC) {
  68. return function (xs) {
  69. var ys = xs.slice(0);
  70. ys[i] = xC(ys[i]);
  71. return ys;
  72. };
  73. };
  74. var par = function par(i, xC) {
  75. return args(nth(i, xC));
  76. };
  77. var and = function and() {
  78. for (var _len2 = arguments.length, xCs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  79. xCs[_key2] = arguments[_key2];
  80. }
  81. return function (x) {
  82. for (var i = 0, n = xCs[LENGTH]; i < n; ++i) {
  83. x = xCs[i](x);
  84. }return x;
  85. };
  86. };
  87. var or = function or() {
  88. for (var _len3 = arguments.length, xCs = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  89. xCs[_key3] = arguments[_key3];
  90. }
  91. return function (x) {
  92. var es = null;
  93. for (var i = 0, n = xCs[LENGTH]; i < n; ++i) {
  94. try {
  95. return xCs[i](x);
  96. } catch (e) {
  97. es = e;
  98. }
  99. }
  100. throw es;
  101. };
  102. };
  103. var ef = function ef(xE) {
  104. return I.defineNameU(function (x) {
  105. xE(x);
  106. return x;
  107. }, xE.name);
  108. };
  109. var tup = function tup() {
  110. for (var _len4 = arguments.length, xCs = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  111. xCs[_key4] = arguments[_key4];
  112. }
  113. return function (xs) {
  114. if (xs[LENGTH] !== xCs[LENGTH]) throw Error('Expected array of ' + xCs[LENGTH] + ' elements, but got ' + xs[LENGTH]);
  115. return and.apply(null, xCs.map(function (xC, i) {
  116. return nth(i, xC);
  117. }))(xs);
  118. };
  119. };
  120. var arr = function arr(xC) {
  121. return function (xs) {
  122. return xs.map(xC);
  123. };
  124. };
  125. //
  126. var id = function id(x) {
  127. return x;
  128. };
  129. var setName = process.env.NODE_ENV === 'production' ? function (x) {
  130. return x;
  131. } : I.defineNameU;
  132. var copyName = process.env.NODE_ENV === 'production' ? function (x) {
  133. return x;
  134. } : function (to, from) {
  135. return I.defineNameU(to, from.name);
  136. };
  137. var toRegExpU = function toRegExpU(str, flags) {
  138. return I.isString(str) ? new RegExp(replace(/[|\\{}()[\]^$+*?.]/g, '\\$&', str), flags) : str;
  139. };
  140. //
  141. var isPair = function isPair(x) {
  142. return I.isArray(x) && x[LENGTH] === 2;
  143. };
  144. //
  145. var inserterOp = /*#__PURE__*/I.curry(function (inserter, value) {
  146. return [inserter, setOp(value)];
  147. });
  148. //
  149. var toGetter = function toGetter(getter) {
  150. if (typeof getter === 'function' && getter[LENGTH] < 4) return getter;
  151. getter = toFunction(getter);
  152. return function (x, i) {
  153. return getter(x, i, Select, id);
  154. };
  155. };
  156. //
  157. var tryCatch = function tryCatch(fn$$1) {
  158. return copyName(function (x) {
  159. try {
  160. return fn$$1(x);
  161. } catch (e) {
  162. return e;
  163. }
  164. }, fn$$1);
  165. };
  166. //
  167. var toStringPartial = function toStringPartial(x) {
  168. return void 0 !== x ? String(x) : '';
  169. };
  170. var sliceIndex = function sliceIndex(m, l, d, i) {
  171. return void 0 !== i ? Math.min(Math.max(m, i < 0 ? l + i : i), l) : d;
  172. };
  173. var cpair = function cpair(xs) {
  174. return function (x) {
  175. return [x, xs];
  176. };
  177. };
  178. var pairPartial = function pairPartial(k) {
  179. return function (v) {
  180. return void 0 !== k && void 0 !== v ? [k, v] : void 0;
  181. };
  182. };
  183. var unto = function unto(c) {
  184. return function (x) {
  185. return void 0 !== x ? x : c;
  186. };
  187. };
  188. var unto0 = /*#__PURE__*/unto(0);
  189. var toTrue = /*#__PURE__*/I.always(true);
  190. var notPartial = function complement(x) {
  191. return void 0 !== x ? !x : x;
  192. };
  193. var expect = function expect(p, f) {
  194. return copyName(function (x) {
  195. return p(x) ? f(x) : void 0;
  196. }, f);
  197. };
  198. var freezeInDev = process.env.NODE_ENV === 'production' ? id : I.freeze;
  199. var freezeResultInDev = process.env.NODE_ENV === 'production' ? id : /*#__PURE__*/res(I.freeze);
  200. var deepFreezeInDev = process.env.NODE_ENV === 'production' ? id : function deepFreezeInDev(x) {
  201. if (I.isArray(x)) {
  202. x.forEach(deepFreezeInDev);
  203. I.freeze(x);
  204. } else if (I.isObject(x)) {
  205. for (var k in x) {
  206. deepFreezeInDev(x[k]);
  207. }I.freeze(x);
  208. }
  209. return x;
  210. };
  211. function freezeObjectOfObjects(xs) {
  212. if (xs) for (var k in xs) {
  213. I.freeze(xs[k]);
  214. }return I.freeze(xs);
  215. }
  216. var isArrayOrPrimitive = function isArrayOrPrimitive(x) {
  217. return !(x instanceof Object) || I.isArray(x);
  218. };
  219. var rev = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(I.freeze))(function reverse(xs) {
  220. if (seemsArrayLike(xs)) {
  221. var n = xs[LENGTH];
  222. var ys = Array(n);
  223. var i = 0;
  224. while (n) {
  225. ys[i++] = xs[--n];
  226. }return ys;
  227. }
  228. });
  229. //
  230. var mapPartialIndexU = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : function (fn$$1) {
  231. return function (xi2y, xs, skip) {
  232. var ys = fn$$1(xi2y, xs, skip);
  233. if (xs !== ys) I.freeze(ys);
  234. return ys;
  235. };
  236. })(function (xi2y, xs, skip) {
  237. var n = xs[LENGTH];
  238. var ys = Array(n);
  239. var j = 0;
  240. var same = true;
  241. for (var i = 0; i < n; ++i) {
  242. var x = xs[i];
  243. var y = xi2y(x, i);
  244. if (skip !== y) {
  245. ys[j++] = y;
  246. if (same) same = x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
  247. }
  248. }
  249. if (j !== n) {
  250. ys[LENGTH] = j;
  251. return ys;
  252. } else if (same) {
  253. return xs;
  254. } else {
  255. return ys;
  256. }
  257. });
  258. var mapIfArrayLike = function mapIfArrayLike(xi2y, xs) {
  259. return seemsArrayLike(xs) ? mapPartialIndexU(xi2y, xs, void 0) : void 0;
  260. };
  261. var mapsIfArray = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(I.freeze))(function (x2y, xs) {
  262. if (I.isArray(xs)) {
  263. var n = xs[LENGTH];
  264. var ys = Array();
  265. for (var i = 0; i < n; ++i) {
  266. if (void 0 === (ys[i] = x2y(xs[i]))) {
  267. return void 0;
  268. }
  269. }
  270. return ys;
  271. }
  272. });
  273. var copyToFrom = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : function (fn$$1) {
  274. return function (ys, k, xs, i, j) {
  275. return ys[LENGTH] === k + j - i ? I.freeze(fn$$1(ys, k, xs, i, j)) : fn$$1(ys, k, xs, i, j);
  276. };
  277. })(function (ys, k, xs, i, j) {
  278. while (i < j) {
  279. ys[k++] = xs[i++];
  280. }return ys;
  281. });
  282. //
  283. function selectInArrayLike(xi2v, xs) {
  284. for (var i = 0, n = xs[LENGTH]; i < n; ++i) {
  285. var v = xi2v(xs[i], i);
  286. if (void 0 !== v) return v;
  287. }
  288. }
  289. //
  290. var ConstantWith = function ConstantWith(ap, empty) {
  291. return I.Applicative(I.sndU, I.always(empty), ap);
  292. };
  293. var ConstantOf = function ConstantOf(_ref) {
  294. var concat = _ref.concat,
  295. empty = _ref.empty;
  296. return ConstantWith(concat, empty());
  297. };
  298. var Sum = /*#__PURE__*/ConstantWith(addU, 0);
  299. var mumBy = function mumBy(ord) {
  300. return I.curry(function mumBy(xi2y, t, s) {
  301. xi2y = toGetter(xi2y);
  302. var minX = void 0;
  303. var minY = void 0;
  304. getAsU(function (x, i) {
  305. var y = xi2y(x, i);
  306. if (void 0 !== y && (void 0 === minY || ord(y, minY))) {
  307. minX = x;
  308. minY = y;
  309. }
  310. }, t, s);
  311. return minX;
  312. });
  313. };
  314. //
  315. var traverseU = function traverse(C, xi2yC, t, s) {
  316. return toFunction(t)(s, void 0, C, xi2yC);
  317. };
  318. //
  319. var expectedOptic = 'Expecting an optic';
  320. var opticIsEither = 'An optic can be either\n- a string,\n- a non-negative integer,\n- a quaternary optic function,\n- an ordinary unary or binary function, or\n- an array of optics.\nSee documentation of `toFunction` and `compose` for details.';
  321. var header = 'partial.lenses: ';
  322. function warn(f, m) {
  323. if (!f.warned) {
  324. f.warned = 1;
  325. console.warn(header + m);
  326. }
  327. }
  328. function errorGiven(m, o, e) {
  329. m = header + m + '.';
  330. e = e ? '\n' + e : '';
  331. console.error(m, 'Given:', o, e);
  332. throw Error(m + e);
  333. }
  334. var reqIndex = function index(x) {
  335. if (!Number.isInteger(x) || x < 0) errorGiven('`index` expects a non-negative integer', x);
  336. };
  337. function reqFunction(o) {
  338. if (!(I.isFunction(o) && (o[LENGTH] === 4 || o[LENGTH] <= 2))) errorGiven(expectedOptic, o, opticIsEither);
  339. }
  340. function reqFn(x) {
  341. if (!I.isFunction(x)) errorGiven('Expected a function', x);
  342. }
  343. function reqArray(o) {
  344. if (!I.isArray(o)) errorGiven(expectedOptic, o, opticIsEither);
  345. }
  346. function reqOptic(o) {
  347. switch (typeof o) {
  348. case 'string':
  349. break;
  350. case 'number':
  351. reqIndex(o);
  352. break;
  353. case 'object':
  354. reqArray(o);
  355. for (var i = 0, n = o[LENGTH]; i < n; ++i) {
  356. reqOptic(o[i]);
  357. }break;
  358. default:
  359. reqFunction(o);
  360. break;
  361. }
  362. }
  363. //
  364. var reqString = function reqString(msg) {
  365. return function (x) {
  366. if (!I.isString(x)) errorGiven(msg, x);
  367. };
  368. };
  369. var reqMaybeArray = function reqMaybeArray(msg) {
  370. return function (zs) {
  371. if (!(void 0 === zs || seemsArrayLike(zs))) errorGiven(msg, zs);
  372. };
  373. };
  374. //
  375. var reqMonad = function reqMonad(name) {
  376. return function (C) {
  377. if (!C.chain) errorGiven('`' + name + '` requires a monad', C, 'Note that you can only `modify`, `remove`, `set`, and `traverse` a transform.');
  378. };
  379. };
  380. //
  381. var mkTraverse = function mkTraverse(after, toC) {
  382. return I.curryN(4, copyName(function (xi2yC, m) {
  383. return m = toC(m), function (t, s) {
  384. return after(traverseU(m, xi2yC, t, s));
  385. };
  386. }, toC));
  387. };
  388. //
  389. var consExcept = function consExcept(skip) {
  390. return function (t) {
  391. return function (h) {
  392. return skip !== h ? [h, t] : t;
  393. };
  394. };
  395. };
  396. var pushTo = function pushTo(n, xs) {
  397. while (consExcept !== n) {
  398. xs.push(n[0]);
  399. n = n[1];
  400. }
  401. return xs;
  402. };
  403. var consTo = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(I.freeze))(function (n) {
  404. return pushTo(n, []).reverse();
  405. });
  406. function traversePartialIndex(A, xi2yA, xs, skip) {
  407. var map = A.map,
  408. ap = A.ap;
  409. var xsA = A.of(consExcept);
  410. var n = xs[LENGTH];
  411. if (map === I.sndU) {
  412. for (var i = 0; i < n; ++i) {
  413. xsA = ap(xsA, xi2yA(xs[i], i));
  414. }return xsA;
  415. } else {
  416. var cons = consExcept(skip);
  417. for (var _i2 = 0; _i2 < n; ++_i2) {
  418. xsA = ap(map(cons, xsA), xi2yA(xs[_i2], _i2));
  419. }return map(consTo, xsA);
  420. }
  421. }
  422. //
  423. var SelectLog = /*#__PURE__*/I.Applicative(function (f, _ref2) {
  424. var p = _ref2.p,
  425. x = _ref2.x,
  426. c = _ref2.c;
  427. x = f(x);
  428. if (!I.isFunction(x)) p = [x, p];
  429. return { p: p, x: x, c: c };
  430. }, function (x) {
  431. return { p: [], x: x, c: undefined };
  432. }, function (l, r) {
  433. var v = undefined !== l.c ? l : r;
  434. return { p: v.p, x: l.x(r.x), c: v.c };
  435. });
  436. //
  437. var lensFrom = function lensFrom(get, set) {
  438. return function (i) {
  439. return function (x, _i, F, xi2yF) {
  440. return F.map(function (v) {
  441. return set(i, v, x);
  442. }, xi2yF(get(i, x), i));
  443. };
  444. };
  445. };
  446. //
  447. var getProp = function getProp(k, o) {
  448. return o instanceof Object ? o[k] : void 0;
  449. };
  450. var setProp = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(I.freeze))(function (k, v, o) {
  451. return void 0 !== v ? I.assocPartialU(k, v, o) : I.dissocPartialU(k, o) || I.object0;
  452. });
  453. var funProp = /*#__PURE__*/lensFrom(getProp, setProp);
  454. //
  455. var getIndex = function getIndex(i, xs) {
  456. return seemsArrayLike(xs) ? xs[i] : void 0;
  457. };
  458. var setIndex = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : fn(nth(0, ef(reqIndex)), I.freeze))(function (i, x, xs) {
  459. if (!seemsArrayLike(xs)) xs = '';
  460. var n = xs[LENGTH];
  461. if (void 0 !== x) {
  462. var m = Math.max(i + 1, n);
  463. var ys = Array(m);
  464. for (var j = 0; j < m; ++j) {
  465. ys[j] = xs[j];
  466. }ys[i] = x;
  467. return ys;
  468. } else {
  469. if (n <= i) return copyToFrom(Array(n), 0, xs, 0, n);
  470. var _ys = Array(n - 1);
  471. for (var _j = 0; _j < i; ++_j) {
  472. _ys[_j] = xs[_j];
  473. }for (var _j2 = i + 1; _j2 < n; ++_j2) {
  474. _ys[_j2 - 1] = xs[_j2];
  475. }return _ys;
  476. }
  477. });
  478. var funIndex = /*#__PURE__*/lensFrom(getIndex, setIndex);
  479. //
  480. var composedMiddle = function composedMiddle(o, r) {
  481. return function (F, xi2yF) {
  482. return xi2yF = r(F, xi2yF), function (x, i) {
  483. return o(x, i, F, xi2yF);
  484. };
  485. };
  486. };
  487. function composed(oi0, os) {
  488. var n = os[LENGTH] - oi0;
  489. if (n < 2) {
  490. return n ? toFunction(os[oi0]) : identity;
  491. } else {
  492. var _last = toFunction(os[oi0 + --n]);
  493. var r = function r(F, xi2yF) {
  494. return function (x, i) {
  495. return _last(x, i, F, xi2yF);
  496. };
  497. };
  498. while (--n) {
  499. r = composedMiddle(toFunction(os[oi0 + n]), r);
  500. }var _first = toFunction(os[oi0]);
  501. return function (x, i, F, xi2yF) {
  502. return _first(x, i, F, r(F, xi2yF));
  503. };
  504. }
  505. }
  506. var disperseU = function disperse(traversal, values, data) {
  507. if (!seemsArrayLike(values)) values = '';
  508. var i = 0;
  509. return modifyU(traversal, function () {
  510. return values[i++];
  511. }, data);
  512. };
  513. var setU = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : par(0, ef(reqOptic)))(function set(o, x, s) {
  514. switch (typeof o) {
  515. case 'string':
  516. return setProp(o, x, s);
  517. case 'number':
  518. return setIndex(o, x, s);
  519. case 'object':
  520. return modifyComposed(o, 0, s, x);
  521. default:
  522. return o[LENGTH] === 4 ? o(s, void 0, I.Identity, I.always(x)) : s;
  523. }
  524. });
  525. var getInverseU = function getInverse(o, x) {
  526. return setU(o, x, void 0);
  527. };
  528. var modifyU = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : par(0, ef(reqOptic)))(function modify(o, xi2x, s) {
  529. switch (typeof o) {
  530. case 'string':
  531. return setProp(o, xi2x(getProp(o, s), o), s);
  532. case 'number':
  533. return setIndex(o, xi2x(getIndex(o, s), o), s);
  534. case 'object':
  535. return modifyComposed(o, xi2x, s);
  536. default:
  537. return o[LENGTH] === 4 ? o(s, void 0, I.Identity, xi2x) : (xi2x(o(s, void 0), void 0), s);
  538. }
  539. });
  540. var modifyAsyncU = function modifyAsyncU(o, f, s) {
  541. return I.resolve(toFunction(o)(s, void 0, I.IdentityAsync, f));
  542. };
  543. var getAsU = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : par(1, ef(reqOptic)))(function getAs(xi2y, l, s) {
  544. switch (typeof l) {
  545. case 'string':
  546. return xi2y(getProp(l, s), l);
  547. case 'number':
  548. return xi2y(getIndex(l, s), l);
  549. case 'object':
  550. {
  551. var n = l[LENGTH];
  552. for (var i = 0, o; i < n; ++i) {
  553. switch (typeof (o = l[i])) {
  554. case 'string':
  555. s = getProp(o, s);
  556. break;
  557. case 'number':
  558. s = getIndex(o, s);
  559. break;
  560. default:
  561. return composed(i, l)(s, l[i - 1], Select, xi2y);
  562. }
  563. }return xi2y(s, l[n - 1]);
  564. }
  565. default:
  566. return xi2y !== id && l[LENGTH] !== 4 ? xi2y(l(s, void 0), void 0) : l(s, void 0, Select, xi2y);
  567. }
  568. });
  569. var getU = function getU(l, s) {
  570. return getAsU(id, l, s);
  571. };
  572. function modifyComposed(os, xi2y, x, y) {
  573. var n = os[LENGTH];
  574. var xs = Array(n);
  575. for (var i = 0, o; i < n; ++i) {
  576. xs[i] = x;
  577. switch (typeof (o = os[i])) {
  578. case 'string':
  579. x = getProp(o, x);
  580. break;
  581. case 'number':
  582. x = getIndex(o, x);
  583. break;
  584. default:
  585. x = composed(i, os)(x, os[i - 1], I.Identity, xi2y || I.always(y));
  586. n = i;
  587. break;
  588. }
  589. }
  590. if (n === os[LENGTH]) x = xi2y ? xi2y(x, os[n - 1]) : y;
  591. for (var _o; 0 <= --n;) {
  592. x = I.isString(_o = os[n]) ? setProp(_o, x, xs[n]) : setIndex(_o, x, xs[n]);
  593. }return x;
  594. }
  595. //
  596. var lensU = function lens(get, set) {
  597. return copyName(function (x, i, F, xi2yF) {
  598. return F.map(function (y) {
  599. return set(y, x, i);
  600. }, xi2yF(get(x, i), i));
  601. }, get);
  602. };
  603. var isoU = function iso(bwd, fwd) {
  604. return copyName(function (x, i, F, xi2yF) {
  605. return F.map(fwd, xi2yF(bwd(x), i));
  606. }, bwd);
  607. };
  608. var stringIsoU = function stringIsoU(bwd, fwd) {
  609. return isoU(expect(I.isString, bwd), expect(I.isString, fwd));
  610. };
  611. var numberIsoU = function numberIsoU(bwd, fwd) {
  612. return isoU(expect(I.isNumber, bwd), expect(I.isNumber, fwd));
  613. };
  614. //
  615. var getPick = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(I.freeze))(function (template, x) {
  616. var r = void 0;
  617. for (var k in template) {
  618. var t = template[k];
  619. var v = I.isObject(t) ? getPick(t, x) : getAsU(id, t, x);
  620. if (void 0 !== v) {
  621. if (!r) r = {};
  622. r[k] = v;
  623. }
  624. }
  625. return r;
  626. });
  627. var reqTemplate = function reqTemplate(name) {
  628. return function (template) {
  629. if (!I.isObject(template)) errorGiven('`' + name + '` expects a plain Object template', template);
  630. };
  631. };
  632. var reqObject = function reqObject(msg) {
  633. return function (value) {
  634. if (!(void 0 === value || value instanceof Object)) errorGiven(msg, value);
  635. };
  636. };
  637. var setPick = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : par(1, ef(reqObject('`pick` must be set with undefined or an object'))))(function (template, value, x) {
  638. for (var k in template) {
  639. var v = value && value[k];
  640. var t = template[k];
  641. x = I.isObject(t) ? setPick(t, v, x) : setU(t, v, x);
  642. }
  643. return x;
  644. });
  645. //
  646. var toObject = function toObject(x) {
  647. return I.constructorOf(x) !== Object ? I.toObject(x) : x;
  648. };
  649. //
  650. var identity = function identity(x, i, _F, xi2yF) {
  651. return xi2yF(x, i);
  652. };
  653. //
  654. var branchAssemble = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(res(I.freeze)))(function (ks) {
  655. return function (xs) {
  656. var r = {};
  657. var i = ks[LENGTH];
  658. while (i--) {
  659. var v = xs[0];
  660. if (void 0 !== v) {
  661. r[ks[i]] = v;
  662. }
  663. xs = xs[1];
  664. }
  665. return r;
  666. };
  667. });
  668. var branchOr1LevelIdentity = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : function (fn$$1) {
  669. return function (otherwise, k2o, xO, x, A, xi2yA) {
  670. var y = fn$$1(otherwise, k2o, xO, x, A, xi2yA);
  671. if (x !== y) I.freeze(y);
  672. return y;
  673. };
  674. })(function (otherwise, k2o, xO, x, A, xi2yA) {
  675. var written = void 0;
  676. var same = true;
  677. var r = {};
  678. for (var k in k2o) {
  679. written = 1;
  680. var _x2 = xO[k];
  681. var y = k2o[k](_x2, k, A, xi2yA);
  682. if (void 0 !== y) {
  683. r[k] = y;
  684. if (same) same = _x2 === y && (_x2 !== 0 || 1 / _x2 === 1 / y) || _x2 !== _x2 && y !== y;
  685. } else {
  686. same = false;
  687. }
  688. }
  689. var t = written;
  690. for (var _k in xO) {
  691. if (void 0 === (t && k2o[_k])) {
  692. written = 1;
  693. var _x3 = xO[_k];
  694. var _y = otherwise(_x3, _k, A, xi2yA);
  695. if (void 0 !== _y) {
  696. r[_k] = _y;
  697. if (same) same = _x3 === _y && (_x3 !== 0 || 1 / _x3 === 1 / _y) || _x3 !== _x3 && _y !== _y;
  698. } else {
  699. same = false;
  700. }
  701. }
  702. }
  703. return written ? same && xO === x ? x : r : x;
  704. });
  705. var branchOr1Level = function branchOr1Level(otherwise, k2o) {
  706. return function (x, _i, A, xi2yA) {
  707. var xO = x instanceof Object ? toObject(x) : I.object0;
  708. if (I.Identity === A) {
  709. return branchOr1LevelIdentity(otherwise, k2o, xO, x, A, xi2yA);
  710. } else if (Select === A) {
  711. for (var k in k2o) {
  712. var y = k2o[k](xO[k], k, A, xi2yA);
  713. if (void 0 !== y) return y;
  714. }
  715. for (var _k2 in xO) {
  716. if (void 0 === k2o[_k2]) {
  717. var _y2 = otherwise(xO[_k2], _k2, A, xi2yA);
  718. if (void 0 !== _y2) return _y2;
  719. }
  720. }
  721. } else {
  722. var map = A.map,
  723. ap = A.ap,
  724. of = A.of;
  725. var xsA = of(cpair);
  726. var ks = [];
  727. for (var _k3 in k2o) {
  728. ks.push(_k3);
  729. xsA = ap(map(cpair, xsA), k2o[_k3](xO[_k3], _k3, A, xi2yA));
  730. }
  731. var t = ks[LENGTH] ? true : void 0;
  732. for (var _k4 in xO) {
  733. if (void 0 === (t && k2o[_k4])) {
  734. ks.push(_k4);
  735. xsA = ap(map(cpair, xsA), otherwise(xO[_k4], _k4, A, xi2yA));
  736. }
  737. }
  738. return ks[LENGTH] ? map(branchAssemble(ks), xsA) : of(x);
  739. }
  740. };
  741. };
  742. function branchOrU(otherwise, template) {
  743. var k2o = I.create(null);
  744. for (var k in template) {
  745. var v = template[k];
  746. k2o[k] = I.isObject(v) ? branchOrU(otherwise, v) : toFunction(v);
  747. }
  748. return branchOr1Level(otherwise, k2o);
  749. }
  750. var replaced = function replaced(inn, out, x) {
  751. return I.acyclicEqualsU(x, inn) ? out : x;
  752. };
  753. function findIndexHint(hint, xi2b, xs) {
  754. var u = hint.hint;
  755. var n = xs[LENGTH];
  756. if (n <= u) u = n - 1;
  757. if (u < 0) u = 0;
  758. var d = u - 1;
  759. for (; 0 <= d && u < n; ++u, --d) {
  760. if (xi2b(xs[u], u, hint)) return u;
  761. if (xi2b(xs[d], d, hint)) return d;
  762. }
  763. for (; u < n; ++u) {
  764. if (xi2b(xs[u], u, hint)) return u;
  765. }for (; 0 <= d; --d) {
  766. if (xi2b(xs[d], d, hint)) return d;
  767. }return n;
  768. }
  769. var partitionIntoIndex = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : dep(function (_xi2b, _xs, ts, fs) {
  770. return res(ef(function () {
  771. I.freeze(ts);
  772. I.freeze(fs);
  773. }));
  774. }))(function (xi2b, xs, ts, fs) {
  775. for (var i = 0, n = xs[LENGTH], x; i < n; ++i) {
  776. (xi2b(x = xs[i], i) ? ts : fs).push(x);
  777. }
  778. });
  779. var fromReader = function fromReader(wi2x) {
  780. return copyName(function (w, i, F, xi2yF) {
  781. return F.map(I.always(w), xi2yF(wi2x(w, i), i));
  782. }, wi2x);
  783. };
  784. //
  785. var LAST_INDEX = 'lastIndex';
  786. var INDEX = 'index';
  787. var RE_VALUE = 0;
  788. var reLastIndex = function reLastIndex(m) {
  789. return m[INDEX] + m[0][LENGTH];
  790. };
  791. var reNext = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : function (fn$$1) {
  792. return function (m, re) {
  793. var res$$1 = fn$$1(m, re);
  794. if ('' === res$$1) warn(reNext, '`matches(' + re + ')` traversal terminated due to empty match. `matches` traversal shouldn\'t be used with regular expressions that can produce empty matches.');
  795. return res$$1;
  796. };
  797. })(function (m, re) {
  798. var lastIndex = re[LAST_INDEX];
  799. re[LAST_INDEX] = reLastIndex(m);
  800. var n = re.exec(m.input);
  801. re[LAST_INDEX] = lastIndex;
  802. return n && n[0] && n;
  803. });
  804. //
  805. var iterCollect = function iterCollect(s) {
  806. return function (xs) {
  807. return function (x) {
  808. return [s, x, xs];
  809. };
  810. };
  811. };
  812. var iterToArray = function iterToArray(xs) {
  813. var ys = [];
  814. while (iterCollect !== xs) {
  815. ys.push(xs[0], xs[1]);
  816. xs = xs[2];
  817. }
  818. return ys;
  819. };
  820. function iterSelect(xi2y, t, s) {
  821. while (s = reNext(s, t)) {
  822. var y = xi2y(s[RE_VALUE], s[INDEX]);
  823. if (void 0 !== y) return y;
  824. }
  825. }
  826. function iterEager(map, ap, of, xi2yA, t, s) {
  827. var r = of(iterCollect);
  828. while (s = reNext(s, t)) {
  829. r = ap(ap(map(iterCollect, of(s)), r), xi2yA(s[RE_VALUE], s[INDEX]));
  830. }return r;
  831. }
  832. //
  833. var keyed = /*#__PURE__*/isoU( /*#__PURE__*/expect( /*#__PURE__*/isInstanceOf(Object), /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(freezeObjectOfObjects))(function keyed(x) {
  834. x = toObject(x);
  835. var es = [];
  836. for (var key in x) {
  837. es.push([key, x[key]]);
  838. }return es;
  839. })), /*#__PURE__*/expect(I.isArray, /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(I.freeze))(function (es) {
  840. var o = {};
  841. for (var i = 0, n = es[LENGTH]; i < n; ++i) {
  842. var entry = es[i];
  843. if (entry[LENGTH] === 2) o[entry[0]] = entry[1];
  844. }
  845. return o;
  846. })));
  847. //
  848. var matchesJoin = function matchesJoin(input) {
  849. return function (matchesIn) {
  850. var result = '';
  851. var lastIndex = 0;
  852. var matches = iterToArray(matchesIn);
  853. var n = matches[LENGTH];
  854. for (var j = n - 2; j !== -2; j += -2) {
  855. var m = matches[j];
  856. result += input.slice(lastIndex, m[INDEX]);
  857. var s = matches[j + 1];
  858. if (void 0 !== s) result += s;
  859. lastIndex = reLastIndex(m);
  860. }
  861. result += input.slice(lastIndex);
  862. return result;
  863. };
  864. };
  865. //
  866. var disjointBwd = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(freezeObjectOfObjects))(function (groupOf, x) {
  867. if (x instanceof Object) {
  868. var y = {};
  869. x = toObject(x);
  870. for (var key in x) {
  871. var group = groupOf(key);
  872. var g = y[group];
  873. if (undefined === g) y[group] = g = {};
  874. g[key] = x[key];
  875. }
  876. return y;
  877. }
  878. });
  879. var disjointFwd = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(res(I.freeze)))(function (groupOf) {
  880. return function (y) {
  881. if (y instanceof Object) {
  882. var x = {};
  883. y = toObject(y);
  884. for (var group in y) {
  885. var g = y[group];
  886. if (g instanceof Object) {
  887. g = toObject(g);
  888. for (var key in g) {
  889. if (groupOf(key) === group) {
  890. x[key] = g[key];
  891. }
  892. }
  893. }
  894. }
  895. return x;
  896. }
  897. };
  898. });
  899. //
  900. var subseqU = function subseq(begin, end, t) {
  901. t = toFunction(t);
  902. return copyName(function (x, i, F, xi2yF) {
  903. var n = -1;
  904. return t(x, i, F, function (x, i) {
  905. return begin <= ++n && !(end <= n) ? xi2yF(x, i) : F.of(x);
  906. });
  907. }, t);
  908. };
  909. //
  910. var attemptU = function attemptU(fn$$1, x) {
  911. if (void 0 !== x) {
  912. var y = fn$$1(x);
  913. if (void 0 !== y) return y;
  914. }
  915. return x;
  916. };
  917. var rewriteAttempt = function rewriteAttempt(fn$$1) {
  918. return function (x, i, F, xi2yF) {
  919. return F.map(function (x) {
  920. return attemptU(fn$$1, x);
  921. }, xi2yF(x, i));
  922. };
  923. };
  924. var rereadAttempt = function rereadAttempt(fn$$1) {
  925. return function (x, i, F, xi2yF) {
  926. return xi2yF(attemptU(fn$$1, x), i);
  927. };
  928. };
  929. //
  930. var transformEvery = function transformEvery(optic) {
  931. return transform(lazy(function (rec) {
  932. return [optic, children, rec];
  933. }));
  934. };
  935. var transformSome = function transformSome(fn$$1) {
  936. return transform(lazy(function (rec) {
  937. return choices(getter(fn$$1), [children, rec]);
  938. }));
  939. };
  940. //
  941. var isDefinedAtU = function isDefinedAtU(o, x, i) {
  942. return void 0 !== o(x, i, Select, id);
  943. };
  944. var isDefinedAt = function isDefinedAt(o) {
  945. return function (x, i) {
  946. return isDefinedAtU(o, x, i);
  947. };
  948. };
  949. var eitherU = function eitherU(t, e) {
  950. return function either(c) {
  951. return function either(x, i, C, xi2yC) {
  952. return (c(x, i) ? t : e)(x, i, C, xi2yC);
  953. };
  954. };
  955. };
  956. var orElseU = function orElse(back, prim) {
  957. prim = toFunction(prim);
  958. back = toFunction(back);
  959. return function orElse(x, i, C, xi2yC) {
  960. return (isDefinedAtU(prim, x, i) ? prim : back)(x, i, C, xi2yC);
  961. };
  962. };
  963. var orAlternativelyU = function orAlternatively(back, prim) {
  964. prim = toFunction(prim);
  965. back = toFunction(back);
  966. var fwd = function fwd(y) {
  967. y = I.always(y);
  968. var yP = prim(void 0, void 0, I.Identity, y);
  969. return void 0 === yP ? back(void 0, void 0, I.Identity, y) : yP;
  970. };
  971. return function orAlternatively(x, i, F, xi2yF) {
  972. var xP = prim(x, i, Select, id);
  973. return F.map(fwd, xi2yF(void 0 === xP ? back(x, i, Select, id) : xP, i));
  974. };
  975. };
  976. var makeSemi = function makeSemi(op) {
  977. return copyName(function (_) {
  978. var n = arguments[LENGTH];
  979. var r = arguments[--n];
  980. while (n) {
  981. r = op(r, arguments[--n]);
  982. }
  983. return r;
  984. }, op);
  985. };
  986. var zero = function zero(x, _i, C, _xi2yC) {
  987. return C.of(x);
  988. };
  989. //
  990. var elemsI = function elemsI(xs, _i, A, xi2yA) {
  991. return A === I.Identity ? mapPartialIndexU(xi2yA, xs, void 0) : A === Select ? selectInArrayLike(xi2yA, xs) : traversePartialIndex(A, xi2yA, xs, void 0);
  992. };
  993. //
  994. var seq2U = function seq2U(l, r) {
  995. return function (x, i, M, xi2yM) {
  996. return M.chain(function (x) {
  997. return r(x, i, M, xi2yM);
  998. }, l(x, i, M, xi2yM));
  999. };
  1000. };
  1001. //
  1002. var pickInAux = function pickInAux(t, k) {
  1003. return [k, pickIn(t)];
  1004. };
  1005. //
  1006. var iteratePartial = function iteratePartial(aa) {
  1007. return function iterate(a) {
  1008. var r = a;
  1009. while (a !== undefined) {
  1010. r = a;
  1011. a = aa(a);
  1012. }
  1013. return r;
  1014. };
  1015. };
  1016. //
  1017. var crossPartial = function crossPartial(op, ls, or$$1) {
  1018. return function (xs, ss) {
  1019. var n = ls[LENGTH];
  1020. if (!seemsArrayLike(xs)) return;
  1021. if (!seemsArrayLike(ss)) ss = '';
  1022. var m = Math.max(n, xs[LENGTH], ss[LENGTH]);
  1023. var ys = Array(m);
  1024. for (var i = 0; i < m; ++i) {
  1025. if (void 0 === (ys[i] = op(i < n ? ls[i] : or$$1, xs[i], ss[i]))) return;
  1026. }return ys;
  1027. };
  1028. };
  1029. var crossOr = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? I.curry : function (fn$$1) {
  1030. return I.curry(function crossOr(or$$1, ls) {
  1031. return toFunction([isoU(id, I.freeze), fn$$1(or$$1, ls), isoU(I.freeze, id)]);
  1032. });
  1033. })(function crossOr(or$$1, ls) {
  1034. return lensU(crossPartial(getU, ls, or$$1), crossPartial(setU, ls, or$$1));
  1035. });
  1036. var subsetPartial = function subsetPartial(p) {
  1037. return function subset(x) {
  1038. return void 0 !== x && p(x) ? x : void 0;
  1039. };
  1040. };
  1041. //
  1042. var unfoldPartial = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(res(function (r) {
  1043. I.freeze(r);
  1044. I.freeze(r[1]);
  1045. return r;
  1046. })))(function (s2sa) {
  1047. return function unfold(s) {
  1048. var xs = [];
  1049. for (;;) {
  1050. var sa = s2sa(s);
  1051. if (!isPair(sa)) return [s, xs];
  1052. s = sa[0];
  1053. xs.push(sa[1]);
  1054. }
  1055. };
  1056. });
  1057. var foldPartial = function foldPartial(sa2s) {
  1058. return function (sxs) {
  1059. if (isPair(sxs)) {
  1060. var xs = sxs[1];
  1061. if (I.isArray(xs)) {
  1062. var s = sxs[0];
  1063. var n = xs[LENGTH];
  1064. while (n--) {
  1065. s = sa2s(freezeInDev([s, xs[n]]));
  1066. }return s;
  1067. }
  1068. }
  1069. };
  1070. };
  1071. //
  1072. var PAYLOAD = '珳襱댎纚䤤鬖罺좴';
  1073. var isPayload = function isPayload(k) {
  1074. return I.isString(k) && k.indexOf(PAYLOAD) === 0;
  1075. };
  1076. function Spread(i) {
  1077. this[PAYLOAD] = i;
  1078. I.freeze(this);
  1079. }
  1080. var isSpread = /*#__PURE__*/isInstanceOf(Spread);
  1081. var Variable = /*#__PURE__*/I.inherit(function Variable(i) {
  1082. this[PAYLOAD + i] = this[PAYLOAD] = I.freeze([new Spread(i)]);
  1083. I.freeze(this);
  1084. }, Object, /*#__PURE__*/I.assocPartialU(iterator, function () {
  1085. return this[PAYLOAD][iterator]();
  1086. }));
  1087. var isVariable = /*#__PURE__*/isInstanceOf(Variable);
  1088. var vars = [];
  1089. function nVars(n) {
  1090. while (vars[LENGTH] < n) {
  1091. vars.push(new Variable(vars[LENGTH]));
  1092. }return vars;
  1093. }
  1094. var isPrimitive = function isPrimitive(x) {
  1095. return x == null || typeof x !== 'object';
  1096. };
  1097. function match1(kinds, i, e, x) {
  1098. if (void 0 !== x) {
  1099. if (i in e) return I.acyclicEqualsU(e[i], x);
  1100. e[i] = x;
  1101. var k = kinds[i];
  1102. return !k || k(x);
  1103. }
  1104. }
  1105. function checkKind(kinds, i, kind) {
  1106. if (0 <= i) {
  1107. if (kinds[i]) {
  1108. if (kinds[i] !== kind) throw Error('Spread patterns must be used consistently either as arrays or as objects.');
  1109. } else {
  1110. kinds[i] = kind;
  1111. }
  1112. }
  1113. }
  1114. var arrayKind = function arrayKind(x) {
  1115. return void 0 === x || I.isArray(x);
  1116. };
  1117. var objectKind = function objectKind(x) {
  1118. return void 0 === x || isInstanceOf(Object);
  1119. };
  1120. function checkPattern(kinds, p) {
  1121. if (isSpread(p)) {
  1122. throw Error('Spread patterns must be inside objects or arrays.');
  1123. } else if (I.isArray(p)) {
  1124. var nSpread = 0;
  1125. for (var i = 0, n = p[LENGTH]; i < n; ++i) {
  1126. var pi = p[i];
  1127. if (isSpread(pi)) {
  1128. if (nSpread++) throw Error('At most one spread is allowed in an array or object.');
  1129. checkKind(kinds, pi[PAYLOAD], arrayKind);
  1130. } else {
  1131. checkPattern(kinds, pi);
  1132. }
  1133. }
  1134. } else if (I.isObject(p)) {
  1135. var spread = p[PAYLOAD];
  1136. if (spread) {
  1137. spread = spread[0][PAYLOAD];
  1138. checkKind(kinds, spread, objectKind);
  1139. }
  1140. var _n = 0;
  1141. for (var k in p) {
  1142. if (isPayload(k)) {
  1143. if (2 < ++_n) throw Error('At most one spread is allowed in an array or object.');
  1144. } else {
  1145. checkPattern(kinds, p[k]);
  1146. }
  1147. }
  1148. } else if (!isPrimitive(p) && !isVariable(p)) {
  1149. throw Error('Only plain arrays and objects are allowed in patterns.');
  1150. }
  1151. }
  1152. var checkPatternInDev = process.env.NODE_ENV === 'production' ? id : function (p) {
  1153. var kinds = [];
  1154. checkPattern(kinds, p);
  1155. return deepFreezeInDev(p);
  1156. };
  1157. var checkPatternPairInDev = process.env.NODE_ENV === 'production' ? id : function (ps) {
  1158. var kinds = [];
  1159. checkPattern(kinds, ps[0]);
  1160. checkPattern(kinds, ps[1]);
  1161. return deepFreezeInDev(ps);
  1162. };
  1163. var setDefined = function setDefined(o, k, x) {
  1164. if (void 0 !== x) o[k] = x;
  1165. };
  1166. var pushDefined = function pushDefined(xs, x) {
  1167. if (void 0 !== x) xs.push(x);
  1168. };
  1169. function toMatch(kinds, p) {
  1170. if (void 0 === p || all1(isPrimitive, leafs, p)) {
  1171. return function (e, x) {
  1172. return I.acyclicEqualsU(p, x);
  1173. };
  1174. } else if (isVariable(p)) {
  1175. var i = p[PAYLOAD][0][PAYLOAD];
  1176. return i < 0 ? id : function (e, x) {
  1177. return match1(kinds, i, e, x);
  1178. };
  1179. } else if (I.isArray(p)) {
  1180. var init = [];
  1181. var rest = [];
  1182. var spread = void 0;
  1183. var n = p[LENGTH];
  1184. for (var _i3 = 0; _i3 < n; ++_i3) {
  1185. var x = p[_i3];
  1186. if (isSpread(x)) {
  1187. spread = x[PAYLOAD];
  1188. kinds[spread] = arrayKind;
  1189. } else {
  1190. var side = void 0 !== spread ? rest : init;
  1191. side.push(toMatch(kinds, x));
  1192. }
  1193. }
  1194. return function (e, x) {
  1195. if (!seemsArrayLike(x)) return;
  1196. var l = x[LENGTH];
  1197. if (void 0 !== spread ? l < n - 1 : l !== n) return;
  1198. var j = init[LENGTH];
  1199. for (var _i4 = 0; _i4 < j; ++_i4) {
  1200. if (!init[_i4](e, x[_i4])) return;
  1201. }var k = rest[LENGTH];
  1202. l -= k;
  1203. for (var _i5 = 0; _i5 < k; ++_i5) {
  1204. if (!rest[_i5](e, x[l + _i5])) return;
  1205. }return !(0 <= spread) || match1(kinds, spread, e, copyToFrom(Array(l - j), 0, x, j, l));
  1206. };
  1207. } else {
  1208. var _spread = p[PAYLOAD];
  1209. if (_spread) {
  1210. _spread = _spread[0][PAYLOAD];
  1211. kinds[_spread] = objectKind;
  1212. }
  1213. p = modify(values, function (p, k) {
  1214. return isPayload(k) ? void 0 : toMatch(kinds, p);
  1215. }, p);
  1216. var _n2 = count(values, p);
  1217. return function (e, x) {
  1218. if (isPrimitive(x) || I.isArray(x)) return;
  1219. x = toObject(x);
  1220. var rest = 0 <= _spread && {};
  1221. var i = 0;
  1222. for (var k in x) {
  1223. var m = p[k];
  1224. if (m) {
  1225. if (!m(e, x[k])) return;
  1226. i++;
  1227. } else if (void 0 !== _spread) {
  1228. if (rest) rest[k] = x[k];
  1229. } else {
  1230. return;
  1231. }
  1232. }
  1233. return i === _n2 && (!rest || match1(kinds, _spread, e, freezeInDev(rest)));
  1234. };
  1235. }
  1236. }
  1237. function toSubst(p, k) {
  1238. if (isPayload(k)) {
  1239. return void 0;
  1240. } else if (void 0 === p || all1(isPrimitive, leafs, p)) {
  1241. return I.always(p);
  1242. } else if (isVariable(p)) {
  1243. var i = p[PAYLOAD][0][PAYLOAD];
  1244. return function (e) {
  1245. return e[i];
  1246. };
  1247. } else if (I.isArray(p)) {
  1248. var init = [];
  1249. var rest = [];
  1250. var spread = void 0;
  1251. var n = p[LENGTH];
  1252. for (var _i6 = 0; _i6 < n; ++_i6) {
  1253. var x = p[_i6];
  1254. if (isSpread(x)) {
  1255. spread = x[PAYLOAD];
  1256. } else {
  1257. var side = void 0 !== spread ? rest : init;
  1258. side.push(toSubst(x));
  1259. }
  1260. }
  1261. return freezeResultInDev(function (e) {
  1262. var r = [];
  1263. for (var _i7 = 0, _n3 = init[LENGTH]; _i7 < _n3; ++_i7) {
  1264. pushDefined(r, init[_i7](e));
  1265. }if (0 <= spread) {
  1266. var xs = e[spread];
  1267. if (xs) for (var _i8 = 0, _n4 = xs[LENGTH]; _i8 < _n4; ++_i8) {
  1268. pushDefined(r, xs[_i8]);
  1269. }
  1270. }
  1271. for (var _i9 = 0, _n5 = rest[LENGTH]; _i9 < _n5; ++_i9) {
  1272. pushDefined(r, rest[_i9](e));
  1273. }return r;
  1274. });
  1275. } else {
  1276. var _spread2 = p[PAYLOAD];
  1277. if (_spread2) _spread2 = _spread2[0][PAYLOAD];
  1278. p = modify(values, toSubst, p);
  1279. return freezeResultInDev(function (e) {
  1280. var r = {};
  1281. for (var _k5 in p) {
  1282. setDefined(r, _k5, p[_k5](e));
  1283. }if (0 <= _spread2) {
  1284. var _x4 = e[_spread2];
  1285. if (_x4) for (var _k6 in _x4) {
  1286. setDefined(r, _k6, _x4[_k6]);
  1287. }
  1288. }
  1289. return r;
  1290. });
  1291. }
  1292. }
  1293. var oneway = function oneway(n, m, s) {
  1294. return function (x) {
  1295. var e = Array(n);
  1296. if (m(e, x)) return s(e);
  1297. };
  1298. };
  1299. //
  1300. var ungroupByFn = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(res(I.freeze)))(function (keyOf) {
  1301. return function ungroupBy(xxs) {
  1302. if (I.isArray(xxs)) {
  1303. var ys = [];
  1304. for (var i = 0, n = xxs.length; i < n; ++i) {
  1305. var xs = xxs[i];
  1306. if (!I.isArray(xs)) return;
  1307. var m = xs.length;
  1308. if (!m) return;
  1309. var k = keyOf(xs[0]);
  1310. if (void 0 === k) return;
  1311. for (var j = 0, _m = xs.length; j < _m; ++j) {
  1312. var x = xs[j];
  1313. if (!I.identicalU(k, keyOf(x))) return;
  1314. ys.push(x);
  1315. }
  1316. }
  1317. return ys;
  1318. }
  1319. };
  1320. });
  1321. var groupByFn = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(res(freezeObjectOfObjects)))(function (keyOf) {
  1322. return function groupBy(ys) {
  1323. if (I.isArray(ys)) {
  1324. var groups = new Map();
  1325. for (var i = 0, n = ys.length; i < n; ++i) {
  1326. var y = ys[i];
  1327. var k = keyOf(y);
  1328. if (void 0 === k) return;
  1329. var xs = groups.get(k);
  1330. if (void 0 !== xs) {
  1331. xs.push(y);
  1332. } else {
  1333. groups.set(k, [y]);
  1334. }
  1335. }
  1336. var xxs = [];
  1337. groups.forEach(function (xs) {
  1338. return xxs.push(xs);
  1339. });
  1340. return xxs;
  1341. }
  1342. };
  1343. });
  1344. //
  1345. var zW1Fn = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(res(I.freeze)))(function (fn$$1) {
  1346. return function zipWith1(xys) {
  1347. if (isPair(xys)) {
  1348. var ys = xys[1];
  1349. var n = ys[LENGTH];
  1350. if (n) {
  1351. var x = xys[0];
  1352. var zs = Array(n);
  1353. for (var i = 0; i < n; ++i) {
  1354. if (void 0 === (zs[i] = fn$$1([x, ys[i]]))) return;
  1355. }return zs;
  1356. }
  1357. }
  1358. };
  1359. });
  1360. var unzW1Fn = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(res(freezeObjectOfObjects)))(function (fn$$1) {
  1361. return function unzipWith1(zs) {
  1362. if (I.isArray(zs)) {
  1363. var n = zs[LENGTH];
  1364. if (n) {
  1365. var xy0 = fn$$1(zs[0]);
  1366. if (isPair(xy0)) {
  1367. var ys = Array(n);
  1368. var x = xy0[0];
  1369. ys[0] = xy0[1];
  1370. for (var i = 1; i < n; ++i) {
  1371. var xy = fn$$1(zs[i]);
  1372. if (!isPair(xy) || !I.acyclicEqualsU(x, xy[0])) return;
  1373. ys[i] = xy[1];
  1374. }
  1375. return [x, ys];
  1376. }
  1377. }
  1378. }
  1379. };
  1380. });
  1381. // Auxiliary
  1382. var seemsArrayLike = function seemsArrayLike(x) {
  1383. return x instanceof Object && (x = x[LENGTH], x === x >> 0 && 0 <= x) || I.isString(x);
  1384. };
  1385. var Select = /*#__PURE__*/ConstantWith(function (l, r) {
  1386. return void 0 !== l ? l : r;
  1387. });
  1388. var toFunction = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : par(0, ef(reqOptic)))(function toFunction(o) {
  1389. switch (typeof o) {
  1390. case 'string':
  1391. return funProp(o);
  1392. case 'number':
  1393. return funIndex(o);
  1394. case 'object':
  1395. return composed(0, o);
  1396. default:
  1397. return o[LENGTH] === 4 ? o : fromReader(o);
  1398. }
  1399. });
  1400. // Operations on optics
  1401. var assign = /*#__PURE__*/I.curry(function assign(o, x, s) {
  1402. return setU([o, assignTo], x, s);
  1403. });
  1404. var disperse = /*#__PURE__*/I.curry(disperseU);
  1405. var modify = /*#__PURE__*/I.curry(modifyU);
  1406. var modifyAsync = /*#__PURE__*/I.curry(modifyAsyncU);
  1407. var remove = /*#__PURE__*/I.curry(function remove(o, s) {
  1408. return setU(o, void 0, s);
  1409. });
  1410. var set = /*#__PURE__*/I.curry(setU);
  1411. var traverse = /*#__PURE__*/I.curry(traverseU);
  1412. // Nesting
  1413. function compose() {
  1414. var n = arguments[LENGTH];
  1415. if (n < 2) {
  1416. return n ? arguments[0] : identity;
  1417. } else {
  1418. var os = Array(n);
  1419. while (n--) {
  1420. os[n] = arguments[n];
  1421. }return os;
  1422. }
  1423. }
  1424. function flat() {
  1425. var r = [flatten];
  1426. for (var i = 0, n = arguments[LENGTH]; i < n; ++i) {
  1427. r.push(arguments[i], flatten);
  1428. }return r;
  1429. }
  1430. // Recursing
  1431. function lazy(o2o) {
  1432. var _memo = function memo(x, i, C, xi2yC) {
  1433. return (_memo = toFunction(o2o(rec)))(x, i, C, xi2yC);
  1434. };
  1435. function rec(x, i, C, xi2yC) {
  1436. return _memo(x, i, C, xi2yC);
  1437. }
  1438. return rec;
  1439. }
  1440. // Adapting
  1441. var choices = /*#__PURE__*/makeSemi(orElseU);
  1442. var choose = function choose(xiM2o) {
  1443. return copyName(function (x, i, C, xi2yC) {
  1444. return toFunction(xiM2o(x, i))(x, i, C, xi2yC);
  1445. }, xiM2o);
  1446. };
  1447. var cond = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : function (fn$$1) {
  1448. return function cond() {
  1449. var pair = tup(ef(reqFn), ef(reqOptic));
  1450. for (var _len = arguments.length, cs = Array(_len), _key = 0; _key < _len; _key++) {
  1451. cs[_key] = arguments[_key];
  1452. }
  1453. arr(pair)(cs.slice(0, -1));
  1454. arr(or(tup(ef(reqOptic)), pair))(cs.slice(-1));
  1455. return fn$$1.apply(undefined, cs);
  1456. };
  1457. })(function cond() {
  1458. var n = arguments[LENGTH];
  1459. var r = zero;
  1460. while (n--) {
  1461. var c = arguments[n];
  1462. r = c[LENGTH] < 2 ? toFunction(c[0]) : eitherU(toFunction(c[1]), r)(c[0]);
  1463. }
  1464. return r;
  1465. });
  1466. var condOf = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : function (fn$$1) {
  1467. return function condOf(of) {
  1468. var pair = tup(ef(reqFn), ef(reqOptic));
  1469. for (var _len2 = arguments.length, cs = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  1470. cs[_key2 - 1] = arguments[_key2];
  1471. }
  1472. arr(pair)(cs.slice(0, -1));
  1473. arr(or(tup(ef(reqOptic)), pair))(cs.slice(-1));
  1474. return fn$$1.apply(undefined, [of].concat(cs));
  1475. };
  1476. })(function condOf(of) {
  1477. of = toFunction(of);
  1478. var n = arguments[LENGTH] - 1;
  1479. if (!n) return zero;
  1480. var def = arguments[n];
  1481. if (def[LENGTH] === 1) {
  1482. --n;
  1483. def = toFunction(def[0]);
  1484. } else {
  1485. def = zero;
  1486. }
  1487. var ps = Array(n);
  1488. var os = Array(n + 1);
  1489. for (var i = 0; i < n; ++i) {
  1490. var c = arguments[i + 1];
  1491. ps[i] = c[0];
  1492. os[i] = toFunction(c[1]);
  1493. }
  1494. os[n] = def;
  1495. return function condOf(x, i, F, xi2yF) {
  1496. var min = n;
  1497. of(x, i, Select, function (y, j) {
  1498. for (var _i10 = 0; _i10 < min; ++_i10) {
  1499. if (ps[_i10](y, j)) {
  1500. min = _i10;
  1501. if (_i10 === 0) return 0;else break;
  1502. }
  1503. }
  1504. });
  1505. return os[min](x, i, F, xi2yF);
  1506. };
  1507. });
  1508. var ifElse = /*#__PURE__*/I.curry(function ifElse(c, t, e) {
  1509. return eitherU(toFunction(t), toFunction(e))(c);
  1510. });
  1511. var orElse = /*#__PURE__*/I.curry(orElseU);
  1512. // Querying
  1513. var chain = /*#__PURE__*/I.curry(function chain(xi2yO, xO) {
  1514. return [xO, choose(function (xM, i) {
  1515. return void 0 !== xM ? xi2yO(xM, i) : zero;
  1516. })];
  1517. });
  1518. var choice = function choice() {
  1519. for (var _len3 = arguments.length, os = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1520. os[_key3] = arguments[_key3];
  1521. }
  1522. return os.reduceRight(orElseU, zero);
  1523. };
  1524. var unless = /*#__PURE__*/eitherU(zero, identity);
  1525. var when = /*#__PURE__*/eitherU(identity, zero);
  1526. var optional = /*#__PURE__*/when(I.isDefined);
  1527. // Indices
  1528. var mapIx = function mapIx(ix2j) {
  1529. return function mapIx(x, i, F, xj2yF) {
  1530. return xj2yF(x, ix2j(i, x));
  1531. };
  1532. };
  1533. var setIx = function setIx(j) {
  1534. return function setIx(x, _i, _F, xj2yF) {
  1535. return xj2yF(x, j);
  1536. };
  1537. };
  1538. var tieIx = /*#__PURE__*/I.curry(function tieIx(ij2k, o) {
  1539. o = toFunction(o);
  1540. return copyName(function (x, i, F, yk2zF) {
  1541. return o(x, i, F, function (y, j) {
  1542. return yk2zF(y, ij2k(j, i));
  1543. });
  1544. }, o);
  1545. });
  1546. var joinIx = /*#__PURE__*/setName( /*#__PURE__*/tieIx(function (j, i) {
  1547. return void 0 !== i ? void 0 !== j ? [i, j] : i : j;
  1548. }), 'joinIx');
  1549. var reIx = function reIx(o) {
  1550. o = toFunction(o);
  1551. return copyName(function (x, i, F, xi2yF) {
  1552. var j = 0;
  1553. return o(x, i, F, function (x) {
  1554. return xi2yF(x, j++);
  1555. });
  1556. }, o);
  1557. };
  1558. var skipIx = /*#__PURE__*/setName( /*#__PURE__*/tieIx(I.sndU), 'skipIx');
  1559. // Debugging
  1560. function getLog(l, s) {
  1561. var _traverseU = traverseU(SelectLog, function (x) {
  1562. return { p: [x, consExcept], x: x, c: x };
  1563. }, l, s),
  1564. p = _traverseU.p,
  1565. c = _traverseU.c;
  1566. p = pushTo(p, ['%O']);
  1567. for (var i = 2; i < p[LENGTH]; ++i) {
  1568. p[0] += ' <= %O';
  1569. }console.log.apply(console, p);
  1570. return c;
  1571. }
  1572. function log() {
  1573. var show = I.curry(function log(dir, x) {
  1574. console.log.apply(console, copyToFrom([], 0, arguments, 0, arguments[LENGTH]).concat([dir, x]));
  1575. return x;
  1576. });
  1577. return isoU(show('get'), show('set'));
  1578. }
  1579. // Operations on transforms
  1580. var transform = /*#__PURE__*/I.curry(function transform(o, s) {
  1581. return modifyU(o, id, s);
  1582. });
  1583. var transformAsync = /*#__PURE__*/I.curry(function transformAsync(o, s) {
  1584. return modifyAsyncU(o, id, s);
  1585. });
  1586. // Sequencing
  1587. var seq = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : function (fn$$1) {
  1588. return function seq() {
  1589. return par(2, ef(reqMonad('seq')))(fn$$1.apply(undefined, arguments));
  1590. };
  1591. })(function seq() {
  1592. var n = arguments[LENGTH];
  1593. var r = zero;
  1594. if (n) {
  1595. r = toFunction(arguments[--n]);
  1596. while (n) {
  1597. r = seq2U(toFunction(arguments[--n]), r);
  1598. }
  1599. }
  1600. return r;
  1601. });
  1602. // Creating new traversals
  1603. var branchOr = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : par(1, ef(reqTemplate('branchOr'))))( /*#__PURE__*/I.curryN(2, function branchOr(otherwise) {
  1604. otherwise = toFunction(otherwise);
  1605. return function branchOr(template) {
  1606. return branchOrU(otherwise, template);
  1607. };
  1608. }));
  1609. var branch = /*#__PURE__*/branchOr(zero);
  1610. function branches() {
  1611. var n = arguments[LENGTH];
  1612. var template = {};
  1613. for (var i = 0; i < n; ++i) {
  1614. template[arguments[i]] = identity;
  1615. }return branch(template);
  1616. }
  1617. // Traversals and combinators
  1618. function elems(xs, i, A, xi2yA) {
  1619. return seemsArrayLike(xs) ? elemsI(xs, i, A, xi2yA) : A.of(xs);
  1620. }
  1621. var elemsTotal = function elemsTotal(xs, i, A, xi2yA) {
  1622. return seemsArrayLike(xs) ? A === I.Identity ? mapPartialIndexU(xi2yA, xs, mapPartialIndexU) : A === Select ? selectInArrayLike(xi2yA, xs) : traversePartialIndex(A, xi2yA, xs, traversePartialIndex) : A.of(xs);
  1623. };
  1624. var entries = /*#__PURE__*/setName( /*#__PURE__*/toFunction([keyed, elems]), 'entries');
  1625. var keys = /*#__PURE__*/setName( /*#__PURE__*/toFunction([keyed, elems, 0]), 'keys');
  1626. var keysEverywhere = function keysEverywhere(x, i, A, xi2yA) {
  1627. var recEntry = function recEntry(kv, i) {
  1628. return A.ap(A.map(pairPartial, xi2yA(kv[0], i)), recAny(kv[1], i));
  1629. };
  1630. var recAny = function recAny(x, i) {
  1631. return I.isArray(x) ? elemsI(x, i, A, recAny) : I.isObject(x) ? entries(x, i, A, recEntry) : A.of(x);
  1632. };
  1633. return recAny(x, i);
  1634. };
  1635. var subseq = /*#__PURE__*/I.curry(subseqU);
  1636. var limit = /*#__PURE__*/subseq(0);
  1637. var offset = /*#__PURE__*/I.curry(function offset(begin, t) {
  1638. return subseqU(begin, void 0, t);
  1639. });
  1640. function matches(re) {
  1641. return function matches(x, _i, C, xi2yC) {
  1642. if (I.isString(x)) {
  1643. var map = C.map;
  1644. if (re.global) {
  1645. var m0 = [''];
  1646. m0.input = x;
  1647. m0[INDEX] = 0;
  1648. if (Select === C) {
  1649. return iterSelect(xi2yC, re, m0);
  1650. } else {
  1651. var ap = C.ap,
  1652. of = C.of;
  1653. return map(matchesJoin(x), iterEager(map, ap, of, xi2yC, re, m0));
  1654. }
  1655. } else {
  1656. var m = x.match(re);
  1657. if (m) return map(function (y) {
  1658. return x.replace(re, void 0 !== y ? y : '');
  1659. }, xi2yC(m[0], m[INDEX]));
  1660. }
  1661. }
  1662. return C.of(x);
  1663. };
  1664. }
  1665. var values = /*#__PURE__*/setName( /*#__PURE__*/branchOr1Level(identity, protoless0), 'values');
  1666. function children(x, i, C, xi2yC) {
  1667. return I.isArray(x) ? elemsI(x, i, C, xi2yC) : I.isObject(x) ? values(x, i, C, xi2yC) : C.of(x);
  1668. }
  1669. function flatten(x, i, C, xi2yC) {
  1670. var rec = function rec(x, i) {
  1671. return I.isArray(x) ? elemsI(x, i, C, rec) : void 0 !== x ? xi2yC(x, i) : C.of(x);
  1672. };
  1673. return rec(x, i);
  1674. }
  1675. function query() {
  1676. var r = [];
  1677. for (var i = 0, n = arguments[LENGTH]; i < n; ++i) {
  1678. var o = toFunction(arguments[i]);
  1679. r.push(satisfying(isDefinedAt(o)), o);
  1680. }
  1681. return r;
  1682. }
  1683. var satisfying = function satisfying(p) {
  1684. return function satisfying(x, i, C, xi2yC) {
  1685. var rec = function rec(x, i) {
  1686. return p(x, i) ? xi2yC(x, i) : children(x, i, C, rec);
  1687. };
  1688. return rec(x, i);
  1689. };
  1690. };
  1691. var leafs = /*#__PURE__*/satisfying(function (x) {
  1692. return void 0 !== x && !I.isArray(x) && !I.isObject(x);
  1693. });
  1694. var whereEq = function whereEq(template) {
  1695. return satisfying(and$1(branch(modify(leafs, is, template))));
  1696. };
  1697. // Folds over traversals
  1698. var all = /*#__PURE__*/I.curry(function all(xi2b, t, s) {
  1699. return !getAsU(function (x, i) {
  1700. if (!xi2b(x, i)) return true;
  1701. }, t, s);
  1702. });
  1703. var and$1 = /*#__PURE__*/all(id);
  1704. var all1 = /*#__PURE__*/I.curry(function all1(xi2b, t, s) {
  1705. var result = false;
  1706. getAsU(function (x, i) {
  1707. if (xi2b(x, i)) result = true;else return result = false;
  1708. }, t, s);
  1709. return result;
  1710. });
  1711. var and1 = /*#__PURE__*/all1(id);
  1712. var any = /*#__PURE__*/I.curry(function any(xi2b, t, s) {
  1713. return !!getAsU(function (x, i) {
  1714. if (xi2b(x, i)) return true;
  1715. }, t, s);
  1716. });
  1717. var collectAs = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? I.curry : res(I.freeze))(function collectAs(xi2y, t, s) {
  1718. var results = [];
  1719. getAsU(function (x, i) {
  1720. var y = xi2y(x, i);
  1721. if (void 0 !== y) results.push(y);
  1722. }, t, s);
  1723. return results;
  1724. });
  1725. var collect = /*#__PURE__*/collectAs(id);
  1726. var collectTotalAs = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? I.curry : res(I.freeze))(function collectTotalAs(xi2y, t, s) {
  1727. var results = [];
  1728. getAsU(function (x, i) {
  1729. results.push(xi2y(x, i));
  1730. }, t, s);
  1731. return results;
  1732. });
  1733. var collectTotal = /*#__PURE__*/collectTotalAs(id);
  1734. var concatAs = /*#__PURE__*/mkTraverse(id, ConstantOf);
  1735. var concat = /*#__PURE__*/concatAs(id);
  1736. var countIf = /*#__PURE__*/I.curry(function countIf(p, t, s) {
  1737. return traverseU(Sum, function (x, i) {
  1738. return p(x, i) ? 1 : 0;
  1739. }, t, s);
  1740. });
  1741. var count = /*#__PURE__*/countIf(I.isDefined);
  1742. var countsAs = /*#__PURE__*/I.curry(function countsAs(xi2k, t, s) {
  1743. var counts = new Map();
  1744. getAsU(function (x, i) {
  1745. var k = xi2k(x, i);
  1746. var n = counts.get(k);
  1747. counts.set(k, void 0 !== n ? n + 1 : 1);
  1748. }, t, s);
  1749. return counts;
  1750. });
  1751. var counts = /*#__PURE__*/countsAs(id);
  1752. var foldl = /*#__PURE__*/I.curry(function foldl(f, r, t, s) {
  1753. getAsU(function (x, i) {
  1754. r = f(r, x, i);
  1755. }, t, s);
  1756. return r;
  1757. });
  1758. var foldr = /*#__PURE__*/I.curry(function foldr(f, r, t, s) {
  1759. var is = [];
  1760. var xs = [];
  1761. getAsU(function (x, i) {
  1762. xs.push(x);
  1763. is.push(i);
  1764. }, t, s);
  1765. for (var i = xs[LENGTH] - 1; 0 <= i; --i) {
  1766. r = f(r, xs[i], is[i]);
  1767. }return r;
  1768. });
  1769. var forEach = /*#__PURE__*/I.curry(function forEach(f, t, s) {
  1770. return getAsU(function (x, i) {
  1771. f(x, i);
  1772. }, t, s);
  1773. });
  1774. var forEachWith = /*#__PURE__*/I.curry(function forEachWith(newC, ef$$1, t, s) {
  1775. var c = newC();
  1776. getAsU(function (x, i) {
  1777. ef$$1(c, x, i);
  1778. }, t, s);
  1779. return c;
  1780. });
  1781. function get(l, s) {
  1782. return 1 < arguments[LENGTH] ? getAsU(id, l, s) : function (s) {
  1783. return getAsU(id, l, s);
  1784. };
  1785. }
  1786. var getAs = /*#__PURE__*/I.curry(getAsU);
  1787. var isDefined = /*#__PURE__*/I.curry(function isDefined(t, s) {
  1788. return void 0 !== getAsU(id, t, s);
  1789. });
  1790. var isEmpty = /*#__PURE__*/I.curry(function isEmpty(t, s) {
  1791. return !getAsU(toTrue, t, s);
  1792. });
  1793. var joinAs = /*#__PURE__*/mkTraverse(toStringPartial, /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : par(0, ef(reqString('`join` and `joinAs` expect a string delimiter'))))(function joinAs(d) {
  1794. return ConstantWith(function (x, y) {
  1795. return void 0 !== x ? void 0 !== y ? x + d + y : x : y;
  1796. });
  1797. }));
  1798. var join = /*#__PURE__*/joinAs(id);
  1799. var maximumBy = /*#__PURE__*/mumBy(gtU);
  1800. var maximum = /*#__PURE__*/maximumBy(id);
  1801. var meanAs = /*#__PURE__*/I.curry(function meanAs(xi2y, t, s) {
  1802. var sum = 0;
  1803. var num = 0;
  1804. getAsU(function (x, i) {
  1805. var y = xi2y(x, i);
  1806. if (void 0 !== y) {
  1807. num += 1;
  1808. sum += y;
  1809. }
  1810. }, t, s);
  1811. return sum / num;
  1812. });
  1813. var mean = /*#__PURE__*/meanAs(id);
  1814. var minimumBy = /*#__PURE__*/mumBy(ltU);
  1815. var minimum = /*#__PURE__*/minimumBy(id);
  1816. var none = /*#__PURE__*/I.curry(function none(xi2b, t, s) {
  1817. return !getAsU(function (x, i) {
  1818. if (xi2b(x, i)) return true;
  1819. }, t, s);
  1820. });
  1821. var or$1 = /*#__PURE__*/any(id);
  1822. var productAs = /*#__PURE__*/traverse( /*#__PURE__*/ConstantWith(multiplyU, 1));
  1823. var product = /*#__PURE__*/productAs( /*#__PURE__*/unto(1));
  1824. var select = process.env.NODE_ENV === 'production' ? get : /*#__PURE__*/I.curry(function select(l, s) {
  1825. warn(select, '`select` has been obsoleted. Just use `get`. See CHANGELOG for details.');
  1826. return get(l, s);
  1827. });
  1828. var selectAs = process.env.NODE_ENV === 'production' ? getAs : /*#__PURE__*/I.curry(function selectAs(f, l, s) {
  1829. warn(selectAs, '`selectAs` has been obsoleted. Just use `getAs`. See CHANGELOG for details.');
  1830. return getAs(f, l, s);
  1831. });
  1832. var sumAs = /*#__PURE__*/traverse(Sum);
  1833. var sum = /*#__PURE__*/sumAs(unto0);
  1834. // Creating new lenses
  1835. var foldTraversalLens = /*#__PURE__*/I.curry(function foldTraversalLens(fold, traversal) {
  1836. return lensU(fold(traversal), set(traversal));
  1837. });
  1838. var getter = function getter(get) {
  1839. return function (x, i, F, xi2yF) {
  1840. return xi2yF(get(x, i), i);
  1841. };
  1842. };
  1843. var lens = /*#__PURE__*/I.curry(lensU);
  1844. function partsOf(t) {
  1845. if (arguments[LENGTH] !== 1) t = toFunction(compose.apply(null, arguments));
  1846. return function partsOf(x, i, F, xi2yF) {
  1847. return F.map(function (y) {
  1848. return disperseU(t, y, x);
  1849. }, xi2yF(collectTotal(t, x), i));
  1850. };
  1851. }
  1852. var setter = /*#__PURE__*/lens(id);
  1853. // Enforcing invariants
  1854. function defaults(out) {
  1855. function o2u(x) {
  1856. return replaced(out, void 0, x);
  1857. }
  1858. return function defaults(x, i, F, xi2yF) {
  1859. return F.map(o2u, xi2yF(void 0 !== x ? x : out, i));
  1860. };
  1861. }
  1862. function define(v) {
  1863. var untoV = unto(v);
  1864. return function define(x, i, F, xi2yF) {
  1865. return F.map(untoV, xi2yF(void 0 !== x ? x : v, i));
  1866. };
  1867. }
  1868. var normalize = function normalize(xi2x) {
  1869. return [reread(xi2x), rewrite(xi2x)];
  1870. };
  1871. function required(inn) {
  1872. return replace$1(inn, void 0);
  1873. }
  1874. var reread = function reread(xi2x) {
  1875. return function (x, i, _F, xi2yF) {
  1876. return xi2yF(void 0 !== x ? xi2x(x, i) : x, i);
  1877. };
  1878. };
  1879. var rewrite = function rewrite(yi2y) {
  1880. return function (x, i, F, xi2yF) {
  1881. return F.map(function (y) {
  1882. return void 0 !== y ? yi2y(y, i) : y;
  1883. }, xi2yF(x, i));
  1884. };
  1885. };
  1886. // Lensing arrays
  1887. var filter = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(function (lens) {
  1888. return toFunction([lens, isoU(id, ef(reqMaybeArray('`filter` must be set with undefined or an array-like object')))]);
  1889. }))(function filter(xi2b) {
  1890. return function filter(xs, i, F, xi2yF) {
  1891. var ts = void 0;
  1892. var fs = I.array0;
  1893. if (seemsArrayLike(xs)) partitionIntoIndex(xi2b, xs, ts = [], fs = []);
  1894. return F.map(function (ts) {
  1895. var tsN = ts ? ts[LENGTH] : 0;
  1896. var fsN = fs[LENGTH];
  1897. var n = tsN + fsN;
  1898. return n === fsN ? fs : copyToFrom(copyToFrom(Array(n), 0, ts, 0, tsN), tsN, fs, 0, fsN);
  1899. }, xi2yF(ts, i));
  1900. };
  1901. });
  1902. function find(xih2b) {
  1903. var hint = arguments[LENGTH] > 1 ? arguments[1] : { hint: 0 };
  1904. return function find(xs, _i, F, xi2yF) {
  1905. var ys = seemsArrayLike(xs) ? xs : '';
  1906. var i = hint.hint = findIndexHint(hint, xih2b, ys);
  1907. return F.map(function (v) {
  1908. return setIndex(i, v, ys);
  1909. }, xi2yF(ys[i], i));
  1910. };
  1911. }
  1912. function findWith(o) {
  1913. var oo = toFunction(o);
  1914. var p = isDefinedAt(oo);
  1915. return [arguments[LENGTH] > 1 ? find(p, arguments[1]) : find(p), oo];
  1916. }
  1917. var first = 0;
  1918. var index = process.env.NODE_ENV !== 'production' ? /*#__PURE__*/ef(reqIndex) : id;
  1919. var last = /*#__PURE__*/choose(function last(maybeArray) {
  1920. return seemsArrayLike(maybeArray) && maybeArray[LENGTH] ? maybeArray[LENGTH] - 1 : 0;
  1921. });
  1922. var prefix = function prefix(n) {
  1923. return slice(0, n);
  1924. };
  1925. var slice = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? I.curry : res(function (lens) {
  1926. return toFunction([lens, isoU(id, ef(reqMaybeArray('`slice` must be set with undefined or an array-like object')))]);
  1927. }))(function slice(begin, end) {
  1928. return function slice(xs, i, F, xsi2yF) {
  1929. var seems = seemsArrayLike(xs);
  1930. var xsN = seems && xs[LENGTH];
  1931. var b = sliceIndex(0, xsN, 0, begin);
  1932. var e = sliceIndex(b, xsN, xsN, end);
  1933. return F.map(function (zs) {
  1934. var zsN = zs ? zs[LENGTH] : 0;
  1935. var bPzsN = b + zsN;
  1936. var n = xsN - e + bPzsN;
  1937. return copyToFrom(copyToFrom(copyToFrom(Array(n), 0, xs, 0, b), b, zs, 0, zsN), bPzsN, xs, e, xsN);
  1938. }, xsi2yF(seems ? copyToFrom(Array(Math.max(0, e - b)), 0, xs, b, e) : void 0, i));
  1939. };
  1940. });
  1941. var suffix = function suffix(n) {
  1942. return slice(0 === n ? Infinity : !n ? 0 : -n, void 0);
  1943. };
  1944. // Lensing objects
  1945. var pickIn = function pickIn(t) {
  1946. return I.isObject(t) ? pick(modify(values, pickInAux, t)) : t;
  1947. };
  1948. var prop = process.env.NODE_ENV === 'production' ? id : function (x) {
  1949. if (!I.isString(x)) errorGiven('`prop` expects a string', x);
  1950. return x;
  1951. };
  1952. function props() {
  1953. var n = arguments[LENGTH];
  1954. var template = {};
  1955. for (var i = 0, k; i < n; ++i) {
  1956. template[k = arguments[i]] = k;
  1957. }return pick(template);
  1958. }
  1959. function propsExcept() {
  1960. var setish = I.create(null);
  1961. for (var i = 0, n = arguments[LENGTH]; i < n; ++i) {
  1962. setish[arguments[i]] = 'd';
  1963. }return [disjoint(function (k) {
  1964. return setish[k] || 't';
  1965. }), 't'];
  1966. }
  1967. var propsOf = function propsOf(o) {
  1968. warn(propsOf, '`propsOf` has been deprecated and there is no replacement. See CHANGELOG for details.');
  1969. return props.apply(null, I.keys(o));
  1970. };
  1971. function removable() {
  1972. for (var _len4 = arguments.length, ps = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  1973. ps[_key4] = arguments[_key4];
  1974. }
  1975. function drop(y) {
  1976. if (!(y instanceof Object)) return y;
  1977. for (var i = 0, n = ps[LENGTH]; i < n; ++i) {
  1978. if (I.hasU(ps[i], y)) return y;
  1979. }
  1980. }
  1981. return function (x, i, F, xi2yF) {
  1982. return F.map(drop, xi2yF(x, i));
  1983. };
  1984. }
  1985. // Providing defaults
  1986. var valueOr = function valueOr(v) {
  1987. return function (x, i, _F, xi2yF) {
  1988. return xi2yF(x != null ? x : v, i);
  1989. };
  1990. };
  1991. // Transforming data
  1992. var pick = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : par(0, ef(reqTemplate('pick'))))(function pick(template) {
  1993. return function (x, i, F, xi2yF) {
  1994. return F.map(function (v) {
  1995. return setPick(template, v, x);
  1996. }, xi2yF(getPick(template, x), i));
  1997. };
  1998. });
  1999. var replace$1 = /*#__PURE__*/I.curry(function replace$$1(inn, out) {
  2000. function o2i(x) {
  2001. return replaced(out, inn, x);
  2002. }
  2003. return function replace$$1(x, i, F, xi2yF) {
  2004. return F.map(o2i, xi2yF(replaced(inn, out, x), i));
  2005. };
  2006. });
  2007. // Inserters
  2008. function appendTo(xs, _, F, xi2yF) {
  2009. var i = seemsArrayLike(xs) ? xs[LENGTH] : 0;
  2010. return F.map(function (x) {
  2011. return setIndex(i, x, xs);
  2012. }, xi2yF(void 0, i));
  2013. }
  2014. var append = process.env.NODE_ENV === 'production' ? appendTo : function append(x, i, F, xi2yF) {
  2015. warn(append, '`append` has been renamed to `appendTo`. See CHANGELOG for details.');
  2016. return appendTo(x, i, F, xi2yF);
  2017. };
  2018. var assignTo = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : function (iso) {
  2019. return copyName(toFunction([isoU(id, I.freeze), iso]), iso);
  2020. })(function assignTo(x, i, F, xi2yF) {
  2021. return F.map(function (y) {
  2022. return I.assign({}, x instanceof Object ? x : null, y);
  2023. }, xi2yF(void 0, i));
  2024. });
  2025. var prependTo = /*#__PURE__*/setName( /*#__PURE__*/toFunction([/*#__PURE__*/prefix(0), 0]), 'prependTo');
  2026. // Transforming
  2027. var appendOp = /*#__PURE__*/setName( /*#__PURE__*/inserterOp(appendTo), 'appendOp');
  2028. var assignOp = /*#__PURE__*/setName( /*#__PURE__*/inserterOp(assignTo), 'assignOp');
  2029. var modifyOp = function modifyOp(xi2y) {
  2030. return function modifyOp(x, i, C, _xi2yC) {
  2031. return C.of(xi2y(x, i));
  2032. };
  2033. };
  2034. var prependOp = /*#__PURE__*/setName( /*#__PURE__*/inserterOp(prependTo), 'prependOp');
  2035. var setOp = function setOp(y) {
  2036. return function setOp(_x, _i, C, _xi2yC) {
  2037. return C.of(y);
  2038. };
  2039. };
  2040. var removeOp = /*#__PURE__*/setOp();
  2041. var cross = /*#__PURE__*/setName( /*#__PURE__*/crossOr(removeOp), 'cross');
  2042. // Operations on isomorphisms
  2043. function getInverse(o, s) {
  2044. return 1 < arguments[LENGTH] ? getInverseU(o, s) : function (s) {
  2045. return getInverseU(o, s);
  2046. };
  2047. }
  2048. // Creating new isomorphisms
  2049. var iso = /*#__PURE__*/I.curry(isoU);
  2050. var _ = /*#__PURE__*/new Variable(-1);
  2051. function mapping(ps) {
  2052. var n = 0;
  2053. if (I.isFunction(ps)) ps = ps.apply(null, nVars(n = ps[LENGTH]));
  2054. checkPatternPairInDev(ps);
  2055. var kinds = Array(n);
  2056. var ms = ps.map(function (p) {
  2057. return toMatch(kinds, p);
  2058. });
  2059. var ss = ps.map(toSubst);
  2060. return isoU(oneway(n, ms[0], ss[1]), oneway(n, ms[1], ss[0]));
  2061. }
  2062. function mappings(ps) {
  2063. if (I.isFunction(ps)) ps = ps.apply(null, nVars(ps[LENGTH]));
  2064. return alternatives.apply(null, ps.map(mapping));
  2065. }
  2066. function pattern(p) {
  2067. var n = 0;
  2068. if (I.isFunction(p)) p = p.apply(null, nVars(n = p[LENGTH]));
  2069. checkPatternInDev(p);
  2070. var kinds = Array(n);
  2071. var m = toMatch(kinds, p);
  2072. return subset(function (x) {
  2073. return m(Array(n), x);
  2074. });
  2075. }
  2076. function patterns(ps) {
  2077. if (I.isFunction(ps)) ps = ps.apply(null, nVars(ps[LENGTH]));
  2078. return alternatives.apply(null, ps.map(pattern));
  2079. }
  2080. // Isomorphism combinators
  2081. var alternatives = /*#__PURE__*/makeSemi(orAlternativelyU);
  2082. var applyAt = /*#__PURE__*/I.curry(function applyAt(elements, transform) {
  2083. return isoU(modify(elements, get(transform)), modify(elements, getInverse(transform)));
  2084. });
  2085. var attemptEveryDown = function attemptEveryDown(iso) {
  2086. return isoU(transformEvery(rereadAttempt(get(iso))), transformEvery(rewriteAttempt(getInverse(iso))));
  2087. };
  2088. var attemptEveryUp = function attemptEveryUp(iso) {
  2089. return isoU(transformEvery(rewriteAttempt(get(iso))), transformEvery(rereadAttempt(getInverse(iso))));
  2090. };
  2091. var attemptSomeDown = function attemptSomeDown(iso) {
  2092. return isoU(transformSome(get(iso)), transformSome(getInverse(iso)));
  2093. };
  2094. var conjugate = /*#__PURE__*/I.curry(function conjugate(outer, inner) {
  2095. return [outer, inner, inverse(outer)];
  2096. });
  2097. var inverse = function inverse(iso) {
  2098. return function (x, i, F, xi2yF) {
  2099. return F.map(function (x) {
  2100. return getAsU(id, iso, x);
  2101. }, xi2yF(setU(iso, x, void 0), i));
  2102. };
  2103. };
  2104. var iterate = function iterate(aIa) {
  2105. return isoU(iteratePartial(get(aIa)), iteratePartial(getInverse(aIa)));
  2106. };
  2107. var orAlternatively = /*#__PURE__*/I.curry(orAlternativelyU);
  2108. var fold = function fold(saIs) {
  2109. return isoU(foldPartial(get(saIs)), unfoldPartial(getInverse(saIs)));
  2110. };
  2111. var unfold = function unfold(sIsa) {
  2112. return isoU(unfoldPartial(get(sIsa)), foldPartial(getInverse(sIsa)));
  2113. };
  2114. // Basic isomorphisms
  2115. var complement = /*#__PURE__*/isoU(notPartial, notPartial);
  2116. var is = function is(v) {
  2117. return isoU(function is(x) {
  2118. return I.acyclicEqualsU(v, x);
  2119. }, function (b) {
  2120. return true === b ? v : void 0;
  2121. });
  2122. };
  2123. function subset(predicate) {
  2124. var subsetFn = subsetPartial(predicate);
  2125. return isoU(subsetFn, subsetFn);
  2126. }
  2127. // Array isomorphisms
  2128. var array = function array(elem) {
  2129. var fwd = getInverse(elem);
  2130. var bwd = get(elem);
  2131. var mapFwd = function mapFwd(x) {
  2132. return mapIfArrayLike(fwd, x);
  2133. };
  2134. return function (x, i, F, xi2yF) {
  2135. return F.map(mapFwd, xi2yF(mapIfArrayLike(bwd, x), i));
  2136. };
  2137. };
  2138. var arrays = function arrays(elem) {
  2139. var fwd = getInverse(elem);
  2140. var bwd = get(elem);
  2141. var mapFwd = function mapFwd(x) {
  2142. return mapsIfArray(fwd, x);
  2143. };
  2144. return function (x, i, F, xi2yF) {
  2145. return F.map(mapFwd, xi2yF(mapsIfArray(bwd, x), i));
  2146. };
  2147. };
  2148. var indexed = /*#__PURE__*/isoU( /*#__PURE__*/expect(seemsArrayLike, /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(freezeObjectOfObjects))(function indexed(xs) {
  2149. var n = xs[LENGTH];
  2150. var xis = Array(n);
  2151. for (var i = 0; i < n; ++i) {
  2152. xis[i] = [i, xs[i]];
  2153. }return xis;
  2154. })), /*#__PURE__*/expect(I.isArray, /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(I.freeze))(function (xis) {
  2155. var n = xis[LENGTH];
  2156. var xs = Array(n);
  2157. for (var i = 0; i < n; ++i) {
  2158. var xi = xis[i];
  2159. if (xi[LENGTH] === 2) xs[xi[0]] = xi[1];
  2160. }
  2161. n = xs[LENGTH];
  2162. var j = 0;
  2163. for (var _i11 = 0; _i11 < n; ++_i11) {
  2164. var x = xs[_i11];
  2165. if (void 0 !== x) {
  2166. if (_i11 !== j) xs[j] = x;
  2167. ++j;
  2168. }
  2169. }
  2170. xs[LENGTH] = j;
  2171. return xs;
  2172. })));
  2173. var reverse = /*#__PURE__*/isoU(rev, rev);
  2174. var singleton = /*#__PURE__*/setName( /*#__PURE__*/mapping(function (x) {
  2175. return [[x], x];
  2176. }), 'singleton');
  2177. var groupBy = function groupBy(keyOf) {
  2178. keyOf = toGetter(keyOf);
  2179. return isoU(groupByFn(keyOf), ungroupByFn(keyOf));
  2180. };
  2181. var ungroupBy = function ungroupBy(keyOf) {
  2182. keyOf = toGetter(keyOf);
  2183. return isoU(ungroupByFn(keyOf), groupByFn(keyOf));
  2184. };
  2185. var zipWith1 = function zipWith1(iso) {
  2186. return isoU(zW1Fn(get(iso)), unzW1Fn(getInverse(iso)));
  2187. };
  2188. var unzipWith1 = function unzipWith1(iso) {
  2189. return isoU(unzW1Fn(get(iso)), zW1Fn(getInverse(iso)));
  2190. };
  2191. // Object isomorphisms
  2192. var disjoint = function disjoint(groupOf) {
  2193. return function disjoint(x, i, F, xi2yF) {
  2194. var fwd = disjointFwd(groupOf);
  2195. return F.map(fwd, xi2yF(disjointBwd(groupOf, x), i));
  2196. };
  2197. };
  2198. var multikeyed = /*#__PURE__*/isoU( /*#__PURE__*/expect( /*#__PURE__*/isInstanceOf(Object), /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(freezeObjectOfObjects))(function multikeyed(o) {
  2199. o = toObject(o);
  2200. var ps = [];
  2201. for (var k in o) {
  2202. var v = o[k];
  2203. if (I.isArray(v)) for (var i = 0, n = v[LENGTH]; i < n; ++i) {
  2204. ps.push([k, v[i]]);
  2205. } else ps.push([k, v]);
  2206. }
  2207. return ps;
  2208. })), /*#__PURE__*/expect(I.isArray, /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(freezeObjectOfObjects))(function (ps) {
  2209. var o = I.create(null);
  2210. for (var i = 0, n = ps[LENGTH]; i < n; ++i) {
  2211. var entry = ps[i];
  2212. if (entry[LENGTH] === 2) {
  2213. var k = entry[0];
  2214. var v = entry[1];
  2215. var was = o[k];
  2216. if (was === void 0) o[k] = v;else if (I.isArray(was)) was.push(v);else o[k] = [was, v];
  2217. }
  2218. }
  2219. return I.assign({}, o);
  2220. })));
  2221. // Standard isomorphisms
  2222. var json = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : res(function (iso) {
  2223. return toFunction([iso, isoU(deepFreezeInDev, id)]);
  2224. }))(function json(options) {
  2225. var _ref3 = options || I.object0,
  2226. reviver = _ref3.reviver,
  2227. replacer = _ref3.replacer,
  2228. space = _ref3.space;
  2229. return isoU(expect(I.isString, tryCatch(function json(text) {
  2230. return JSON.parse(text, reviver);
  2231. })), expect(I.isDefined, function (value) {
  2232. return JSON.stringify(value, replacer, space);
  2233. }));
  2234. });
  2235. var uri = /*#__PURE__*/stringIsoU( /*#__PURE__*/tryCatch(decodeURI), encodeURI);
  2236. var uriComponent = /*#__PURE__*/isoU( /*#__PURE__*/expect(I.isString, /*#__PURE__*/tryCatch(decodeURIComponent)), /*#__PURE__*/expect(isPrimitiveData, encodeURIComponent));
  2237. // String isomorphisms
  2238. var dropPrefix = function dropPrefix(pfx) {
  2239. return stringIsoU(function dropPrefix(x) {
  2240. return x.startsWith(pfx) ? x.slice(pfx[LENGTH]) : undefined;
  2241. }, function (x) {
  2242. return pfx + x;
  2243. });
  2244. };
  2245. var dropSuffix = function dropSuffix(sfx) {
  2246. return stringIsoU(function dropSuffix(x) {
  2247. return x.endsWith(sfx) ? x.slice(0, x[LENGTH] - sfx[LENGTH]) : undefined;
  2248. }, function (x) {
  2249. return x + sfx;
  2250. });
  2251. };
  2252. var replaces = /*#__PURE__*/I.curry(function replaces(i, o) {
  2253. return stringIsoU(replace(toRegExpU(i, 'g'), o), replace(toRegExpU(o, 'g'), i));
  2254. });
  2255. var split = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : function (fn$$1) {
  2256. return function split(_sep) {
  2257. return toFunction([fn$$1.apply(null, arguments), isoU(I.freeze, id)]);
  2258. };
  2259. })(function split(sep) {
  2260. var re = arguments[LENGTH] > 1 ? arguments[1] : sep;
  2261. return isoU(expect(I.isString, function (x) {
  2262. return x.split(re);
  2263. }), expect(I.isArray, function (xs) {
  2264. return xs.join(sep);
  2265. }));
  2266. });
  2267. var uncouple = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : function (fn$$1) {
  2268. return function uncouple(_sep) {
  2269. return toFunction([fn$$1.apply(null, arguments), isoU(I.freeze, id)]);
  2270. };
  2271. })(function uncouple(sep) {
  2272. var re = toRegExpU(arguments[LENGTH] > 1 ? arguments[1] : sep, '');
  2273. return isoU(expect(I.isString, function (x) {
  2274. var m = re.exec(x);
  2275. return m ? [x.slice(0, m[INDEX]), x.slice(reLastIndex(m))] : [x, ''];
  2276. }), function (kv) {
  2277. if (isPair(kv)) {
  2278. var k = kv[0];
  2279. var v = kv[1];
  2280. return v ? k + sep + v : k;
  2281. }
  2282. });
  2283. });
  2284. // Standardish isomorphisms
  2285. var querystring = /*#__PURE__*/setName( /*#__PURE__*/toFunction([/*#__PURE__*/reread(function (s) {
  2286. return I.isString(s) ? s.replace(/\+/g, '%20') : s;
  2287. }), /*#__PURE__*/split('&'), /*#__PURE__*/array([/*#__PURE__*/uncouple('='), /*#__PURE__*/array(uriComponent)]), /*#__PURE__*/inverse(multikeyed)]), 'querystring');
  2288. // Arithmetic isomorphisms
  2289. var add$1 = function add$$1(c) {
  2290. return numberIsoU(add(c), add(-c));
  2291. };
  2292. var divide = function divide(c) {
  2293. return numberIsoU(divideBy(c), multiply(c));
  2294. };
  2295. var multiply$1 = function multiply$$1(c) {
  2296. return numberIsoU(multiply(c), divideBy(c));
  2297. };
  2298. var negate$1 = /*#__PURE__*/numberIsoU(negate, negate);
  2299. var subtract = function subtract(c) {
  2300. return numberIsoU(add(-c), add(c));
  2301. };
  2302. var pointer = function pointer(s) {
  2303. if (s[0] === '#') s = decodeURIComponent(s);
  2304. var ts = s.split('/');
  2305. var n = ts[LENGTH];
  2306. for (var i = 1; i < n; ++i) {
  2307. var t = ts[i];
  2308. ts[i - 1] = /^(0|[1-9]\d*)$/.test(t) ? ifElse(isArrayOrPrimitive, Number(t), t) : '-' === t ? ifElse(isArrayOrPrimitive, append, t) : t.replace('~1', '/').replace('~0', '~');
  2309. }
  2310. ts[LENGTH] = n - 1;
  2311. return ts;
  2312. };
  2313. exports.Identity = I.Identity;
  2314. exports.IdentityAsync = I.IdentityAsync;
  2315. exports.FantasyFunctor = I.FantasyFunctor;
  2316. exports.fromFantasy = I.fromFantasy;
  2317. exports.fromFantasyApplicative = I.fromFantasyApplicative;
  2318. exports.fromFantasyMonad = I.fromFantasyMonad;
  2319. exports.seemsArrayLike = seemsArrayLike;
  2320. exports.Select = Select;
  2321. exports.toFunction = toFunction;
  2322. exports.assign = assign;
  2323. exports.disperse = disperse;
  2324. exports.modify = modify;
  2325. exports.modifyAsync = modifyAsync;
  2326. exports.remove = remove;
  2327. exports.set = set;
  2328. exports.traverse = traverse;
  2329. exports.compose = compose;
  2330. exports.flat = flat;
  2331. exports.lazy = lazy;
  2332. exports.choices = choices;
  2333. exports.choose = choose;
  2334. exports.cond = cond;
  2335. exports.condOf = condOf;
  2336. exports.ifElse = ifElse;
  2337. exports.orElse = orElse;
  2338. exports.chain = chain;
  2339. exports.choice = choice;
  2340. exports.unless = unless;
  2341. exports.when = when;
  2342. exports.optional = optional;
  2343. exports.zero = zero;
  2344. exports.mapIx = mapIx;
  2345. exports.setIx = setIx;
  2346. exports.tieIx = tieIx;
  2347. exports.joinIx = joinIx;
  2348. exports.reIx = reIx;
  2349. exports.skipIx = skipIx;
  2350. exports.getLog = getLog;
  2351. exports.log = log;
  2352. exports.transform = transform;
  2353. exports.transformAsync = transformAsync;
  2354. exports.seq = seq;
  2355. exports.branchOr = branchOr;
  2356. exports.branch = branch;
  2357. exports.branches = branches;
  2358. exports.elems = elems;
  2359. exports.elemsTotal = elemsTotal;
  2360. exports.entries = entries;
  2361. exports.keys = keys;
  2362. exports.keysEverywhere = keysEverywhere;
  2363. exports.subseq = subseq;
  2364. exports.limit = limit;
  2365. exports.offset = offset;
  2366. exports.matches = matches;
  2367. exports.values = values;
  2368. exports.children = children;
  2369. exports.flatten = flatten;
  2370. exports.query = query;
  2371. exports.satisfying = satisfying;
  2372. exports.leafs = leafs;
  2373. exports.whereEq = whereEq;
  2374. exports.all = all;
  2375. exports.and = and$1;
  2376. exports.all1 = all1;
  2377. exports.and1 = and1;
  2378. exports.any = any;
  2379. exports.collectAs = collectAs;
  2380. exports.collect = collect;
  2381. exports.collectTotalAs = collectTotalAs;
  2382. exports.collectTotal = collectTotal;
  2383. exports.concatAs = concatAs;
  2384. exports.concat = concat;
  2385. exports.countIf = countIf;
  2386. exports.count = count;
  2387. exports.countsAs = countsAs;
  2388. exports.counts = counts;
  2389. exports.foldl = foldl;
  2390. exports.foldr = foldr;
  2391. exports.forEach = forEach;
  2392. exports.forEachWith = forEachWith;
  2393. exports.get = get;
  2394. exports.getAs = getAs;
  2395. exports.isDefined = isDefined;
  2396. exports.isEmpty = isEmpty;
  2397. exports.joinAs = joinAs;
  2398. exports.join = join;
  2399. exports.maximumBy = maximumBy;
  2400. exports.maximum = maximum;
  2401. exports.meanAs = meanAs;
  2402. exports.mean = mean;
  2403. exports.minimumBy = minimumBy;
  2404. exports.minimum = minimum;
  2405. exports.none = none;
  2406. exports.or = or$1;
  2407. exports.productAs = productAs;
  2408. exports.product = product;
  2409. exports.select = select;
  2410. exports.selectAs = selectAs;
  2411. exports.sumAs = sumAs;
  2412. exports.sum = sum;
  2413. exports.foldTraversalLens = foldTraversalLens;
  2414. exports.getter = getter;
  2415. exports.lens = lens;
  2416. exports.partsOf = partsOf;
  2417. exports.setter = setter;
  2418. exports.defaults = defaults;
  2419. exports.define = define;
  2420. exports.normalize = normalize;
  2421. exports.required = required;
  2422. exports.reread = reread;
  2423. exports.rewrite = rewrite;
  2424. exports.filter = filter;
  2425. exports.find = find;
  2426. exports.findWith = findWith;
  2427. exports.first = first;
  2428. exports.index = index;
  2429. exports.last = last;
  2430. exports.prefix = prefix;
  2431. exports.slice = slice;
  2432. exports.suffix = suffix;
  2433. exports.pickIn = pickIn;
  2434. exports.prop = prop;
  2435. exports.props = props;
  2436. exports.propsExcept = propsExcept;
  2437. exports.propsOf = propsOf;
  2438. exports.removable = removable;
  2439. exports.valueOr = valueOr;
  2440. exports.pick = pick;
  2441. exports.replace = replace$1;
  2442. exports.appendTo = appendTo;
  2443. exports.append = append;
  2444. exports.assignTo = assignTo;
  2445. exports.prependTo = prependTo;
  2446. exports.appendOp = appendOp;
  2447. exports.assignOp = assignOp;
  2448. exports.modifyOp = modifyOp;
  2449. exports.prependOp = prependOp;
  2450. exports.setOp = setOp;
  2451. exports.removeOp = removeOp;
  2452. exports.cross = cross;
  2453. exports.getInverse = getInverse;
  2454. exports.iso = iso;
  2455. exports._ = _;
  2456. exports.mapping = mapping;
  2457. exports.mappings = mappings;
  2458. exports.pattern = pattern;
  2459. exports.patterns = patterns;
  2460. exports.alternatives = alternatives;
  2461. exports.applyAt = applyAt;
  2462. exports.attemptEveryDown = attemptEveryDown;
  2463. exports.attemptEveryUp = attemptEveryUp;
  2464. exports.attemptSomeDown = attemptSomeDown;
  2465. exports.conjugate = conjugate;
  2466. exports.inverse = inverse;
  2467. exports.iterate = iterate;
  2468. exports.orAlternatively = orAlternatively;
  2469. exports.fold = fold;
  2470. exports.unfold = unfold;
  2471. exports.complement = complement;
  2472. exports.identity = identity;
  2473. exports.is = is;
  2474. exports.subset = subset;
  2475. exports.array = array;
  2476. exports.arrays = arrays;
  2477. exports.indexed = indexed;
  2478. exports.reverse = reverse;
  2479. exports.singleton = singleton;
  2480. exports.groupBy = groupBy;
  2481. exports.ungroupBy = ungroupBy;
  2482. exports.zipWith1 = zipWith1;
  2483. exports.unzipWith1 = unzipWith1;
  2484. exports.disjoint = disjoint;
  2485. exports.keyed = keyed;
  2486. exports.multikeyed = multikeyed;
  2487. exports.json = json;
  2488. exports.uri = uri;
  2489. exports.uriComponent = uriComponent;
  2490. exports.dropPrefix = dropPrefix;
  2491. exports.dropSuffix = dropSuffix;
  2492. exports.replaces = replaces;
  2493. exports.split = split;
  2494. exports.uncouple = uncouple;
  2495. exports.querystring = querystring;
  2496. exports.add = add$1;
  2497. exports.divide = divide;
  2498. exports.multiply = multiply$1;
  2499. exports.negate = negate$1;
  2500. exports.subtract = subtract;
  2501. exports.pointer = pointer;