text: var e=require("fs"),r=require("path"),t=require("fp-ts/lib/Task"),n=require("fp-ts/lib/TaskEither"),i=require("fp-ts/lib/pipeable"),a=require("fp-ts/lib/Apply"),u=require("fp-ts/lib/Array"),o=require("fp-ts/lib/Option"),c=require("fp-ts/lib/Record"),s=require("fp-ts/lib/Eq"),l=require("fp-ts/lib/Ord"),f=require("node-fetch"),p=require("md5"),m=require("fp-ts/lib/Semigroup"),d=require("fp-ts/lib/function"),g=require("imgix-url-params/dist/parameters.json"),h=require("camel-case");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v=y(e),b=y(r),x=y(f),I=y(p),S=y(g);function P(){return(P=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function T(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function U(e,r){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return T(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?T(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}var w=function(e){return e.schema.buildInterfaceType({name:"ImgixFixedImage",fields:{base64:"String!",src:"String!",srcSet:"String!",srcWebp:"String!",srcSetWebp:"String!",sizes:"String!",width:"Int!",height:"Int!"}})};function W(e,r,t){e||t.panic("Invariant failed: "+r)}var k,j=function(){},q=function(e,r){var t=new URL("https://"+r);return t.pathname=encodeURIComponent(e),t.toString()},A=function(e,r){return void 0===e&&(e=""),""+e+r},R=function(e,r,t){return i.pipe(function(e,r){return function(){return r.get(e).then(function(e){return o.fromNullable(e)})}}(e,r),n.rightTask,n.chain(o.fold(d.flow(t,n.chain(d.flow(function(e,r){return function(t){return function(){return r.set(e,t).then(function(){return t})}}}(e,r),function(e){return n.rightTask(e)}))),n.right)))},F=function(e){return n.tryCatch(function(){return x.default(e)},function(e){return new Error(String(e))})},O=(d.flow(F,n.chain(function(e){return n.rightTask(function(){return e.buffer()})}),n.chain(function(e){return n.right(e.toString("base64"))})),m.getObjectSemigroup()),N=function(e){return function(r){return r.join(e)}},E=function(e,r){return function(t){return n.tryCatch(function(){return Promise.resolve(e(t)).then(function(e){return null==e?Promise.reject("Resolved data is null or undefined"):r?r(e)?e:Promise.reject("Resolved data is invalid."):e})},function(e){return new Error(String(e))})}},L=[1,1.5,2],z=[.25,.5,1.5,2],C={w:100,blur:15,q:20},H=function(e,r){return function(t){return i.pipe(t,c.filterMap(function(e){return o.some(void 0===e?void 0:String(e))}),function(e){return function(r){var t,n,a,o=new URL(e),s=i.pipe(r,c.reduceWithIndex([],function(e,r,t){return void 0===t?u.cons(e,r):r})),l=i.pipe(r,c.filter(function(e){return void 0!==e})),f=(t=o.searchParams,n=new URLSearchParams(l),a=new URLSearchParams(t.toString()),n.forEach(function(e,r){null==e?a.delete(r):a.set(r,e)}),a);return f.forEach(function(e,r){s.includes(r)&&f.delete(r)}),o.search=f.toString(),o.toString()}}(e),function(e){return function(r){return i.pipe(e,o.fold(function(){return r},function(e){return i.pipe(r,function(e){var r=new URL(e);return r.searchParams.delete("s"),r.toString()},(t=function(e){return function(r){return i.pipe(new URL(r),function(r){return e+r.pathname+r.search},function(e){return I.default(e)})}}(e)(r),function(e){var r=new URL(e);return r.searchParams.append("s",String(t)),r.toString()}));var t}))}}(o.fromNullable(r)))}},M=function(e,r){return function(t){return i.pipe(O.concat(C,t),H(e,r))}},V=a.sequenceT(n.taskEither),B=function(e,r,t,a,u){return function(o){return i.pipe(V(E(r)(e),E(t)(e)),n.fold(function(){return i.pipe(o,function(e,r){return function(t){return R("gatsby-plugin-imgix-metadata-"+t,e,function(){return i.pipe({fm:"json"},H(t,r),function(e){return function(e){return i.pipe(e,F,n.chain(function(e){return n.rightTask(function(){return e.json()})}))}(e)})})}}(a,u),n.map(function(e){return[e.PixelWidth,e.PixelHeight]}))},n.right))}},_=function(e){var r=e.resolveUrl,a=void 0===r?function(e){return e.base64}:r,u=e.cache;return{type:"String!",resolve:function(e){return i.pipe(e,E(a),n.chain(function(e){return function(r){return R("gatsby-plugin-imgix-base64-url-"+r,e,function(){return i.pipe(r,F,n.chain(function(e){return i.pipe(n.rightTask(function(){return e.buffer()}),n.chain(function(e){return n.right(e.toString("base64"))}),n.chain(function(r){return n.right(function(e,r){return"data:"+e+";base64,"+r}(String(e.headers.get("content-type")),r))}))}))})}}(u)),n.fold(function(){return t.of(void 0)},t.of))()}}},D=function(e){var r;return e.schema.buildObjectType({name:null!=(r=e.name)?r:"ImgixFixedImage",fields:{base64:_({cache:e.cache}),src:{type:"String!"},srcSet:{type:"String!"},srcWebp:{type:"String!"},srcSetWebp:{type:"String!"},sizes:{type:"String!"},width:{type:"Int!"},height:{type:"Int!"}},interfaces:["ImgixFixedImage"]})},G=function(e){return e.schema.buildInterfaceType({name:"ImgixFluidImage",fields:{base64:"String!",src:"String!",srcSet:"String!",srcWebp:"String!",srcSetWebp:"String!",sizes:"String!",aspectRatio:"Float!"}})},Q=function(e){var r;return e.schema.buildObjectType({name:null!=(r=e.name)?r:"ImgixFluidImage",fields:{base64:_({cache:e.cache}),src:{type:"String!"},srcSet:{type:"String!"},srcWebp:{type:"String!"},srcSetWebp:{type:"String!"},sizes:{type:"String!"},aspectRatio:{type:"Float!"}},interfaces:["ImgixFluidImage"]})},$=function(e){var r;return e.schema.buildInputObjectType({name:null!=(r=e.name)?r:"ImgixUrlParamsInput",fields:Object.keys(S.default.parameters).reduce(function(e,r){var t=S.default.parameters[r],n=h.camelCase(r),i=Array.from(new Set(t.expects.map(function(e){return e.type}))),a=i.every(function(e){return"integer"===e||"unit_scalar"===e})?"Int":i.every(function(e){return"integer"===e||"unit_scalar"===e||"number"===e})?"Float":i.every(function(e){return"boolean"===e})?"Boolean":"String";e[n]={type:a,description:t.short_description+("."===t.short_description.slice(-1)?"":".")};var u=e[n];if("default"in t&&(u.description=u.description+" Default: `"+t.default+"`."),"url"in t&&(u.description=u.description+" [See docs]("+t.url+")."),"aliases"in t)for(var o,c=U(t.aliases);!(o=c()).done;)e[h.camelCase(o.value)]=P({},u,{description:"Alias for `"+n+"`."});return e},{})})},J=function(e){var r=e.type,a=e.paramsInputType,o=void 0===a?"ImgixUrlParamsInput":a,c=e.resolveUrl,s=e.resolveWidth,l=void 0===s?j:s,f=e.resolveHeight,p=void 0===f?j:f,m=e.secureUrlToken,d=e.cache,g=e.defaultImgixParams,h=e.defaultPlaceholderImgixParams;return{type:void 0===r?"ImgixFixedImage":r,args:{width:{type:"Int",defaultValue:400},height:{type:"Int"},imgixParams:{type:o,defaultValue:{}},placeholderImgixParams:{type:o,defaultValue:{}}},resolve:function(e,r){return i.pipe(e,E(c,function(e){return"string"==typeof e}),n.chain(function(t){return i.pipe(t,B(e,l,p,d,m),n.map(function(e){return function(e){var r,t,n=e.url,a=e.secureUrlToken,o=e.args,c=void 0===o?{}:o,s=e.sourceWidth/e.sourceHeight;null!=c.width&&null!=c.height?(r=c.width,t=c.height):null!=c.width?(r=c.width,t=Math.round(r/s)):null!=c.height?(r=Math.round(c.height*s),t=c.height):(r=400,t=Math.round(r/s));var l=M(n,a)(P({},c.imgixParams,c.placeholderImgixParams)),f=H(n,a)(P({},c.imgixParams,{w:r,h:t})),p=function(e,r){return function(t){return i.pipe(L,u.map(function(n){return i.pipe(O.concat(t,{dpr:n}),H(e,r),function(e){return e+" "+n+"x"})}),N(", "))}}(n,a)(P({},c.imgixParams,{w:r,h:t}));return{base64:l,width:r,height:t,src:f,srcWebp:f,srcSet:p,srcSetWebp:p}}({url:t,sourceWidth:e[0],sourceHeight:e[1],secureUrlToken:m,args:P({},r,{imgixParams:P({},g,r.imgixParams),placeholderImgixParams:P({},h,r.placeholderImgixParams)})})}))}),n.getOrElseW(function(){return t.of(void 0)}))()}}},K=function(e){var r=e.type,a=e.paramsInputType,o=void 0===a?"ImgixUrlParamsInput":a,c=e.resolveUrl,f=e.resolveWidth,p=void 0===f?j:f,m=e.resolveHeight,d=void 0===m?j:m,g=e.secureUrlToken,h=e.cache,y=e.defaultImgixParams,v=e.defaultPlaceholderImgixParams;return{type:void 0===r?"ImgixFluidImage":r,args:{maxWidth:{type:"Int",defaultValue:800},maxHeight:{type:"Int"},srcSetBreakpoints:{type:"[Int]"},imgixParams:{type:o,defaultValue:{}},placeholderImgixParams:{type:o,defaultValue:{}}},resolve:function(e,r){return i.pipe(e,E(c,function(e){return"string"==typeof e}),n.chain(function(t){return i.pipe(t,B(e,p,d,h,g),n.map(function(e){return function(e){var r,t,n=e.url,a=e.secureUrlToken,o=e.args,c=void 0===o?{}:o,f=e.sourceWidth/e.sourceHeight,p=null!=(r=c.maxWidth)?r:800,m=M(n,a)(P({},c.imgixParams,c.placeholderImgixParams)),d=H(n,a)(P({},c.imgixParams,{w:p,h:c.maxHeight})),g=function(e,r){return function(t){return function(n){var a=n.aspectRatio,o=n.maxWidth,c=n.srcSetBreakpoints,f=void 0===c?z.map(function(e){return o*e}):c;return i.pipe(u.cons(o,f),u.uniq(s.eqNumber),u.sort(l.ordNumber),u.map(function(n){return i.pipe(O.concat(t,{w:Math.round(n),h:Math.round(n/a)}),H(e,r),function(e){return e+" "+Math.round(n)+"w"})}),N(", "))}}}(n,a)(null!=(t=c.imgixParams)?t:{})({aspectRatio:f,maxWidth:p,srcSetBreakpoints:c.srcSetBreakpoints});return{base64:m,aspectRatio:f,src:d,srcWebp:d,srcSet:g,srcSetWebp:g,sizes:""}}({url:t,sourceWidth:e[0],sourceHeight:e[1],secureUrlToken:g,args:P({},r,{imgixParams:P({},y,r.imgixParams),placeholderImgixParams:P({},v,r.placeholderImgixParams)})})}))}),n.getOrElseW(function(){return t.of(void 0)}))()}}},X=function(e){var r=e.paramsInputType,a=e.resolveUrl,u=e.secureUrlToken,o=e.defaultImgixParams,c=void 0===o?{}:o;return{type:"String",args:{imgixParams:{type:void 0===r?"ImgixUrlParamsInput":r,defaultValue:{}}},resolve:function(e,r){return i.pipe(e,E(a),n.map(function(e){var t;return i.pipe(O.concat(c,null!=(t=r.imgixParams)?t:{}),H(e,u))}),n.fold(function(){return t.of(void 0)},t.of))()}}};!function(e){e.AmazonS3="s3",e.GoogleCloudStorange="gcs",e.MicrosoftAzure="azure",e.WebFolder="webFolder",e.WebProxy="webProxy"}(k||(k={})),exports.createSchemaCustomization=function(e,r){try{var t=e.cache,n=e.schema,i=e.reporter,a=e.actions.createTypes,u=r.secureUrlToken,o=r.sourceType,c=r.namespace,s=r.defaultImgixParams,l=r.defaultPlaceholderImgixParams,f=r.fields,p=void 0===f?[]:f;W(Array.isArray(p),"fields must be an array of field options",i),W(o!==k.WebProxy||Boolean(u),"a secure URL token must be provided if sourceType is webProxy",i);var m=A(c,"ImgixFixed"),d=A(c,"ImgixFluid"),g=A(c,"ImgixUrlParamsInput"),h=[D({name:(b={fixedTypeName:m,fluidTypeName:d,paramsInputTypeName:g,cache:t,schema:n}).fixedTypeName,cache:b.cache,schema:b.schema}),w({schema:b.schema}),Q({name:b.fluidTypeName,cache:b.cache,schema:b.schema}),G({schema:b.schema}),$({name:b.paramsInputTypeName,schema:b.schema})],y=n.buildObjectType({name:A(c,"ImgixImage"),fields:{url:X({paramsInputType:g,resolveUrl:function(e){return e},secureUrlToken:u,defaultImgixParams:s}),fixed:J({type:m,paramsInputType:g,resolveUrl:function(e){return e},secureUrlToken:u,defaultImgixParams:s,defaultPlaceholderImgixParams:l,cache:t}),fluid:K({type:d,paramsInputType:g,resolveUrl:function(e){return e},secureUrlToken:u,defaultImgixParams:s,defaultPlaceholderImgixParams:l,cache:t})}}),v=p.map(function(e){var r;return n.buildObjectType({name:e.nodeType+"Fields",fields:(r={},r[e.fieldName]={type:"getUrls"in e?"["+y.config.name+"]":y.config.name},r)})});return a(h),a(y),a(v),Promise.resolve()}catch(e){return Promise.reject(e)}var b},exports.onCreateNode=function(e,r){try{var t=function(){var t=e.node,n=e.reporter,i=e.actions.createNodeField,a=r.domain,u=r.secureUrlToken,o=r.sourceType,c=r.fields,s=void 0===c?[]:c;W(Array.isArray(s),"fields must be an array of field options",n);var l=s.filter(function(e){return e.nodeType===t.internal.type});if(l.length<1)return{v:Promise.resolve()};for(var f,p=U(l);!(f=p()).done;){var m=f.value,d=void 0;"getUrl"in m?W(null==(d=m.getUrl(t))||"string"==typeof d,"getUrl must return a URL string",n):"getUrls"in m&&(d=m.getUrls(t),W(Array.isArray(d),"getUrls must return an array of URLs",n)),d&&(o===k.WebProxy&&(W(void 0!==a,"an Imgix domain must be provided if sourceType is webProxy",n),W(void 0!==u,"a secure URL token must be provided if sourceType is webProxy",n),d=Array.isArray(d)?d.map(function(e){return q(e,a)}):q(d,a)),i({node:t,name:m.fieldName,value:d}))}return{v:Promise.resolve()}}();if("object"==typeof t)return t.v}catch(e){return Promise.reject(e)}},exports.onPreExtractQueries=function(e){var r=e.store.getState().program;v.default.copyFileSync(b.default.resolve(__dirname,"../fragments.js"),b.default.resolve(r.directory,".cache/fragments/gatsby-plugin-imgix-fragments.js"))};
  //# sourceMappingURL=gatsby-node.js.map
  