// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){var a=Scanner.fromMessage(e);a.setLocale(r);for(var i,n=a.getSpan(),p=t.isCancellation?"Cancelled":"Confirmed",o=[],l=[],u=[],m=n.next(t.flightLegPrefix[0]).parentTag("table3");m.exists();){m.allInnerTags("table4").forEach(function(e){var r,i,n,p,l,m,s,c,g=e.allInnerTags("td5").map(function(e){return e.tagContents()});if(g&&10==g.length)l=a.getDetachedSpan(g[0]+" "+g[1].replace(/\s+/," ")+" "+g[4]),[,r,i]=g[3].innerCapture(/([0-9A-Z]{2})([0-9]{1,4})/),[,n,p]=g[6].replace(/\s+/," ").innerCapture(/(.+)\s\(([A-Z]{3})\)/),c=a.getDetachedSpan(g[0]+" "+g[1].replace(/\s+/," ")+" "+g[7]),[,m,s]=g[9].replace(/\s+/," ").innerCapture(/(.+)\s\(([A-Z]{3})\)/),u.push({airlineCode:r,flightNumber:i,departureAirport:n.trim(),departureAirportCode:p,departureDateTime:l,arrivalAirport:m.trim(),arrivalAirportCode:s,arrivalDateTime:c});else{var h={name:null,ticketNumber:null};[h.name,h.ticketNumber]=e.nextAnyTag("td").tagContents().split(/\n/),h.name=""+h.name,h.ticketNumber=""+h.ticketNumber.innerCapture(t.ticketNumberRegExp,1),o.map(function(e){return e.name}).indexOf(h.name)===-1&&o.push(h)}});var s=m.next(t.flightLegStopOverPrefix).nextTag("table3");if(s.exists())m=s;else{if(s=m.next(t.flightLegPrefix[1]).parentTag("table3"),""+s==""+m)break;m=s}}return 0===o.length&&o.push({}),u.forEach(function(e){o.forEach(function(r){ASSERT(e.airlineCode,e.flightNumber,e.departureAirport,e.departureDateTime),l.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"+p,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:r.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:r.seat,seatingType:null}}})})}),l}}).call();