// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){var a=Scanner.fromMessage(e);a.setLocale(r);var i,n=a.getSpan(),o=t.isCancellation?"Cancelled":"Confirmed",p=[],s=[],u=[];i=n.nextTagContents(t.reservationIdPrefix),n.next(t.passengerListPrefix).parentAnyTag("td").tagContents().split(/\n/).slice(1).forEach(function(e){var r=e.innerCapture(/(.+)\s?:\s?(\d+)/);p.push({name:r[1],ticketNumber:r[2]})}),0===p.length&&p.push({});var l,d,m,h,c,g,C,f,v,A,T,x;return c=n.nextTagContents(t.flightNumberPrefix),[,l,d]=n.next(t.flightNumberPrefix).parentAnyTag("td").tagContents().innerCapture(/([0-9A-Z]{2})\s?(\d{1,4})/),[m,g]=n.nextTagContents(t.departureAirportPrefix).split(/\n/),[,h,m]=m.innerCapture(/([A-Z]{3})\s(.+)/),[f,T]=n.nextTagContents(t.arrivalAirportPrefix).split(/\n/),[,v,f]=f.innerCapture(/([A-Z]{3})\s(.+)/),C=a.getDetachedSpan(c+" "+g).innerDate(),x=a.getDetachedSpan(A+" "+T).innerDate(),s.push({airlineCode:l,flightNumber:d,departureAirport:m.trim(),departureAirportCode:h,departureDateTime:C,arrivalAirport:f.trim(),arrivalAirportCode:v,arrivalDateTime:x}),s.forEach(function(e){p.forEach(function(r){ASSERT(e.airlineCode,e.flightNumber,e.departureAirport,e.departureDateTime),u.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:r.name},reservationId:i,reservationStatus:"http://schema.org/Reservation"+o,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:r.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:r.seat,seatingType:null}}})})}),u}}).call();