// 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(),s="Confirmed",l=[],m=[];a=/- (.*)/.exec(e.subject)[1],o=p.next(/To check in online/).nextLink();var g=p.allInnerTags("table3").filter(function(e){var r=""+e;return r.indexOf("Cabin Class")>-1});return g.forEach(function(e){var r,a,i,n,o,s,m,g,u,c,d="Singapore Airlines",h=/\((.*)\).*to.*\((.*)\).*\n/.exec(""+e);s=h[1],u=h[2];var T=e.nextAnyTag("table").nextAnyTag("table");[,r,a]=/([0-9A-Z]{2,3}?)\s?(\d{3,4})/.exec(""+T);var v=(""+T.nextAnyTag("table").nextAnyTag("td").tagContents()).split("\n");o=v[0],n=v[1].replace(/[()]/g," "),n=getFuzzyDate(t.getDetachedSpan(n).firstDate());var A=(""+T.nextAnyTag("table").nextAnyTag("table").nextAnyTag("td").tagContents()).split("\n");g=A[0],m=A[1].replace(/[()]/g," "),m=getFuzzyDate(t.getDetachedSpan(m).firstDate()),c=p.next("Passengers").parentTag("table4").allInnerTags("tr4"),c.shift(),c.forEach(function(e){var t;t=e.nextAnyTag("td").nextAnyTag("td").tagContents(),l.push({airlineName:d,airlineCode:r,flightNumber:a,departureDateTime:n,departureAirport:o,departureAirportCode:s,arrivalDateTime:m,arrivalAirport:g,arrivalAirportCode:u,ticketNumber:i,underPersonName:t})})}),l.forEach(function(e){ASSERT(e.departureDateTime,e.arrivalDateTime,e.departureAirportCode,e.arrivalAirportCode),m.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"+s,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}})}),m.length>=1?m:CONTINUE}}).call();