// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r){var t=Scanner.fromMessage(e);t.setLocale(r);var a,i,n,o,p=t.getSpan(),l="Confirmed",m=[],s=[];a=/- (.*)/.exec(e.subject)[1];var g=p.allInnerTags("table2").filter(function(e){var r=""+e;return r.indexOf("Total travel time")>-1});return g.forEach(function(e){var r,a,i,n,o,l,s,g,u,c="Singapore Airlines",d="SQ",h=/\((.*)\).*to.*\((.*)\).*\n/.exec(""+e);o=h[1],g=h[2];var T=e.nextAnyTag("table").nextAnyTag("table");r=/SQ([0-9]*)/.exec(""+T)[1];var v=(""+T.nextAnyTag("table").nextAnyTag("table").nextAnyTag("td").tagContents()).split("\n");n=v[0],i=v[1].replace(/[\(\)]/g," "),i=getFuzzyDate(t.getDetachedSpan(i).firstDate());var A=(""+T.nextAnyTag("table").nextAnyTag("table").nextAnyTag("table").nextAnyTag("td").tagContents()).split("\n");s=A[0],l=A[1].replace(/[\(\)]/g," "),l=getFuzzyDate(t.getDetachedSpan(l).firstDate()),u=p.next("Passengers").parentTag("table4").allInnerTags("tr4"),u.shift(),u.forEach(function(e){var t;t=e.nextAnyTag("td").nextAnyTag("td").tagContents(),m.push({airlineName:c,airlineCode:d,flightNumber:r,departureDateTime:i,departureAirport:n,departureAirportCode:o,arrivalDateTime:l,arrivalAirport:s,arrivalAirportCode:g,ticketNumber:a,underPersonName:t})})}),m.forEach(function(e){ASSERT(e.departureDateTime,e.arrivalDateTime,e.departureAirportCode,e.arrivalAirportCode),s.push({"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:e.airlineName,airlineCode:e.airlineCode,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:e.underPersonName},checkinUrl:o,reservationId:a,reservationStatus:"http://schema.org/Reservation"+l,totalPrice:i,priceCurrency:n,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:e.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:e.seatNumber,seatingType:e.seatType}},programMembershipUsed:{"@type":"http://schema.org/ProgramMembership",membershipNumber:e.membershipNumber,programName:e.programName}})}),s.length>=1?s:CONTINUE}}).call();