// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e),i=a.getSpan();a.setLocale(t);var n,o,g,l,p,T,x,m,d,s,u,c,C;n=i.nextText(r.reservationIdPrefix).nextTag("td3").tagContents(),l=i.nextText(r.totalCostPrefix).parentTag("td3").tagContents().innerCapture(regExpFormatted(/\1(.+)/,r.totalCostPrefix),1);var v,h=(l.innerCapture(/([\d,.-]+)/,1),l.innerCapture(/([^\d,.-\w]+)/,1).trim(),!0);v=i.nextText(r.singleTripPrefix),v.exists()||(h=!1,v=i.nextText(r.roundTripPrefix),v.exists()||(v=i.nextText(r.conjectionPrefix))),v=v.nextTag("table3").allInnerTagsFiltered("tr3");for(var f,b=[],A=0;A<v.length;A++){f={};var N,P=/\u7968\u53f7\uff1a/;N=v[A].innerCapture(P.test(v[A])?/($<name>.+?)\[.*\u7968\u53f7\uff1a($<ticketNumber>.+)/:/($<name>.+?)\[/),f.name=N.$name.trim(),f.ticketNumber=N.$ticketNumber,b.push(f)}var y=[];if(h)f={},[,u,C,s]=i.nextText(r.singleTripPrefix).nextTag("table3").nextTag("tr2").nextTag("td2").nextTag("td2").tagContents().innerCapture(/(.+)\u2192(.+)\s(.+)/),f.departureAirport=u.trim(),f.arrivalAirport=C.trim(),s=s,[,x,m,g]=i.nextText(r.singleTripPrefix).nextTag("table3").nextTag("table3").nextTag("td3").tagContents().innerCapture(/(.+?)\s([A-Z0-9]{2})([\d]+)/),f.airlineName=x,f.airlineCode=m,f.flightNumber=g,d=i.nextText(r.singleTripPrefix).nextTag("table3").nextTag("table4").nextTag("td4").tagContents(),c=i.nextText(r.singleTripPrefix).nextTag("table3").nextTag("table4").nextTag("td4").nextTag("td4").nextTag("td4").tagContents(),f.departureTime=combineDateAndTime(s,d),f.arrivalTime=combineDateAndTime(s,c),ASSERT(f.departureAirport,f.arrivalAirport,f.departureTime,f.arrivalTime,f.airlineCode,f.flightNumber)&&y.push(f);else{f={};for(var S=1,k=a.getSpan().nextText(r.legPrefix+""+S);k.exists();)f={},[,u,C,s]=k.nextTag("td2").tagContents().innerCapture(/(.+)\u2192(.+)\s(.+)/),f.departureAirport=u.trim(),f.arrivalAirport=C.trim(),s=s,[,x,m,g]=k.nextTag("table3").nextTag("td3").tagContents().innerCapture(/(.+?)\s([A-Z0-9]{2})([\d]+)/),f.airlineName=x,f.airlineCode=m,f.flightNumber=g,d=k.nextTag("table4").nextTag("td4").tagContents(),c=k.nextTag("table4").nextTag("td4").nextTag("td4").nextTag("td4").tagContents(),f.departureTime=combineDateAndTime(s,d),f.arrivalTime=combineDateAndTime(s,c),ASSERT(f.departureAirport,f.arrivalAirport,f.departureTime,f.arrivalTime,f.airlineCode,f.flightNumber)&&y.push(f),S++,k=i.nextText(r.legPrefix+""+S)}var F,z=[];for(A=0;A<y.length;A++)for(var $=y[A],D=0;D<b.length;D++){var R=b[D];F={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:$.airlineName,airlineCode:$.airlineCode,flightNumber:$.flightNumber,departureAirportFuzzy:$.departureAirport,departureAirportCode:$.departureCode,departureTime:$.departureTime,arrivalAirportFuzzy:$.arrivalAirport,arrivalAirportCode:$.arrivalCode,arrivalTime:$.arrivalTime},underName:{"@type":"http://schema.org/Person",name:R.name},checkinUrl:o,reservationId:n,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:R.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:"",seatingType:""}},totalPrice:p,priceCurrency:T,reservationStatus:"http://schema.org/ReservationConfirmed"},z.push(F)}if(z.length)return z}}).call();