// Copyright 2014 Apple Inc.  All Rights Reserved.
new ReverseTemplateList([new ReverseTemplate("jal.com-confirmation-en",function(e){return/Reservation \/ Ticket Confirmation for .+/.test(e.subject)},function(e){if(!/Reservation \/ Ticket Confirmation for .+/.test(e.subject))return CONTINUE;var t="en_GB",r={};r.passengerBlockPrefix="Traveler Information";var a=Scanner.fromMessage(e);a.setLocale(t);var n,i=a.getSpan(),o=r.isCancellation?"Cancelled":"Confirmed",s=[],p=[],l=[];return i.next(r.passengerBlockPrefix).nextTag("table2").allInnerTags("td2").map(function(e){return e.tagContents()}).filter(function(e){return/^M/.test(""+e)}).forEach(function(e){s.push({name:e.tagContents()})}),i.withStart(i.next("Participate in the carbon offset program for this flight?").getEnd()).withEnd(i.next("Payment Summary").getStart()).allInnerTags("table2").forEach(function(e){var t,r,n,i,o,s,p,u,m,c=e.allInnerTags("td2").filter(function(e){return""!==(""+e.tagContents()).trim()});i=c[1].tagContents(),[,t,r]=c[3].next("Flight:").nextTag("td3").tagContents().innerCapture(/([A-Z0-9]{2})(\d{1,4})/),c=c[3].allInnerTags("td4").map(function(e){return e.tagContents()}),o=c[1],n=c[2],u=c[4],p=c[5],s=a.getDetachedSpan(i+" "+o).innerDate(),m=a.getDetachedSpan(i+" "+u).innerDate(),/\+\d+ day\(s\)/.test(""+u)&&(m=modifyDate(m,1)),l.push({airlineCode:t,flightNumber:r,departureAirport:n.trim(),departureDateTime:s,arrivalAirport:p.trim(),arrivalDateTime:m})}),0===s.length&&s.push({}),l.forEach(function(e){s.forEach(function(t){ASSERT(e.airlineCode,e.flightNumber,e.departureAirport,e.departureDateTime),p.push({"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineCode:e.airlineCode,airlineName:e.airlineName,flightNumber:e.flightNumber,departureAirportFuzzy:e.departureAirport,departureAirportCode:e.departureAirportCode,departureTime:e.departureDateTime,arrivalAirportFuzzy:e.arrivalAirport,arrivalAirportCode:e.arrivalAirportCode,arrivalTime:e.arrivalDateTime},underName:{"@type":"http://schema.org/Person",name:t.name},reservationId:n,reservationStatus:"http://schema.org/Reservation"+o,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:t.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:t.seat,seatingType:null}}})})}),p},"0/1/2/3/4/5/240/463/465","SGdde2342f")]);