// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){if(!e||!r||!t)return CONTINUE;var a=Scanner.fromMessage(e);a.setLocale(r);var n,i,o,p,s,d,c,g,m,l,u,h,C,T,x,f,v,y,b,N,k,A,$,F,S,P,D,R,I,U,E=[],z=[],w={},O=[],L=function(e){if(p=e.tagContents().innerCapture(regExpFormatted(/\1:\s+(.*)/,t.car.name),1),l=e.tagContents().innerCapture(regExpFormatted(/\s+\1:\s*(.*)/,t.car.reservationId),1),x=l.nextText(t.car.driver).nextTag("td5").tagContents().innerCapture(/(.*?):/,1),c=e.nextText(t.car.totalPrice).nextTag("td5").tagContents(),s=c.innerCapture(/([\d,.]+)/,1),d=c.innerCapture(/([^\d,.]+)/,1),u=e.nextText(t.car.pickupTime).tagContents().nextDate(),C=u.nextDate(),f=u.parentTag("td5").tagContents().innerCapture(regExpFormatted(/(.*)\s+\1/,""+x),1),h=C.nextText(t.car.loc).parentTag("td6").tagContents().innerCapture(regExpFormatted(/\1:\s+(.*)/,t.car.loc),1),T=h,ASSERT(p,u,h,f))return{name:p,reservationId:l,priceCurrency:d,totalPrice:s,pickupTime:u,pickupAddress:h,dropoffTime:C,dropoffAddress:T,brand:x,provider:f}},M=function(e){for(y=e.nextText(t.flight.summary).nextTag("table5"),c=e.nextText(t.flight.price).nextTag("td5").tagContents(),s=c.innerCapture(/([\d,.]+)/,1),d=c.innerCapture(/([^\d,.]+)/,1),l=e.nextTag("table5").nextTag("table5").nextTag("tr5").nextTag("td5").tagContents().innerCapture(regExpFormatted(/\1:\s+(.*)/,t.flight.reservationId),1),K=e.nextText(t.flight.passenger);!K.nextTag("tr5").innerText(t.flight.taxes).exists();)K=K.nextTag("tr5"),p=K.nextTag("td5").tagContents(),w[""+p]={name:p,totalPrice:s,priceCurrency:d,seats:{},seatingType:{},ticketNumber:v};for(;y.innerDate().exists();)g=y.nextDate().parentAnyTag("td").tagContents().innerCapture(/\w+\s+(.*)/,1),k=g.nextDate().parentAnyTag("td"),R=k.tagContents().innerCapture(/($<departureAirport>.*)\(($<departureCode>.*)\)/),b=R.$departureCode,R=R.$departureAirport,N=a.getDetachedSpan(""+g+" "+k.firstDate()).innerDate(),A=k.nextTag("td5").nextTag("td5"),D=A.tagContents().innerCapture(/($<arrivalAirport>.*)\(($<arrivalCode>.*)\)/),$=D.$arrivalCode,D=D.$arrivalAirport,F=a.getDetachedSpan(""+g+" "+A.firstDate()).innerDate(),S=A.nextTag("td5").nextTag("td5"),S=S.tagContents().innerCapture(regExpFormatted(/^($<airlineCode>.*)\s+($<airline>.*)\n\1: ($<flightNr>\w+)/,t.flightName)),I=S.$airline,U=S.$flightNr,P=S.$airlineCode,ASSERT(I,U,N,b,F,$)&&O.push({airlineName:I,airlineCode:P,flightNumber:U,reservationId:l,departureAirport:R,departureCode:b,departureTime:N,arrivalAirport:D,arrivalCode:$,arrivalTime:F,passengers:w}),y=y.nextTag("table5")};switch(n=a.getSpan().nextText(t.bookedItems),i=n.nextTag("table4"),o=""+i.tagContents().innerCapture(/(\w+):/,1)){case t.carName:z.push(L(i));break;case t.eventName:break;case t.flightName:M(i)}for(var j,q=0;q<z.length;q++)j=z[q],m={"@context":"http://schema.org","@type":"http://schema.org/RentalCarReservation",totalPrice:j.totalPrice,priceCurrency:j.priceCurrency,reservationId:j.reservationId,reservationStatus:"http://schema.org/Reservation"+(j.reservationStatus||"Confirmed"),checkinUrl:j.checkinUrl,modifyReservationUrl:j.modifyReservationUrl,cancelReservationUrl:j.cancelReservationUrl,underName:{"@type":"http://schema.org/Person",name:j.name,email:j.email},provider:{"@type":"http://schema.org/Organization",name:j.provider},pickupTime:j.pickupTime,pickupLocation:{"@type":"http://schema.org/Place",name:j.pickupName,telephone:j.pickupTelephone,address:j.pickupAddress},dropoffTime:j.dropoffTime,dropoffLocation:{"@type":"http://schema.org/Place",name:j.dropoffName,telephone:j.dropoffTelephone,address:j.dropoffAddress}},j.brand&&(m.reservationFor={"@type":"http://schema.org/Car",brand:{"@type":"http://schema.org/Organization",name:j.brand},license:j.license,color:j.color}),E.push(m);for(var B,G=0;G<O.length;G++){B=O[q];for(var H=Object.keys(B.passengers),J=0;J<H.length;J++){var K=B.passengers[H[J]],m={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:B.airlineName,airlineCode:B.airlineCode,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:K.name},checkinUrl:B.checkinUrl,reservationId:B.reservationId,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:K.totalPrice,priceCurrency:K.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:K.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:K.seats[B.flightNumber],seatingType:K.seatingType[B.flightNumber]}}};valid(K.membershipNumber,K.programName)&&(m.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:K.membershipNumber,programName:K.programName}),E.push(m)}}return E.length?E:void 0}}).call();