/*************************************************************************
* 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.
**************************************************************************/
(async()=>{let e,t,o=null;const n="GoogleDocs",c="ConvertToPdf",r="acrobat-convert-to-pdf-touch-point",a={document:{surface:"gdocs_chrome",fileExtension:".docx",exportFormat:"docx"},spreadsheets:{surface:"gsheets_chrome",fileExtension:".xlsx",exportFormat:"xlsx"},presentation:{surface:"gslides_chrome",fileExtension:".pptx",exportFormat:"pptx"}},s=(e,t={})=>{try{chrome.runtime.sendMessage({main_op:"analytics",analytics:[[e,t]]})}catch(e){}},i=e=>{const{authuser:t}=e.detail;t&&(o=t)},d=()=>{const e=(e=>{try{return new URL(e).searchParams.get("authuser")}catch(t){const o=e.match(/[?&]authuser=([^&]*)/);return o?o[1]:null}})(window.location.href);null!==e?o=e:((()=>{const e=document.createElement("script");e.src=chrome.runtime.getURL("content_scripts/gdocs/google-docs-fetch-interceptor.js"),(document.head||document.documentElement).appendChild(e),e.onload=()=>{e.remove()}})(),document.addEventListener("acrobat-extension-authuser",i))},l=(t,r,i)=>{if("click"===t.type||"mousedown"===t.type||"Enter"===t.key){const t=window.location.href,d=((e,t)=>{const o=new RegExp(`\\/${t}\\/d\\/([a-zA-Z0-9_-]+)`),n=e.match(o);return n?n[1]:null})(t,i);if(d){const l=a[i]?.surface,u=a[i]?.fileExtension,m=a[i]?.exportFormat,p=e?.buildAcrobatPromotionSource(l,"convert_to_pdf");let h;if(null!==o)h=`&authuser=${o}`;else{const e=t.match(/\/u\/(\d+)\//);h=e?`&authuser=${e[1]}`:"&authuser=0"}const w=`${`https://docs.google.com/${i}/d/${d}/export?format=${m}${h}`}&acrobatPromotionSource=${p}`,g=`${chrome.runtime.getURL("viewer.html")}?pdfurl=${encodeURIComponent(w)}&pdffilename=${encodeURIComponent(r+u)}&acrobatPromotionWorkflow=createpdf`;s("DCBrowserExt:DirectVerb:CTA:Clicked",{source:`${n}_${i}`,workflow:c}),window.updateFTEStateWhenGoogleDocsTouchPointClicked&&window.updateFTEStateWhenGoogleDocsTouchPointClicked(),window.open(g,"_blank")}}},u=async(t,o)=>{if(document.getElementsByClassName(r)?.length>0)return;const a=e.getElementFromParent(t?.selectors?.touchPointContainer,document),i=e?.getElementFromParent(t?.selectors?.docTitle,document);if(i){const d=i?.value,u=document.createElement("div"),m=e?.createAcrobatIconElement("acrobat-icon","browser/images/acrobat_dc_appicon_128.png"),p=(e=>{const t=document.createElement("span");return t.classList.add("acrobat-convert-to-pdf-touch-point-text"),t.textContent=e?.text?.acrobatTouchPointText,t})(t),h=(e=>{const t=document.createElement("div");return t.classList.add("acrobat-convert-to-pdf-touch-point-tooltip"),t.textContent=e?.text?.acrobatTouchPointTooltip,t})(t);u.appendChild(m),u.appendChild(p),u.appendChild(h),u.className=r,u.addEventListener("click",e=>l(e,d,o)),u.addEventListener("keydown",e=>l(e,d,o)),u.setAttribute("tabindex","0");const w=e.getFirstElementBasedOnSelectors(t?.selectors?.shareButton,document);w&&(a.insertBefore(u,w),s("DCBrowserExt:DirectVerb:CTA:Shown",{source:`${n}_${o}`,workflow:c}),chrome.runtime.sendMessage({main_op:"google_docs_touch_point_added"}))}};(async()=>{const o=window.location.pathname.split("/")?.length>1?window.location.pathname.split("/")[1]:null,r=await chrome.runtime.sendMessage({main_op:"google_docs_init"});r?.validPaths?.includes(o)&&r?.enableGoogleDocsConvertToPDFTouchPoint&&(async()=>{[e]=await Promise.all([import(chrome.runtime.getURL("content_scripts/utils/util.js"))])})().then(()=>{d(),s("DCBrowserExt:DirectVerb:CTA:Enabled",{source:`${n}_${o}`,workflow:c}),document.addEventListener("acrobat-extension-authuser",i),e?.addFontToDocument({adobeCleanFontAdded:!1}),((e,o)=>{t=new MutationObserver(()=>{u(e,o)}),t.observe(document.body,{childList:!0,subtree:!0})})(r,o)})})()})();