forked from kriszyp/xstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xstyle.min.js
2 lines (2 loc) · 21.2 KB
/
xstyle.min.js
1
2
!function(){var e=document,t=e.scripts,r=t[t.length-1],n=r.src.replace(/[^\/]+\/xstyle[^\/]*js/,"");define=function(t,s,l){function a(){if(--o<1){for(var e=f.result=l&&l.apply(this,s),t=f.callbacks,r=0;r<t.length;r++)t[r](e);f.callbacks=0}}l||(l=s,s=t,t="put-selector/put");for(var o=1,c=0;c<s.length;c++){var u=s[c],f=i[u];if(!f){f=i[u]={callbacks:[]};var h=e.createElement("script");h.src=n+u+".js",r.parentNode.insertBefore(h,r)}f.callbacks?(o++,f.callbacks.push(function(e){return function(t){s[e]=t,a()}}(c))):s[c]=f.result}f=i[t]||(i[t]={callbacks:[]}),a()},require=function(e,t){define("",e,t)};var i={require:{result:require}}}(),function(e){var t,r=/[-+,> ]/;e([],t=function(e,n){"use strict";function i(t,r){t.appendChild(e.createTextNode(r))}function s(t){function n(){p&&d&&p!=d&&(d==t&&(u||(u=r.test(y)&&e.createDocumentFragment()))?u:d).insertBefore(p,h||null)}for(var u,f,h,d,p,v=arguments,g=v[0],m=0;m<v.length;m++){var y=v[m];if("object"==typeof y){if(f=!1,y instanceof Array){p=e.createDocumentFragment();for(var x=0;x<y.length;x++)p.appendChild(s(y[x]));y=p}if(y.nodeType)p=y,n(),d=y,h=0;else for(var x in y)p[x]=y[x]}else if(f)f=!1,i(p,y);else{1>m&&(t=null),f=!0;var S=y.replace(a,function(r,a,u,f,g,x){a&&(n(),"-"==a||"+"==a?(d=(h=p||d).parentNode,p=null,"+"==a&&(h=h.nextSibling)):("<"==a?d=p=(p||d).parentNode:(","==a?d=t:p&&(d=p),p=null),h=0),p&&(d=p));var S=!u&&f;if(S||!p&&(u||g))if("$"==S)i(d,v[++m]);else{S=S||s.defaultTag;var w=c&&v[m+1]&&v[m+1].name;w&&(S="<"+S+' name="'+w+'">'),p=o&&~(l=S.indexOf("|"))?e.createElementNS(o[S.slice(0,l)],S.slice(l+1)):e.createElement(S)}if(u)if("$"==f&&(f=v[++m]),"#"==u)p.id=f;else{var b=p.className,R=b&&(" "+b+" ").replace(" "+f+" "," ");if("."==u)p.className=b?(R+f).substring(1):f;else if("!"==y){var E;c?s("div",p,"<").innerHTML="":(E=p.parentNode)&&E.removeChild(p)}else R=R.substring(1,R.length-1),R!=b&&(p.className=R)}if(g)if("$"==x&&(x=v[++m]),"style"==g)p.style.cssText=x;else{var T="!"==g.charAt(0)?(g=g.substring(1))&&"removeAttribute":"setAttribute";x=""===x?g:x,o&&~(l=g.indexOf("|"))?p[T+"NS"](o[g.slice(0,l)],g.slice(l+1),x):p[T](g,x)}return""});if(S)throw new SyntaxError("Unexpected char "+S+" in "+y);n(),d=g=p||d}}return t&&u&&t.appendChild(u),g}r=n||r;var l,a=/(?:\s*([-+ ,<>]))?\s*(\.|!\.?|#)?([-\w%$|]+)?(?:\[([^\]=]+)=?['"]?([^\]'"]*)['"]?\])?/g,o=!1,e=e||document,c="object"==typeof e.createElement;return s.addNamespace=function(t,r){e.createElementNS?(o||(o={}))[t]=r:e.namespaces.add(t,r)},s.defaultTag="div",s.forDocument=t,s})}(function(e,t,r){r=r||t,"function"==typeof define?define([],function(){return r()}):"undefined"==typeof window?require("./node-html")(module,r):put=r()}),define("xstyle/core/observe",[],function(){var e=function(e,t,r){var n="_listeners_"+t,i=e[n];if(!i){var s=e[t];Object.defineProperty(e,t,{get:function(){return s},set:function(e){s=e;for(var t=0,r=i.length;r>t;t++)i[t].call(this,e)}}),i=e[n]=[]}i.push(r)};return e.get=function(t,r,n){return n(t[r]),e(t,r,n)},e}),define("xstyle/core/Rule",["xstyle/core/expression","put-selector/put","xstyle/core/utils"],function(e,t,r){function n(){}function i(e){this.caller=e,this.args=[]}var s=Object.create||function(e){function t(){}return t.prototype=e,new t},l={"{":"}","[":"]","(":")"},a=t("div");n.prototype={eachProperty:function(e){for(var t=this.values||0,r=0;r<t.length;r++){var n=t[r];e.call(this,n||"unnamed",t[n])}},fullSelector:function(){return(this.parent?this.parent.fullSelector():"")+(this.selector||"")+" "},newRule:function(e){var t=(this.rules||(this.rules={}))[e]=new n;return t.disabled=this.disabled,t},newCall:function(e){var t=new i(e);return t},addSheetRule:function(e,t){if(t&&"@"!=e.charAt(0)){var r=this.styleSheet,n=r.cssRules||r.rules,i=this.ruleIndex>-1?this.ruleIndex:n.length;return r.addRule(e,t,i),n[i]}},onRule:function(){var e=this.getCssRule();if(this.installStyles)for(var t=0;t<this.installStyles.length;t++){var r=this.installStyles[t];e.style[r[0]]=r[1]}},setStyle:function(e,t){this.cssRule?this.cssRule.style[e]=t:(this.installStyles||(this.installStyles=[])).push([e,t])},getCssRule:function(){return this.cssRule||(this.cssRule=this.addSheetRule(this.selector,this.cssText)),this.cssRule},get:function(e){return this.values[e]},elements:function(e){var t=this;require(["xstyle/core/elemental"],function(r){r.addRenderer(t,function(t){e(t)})})},declareProperty:function(t,r,n){if(!this.disabled)if(r.length)if(">"==r[0].toString().charAt(0)){if(!t){this.generator=r;var i=this;return require(["xstyle/core/generate","xstyle/core/elemental"],function(e,t){r=e.forSelector(r,i),t.addRenderer(i,r)}),void 0}}else{var s=t in a.style||this.getDefinition(t);if(!n||!s){var l=this.definitions||(this.definitions={}),o=r[0];if(o.indexOf&&o.indexOf(",")>-1)for(var c=r.join("").split(/\s*,\s*/),u=[],f=0;f<c.length;f++)u[f]=e(this,t,c[f]);r[0]&&"{"==r[0].operator?u=r[0]:r[1]&&"{"==r[1].operator&&(u=r[1]),l[t]=u||e(this,t,r),s&&console.warn('Overriding existing property "'+t+'"')}}else{var l=this.definitions||(this.definitions={});l[t]=r}},onCall:function(e,t,r){var n=e.ref;return n&&"function"==typeof n.call?n.call(e,this,t,r):void 0},setValue:function(e,t,n){if(!this.disabled){var i=this.values||(this.values=[]);i.push(e),i[e]=t;var s=t.calls;if(s)for(var l=0;l<s.length;l++){{s[l]}this.onCall(s[l],e,t)}if(e){var a=e;do{var o=(n||this).getDefinition(e);if(o){var c=this;return r.when(o,function(e){e=e.splice?e:[e];for(var n=0;n<e.length;n++){var i,s=e[n];if(r.when(s,function(e){i=e.put&&e.put(t,c,a)}),i)return i}})}e=e.substring(0,e.lastIndexOf("-"))}while(e)}}},put:function(e,t){if(this.extend(t),"defaults"!=e&&e&&"string"==typeof e&&this.values)for(var r=e.toString().split(/,\s*/),n=0;n<r.length;n++){var i=this.values[n];i&&t.setValue(i,r[n],this)}},extend:function(e,t){var r=this,n=r.cssText;if(e.cssRule)for(var i=r.cssRule.style,l=e.cssRule.style,a=e.inheritedStyles||(e.inheritedStyles={}),o=0;o<i.length;o++){var c=i[o];(!l[c]||a[c])&&(l[c]=i[c],a[c]=!0)}else e.cssText+=n;if("values,variables,calls".replace(/\w+/g,function(t){var n=r[t];n&&(e[t]=s(n))}),t){var u=r.definitions;u&&(e.definitions=s(u)),e.tagName=r.tagName||e.tagName}e.base=r,r.eachProperty(function(t,r){e.setValue(t,r)}),r.generator&&e.declareProperty(null,r.generator)},getDefinition:function(e,t){var r=this;do{var n=r.definitions&&r.definitions[e]||t&&r.rules&&r.rules[e];r=r.parent}while(!n&&r);return n},appendTo:function(e,r){return t(r||e,(r?"-":"")+(this.tagName||"span")+(this.selector||""))},cssText:""};var o=i.prototype=new n;return o.declareProperty=o.setValue=function(e,t){this.args.push(t)},o.toString=function(){var e=this.operator;return e+this.args+l[e]},n}),define("xstyle/core/expression",["xstyle/core/utils"],function(e){function t(r,n,i){return e.when(r,function(e){var r=n[0];return e?r&&e.get?t(e.get(r),n.slice(1),i):e.receive?e.receive(r?function(e){t(e,n,i)}:i):r?t(e[r],n.slice(1),i):i(e):i(r||e)})}function r(e,r,n){t(e,r.slice(0,r.length-1),function(e){var t=r[r.length-1];e.set?e.set(t,n):e[t]=n})}var n={"true":!0,"false":!1,"null":"null","typeof":"typeof",or:"||",and:"&&"},i=1;return function(s,l,a){function o(){var n,i,s,l=f.length+1,a=[],o=[],c=function(e){return function(t){if(!s&&(a[e]=t,l--,0>=l)){i=!0,n=m?m.apply(this,a):a[0];for(var r=0;r<o.length;r++)o[r](n)}}};if(!m){var u=f[0],h={then:function(e){o?o.push(e):e(h)}};return e.when(u[0],function(e){h=e;for(var n=1;n<u.length;n++){if(!h||!h.get){h={receive:function(r){t(e,u.slice(1),r)},put:function(t){r(e,u.slice(1),t)}};break}h=h.get(u[n])}for(var n=0;n<o.length;n++)o[n](h);o=null}),h}for(var d=0;d<f.length;d++){var u=f[d];t(u[0],u.slice(1),c(d))}return c(-1)(),n&&n.then?n:{receive:function(e){o&&o.push(e),i&&e(n)},stop:function(){s=!0}}}var c=s["var-expr-"+l];if(f)return c;var u,f=[];f.id=i++;var h,d=[],p=a.join?a.join(""):a.toString(),v=p.match(/^[\w_$\/\.-]*$/);if(p=p.replace(/("[^\"]*")|([\w_$\.\/-]+)/g,function(e,t,r){if(r){if(n.hasOwnProperty(r))return n[r];h=r.split("/");var i=h.join("_").replace(/-/g,"_");d.push(i),f.push(h);var l=h[0],a=s.getDefinition(l);if("string"==typeof a||a instanceof Array)a=evaluateExpression(s,l,a);else if(!a)throw new Error('Could not find reference "'+l+'"');return a.forElement&&(u=!0),h[0]=a,i}return e}),v){if(l){var g=function(t,r,n){e.when(findAttributeInAncestors(t,h[0],h[1]),function(e){for(var t=2;t<h.length-1;t++){var r=h[t];e=e.get?e.get(r):e[r]}var r=h[t];e.set?e.set(r,n):e[r]=n})};g.rule=s}}else var m=Function.apply(this,d.concat(["return ("+p+")"]));return f.func=m,s["var-expr-"+l]=f,s["var-expr-"+l]=u?{forElement:function(e){for(var t,r,n=0;n<f.length;n++){var i=f[n],s=i[0];s.forElement&&(s=i[0]=s.forElement(e,1==i.length));var l=r=s.element;if(t)for(;r&&r!=t;)r=r.parentNode;r&&(t=l)}var a=t["expr-result-"+f.id];return a||(t["expr-result-"+f.id]=a=o(),a.element=t),a}}:o()}}),define("xstyle/core/generate",["xstyle/core/elemental","put-selector/put","xstyle/core/utils","xstyle/core/expression","xstyle/core/base","xstyle/core/observe"],function(e,t,r,n,i,s){function l(e,t,r,n){e&&e.receive?e.receive(t,r,n):t(e)}function a(i,a){c++;return i=i.sort?i:[i],function(c,d,p){var v=c;if(c._defaultBinding=!1,c._contentNode)c=c._contentNode;else{if(void 0===p){var g,m=c.childNodes,y=m[0];if(y){g=h.createDocumentFragment();do g.appendChild(y);while(y=m[0])}}c.content=g}for(var x=0,S=[c],w=0,b=i.length;b>w;w++){var R=E,E=i[w];try{if(E.eachProperty)if(E.args)if("("==E.operator){var T=i[w+1];T&&T.eachProperty&&t(v,T.selector);var N=E.args.toString(),I=n(E.parent,0,N);!function(e,n){if(r.when(I,function(t){t.forElement&&(t=t.forElement(e)),l(t,function(t){e.content=t},a,N)}),!("_defaultBinding"in e)){e._defaultBinding=!0;var i=e.appendChild(h.createTextNode("Loading"));s.get(e,"content",function(r){if(e._defaultBinding)if(r&&r.sort)if(i&&(i.parentNode.removeChild(i),i=null),r.isSequence)o(r,E.parent)(e,d,p);else{e.innerHTML="";var s=n&&n.eachProperty&&n.each;s=s?o(s,n):function(e,r,n){return t(n||e,(n?"-":"")+(u[e.tagName]||"span"),""+r)};var l=r.map(function(t){return s(e,t,null)});r.observe&&r.observe(function(t,r,n){if(r>-1){var i=l[r];i.parentNode.removeChild(i),l.splice(r,1)}n>-1&&l.splice(n,0,s(e,t,l[n]||null))},!0)}else r&&r.nodeType?(i&&(i.parentNode.removeChild(i),i=null),e.appendChild(r)):(r=void 0===r?"":r,e.tagName in f?(e.value=r,e["-x-variable"]=I):i.nodeValue=r)})}}(v,T)}else t(v,E.toString());else t(v,E.selector),e.update(v,E.selector);else if("string"==typeof E){"="==E.charAt(0)&&(E=E.slice(1));var k=v,T=i[w+1],C=[];E.replace(/([,\n]+)?([\t ]+)?(\.|#)?([-\w%$|\.\#]+)(?:\[([^\]=]+)=?['"]?([^\]'"]*)['"]?\])?/g,function(){C.push(arguments)});for(var A=0;A<C.length;A++)(function(r,n,i,s,l,o,u){if(i&&n){var f=i.length;f>x?S[f]=k:k=S[f]||k,x=f}k=k._contentNode||k;var h;if(s)h=(R&&R.args?"":"span")+s+l;else{var g=l.match(/^[-\w]+/)[0],m=a.getDefinition(g);m&&m.appendTo?(k=m.appendTo(k,p),l=l.slice(g.length),l&&t(k,l)):h=l}h&&(k=t(p||k,(p?"-":"")+h)),p=null,o&&(u=""===u?o:u,k.setAttribute(o,u)),d&&(k.item=d),(A<C.length-1||k!=v&&k!=c&&(!T||!T.base))&&e.update(k),v=k}).apply(this,C[A])}else v.appendChild(h.createTextNode(E.value))}catch(q){console.error(q,q.stack),v.appendChild(h.createTextNode(q))}}return v}}function o(e,t){return a(t,i)(e)}var c=0,u={TABLE:"tr",TBODY:"tr",TR:"td",UL:"li",OL:"li",SELECT:"option"},f={INPUT:1,TEXTAREA:1,SELECT:1},h=document;return o.forSelector=a,o}),define("xstyle/core/elemental",["put-selector/put"],function(e){function t(e,t,r,n){function i(e){(!r||d.call(e.target,r))&&n(e)}c?e.addEventListener(t,i,!1):e.attachEvent(t,i)}function r(e){return h[e]}function n(e){/e/.test(a.readyState||"")?setTimeout(e,200):a.addEventListener("DOMContentLoaded",e)}function i(e){for(var t=a.querySelectorAll(e.selector),r=e.name,n=0,i=t.length;i>n;n++){var s=t[n],l=s.elementalStyle,o=s.elementalSpecificities;l||(l=s.elementalStyle={},o=s.elementalSpecificities={});var c=s.renderings;c||(c=s.renderings=[],v.push(s)),c.push({name:r,rendered:l[r]==e.propertyValue,renderer:e}),l[r]=e.propertyValue}}function s(){for(var t=0;t<v.length;t++){var r=v[t],n=r.renderings,i=r.elementalStyle;delete r.renderings;for(var s=0;s<n.length;s++){var l=n[s],a=l.renderer,o=a.rendered;if(g=i[l.name]==a.propertyValue,!o&&g)try{a.render(r)}catch(c){console.error(c,c.stack),e(r,"div.error",c.toString())}o&&!g&&a.unrender&&(a.unrender(r),n.splice(s--,1))}}v=[]}function l(e,t){for(var r=0,n=p.length;n>r;r++){var i=p[r];t&&t!=i.selector||(d?!d.call(e,i.selector):!e.currentStyle[i.id])||i.render(e)}}var a=document,o=1,c=!!a.addEventListener;t(a,"change",null,function(e){var t=e.target,r=t["-x-variable"];r&&r.put&&r.put(t.value)});var u,f=a.createElement("div"),h={"dom-qsa2.1":!!f.querySelectorAll},d=f.matches||f.matchesSelector||f.webkitMatchesSelector||f.mozMatchesSelector||f.msMatchesSelector||f.oMatchesSelector,p=[],v=[];n(function(){if(!u)if(u=!0,r("dom-qsa2.1")){for(var e=0,t=p.length;t>e;e++)i(p[e]);s()}else for(var n=a.all,e=0,t=n.length;t>e;e++)l(n[e])});var g;return{ready:n,on:t,addRenderer:function(e,t){var r={selector:e.selector,render:t};d||e.setStyle(r.id="x"+o++,"true"),p.push(r),u&&i(r),s()},update:l,clearRenderers:function(){p=[]}}}),define("xstyle/core/base",["xstyle/core/elemental","xstyle/core/expression","xstyle/core/utils","put-selector/put","xstyle/core/Rule","xstyle/core/observe"],function(e,t,r,n,i,s){function l(e,t){return{forElement:function(r,n){var i=r;for(t&&(r=r.parentNode);!(e in r);)if(r=r.parentNode,!r)throw new Error(e+" not found");return n&&(r["_"+e+"Node"]=i),{element:r,receive:function(t,n){s.get(e in r?r:n,e,t)},appendTo:t}},put:function(t,r){r[e]=t}}}var a={"":0,"false":0,"true":1},o={display:["none",""],visibility:["hidden","visible"],"float":["none","left"]},c=n("div"),u=navigator.userAgent,f=u.indexOf("WebKit")>-1?"-webkit-":u.indexOf("Firefox")>-1?"-moz-":u.indexOf("MSIE")>-1?"-ms-":u.indexOf("Opera")>-1?"-o-":"",h=new i;return h.root=!0,h.definitions={Math:Math,module:function(e,t){return t||require([e]),{then:function(t){require([e],t)}}},item:l("item"),content:l("content",function(e){e.appendChild(this.element)}),element:{forElement:function(e){return{element:e,receive:function(t){t(e)},get:function(e){return this.element[e]}}}},event:{receive:function(e){e(currentEvent)}},each:{put:function(e,t){t.each=e}},prefix:{put:function(e,t,r){return"string"==typeof c.style[f+r]?(t.setStyle(f+r,e),!0):void 0}},"var":{put:function(e,t,r){(t.variables||(t.variables={}))[r]=e;var n=t.variableListeners;n=n&&n[r]||0;for(var i=0;i<n.length;i++)n[i](e)},call:function(e,t,r,n){this.receive(function(e){var i=n.toString().replace(/var\([^)]+\)/g,e),s=a[i];if(s>-1){var l=o[r];l&&(i=l[s])}t.setStyle(r,i)},t,e.args[0])},receive:function(e,t,r){var n=t;do{var i=n.variables&&n.variables[r]||n.definitions&&n.definitions[r];if(i){if(i.receive)return i.receive(e,t,r);var s=n.variableListeners||(n.variableListeners={});return(s[r]||(s[r]=[])).push(e),e(i)}n=n.parent}while(n);e()}},"extends":{call:function(e,t){for(var n=e.args,i=0;i<n.length;i++)return r.extend(t,n[i],console.error)}},on:{put:function(r,n,i){e.on(document,i.slice(3),n.selector,function(e){currentEvent=e;var s=t(n,i,r);s.forElement&&(s=s.forElement(e.target)),s&&s.stop&&s.stop(),currentEvent=null})}},"@supports":{selector:function(e){function t(e){var i;if(i=e.match(/^\s*not(.*)/))return!t(i[1]);if(i=e.match(/\((.*)\)/))return t(i[1]);if(i=e.match(/([^:]*):(.*)/)){var s=r.convertCssNameToJs(i[1]),l=c.style[s]=i[2];return c.style[s]==l}if(i=e.match(/\w+\[(.*)=(.*)\]/))return n(i[0])[i[1]]==i[2];if(i=e.match(/\w+/))return r.isTagSupported(i);throw new Error("can't parse @supports string")}t(e.selector.slice(10))?e.selector="":e.disabled=!0}}},h}),define("xstyle/core/parser",["xstyle/core/utils"],function(e){function t(){this.push.apply(this,arguments)}function r(e){this.value=e}function n(u,f,h){function d(f,h){function m(e){w=!1;var t=v.lastIndex;e.then(function(){w=!0,r&&(v.lastIndex=t,y())});var r=!0}function y(){function l(e){e&&"string"==typeof e&&A&&(e=A+e),I?I.push?"string"==typeof I[I.length-1]&&"string"==typeof e?I[I.length-1]+=e:e&&I.push(e):"string"==typeof I&&"string"==typeof e?I+=e:I=new t(I,e):I=e}for(w=!0;w;){var u=v.exec(f);if(!u)return;var y,N,I,k,C=u[5],A=u[1],q=u[2],O=u[3],L=u[4];switch(L=L&&c(L),q=q&&c(q),T?(O?(N=q,y=O.charAt(0),k="?"==O.charAt(1),O.indexOf("\n")>-1&&(L=O.slice(1))):L=q,I=L,T=!1):(L=O?q+O:q,l(L)),"{"!=C&&(E+=u[0]),C){case"'":case'"':var P="'"==C?i:s;P.lastIndex=v.lastIndex;var M=P.exec(f);M||x("unterminated string");var $=M[1];v.lastIndex=P.lastIndex,l(new r($)),E+=M[0];continue;case"\\":var _=P.lastIndex++;l(f.charAt(_));continue;case"(":case"{":case"[":var D,j=!1;if("{"==C){T=!0,":"==y&&O&&(q+=O),E=c((E+q).replace(/\s+/g," ").replace(/([\.#:])\S+|\w+/g,function(e,t){return t?e:e.toLowerCase()})),l(D=S.newRule(E)),"="==y&&(R=!1,I.creating=!0,L&&(j=!0)),":"!=y||S.root||(I.creating=!0);var V=null,B=b;if(u[6]){var F=h.cssRules||h.rules;(D.cssRule=V=F[u[6].slice(1)])&&(E=V.selectorText)}if(S.root&&R)for(var F=h.cssRules||h.rules;V=F[b++];)if(V.selectorText==E){D.cssRule=V;break}V||(D.ruleIndex=b=B,D.styleSheet=h),I.creating?(D.selector="."+("="==y?q.match(/[\w-]*$/g,"")[0]:"")+"-x-"+o++,D.creating=!0):D.selector=S.root?E:S.selector+" "+E,E=""}else{var U=L.match(/(.*?)([\w-]*)$/);l(D=S.newCall(U[2],I,S)),D.ref=S.getDefinition(U[2]),(I.calls||(I.calls=[])).push(D)}D.parent=S,j&&L.replace(/\s*([\w-]+)\s*$/g,function(t,r){var n=e.extend(D,r,x);n&&n.then&&m(n)}),S.currentName=N,S.currentSequence=I,S.assignmentOperator=y;var H;if("{"==C&&(H=D.selector.match(/[@:]\w+/))){H=H[0];var z=S.getDefinition(H);z&&z.selector&&z.selector(D)}g.push(S=D),S.operator=C,S.start=v.lastIndex,N=null,I=null;continue}if(I){var q="string"==typeof I?I:I[0];if(q.charAt&&"@"==q.charAt(0)){var W=q.match(/\w+/)[0];if("import"==W){var J=n.getStyleSheet((h.cssRules||h.imports)[b++],I,h),K=v.lastIndex;d(J.localSource,J),v.lastIndex=K}else if("xstyle"==W){if("start"==q.slice(8,13)){var D=S?S.newRule(""):X;D.root=S.root,D.parent=S,g.push(S=D)}else{var X=S||X;g.pop(),S=g[g.length-1]}v=S?p:/(@[\w\s])/g}}else if(y)try{var Y=S[":"==y?"setValue":"declareProperty"](N,I,k);Y&&Y.then&&m(Y)}catch(G){x(G)}}switch(C){case":":"="==y?(T=!0,y=":"):l(":");break;case"}":case")":case"]":a[S.operator]!=C&&x("Incorrect opening operator "+S.operator+" with closing operator "+C),N=null;var Q=f.slice(S.start,v.lastIndex-1);if(S.cssText=S.cssText?S.cssText+";"+Q:Q,"}"==C){if("}"==et){var Z=S.parent.selector;Z&&"@"==!Z.charAt(0)&&x("A nested rule must end with a semicolon")}if(S.root)x("Unmatched "+C);else{try{S.onRule(S.selector,S)}catch(G){x(G)}R=!0}E=""}if(")"==C&&!y){S.args=I.isSequence?I:[I];var Y=g[g.length-2].onCall(S);Y&&Y.then&&m(Y)}if(g.pop(),S=g[g.length-1],I=S.currentSequence,N=S.currentName,y=S.assignmentOperator,S.root&&"}"==C){if(y)try{S[":"==y?"setValue":"declareProperty"](N,I[1]||I,k)}catch(G){x(G)}T=!0,y=!1}break;case"":case void 0:return;case";":I=null,T=!0,R=!1,y=!1,E=""}var et=C}}function x(e){console.error(e.message||e,(h.href||"in-page stylesheet")+":"+f.slice(0,v.lastIndex).split("\n").length),e.stack&&console.error(e.stack)}f=f.replace(l,function(e){return e.replace(/[^\n]/g,"")});var S=u;v.lastIndex=0;var w,b=0,R=!0,E="",T=!0;y()}var p,v=p=/(\s*)((?:[^{\}\[\]\(\)\\'":=;]|\[(?:[^\]'"]|'(?:\\.|[^'])*'|"(?:\\.|[^"])*")\])*)([=:]\??\s*([^{\}\[\]\(\)\\'":;]*))?(?:([{\}\[\]\(\)\\'":;])(\/\d+)?|$)/g,g=[u];u.parse=d,d(f,h)}var i=/((?:\\.|[^'])*)'/g,s=/((?:\\.|[^"])*)"/g,l=/\/\*[\w\W]*?\*\//g,a={"{":"}","[":"]","(":")"},o=0,c="".trim?function(e){return e.trim()}:function(e){return e.replace(/^\s+|\s+$/g,"")},u=t.prototype=[];return u.toString=function(){return this.join("")},u.isSequence=!0,r.prototype.toString=function(){return'"'+this.value.replace(/["\\\n\r]/g,"\\$&")+'"'},n}),define("xstyle/main",["require","xstyle/core/parser","xstyle/core/base","xstyle/core/elemental","xstyle/core/generate"],function(require,parser,ruleModel,elemental,generate){"use strict";function search(e){for(var t=document.getElementsByTagName(e),r=0;r<t.length;r++)checkImports(t[r])}function checkImports(element,callback,fixedImports){function fixImports(){require(["xstyle/core/load-imports"],function(e){e(element,function(){checkImports(element,callback,!0)})})}function checkForInlinedExtensions(sheet){for(var cssRules=sheet.cssRules,i=0;i<cssRules.length;i++){var rule=cssRules[i];if(rule.selectorText&&"x-"==rule.selectorText.substring(0,2)&&(needsParsing=!0,/^'/.test(rule.style.content)))return parse(eval(rule.style.content),sheet,callback),!0}}var sheet=element.sheet||element.styleSheet||element,needsParsing=sheet.needsParsing,cssRules=sheet.rules||sheet.cssRules;if((sheet.href||sheet.imports&&sheet.imports.length)&&!fixedImports)return fixImports();if(!needsParsing)for(var i=0;i<cssRules.length;i++){var rule=cssRules[i];if(rule.href&&!fixedImports){if(!checkForInlinedExtensions(rule.styleSheet))return fixImports();return}}parse(sheet.localSource||(sheet.ownerNode||sheet.owningElement).innerHTML,sheet,callback)}function parse(e,t,r){function n(){0==--i&&r&&r(t)}t.addRule||(t.addRule=function(e,t,r){return this.insertRule(e+"{"+t+"}",r>=0?r:this.cssRules.length)}),t.deleteRule||(t.deleteRule=t.removeRule);{var i=1;(t.href||location.href).replace(/[^\/]+$/,"")}return ruleModel.css=e,parser(ruleModel,e,t),n(ruleModel),ruleModel}elemental.ready(function(){search("link"),search("style")}),parser.getStyleSheet=function(e){return e.styleSheet||e};var xstyle={process:checkImports,parse:parse,generate:generate,load:function(e,t,r,n){t(["xstyle/css"],function(i){i.load(e,t,r,n)})}};return xstyle});
//# sourceMappingURL=xstyle.min.js.map