@snippyly/plugin-staging 1.0.32 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/snippyly.js +1 -1
package/package.json
CHANGED
package/snippyly.js
CHANGED
|
@@ -55,7 +55,7 @@ const ei=1;
|
|
|
55
55
|
*/
|
|
56
56
|
const ni=(i=>(...t)=>({_$litDirective$:i,values:t}))(class extends class{constructor(i){}get _$AU(){return this._$AM._$AU}_$AT(i,t,e){this._$Ct=i,this._$AM=t,this._$Ci=e}_$AS(i,t){return this.update(i,t)}update(i,t){return this.render(...t)}}{constructor(i){var t;if(super(i),i.type!==ei||"class"!==i.name||(null===(t=i.strings)||void 0===t?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(i){return" "+Object.keys(i).filter((t=>i[t])).join(" ")+" "}update(i,[t]){var e,n;if(void 0===this.et){this.et=new Set,void 0!==i.strings&&(this.st=new Set(i.strings.join(" ").split(/\s/).filter((i=>""!==i))));for(const i in t)t[i]&&!(null===(e=this.st)||void 0===e?void 0:e.has(i))&&this.et.add(i);return this.render(t)}const s=i.element.classList;this.et.forEach((i=>{i in t||(s.remove(i),this.et.delete(i))}));for(const i in t){const e=!!t[i];e===this.et.has(i)||(null===(n=this.st)||void 0===n?void 0:n.has(i))||(e?(s.add(i),this.et.add(i)):(s.remove(i),this.et.delete(i)))}return j}}),si="snippyly-cursor",oi="snippyly-comments",ri="snippyly-comments-sidebar",li="enable-url-navigation",hi=(i,t,e=!1,n="localStorage")=>{try{const s=e?btoa(t):t;"localStorage"===n?localStorage.setItem(i,s):sessionStorage.setItem(i,s)}catch(i){console.warn("Error in setLocalStorage: ",i)}},ai=(i,t=!1,e="localStorage")=>{try{let n=null;return n="localStorage"===e?localStorage.getItem(i):sessionStorage.getItem(i),n&&t?atob(n):n}catch(i){return console.warn("Error in getLocalStorage: ",i),null}},ci=(i,t="localStorage")=>{try{"localStorage"===t?localStorage.removeItem(i):sessionStorage.removeItem(i)}catch(i){console.warn("Error in removeLocalStorageData: ",i)}},di=(...i)=>{if(i)switch(i.length){case 1:return s`calc(${i[0]}rem * var(--snippyly-base-rem-unit, 1))`;case 2:return s`calc(${i[0]}rem * var(--snippyly-base-rem-unit, 1)) calc(${i[1]}rem * var(--snippyly-base-rem-unit, 1))`;case 3:return s`calc(${i[0]}rem * var(--snippyly-base-rem-unit, 1)) calc(${i[1]}rem * var(--snippyly-base-rem-unit, 1))
|
|
57
57
|
calc(${i[2]}rem * var(--snippyly-base-rem-unit, 1))`;case 4:return s`calc(${i[0]}rem * var(--snippyly-base-rem-unit, 1)) calc(${i[1]}rem * var(--snippyly-base-rem-unit, 1))
|
|
58
|
-
calc(${i[2]}rem * var(--snippyly-base-rem-unit, 1)) calc(${i[3]}rem * var(--snippyly-base-rem-unit, 1))`}return s`0`};var pi=function(i,t,e,n){for(var s,o=arguments.length,r=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,e):n,l=i.length-1;l>=0;l--)(s=i[l])&&(r=(o<3?s(r):o>3?s(t,e,r):s(t,e))||r);return o>3&&r&&Object.defineProperty(t,e,r),r};let ui=class extends q{constructor(){super(),this._loadPlugin=!1,this.comments=[],this.addCommentMode=!1,this._expanded=!0,this.staging=true,this.copyLinkTooltip="Copy Link",this.invalidApiKey=!1,this.isUserGlobalContact=!1,this.addWindowClickEventListener=()=>{try{this.windowClickEventListener||(this.windowClickEventListener=()=>{this.menuOpenedId&&(this.menuOpenedId=void 0)},window.addEventListener("click",this.windowClickEventListener))}catch(i){console.warn("Error in addWindowClickEventListener: ",i)}},this.removeWindowClickEventListener=()=>{try{window.removeEventListener("click",this.windowClickEventListener),this.windowClickEventListener=void 0}catch(i){console.warn("Error in removeWindowClickEventListener: ",i)}},this.setWindowEventListner=()=>{try{window.addEventListener("locationchange",(()=>{this.checkUrl()}))}catch(i){console.warn("Error in setWindowEventListner: ",i)}},this.urlChangeListener=()=>{try{const i=history.pushState;history.pushState=function(){const t=i.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),t};const t=history.replaceState;history.replaceState=function(){const i=t.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),i},window.addEventListener("popstate",(()=>{window.dispatchEvent(new Event("locationchange"))}))}catch(i){console.warn("Error in urlChangeListener: ",i)}},this.checkUrl=()=>{var i;try{const t=new URL(document.location),e=t.searchParams;if(e.has("snippyly_google_token")){const n=JSON.parse(atob(e.get("snippyly_google_token"))),s={},o=(null===(i=n.providerData)||void 0===i?void 0:i.length)?n.providerData[0]:null;s.userId=n.uid,s.name=n.displayName||(null==o?void 0:o.displayName),s.email=n.email||(null==o?void 0:o.email),s.photoUrl=(null==n?void 0:n.photoURL)||(null==o?void 0:o.photoURL),s.contacts=window.SNIPPYLY_USER_CONTACTS||[],hi("snippyly-user",JSON.stringify(s),!0),e.delete("snippyly_google_token"),window.history.replaceState({},document.title,t.href)}e.has("review")?(hi("review","true",!1,"sessionStorage"),"true"!==e.get("review")&&(e.delete("review"),e.append("review","true"),window.history.replaceState({},document.title,t.href)),this.loadPluginUI()):ai("review",!1,"sessionStorage")&&(e.append("review","true"),window.history.replaceState({},document.title,t.href),this.loadPluginUI()),this.setVersionInUrl()}catch(i){console.warn("Error in checkUrl: ",i)}},this.detectVersion=()=>{try{if(this.projectVersionKey){const i=new URL(document.location).searchParams;if(i.get(this.projectVersionKey))this.projectVersion=i.get(this.projectVersionKey);else if(window.snippylyInitialLoadUrl){const i=new URL(window.snippylyInitialLoadUrl).searchParams;i.get(this.projectVersionKey)&&(this.projectVersion=i.get(this.projectVersionKey))}this.projectVersion&&hi("projectVersion",this.projectVersion,!1,"sessionStorage")}}catch(i){console.warn("Error in detectVersion: ",i)}},this.setVersionInUrl=()=>{try{const i=this.projectVersionKey||ai("projectVersionKey",!1,"sessionStorage"),t=this.projectVersion||ai("projectVersion",!1,"sessionStorage");if(i&&t){const e=new URL(document.location),n=e.searchParams;n.get(i)||(n.set(i,t),window.history.replaceState({},document.title,e.href))}}catch(i){console.warn("Error in setVersionInUrl: ",i)}},this.loadPluginUI=()=>{try{if(this.loadPlugin)return;if(this.loadPlugin=!0,!document.querySelector(oi)){const i=document.createElement(oi);null==i||i.addEventListener("signIn",(()=>{this.loginWithGoogle()})),window.document.body.appendChild(i)}if(!document.querySelector(ri)){const i=document.createElement(ri);i.setAttribute(li,"true"),window.document.body.appendChild(i)}if(!document.querySelector(si)){const i=document.createElement(si);window.document.body.appendChild(i)}((i="",t=!1,e)=>{if(console.log("load snippyly called"),document.getElementById("snippylyScript"))e&&e();else{const n=document.createElement("script");n.src=`https://cdn.jsdelivr.net/npm/@snippyly/sdk${t?"-staging":""}${i?"@"+i:""}/snippyly.js`,n.id="snippylyScript",n.type="module",document.body.appendChild(n),n.onload=()=>{e&&e()}}})(void 0,this.staging,(()=>{window.Snippyly&&this.initializeSnippyly()}))}catch(i){console.warn("Error in loadPluginUI: ",i)}},this.initializeSnippyly=async()=>{try{await(null===Snippyly||void 0===Snippyly?void 0:Snippyly.init(this.apiKey));const i=new URL(document.location).searchParams;this.documentId=((i,t=0)=>{try{let e=3735928559^t,n=1103547991^t;for(let t,s=0;s<i.length;s++)t=i.charCodeAt(s),e=Math.imul(e^t,2654435761),n=Math.imul(n^t,1597334677);return e=Math.imul(e^e>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),4294967296*(2097151&n)+(e>>>0)}catch(i){return console.warn("Error in cyrb53: ",i),0}})((i=>{let t;return t=i.includes("http")?new URL(i):new URL("http://"+i),t.hostname.replace("www.","")})(window.location.origin))+"",null===Snippyly||void 0===Snippyly||Snippyly.setDocumentId(this.documentId+"");const t=new URL(document.location);t.searchParams.delete("review"),t.searchParams.delete("sreviewId"),t.searchParams.delete("scommentId");const e=i.get("sversion")||this.projectVersion;this.location={url:t.href,version:e},this.setLocation(),this.commentElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getCommentElement(),this.commentElement&&(this.commentElement.enableTextComments(!0),this.commentElement.enableSignInButton(!0),this.commentElement.enableAttachment(!0),this.commentElement.showScreenSizeInfo(!0),this.commentElement.addCommentModeChange&&this.commentElement.addCommentModeChange().subscribe((i=>{this.addCommentMode=i}))),this.selectionElement=Snippyly.getSelectionElement(),this.selectionElement&&this.selectionElement.enableLiveSelection(!0),this.identifySnippyly()}catch(i){console.warn("Error in initializeSnippyly: ",i)}},this.setLocation=()=>{try{null===Snippyly||void 0===Snippyly||Snippyly.setLocation(JSON.parse(JSON.stringify(this.location)))}catch(i){console.warn("Error in setLocation: ",i)}},this.identifySnippyly=async()=>{var i;try{this.invalidApiKey=!1;let i={name:"Anonymous User",email:"anonymous@snippyly.com",userId:"anonymous",isAnonymous:!0};if(ai("snippyly-user",!0)){const t=JSON.parse(ai("snippyly-user",!0));(null==t?void 0:t.email)&&(i=t)}i.contacts=window.SNIPPYLY_USER_CONTACTS||[],i.isAnonymous?delete i.groupId:i.groupId=Snippyly.getDocumentId()+"",await Snippyly.identify(i),(null==i?void 0:i.isAnonymous)||(this.snippylyUser=JSON.parse(JSON.stringify(i))),this.getComments(),this.checkGlobalUserContact()}catch(t){t&&"string"==typeof t&&(null===(i=null==t?void 0:t.toLowerCase())||void 0===i?void 0:i.includes("invalid"))&&(this.invalidApiKey=!0),console.warn("Error in identifySnippyly: ",t)}},this.getComments=()=>{try{this.commentElement&&(this.commentSubscription&&this.commentSubscription.unsubscribe(),this.commentSubscription=this.commentElement.getAllCommentAnnotations(this.documentId).subscribe((i=>{this.comments=i,"All"!==this.viewMode&&(this.viewMode?this.comments=i.filter((i=>{var t;return(null===(t=null==i?void 0:i.location)||void 0===t?void 0:t.view)===this.viewMode})):this.comments=this.comments.filter((i=>{var t;return!(null===(t=null==i?void 0:i.location)||void 0===t?void 0:t.view)})))})))}catch(i){console.warn("Error in getComments: ",i)}},this.checkGlobalUserContact=()=>{try{this.commentElement&&this.commentElement.isUserGlobalContact().subscribe((i=>{!this.isUserGlobalContact&&i&&this.setViewMode("All"),this.isUserGlobalContact=i,i||this.setViewMode(null)}))}catch(i){console.warn("Error in checkGlobalUserContact: ",i)}},this.toggleCommentSidebar=()=>{try{this.commentElement&&this.commentElement.toggleCommentSidebar()}catch(i){console.warn("Error in toggleCommentSidebar: ",i)}},this.toggleSnippylyPluginToolbar=()=>{try{this.expanded=!this.expanded}catch(i){console.warn("Error in toggleSnippylyPluginToolbar: ",i)}},this.loginWithGoogle=()=>{try{window.open(`https://snippyly-login-staging.web.app/?redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(i){console.warn("Error in loginWithGoogle: ",i)}},this.removeSnippyly=async()=>{try{ci("review","sessionStorage"),ci("sreviewId","sessionStorage"),ci("projectVersionKey","sessionStorage"),ci("projectVersion","sessionStorage");const i=new URL(document.location),t=i.searchParams;t.delete("sreviewId"),t.delete("review"),this.projectVersionKey&&t.delete(this.projectVersionKey),this.projectVersion=void 0,this.projectVersionKey=void 0,delete window.snippylyInitialLoadUrl,window.history.replaceState({},document.title,i.href),window.location.reload()}catch(i){console.warn("Error in removeSnippyly: ",i)}},this.signOutUser=async()=>{try{await Snippyly.signOutUser(),ci("snippyly-user"),this.snippylyUser=void 0,window.open(`https://snippyly-login-staging.web.app/?signout=true&redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(i){console.warn("Error in signOutUser: ",i)}},this.toggleMenu=(i,t)=>{try{i.stopPropagation(),this.menuOpenedId===t?this.menuOpenedId=void 0:this.menuOpenedId=t}catch(i){console.warn("Error in toggleMenu: ",i)}},this.copyLink=()=>{try{navigator.clipboard.writeText(window.location.href),this.copyLinkTooltip="Link copied!",setTimeout((()=>{this.copyLinkTooltip="Copy Link"}),2e3)}catch(i){console.warn("Error in copyLink: ",i)}},this.setViewMode=i=>{try{this.viewMode!==i&&(this.viewMode=i,i?this.location.view=i:delete this.location.view,this.setLocation(),this.getComments())}catch(i){console.warn("Error in setViewMode: ",i)}},this.setAttribute("snippyly-comment-disabled","true");try{this.expanded=!0,this.detectVersion(),this.setWindowEventListner(),this.urlChangeListener(),this.checkUrl(),console.log("*** Staging Mode ON! ***")}catch(i){console.warn("Error in constructor: ",i)}}get loadPlugin(){return this._loadPlugin}set loadPlugin(i){this._loadPlugin=i,this.loadPlugin?this.classList.add("visible"):this.classList.remove("visible")}get expanded(){return this._expanded}set expanded(i){this._expanded=i,this.expanded?this.classList.add("expanded"):this.classList.remove("expanded")}get projectVersionKey(){return this._projectVersionKey}set projectVersionKey(i){try{this._projectVersionKey=i,this.projectVersionKey&&hi("projectVersionKey",this.projectVersionKey,!1,"sessionStorage"),this.detectVersion()}catch(i){console.warn("Error in set projectVersionKey: ",i)}}get menuOpenedId(){return this._menuOpenedId}set menuOpenedId(i){this._menuOpenedId=i,this.menuOpenedId?this.addWindowClickEventListener():this.removeWindowClickEventListener()}render(){var i,t,e,n,s,o,r,l,h,a,c,d,p,u;return this.loadPlugin?U`
|
|
58
|
+
calc(${i[2]}rem * var(--snippyly-base-rem-unit, 1)) calc(${i[3]}rem * var(--snippyly-base-rem-unit, 1))`}return s`0`};var pi=function(i,t,e,n){for(var s,o=arguments.length,r=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,e):n,l=i.length-1;l>=0;l--)(s=i[l])&&(r=(o<3?s(r):o>3?s(t,e,r):s(t,e))||r);return o>3&&r&&Object.defineProperty(t,e,r),r};let ui=class extends q{constructor(){super(),this._loadPlugin=!1,this.comments=[],this.addCommentMode=!1,this._expanded=!0,this.staging=true,this.copyLinkTooltip="Copy Link",this.invalidApiKey=!1,this.isUserGlobalContact=!1,this.addWindowClickEventListener=()=>{try{this.windowClickEventListener||(this.windowClickEventListener=()=>{this.menuOpenedId&&(this.menuOpenedId=void 0)},window.addEventListener("click",this.windowClickEventListener))}catch(i){console.warn("Error in addWindowClickEventListener: ",i)}},this.removeWindowClickEventListener=()=>{try{window.removeEventListener("click",this.windowClickEventListener),this.windowClickEventListener=void 0}catch(i){console.warn("Error in removeWindowClickEventListener: ",i)}},this.setWindowEventListner=()=>{try{window.addEventListener("locationchange",(()=>{this.checkUrl()}))}catch(i){console.warn("Error in setWindowEventListner: ",i)}},this.urlChangeListener=()=>{try{const i=history.pushState;history.pushState=function(){const t=i.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),t};const t=history.replaceState;history.replaceState=function(){const i=t.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),i},window.addEventListener("popstate",(()=>{window.dispatchEvent(new Event("locationchange"))}))}catch(i){console.warn("Error in urlChangeListener: ",i)}},this.checkUrl=()=>{var i;try{const t=new URL(document.location),e=t.searchParams;if(e.has("snippyly_google_token")){const n=JSON.parse(atob(e.get("snippyly_google_token"))),s={},o=(null===(i=n.providerData)||void 0===i?void 0:i.length)?n.providerData[0]:null;s.userId=n.uid,s.name=n.displayName||(null==o?void 0:o.displayName),s.email=n.email||(null==o?void 0:o.email),s.photoUrl=(null==n?void 0:n.photoURL)||(null==o?void 0:o.photoURL),s.contacts=window.SNIPPYLY_USER_CONTACTS||[],hi("snippyly-user",JSON.stringify(s),!0),e.delete("snippyly_google_token"),window.history.replaceState({},document.title,t.href)}e.has("review")?(hi("review","true",!1,"sessionStorage"),"true"!==e.get("review")&&(e.delete("review"),e.append("review","true"),window.history.replaceState({},document.title,t.href)),this.loadPluginUI()):ai("review",!1,"sessionStorage")&&(e.append("review","true"),window.history.replaceState({},document.title,t.href),this.loadPluginUI()),this.setVersionInUrl()}catch(i){console.warn("Error in checkUrl: ",i)}},this.detectVersion=()=>{try{if(this.projectVersionKey){const i=new URL(document.location).searchParams;if(i.get(this.projectVersionKey))this.projectVersion=i.get(this.projectVersionKey);else if(window.snippylyInitialLoadUrl){const i=new URL(window.snippylyInitialLoadUrl).searchParams;i.get(this.projectVersionKey)&&(this.projectVersion=i.get(this.projectVersionKey))}this.projectVersion&&hi("projectVersion",this.projectVersion,!1,"sessionStorage")}}catch(i){console.warn("Error in detectVersion: ",i)}},this.setVersionInUrl=()=>{try{const i=this.projectVersionKey||ai("projectVersionKey",!1,"sessionStorage"),t=this.projectVersion||ai("projectVersion",!1,"sessionStorage");if(i&&t){const e=new URL(document.location),n=e.searchParams;n.get(i)||(n.set(i,t),window.history.replaceState({},document.title,e.href))}}catch(i){console.warn("Error in setVersionInUrl: ",i)}},this.loadPluginUI=()=>{try{if(this.loadPlugin)return this.generateLocation(),void this.setViewMode(this.viewMode);if(this.loadPlugin=!0,!document.querySelector(oi)){const i=document.createElement(oi);null==i||i.addEventListener("signIn",(()=>{this.loginWithGoogle()})),window.document.body.appendChild(i)}if(!document.querySelector(ri)){const i=document.createElement(ri);i.setAttribute(li,"true"),window.document.body.appendChild(i)}if(!document.querySelector(si)){const i=document.createElement(si);window.document.body.appendChild(i)}((i="",t=!1,e)=>{if(console.log("load snippyly called"),document.getElementById("snippylyScript"))e&&e();else{const n=document.createElement("script");n.src=`https://cdn.jsdelivr.net/npm/@snippyly/sdk${t?"-staging":""}${i?"@"+i:""}/snippyly.js`,n.id="snippylyScript",n.type="module",document.body.appendChild(n),n.onload=()=>{e&&e()}}})(void 0,this.staging,(()=>{window.Snippyly&&this.initializeSnippyly()}))}catch(i){console.warn("Error in loadPluginUI: ",i)}},this.initializeSnippyly=async()=>{try{await(null===Snippyly||void 0===Snippyly?void 0:Snippyly.init(this.apiKey)),this.documentId=((i,t=0)=>{try{let e=3735928559^t,n=1103547991^t;for(let t,s=0;s<i.length;s++)t=i.charCodeAt(s),e=Math.imul(e^t,2654435761),n=Math.imul(n^t,1597334677);return e=Math.imul(e^e>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),4294967296*(2097151&n)+(e>>>0)}catch(i){return console.warn("Error in cyrb53: ",i),0}})((i=>{let t;return t=i.includes("http")?new URL(i):new URL("http://"+i),t.hostname.replace("www.","")})(window.location.origin))+"",null===Snippyly||void 0===Snippyly||Snippyly.setDocumentId(this.documentId+""),this.generateLocation(),this.setLocation(),this.commentElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getCommentElement(),this.commentElement&&(this.commentElement.enableTextComments(!0),this.commentElement.enableSignInButton(!0),this.commentElement.enableAttachment(!0),this.commentElement.showScreenSizeInfo(!0),this.commentElement.addCommentModeChange&&this.commentElement.addCommentModeChange().subscribe((i=>{this.addCommentMode=i}))),this.selectionElement=Snippyly.getSelectionElement(),this.selectionElement&&this.selectionElement.enableLiveSelection(!0),this.identifySnippyly()}catch(i){console.warn("Error in initializeSnippyly: ",i)}},this.generateLocation=()=>{try{const i=new URL(document.location).searchParams,t=new URL(document.location);t.searchParams.delete("review"),t.searchParams.delete("sreviewId"),t.searchParams.delete("scommentId");const e=i.get("sversion")||this.projectVersion;this.location={url:t.href,version:e}}catch(i){console.warn("Error in generateLocation: ",i)}},this.setLocation=()=>{try{null===Snippyly||void 0===Snippyly||Snippyly.setLocation(JSON.parse(JSON.stringify(this.location)))}catch(i){console.warn("Error in setLocation: ",i)}},this.identifySnippyly=async()=>{var i;try{this.invalidApiKey=!1;let i={name:"Anonymous User",email:"anonymous@snippyly.com",userId:"anonymous",isAnonymous:!0};if(ai("snippyly-user",!0)){const t=JSON.parse(ai("snippyly-user",!0));(null==t?void 0:t.email)&&(i=t)}i.contacts=window.SNIPPYLY_USER_CONTACTS||[],i.isAnonymous?delete i.groupId:i.groupId=Snippyly.getDocumentId()+"",await Snippyly.identify(i),(null==i?void 0:i.isAnonymous)||(this.snippylyUser=JSON.parse(JSON.stringify(i))),this.getComments(),this.checkGlobalUserContact()}catch(t){t&&"string"==typeof t&&(null===(i=null==t?void 0:t.toLowerCase())||void 0===i?void 0:i.includes("invalid"))&&(this.invalidApiKey=!0),console.warn("Error in identifySnippyly: ",t)}},this.getComments=()=>{try{this.commentElement&&(this.commentSubscription&&this.commentSubscription.unsubscribe(),this.commentSubscription=this.commentElement.getAllCommentAnnotations(this.documentId).subscribe((i=>{this.comments=i,"All"!==this.viewMode&&(this.viewMode?this.comments=i.filter((i=>{var t;return(null===(t=null==i?void 0:i.location)||void 0===t?void 0:t.view)===this.viewMode})):this.comments=this.comments.filter((i=>{var t;return!(null===(t=null==i?void 0:i.location)||void 0===t?void 0:t.view)})))})))}catch(i){console.warn("Error in getComments: ",i)}},this.checkGlobalUserContact=()=>{try{this.commentElement&&this.commentElement.isUserGlobalContact().subscribe((i=>{!this.isUserGlobalContact&&i&&this.setViewMode("All"),this.isUserGlobalContact=i,i||this.setViewMode(null)}))}catch(i){console.warn("Error in checkGlobalUserContact: ",i)}},this.toggleCommentSidebar=()=>{try{this.commentElement&&this.commentElement.toggleCommentSidebar()}catch(i){console.warn("Error in toggleCommentSidebar: ",i)}},this.toggleSnippylyPluginToolbar=()=>{try{this.expanded=!this.expanded}catch(i){console.warn("Error in toggleSnippylyPluginToolbar: ",i)}},this.loginWithGoogle=()=>{try{window.open(`https://snippyly-login-staging.web.app/?redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(i){console.warn("Error in loginWithGoogle: ",i)}},this.removeSnippyly=async()=>{try{ci("review","sessionStorage"),ci("sreviewId","sessionStorage"),ci("projectVersionKey","sessionStorage"),ci("projectVersion","sessionStorage");const i=new URL(document.location),t=i.searchParams;t.delete("sreviewId"),t.delete("review"),this.projectVersionKey&&t.delete(this.projectVersionKey),this.projectVersion=void 0,this.projectVersionKey=void 0,delete window.snippylyInitialLoadUrl,window.history.replaceState({},document.title,i.href),window.location.reload()}catch(i){console.warn("Error in removeSnippyly: ",i)}},this.signOutUser=async()=>{try{await Snippyly.signOutUser(),ci("snippyly-user"),this.snippylyUser=void 0,window.open(`https://snippyly-login-staging.web.app/?signout=true&redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(i){console.warn("Error in signOutUser: ",i)}},this.toggleMenu=(i,t)=>{try{i.stopPropagation(),this.menuOpenedId===t?this.menuOpenedId=void 0:this.menuOpenedId=t}catch(i){console.warn("Error in toggleMenu: ",i)}},this.copyLink=()=>{try{navigator.clipboard.writeText(window.location.href),this.copyLinkTooltip="Link copied!",setTimeout((()=>{this.copyLinkTooltip="Copy Link"}),2e3)}catch(i){console.warn("Error in copyLink: ",i)}},this.setViewMode=i=>{try{this.viewMode=i,i?this.location.view=i:delete this.location.view,this.setLocation(),this.getComments()}catch(i){console.warn("Error in setViewMode: ",i)}},this.setAttribute("snippyly-comment-disabled","true");try{this.expanded=!0,this.detectVersion(),this.setWindowEventListner(),this.urlChangeListener(),this.checkUrl(),console.log("*** Staging Mode ON! ***")}catch(i){console.warn("Error in constructor: ",i)}}get loadPlugin(){return this._loadPlugin}set loadPlugin(i){this._loadPlugin=i,this.loadPlugin?this.classList.add("visible"):this.classList.remove("visible")}get expanded(){return this._expanded}set expanded(i){this._expanded=i,this.expanded?this.classList.add("expanded"):this.classList.remove("expanded")}get projectVersionKey(){return this._projectVersionKey}set projectVersionKey(i){try{this._projectVersionKey=i,this.projectVersionKey&&hi("projectVersionKey",this.projectVersionKey,!1,"sessionStorage"),this.detectVersion()}catch(i){console.warn("Error in set projectVersionKey: ",i)}}get menuOpenedId(){return this._menuOpenedId}set menuOpenedId(i){this._menuOpenedId=i,this.menuOpenedId?this.addWindowClickEventListener():this.removeWindowClickEventListener()}render(){var i,t,e,n,s,o,r,l,h,a,c,d,p,u;return this.loadPlugin?U`
|
|
59
59
|
<div class="snippyly-plugin-container ${ni({expanded:this.expanded,active:null===(i=this.snippylyUser)||void 0===i?void 0:i.userId,"comment-mode-enabled":this.addCommentMode})}">
|
|
60
60
|
<div class="snippyly-logo-container snippyly-menu-trigger" @click=${()=>this.toggleSnippylyPluginToolbar()}>
|
|
61
61
|
${this.expanded?null:U`
|