@snippyly/plugin-staging 1.0.69 → 1.0.71
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 +5 -5
package/package.json
CHANGED
package/snippyly.js
CHANGED
|
@@ -390,7 +390,7 @@ class Fe{constructor(t,e,i){this.auth=null,this.messaging=null,this.appCheck=nul
|
|
|
390
390
|
*/
|
|
391
391
|
class us extends ri{}us.Encryptor=class extends us{processBlock(t,e){const i=t,n=this._cipher,{blockSize:s}=n,o=this._iv;let r=this._counter;o&&(this._counter=o.slice(0),r=this._counter,this._iv=void 0),(t=>{const e=t;e[0]=ds(e[0]),0===e[0]&&(e[1]=ds(e[1]))})(r);const a=r.slice(0);n.encryptBlock(a,0);for(let t=0;t<s;t+=1)i[e+t]^=a[t]}},us.Decryptor=us.Encryptor;class ps extends ri{}ps.Encryptor=class extends ps{processBlock(t,e){this._cipher.encryptBlock(t,e)}},ps.Decryptor=class extends ps{processBlock(t,e){this._cipher.decryptBlock(t,e)}};class fs extends ri{}fs.Encryptor=class extends fs{processBlock(t,e){const i=t,n=this._cipher,{blockSize:s}=n,o=this._iv;let r=this._keystream;o&&(this._keystream=o.slice(0),r=this._keystream,this._iv=void 0),n.encryptBlock(r,0);for(let t=0;t<s;t+=1)i[e+t]^=r[t]}},fs.Decryptor=fs.Encryptor;const vs={pad(t,e){const i=4*e,n=i-t.sigBytes%i;t.concat(Ue.random(n-1)).concat(Ue.create([n<<24],1))},unpad(t){const e=t,i=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=i}},ws={pad(t,e){const i=t,n=4*e;i.clamp(),i.sigBytes+=n-(t.sigBytes%n||n)},unpad(t){const e=t,i=e.words;for(let t=e.sigBytes-1;t>=0;t-=1)if(i[t>>>2]>>>24-t%4*8&255){e.sigBytes=t+1;break}}},ys={pad(t,e){t.concat(Ue.create([2147483648],1)),ws.pad(t,e)},unpad(t){const e=t;ws.unpad(e),e.sigBytes-=1}},gs={stringify:t=>t.ciphertext.toString(Re),parse(t){const e=Re.parse(t);return di.create({ciphertext:e})}};var ms={lib:{Base:Ne,WordArray:Ue,BufferedBlockAlgorithm:He,Hasher:ze,Cipher:si,StreamCipher:oi,BlockCipherMode:ri,BlockCipher:hi,CipherParams:di,SerializableCipher:pi,PasswordBasedCipher:vi},x64:{Word:Ke,WordArray:Je},enc:{Hex:Re,Latin1:je,Utf8:Pe,Utf16:gi,Utf16BE:yi,Utf16LE:mi,Base64:We},algo:{HMAC:Ve,MD5:ti,SHA1:Ci,SHA224:Li,SHA256:Di,SHA384:Hi,SHA512:Ri,SHA3:qi,RIPEMD160:fn,PBKDF2:yn,EvpKDF:ni,AES:Mn,DES:Pn,TripleDES:zn,Rabbit:Gn,RabbitLegacy:es,RC4:ss,RC4Drop:rs},mode:{CBC:li,CFB:cs,CTR:hs,CTRGladman:us,ECB:ps,OFB:fs},pad:{Pkcs7:ci,AnsiX923:{pad(t,e){const i=t,n=i.sigBytes,s=4*e,o=s-n%s,r=n+o-1;i.clamp(),i.words[r>>>2]|=o<<24-r%4*8,i.sigBytes+=o},unpad(t){const e=t,i=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=i}},Iso10126:vs,Iso97971:ys,NoPadding:{pad(){},unpad(){}},ZeroPadding:ws},format:{OpenSSL:ui,Hex:gs},kdf:{OpenSSL:fi},MD5:ei,HmacMD5:ii,SHA1:xi,HmacSHA1:Si,SHA224:Ti,HmacSHA224:Oi,SHA256:Mi,HmacSHA256:Bi,SHA384:zi,HmacSHA384:Vi,SHA512:ji,HmacSHA512:Pi,SHA3:Qi,HmacSHA3:tn,RIPEMD160:vn,HmacRIPEMD160:wn,PBKDF2:(t,e,i)=>yn.create(i).compute(t,e),EvpKDF:(t,e,i)=>ni.create(i).compute(t,e),AES:Bn,DES:Hn,TripleDES:Vn,Rabbit:Xn,RabbitLegacy:is,RC4:os,RC4Drop:as};const bs=(t,e,i=!1,n="localStorage")=>{try{const s=i?btoa(e):e;"localStorage"===n?localStorage.setItem(t,s):sessionStorage.setItem(t,s)}catch(t){console.warn("Error in setLocalStorage: ",t),Le("Error in setLocalStorage: ",t)}},Cs=(t,e=!1,i="localStorage")=>{try{let n=null;return n="localStorage"===i?localStorage.getItem(t):sessionStorage.getItem(t),n&&e?atob(n):n}catch(t){return console.warn("Error in getLocalStorage: ",t),Le("Error in getLocalStorage: ",t),null}},xs=(t,e="localStorage")=>{try{"localStorage"===e?localStorage.removeItem(t):sessionStorage.removeItem(t)}catch(t){console.warn("Error in removeLocalStorageData: ",t),Le("Error in removeLocalStorageData: ",t)}},Ss=(...t)=>{if(t)switch(t.length){case 1:return r`calc(${t[0]}rem * var(--snippyly-base-rem-unit, 1))`;case 2:return r`calc(${t[0]}rem * var(--snippyly-base-rem-unit, 1)) calc(${t[1]}rem * var(--snippyly-base-rem-unit, 1))`;case 3:return r`calc(${t[0]}rem * var(--snippyly-base-rem-unit, 1)) calc(${t[1]}rem * var(--snippyly-base-rem-unit, 1))
|
|
392
392
|
calc(${t[2]}rem * var(--snippyly-base-rem-unit, 1))`;case 4:return r`calc(${t[0]}rem * var(--snippyly-base-rem-unit, 1)) calc(${t[1]}rem * var(--snippyly-base-rem-unit, 1))
|
|
393
|
-
calc(${t[2]}rem * var(--snippyly-base-rem-unit, 1)) calc(${t[3]}rem * var(--snippyly-base-rem-unit, 1))`}return r`0`},Es=t=>{try{return t.replace(/#.*$/,"")}catch(e){return console.warn("Error in removeHashFromUrl: ",e),Le("Error in removeHashFromUrl: ",e),t}},ks=(t,e,i)=>{try{const n=ms.enc.Utf8.parse(e),s=ms.enc.Utf8.parse(i);return ms.AES.encrypt(ms.enc.Utf8.parse(t),n,{keySize:32,iv:s,mode:ms.mode.CBC,padding:ms.pad.Pkcs7}).toString()}catch(e){return console.warn("Error in encrypt: ",e),Le("Error in encrypt: ",e),t}},Fs=(t,e,i)=>{try{const n=ms.enc.Utf8.parse(e),s=ms.enc.Utf8.parse(i);return ms.AES.decrypt(t,n,{keySize:32,iv:s,mode:ms.mode.CBC,padding:ms.pad.Pkcs7}).toString(ms.enc.Utf8)}catch(t){return console.warn("Error in decrypt: ",t),Le("Error in decrypt: ",t),null}},$s=()=>{try{const t=Cs("snippyly-user",!0);if(t){const e=ks(t,pt,ft);bs("_sfut",e,!0)}xs("snippyly-user")}catch(t){console.warn("Error in moveSnippylyUserToST: ",t),Le("Error in moveSnippylyUserToST: ",t)}},
|
|
393
|
+
calc(${t[2]}rem * var(--snippyly-base-rem-unit, 1)) calc(${t[3]}rem * var(--snippyly-base-rem-unit, 1))`}return r`0`},Es=t=>{try{return t.replace(/#.*$/,"")}catch(e){return console.warn("Error in removeHashFromUrl: ",e),Le("Error in removeHashFromUrl: ",e),t}},ks=(t,e,i)=>{try{const n=ms.enc.Utf8.parse(e),s=ms.enc.Utf8.parse(i);return ms.AES.encrypt(ms.enc.Utf8.parse(t),n,{keySize:32,iv:s,mode:ms.mode.CBC,padding:ms.pad.Pkcs7}).toString()}catch(e){return console.warn("Error in encrypt: ",e),Le("Error in encrypt: ",e),t}},Fs=(t,e,i)=>{try{const n=ms.enc.Utf8.parse(e),s=ms.enc.Utf8.parse(i);return ms.AES.decrypt(t,n,{keySize:32,iv:s,mode:ms.mode.CBC,padding:ms.pad.Pkcs7}).toString(ms.enc.Utf8)}catch(t){return console.warn("Error in decrypt: ",t),Le("Error in decrypt: ",t),null}},$s=()=>{try{const t=Cs("_sfut",!0);if(t){const e=Fs(t,pt,ft);if(e)return JSON.parse(e);console.warn("Error in getUserFromToken: ","Invalid token."),xs("_sfut")}else{const t=Cs("snippyly-user",!0);if(t)return As(),JSON.parse(t)}return null}catch(t){return console.warn("Error in getUserFromToken: ",t),Le("Error in getUserFromToken: ",t),null}},As=()=>{try{const t=Cs("snippyly-user",!0);if(t){const e=ks(t,pt,ft);bs("_sfut",e,!0)}xs("snippyly-user")}catch(t){console.warn("Error in moveSnippylyUserToST: ",t),Le("Error in moveSnippylyUserToST: ",t)}},Is=r`
|
|
394
394
|
|
|
395
395
|
.wrap {
|
|
396
396
|
padding: 32px;
|
|
@@ -676,7 +676,7 @@ class us extends ri{}us.Encryptor=class extends us{processBlock(t,e){const i=t,n
|
|
|
676
676
|
transform: translate(50%, 41%) rotate(45deg);
|
|
677
677
|
transform-origin: center;
|
|
678
678
|
}
|
|
679
|
-
`,
|
|
679
|
+
`,_s=r`
|
|
680
680
|
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
|
|
681
681
|
|
|
682
682
|
* {
|
|
@@ -687,7 +687,7 @@ class us extends ri{}us.Encryptor=class extends us{processBlock(t,e){const i=t,n
|
|
|
687
687
|
position: fixed;
|
|
688
688
|
bottom: 0;
|
|
689
689
|
right: 0;
|
|
690
|
-
z-index:
|
|
690
|
+
z-index: 2147483577;
|
|
691
691
|
margin: ${Ss(1.5)};
|
|
692
692
|
margin-bottom: ${Ss(3)}; // Added to prevent overlap between plugin UI and webflow badge
|
|
693
693
|
max-width: 100vw !important;
|
|
@@ -980,7 +980,7 @@ class us extends ri{}us.Encryptor=class extends us{processBlock(t,e){const i=t,n
|
|
|
980
980
|
padding: 0px 2px;
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
|
-
`;var _s=function(t,e,i,n){for(var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,a=t.length-1;a>=0;a--)(s=t[a])&&(r=(o<3?s(r):o>3?s(e,i,r):s(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r};let Ds=class extends q{constructor(){var i,n,s,o,r;super(),this._loadPlugin=!1,this.comments=[],this.addCommentMode=!1,this._expanded=!0,this.loading=!1,this.staging=true,this.copyLinkTooltip="Copy Link",this.invalidApiKey=!1,this.isUserGlobalContact=!1,this.exitReviewModeCalled=!1,this.addWindowClickEventListener=()=>{try{this.windowClickEventListener||(this.windowClickEventListener=()=>{this.menuOpenedId&&(this.menuOpenedId=void 0)},window.addEventListener("click",this.windowClickEventListener))}catch(t){console.warn("Error in addWindowClickEventListener: ",t),Le("Error in addWindowClickEventListener: ",t)}},this.removeWindowClickEventListener=()=>{try{window.removeEventListener("click",this.windowClickEventListener),this.windowClickEventListener=void 0}catch(t){console.warn("Error in removeWindowClickEventListener: ",t),Le("Error in removeWindowClickEventListener: ",t)}},this.setWindowEventListner=()=>{try{window.addEventListener("locationchange",(()=>{this.checkUrl()}))}catch(t){console.warn("Error in setWindowEventListner: ",t),Le("Error in setWindowEventListner: ",t)}},this.urlChangeListener=()=>{try{const t=history.pushState;history.pushState=function(){const e=t.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),e};const e=history.replaceState;history.replaceState=function(){const t=e.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),t},window.addEventListener("popstate",(()=>{window.dispatchEvent(new Event("locationchange"))}))}catch(t){console.warn("Error in urlChangeListener: ",t),Le("Error in urlChangeListener: ",t)}},this.checkUrl=()=>{try{const t=new URL(document.location),e=t.searchParams;if(e.has("st")||e.has("snippyly_google_token")){if(e.has("st")){const t=decodeURIComponent(e.get("st")),i=Fs(t,pt,ft),n=i&&JSON.parse(i);if(n){const t={};t.userId=n.uid,t.name=n.displayName,t.email=n.email,t.photoUrl=null==n?void 0:n.photoURL;const e=JSON.stringify(t),i=ks(e,pt,ft);bs("_sfut",i,!0)}}else if(e.has("snippyly_google_token")){const t=JSON.parse(atob(e.get("snippyly_google_token"))),i={};i.userId=t.uid,i.name=t.displayName,i.email=t.email,i.photoUrl=null==t?void 0:t.photoURL,bs("snippyly-user",JSON.stringify(i),!0)}e.delete("st"),e.delete("snippyly_google_token"),window.history.replaceState({},document.title,t.href)}e.has("review")?(bs("review","true",!1),"true"!==e.get("review")&&(e.delete("review"),e.append("review","true"),window.history.replaceState({},document.title,t.href)),this.loadPluginUI()):Cs("review",!1)&&(e.append("review","true"),window.history.replaceState({},document.title,t.href),this.loadPluginUI()),this.setVersionInUrl()}catch(t){console.warn("Error in checkUrl: ",t),Le("Error in checkUrl: ",t)}},this.detectVersion=()=>{try{if(this.projectVersionKey){const t=new URL(document.location).searchParams;if(t.get(this.projectVersionKey))this.projectVersion=t.get(this.projectVersionKey);else if(window.snippylyInitialLoadUrl){const t=new URL(window.snippylyInitialLoadUrl).searchParams;t.get(this.projectVersionKey)&&(this.projectVersion=t.get(this.projectVersionKey))}this.projectVersion&&bs("projectVersion",this.projectVersion,!1,"sessionStorage")}else{const t=new URL(document.location).searchParams;t.has("review")&&t.has("sversion")&&(bs("projectVersionKey","sversion",!1,"sessionStorage"),this.projectVersion=t.get("sversion"),this.projectVersion&&bs("projectVersion",this.projectVersion,!1,"sessionStorage"))}}catch(t){console.warn("Error in detectVersion: ",t),Le("Error in detectVersion: ",t)}},this.setVersionInUrl=()=>{try{const t=this.projectVersionKey||Cs("projectVersionKey",!1,"sessionStorage"),e=this.projectVersion||Cs("projectVersion",!1,"sessionStorage");if(t&&e){const i=new URL(document.location),n=i.searchParams;n.get(t)||(n.set(t,e),window.history.replaceState({},document.title,i.href))}}catch(t){console.warn("Error in setVersionInUrl: ",t),Le("Error in setVersionInUrl: ",t)}},this.loadPluginUI=()=>{try{if(!this.apiKey)return;if(this.loadPlugin)return this.generateLocation(),void this.setViewMode(this.viewMode);if(this.loadPlugin=!0,!document.querySelector(at)){const t=document.createElement(at);null==t||t.addEventListener("signIn",(()=>{this.loginWithGoogle()})),window.document.body.appendChild(t)}if(!document.querySelector(lt)){const t=document.createElement(lt);t.setAttribute(ut,"true"),window.document.body.appendChild(t)}if(!document.querySelector(rt)){const t=document.createElement(rt);window.document.body.appendChild(t)}if(!document.querySelector(ct)){const t=document.createElement(ct);window.document.body.appendChild(t)}if(!document.querySelector(ht)){const t=document.createElement(ht);window.document.body.appendChild(t)}if(!document.querySelector(dt)){const t=document.createElement(dt);window.document.body.appendChild(t)}this.initializeSnippyly()}catch(t){console.warn("Error in loadPluginUI: ",t),Le("Error in loadPluginUI: ",t)}},this.initializeSnippyly=async()=>{var i,n,s;try{await(n=this.apiKey,s={options:{staging:this.staging,version:"latest"}},t(void 0,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,6,,7]),[4,(o=null==s?void 0:s.options,new Promise((function(t,e){var i=document.getElementById("snippylyScript"),n=!1,s="latest";if(o&&(o.staging&&(n=o.staging),o.version&&(s=o.version)),(null==o?void 0:o.version)||(s="1.0.78"),i)t();else{var r=document.createElement("script");r.src="https://cdn.jsdelivr.net/npm/@snippyly/sdk".concat(n?"-staging":"","@").concat(s,"/snippyly.js"),r.id="snippylyScript",r.type="module",document.body.appendChild(r),r.onload=function(){t()},r.onerror=function(){e(new Error("Failed to load Snippyly script"))}}})))];case 1:return e.sent(),t=window.Snippyly,s?[4,t.init(n,s)]:[3,3];case 2:return e.sent(),[3,5];case 3:return[4,t.init(n)];case 4:e.sent(),e.label=5;case 5:return(null==t?void 0:t.st)&&(null==t||t.st("client")),[2,t];case 6:return i=e.sent(),console.error(i),[2,null];case 7:return[2]}var o}))}))),Snippyly&&(null===Snippyly||void 0===Snippyly||Snippyly.sf(!0)),Snippyly&&Be({sdkVersion:null===Snippyly||void 0===Snippyly?void 0:Snippyly.version,sdkType:"client"}),this.documentId=((t,e=0)=>{try{let i=3735928559^e,n=1103547991^e;for(let e,s=0;s<t.length;s++)e=t.charCodeAt(s),i=Math.imul(i^e,2654435761),n=Math.imul(n^e,1597334677);return i=Math.imul(i^i>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(i^i>>>13,3266489909),4294967296*(2097151&n)+(i>>>0)}catch(t){return console.warn("Error in cyrb53: ",t),Le("Error in cyrb53: ",t),0}})((t=>{let e;return e=t.includes("http")?new URL(t):new URL("http://"+t),e.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.contactElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getContactElement(),this.rewriterElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getRewriterElement(),this.commentElement&&(this.commentElement.enableTextComments(!0),this.commentElement.enableSignInButton(!0),this.commentElement.enableAttachment(!0),this.commentElement.showScreenSizeInfo(!0),this.commentElement.showCommentIndex(!0),this.commentElement.addCommentModeChange&&this.commentElement.addCommentModeChange().subscribe((t=>{this.addCommentMode=t}))),this.selectionElement=Snippyly.getSelectionElement(),this.selectionElement&&this.selectionElement.enableLiveSelection(!0),this.rewriterElement&&(null===(i=this.rewriterElement)||void 0===i||i.enableRewriter()),this.identifySnippyly()}catch(t){console.warn("Error in initializeSnippyly: ",t),Le("Error in initializeSnippyly: ",t)}},this.generateLocation=()=>{try{const t=new URL(document.location).searchParams,e=new URL(document.location);e.searchParams.delete("review"),e.searchParams.delete("sreviewId"),e.searchParams.delete("scommentId");const i=t.get("sversion")||this.projectVersion;this.location={url:Es(e.href),version:i}}catch(t){console.warn("Error in generateLocation: ",t),Le("Error in generateLocation: ",t)}},this.setLocation=()=>{try{window.Snippyly&&(null===Snippyly||void 0===Snippyly?void 0:Snippyly.setLocation)&&(null===Snippyly||void 0===Snippyly||Snippyly.setLocation(JSON.parse(JSON.stringify(this.location))))}catch(t){console.warn("Error in setLocation: ",t),Le("Error in setLocation: ",t)}},this.identifySnippyly=async()=>{var t,e;try{this.invalidApiKey=!1;let e={name:"Anonymous User",email:"anonymous@snippyly.com",userId:"anonymous",isAnonymous:!0};const i=(()=>{try{const t=Cs("_sfut",!0);if(t){const e=Fs(t,pt,ft);if(e)return JSON.parse(e);console.warn("Error in getUserFromToken: ","Invalid token."),xs("_sfut")}else{const t=Cs("snippyly-user",!0);if(t)return $s(),JSON.parse(t)}return null}catch(t){return console.warn("Error in getUserFromToken: ",t),Le("Error in getUserFromToken: ",t),null}})();(null==i?void 0:i.email)&&(e=i),e.isAnonymous?delete e.groupId:e.groupId=Snippyly.getDocumentId()+"",(null===(t=null==e?void 0:e.contacts)||void 0===t?void 0:t.length)&&(e.contacts=[]),(null==e?void 0:e.isAnonymous)||(this.loading=!0),await Snippyly.identify(e),this.loading=!1,(null==e?void 0:e.isAnonymous)||(this.snippylyUser=JSON.parse(JSON.stringify(e))),Be({clientUserId:null==e?void 0:e.userId}),this.getComments(),this.checkGlobalUserContact()}catch(t){this.loading=!1,this.signInError=!0,t&&"string"==typeof t&&(null===(e=null==t?void 0:t.toLowerCase())||void 0===e?void 0:e.includes("invalid"))&&(this.invalidApiKey=!0),console.warn("Error in identifySnippyly: ",t),Le("Error in identifySnippyly: ",t)}},this.getComments=()=>{try{this.commentElement&&(this.commentSubscription&&this.commentSubscription.unsubscribe(),this.commentSubscription=this.commentElement.getAllCommentAnnotations(this.documentId).subscribe((t=>{this.comments=t,"All"!==this.viewMode&&(this.viewMode?this.comments=t.filter((t=>{var e;return(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.view)===this.viewMode})):this.comments=this.comments.filter((t=>{var e;return!(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.view)})))})))}catch(t){console.warn("Error in getComments: ",t),Le("Error in getComments: ",t)}},this.checkGlobalUserContact=()=>{try{this.contactElement&&this.contactElement.isUserGlobalContact().subscribe((t=>{!this.isUserGlobalContact&&t&&this.setViewMode("All"),this.isUserGlobalContact=t,t||this.setViewMode(null)}))}catch(t){console.warn("Error in checkGlobalUserContact: ",t),Le("Error in checkGlobalUserContact: ",t)}},this.toggleCommentSidebar=()=>{try{this.commentElement&&this.commentElement.toggleCommentSidebar()}catch(t){console.warn("Error in toggleCommentSidebar: ",t),Le("Error in toggleCommentSidebar: ",t)}},this.toggleSnippylyPluginToolbar=()=>{try{this.expanded=!this.expanded}catch(t){console.warn("Error in toggleSnippylyPluginToolbar: ",t),Le("Error in toggleSnippylyPluginToolbar: ",t)}},this.loginWithGoogle=()=>{try{if(this.loading)return;window.open(`https://snippyly-login-staging.web.app/?redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(t){console.warn("Error in loginWithGoogle: ",t),Le("Error in loginWithGoogle: ",t)}},this.removeSnippyly=async()=>{try{this.exitReviewModeCalled=!0,xs("review"),xs("sreviewId"),xs("projectVersionKey","sessionStorage"),xs("projectVersion","sessionStorage");const t=new URL(document.location),e=t.searchParams;e.delete("sreviewId"),e.delete("review"),this.projectVersionKey&&e.delete(this.projectVersionKey),e.delete("sversion"),this.projectVersion=void 0,this.projectVersionKey=void 0,delete window.snippylyInitialLoadUrl,window.history.replaceState({},document.title,t.href),window.location.reload()}catch(t){console.warn("Error in removeSnippyly: ",t),Le("Error in removeSnippyly: ",t)}},this.signOutUser=async()=>{try{await Snippyly.signOutUser(),xs("snippyly-user"),xs("_sfut"),this.snippylyUser=void 0,window.open(`https://snippyly-login-staging.web.app/?signout=true&redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(t){console.warn("Error in signOutUser: ",t),Le("Error in signOutUser: ",t)}},this.toggleMenu=(t,e)=>{try{t.stopPropagation(),this.menuOpenedId===e?this.menuOpenedId=void 0:this.menuOpenedId=e}catch(t){console.warn("Error in toggleMenu: ",t),Le("Error in toggleMenu: ",t)}},this.copyLink=()=>{try{navigator.clipboard.writeText(window.location.href),this.copyLinkTooltip="Link copied!",setTimeout((()=>{this.copyLinkTooltip="Copy Link"}),2e3)}catch(t){console.warn("Error in copyLink: ",t),Le("Error in copyLink: ",t)}},this.setViewMode=t=>{try{this.viewMode=t,t?this.location.view=t:delete this.location.view,this.setLocation(),this.getComments()}catch(t){console.warn("Error in setViewMode: ",t),Le("Error in setViewMode: ",t)}},this.goToAdminPortal=()=>{try{window.open("https://snippyly-self-serve-platform.web.app/","_blank")}catch(t){console.warn("Error in goToAdminPortal: ",t),Le("Error in goToAdminPortal: ",t)}},this.setAttribute("snippyly-comment-disabled","true"),null===(n=null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.style)||void 0===n||n.setProperty("transform","none","important"),null===(r=null===(o=null===(s=null===document||void 0===document?void 0:document.body)||void 0===s?void 0:s.parentElement)||void 0===o?void 0:o.style)||void 0===r||r.setProperty("transform","none","important");try{this.expanded=!0,this.detectVersion(),this.setWindowEventListner(),this.urlChangeListener(),this.checkUrl(),console.log("*** Staging Mode ON! ***")}catch(t){console.warn("Error in constructor: ",t),Le("Error in constructor: ",t)}}get loadPlugin(){return this._loadPlugin}set loadPlugin(t){this._loadPlugin=t,this.loadPlugin?this.classList.add("visible"):this.classList.remove("visible")}get expanded(){return this._expanded}set expanded(t){this._expanded=t,this.expanded?this.classList.add("expanded"):this.classList.remove("expanded")}get apiKey(){return this._apiKey}set apiKey(t){this._apiKey=t,Be({apiKey:this.apiKey}),this.checkUrl()}get projectVersionKey(){return this._projectVersionKey}set projectVersionKey(t){try{this._projectVersionKey=t,this.projectVersionKey&&bs("projectVersionKey",this.projectVersionKey,!1,"sessionStorage"),this.exitReviewModeCalled||this.detectVersion()}catch(t){console.warn("Error in set projectVersionKey: ",t),Le("Error in set projectVersionKey: ",t)}}get menuOpenedId(){return this._menuOpenedId}set menuOpenedId(t){this._menuOpenedId=t,this.menuOpenedId?this.addWindowClickEventListener():this.removeWindowClickEventListener()}render(){var t,e,i,n,s,o,r;return this.loadPlugin?this.snippylyUser?B`
|
|
983
|
+
`;var Ds=function(t,e,i,n){for(var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,a=t.length-1;a>=0;a--)(s=t[a])&&(r=(o<3?s(r):o>3?s(e,i,r):s(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r};let Ms=class extends q{constructor(){var i,n,s,o,r;super(),this._loadPlugin=!1,this.comments=[],this.addCommentMode=!1,this._expanded=!0,this.loading=!1,this.staging=true,this.copyLinkTooltip="Copy Link",this.invalidApiKey=!1,this.isUserGlobalContact=!1,this.exitReviewModeCalled=!1,this.addWindowClickEventListener=()=>{try{this.windowClickEventListener||(this.windowClickEventListener=()=>{this.menuOpenedId&&(this.menuOpenedId=void 0)},window.addEventListener("click",this.windowClickEventListener))}catch(t){console.warn("Error in addWindowClickEventListener: ",t),Le("Error in addWindowClickEventListener: ",t)}},this.removeWindowClickEventListener=()=>{try{window.removeEventListener("click",this.windowClickEventListener),this.windowClickEventListener=void 0}catch(t){console.warn("Error in removeWindowClickEventListener: ",t),Le("Error in removeWindowClickEventListener: ",t)}},this.setWindowEventListner=()=>{try{window.addEventListener("locationchange",(()=>{this.checkUrl()}))}catch(t){console.warn("Error in setWindowEventListner: ",t),Le("Error in setWindowEventListner: ",t)}},this.urlChangeListener=()=>{try{const t=history.pushState;history.pushState=function(){const e=t.apply(this,arguments);return window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange")),e};const e=history.replaceState;history.replaceState=function(){const t=e.apply(this,arguments);return window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange")),t},window.addEventListener("popstate",(()=>{window.dispatchEvent(new Event("locationchange"))}))}catch(t){console.warn("Error in urlChangeListener: ",t),Le("Error in urlChangeListener: ",t)}},this.checkUrl=()=>{try{const t=new URL(document.location),e=t.searchParams;if(e.has("st")||e.has("snippyly_google_token")){if(e.has("st")){const t=decodeURIComponent(e.get("st")),i=Fs(t,pt,ft),n=i&&JSON.parse(i);if(n){const t={};t.userId=n.uid,t.name=n.displayName,t.email=n.email,t.photoUrl=null==n?void 0:n.photoURL;const e=JSON.stringify(t),i=ks(e,pt,ft);bs("_sfut",i,!0)}}else if(e.has("snippyly_google_token")){const t=JSON.parse(atob(e.get("snippyly_google_token"))),i={};i.userId=t.uid,i.name=t.displayName,i.email=t.email,i.photoUrl=null==t?void 0:t.photoURL,bs("snippyly-user",JSON.stringify(i),!0)}e.delete("st"),e.delete("snippyly_google_token"),window.history.replaceState({},document.title,t.href)}e.has("review")?(bs("review","true",!1),"true"!==e.get("review")&&(e.delete("review"),e.append("review","true"),window.history.replaceState({},document.title,t.href)),this.loadPluginUI()):Cs("review",!1)&&(e.append("review","true"),window.history.replaceState({},document.title,t.href),this.loadPluginUI()),this.setVersionInUrl()}catch(t){console.warn("Error in checkUrl: ",t),Le("Error in checkUrl: ",t)}},this.detectVersion=()=>{try{if(this.projectVersionKey){const t=new URL(document.location).searchParams;if(t.get(this.projectVersionKey))this.projectVersion=t.get(this.projectVersionKey);else if(window.snippylyInitialLoadUrl){const t=new URL(window.snippylyInitialLoadUrl).searchParams;t.get(this.projectVersionKey)&&(this.projectVersion=t.get(this.projectVersionKey))}this.projectVersion&&bs("projectVersion",this.projectVersion,!1,"sessionStorage")}else{const t=new URL(document.location).searchParams;t.has("review")&&t.has("sversion")&&(bs("projectVersionKey","sversion",!1,"sessionStorage"),this.projectVersion=t.get("sversion"),this.projectVersion&&bs("projectVersion",this.projectVersion,!1,"sessionStorage"))}}catch(t){console.warn("Error in detectVersion: ",t),Le("Error in detectVersion: ",t)}},this.setVersionInUrl=()=>{try{const t=this.projectVersionKey||Cs("projectVersionKey",!1,"sessionStorage"),e=this.projectVersion||Cs("projectVersion",!1,"sessionStorage");if(t&&e){const i=new URL(document.location),n=i.searchParams;n.get(t)||(n.set(t,e),window.history.replaceState({},document.title,i.href))}}catch(t){console.warn("Error in setVersionInUrl: ",t),Le("Error in setVersionInUrl: ",t)}},this.loadPluginUI=()=>{try{if(!this.apiKey)return;if(this.loadPlugin)return this.generateLocation(),void this.setViewMode(this.viewMode);const t=$s();if(t&&!(null==t?void 0:t.isAnonymous)&&(this.loading=!0),this.loadPlugin=!0,!document.querySelector(at)){const t=document.createElement(at);null==t||t.addEventListener("signIn",(()=>{this.loginWithGoogle()})),window.document.body.appendChild(t)}if(!document.querySelector(lt)){const t=document.createElement(lt);t.setAttribute(ut,"true"),window.document.body.appendChild(t)}if(!document.querySelector(rt)){const t=document.createElement(rt);window.document.body.appendChild(t)}if(!document.querySelector(ct)){const t=document.createElement(ct);window.document.body.appendChild(t)}if(!document.querySelector(ht)){const t=document.createElement(ht);window.document.body.appendChild(t)}if(!document.querySelector(dt)){const t=document.createElement(dt);window.document.body.appendChild(t)}this.initializeSnippyly()}catch(t){this.loading=!1,console.warn("Error in loadPluginUI: ",t),Le("Error in loadPluginUI: ",t)}},this.initializeSnippyly=async()=>{var i,n,s;try{await(n=this.apiKey,s={options:{staging:this.staging,version:"latest"}},t(void 0,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,6,,7]),[4,(o=null==s?void 0:s.options,new Promise((function(t,e){var i=document.getElementById("snippylyScript"),n=!1,s="latest";if(o&&(o.staging&&(n=o.staging),o.version&&(s=o.version)),(null==o?void 0:o.version)||(s="1.0.78"),i)t();else{var r=document.createElement("script");r.src="https://cdn.jsdelivr.net/npm/@snippyly/sdk".concat(n?"-staging":"","@").concat(s,"/snippyly.js"),r.id="snippylyScript",r.type="module",document.body.appendChild(r),r.onload=function(){t()},r.onerror=function(){e(new Error("Failed to load Snippyly script"))}}})))];case 1:return e.sent(),t=window.Snippyly,s?[4,t.init(n,s)]:[3,3];case 2:return e.sent(),[3,5];case 3:return[4,t.init(n)];case 4:e.sent(),e.label=5;case 5:return(null==t?void 0:t.st)&&(null==t||t.st("client")),[2,t];case 6:return i=e.sent(),console.error(i),[2,null];case 7:return[2]}var o}))}))),Snippyly&&(null===Snippyly||void 0===Snippyly||Snippyly.sf(!0)),Snippyly&&Be({sdkVersion:null===Snippyly||void 0===Snippyly?void 0:Snippyly.version,sdkType:"client"}),this.documentId=((t,e=0)=>{try{let i=3735928559^e,n=1103547991^e;for(let e,s=0;s<t.length;s++)e=t.charCodeAt(s),i=Math.imul(i^e,2654435761),n=Math.imul(n^e,1597334677);return i=Math.imul(i^i>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(i^i>>>13,3266489909),4294967296*(2097151&n)+(i>>>0)}catch(t){return console.warn("Error in cyrb53: ",t),Le("Error in cyrb53: ",t),0}})((t=>{let e;return e=t.includes("http")?new URL(t):new URL("http://"+t),e.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.contactElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getContactElement(),this.rewriterElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getRewriterElement(),this.commentElement&&(this.commentElement.enableTextComments(!0),this.commentElement.enableSignInButton(!0),this.commentElement.enableAttachment(!0),this.commentElement.showScreenSizeInfo(!0),this.commentElement.showCommentIndex(!0),this.commentElement.addCommentModeChange&&this.commentElement.addCommentModeChange().subscribe((t=>{this.addCommentMode=t}))),this.selectionElement=Snippyly.getSelectionElement(),this.selectionElement&&this.selectionElement.enableLiveSelection(!0),this.rewriterElement&&(null===(i=this.rewriterElement)||void 0===i||i.enableRewriter()),this.identifySnippyly()}catch(t){this.loading=!1,console.warn("Error in initializeSnippyly: ",t),Le("Error in initializeSnippyly: ",t)}},this.generateLocation=()=>{try{const t=new URL(document.location).searchParams,e=new URL(document.location);e.searchParams.delete("review"),e.searchParams.delete("sreviewId"),e.searchParams.delete("scommentId");const i=t.get("sversion")||this.projectVersion;this.location={url:Es(e.href),version:i}}catch(t){console.warn("Error in generateLocation: ",t),Le("Error in generateLocation: ",t)}},this.setLocation=()=>{try{window.Snippyly&&(null===Snippyly||void 0===Snippyly?void 0:Snippyly.setLocation)&&(null===Snippyly||void 0===Snippyly||Snippyly.setLocation(JSON.parse(JSON.stringify(this.location))))}catch(t){console.warn("Error in setLocation: ",t),Le("Error in setLocation: ",t)}},this.identifySnippyly=async()=>{var t,e;try{this.invalidApiKey=!1;let e={name:"Anonymous User",email:"anonymous@snippyly.com",userId:"anonymous",isAnonymous:!0};const i=$s();(null==i?void 0:i.email)&&(e=i),e.isAnonymous?delete e.groupId:e.groupId=Snippyly.getDocumentId()+"",(null===(t=null==e?void 0:e.contacts)||void 0===t?void 0:t.length)&&(e.contacts=[]),(null==e?void 0:e.isAnonymous)||(this.loading=!0),await Snippyly.identify(e),this.loading=!1,(null==e?void 0:e.isAnonymous)||(this.snippylyUser=JSON.parse(JSON.stringify(e))),Be({clientUserId:null==e?void 0:e.userId}),this.getComments(),this.checkGlobalUserContact()}catch(t){this.loading=!1,this.signInError=!0,t&&"string"==typeof t&&(null===(e=null==t?void 0:t.toLowerCase())||void 0===e?void 0:e.includes("invalid"))&&(this.invalidApiKey=!0),console.warn("Error in identifySnippyly: ",t),Le("Error in identifySnippyly: ",t)}},this.getComments=()=>{try{this.commentElement&&(this.commentSubscription&&this.commentSubscription.unsubscribe(),this.commentSubscription=this.commentElement.getAllCommentAnnotations(this.documentId).subscribe((t=>{this.comments=t,"All"!==this.viewMode&&(this.viewMode?this.comments=t.filter((t=>{var e;return(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.view)===this.viewMode})):this.comments=this.comments.filter((t=>{var e;return!(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.view)})))})))}catch(t){console.warn("Error in getComments: ",t),Le("Error in getComments: ",t)}},this.checkGlobalUserContact=()=>{try{this.contactElement&&this.contactElement.isUserGlobalContact().subscribe((t=>{!this.isUserGlobalContact&&t&&this.setViewMode("All"),this.isUserGlobalContact=t,t||this.setViewMode(null)}))}catch(t){console.warn("Error in checkGlobalUserContact: ",t),Le("Error in checkGlobalUserContact: ",t)}},this.toggleCommentSidebar=()=>{try{this.commentElement&&this.commentElement.toggleCommentSidebar()}catch(t){console.warn("Error in toggleCommentSidebar: ",t),Le("Error in toggleCommentSidebar: ",t)}},this.toggleSnippylyPluginToolbar=()=>{try{this.expanded=!this.expanded}catch(t){console.warn("Error in toggleSnippylyPluginToolbar: ",t),Le("Error in toggleSnippylyPluginToolbar: ",t)}},this.loginWithGoogle=()=>{try{if(this.loading)return;window.open(`https://snippyly-login-staging.web.app/?redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(t){console.warn("Error in loginWithGoogle: ",t),Le("Error in loginWithGoogle: ",t)}},this.removeSnippyly=async()=>{try{this.exitReviewModeCalled=!0,xs("review"),xs("sreviewId"),xs("projectVersionKey","sessionStorage"),xs("projectVersion","sessionStorage");const t=new URL(document.location),e=t.searchParams;e.delete("sreviewId"),e.delete("review"),this.projectVersionKey&&e.delete(this.projectVersionKey),e.delete("sversion"),this.projectVersion=void 0,this.projectVersionKey=void 0,delete window.snippylyInitialLoadUrl,window.history.replaceState({},document.title,t.href),window.location.reload()}catch(t){console.warn("Error in removeSnippyly: ",t),Le("Error in removeSnippyly: ",t)}},this.signOutUser=async()=>{try{await Snippyly.signOutUser(),xs("snippyly-user"),xs("_sfut"),this.snippylyUser=void 0,window.open(`https://snippyly-login-staging.web.app/?signout=true&redirect_url=${encodeURIComponent(window.location.href)}`,"_self")}catch(t){console.warn("Error in signOutUser: ",t),Le("Error in signOutUser: ",t)}},this.toggleMenu=(t,e)=>{try{t.stopPropagation(),this.menuOpenedId===e?this.menuOpenedId=void 0:this.menuOpenedId=e}catch(t){console.warn("Error in toggleMenu: ",t),Le("Error in toggleMenu: ",t)}},this.copyLink=()=>{try{navigator.clipboard.writeText(window.location.href),this.copyLinkTooltip="Link copied!",setTimeout((()=>{this.copyLinkTooltip="Copy Link"}),2e3)}catch(t){console.warn("Error in copyLink: ",t),Le("Error in copyLink: ",t)}},this.setViewMode=t=>{try{this.viewMode=t,t?this.location.view=t:delete this.location.view,this.setLocation(),this.getComments()}catch(t){console.warn("Error in setViewMode: ",t),Le("Error in setViewMode: ",t)}},this.goToAdminPortal=()=>{try{window.open("https://snippyly-self-serve-platform.web.app/","_blank")}catch(t){console.warn("Error in goToAdminPortal: ",t),Le("Error in goToAdminPortal: ",t)}},this.setAttribute("data-snippyly-comment-disabled","true"),this.style.zIndex="2147483577",null===(n=null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.style)||void 0===n||n.setProperty("transform","none","important"),null===(r=null===(o=null===(s=null===document||void 0===document?void 0:document.body)||void 0===s?void 0:s.parentElement)||void 0===o?void 0:o.style)||void 0===r||r.setProperty("transform","none","important");try{this.expanded=!0,this.detectVersion(),this.setWindowEventListner(),this.urlChangeListener(),this.checkUrl(),console.log("*** Staging Mode ON! ***")}catch(t){console.warn("Error in constructor: ",t),Le("Error in constructor: ",t)}}get loadPlugin(){return this._loadPlugin}set loadPlugin(t){this._loadPlugin=t,this.loadPlugin?this.classList.add("visible"):this.classList.remove("visible")}get expanded(){return this._expanded}set expanded(t){this._expanded=t,this.expanded?this.classList.add("expanded"):this.classList.remove("expanded")}get apiKey(){return this._apiKey}set apiKey(t){this._apiKey=t,Be({apiKey:this.apiKey}),this.checkUrl()}get projectVersionKey(){return this._projectVersionKey}set projectVersionKey(t){try{this._projectVersionKey=t,this.projectVersionKey&&bs("projectVersionKey",this.projectVersionKey,!1,"sessionStorage"),this.exitReviewModeCalled||this.detectVersion()}catch(t){console.warn("Error in set projectVersionKey: ",t),Le("Error in set projectVersionKey: ",t)}}get menuOpenedId(){return this._menuOpenedId}set menuOpenedId(t){this._menuOpenedId=t,this.menuOpenedId?this.addWindowClickEventListener():this.removeWindowClickEventListener()}render(){var t,e,i,n,s,o,r;return this.loadPlugin?this.snippylyUser?B`
|
|
984
984
|
<div class="snippyly-plugin-container">
|
|
985
985
|
<div class="toolbar ${ot({expanded:this.expanded})}">
|
|
986
986
|
|
|
@@ -1290,4 +1290,4 @@ class us extends ri{}us.Encryptor=class extends us{processBlock(t,e){const i=t,n
|
|
|
1290
1290
|
</div>
|
|
1291
1291
|
</div>
|
|
1292
1292
|
</div>
|
|
1293
|
-
`:B``}};
|
|
1293
|
+
`:B``}};Ms.styles=[Is,_s],Ds([it()],Ms.prototype,"loadPlugin",null),Ds([it()],Ms.prototype,"comments",void 0),Ds([it()],Ms.prototype,"commentElement",void 0),Ds([it()],Ms.prototype,"contactElement",void 0),Ds([it()],Ms.prototype,"rewriterElement",void 0),Ds([it()],Ms.prototype,"commentSubscription",void 0),Ds([it()],Ms.prototype,"selectionElement",void 0),Ds([it()],Ms.prototype,"addCommentMode",void 0),Ds([it()],Ms.prototype,"_expanded",void 0),Ds([it()],Ms.prototype,"loading",void 0),Ds([it()],Ms.prototype,"signInError",void 0),Ds([it()],Ms.prototype,"snippylyUser",void 0),Ds([et()],Ms.prototype,"apiKey",null),Ds([it()],Ms.prototype,"staging",void 0),Ds([et()],Ms.prototype,"projectVersionKey",null),Ds([it()],Ms.prototype,"projectVersion",void 0),Ds([it()],Ms.prototype,"_menuOpenedId",void 0),Ds([it()],Ms.prototype,"copyLinkTooltip",void 0),Ds([it()],Ms.prototype,"invalidApiKey",void 0),Ds([it()],Ms.prototype,"documentId",void 0),Ds([it()],Ms.prototype,"isUserGlobalContact",void 0),Ds([it()],Ms.prototype,"location",void 0),Ds([it()],Ms.prototype,"viewMode",void 0),Ms=Ds([(t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){window.customElements.define(t,e)}}})(t,e))("snippyly-plugin")],Ms);export{Ms as SnippylyPlugin};
|