// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r){var t=Scanner.fromMessage(e);t.setLocale("en_US");for(var a=t.getSpan(),i=[],n=[],o=[],p=e.plain.split(/Departing From/i).length-1,m=(e.plain.slice(),0);m<p;m++)a=a.next(/(^Flight [A-Z]{2}[\s\S]*?)(?:^Flight [A-Z]|^Hotel$|^Car Rental$|^Plan)/gm),o.push(""+a);return o.forEach(function(e){var a,i,o,p,m,c,l,s,u,h,d,g,v,A,N,C,b="Confirmed",y=t.getDetachedSpan(e),T=e.slice(),e=e.split("\n"),f=/^([A-Z]{3})-([A-Z]{3})$/.exec(e[2].trim());u=f[1],g=f[2];var x=/([A-Z]{2})([0-9]{4})/.exec(e[0].trim());i=x[1],o=x[2],a=/Airline.*\n.*\n(.*)\n/.exec(T)[1].split("<")[0].trim(),s=/Departing From.*\n.*\n(.*)\n/.exec(T)[1],d=/Arriving At.*\n.*\n(.*)\n/.exec(T)[1],v=/Reference #.*\n.*\n(.*)\n/.exec(T),v&&2===v.length&&(v=v[1]),c=/Seat #.*\n.*\n(.*)\n/.exec(T),c&&2===c.length&&(c=c[1]),m=/Cabin.*\n.*\n(.*)\n/.exec(T),m&&2===m.length&&(m=m[1]),l=y.nextDate(),h=y.nextDate().nextDate(),n.push({airlineName:a,airlineCode:i,flightNumber:o,departureDateTime:l,departureAirport:s,departureAirportCode:u,arrivalDateTime:h,arrivalAirport:d,arrivalAirportCode:g,ticketNumber:p,checkinUrl:C,reservationId:v,reservationStatus:b,totalPrice:A,priceCurrency:N,seatNumber:c,seatType:m,underPersonName:r.underName})}),n.forEach(function(e){ASSERT(e.departureDateTime,e.arrivalDateTime,e.departureAirportCode,e.arrivalAirportCode),i.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:e.checkinUrl,reservationId:e.reservationId,reservationStatus:"http://schema.org/Reservation"+e.reservationStatus,totalPrice:e.totalPrice,priceCurrency:e.priceCurrency,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}})}),i.length>=1?i:CONTINUE}}).call();