// Copyright 2014 Apple Inc.  All Rights Reserved.
new ReverseTemplateList([new ReverseTemplate("canadiannorth-flight-confirmation-en",function(e){return/^Canadian North Electronic Ticket Receipt/.test(e.subject)},function(e){if(/^Canadian North Electronic Ticket Receipt/.test(e.subject)){var t=Scanner.fromMessage(e);t.setLocale("en_CA");var r,a,n,i,s,o,p,l,c,g,u,d,m,h,T,C,v,x,f,b,k=t.getSpan(),y=[],A={};for(a=k.nextText("Booking reference/Record locator").nextTag("td4").tagContents().trim(),s=k.nextText("Your ticket(s) number(s) is/are:").parentTag("td3").tagContents().innerCapture(regExpFormatted(/\1([\w\s\W]+)/,"Your ticket(s) number(s) is/are:"),1).split(/\n/),s.shift(),f=0;f<s.length;f++)[,i,r]=s[f].innerCapture(/(.+):\s(\d+)\s<https/),A[""+i]={name:i.trim(),ticketNumber:r.trim(),seats:{}};for(l=k.withInterval(k.nextText("Booking reference/Record locator").getEnd(),k.nextText("Your ticket(s) number(s) is/are:").getStart()).allInnerTagsFiltered("table5"),f=0;f<l.length;f++){[,g,u,c]=l[f].innerCapture(/(.+)\sFlight Number\s([A-Z0-9]+)\s(\d+)\s/);var N=l[f].allInnerTagsFiltered("table6");[,h,m]=N[0].innerText("Departure:").nextTag("td6").tagContents().innerCapture(/(.+?)\s(.+)\n/),d=N[0].innerText("Departure:").nextTag("td6").tagContents().innerDate(),[,v,C]=N[0].innerText("Arrival:").nextTag("td6").tagContents().innerCapture(/(.+?)\s(.+)\n/),T=N[0].innerText("Arrival:").nextTag("td6").tagContents().innerDate(),p=N[2].split("/td6"),o="";for(b=0;b<p.length;b++){var S=p[b];i=S.innerText("Seat(s):").previousTag("td7").tagContents(),/Check-In Required/.test(S)||([,o]=S.innerText("Seat(s):").nextTag("td7").tagContents().innerCapture(/(.+)\s\//));for(var F=Object.keys(A),R=0;R<F.length;R++){var z=A[F[R]];if(0===(""+z.name).localeCompare(""+i)){A[F[R]].seats[""+d]=o;break}}}ASSERT(c,d,T)&&y.push({airlineCode:u,flightNumber:c,departureTime:d,departureCode:h,departureAirport:m.trim(),arrivalTime:T,arrivalCode:v,arrivalAirport:C.trim(),passengers:A})}var E=[];for(f=0;f<y.length;f++){var I=y[f],j=Object.keys(I.passengers);for(b=0;b<j.length;b++){x=I.passengers[j[b]];var w={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:I.airlineName,airlineCode:I.airlineCode,flightNumber:I.flightNumber,departureAirportFuzzy:I.departureAirport,departureAirportCode:I.departureCode,departureTime:I.departureTime,arrivalAirportFuzzy:I.arrivalAirport,arrivalAirportCode:I.arrivalCode,arrivalTime:I.arrivalTime},underName:{"@type":"http://schema.org/Person",name:x.name},checkinUrl:n,reservationId:a,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:x.totalPrice,priceCurrency:x.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:x.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:x.seats[""+I.departureTime],seatingType:""}}};E.push(w)}}if(E.length)return E}},"0/1/2/3/4/5/240/387/388","SGb337ee47")]);