mastodon-share-button
Version:
Stencil Mastodon share button
1 lines • 11.4 kB
JavaScript
const t="mastodon-share-button";let e,n,o,l=0,s=!1,r=!1,c=!1,i=!1;const a="undefined"!=typeof window?window:{},u=a.CSS,f=a.document||{head:{}},$={t:0,o:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,o)=>t.addEventListener(e,n,o),rel:(t,e,n,o)=>t.removeEventListener(e,n,o)},d=(()=>(f.head.attachShadow+"").indexOf("[native")>-1)(),m=t=>Promise.resolve(t),p=(()=>{try{return new CSSStyleSheet,!0}catch(t){}return!1})(),h=new WeakMap,w=t=>h.get(t),y=(t,e)=>h.set(e.l=t,e),b=(t,e)=>e in t,_=t=>console.error(t),g=new Map,v=new Map,j=[],R=[],S=[],M=(t,e)=>n=>{t.push(n),s||(s=!0,e&&4&$.t?U(L):$.raf(L))},k=(t,e)=>{let n=0,o=0;for(;n<t.length&&(o=performance.now())<e;)try{t[n++](o)}catch(l){_(l)}n===t.length?t.length=0:0!==n&&t.splice(0,n)},L=()=>{l++,(t=>{for(let n=0;n<t.length;n++)try{t[n](performance.now())}catch(e){_(e)}t.length=0})(j);const t=2==(6&$.t)?performance.now()+10*Math.ceil(l*(1/22)):1/0;k(R,t),k(S,t),R.length>0&&(S.push(...R),R.length=0),(s=j.length+R.length+S.length>0)?$.raf(L):l=0},U=t=>m().then(t),O=M(R,!0),P={},T=t=>"object"==(t=typeof t)||"function"===t,x=()=>u&&u.supports&&u.supports("color","var(--c)")?m():__sc_import_mastodon_share_button("./p-1826e5f0.js").then(()=>($.s=a.__cssshim)?(!1).i():0),C=()=>{$.s=a.__cssshim;const e=Array.from(f.querySelectorAll("script")).find(e=>new RegExp(`/${t}(\\.esm)?\\.js($|\\?|#)`).test(e.src)||e.getAttribute("data-stencil-namespace")===t),n={};return"onbeforeload"in e&&!history.scrollRestoration?{then(){}}:(n.resourcesUrl=new URL(".",new URL(e.getAttribute("data-resources-url")||e.src,a.location.href)).href,A(n.resourcesUrl,e),a.customElements?m(n):__sc_import_mastodon_share_button("./p-3b66a627.js").then(()=>n))},A=(e,n)=>{const o=`__sc_import_${t.replace(/\s|-/g,"_")}`;try{a[o]=new Function("w",`return import(w);//${Math.random()}`)}catch(l){const t=new Map;a[o]=l=>{const s=new URL(l,e).href;let r=t.get(s);if(!r){const e=f.createElement("script");e.type="module",e.crossOrigin=n.crossOrigin,e.src=URL.createObjectURL(new Blob([`import * as m from '${s}'; window.${o}.m = m;`],{type:"application/javascript"})),r=new Promise(t=>{e.onload=()=>{t(a[o].m),e.remove()}}),t.set(s,r),f.head.appendChild(e)}return r}}},E=new WeakMap,F=t=>"sc-"+t,N=(t,e,...n)=>{let o=null,l=null,s=!1,r=!1,c=[];const i=e=>{for(let n=0;n<e.length;n++)o=e[n],Array.isArray(o)?i(o):null!=o&&"boolean"!=typeof o&&((s="function"!=typeof t&&!T(o))&&(o=String(o)),s&&r?c[c.length-1].u+=o:c.push(s?W(null,o):o),r=s)};if(i(n),e){e.name&&(l=e.name);{const t=e.className||e.class;t&&(e.class="object"!=typeof t?t:Object.keys(t).filter(e=>t[e]).join(" "))}}const a=W(t,null);return a.$=e,c.length>0&&(a.p=c),a.h=l,a},W=(t,e)=>({t:0,_:t,u:e,g:null,p:null,$:null,h:null}),q={},B=(t,e,n,o,l,s)=>{if(n!==o){let c=b(t,e),i=e.toLowerCase();if("class"===e){const e=t.classList,l=H(n),s=H(o);e.remove(...l.filter(t=>t&&!s.includes(t))),e.add(...s.filter(t=>t&&!l.includes(t)))}else if(c||"o"!==e[0]||"n"!==e[1]){const i=T(o);if((c||i&&null!==o)&&!l)try{if(t.tagName.includes("-"))t[e]=o;else{let l=null==o?"":o;"list"===e?c=!1:null!=n&&t[e]==l||(t[e]=l)}}catch(r){}null==o||!1===o?t.removeAttribute(e):(!c||4&s||l)&&!i&&t.setAttribute(e,o=!0===o?"":o)}else e="-"===e[2]?e.slice(3):b(a,i)?i.slice(2):i[2]+e.slice(3),n&&$.rel(t,e,n,!1),o&&$.ael(t,e,o,!1)}},D=/\s/,H=t=>t?t.split(D):[],V=(t,e,n,o)=>{const l=11===e.g.nodeType&&e.g.host?e.g.host:e.g,s=t&&t.$||P,r=e.$||P;for(o in s)o in r||B(l,o,s[o],void 0,n,e.t);for(o in r)B(l,o,s[o],r[o],n,e.t)},z=(t,l,s,c)=>{let a,u,$,d=l.p[s],m=0;if(r||(i=!0,"slot"===d._&&(e&&c.classList.add(e+"-s"),d.t|=d.p?2:1)),null!==d.u)a=d.g=f.createTextNode(d.u);else if(1&d.t)a=d.g=f.createTextNode("");else if(a=d.g=f.createElement(2&d.t?"slot-fb":d._),V(null,d,!1),null!=e&&a["s-si"]!==e&&a.classList.add(a["s-si"]=e),d.p)for(m=0;m<d.p.length;++m)u=z(t,d,m,a),u&&a.appendChild(u);return a["s-hn"]=o,3&d.t&&(a["s-sr"]=!0,a["s-cr"]=n,a["s-sn"]=d.h||"",$=t&&t.p&&t.p[s],$&&$._===d._&&t.g&&G(t.g,!1)),a},G=(t,e)=>{$.t|=1;const n=t.childNodes;for(let l=n.length-1;l>=0;l--){const t=n[l];t["s-hn"]!==o&&t["s-ol"]&&(X(t).insertBefore(t,Q(t)),t["s-ol"].remove(),t["s-ol"]=void 0,i=!0),e&&G(t,e)}$.t&=-2},I=(t,e,n,l,s,r)=>{let c,i=t["s-cr"]&&t["s-cr"].parentNode||t;for(i.shadowRoot&&i.tagName===o&&(i=i.shadowRoot);s<=r;++s)l[s]&&(c=z(null,n,s,t),c&&(l[s].g=c,i.insertBefore(c,Q(e))))},J=(t,e,n,o,l)=>{for(;e<=n;++e)(o=t[e])&&(c=!0,(l=o.g)["s-ol"]?l["s-ol"].remove():G(l,!0),l.remove())},K=(t,e)=>t._===e._&&("slot"!==t._||t.h===e.h),Q=t=>t&&t["s-ol"]||t,X=t=>(t["s-ol"]?t["s-ol"]:t).parentNode,Y=(t,e)=>{const n=e.g=t.g,o=t.p,l=e.p,s=e.u;let r;null===s?("slot"===e._||V(t,e,!1),null!==o&&null!==l?((t,e,n,o)=>{let l,s=0,r=0,c=e.length-1,i=e[0],a=e[c],u=o.length-1,f=o[0],$=o[u];for(;s<=c&&r<=u;)null==i?i=e[++s]:null==a?a=e[--c]:null==f?f=o[++r]:null==$?$=o[--u]:K(i,f)?(Y(i,f),i=e[++s],f=o[++r]):K(a,$)?(Y(a,$),a=e[--c],$=o[--u]):K(i,$)?("slot"!==i._&&"slot"!==$._||G(i.g.parentNode,!1),Y(i,$),t.insertBefore(i.g,a.g.nextSibling),i=e[++s],$=o[--u]):K(a,f)?("slot"!==i._&&"slot"!==$._||G(a.g.parentNode,!1),Y(a,f),t.insertBefore(a.g,i.g),a=e[--c],f=o[++r]):(l=z(e&&e[r],n,r,t),f=o[++r],l&&X(i.g).insertBefore(l,Q(i.g)));s>c?I(t,null==o[u+1]?null:o[u+1].g,n,o,r,u):r>u&&J(e,s,c)})(n,o,e,l):null!==l?(null!==t.u&&(n.textContent=""),I(n,null,e,l,0,l.length-1)):null!==o&&J(o,0,o.length-1)):(r=n["s-cr"])?r.parentNode.textContent=s:t.u!==s&&(n.data=s)},Z=t=>{let e,n,o,l,s,r,c=t.childNodes;for(n=0,o=c.length;n<o;n++)if(e=c[n],1===e.nodeType){if(e["s-sr"])for(s=e["s-sn"],e.hidden=!1,l=0;l<o;l++)if(c[l]["s-hn"]!==e["s-hn"])if(r=c[l].nodeType,""!==s){if(1===r&&s===c[l].getAttribute("slot")){e.hidden=!0;break}}else if(1===r||3===r&&""!==c[l].textContent.trim()){e.hidden=!0;break}Z(e)}},tt=[],et=t=>{let e,n,o,l,s,r,i=0,a=t.childNodes,u=a.length;for(;i<u;i++){if(e=a[i],e["s-sr"]&&(n=e["s-cr"]))for(o=n.parentNode.childNodes,l=e["s-sn"],r=o.length-1;r>=0;r--)n=o[r],n["s-cn"]||n["s-nr"]||n["s-hn"]===e["s-hn"]||(nt(n,l)?(s=tt.find(t=>t.v===n),c=!0,n["s-sn"]=n["s-sn"]||l,s?s.j=e:tt.push({j:e,v:n}),n["s-sr"]&&tt.forEach(t=>{nt(t.v,n["s-sn"])&&(s=tt.find(t=>t.v===n),s&&(t.j=s.j))})):tt.some(t=>t.v===n)||tt.push({v:n}));1===e.nodeType&&et(e)}},nt=(t,e)=>1===t.nodeType?null===t.getAttribute("slot")&&""===e||t.getAttribute("slot")===e:t["s-sn"]===e||""===e,ot=(t,e)=>{e&&!t.R&&e["s-p"].push(new Promise(e=>t.R=e))},lt=(t,e,n,o)=>{if(e.t|=16,4&e.t)return void(e.t|=512);const l=e.l,s=()=>st(t,e,n,l,o);return ot(e,e.S),ut(void 0,()=>O(s))},st=(t,l,s,a,u)=>{const m=t["s-rc"];u&&((t,e)=>{const n=((t,e)=>{let n=F(e.M),o=v.get(n);if(t=11===t.nodeType?t:f,o)if("string"==typeof o){let e,l=E.get(t=t.head||t);l||E.set(t,l=new Set),l.has(n)||(e=f.createElement("style"),e.innerHTML=o,t.insertBefore(e,t.querySelector("link")),l&&l.add(n))}else t.adoptedStyleSheets.includes(o)||(t.adoptedStyleSheets=[...t.adoptedStyleSheets,o]);return n})(d&&t.shadowRoot?t.shadowRoot:t.getRootNode(),e);10&e.t&&(t["s-sc"]=n,t.classList.add(n+"-h"))})(t,s),((t,l,s,a)=>{o=t.tagName;const u=l.k||W(null,null),m=(p=a)&&p._===q?a:N(null,null,a);var p;if(m._=null,m.t|=4,l.k=m,m.g=u.g=t.shadowRoot||t,e=t["s-sc"],n=t["s-cr"],r=d&&0!=(1&s.t),c=!1,Y(u,m),i){let t,e,n,o,l,s;et(m.g);let r=0;for(;r<tt.length;r++)t=tt[r],e=t.v,e["s-ol"]||(n=f.createTextNode(""),n["s-nr"]=e,e.parentNode.insertBefore(e["s-ol"]=n,e));for($.t|=1,r=0;r<tt.length;r++)if(t=tt[r],e=t.v,t.j){for(o=t.j.parentNode,l=t.j.nextSibling,n=e["s-ol"];n=n.previousSibling;)if(s=n["s-nr"],s&&s["s-sn"]===e["s-sn"]&&o===s.parentNode&&(s=s.nextSibling,!s||!s["s-nr"])){l=s;break}(!l&&o!==e.parentNode||e.nextSibling!==l)&&e!==l&&(!e["s-hn"]&&e["s-ol"]&&(e["s-hn"]=e["s-ol"].parentNode.nodeName),o.insertBefore(e,l))}else 1===e.nodeType&&(e.hidden=!0);$.t&=-2}c&&Z(m.g),tt.length=0})(t,l,s,rt(a)),l.t&=-17,l.t|=2,m&&(m.forEach(t=>t()),t["s-rc"]=void 0);{const e=t["s-p"],n=()=>ct(t,l,s);0===e.length?n():(Promise.all(e).then(n),l.t|=4,e.length=0)}},rt=t=>{try{t=t.render()}catch(e){_(e)}return t},ct=(t,e,n)=>{const o=e.l,l=e.S;64&e.t||(e.t|=64,ft(t),at(o,"componentDidLoad"),e.L(t),l||it()),e.R&&(e.R(),e.R=void 0),512&e.t&&U(()=>lt(t,e,n,!1)),e.t&=-517},it=()=>{ft(f.documentElement),$.t|=2},at=(t,e,n)=>{if(t&&t[e])try{return t[e](n)}catch(o){_(o)}},ut=(t,e)=>t&&t.then?t.then(e):e(),ft=t=>t.classList.add("hydrated"),$t=(t,e,n)=>{if(e.U){const o=Object.entries(e.U),l=t.prototype;if(o.forEach(([t,[o]])=>{(31&o||2&n&&32&o)&&Object.defineProperty(l,t,{get(){return e=t,w(this).O.get(e);var e},set(n){((t,e,n,o)=>{const l=w(this),s=l.P,r=l.O.get(e),c=l.t,i=l.l;var a,u;u=o.U[e][0],(n=null==(a=n)||T(a)?a:4&u?"false"!==a&&(""===a||!!a):1&u?String(a):a)===r||8&c&&void 0!==r||(l.O.set(e,n),i&&2==(18&c)&<(s,l,o,!1))})(0,t,n,e)},configurable:!0,enumerable:!0})}),1&n){const e=new Map;l.attributeChangedCallback=function(t,n,o){$.jmp(()=>{const n=e.get(t);this[n]=(null!==o||"boolean"!=typeof this[n])&&o})},t.observedAttributes=o.filter(([t,e])=>15&e[0]).map(([t,n])=>{const o=n[1]||t;return e.set(o,t),o})}}return t},dt=(t,e={})=>{const n=[],o=e.exclude||[],l=a.customElements,s=f.head,r=s.querySelector("meta[charset]"),c=f.createElement("style"),i=[];let u,m=!0;Object.assign($,e),$.o=new URL(e.resourcesUrl||"./",f.baseURI).href,e.syncQueue&&($.t|=4),t.forEach(t=>t[1].forEach(e=>{const s={t:e[0],M:e[1],U:e[2],T:e[3]};s.U=e[2],!d&&1&s.t&&(s.t|=8);const r=s.M,c=class extends HTMLElement{constructor(t){super(t),(t=>{const e={t:0,P:t,O:new Map};e.C=new Promise(t=>e.L=t),t["s-p"]=[],t["s-rc"]=[],h.set(t,e)})(t=this),1&s.t&&(d?t.attachShadow({mode:"open"}):"shadowRoot"in t||(t.shadowRoot=t))}connectedCallback(){u&&(clearTimeout(u),u=null),m?i.push(this):$.jmp(()=>((t,e)=>{if(0==(1&$.t)){const n=()=>{},o=w(t);if(!(1&o.t)){o.t|=1,(4&e.t||8&e.t)&&(t=>{const e=t["s-cr"]=f.createComment("");e["s-cn"]=!0,t.insertBefore(e,t.firstChild)})(t);{let e=t;for(;e=e.parentNode||e.host;)if(e["s-p"]){ot(o,o.S=e);break}}e.U&&Object.entries(e.U).forEach(([e,[n]])=>{if(31&n&&t.hasOwnProperty(e)){const n=t[e];delete t[e],t[e]=n}}),U(()=>(async(t,e,n,o,l)=>{if(0==(32&e.t)){e.t|=32;{if((l=(t=>{const e=t.M.replace(/-/g,"_"),n=t.A,o=g.get(n);return o?o[e]:__sc_import_mastodon_share_button(`./${n}.entry.js`).then(t=>(g.set(n,t),t[e]),_)})(n)).then){const t=()=>{};l=await l,t()}l.isProxied||($t(l,n,2),l.isProxied=!0);const t=()=>{};e.t|=8;try{new l(e)}catch(c){_(c)}e.t&=-9,t()}const t=F(n.M);if(!v.has(t)&&l.style){const e=()=>{};let o=l.style;8&n.t&&(o=await __sc_import_mastodon_share_button("./p-93e23355.js").then(e=>e.scopeCss(o,t,!1))),((t,e,n)=>{let o=v.get(t);p&&n?(o=o||new CSSStyleSheet,o.replace(e)):o=e,v.set(t,o)})(t,o,!!(1&n.t)),e()}}const s=e.S,r=()=>lt(t,e,n,!0);s&&s["s-rc"]?s["s-rc"].push(r):r()})(t,o,e))}n()}})(this,s))}disconnectedCallback(){$.jmp(()=>{})}forceUpdate(){((t,e)=>{{const n=w(t);n.P.isConnected&&2==(18&n.t)&<(t,n,e,!1)}})(this,s)}componentOnReady(){return w(this).C}};s.A=t[0],o.includes(r)||l.get(r)||(n.push(r),l.define(r,$t(c,s,1)))})),c.innerHTML=n+"{visibility:hidden}.hydrated{visibility:inherit}",c.setAttribute("data-styles",""),s.insertBefore(c,r?r.nextSibling:s.firstChild),m=!1,i.length>0?i.forEach(t=>t.connectedCallback()):$.jmp(()=>u=setTimeout(it,30))},mt=t=>{const e=new URL(t,$.o);return e.origin!==a.location.origin?e.href:e.pathname},pt=t=>w(t).P;export{x as a,dt as b,pt as c,mt as g,N as h,C as p,y as r};