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E,CAAA,CAAI,KAAG,CAAC;IAC7C,CAAC,CAAC;EACJ;AAAA,AACF;AAAA,AAnCA,KAAK,eAAe,AAAC,iCACb,EAAC,GAAE,CAAG,UAAS,AAAD,CAAG;AAAC,cASzB,WAAS,AAAC,EAAC,EATqC;EAAC,CAAC,CAAC,CAAC;AADrD,KAAK,eAAe,AAAC,gCACb,EAAC,GAAE,CAAG,UAAS,AAAD,CAAG;AAAC,YAaF,WAAU,GAbe;EAAC,CAAC,CAAC,CAAC;AADrD,KAAK,eAAe,AAAC,sDACb,EAAC,GAAE,CAAG,UAAS,AAAD,CAAG;AAAC,YAD1B,MAAK,KAAgB,WAArB,MAAK,KAAgB,UAC4B;EAAC,CAAC,CAAC,CAAC;AADrD,KAAK,eAAe,AAAC,uDACb,EAAC,GAAE,CAAG,UAAS,AAAD,CAAG;AAAC,YAD1B,MAAK,KAAgB,WAwBe,MAAK,IAxBzC,MAAK,KAAgB,UAC4B;EAAC,CAAC,CAAC,CAAC;AAoCrD,AAAI,EAAA,CAAA,SAAQ,EAAI,CAAA,aAAY,OAAO,AAAC,CAAC,sBAAqB,CAAC,CAAC;AAC5D,AAAI,EAAA,CAAA,YAAW,EAAI,CAAA,aAAY,OAAO,AAAC,CAAC,mDAAkD,CAAC,CAAC;AAC5F,AAAI,EAAA,CAAA,QAAO,EAAI,CAAA,aAAY,OAAO,AAAC,CAAC,OAAM,CAAC,CAAC;AAC5C","file":"angular2/src/render/dom/shadow_dom/style_url_resolver.es6","sourcesContent":["// Some of the code comes from WebComponents.JS\n// https://github.com/webcomponents/webcomponentsjs/blob/master/src/HTMLImports/path.js\n\nimport {Injectable} from 'angular2/src/di/annotations_impl';\nimport {RegExp, RegExpWrapper, StringWrapper} from 'angular2/src/facade/lang';\nimport {UrlResolver} from 'angular2/src/services/url_resolver';\n\n/**\n * Rewrites URLs by resolving '@import' and 'url()' URLs from the given base URL.\n */\n@Injectable()\nexport class StyleUrlResolver {\n  _resolver: UrlResolver;\n\n  constructor(resolver: UrlResolver) {\n    this._resolver = resolver;\n  }\n\n  resolveUrls(cssText: string, baseUrl: string) {\n    cssText = this._replaceUrls(cssText, _cssUrlRe, baseUrl);\n    cssText = this._replaceUrls(cssText, _cssImportRe, baseUrl);\n    return cssText;\n  }\n\n  _replaceUrls(cssText: string, re: RegExp, baseUrl: string) {\n    return StringWrapper.replaceAllMapped(cssText, re, (m) => {\n      var pre = m[1];\n      var url = StringWrapper.replaceAll(m[2], _quoteRe, '');\n      var post = m[3];\n\n      var resolvedUrl = this._resolver.resolve(baseUrl, url);\n\n      return pre + \"'\" + resolvedUrl + \"'\" + post;\n    });\n  }\n}\n\nvar _cssUrlRe = RegExpWrapper.create('(url\\\\()([^)]*)(\\\\))');\nvar _cssImportRe = RegExpWrapper.create('(@import[\\\\s]+(?!url\\\\())[\\'\"]([^\\'\"]*)[\\'\"](.*;)');\nvar _quoteRe = RegExpWrapper.create('[\\'\"]');\n"]}