// Copyright 2014 Apple Inc.  All Rights Reserved.
new ReverseTemplateList([new ReverseTemplate("hawaiiairlines.com-reservation-confirmation-en",function(e){return/^Reservation Confirmation/.test(e.subject)},function(e){if(/^Reservation Confirmation/.test(e.subject)){var r="en_US",t=Scanner.fromMessage(e);t.setLocale(r);var a,n={};if(n.reservationId="Your Hawaiian Airlines Reservation Confirmation:",n.itinerary="Air Itinerary",n.to="to",n.passenger="Name:",n.price="Total Air Travel Cost",n.checkInUrl="Web Check-in",n.frequentFlyer=/(HawaiianMiles #)/,t.getSpan().next("to your address book").exists()&&t.getSpan().next("Air Itinerary").exists())return n.passengerInfo="Passenger Information and Cost Breakdown",n.plusDay="(+1 day)",n.ticketNumber="eTicket #:",n.flight="Flight #",n.pending="Purchase Held Reservation",(a=loadHelper("hawaiiairlines.com-confirmation-skeleton-2015.js"))(e,r,n);if(t.getSpan().next("Air Itinerary").exists())return n.passengerInfo="Passenger Info and Cost Breakdown",n.ticketNumber="ETicket Number",(a=loadHelper("hawaiiairlines.com-confirmation-skeleton.js"))(e,r,n);var i,o,s,l,p,m,g,u,d,c,h,T,f,C,b,v,y,x,N,A,k,S,$,I=[],w={};o=t.getSpan().innerCapture(/Reservation Confirmation:\s+([A-Z]{6})\s+</,1),s=t.getSpan().nextText("Web Check-in <").nextLink(),p=t.getSpan().nextText("Passenger and Seating Information").nextTag("table2").allInnerTags("table3"),h=t.getSpan().nextText("TOTAL COST").parentAnyTag("td").tagContents();var D=h.innerCapture(/TOTAL COST \(([A-Z]{3})\)/,1),F=h.nextAnyTag("td").tagContents().innerCapture(/([\d,.]+)/,1);if(p.length){var R=p[0].allInnerTagsFiltered("td3");for($=1;$<p.length;$++){T=p[$].allInnerTags("td3");var P;if(T.length>=4&&((""+R[0]).indexOf("HawaiianMiles")>=0?(l=T[1].tagContents().innerCapture(/($<name>[^\d]+)(?:($<membershipNumber>[\d ]+))?/),P=l?l.$membershipNumber:null,l=l?l.$name.trim():null,i=T[2].tagContents()):(""+R[1]).indexOf("HawaiianMiles")>=0&&(l=T[1].tagContents(),P=T[2].tagContents(),i=T[3].tagContents()),valid(l)&&(w[""+l]={name:l,seats:{},seatingType:{},programName:"Hawaiian Miles",membershipNumber:P,ticketNumber:i,totalPrice:F,priceCurrency:D},m=p[$].innerTag("table4").innerTag("tr4").allInnerTags("td4").map(function(e){return e.tagContents()}),m.length%2===0)))for(var H=0;H<m.length/2;H++)m[2*H].getLength()&&(w[""+l].seats[""+m[2*H]]=m[2*H+1].tagContents())}}d=t.getSpan().nextText("Flight").nextText("Date").nextText("Depart").nextText("Arrive").parentTag("table2").allInnerTags("table3").map(function(e){return e.allInnerTagsFiltered("td3")}).filter(function(e){return e.length>=5});for($=1;$<d.length;$++)u=d[$],f=u[0].innerCapture(/($<code>\D+)($<flightNumber>\d+)/),C=f?f.$code:null,c=f?f.$flightNumber:null,g=u[1].innerDate(),v=combineDateAndTime(g,u[2].innerDate()),A=combineDateAndTime(g,u[3].innerDate()),b=u[2].innerCapture(/($<airport>.*) \(($<code>[A-Z]{3})\)/),y=b?b.$airport:null,x=b?b.$code:null,N=u[3].innerCapture(/($<airport>.*) \(($<code>[A-Z]{3})\)[^+]+($<nextDay>\+1)?/),k=N?N.$airport:null,S=N?N.$code:null,N&&valid(N.$nextDay)&&(A=modifyDate(A,1)),ASSERT(C,c,v,x,A,S)&&I.push({airlineCode:C,flightNumber:c,departureTime:v,departureAirport:y,departureCode:x,arrivalTime:A,arrivalAirport:k,arrivalCode:S,passengers:w});var M=[];for($=0;$<I.length;$++)for(var O=I[$],z=Object.keys(O.passengers),L=0;L<z.length;L++){var j=O.passengers[z[L]],U={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:O.airlineName,airlineCode:O.airlineCode,flightNumber:O.flightNumber,departureAirportFuzzy:O.departureAirport,departureAirportCode:O.departureCode,departureTime:O.departureTime,arrivalAirportFuzzy:O.arrivalAirport,arrivalAirportCode:O.arrivalCode,arrivalTime:O.arrivalTime},underName:{"@type":"http://schema.org/Person",name:j.name},checkinUrl:s,reservationId:o,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:j.totalPrice,priceCurrency:j.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:i,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:j.seats[""+O.airlineCode+(""+O.flightNumber)],seatingType:j.seatingType[O.flightNumber]}}};valid(j.membershipNumber,j.programName)&&(U.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:j.membershipNumber,programName:j.programName}),M.push(U)}if(M.length)return M}},"0/1/2/3/4/5/240/454/455","SG50529d95")]);