// Copyright 2014 Apple Inc.  All Rights Reserved.
new ReverseTemplateList([new ReverseTemplate("finnair-flight-confirmation-en",function(e){return/^Your confirmation, Booking Ref/.test(e.subject)},function(e){if(/^Your confirmation, Booking Ref/.test(e.subject)){var t=Scanner.fromMessage(e);t.setLocale("en_GB");var r,a,i,n,o,p,s,m,d,g,l,c,u,h,T,C,E,R,f,v,F=t.getSpan(),x=[],y={};for(a=F.nextText("YOUR BOOKING REFERENCE: ").parentTag("td2").tagContents().innerCapture(regExpFormatted(/\1(.+)\s/,"YOUR BOOKING REFERENCE: "),1).trim(),m=F.nextText("PRICE: ").parentTag("td2").tagContents().innerCapture(regExpFormatted(/\1([\d,.]+)\s(.+)/,"PRICE: "),1).trim(),d=F.nextText("PRICE: ").parentTag("td2").tagContents().innerCapture(regExpFormatted(/\1([\d,.]+)\s(.+)/,"PRICE: "),2).trim(),o=F.nextText("PASSENGERS").parentTag("td2").split("Passenger"),o.shift(),f=0;f<o.length;f++)n=(""+o[f]).match(/[\d:]\s(.+)\s/)[1].trim(),y[""+n]={name:n,totalPrice:m,priceCurrency:d};for(p=F.nextText("YOUR BOOKING REFERENCE:").nextTag("table3").allInnerTagsFiltered("td3"),f=0;f<p.length;f++)if(/DEPARTURE/.test(p[f])||/RETURN/.test(p[f])){var N=p[f].split("cabin");for(N.pop(),v=0;v<N.length;v++)[,u,C,g,s,c,T]=N[v].innerCapture(/(.+)- (.+).*\s.*\s([A-Z0-9]{2})([\d]+).*([\d]{2}:[\d]{2}) - ([\d]{2}:[\d]{2})/),l=N[v].innerDate(),l=getFuzzyDate(t.getDetachedSpan(""+l)),c=getFuzzyDate(t.getDetachedSpan(""+c)),T=getFuzzyDate(t.getDetachedSpan(""+T)),c=combineDateAndTime(l,c),T=combineDateAndTime(l,T),/\(Terminal/.test(C)&&(C=C.innerCapture(regExpFormatted(/(.+)\1/,"(Terminal"),1).trim()),/\(Terminal/.test(u)&&(u=u.innerCapture(regExpFormatted(/(.+)\1/,"(Terminal"),1).trim()),ASSERT(s,c,T)&&x.push({airlineCode:g,flightNumber:s,departureTime:c,departureCode:h,departureAirport:u.trim(),arrivalTime:T,arrivalCode:E,arrivalAirport:C.trim(),passengers:y})}var A=[];for(f=0;f<x.length;f++){var S=x[f],b=Object.keys(S.passengers);for(v=0;v<b.length;v++){R=S.passengers[b[v]];var z={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:"InterJet",airlineCode:S.airlineCode,flightNumber:S.flightNumber,departureAirportFuzzy:S.departureAirport,departureAirportCode:S.departureCode,departureTime:S.departureTime,arrivalAirportFuzzy:S.arrivalAirport,arrivalAirportCode:S.arrivalCode,arrivalTime:S.arrivalTime},underName:{"@type":"http://schema.org/Person",name:R.name},checkinUrl:i,reservationId:a,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:R.totalPrice,priceCurrency:R.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:r,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:"",seatingType:""}}};A.push(z)}}if(A.length)return A}},"0/1/2/3/4/5/240/439/441","SGc8148a67")]);