// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,a){var r=Scanner.fromMessage(e);r.setLocale(t);var n=r.getSpan().nextText(a.passengerDetailsHeader).nextTag("table6").nextTag("td6").tagContents().innerCapture(regExpFormatted(/\1\n(.+)/,a.passengerNamePrefix),1),i=r.getSpan().nextText(a.reservationIdPrefix).parentTag("td6").tagContents().innerCapture(regExpFormatted(/\1 (.+)/,a.reservationIdPrefix),1),g=[],p=[],o=r.getSpan().nextText(a.reservationIdPrefix).nextTag("table4").tagContents(),x=o.split(a.terminal);x.pop();for(var l=0;l<x.length;l++){var d,T,s,m,u,c={},C="",b="";c.departureDate=x[l].nextTag("table5").nextTag("td5").innerDate(),""+c.departureDate==""&&(c.departureDate=x[l].nextTag("table5").nextTag("table5").nextTag("table5").nextTag("td5").innerDate()),[C,b]=x[l].nextTag("table5").nextTag("td5").nextTag("td5").tagContents().split("-"),void 0===b&&([C,b]=x[l].nextTag("table5").nextTag("table5").nextTag("table5").nextTag("td5").nextTag("td5").tagContents().split("-")),C=getFuzzyDate(r.getDetachedSpan(""+C)),b=getFuzzyDate(r.getDetachedSpan(""+b)),C=combineDateAndTime(c.departureDate,C),b=combineDateAndTime(c.departureDate,b),c.departureTime=C,c.arrivalTime=b;var h=/(.+) (\w{2})([1-9]+)/;[,s,u,m]=h.test(x[l].nextTag("table5").nextTag("table5").nextTag("td5").tagContents())?(""+x[l].nextTag("table5").nextTag("table5").nextTag("td5").tagContents()).match(/(.+) (\w{2})([1-9]+)/):(""+x[l].nextTag("table5").nextTag("table5").nextTag("table5").nextTag("table5").nextTag("td5").tagContents()).match(/(.+) (\w{2})([1-9]+)/),c.airlineName=s,c.airlineCode=u,c.flightNumber=m;var v;0===(""+t).localeCompare("es_ES")?(v="a",h=/a/):0===(""+t).localeCompare("en_US")&&(v="to",h=/to/),[,d,T]=h.test(x[l].nextTag("table5").nextTag("table5").nextTag("td5").nextTag("td5").tagContents())?x[l].nextTag("table5").nextTag("table5").nextTag("td5").nextTag("td5").tagContents().innerCapture(regExpFormatted(/(.+)\s\1(.+)/,v)):x[l].nextTag("table5").nextTag("table5").nextTag("table5").nextTag("table5").nextTag("td5").nextTag("td5").tagContents().innerCapture(regExpFormatted(/(.+)\s\1(.+)/,v)),c.departureAirport=d.trim(),c.arrivalAirport=T.trim(),ASSERT(c.airlineCode,c.flightNumber,c.departureTime,c.departureAirport,c.arrivalTime,c.arrivalAirport)&&g.push(c)}var f,S,A;for(0===(""+t).localeCompare("es_ES")?(f=r.getSpan().nextText(a.pricePrefix).parentTag("td5").tagContents().innerCapture(regExpFormatted(/\1($<price>[\d,\. ]+)($<currency>[^\d,\. ]+)/,a.pricePrefix)),S=f.$price,A=f.$currency):(f=r.getSpan().nextText(a.pricePrefix).parentTag("td5").tagContents().innerCapture(regExpFormatted(/\1(.+)/,a.pricePrefix),1),S=f.innerCapture(/([\d,.-]+)/,1),A=f.innerCapture(/([^\d,.-]+)/,1).trim()),l=0;l<g.length;l++){var D=g[l],F={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:D.airlineName,airlineCode:D.airlineCode,flightNumber:D.flightNumber,departureAirportFuzzy:D.departureAirport,departureAirportCode:D.departureAirportCode,departureTime:D.departureTime,arrivalAirportFuzzy:D.arrivalAirport,arrivalAirportCode:"",arrivalTime:D.arrivalTime},underName:{"@type":"http://schema.org/Person",name:n},reservationId:i,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:S,priceCurrency:A,reservedTicket:{"@type":"http://schema.org/Ticket",ticketedSeat:{"@type":"http://schema.org/Seat"}}};p.push(F)}return p}}).call();