UNPKG

@tindtechnologies/universalviewer

Version:

The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎

18 lines (16 loc) 5.24 kB
import"./chunk-L67DAW3A.js";var P=function(r){var e=[],n=0,t;r=r.replace(/(\[[^\]]*\])/g,function(a,i){var c="__ph-"+n+"__";return e.push(i),n++,c}),t=r.replace(/(:nth-[-\w]+)(\([^)]+\))/g,function(a,i,c){var v="__ph-"+n+"__";return e.push(c),n++,i+v});var o={content:t,placeholders:e};return o},j=function(r,e){return e.replace(/__ph-(\d+)__/g,function(n,t){return r[+t]})},d="-shadowcsshost",E="-shadowcssslotted",b="-shadowcsscontext",W=")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)",N=new RegExp("("+d+W,"gim"),x=new RegExp("("+b+W,"gim"),M=new RegExp("("+E+W,"gim"),h=d+"-no-combinator",D=/-shadowcsshost-no-combinator([^\s]*)/,K=[/::shadow/g,/::content/g],U="([>\\s~+[.,{:][\\s\\S]*)?$",R=/-shadowcsshost/gim,Y=/:host/gim,$=/::slotted/gim,A=/:host-context/gim,q=/\/\*\s*[\s\S]*?\*\//g,z=function(r){return r.replace(q,"")},F=/\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g,G=function(r){return r.match(F)||[]},I=/(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g,J=/([{}])/g,Q="{",V="}",C="%BLOCK%",O=function(r,e){var n=X(r),t=0;return n.escapedString.replace(I,function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var i=o[2],c="",v=o[4],s="";v&&v.startsWith("{"+C)&&(c=n.blocks[t++],v=v.substring(C.length+1),s="{");var l={selector:i,content:c},u=e(l);return""+o[1]+u.selector+o[3]+s+u.content+v})},X=function(r){for(var e=r.split(J),n=[],t=[],o=0,a=[],i=0;i<e.length;i++){var c=e[i];c===V&&o--,o>0?a.push(c):(a.length>0&&(t.push(a.join("")),n.push(C),a=[]),n.push(c)),c===Q&&o++}a.length>0&&(t.push(a.join("")),n.push(C));var v={escapedString:n.join(""),blocks:t};return v},Z=function(r){return r=r.replace(A,b).replace(Y,d).replace($,E),r},k=function(r,e,n){return r.replace(e,function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];if(t[2]){for(var a=t[2].split(","),i=[],c=0;c<a.length;c++){var v=a[c].trim();if(!v)break;i.push(n(h,v,t[3]))}return i.join(",")}else return h+t[3]})},w=function(r,e,n){return r+e.replace(d,"")+n},T=function(r){return k(r,N,w)},rr=function(r,e,n){return e.indexOf(d)>-1?w(r,e,n):r+e+n+", "+e+" "+r+n},er=function(r,e){var n=M;return r.replace(n,function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];if(t[2]){var a=t[2].trim(),i=t[3],c="."+e+" > "+a+i;return c}else return h+t[3]})},nr=function(r){return k(r,x,rr)},tr=function(r){return K.reduce(function(e,n){return e.replace(n," ")},r)},ar=function(r){var e=/\[/g,n=/\]/g;return r=r.replace(e,"\\[").replace(n,"\\]"),new RegExp("^("+r+")"+U,"m")},or=function(r,e){var n=ar(e);return!n.test(r)},cr=function(r,e,n){if(R.lastIndex=0,R.test(r)){var t="."+n;return r.replace(D,function(o,a){return a.replace(/([^:]*)(:*)(.*)/,function(i,c,v,s){return c+t+v+s})}).replace(R,t+" ")}return e+" "+r},sr=function(r,e,n){var t=/\[is=([^\]]*)\]/g;e=e.replace(t,function(g){for(var f=[],p=1;p<arguments.length;p++)f[p-1]=arguments[p];return f[0]});var o="."+e,a=function(g){var f=g.trim();if(!f)return"";if(g.indexOf(h)>-1)f=cr(g,e,n);else{var p=g.replace(R,"");if(p.length>0){var _=p.match(/([^:]*)(:*)(.*)/);_&&(f=_[1]+o+_[2]+_[3])}}return f},i=P(r);r=i.content;for(var c="",v=0,s,l=/( |>|\+|~(?!=))\s*/g,u=r.indexOf(h)>-1,m=!u;(s=l.exec(r))!==null;){var B=s[1],S=r.slice(v,s.index).trim();m=m||S.indexOf(h)>-1;var L=m?a(S):S;c+=L+" "+B+" ",v=l.lastIndex}var H=r.substring(v);return m=m||H.indexOf(h)>-1,c+=m?a(H):H,j(i.placeholders,c)},ir=function(r,e,n,t){return r.split(",").map(function(o){return t&&o.indexOf("."+t)>-1?o.trim():or(o,e)?sr(o,e,n).trim():o.trim()}).join(", ")},y=function(r,e,n,t,o){return O(r,function(a){var i=a.selector,c=a.content;a.selector[0]!=="@"?i=ir(a.selector,e,n,t):(a.selector.startsWith("@media")||a.selector.startsWith("@supports")||a.selector.startsWith("@page")||a.selector.startsWith("@document"))&&(c=y(a.content,e,n,t));var v={selector:i.replace(/\s{2,}/g," ").trim(),content:c};return v})},vr=function(r,e,n,t,o){return r=Z(r),r=T(r),r=nr(r),r=er(r,t),r=tr(r),e&&(r=y(r,e,n,t)),r=r.replace(/-shadowcsshost-no-combinator/g,"."+n),r=r.replace(/>\s*\*\s+([^{, ]+)/gm," $1 "),r.trim()},lr=function(r,e,n){var t=e+"-h",o=e+"-s",a=G(r);r=z(r);var i=[];if(n){var c=function(s){var l="/*!@___"+i.length+"___*/",u="/*!@"+s.selector+"*/";return i.push({placeholder:l,comment:u}),s.selector=l+s.selector,s};r=O(r,function(s){return s.selector[0]!=="@"?c(s):((s.selector.startsWith("@media")||s.selector.startsWith("@supports")||s.selector.startsWith("@page")||s.selector.startsWith("@document"))&&(s.content=O(s.content,c)),s)})}var v=vr(r,e,t,o);return r=[v].concat(a).join(` `),n&&i.forEach(function(s){var l=s.placeholder,u=s.comment;r=r.replace(l,u)}),r};export{lr as scopeCss}; /*! Bundled license information: @universalviewer/aleph/dist/esm-es5/shadow-css-9e778f69-c68d0961.js: (** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license * * This file is a port of shadowCSS from webcomponents.js to TypeScript. * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js * https://github.com/angular/angular/blob/master/packages/compiler/src/shadow_css.ts *) */