@snippyly/plugin-staging 1.0.10 → 1.0.11
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
|
@@ -14,13 +14,13 @@ const i=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
14
14
|
* Copyright 2017 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
var u;p.finalized=!0,p.elementProperties=new Map,p.elementStyles=[],p.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:p}),(null!==(o=globalThis.reactiveElementVersions)&&void 0!==o?o:globalThis.reactiveElementVersions=[]).push("1.3.2");const y=globalThis.trustedTypes,v=y?y.createPolicy("lit-html",{createHTML:i=>i}):void 0,g=`lit$${(Math.random()+"").slice(9)}$`,m="?"+g,w=`<${m}>`,f=document,b=(i="")=>f.createComment(i),C=i=>null===i||"object"!=typeof i&&"function"!=typeof i,S=Array.isArray,x=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,$=/-->/g,k=/>/g,E=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,L=/'/g,_=/"/g,M=/^(?:script|style|textarea|title)$/i,A=(i=>(t,...e)=>({_$litType$:i,strings:t,values:e}))(1),U=Symbol.for("lit-noChange"),T=Symbol.for("lit-nothing"),O=new WeakMap,z=f.createTreeWalker(f,129,null,!1),B=(i,t)=>{const e=i.length-1,n=[];let s,o=2===t?"<svg>":"",r=x;for(let t=0;t<e;t++){const e=i[t];let l,h,d=-1,a=0;for(;a<e.length&&(r.lastIndex=a,h=r.exec(e),null!==h);)a=r.lastIndex,r===x?"!--"===h[1]?r=$:void 0!==h[1]?r=k:void 0!==h[2]?(M.test(h[2])&&(s=RegExp("</"+h[2],"g")),r=E):void 0!==h[3]&&(r=E):r===E?">"===h[0]?(r=null!=s?s:x,d=-1):void 0===h[1]?d=-2:(d=r.lastIndex-h[2].length,l=h[1],r=void 0===h[3]?E:'"'===h[3]?_:L):r===_||r===L?r=E:r===$||r===k?r=x:(r=E,s=void 0);const c=r===E&&i[t+1].startsWith("/>")?" ":"";o+=r===x?e+w:d>=0?(n.push(l),e.slice(0,d)+"$lit$"+e.slice(d)+g+c):e+g+(-2===d?(n.push(void 0),t):c)}const l=o+(i[e]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==v?v.createHTML(l):l,n]};class
|
|
17
|
+
var u;p.finalized=!0,p.elementProperties=new Map,p.elementStyles=[],p.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:p}),(null!==(o=globalThis.reactiveElementVersions)&&void 0!==o?o:globalThis.reactiveElementVersions=[]).push("1.3.2");const y=globalThis.trustedTypes,v=y?y.createPolicy("lit-html",{createHTML:i=>i}):void 0,g=`lit$${(Math.random()+"").slice(9)}$`,m="?"+g,w=`<${m}>`,f=document,b=(i="")=>f.createComment(i),C=i=>null===i||"object"!=typeof i&&"function"!=typeof i,S=Array.isArray,x=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,$=/-->/g,k=/>/g,E=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,L=/'/g,_=/"/g,M=/^(?:script|style|textarea|title)$/i,A=(i=>(t,...e)=>({_$litType$:i,strings:t,values:e}))(1),U=Symbol.for("lit-noChange"),T=Symbol.for("lit-nothing"),O=new WeakMap,z=f.createTreeWalker(f,129,null,!1),B=(i,t)=>{const e=i.length-1,n=[];let s,o=2===t?"<svg>":"",r=x;for(let t=0;t<e;t++){const e=i[t];let l,h,d=-1,a=0;for(;a<e.length&&(r.lastIndex=a,h=r.exec(e),null!==h);)a=r.lastIndex,r===x?"!--"===h[1]?r=$:void 0!==h[1]?r=k:void 0!==h[2]?(M.test(h[2])&&(s=RegExp("</"+h[2],"g")),r=E):void 0!==h[3]&&(r=E):r===E?">"===h[0]?(r=null!=s?s:x,d=-1):void 0===h[1]?d=-2:(d=r.lastIndex-h[2].length,l=h[1],r=void 0===h[3]?E:'"'===h[3]?_:L):r===_||r===L?r=E:r===$||r===k?r=x:(r=E,s=void 0);const c=r===E&&i[t+1].startsWith("/>")?" ":"";o+=r===x?e+w:d>=0?(n.push(l),e.slice(0,d)+"$lit$"+e.slice(d)+g+c):e+g+(-2===d?(n.push(void 0),t):c)}const l=o+(i[e]||"<?>")+(2===t?"</svg>":"");if(!Array.isArray(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==v?v.createHTML(l):l,n]};class I{constructor({strings:i,_$litType$:t},e){let n;this.parts=[];let s=0,o=0;const r=i.length-1,l=this.parts,[h,d]=B(i,t);if(this.el=I.createElement(h,e),z.currentNode=this.el.content,2===t){const i=this.el.content,t=i.firstChild;t.remove(),i.append(...t.childNodes)}for(;null!==(n=z.nextNode())&&l.length<r;){if(1===n.nodeType){if(n.hasAttributes()){const i=[];for(const t of n.getAttributeNames())if(t.endsWith("$lit$")||t.startsWith(g)){const e=d[o++];if(i.push(t),void 0!==e){const i=n.getAttribute(e.toLowerCase()+"$lit$").split(g),t=/([.?@])?(.*)/.exec(e);l.push({type:1,index:s,name:t[2],strings:i,ctor:"."===t[1]?Z:"?"===t[1]?J:"@"===t[1]?V:P})}else l.push({type:6,index:s})}for(const t of i)n.removeAttribute(t)}if(M.test(n.tagName)){const i=n.textContent.split(g),t=i.length-1;if(t>0){n.textContent=y?y.emptyScript:"";for(let e=0;e<t;e++)n.append(i[e],b()),z.nextNode(),l.push({type:2,index:++s});n.append(i[t],b())}}}else if(8===n.nodeType)if(n.data===m)l.push({type:2,index:s});else{let i=-1;for(;-1!==(i=n.data.indexOf(g,i+1));)l.push({type:7,index:s}),i+=g.length-1}s++}}static createElement(i,t){const e=f.createElement("template");return e.innerHTML=i,e}}function R(i,t,e=i,n){var s,o,r,l;if(t===U)return t;let h=void 0!==n?null===(s=e._$Cl)||void 0===s?void 0:s[n]:e._$Cu;const d=C(t)?void 0:t._$litDirective$;return(null==h?void 0:h.constructor)!==d&&(null===(o=null==h?void 0:h._$AO)||void 0===o||o.call(h,!1),void 0===d?h=void 0:(h=new d(i),h._$AT(i,e,n)),void 0!==n?(null!==(r=(l=e)._$Cl)&&void 0!==r?r:l._$Cl=[])[n]=h:e._$Cu=h),void 0!==h&&(t=R(i,h._$AS(i,t.values),h,n)),t}class N{constructor(i,t){this.v=[],this._$AN=void 0,this._$AD=i,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(i){var t;const{el:{content:e},parts:n}=this._$AD,s=(null!==(t=null==i?void 0:i.creationScope)&&void 0!==t?t:f).importNode(e,!0);z.currentNode=s;let o=z.nextNode(),r=0,l=0,h=n[0];for(;void 0!==h;){if(r===h.index){let t;2===h.type?t=new j(o,o.nextSibling,this,i):1===h.type?t=new h.ctor(o,h.name,h.strings,this,i):6===h.type&&(t=new F(o,this,i)),this.v.push(t),h=n[++l]}r!==(null==h?void 0:h.index)&&(o=z.nextNode(),r++)}return s}m(i){let t=0;for(const e of this.v)void 0!==e&&(void 0!==e.strings?(e._$AI(i,e,t),t+=e.strings.length-2):e._$AI(i[t])),t++}}class j{constructor(i,t,e,n){var s;this.type=2,this._$AH=T,this._$AN=void 0,this._$AA=i,this._$AB=t,this._$AM=e,this.options=n,this._$Cg=null===(s=null==n?void 0:n.isConnected)||void 0===s||s}get _$AU(){var i,t;return null!==(t=null===(i=this._$AM)||void 0===i?void 0:i._$AU)&&void 0!==t?t:this._$Cg}get parentNode(){let i=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===i.nodeType&&(i=t.parentNode),i}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(i,t=this){i=R(this,i,t),C(i)?i===T||null==i||""===i?(this._$AH!==T&&this._$AR(),this._$AH=T):i!==this._$AH&&i!==U&&this.$(i):void 0!==i._$litType$?this.T(i):void 0!==i.nodeType?this.k(i):(i=>{var t;return S(i)||"function"==typeof(null===(t=i)||void 0===t?void 0:t[Symbol.iterator])})(i)?this.S(i):this.$(i)}M(i,t=this._$AB){return this._$AA.parentNode.insertBefore(i,t)}k(i){this._$AH!==i&&(this._$AR(),this._$AH=this.M(i))}$(i){this._$AH!==T&&C(this._$AH)?this._$AA.nextSibling.data=i:this.k(f.createTextNode(i)),this._$AH=i}T(i){var t;const{values:e,_$litType$:n}=i,s="number"==typeof n?this._$AC(i):(void 0===n.el&&(n.el=I.createElement(n.h,this.options)),n);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===s)this._$AH.m(e);else{const i=new N(s,this),t=i.p(this.options);i.m(e),this.k(t),this._$AH=i}}_$AC(i){let t=O.get(i.strings);return void 0===t&&O.set(i.strings,t=new I(i)),t}S(i){S(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let e,n=0;for(const s of i)n===t.length?t.push(e=new j(this.M(b()),this.M(b()),this,this.options)):e=t[n],e._$AI(s),n++;n<t.length&&(this._$AR(e&&e._$AB.nextSibling,n),t.length=n)}_$AR(i=this._$AA.nextSibling,t){var e;for(null===(e=this._$AP)||void 0===e||e.call(this,!1,!0,t);i&&i!==this._$AB;){const t=i.nextSibling;i.remove(),i=t}}setConnected(i){var t;void 0===this._$AM&&(this._$Cg=i,null===(t=this._$AP)||void 0===t||t.call(this,i))}}class P{constructor(i,t,e,n,s){this.type=1,this._$AH=T,this._$AN=void 0,this.element=i,this.name=t,this._$AM=n,this.options=s,e.length>2||""!==e[0]||""!==e[1]?(this._$AH=Array(e.length-1).fill(new String),this.strings=e):this._$AH=T}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(i,t=this,e,n){const s=this.strings;let o=!1;if(void 0===s)i=R(this,i,t,0),o=!C(i)||i!==this._$AH&&i!==U,o&&(this._$AH=i);else{const n=i;let r,l;for(i=s[0],r=0;r<s.length-1;r++)l=R(this,n[e+r],t,r),l===U&&(l=this._$AH[r]),o||(o=!C(l)||l!==this._$AH[r]),l===T?i=T:i!==T&&(i+=(null!=l?l:"")+s[r+1]),this._$AH[r]=l}o&&!n&&this.C(i)}C(i){i===T?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=i?i:"")}}class Z extends P{constructor(){super(...arguments),this.type=3}C(i){this.element[this.name]=i===T?void 0:i}}const H=y?y.emptyScript:"";class J extends P{constructor(){super(...arguments),this.type=4}C(i){i&&i!==T?this.element.setAttribute(this.name,H):this.element.removeAttribute(this.name)}}class V extends P{constructor(i,t,e,n,s){super(i,t,e,n,s),this.type=5}_$AI(i,t=this){var e;if((i=null!==(e=R(this,i,t,0))&&void 0!==e?e:T)===U)return;const n=this._$AH,s=i===T&&n!==T||i.capture!==n.capture||i.once!==n.once||i.passive!==n.passive,o=i!==T&&(n===T||s);s&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,i),this._$AH=i}handleEvent(i){var t,e;"function"==typeof this._$AH?this._$AH.call(null!==(e=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==e?e:this.element,i):this._$AH.handleEvent(i)}}class F{constructor(i,t,e){this.element=i,this.type=6,this._$AN=void 0,this._$AM=t,this.options=e}get _$AU(){return this._$AM._$AU}_$AI(i){R(this,i)}}const D=window.litHtmlPolyfillSupport;
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2017 Google LLC
|
|
21
21
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
22
|
*/
|
|
23
|
-
var W,K;null==D||D(
|
|
23
|
+
var W,K;null==D||D(I,j),(null!==(u=globalThis.litHtmlVersions)&&void 0!==u?u:globalThis.litHtmlVersions=[]).push("2.2.6");class q extends p{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var i,t;const e=super.createRenderRoot();return null!==(i=(t=this.renderOptions).renderBefore)&&void 0!==i||(t.renderBefore=e.firstChild),e}update(i){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(i),this._$Dt=((i,t,e)=>{var n,s;const o=null!==(n=null==e?void 0:e.renderBefore)&&void 0!==n?n:t;let r=o._$litPart$;if(void 0===r){const i=null!==(s=null==e?void 0:e.renderBefore)&&void 0!==s?s:null;o._$litPart$=r=new j(t.insertBefore(b(),i),i,void 0,null!=e?e:{})}return r._$AI(i),r})(t,this.renderRoot,this.renderOptions)}connectedCallback(){var i;super.connectedCallback(),null===(i=this._$Dt)||void 0===i||i.setConnected(!0)}disconnectedCallback(){var i;super.disconnectedCallback(),null===(i=this._$Dt)||void 0===i||i.setConnected(!1)}render(){return U}}q.finalized=!0,q._$litElement$=!0,null===(W=globalThis.litElementHydrateSupport)||void 0===W||W.call(globalThis,{LitElement:q});const G=globalThis.litElementPolyfillSupport;null==G||G({LitElement:q}),(null!==(K=globalThis.litElementVersions)&&void 0!==K?K:globalThis.litElementVersions=[]).push("3.2.0");
|
|
24
24
|
/**
|
|
25
25
|
* @license
|
|
26
26
|
* Copyright 2017 Google LLC
|
|
@@ -53,7 +53,7 @@ const ti=1;
|
|
|
53
53
|
* Copyright 2018 Google LLC
|
|
54
54
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
55
55
|
*/
|
|
56
|
-
const ei=(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!==ti||"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 U}}),ni=(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}},si=(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)}},oi=(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}},ri=(i,t="localStorage")=>{try{"localStorage"===t?localStorage.removeItem(i):sessionStorage.removeItem(i)}catch(i){console.warn("Error in removeLocalStorageData: ",i)}};var li=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 hi=class extends q{constructor(){super(),this._loadPlugin=!1,this.comments=[],this._expanded=!0,this.staging=true,this.copyLinkTooltip="Copy Link",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=()=>{try{const i=new URL(document.location),t=i.searchParams;if(t.has("snippyly_google_token")){const e=JSON.parse(atob(t.get("snippyly_google_token"))),n={};n.userId=e.uid,n.name=e.displayName,n.email=e.email,n.photoUrl=null==e?void 0:e.photoURL,n.contacts=window.SNIPPYLY_USER_CONTACTS||[],si("snippyly-user",JSON.stringify(n),!0),t.delete("snippyly_google_token"),window.history.replaceState({},document.title,i.href)}if(t.has("review"))if(si("review","true",!1,"sessionStorage"),t.has("review-doc-id"))this.loadPluginUI();else{const e=ni(window.location.origin);t.append("review-doc-id",`${e}`),window.history.replaceState({},document.title,i.href),this.loadPluginUI()}else if(oi("review",!1,"sessionStorage")){t.append("review","true");const e=ni(window.location.origin);t.append("review-doc-id",`${e}`),window.history.replaceState({},document.title,i.href),this.loadPluginUI()}}catch(i){console.warn("Error in checkUrl: ",i)}},this.loadPluginUI=()=>{try{this.loadPlugin=!0;const i=document.createElement("snippyly-comments");window.document.body.appendChild(i);const t=document.createElement("snippyly-comments-sidebar");window.document.body.appendChild(t);const e=document.createElement("snippyly-cursor");window.document.body.appendChild(e),((i="latest",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||"latest"}/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;if(i.has("review-doc-id")){null===Snippyly||void 0===Snippyly||Snippyly.setDocumentId(i.get("review-doc-id"));const t=new URL(document.location);t.searchParams.delete("review"),t.searchParams.delete("review-doc-id"),null===Snippyly||void 0===Snippyly||Snippyly.setDocumentParams({url:t.href})}this.commentElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getCommentElement(),this.commentElement&&this.commentElement.enableTextComments(!0),this.identifySnippyly()}catch(i){console.warn("Error in initializeSnippyly: ",i)}},this.identifySnippyly=async()=>{try{let i={name:"Anonymous User",email:"anonymous@snippyly.com",userId:"anonymous",isAnonymous:!0};oi("snippyly-user",!0)&&(i=JSON.parse(oi("snippyly-user",!0)),this.snippylyUser=JSON.parse(
|
|
56
|
+
const ei=(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!==ti||"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 U}}),ni=(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}},si=(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)}},oi=(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}},ri=(i,t="localStorage")=>{try{"localStorage"===t?localStorage.removeItem(i):sessionStorage.removeItem(i)}catch(i){console.warn("Error in removeLocalStorageData: ",i)}};var li=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 hi=class extends q{constructor(){super(),this._loadPlugin=!1,this.comments=[],this._expanded=!0,this.staging=true,this.copyLinkTooltip="Copy Link",this.invalidApiKey=!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=()=>{try{const i=new URL(document.location),t=i.searchParams;if(t.has("snippyly_google_token")){const e=JSON.parse(atob(t.get("snippyly_google_token"))),n={};n.userId=e.uid,n.name=e.displayName,n.email=e.email,n.photoUrl=null==e?void 0:e.photoURL,n.contacts=window.SNIPPYLY_USER_CONTACTS||[],si("snippyly-user",JSON.stringify(n),!0),t.delete("snippyly_google_token"),window.history.replaceState({},document.title,i.href)}if(t.has("review"))if(si("review","true",!1,"sessionStorage"),t.has("review-doc-id"))this.loadPluginUI();else{const e=ni(window.location.origin);t.append("review-doc-id",`${e}`),window.history.replaceState({},document.title,i.href),this.loadPluginUI()}else if(oi("review",!1,"sessionStorage")){t.append("review","true");const e=ni(window.location.origin);t.append("review-doc-id",`${e}`),window.history.replaceState({},document.title,i.href),this.loadPluginUI()}}catch(i){console.warn("Error in checkUrl: ",i)}},this.loadPluginUI=()=>{try{this.loadPlugin=!0;const i=document.createElement("snippyly-comments");null==i||i.addEventListener("signIn",(()=>{this.loginWithGoogle()})),window.document.body.appendChild(i);const t=document.createElement("snippyly-comments-sidebar");window.document.body.appendChild(t);const e=document.createElement("snippyly-cursor");window.document.body.appendChild(e),((i="latest",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||"latest"}/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;if(i.has("review-doc-id")){null===Snippyly||void 0===Snippyly||Snippyly.setDocumentId(i.get("review-doc-id"));const t=new URL(document.location);t.searchParams.delete("review"),t.searchParams.delete("review-doc-id"),null===Snippyly||void 0===Snippyly||Snippyly.setDocumentParams({url:t.href})}this.commentElement=null===Snippyly||void 0===Snippyly?void 0:Snippyly.getCommentElement(),this.commentElement&&(this.commentElement.enableTextComments(!0),this.commentElement.enableSignInButton(!0)),this.identifySnippyly()}catch(i){console.warn("Error in initializeSnippyly: ",i)}},this.identifySnippyly=async()=>{var i;try{this.invalidApiKey=!1;let i={name:"Anonymous User",email:"anonymous@snippyly.com",userId:"anonymous",isAnonymous:!0};oi("snippyly-user",!0)&&(i=JSON.parse(oi("snippyly-user",!0))),await Snippyly.identify(i),(null==i?void 0:i.isAnonymous)||(this.snippylyUser=JSON.parse(JSON.stringify(i))),this.getComments()}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{if(this.commentElement){const i=new URL(document.location).searchParams;this.commentElement.getAllCommentAnnotations(i.get("review-doc-id")).subscribe((i=>{this.comments=i}))}}catch(i){console.warn("Error in getComments: ",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{ri("review","sessionStorage");const i=new URL(document.location),t=i.searchParams;t.delete("review-doc-id"),t.delete("review"),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(),ri("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)}};try{this.expanded=!0,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 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,d,a,c;return this.loadPlugin?A`
|
|
57
57
|
<div class="snippyly-plugin-container ${ei({expanded:this.expanded,active:null===(i=this.snippylyUser)||void 0===i?void 0:i.userId})}">
|
|
58
58
|
<div class="snippyly-logo-container snippyly-menu-trigger" @click=${()=>this.toggleSnippylyPluginToolbar()}>
|
|
59
59
|
${this.expanded?null:A`
|
|
@@ -99,7 +99,7 @@ const ei=(i=>(...t)=>({_$litDirective$:i,values:t}))(class extends class{constru
|
|
|
99
99
|
</svg>
|
|
100
100
|
</snippyly-comment-tool>
|
|
101
101
|
<div class="snippyly-menu snippyly-tooltip">
|
|
102
|
-
<div class="menu-item">${(null===(e=this.snippylyUser)||void 0===e?void 0:e.userId)?"Add comments":"Sign in to add comments"}</div>
|
|
102
|
+
<div class="menu-item">${this.invalidApiKey?"API key is Invalid":(null===(e=this.snippylyUser)||void 0===e?void 0:e.userId)?"Add comments":"Sign in to add comments"}</div>
|
|
103
103
|
</div>
|
|
104
104
|
</div>
|
|
105
105
|
${(null===(n=this.comments)||void 0===n?void 0:n.length)?A`
|
|
@@ -427,4 +427,4 @@ const ei=(i=>(...t)=>({_$litDirective$:i,values:t}))(class extends class{constru
|
|
|
427
427
|
.away {
|
|
428
428
|
filter: grayscale(1);
|
|
429
429
|
}
|
|
430
|
-
`,li([Y()],hi.prototype,"loadPlugin",null),li([Y()],hi.prototype,"comments",void 0),li([Y()],hi.prototype,"commentElement",void 0),li([Y()],hi.prototype,"_expanded",void 0),li([Y()],hi.prototype,"snippylyUser",void 0),li([Q()],hi.prototype,"apiKey",void 0),li([Y()],hi.prototype,"staging",void 0),li([Y()],hi.prototype,"_menuOpenedId",void 0),li([Y()],hi.prototype,"copyLinkTooltip",void 0),hi=li([(i=>t=>"function"==typeof t?((i,t)=>(window.customElements.define(i,t),t))(i,t):((i,t)=>{const{kind:e,elements:n}=t;return{kind:e,elements:n,finisher(t){window.customElements.define(i,t)}}})(i,t))("snippyly-plugin")],hi);export{hi as SnippylyPlugin};
|
|
430
|
+
`,li([Y()],hi.prototype,"loadPlugin",null),li([Y()],hi.prototype,"comments",void 0),li([Y()],hi.prototype,"commentElement",void 0),li([Y()],hi.prototype,"_expanded",void 0),li([Y()],hi.prototype,"snippylyUser",void 0),li([Q()],hi.prototype,"apiKey",void 0),li([Y()],hi.prototype,"staging",void 0),li([Y()],hi.prototype,"_menuOpenedId",void 0),li([Y()],hi.prototype,"copyLinkTooltip",void 0),li([Y()],hi.prototype,"invalidApiKey",void 0),hi=li([(i=>t=>"function"==typeof t?((i,t)=>(window.customElements.define(i,t),t))(i,t):((i,t)=>{const{kind:e,elements:n}=t;return{kind:e,elements:n,finisher(t){window.customElements.define(i,t)}}})(i,t))("snippyly-plugin")],hi);export{hi as SnippylyPlugin};
|