/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
*
*  Copyright 2015 Adobe Systems Incorporated
*  All Rights Reserved.
*
* NOTICE:  All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any.  The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by all applicable intellectual property laws,
* including trade secret and or copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
(()=>{const e="acrobatContentScriptDisconnectStart",t="acrobatContentScriptDisconnectEnd",i="acrobat-gmail-fte-config";let o,n,r,s,a,c,m,l,p,u,g,h,d,w,f,v,T,b,P,D,C,_,E;const S=()=>{v&&(r?.addAcrobatTouchPointInTheMessageView(),s?.processForListView(),n?.processForAlreadyShownNativeViewerPrompt()),(T||_)&&l?.addExpressNativeViewerTouchpoint(),b&&p?.addExpressMessageViewTouchpoint(),C&&w?.addTouchPointToComposeBoxPDFAttachment(),P?(h?.addTouchpointToNativeViewerViaMessageView(),u?.addTouchpointToNativeViewerViaListView(),g?.processForAlreadyShownNativeViewerTouchpoint()):D&&g?.processForNativeViewerControlExperiment()},L=new MutationObserver(function(){f?.disconnectBodyObserver?L.disconnect():(L.takeRecords(),chrome?.runtime?.id?S():(c?.removeAllAcrobatTouchPoints(),l?.removeExpressTouchpoints(),g?.removeAllAcrobatNonPdfTouchPoints(),L?.disconnect()))}),V=()=>{if(document?.body)try{const e={childList:!0,subtree:!0};L.observe(document.body,e)}catch(e){}else setTimeout(V,500)},A=()=>{window.addEventListener(t,e=>f.contentScriptDisconnectEnd(e),{signal:f?.eventControllerSignal}),window.addEventListener(e,()=>(e=>{if(!chrome.runtime?.id){const i=e.createStateToTransferToNewContentScript();e.contentScriptDisconnectStart(),L?.disconnect(),window.dispatchEvent(new CustomEvent(t,{detail:{state:i}}))}})(f),{signal:f?.eventControllerSignal})},F=()=>{A(),window.dispatchEvent(new Event("orphanContentScript")),window.dispatchEvent(new CustomEvent(e)),a.addFontToDocument(f)},x=(e,t,n,r,s)=>{f&&(f.gmailConfig=e,f.iconURL="browser/images/acrobat_dc_appicon_128.png",f.iconURLListView="browser/images/acrobat_dc_trefoil_24_white.svg",f.viewerURLPrefix=chrome.runtime.getURL("viewer.html"),f.expressConfig=t,f.gmailConvertToPdfConfig=n,f.gmailImplicitDefaultViewershipConfig=r,f.gmailCompressPDFConfig=s),v&&(F(),o&&o.init(),(async()=>{const e=(new Date).getTime();let t={count:0,nextDate:e};t=(await chrome.storage.local.get(i))?.[i]||t;const o=f?.gmailConfig?.fteConfig?.tooltip;((e,t)=>-1!==e?.resetDay&&t>e?.resetDay)(o,e)&&(t.count=0,t.nextDate=e),f.fteToolTip={eligibleFte:{type:""},...t},t={[i]:t},chrome.storage.local.set(t)})(),((e,t)=>{f.isAcrobatDefaultForGmailPDFs=e?.isAcrobatDefaultForSurface||t?.isAcrobatDefaultForSurface})(e,r)),!v&&P&&(F(),o&&o.init())};chrome.runtime.onMessage.addListener(function(e){"acrobatGmailFteStateUpdated"===e.content_op?f.fteToolTip={...f.fteToolTip,...e?.fteState}:"changeDefaultViewershipForSurface"===e.content_op?"gmail"===e?.surfaceId&&chrome.runtime.id&&(e?.isDefault?m?.takeDefaultViewerShip():m?.resetDefaultViewership(),A(),S()):"acrobatTouchPointsDisabled"===e.content_op?e.acrobatShortcutSurfaceId&&"gmail"!==e.acrobatShortcutSurfaceId||(f.gmailConfig.touchPointSettingEnabled=!1,f?.isAcrobatDefaultForGmailPDFs||(v=!1,c?.removeAllAcrobatTouchPoints()),P=!1,g?.removeAllAcrobatNonPdfTouchPoints(),f?.disconnectAcrobatListeners()):"show-implicit-dv-toast"===e.content_op&&d?.shouldShowImplicitDefaultViewerToast("gmail",f)&&d?.showImplicitDefaultViewershipToast("gmail",f?.gmailImplicitDefaultViewershipConfig?.toastMessage)}),(async()=>{const e=chrome.runtime.getURL("content_scripts/gmail/state.js"),t=chrome.runtime.getURL("content_scripts/gmail/gmail-response-service.js"),i=chrome.runtime.getURL("content_scripts/gmail/native-viewer-touch-point-service.js"),v=chrome.runtime.getURL("content_scripts/gmail/message-view-touch-point-service.js"),T=chrome.runtime.getURL("content_scripts/gmail/list-view-touch-point-service.js"),b=chrome.runtime.getURL("content_scripts/utils/util.js"),P=chrome.runtime.getURL("content_scripts/gmail/util.js"),D=chrome.runtime.getURL("content_scripts/gmail/default-viewership-service.js"),C=chrome.runtime.getURL("content_scripts/express/gmail/image-gmail-touchpoint-service.js"),_=chrome.runtime.getURL("content_scripts/express/gmail/express-gmail-message-view-touchpoint-service.js"),E=chrome.runtime.getURL("content_scripts/gmail/gmail-verb-message-view.js"),S=chrome.runtime.getURL("content_scripts/gmail/gmail-verb-list-view.js"),L=chrome.runtime.getURL("content_scripts/gmail/gmail-verb-native-viewer.js"),V=chrome.runtime.getURL("content_scripts/utils/implicit-toast-service.js"),A=chrome.runtime.getURL("content_scripts/gmail/gmail-compose-attachment-touch-point-service.js");return Promise.all([import(t),import(i),import(v),import(T),import(P),import(b),import(D),import(e),import(C),import(_),import(E),import(S),import(L),import(V),import(A)]).then(e=>{o=e[0],n=e[1],r=e[2],s=e[3],c=e[4],a=e[5],m=e[6],f=e[7]?.default,l=e[8],p=e[9],h=e[10],u=e[11],g=e[12],d=e[13],w=e[14]})})().then(()=>{window.location?.search?.includes("acrobatPromotionSource")||Promise.all([chrome.runtime.sendMessage({main_op:"gmail-init"}),chrome.runtime.sendMessage({main_op:"gmail-express-init"}),chrome.runtime.sendMessage({main_op:"gmail-convert-to-pdf-init"}),chrome.runtime.sendMessage({main_op:"gmail-compress-pdf-init"}),chrome.runtime.sendMessage({main_op:"implicit-default-viewership-init",surfaceId:"gmail"})]).then(([e,t,i,o,n])=>{var r;v=((e,t)=>c?.shouldProcessForListView(e,t))(e,n),T=function(e){return e.enableGmailNVExpressMenu}(t),b=function(e){return e.enableGmailMessageViewCTA}(t),P=function(e,t){return c?.shouldProcessForConvertToPDF(e,t)}(i,e),D=function(e){return e?.enableConvertToPdfTouchpointInGmailControl}(i),r=o,C=r?.enableGmailCompressPDFTouchPoint,_=function(e){return e.enableGmailConvertToPdfInImages&&e.enableExpressTouchpointsPreference}(t),E=function(e){return e.enableGmailConvertToPdfInImagesControl}(t),(v||T||b||P||D||C||_||E)&&(function(e,t){t?.enableImplicitDefaultViewershipFeature&&(e.gmailFteToolTipStrings=t.fteToolTipStrings)}(e,n),x(e,t,i,n,o),c?.removeAllAcrobatTouchPoints(),l?.removeExpressTouchpoints(),g?.removeAllAcrobatNonPdfTouchPoints(),d?.shouldShowImplicitDefaultViewerToast("gmail",f)&&setTimeout(()=>{d?.showImplicitDefaultViewershipToast("gmail",f?.gmailImplicitDefaultViewershipConfig?.toastMessage)},1e3),S(),V(),v&&(a?.sendAnalyticsOncePerMonth("DCBrowserExt:Gmail:PromotionFeature:Enable"),a?.sendAnalyticsOncePerMonth("DCBrowserExt:Gmail:FTE:Enable")),(P||D)&&a?.sendAnalyticsOncePerMonth("DCBrowserExt:Gmail:ConvertToPdf:Enable"),_&&a?.sendAnalyticsOncePerMonth("DCBrowserExt:Gmail:Images:Enable"),E&&a?.sendAnalyticsOncePerMonth("DCBrowserExt:Gmail:Images:Control:Enable"))})})})();