(function (_, Kotlin) { 'use strict'; var Kind_CLASS = Kotlin.Kind.CLASS; var throwCCE = Kotlin.throwCCE; var until = Kotlin.kotlin.ranges.until_dqglrj$; var chunked = Kotlin.kotlin.collections.chunked_ba2ldo$; function get_cm($receiver) { return $receiver / 2.54; } function get_asPoints($receiver) { return $receiver * 72; } function Entry(eventNbr, event, lane, heat, swimmer, team) { this.eventNbr = eventNbr; this.event = event; this.lane = lane; this.heat = heat; this.swimmer = swimmer; this.team = team; } Entry.$metadata$ = { kind: Kind_CLASS, simpleName: 'Entry', interfaces: [] }; Entry.prototype.component1 = function () { return this.eventNbr; }; Entry.prototype.component2 = function () { return this.event; }; Entry.prototype.component3 = function () { return this.lane; }; Entry.prototype.component4 = function () { return this.heat; }; Entry.prototype.component5 = function () { return this.swimmer; }; Entry.prototype.component6 = function () { return this.team; }; Entry.prototype.copy_cdqwiw$ = function (eventNbr, event, lane, heat, swimmer, team) { return new Entry(eventNbr === void 0 ? this.eventNbr : eventNbr, event === void 0 ? this.event : event, lane === void 0 ? this.lane : lane, heat === void 0 ? this.heat : heat, swimmer === void 0 ? this.swimmer : swimmer, team === void 0 ? this.team : team); }; Entry.prototype.toString = function () { return 'Entry(eventNbr=' + Kotlin.toString(this.eventNbr) + (', event=' + Kotlin.toString(this.event)) + (', lane=' + Kotlin.toString(this.lane)) + (', heat=' + Kotlin.toString(this.heat)) + (', swimmer=' + Kotlin.toString(this.swimmer)) + (', team=' + Kotlin.toString(this.team)) + ')'; }; Entry.prototype.hashCode = function () { var result = 0; result = result * 31 + Kotlin.hashCode(this.eventNbr) | 0; result = result * 31 + Kotlin.hashCode(this.event) | 0; result = result * 31 + Kotlin.hashCode(this.lane) | 0; result = result * 31 + Kotlin.hashCode(this.heat) | 0; result = result * 31 + Kotlin.hashCode(this.swimmer) | 0; result = result * 31 + Kotlin.hashCode(this.team) | 0; return result; }; Entry.prototype.equals = function (other) { return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && (Kotlin.equals(this.eventNbr, other.eventNbr) && Kotlin.equals(this.event, other.event) && Kotlin.equals(this.lane, other.lane) && Kotlin.equals(this.heat, other.heat) && Kotlin.equals(this.swimmer, other.swimmer) && Kotlin.equals(this.team, other.team))))); }; function Meet(meet, entries) { this.meet = meet; this.entries = entries; } Meet.$metadata$ = { kind: Kind_CLASS, simpleName: 'Meet', interfaces: [] }; Meet.prototype.component1 = function () { return this.meet; }; Meet.prototype.component2 = function () { return this.entries; }; Meet.prototype.copy_khic54$ = function (meet, entries) { return new Meet(meet === void 0 ? this.meet : meet, entries === void 0 ? this.entries : entries); }; Meet.prototype.toString = function () { return 'Meet(meet=' + Kotlin.toString(this.meet) + (', entries=' + Kotlin.toString(this.entries)) + ')'; }; Meet.prototype.hashCode = function () { var result = 0; result = result * 31 + Kotlin.hashCode(this.meet) | 0; result = result * 31 + Kotlin.hashCode(this.entries) | 0; return result; }; Meet.prototype.equals = function (other) { return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && (Kotlin.equals(this.meet, other.meet) && Kotlin.equals(this.entries, other.entries))))); }; function hydrateEntry(entry) { return new Entry(entry.eventNbr, entry.event, entry.lane, entry.heat, entry.swimmer, entry.team); } var collectionSizeOrDefault = Kotlin.kotlin.collections.collectionSizeOrDefault_ba2ldo$; var ArrayList_init = Kotlin.kotlin.collections.ArrayList_init_ww73n8$; function iterate(list) { var tmp$; var $receiver = until(0, typeof (tmp$ = list.length) === 'number' ? tmp$ : throwCCE()); var destination = ArrayList_init(collectionSizeOrDefault($receiver, 10)); var tmp$_0; tmp$_0 = $receiver.iterator(); while (tmp$_0.hasNext()) { var item = tmp$_0.next(); destination.add_11rb$(list[item]); } return destination; } function hydrateMeet(meet) { var tmp$ = meet.meet; var $receiver = iterate(meet.entries); var destination = ArrayList_init(collectionSizeOrDefault($receiver, 10)); var tmp$_0; tmp$_0 = $receiver.iterator(); while (tmp$_0.hasNext()) { var item = tmp$_0.next(); destination.add_11rb$(hydrateEntry(item)); } return new Meet(tmp$, destination); } function main$lambda(req, res) { var doc = new (require('pdfkit'))({autoFirstPage: false}); var meetInfo = hydrateMeet(req.body); res.setHeader('Content-Disposition', 'attachment;filename=' + '"' + 'lane-slips-' + meetInfo.meet + '.pdf' + '"'); res.setHeader('Content-Type', 'application/pdf'); doc.pipe(res); var tmp$; tmp$ = chunked(meetInfo.entries, 6).iterator(); while (tmp$.hasNext()) { var element = tmp$.next(); doc.addPage(); var tmp$_0, tmp$_0_0; var index = 0; tmp$_0 = element.iterator(); while (tmp$_0.hasNext()) { var item = tmp$_0.next(); var index_0 = (tmp$_0_0 = index, index = tmp$_0_0 + 1 | 0, tmp$_0_0); writeSlip(item, doc, index_0 % 2, index_0 / 2 | 0); } drawDashes(doc); } return doc.end(); } function main(args) { var fireFunctions = require('firebase-functions'); fireFunctions.config(); exports.laneslips = fireFunctions.https.onRequest(main$lambda); } function drawDashes(doc) { var dashOptions = {}; dashOptions.space = 10; doc.moveTo(get_asPoints(get_cm(10.25)), get_asPoints(get_cm(1.0))).lineTo(get_asPoints(get_cm(10.25)), get_asPoints(get_cm(27.0))).dash(5, dashOptions).stroke(); doc.moveTo(get_asPoints(get_cm(1.0)), get_asPoints(get_cm(9.5))).lineTo(get_asPoints(get_cm(21.0)), get_asPoints(get_cm(9.5))).dash(5, dashOptions).stroke(); doc.moveTo(get_asPoints(get_cm(1.0)), get_asPoints(get_cm(18.5))).lineTo(get_asPoints(get_cm(21.0)), get_asPoints(get_cm(18.5))).dash(5, dashOptions).stroke(); } function writeSlip($receiver, doc, x, y) { var xOffset = get_asPoints(get_cm(10.0)) * x; var yOffset = get_asPoints(get_cm(8.0)) * y; var leftMargin = get_asPoints(get_cm(0.9)) + xOffset; var opts = {}; opts.width = get_asPoints(get_cm(8.5)); opts.align = 'center'; doc.fontSize(13); doc.font('Helvetica-Bold'); doc.text('Southern Ohio Swim League', leftMargin, get_asPoints(get_cm(1.5)) + yOffset, opts); doc.fontSize(11); doc.font('Times-Roman'); var eventY = get_asPoints(get_cm(2.3)) + yOffset; doc.text('EVENT #' + $receiver.eventNbr + ' - ' + $receiver.event, leftMargin, eventY); var lineSeparation = get_asPoints(get_cm(1.0)); var laneY = eventY + lineSeparation; doc.text('Lane:', leftMargin, laneY); var colWidth = get_asPoints(get_cm(1.3)); doc.text('1', leftMargin + colWidth * 1, laneY); doc.text('2', leftMargin + colWidth * 2, laneY); doc.text('3', leftMargin + colWidth * 3, laneY); doc.text('4', leftMargin + colWidth * 4, laneY); doc.text('5', leftMargin + colWidth * 5, laneY); doc.text('6', leftMargin + colWidth * 6, laneY); doc.circle(leftMargin + colWidth * $receiver.lane + get_asPoints(get_cm(0.1)), laneY + get_asPoints(get_cm(0.15)), get_asPoints(get_cm(0.3))); doc.stroke(); var heatY = laneY + lineSeparation; doc.text('Heat:', leftMargin, heatY); doc.text('1', leftMargin + colWidth * 1, heatY); doc.text('2', leftMargin + colWidth * 2, heatY); doc.text('3', leftMargin + colWidth * 3, heatY); doc.text('4', leftMargin + colWidth * 4, heatY); doc.text('5', leftMargin + colWidth * 5, heatY); doc.text('6', leftMargin + colWidth * 6, heatY); doc.circle(leftMargin + colWidth * $receiver.heat + get_asPoints(get_cm(0.1)), heatY + get_asPoints(get_cm(0.15)), get_asPoints(get_cm(0.3))); doc.stroke(); var nameY = heatY + lineSeparation; doc.text('Name: ' + $receiver.swimmer, leftMargin, nameY); var teamY = nameY + lineSeparation; doc.text('Team: ' + $receiver.team, leftMargin, teamY); var timesY = teamY + lineSeparation * 1.5; doc.text('Times:', leftMargin, timesY); doc.moveTo(leftMargin + colWidth, timesY + 14).lineTo(leftMargin + colWidth + get_asPoints(get_cm(2.0)), timesY + 14).stroke(); doc.moveTo(leftMargin + colWidth + get_asPoints(get_cm(2.7)), timesY + 14).lineTo(leftMargin + colWidth + get_asPoints(get_cm(4.7)), timesY + 14).stroke(); doc.moveTo(leftMargin + colWidth + get_asPoints(get_cm(5.4)), timesY + 14).lineTo(leftMargin + colWidth + get_asPoints(get_cm(7.4)), timesY + 14).stroke(); var officialTimesY = timesY + lineSeparation * 1.5; doc.text('Official Time:', leftMargin, officialTimesY); doc.moveTo(leftMargin + colWidth * 2, officialTimesY + 14).lineTo(leftMargin + colWidth * 2 + get_asPoints(get_cm(4.0)), officialTimesY + 14).stroke(); var placeY = officialTimesY + lineSeparation * 1.25; doc.text('Place:', leftMargin, placeY); doc.text('1', leftMargin + colWidth * 1, placeY); doc.text('2', leftMargin + colWidth * 2, placeY); doc.text('3', leftMargin + colWidth * 3, placeY); doc.text('4', leftMargin + colWidth * 4, placeY); doc.text('5', leftMargin + colWidth * 5, placeY); doc.text('6', leftMargin + colWidth * 6, placeY); } var package$online = _.online || (_.online = {}); var package$cinphart = package$online.cinphart || (package$online.cinphart = {}); var package$laneslips = package$cinphart.laneslips || (package$cinphart.laneslips = {}); package$laneslips.get_cm_yrwdxr$ = get_cm; package$laneslips.get_asPoints_yrwdxr$ = get_asPoints; package$laneslips.Entry = Entry; package$laneslips.Meet = Meet; package$laneslips.hydrateEntry_za3rmp$ = hydrateEntry; package$laneslips.iterate_za3rmp$ = iterate; package$laneslips.hydrateMeet_za3rmp$ = hydrateMeet; package$laneslips.main_kand9s$ = main; package$laneslips.drawDashes_za3rmp$ = drawDashes; package$laneslips.writeSlip_dmpztf$ = writeSlip; main([]); Kotlin.defineModule('index', _); return _; }(module.exports, require('kotlin'))); //# sourceMappingURL=index.js.map