// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){if(!e||!t||!r)return CONTINUE;var a=Scanner.fromMessage(e);a.setLocale(t);var i,n,l,p,o,s,u,c,g,h,d,m,v,T,C,x,y,f=a.getSpan(),F=[],S={};for(n=(""+f.withInterval(f.nextText(r.reservationId).getEnd(),f.nextText(r.ticketNumber).getStart()).trim()).match(/(.+)\s/)[1],i=(""+f.withInterval(f.nextText(r.ticketNumber).getEnd(),f.nextText(r.flightDetails).getStart()).trim()).match(/(.+)\s/)[1],s=f.nextText(r.totalPrice).nextTag("th1").tagContents().innerCapture(/($<priceCurrency>[\w]+)\s($<totalPrice>[\d,.]+)/),u=s?s.$totalPrice:null,c=s?s.$priceCurrency:null,p=f.withInterval(f.nextText(r.flightDetails).getEnd(),f.nextText(r.endOfFlightDetails).getStart()).allInnerTagsFiltered("table1"),y=0;y<p.length;y++){var A=p[y].allInnerTagsFiltered("tr1");h=(""+A[0]).match(/,(.+)/)[1].trim();var N=(""+A[1].allInnerDates()).split(",");d=N[0],T=N[1],h=h.replace(/,/g,""),N=h.split(" "),h=N[1]+" "+N[0]+" "+N[2],d=getFuzzyDate(a.getDetachedSpan(h+" "+d)),T=getFuzzyDate(a.getDetachedSpan(h+" "+T)),[,m,v]=A[1].innerCapture(/\n(.+)\((.+)\)/);var z=A[1].allInnerTagsFiltered("th1");[,C,x]=z[0].innerCapture(/\n(.+)\((.+)\)/),[,g,o]=z[1].innerCapture(/([0-9A-Z]{2}?)(?:\W+)(\d+)/),ASSERT(o,d,T)&&F.push({airlineCode:g,flightNumber:o,departureTime:d,departureCode:v,departureAirport:m.trim(),arrivalTime:T,arrivalCode:x,arrivalAirport:C.trim(),passengers:S})}var I=[];for(y=0;y<F.length;y++){var b=F[y],D={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:"Copa Airlines",airlineCode:"CM",flightNumber:b.flightNumber,departureAirportFuzzy:b.departureAirport,departureAirportCode:b.departureCode,departureTime:b.departureTime,arrivalAirportFuzzy:b.arrivalAirport,arrivalAirportCode:b.arrivalCode,arrivalTime:b.arrivalTime},underName:{"@type":"http://schema.org/Person",name:""},checkinUrl:l,reservationId:n,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:u,priceCurrency:c,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:i,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:"",seatingType:""}}};I.push(D)}return I.length?I:void 0}}).call();