UNPKG

web-social-share

Version:

A Web Component to share urls and text on social networks

3 lines 11.5 kB
const t="websocialshare";let e;let n;let s=false;let l=false;const o=(t,e="")=>{{return()=>{}}};const c=(t,e)=>{{return()=>{}}};const i="{visibility:hidden}.hydrated{visibility:inherit}";const f="slot-fb{display:contents}slot-fb[hidden]{display:none}";const r={};const u=t=>t!=null;const a=t=>{t=typeof t;return t==="object"||t==="function"};function d(t){var e,n,s;return(s=(n=(e=t.head)===null||e===void 0?void 0:e.querySelector('meta[name="csp-nonce"]'))===null||n===void 0?void 0:n.getAttribute("content"))!==null&&s!==void 0?s:undefined}const y=(t,e,...n)=>{let s=null;let l=null;let o=false;let c=false;const i=[];const f=e=>{for(let n=0;n<e.length;n++){s=e[n];if(Array.isArray(s)){f(s)}else if(s!=null&&typeof s!=="boolean"){if(o=typeof t!=="function"&&!a(s)){s=String(s)}if(o&&c){i[i.length-1].t+=s}else{i.push(o?p(null,s):s)}c=o}}};f(n);if(e){if(e.key){l=e.key}{const t=e.className||e.class;if(t){e.class=typeof t!=="object"?t:Object.keys(t).filter((e=>t[e])).join(" ")}}}const r=p(t,null);r.l=e;if(i.length>0){r.o=i}{r.i=l}return r};const p=(t,e)=>{const n={u:0,p:t,t:e,h:null,o:null};{n.l=null}{n.i=null}return n};const h={};const $=t=>t&&t.p===h;const b=(t,e)=>{if(t!=null&&!a(t)){if(e&4){return t==="false"?false:t===""||!!t}return t}return t};const m=t=>it(t).$hostElement$;const v=(t,e,n)=>{const s=m(t);return{emit:t=>w(s,e,{bubbles:!!(n&4),composed:!!(n&2),cancelable:!!(n&1),detail:t})}};const w=(t,e,n)=>{const s=bt.ce(e,n);t.dispatchEvent(s);return s};const S=new WeakMap;const g=(t,e,n)=>{let s=pt.get(t);if(vt&&n){s=s||new CSSStyleSheet;if(typeof s==="string"){s=e}else{s.replaceSync(e)}}else{s=e}pt.set(t,s)};const j=(t,e,n)=>{var s;const l=C(e);const o=pt.get(l);t=t.nodeType===11?t:$t;if(o){if(typeof o==="string"){t=t.head||t;let n=S.get(t);let c;if(!n){S.set(t,n=new Set)}if(!n.has(l)){{c=$t.createElement("style");c.innerHTML=o;const e=(s=bt.$)!==null&&s!==void 0?s:d($t);if(e!=null){c.setAttribute("nonce",e)}t.insertBefore(c,t.querySelector("link"))}if(e.u&4){c.innerHTML+=f}if(n){n.add(l)}}}else if(!t.adoptedStyleSheets.includes(o)){t.adoptedStyleSheets=[...t.adoptedStyleSheets,o]}}return l};const k=t=>{const e=t.m;const n=t.$hostElement$;const s=e.u;const l=o("attachStyles",e.v);const c=j(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);if(s&10){n["s-sc"]=c;n.classList.add(c+"-h")}l()};const C=(t,e)=>"sc-"+t.v;const M=(t,e,n,s,l,o)=>{if(n!==s){let c=ut(t,e);let i=e.toLowerCase();if(e==="class"){const e=t.classList;const l=P(n);const o=P(s);e.remove(...l.filter((t=>t&&!o.includes(t))));e.add(...o.filter((t=>t&&!l.includes(t))))}else if(e==="key");else if(e==="ref"){if(s){s(t)}}else if(!c&&e[0]==="o"&&e[1]==="n"){if(e[2]==="-"){e=e.slice(3)}else if(ut(ht,i)){e=i.slice(2)}else{e=i[2]+e.slice(3)}if(n||s){const l=e.endsWith(x);e=e.replace(E,"");if(n){bt.rel(t,e,n,l)}if(s){bt.ael(t,e,s,l)}}}else{const i=a(s);if((c||i&&s!==null)&&!l){try{if(!t.tagName.includes("-")){const l=s==null?"":s;if(e==="list"){c=false}else if(n==null||t[e]!=l){t[e]=l}}else{t[e]=s}}catch(t){}}if(s==null||s===false){if(s!==false||t.getAttribute(e)===""){{t.removeAttribute(e)}}}else if((!c||o&4||l)&&!i){s=s===true?"":s;{t.setAttribute(e,s)}}}}};const O=/\s/;const P=t=>!t?[]:t.split(O);const x="Capture";const E=new RegExp(x+"$");const U=(t,e,n,s)=>{const l=e.h.nodeType===11&&e.h.host?e.h.host:e.h;const o=t&&t.l||r;const c=e.l||r;{for(s in o){if(!(s in c)){M(l,s,o[s],undefined,n,e.u)}}}for(s in c){M(l,s,o[s],c[s],n,e.u)}};const A=(t,l,o,c)=>{const i=l.o[o];let f=0;let r;let a;if(i.t!==null){r=i.h=$t.createTextNode(i.t)}else{r=i.h=$t.createElement(i.p);{U(null,i,s)}if(u(e)&&r["s-si"]!==e){r.classList.add(r["s-si"]=e)}if(i.o){for(f=0;f<i.o.length;++f){a=A(t,i,f);if(a){r.appendChild(a)}}}}r["s-hn"]=n;return r};const N=(t,e,s,l,o,c)=>{let i=t;let f;if(i.shadowRoot&&i.tagName===n){i=i.shadowRoot}for(;o<=c;++o){if(l[o]){f=A(null,s,o);if(f){l[o].h=f;i.insertBefore(f,e)}}}};const R=(t,e,n)=>{for(let s=e;s<=n;++s){const e=t[s];if(e){const t=e.h;q(e);if(t){t.remove()}}}};const T=(t,e,n,s,l=false)=>{let o=0;let c=0;let i=0;let f=0;let r=e.length-1;let u=e[0];let a=e[r];let d=s.length-1;let y=s[0];let p=s[d];let h;let $;while(o<=r&&c<=d){if(u==null){u=e[++o]}else if(a==null){a=e[--r]}else if(y==null){y=s[++c]}else if(p==null){p=s[--d]}else if(L(u,y,l)){W(u,y,l);u=e[++o];y=s[++c]}else if(L(a,p,l)){W(a,p,l);a=e[--r];p=s[--d]}else if(L(u,p,l)){W(u,p,l);t.insertBefore(u.h,a.h.nextSibling);u=e[++o];p=s[--d]}else if(L(a,y,l)){W(a,y,l);t.insertBefore(a.h,u.h);a=e[--r];y=s[++c]}else{i=-1;{for(f=o;f<=r;++f){if(e[f]&&e[f].i!==null&&e[f].i===y.i){i=f;break}}}if(i>=0){$=e[i];if($.p!==y.p){h=A(e&&e[c],n,i)}else{W($,y,l);e[i]=undefined;h=$.h}y=s[++c]}else{h=A(e&&e[c],n,c);y=s[++c]}if(h){{u.h.parentNode.insertBefore(h,u.h)}}}}if(o>r){N(t,s[d+1]==null?null:s[d+1].h,n,s,c,d)}else if(c>d){R(e,o,r)}};const L=(t,e,n=false)=>{if(t.p===e.p){if(!n){return t.i===e.i}return true}return false};const W=(t,e,n=false)=>{const l=e.h=t.h;const o=t.o;const c=e.o;const i=e.p;const f=e.t;if(f===null){{if(i==="slot");else{U(t,e,s)}}if(o!==null&&c!==null){T(l,o,e,c,n)}else if(c!==null){if(t.t!==null){l.textContent=""}N(l,null,e,c,0,c.length-1)}else if(o!==null){R(o,0,o.length-1)}}else if(t.t!==f){l.data=f}};const q=t=>{{t.l&&t.l.ref&&t.l.ref(null);t.o&&t.o.map(q)}};const F=(t,s,l=false)=>{const o=t.$hostElement$;const c=t.S||p(null,null);const i=$(s)?s:y(null,null,s);n=o.tagName;if(l&&i.l){for(const t of Object.keys(i.l)){if(o.hasAttribute(t)&&!["key","ref","style","class"].includes(t)){i.l[t]=o[t]}}}i.p=null;i.u|=4;t.S=i;i.h=c.h=o.shadowRoot||o;{e=o["s-sc"]}W(c,i,l)};const H=(t,e)=>{if(e&&!t.j&&e["s-p"]){e["s-p"].push(new Promise((e=>t.j=e)))}};const I=(t,e)=>{{t.u|=16}if(t.u&4){t.u|=512;return}H(t,t.k);const n=()=>V(t,e);return Mt(n)};const V=(t,e)=>{const n=o("scheduleUpdate",t.m.v);const s=t.C;let l;n();return _(l,(()=>B(t,s,e)))};const _=(t,e)=>z(t)?t.then(e):e();const z=t=>t instanceof Promise||t&&t.then&&typeof t.then==="function";const B=async(t,e,n)=>{var s;const l=t.$hostElement$;const c=o("update",t.m.v);const i=l["s-rc"];if(n){k(t)}const f=o("render",t.m.v);{D(t,e,l,n)}if(i){i.map((t=>t()));l["s-rc"]=undefined}f();c();{const e=(s=l["s-p"])!==null&&s!==void 0?s:[];const n=()=>G(t);if(e.length===0){n()}else{Promise.all(e).then(n);t.u|=4;e.length=0}}};const D=(t,e,n,s)=>{try{e=e.render();{t.u&=~16}{t.u|=2}{{{F(t,e,s)}}}}catch(e){at(e,t.$hostElement$)}return null};const G=t=>{const e=t.m.v;const n=t.$hostElement$;const s=o("postUpdate",e);const l=t.k;if(!(t.u&64)){t.u|=64;{K(n)}s();{t.M(n);if(!l){J()}}}else{s()}{if(t.j){t.j();t.j=undefined}if(t.u&512){Ct((()=>I(t,false)))}t.u&=~(4|512)}};const J=e=>{{K($t.documentElement)}Ct((()=>w(ht,"appload",{detail:{namespace:t}})))};const K=t=>t.classList.add("hydrated");const Q=(t,e)=>it(t).O.get(e);const X=(t,e,n,s)=>{const l=it(t);const o=l.O.get(e);const c=l.u;const i=l.C;n=b(n,s.P[e][0]);const f=Number.isNaN(o)&&Number.isNaN(n);const r=n!==o&&!f;if((!(c&8)||o===undefined)&&r){l.O.set(e,n);if(i){if((c&(2|16))===2){I(l,false)}}}};const Y=(t,e,n)=>{var s;const l=t.prototype;if(e.P){const o=Object.entries(e.P);o.map((([t,[s]])=>{if(s&31||n&2&&s&32){Object.defineProperty(l,t,{get(){return Q(this,t)},set(n){X(this,t,n,e)},configurable:true,enumerable:true})}}));if(n&1){const n=new Map;l.attributeChangedCallback=function(t,s,o){bt.jmp((()=>{var c;const i=n.get(t);if(this.hasOwnProperty(i)){o=this[i];delete this[i]}else if(l.hasOwnProperty(i)&&typeof this[i]==="number"&&this[i]==o){return}else if(i==null){const n=it(this);const l=n===null||n===void 0?void 0:n.u;if(l&&!(l&8)&&l&128&&o!==s){const l=n.C;const i=(c=e.U)===null||c===void 0?void 0:c[t];i===null||i===void 0?void 0:i.forEach((e=>{if(l[e]!=null){l[e].call(l,o,s,t)}}))}return}this[i]=o===null&&typeof this[i]==="boolean"?false:o}))};t.observedAttributes=Array.from(new Set([...Object.keys((s=e.U)!==null&&s!==void 0?s:{}),...o.filter((([t,e])=>e[0]&15)).map((([t,e])=>{const s=e[1]||t;n.set(s,t);return s}))]))}}return t};const Z=async(t,e,n,s)=>{let l;if((e.u&32)===0){e.u|=32;{l=yt(n);if(l.then){const t=c();l=await l;t()}if(!l.isProxied){Y(l,n,2);l.isProxied=true}const t=o("createInstance",n.v);{e.u|=8}try{new l(e)}catch(t){at(t)}{e.u&=~8}t()}if(l.style){let t=l.style;const e=C(n);if(!pt.has(e)){const s=o("registerStyles",n.v);g(e,t,!!(n.u&1));s()}}}const i=e.k;const f=()=>I(e,true);if(i&&i["s-rc"]){i["s-rc"].push(f)}else{f()}};const tt=t=>{};const et=t=>{if((bt.u&1)===0){const e=it(t);const n=e.m;const s=o("connectedCallback",n.v);if(!(e.u&1)){e.u|=1;{let n=t;while(n=n.parentNode||n.host){if(n["s-p"]){H(e,e.k=n);break}}}if(n.P){Object.entries(n.P).map((([e,[n]])=>{if(n&31&&t.hasOwnProperty(e)){const n=t[e];delete t[e];t[e]=n}}))}{Z(t,e,n)}}else{if(e===null||e===void 0?void 0:e.C);else if(e===null||e===void 0?void 0:e.A){e.A.then((()=>tt()))}}s()}};const nt=t=>{};const st=async t=>{if((bt.u&1)===0){const e=it(t);if(e===null||e===void 0?void 0:e.C);else if(e===null||e===void 0?void 0:e.A){e.A.then((()=>nt()))}}};const lt=(t,e={})=>{var n;const s=o();const l=[];const c=e.exclude||[];const r=ht.customElements;const u=$t.head;const a=u.querySelector("meta[charset]");const y=$t.createElement("style");const p=[];let h;let $=true;Object.assign(bt,e);bt.N=new URL(e.resourcesUrl||"./",$t.baseURI).href;let b=false;t.map((t=>{t[1].map((e=>{const n={u:e[0],v:e[1],P:e[2],R:e[3]};if(n.u&4){b=true}{n.P=e[2]}const s=n.v;const o=class extends HTMLElement{constructor(t){super(t);t=this;rt(t,n);if(n.u&1){{{t.attachShadow({mode:"open"})}}}}connectedCallback(){if(h){clearTimeout(h);h=null}if($){p.push(this)}else{bt.jmp((()=>et(this)))}}disconnectedCallback(){bt.jmp((()=>st(this)))}componentOnReady(){return it(this).A}};n.T=t[0];if(!c.includes(s)&&!r.get(s)){l.push(s);r.define(s,Y(o,n,1))}}))}));if(b){y.innerHTML+=f}{y.innerHTML+=l+i}if(y.innerHTML.length){y.setAttribute("data-styles","");const t=(n=bt.$)!==null&&n!==void 0?n:d($t);if(t!=null){y.setAttribute("nonce",t)}u.insertBefore(y,a?a.nextSibling:u.firstChild)}$=false;if(p.length){p.map((t=>t.connectedCallback()))}else{{bt.jmp((()=>h=setTimeout(J,30)))}}s()};const ot=t=>bt.$=t;const ct=new WeakMap;const it=t=>ct.get(t);const ft=(t,e)=>ct.set(e.C=t,e);const rt=(t,e)=>{const n={u:0,$hostElement$:t,m:e,O:new Map};{n.A=new Promise((t=>n.M=t));t["s-p"]=[];t["s-rc"]=[]}return ct.set(t,n)};const ut=(t,e)=>e in t;const at=(t,e)=>(0,console.error)(t,e);const dt=new Map;const yt=(t,e,n)=>{const s=t.v.replace(/-/g,"_");const l=t.T;const o=dt.get(l);if(o){return o[s]} /*!__STENCIL_STATIC_IMPORT_SWITCH__*/return import(`./${l}.entry.js${""}`).then((t=>{{dt.set(l,t)}return t[s]}),at)};const pt=new Map;const ht=typeof window!=="undefined"?window:{};const $t=ht.document||{head:{}};const bt={u:0,N:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,s)=>t.addEventListener(e,n,s),rel:(t,e,n,s)=>t.removeEventListener(e,n,s),ce:(t,e)=>new CustomEvent(t,e)};const mt=t=>Promise.resolve(t);const vt=(()=>{try{new CSSStyleSheet;return typeof(new CSSStyleSheet).replaceSync==="function"}catch(t){}return false})();const wt=[];const St=[];const gt=(t,e)=>n=>{t.push(n);if(!l){l=true;if(e&&bt.u&4){Ct(kt)}else{bt.raf(kt)}}};const jt=t=>{for(let e=0;e<t.length;e++){try{t[e](performance.now())}catch(t){at(t)}}t.length=0};const kt=()=>{jt(wt);{jt(St);if(l=wt.length>0){bt.raf(kt)}}};const Ct=t=>mt().then(t);const Mt=gt(St,true);export{lt as b,v as c,m as g,y as h,mt as p,ft as r,ot as s}; //# sourceMappingURL=p-0b91ba61.js.map