partial.lenses.es.js 70 KB

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