// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e);if(a.setLocale(t),!a.getSpan().nextText(r.yourItinerary))return CONTINUE;var n;n=a.getSpan().nextText(r.bookingReferencePrefix).parentTag("td3").innerCapture(regExpFormatted(/\1 ($<bookingReference>\w{6})/,r.bookingReferencePrefix),1);var i,p,g=a.getSpan().next(r.pricePrefix).nextTag("td4").innerCapture(/($<currency>\w+) ($<price>[\d.,]+)/);g&&(i=g.$price,p=g.$currency);var o=[],l=n.nextText(r.passengersPrefix).parentTag("table4").allInnerTags("td4").filter(function(e){return e&&(""+e.tagContents().trim()).length>0});l=l.slice(1);for(var x=0;x<l.length;x++)o.push({name:l[x].tagContents().trim(),price:i,currency:p});for(var u=[],c=a.getSpan().nextText(r.flightNumberPrefix).parentTag("table5");c.exists()&&c.nextText(r.flightNumberPrefix).exists();){var d=c.nextText(r.flightNumberPrefix).nextTag("td5").tagContents(),m=d.innerCapture(/($<airlineCode>\w{2})($<flightNumber>\d{1,4})/),s=m.$airlineCode,f=m.$flightNumber,h=f.nextTag("td5").nextText(r.departureAirportPrefix).nextTag("td5").tagContents();r.terminal&&h&&(""+h).indexOf(r.terminal)>0&&(h=h.innerCapture(regExpFormatted(/(.*) \1/,r.terminal),1));var T=h.nextTag("td5").nextText(r.arrivalAirportPrefix).nextTag("td5").tagContents();r.terminal&&T&&(""+T).indexOf(r.terminal)>0&&(T=T.innerCapture(regExpFormatted(/(.*) \1/,r.terminal),1));var v,C=a.getDetachedSpan((""+c.nextText(r.departureDatePrefix).nextTag("td5").tagContents()).replace(/abr/i,"apr")).allDates();v=1===C.length?C[0]:a.getDetachedSpan(C.map(function(e){return e.trim()}).join("")).firstDate();var b,N=a.getDetachedSpan((""+c.nextText(r.arrivalDatePrefix).nextTag("td5").tagContents()).replace(/abr/i,"apr")).allDates();b=1===N.length?N[0]:a.getDetachedSpan(N.map(function(e){return e.trim()}).join("")).firstDate();var S=(c.nextText(r.cabinPrefix).nextTag("td5").tagContents(),c.nextText(r.airlineNamePrefix).nextTag("td5").tagContents());ASSERT(S||s,f,v,h)&&(u.push({airlineName:S,airlineCode:s,flightNumber:f,departureDate:v,departureAirport:h,arrivalDate:b,arrivalAirport:T,passengers:o}),S=s=f=v=h=b=T=null),c=c.nextTag("table5")}c=null;for(var P=a.getSpan().nextText(r.ticketNumberPrefix).nextTag("td4").tagContents().innerCapture(/([\d-]+)/,1),y=[],x=0;x<u.length;x++){c=u[x];for(var D=0;D<o.length;D++){ASSERT(c.airlineName||c.airlineCode,c.flightNumber,c.departureAirport,c.departureDate);var A=o[D],F={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:c.airlineName,airlineCode:c.airlineCode,flightNumber:c.flightNumber,departureAirportFuzzy:c.departureAirport,departureTime:c.departureDate,arrivalAirportFuzzy:c.arrivalAirport,arrivalTime:c.arrivalDate},underName:{"@type":"http://schema.org/Person",name:A.name},reservationId:n,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:A.price,priceCurrency:A.currency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:P,ticketedSeat:{"@type":"http://schema.org/Seat"}}};y.push(F)}}return y.length?y:void 0}}).call();