// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e),i=a.getSpan();a.setLocale(t);for(var n,o,p,l,g,u,d,s,x,m,h={},T=[],c=(i.nextText("vocabulary.itinerayHeader").nextTag("table1").allInnerTagsFiltered("tr1"),1),v=i.nextText(r.legPrefix+""+c);v.exists();)h={},[,s,m]=v.nextTag("td1").tagContents().innerCapture(/(.+)-(.+)/),[,u,l]=v.nextText(r.flightPrefix).nextTag("td1").tagContents().innerCapture(/([A-Z0-9]{2})(\d+)/),[,d]=v.nextText(r.departurePrefix).nextTag("td1").tagContents().innerCapture(/(.* @ [0-9]{2}:[0-9]{2})\,?/),[,x]=v.nextText(r.arrivalPrefix).nextTag("td1").tagContents().innerCapture(/(.* @ [0-9]{2}:[0-9]{2})\,?/),d=getFuzzyDate(a.getDetachedSpan(""+d)),x=getFuzzyDate(a.getDetachedSpan(""+x)),c++,v=i.nextText(r.legPrefix+""+c),h.departureAirport=s.trim(),h.arrivalAirport=m.trim(),h.airlineCode=u,h.flightNumber=l,h.departureTime=d,h.arrivalTime=x,ASSERT(h.departureAirport,h.arrivalAirport,h.departureTime,h.arrivalTime,h.airlineCode,h.flightNumber)&&T.push(h);g=i.nextText(r.totalCostPrefix).nextTag("td1").tagContents();var C=g.innerCapture(/([\d,.-]+)/,1),f=g.innerCapture(/([^\d,.-\w]+)/,1).trim();null!==f&&0!==(""+f).length||(f=g.innerCapture(/([^\d,.-]+)/,1).trim());var y=[];for(c=1,v=i.nextText(r.passengerPrefix+""+c);v.exists();)h={},p=v.nextTag("td1").tagContents(),h.name=p,y.push(h),c++,v=i.nextText(r.passengerPrefix+""+c);for(var A,z=[],N=0;N<T.length;N++)for(var P=T[N],b=0;b<y.length;b++){var F=y[b];A={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:P.airlineName,airlineCode:P.airlineCode,flightNumber:P.flightNumber,departureAirportFuzzy:P.departureAirport,departureAirportCode:P.departureCode,departureTime:P.departureTime,arrivalAirportFuzzy:P.arrivalAirport,arrivalAirportCode:P.arrivalCode,arrivalTime:P.arrivalTime},underName:{"@type":"http://schema.org/Person",name:F.name},checkinUrl:o,reservationId:n,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:F.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:"",seatingType:""}},totalPrice:C,priceCurrency:f,reservationStatus:"http://schema.org/ReservationConfirmed"},z.push(A)}if(z.length)return z}}).call();