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NC,KAAMd,sBAERV,EAAG,8BACDuB,KAAM,gDACNC,KAAMd,sBAERV,EAAG,8BACDuB,KAAM,8CACNC,KAAMd,sBAGHL,sBACJL,EAAG,+BACDgB,KAAMR,mCAAmCiB,gBAAkB,IAAMxB,cAAgB,KACjFyB,OAEJ,G","sources":["webpack://woocommerce-bookings/webpack/bootstrap","webpack://woocommerce-bookings/webpack/runtime/compat get default export","webpack://woocommerce-bookings/webpack/runtime/define property getters","webpack://woocommerce-bookings/webpack/runtime/hasOwnProperty shorthand","webpack://woocommerce-bookings/external window \"jQuery\"","webpack://woocommerce-bookings/./src/js/user-my-account.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","const __WEBPACK_NAMESPACE_OBJECT__ = window[\"jQuery\"];","/*global moment, wc_bookings_user_my_account_params*/\nimport jQuery from 'jquery';\n\njQuery( document ).ready( function( $ ) {\n\tvar localTimezone = moment.tz.guess();\n\tvar shouldDisplayNotices = false;\n\n\t// Confirm booking cancellation.\n\t$( '.booking-cancel' ).on( 'click', 'a.cancel', function() {\n\t\treturn window.confirm( wc_bookings_user_my_account_params.cancel_confirmation );\n\t} );\n\n\t/**\n\t * Callback that checks if we should convert or add timezone string to the booking time.\n\t *\n\t * Since admin does not know what timezone the user is in, it is not possible to set a proper\n\t * local timezone for the booking manually create by admin. If timezone conversion is enabled\n\t * and the user timezone is different then admin timezone the user will see wrong start and end times.\n\t *\n\t * Because the booking start and end time are filterable, it's possible for those times to use different\n\t * format. We validate the time and only convert times that use the same format as Bookings is using.\n\t *\n\t * Reference: https://github.com/woocommerce/woocommerce-bookings/issues/2650\n\t *\n\t * @param {element index } index\n\t * @param {jQuery element } element\n\t */\n\tvar maybeConvertDateTime = function( index, element ) {\n\t\tvar elementTimezone = $( element ).data( 'timezone' );\n\t\tvar elementTime = $( element ).text().trim();\n\n\t\tif ( $( element ).data( 'allDay' ) === 'yes' ) {\n\t\t\t// Don't adjust for day availability type events.\n\t\t\treturn;\n\t\t}\n\n\t\tif ( elementTimezone === localTimezone ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the format is changed, only add timezone string.\n\t\tif ( ! moment( elementTime, wc_bookings_user_my_account_params.datetime_format, true ).isValid() ) {\n\t\t\t$( element ).text( elementTime + ' ' + elementTimezone );\n\t\t\tshouldDisplayNotices = true;\n\t\t\treturn;\n\t\t}\n\n\t\tvar formattedDate = moment // eslint-disable-line vars-on-top\n\t\t\t.tz( elementTime, wc_bookings_user_my_account_params.datetime_format, elementTimezone )\n\t\t\t.tz( localTimezone )\n\t\t\t.format( wc_bookings_user_my_account_params.datetime_format );\n\n\t\t$( element ).text( formattedDate );\n\t};\n\n\tif ( ! wc_bookings_user_my_account_params.timezone_conversion ) {\n\t\t// No conversion necessary, don't adjust the time display.\n\t\treturn;\n\t}\n\n\tif ( ! localTimezone ) {\n\t\t// Local timezone not found. We can't compare the bookings timezone to local - abort!\n\t\treturn;\n\t}\n\n\t$( '.my_account_bookings' )\n\t\t.find( 'tbody .booking-start-date' )\n\t\t.each( maybeConvertDateTime );\n\n\t$( '.my_account_bookings' )\n\t\t.find( 'tbody .booking-end-date' )\n\t\t.each( maybeConvertDateTime );\n\n\t$( '.woocommerce-order-details' )\n\t\t.find( '.wc-booking-summary-list .booking-start-date' )\n\t\t.each( maybeConvertDateTime );\n\n\t$( '.woocommerce-order-details' )\n\t\t.find( '.wc-booking-summary-list .booking-end-date' )\n\t\t.each( maybeConvertDateTime );\n\n\t// Inform user about the display of timezones for some of the items.\n\tif ( shouldDisplayNotices ) {\n\t\t$( '.bookings-my-account-notice' )\n\t\t\t.text( wc_bookings_user_my_account_params.timezone_notice + ' ' + localTimezone + '.' )\n\t\t\t.show();\n\t}\n} );\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","window","jQuery","document","ready","$","localTimezone","moment","tz","guess","shouldDisplayNotices","on","confirm","wc_bookings_user_my_account_params","cancel_confirmation","maybeConvertDateTime","index","element","elementTimezone","data","elementTime","text","trim","datetime_format","isValid","formattedDate","format","timezone_conversion","find","each","timezone_notice","show"],"sourceRoot":""}