-
Notifications
You must be signed in to change notification settings - Fork 1
/
jsColorEngineWeb.js
2 lines (2 loc) · 169 KB
/
jsColorEngineWeb.js
1
2
/*! For license information please see jsColorEngineWeb.js.LICENSE.txt */
var jsColorEngine;(()=>{var t={231:t=>{"use strict";t.exports=require("fs")},155:(t,e,a)=>{let i=a(577);t.exports=class{constructor(){this.profiles=[],this.loadCount=0,this.errorCount=0}add(t,e,a){let r=new i;return this.profiles.push({profile:r,url:t,preload:!0===a,key:void 0===e?t:e}),r}async loadProfileIndex(t){let e=this.profiles[t].profile;if(e.loaded)return!0;if(!e.loadError)try{return await e.load(this.profiles[t].url)}catch(t){return!1}return!1}async loadAll(){for(let t of this.profiles)t.preload&&!t.profile.loaded&&await t.profile.loadPromise(t.url);this.loadCount=0,this.errorCount=0;let t=0;for(let e=0;e<this.profiles.length;e++)if(this.profiles[e].preload){t++;let a=this.profiles[e].profile;a.loadError?this.errorCount++:a.loaded&&this.loadCount++}console.log("Loaded "+this.loadCount+" profiles with "+this.errorCount+" errors out of "+t+" profiles")}async get(t){let e=this.findByKey(t);if(e.loaded)return e;if(await this.loadProfileIndex(t),e.loaded)return e;throw new Error("Unable to load the profile: "+t+" Error:"+e.lastError.text)}findByKey(t){for(let e=0;e<this.profiles.length;e++)if(this.profiles[e].key===t)return this.profiles[e].profile;return!1}findByURL(t){for(let e=0;e<this.profiles.length;e++)if(this.profiles[e].url===t)return this.profiles[e].profile;return!1}}},577:(t,e,a)=>{"use strict";const i=a(618),r=a(362),n=r.eIntent,s=r.eProfileType,o=a(153);t.exports=class{constructor(t,e){this.loaded=!1,this.loadError=!1,this.type=0,this.name="",this.header={},this.intent=0,this.tags=[],this.description="",this.tagDescription="",this.copyright="",this.technology="",this.viewingConditions="",this.characterizationTarget="",this.mediaWhitePoint=null,this.PCSEncode=2,this.PCSDecode=2,this.PCS8BitScale=0,this.version=0,this.pcs=!1,this.blackPoint=null,this.luminance=null,this.chromaticAdaptation=null,this.virutalProfileUsesD50AdaptedPrimaries=!0,this.unsuportedTags=[],this.Gray={kTRC:null,inv_kTRC:null},this.rgb={rTRC:null,rTRCInv:null,gTRC:null,gTRCInv:null,bTRC:null,bTRCInv:null,rXYZ:null,gXYZ:null,bXYZ:null},this.RGBMatrix={gamma:0,cRx:0,cRy:0,cGx:0,cGy:0,cBx:0,cBy:0},this.PCSWhitepoint=i.d50,this.outputChannels=0,this.lastError={err:0,text:"No Error"},this.B2D=[null,null,null,null],this.D2B=[null,null,null,null],this.A2B=[null,null,null],this.B2A=[null,null,null],this.absoluteAdaptationIn={Xa:1,Ya:1,Za:1},this.absoluteAdaptationOut={Xa:1,Ya:1,Za:1},t&&this.load(t,e)}loadPromise(t){return new Promise(((e,a)=>{this.load(t,(t=>{t?e(t):a(new Error("Profile failed to load"))}))}))}load(t,e){this.loaded=!1,this.loadError=!1,"[object Uint8Array]"===Object.prototype.toString.call(t)?this.loadBinary(t,e):"*"===t.substring(0,1)?this.loadVirtualProfile(t,e):"file:"===t.substring(0,5).toLowerCase()?this.loadFile(t,e):"data:"===t.substring(0,5).toLowerCase()?this.loadBase64(t,e):this.loadURL(t,e)}loadBinary(t,e,a){this.loaded=this.readICCProfile(t,a),this.loadError=!this.loaded,"function"==typeof e&&e(this)}loadFile(t,e){"file:"===t.substring(0,5).toLowerCase()&&(t=t.substring(5,t.length));var i=function(t){var e;if(window.cep&&window.cep.fs&&window.cep.fs.readFile){if((e=window.cep.fs.readFile(t,cep.encoding.Base64)).errorString=["NO_ERROR","ERR_UNKNOWN","ERR_INVALID_PARAMS","ERR_NOT_FOUND","ERR_CANT_READ","ERR_UNSUPPORTED_ENCODING","ERR_CANT_WRITE","ERR_OUT_OF_SPACE","ERR_NOT_FILE","ERR_NOT_DIRECTORY","ERR_FILE_EXISTS","UNABLE TO PARSE FILE","ERR_DIRECTORY_NOT_FOUND"][e.err]||"UNKNOWN ERROR "+e.err,0===e.err){for(var i=window.atob(e.data),r=new Uint8Array(i.length),n=0;n<i.length;n++)r[n]=i.charCodeAt(n);e.binary=r}return e}return a(231).readFileSync(t,{encoding:"base64"})}(t);0===i.err?(this.loaded=this.readICCProfile(i.binary),this.loadError=!this.loaded):(this.loadError=!0,this.lastError={err:i.err,text:i.errorString||i.err}),"function"==typeof e&&e(this)}loadBase64(t,e){"data:"===t.substring(0,5).toLowerCase()&&(t=t.substring(5,t.length));var a=function(t){let e=window.atob(t),a=e.length,i=new Uint8Array(a);for(let t=0;t<a;t++)i[t]=e.charCodeAt(t);return i}(t);this.loaded=this.readICCProfile(a),this.loadError=!this.loaded,"function"==typeof e&&e(this)}loadURL(t,e){var a=this;!function(t,e){var a=new XMLHttpRequest;a.open("GET",t,!0),a.responseType="arraybuffer",a.onload=function(){if(200===this.status){var t=a.response;if(t){var i=new Uint8Array(t);e(i,"")}else e(!1,"Invalid arrayBuffer")}else e(!1,"Server Status "+this.status)},a.timeout=function(){e(!1,"Timeout")},a.error=function(){e(!1,"XHR Error")},a.send()}(t,(function(t,i){a.lastError={err:""===i?0:-1,text:i},t?(a.loaded=a.readICCProfile(t),a.loadError=!a.loaded):(a.loaded=!1,a.loadError=!0),"function"==typeof e&&e(a)}))}loadVirtualProfile(t,e){"*"===t.substring(0,1)&&(t=t.substring(1,t.length)),this.loaded=this.createVirtualProfile(t),this.loadError=!this.loaded,"function"==typeof e&&e(this)}createVirtualProfile(t){var e,a,r,n;switch(this.outputChannels=3,this.version=4,this.pcs="XYZ",this.colorSpace="RGB",this.header={profileSize:0,cmmType:0,version:4,pClass:"mntr",space:"rgb",pcs:"XYZ",date:new Date,signature:"",platform:"",flags:0,attributes:0,intent:3,PCSilluminant:i.d50},String(t).replace(" ","").toLowerCase()){case"labd50":case"lab":return this.type=s.Lab,this.name=this.description="Lab D50 Profile",this.PCSWhitepoint=i.d50,this.mediaWhitePoint=i.d50,this.pcs="LAB",this.colorSpace="LAB",this.header={profileSize:0,cmmType:0,version:4,pClass:"abst",space:"Lab",pcs:"LAB",date:new Date,signature:"",platform:"",flags:0,attributes:0,intent:3,PCSilluminant:i.d50},!0;case"labd65":return this.type=s.Lab,this.name=this.description="Lab D65 Profile",this.PCSWhitepoint=i.d50,this.mediaWhitePoint=i.d65,this.pcs="LAB",this.colorSpace="LAB",this.header={profileSize:0,cmmType:0,version:4,pClass:"abst",space:"Lab",pcs:"LAB",date:new Date,signature:"",platform:"",flags:0,attributes:0,intent:3,PCSilluminant:i.d50},!0;case"srgb":return this.virutalProfileUsesD50AdaptedPrimaries?(e=i.xyY(.648431,.330856,.222491),a=i.xyY(.321152,.597871,.716888),r=i.xyY(.155886,.066044,.060621),n=i.d50):(e=i.xyY(.64,.33,.212656),a=i.xyY(.3,.6,.715158),r=i.xyY(.15,.06,.072186),n=i.d65),this.name="sRGB",this.description="RGB is a standard RGB color space created cooperatively by HP and Microsoft in 1996 for use on monitors, printers and the Internet<br><br>Note that sRGB's small Gamut is not suitable for graphic production.<br><br>Encompasses roughly 35% of the visible colors specified by the Lab color space",this.mediaWhitePoint=n,o(this,2.2,e,a,r,!0),!0;case"adobe1998":case"adobe":case"adobergb":case"adobe1998rgb":return this.virutalProfileUsesD50AdaptedPrimaries?(e=i.xyY(.648431,.330856,.311114),a=i.xyY(.230154,.701572,.625662),r=i.xyY(.155886,.066044,.063224),n=i.d50):(e=i.xyY(.64,.33,.297361),a=i.xyY(.21,.71,.627355),r=i.xyY(.15,.06,.075285),n=i.d65),this.name="Adobe RGB (1998)",this.description="Developed by Adobe Systems, Inc. in 1998. It was designed to encompass most of the colors achievable on CMYK color printers, but by using RGB primary colors on a device such as a computer display. The Adobe RGB (1998) improves upon the gamut of the sRGB color space, primarily in cyan-green hues<br>Encompasses roughly 50% of the visible colors specified by the Lab color space",this.mediaWhitePoint=n,o(this,2.2,e,a,r,!1),!0;case"apple":case"applergb":return this.virutalProfileUsesD50AdaptedPrimaries?(e=i.xyY(.634756,.340596,.255166),a=i.xyY(.301775,.597511,.672578),r=i.xyY(.162897,.079001,.072256),n=i.d50):(e=i.xyY(.625,.34,.244634),a=i.xyY(.28,.595,.672034),r=i.xyY(.155,.07,.083332),n=i.d65),this.name="Apple RGB",this.description='Apple RGB is based on the classic Apple 13" RGB monitor. Because of its popularity and similar Trinitronbased monitors that followed, many key publishing applications, including Adobe Photoshop and Illustrator, used it as the default RGB space in the past.<br>Encompasses roughly 33.5% of the visible colors specified by the Lab color space',this.mediaWhitePoint=n,o(this,2.2,e,a,r,!1),!0;case"colormatchrgb":case"colormatch":return e=i.xyY(.63,.34,.274884),a=i.xyY(.295,.605,.658132),r=i.xyY(.15,.075,.066985),this.name="ColorMatch RGB",this.description="An RGB profile with a D50 whitepoint used for prepress<br>Encompasses roughly 35.2% of the visible colors specified by the Lab color space",this.mediaWhitePoint=i.d50,o(this,1.8,e,a,r,!1),!0;case"prophoto":case"prophotorgb":return e=i.xyY(.7347,.2653,.28804),a=i.xyY(.1596,.8404,.711874),r=i.xyY(.0366,1e-4,86e-6),this.name="ProPhoto RGB",this.description="The ProPhoto RGB color space, also known as ROMM RGB (Reference Output Medium Metric), is an output referred RGB color space developed by Kodak. It offers an especially large gamut designed for use with photographic output in mind.<br>Encompasses roughly 91.2% of the visible colors specified by the Lab color space",this.mediaWhitePoint=i.d50,o(this,1.8,e,a,r,!1),!0;default:return this.lastError={err:100,text:"Unsupported Virtual Profile ["+t+"]"},!1}function o(t,e,a,r,n,o){t.type=s.RGBMatrix,t.PCSWhitepoint=i.d50,t.rgb.rXYZ=i.xyY2XYZ(a),t.rgb.gXYZ=i.xyY2XYZ(r),t.rgb.bXYZ=i.xyY2XYZ(n),t.RGBMatrix={gamma:e,issRGB:!0===o,cRx:a.x,cRy:a.y,cGx:r.x,cGy:r.y,cBx:n.x,cBy:n.y};var h={m00:t.RGBMatrix.cRx/t.RGBMatrix.cRy,m01:t.RGBMatrix.cGx/t.RGBMatrix.cGy,m02:t.RGBMatrix.cBx/t.RGBMatrix.cBy,m10:1,m11:1,m12:1,m20:(1-t.RGBMatrix.cRx-t.RGBMatrix.cRy)/t.RGBMatrix.cRy,m21:(1-t.RGBMatrix.cGx-t.RGBMatrix.cGy)/t.RGBMatrix.cGy,m22:(1-t.RGBMatrix.cBx-t.RGBMatrix.cBy)/t.RGBMatrix.cBy},u=i.invertMatrix(h),c=t.mediaWhitePoint.X*u.m00+t.mediaWhitePoint.Y*u.m01+t.mediaWhitePoint.Z*u.m02,l=t.mediaWhitePoint.X*u.m10+t.mediaWhitePoint.Y*u.m11+t.mediaWhitePoint.Z*u.m12,p=t.mediaWhitePoint.X*u.m20+t.mediaWhitePoint.Y*u.m21+t.mediaWhitePoint.Z*u.m22;t.RGBMatrix.matrixV4={m00:c*h.m00,m01:l*h.m01,m02:p*h.m02,m10:c*h.m10,m11:l*h.m11,m12:p*h.m12,m20:c*h.m20,m21:l*h.m21,m22:p*h.m22},t.RGBMatrix.matrixInv=i.invertMatrix(t.RGBMatrix.matrixV4),t.RGBMatrix.XYZMatrix={m00:t.rgb.rXYZ.X,m01:t.rgb.gXYZ.X,m02:t.rgb.bXYZ.X,m10:t.rgb.rXYZ.Y,m11:t.rgb.gXYZ.Y,m12:t.rgb.bXYZ.Y,m20:t.rgb.rXYZ.Z,m21:t.rgb.gXYZ.Z,m22:t.rgb.bXYZ.Z},t.RGBMatrix.XYZMatrixInv=i.invertMatrix(t.RGBMatrix.XYZMatrix)}}readICCProfile(t,e){var a=this,r=0;return(!e||-1!==(r=s(t,0,[73,67,67,95,80,82,79,70,73,76,69])))&&(-1!==s(t,r,[97,99,115,112])&&(!0===this.decodeFile(t)?(this.PCSWhitepoint=i.getWhitePointFromIlluminant(this.header.PCSilluminant),this.absoluteAdaptationIn={Xa:this.mediaWhitePoint.X/this.header.PCSilluminant.X,Ya:this.mediaWhitePoint.Y/this.header.PCSilluminant.Y,Za:this.mediaWhitePoint.Z/this.header.PCSilluminant.Z},this.absoluteAdaptationOut={Xa:this.header.PCSilluminant.X/this.mediaWhitePoint.X,Ya:this.header.PCSilluminant.Y/this.mediaWhitePoint.Y,Za:this.header.PCSilluminant.Z/this.mediaWhitePoint.Z},"RGB "===a.header.space&&null===a.A2B[n.relative]&&null===a.B2A[n.relative]&&a.rgb.gXYZ&&a.rgb.rXYZ&&a.rgb.bXYZ&&a.rgb.rTRC&&a.rgb.gTRC&&a.rgb.bTRC&&this.createRGBMatrix(),this.loaded=!0,!0):(this.loaded=!1,!1)));function s(t,e,a){for(var i=e;i<t.length-a.length;i++){for(var r=!0,n=0;n<a.length;n++)if(t[i+n]!==a[n]){r=!1;break}if(r)return i}return-1}}createRGBMatrix(){this.PCSWhitepoint=this.header.PCSilluminant;var t=i.d50,e=i.XYZ2xyY(i.adaptation(this.rgb.rXYZ,t,this.mediaWhitePoint),this.PCSWhitepoint),a=i.XYZ2xyY(i.adaptation(this.rgb.gXYZ,t,this.mediaWhitePoint),this.PCSWhitepoint),r=i.XYZ2xyY(i.adaptation(this.rgb.bXYZ,t,this.mediaWhitePoint),this.PCSWhitepoint);this.type=s.RGBMatrix,this.RGBMatrix={gamma:this.rgb.rTRC.gamma,issRGB:"sRGB"===this.name.substr(0,4),cRx:e.x,cRy:e.y,cGx:a.x,cGy:a.y,cBx:r.x,cBy:r.y},i.computeMatrix(this)}decodeHeader(t){var e={};return e.profileSize=o.uint32(t,0),e.cmmType=o.chars(t,4,4),e.version=o.array(t,8,4),e.pClass=o.chars(t,12,4),e.space=o.chars(t,16,4),e.pcs=o.chars(t,20,4),e.date=o.array(t,24,12),e.signature=o.chars(t,36,4),e.platform=o.chars(t,40,4),e.flags=o.array(t,44,4),e.attributes=o.array(t,56,8),e.intent=o.uint32(t,64),e.PCSilluminant=o.XYZNumber(t,68),e}decodeTags(t){for(var e=[],a=o.uint32(t,128),i=132,r=0;r<a;r++)e.push({sig:o.chars(t,i,4),offset:o.uint32(t,i+4),length:o.uint32(t,i+8)}),i+=12;return e}decodeFile(t){if(this.header=this.decodeHeader(t),this.unsuportedTags=[],this.version=this.header.version[0],this.pcs=this.header.pcs.trim().toUpperCase(),this.colorSpace=this.header.space.trim().toUpperCase(),"LAB"!==this.pcs&&"XYZ"!==this.pcs)return this.lastError={err:100,text:"Unsupported PCS ["+this.pcs+"]"},!1;if(2!==this.version&&4!==this.version)return this.lastError={err:101,text:"Unsupported Profile Version ["+this.version+"]"},!1;switch(this.header.space){case"GRAY":this.outputChannels=1,this.type=s.Gray;break;case"2CLR":this.outputChannels=2,this.type=s.Duo;break;case"3CLR":case"CMY ":case"RGB ":this.outputChannels=3,this.type=s.RGBLut;break;case"4CLR":case"CMYK":this.outputChannels=4,this.type=s.CMYK;break;default:return this.lastError={err:110,text:"Unsupported Profile Colorspace ["+this.header.space+"]"},!1}this.tags=this.decodeTags(t);for(var e=0;e<this.tags.length;e++){var a=this.tags[e];switch(a.sig){case"rXYZ":this.rgb.rXYZ=o.XYZType(t,a.offset);break;case"gXYZ":this.rgb.gXYZ=o.XYZType(t,a.offset);break;case"bXYZ":this.rgb.bXYZ=o.XYZType(t,a.offset);break;case"rTRC":this.rgb.rTRC=o.curve(t,a.offset),this.rgb.rTRCInv=o.curve(t,a.offset,!0);break;case"gTRC":this.rgb.gTRC=o.curve(t,a.offset),this.rgb.gTRCInv=o.curve(t,a.offset,!0);break;case"bTRC":this.rgb.bTRC=o.curve(t,a.offset),this.rgb.bTRCInv=o.curve(t,a.offset,!0);break;case"kTRC":this.Gray.kTRC=o.curve(t,a.offset),this.Gray.inv_kTRC=o.curve(t,a.offset,!0);break;case"wtpt":this.mediaWhitePoint=o.XYZType(t,a.offset);break;case"A2B0":this.A2B[0]=o.lut(t,a.offset);break;case"A2B1":this.A2B[1]=o.lut(t,a.offset);break;case"A2B2":this.A2B[2]=o.lut(t,a.offset);break;case"B2A0":this.B2A[0]=o.lut(t,a.offset);break;case"B2A1":this.B2A[1]=o.lut(t,a.offset);break;case"B2A2":this.B2A[2]=o.lut(t,a.offset);break;case"desc":this.name=o.text(t,a.offset).text;break;case"cprt":this.copyright=o.text(t,a.offset).text;break;case"tech":this.technology=this.techSignatureString(o.chars(t,a.offset,4));break;case"vued":this.viewingConditions=o.text(t,a.offset);break;case"targ":this.characterizationTarget=o.text(t,a.offset);break;case"bkpt":this.blackPoint=o.XYZType(t,a.offset);break;case"lumi":this.luminance=o.XYZType(t,a.offset);break;case"chad":this.chromaticAdaptation=o.s15Array(t,a.offset,a.length);break;case"view":this.viewingConditions=o.viewingConditions(t,a.offset);break;case"gamt":case"calt":case"chrm":case"cicp":case"clro":case"clrt":case"ciis":case"dmnd":case"dmdd":case"meas":case"meta":case"ncl2":case"resp":case"rig0":case"pre0":case"pre1":case"pre2":case"pseq":case"psid":case"rig2":break;case"B2D0":this.B2D[0]=o.multiProcessElement(t,a.offset);break;case"B2D1":this.B2D[1]=o.multiProcessElement(t,a.offset);break;case"B2D2":this.B2D[2]=o.multiProcessElement(t,a.offset);break;case"B2D3":this.B2D[3]=o.multiProcessElement(t,a.offset);break;case"D2B0":this.D2B[0]=o.multiProcessElement(t,a.offset);break;case"D2B1":this.D2B[1]=o.multiProcessElement(t,a.offset);break;case"D2B2":this.D2B[2]=o.multiProcessElement(t,a.offset);break;case"D2B3":this.D2B[3]=o.multiProcessElement(t,a.offset);break;case"Info":this.info=o.text(t,a.offset);break;default:console.log("Unsupported Tag ["+a.sig+"]"),this.unsuportedTags.push(a)}}return console.log(this),null===this.B2A[n.perceptual]&&(this.B2A[n.perceptual]=this.B2A[n.relative]),null===this.B2A[n.saturation]&&(this.B2A[n.saturation]=this.B2A[n.perceptual]),null===this.A2B[n.perceptual]&&(this.A2B[n.perceptual]=this.A2B[n.relative]),null===this.A2B[n.saturation]&&(this.A2B[n.saturation]=this.A2B[n.perceptual]),"prtr"===this.header.pClass||"mntr"===this.header.pClass||"scnr"===this.header.pClass||"spac"===this.header.pClass||"abst"===this.header.pClass||(this.lastError={err:100,text:"profile class not "+this.header.pClass+" supported"},!1)}techSignatureString(t){for(var e=[{desc:"Film Scanner",sig:"fscn"},{desc:"Digital Camera",sig:"dcam"},{desc:"Reflective Scanner",sig:"rscn"},{desc:"Ink Jet Printer",sig:"ijet"},{desc:"Thermal Wax Printer",sig:"twax"},{desc:"Electrophotographic Printer",sig:"epho"},{desc:"Electrostatic Printer",sig:"esta"},{desc:"Dye Sublimation Printer",sig:"dsub"},{desc:"Photographic Paper Printer",sig:"rpho"},{desc:"Film Writer",sig:"fprn"},{desc:"Video Monitor",sig:"vidm"},{desc:"Video Camera",sig:"vidc"},{desc:"Projection Television",sig:"pjtv"},{desc:"Cathode Ray Tube Display",sig:"CRT "},{desc:"Passive Matrix Display",sig:"PMD "},{desc:"Active Matrix Display",sig:"AMD "},{desc:"Photo CD",sig:"KPCD"},{desc:"PhotoImageSetter",sig:"imgs"},{desc:"Gravure",sig:"grav"},{desc:"Offset Lithography",sig:"offs"},{desc:"Silkscreen",sig:"silk"},{desc:"Flexography",sig:"flex"}],a=0;a<e.length;a++)if(e[a].sig===t)return e[a].desc;return"<Unknown Technology Signature>"}}},706:(t,e,a)=>{"use strict";var i=a(618),r=[{name:"A",description:"# CIE standard Illuminant A, a typical tungsten-filament light with relative spectral power distribution of 2856K, at 1nm resolution",startnm:300,endnm:830,step:1,range:1e3,temp:2856.1,whitePoint:i.a,data:[.930483,.967643,1.00597,1.04549,1.08623,1.12821,1.17147,1.21602,1.26188,1.3091,1.35769,1.40768,1.4591,1.51198,1.56633,1.62219,1.67959,1.73855,1.7991,1.86127,1.92508,1.99057,2.05776,2.12667,2.19734,2.2698,2.34406,2.42017,2.49814,2.57801,2.65981,2.74355,2.82928,2.91701,3.00678,3.09861,3.19253,3.28857,3.38676,3.48712,3.58968,3.69447,3.80152,3.91085,4.0225,4.13648,4.25282,4.37156,4.49272,4.61631,4.74238,4.87095,5.00204,5.13568,5.27189,5.4107,5.55213,5.69622,5.84298,5.99244,6.14462,6.29955,6.45724,6.61774,6.78105,6.9472,7.11621,7.28811,7.46292,7.64066,7.82135,8.00501,8.19167,8.38134,8.57404,8.7698,8.96864,9.17056,9.37561,9.58378,9.7951,10.0096,10.2273,10.4481,10.6722,10.8996,11.1302,11.364,11.6012,11.8416,12.0853,12.3324,12.5828,12.8366,13.0938,13.3543,13.6182,13.8855,14.1563,14.4304,14.708,14.9891,15.2736,15.5616,15.853,16.148,16.4464,16.7484,17.0538,17.3628,17.6753,17.9913,18.3108,18.6339,18.9605,19.2907,19.6244,19.9617,20.3026,20.647,20.995,21.3465,21.7016,22.0603,22.4225,22.7883,23.1577,23.5307,23.9072,24.2873,24.6709,25.0581,25.4489,25.8432,26.2411,26.6425,27.0475,27.456,27.8681,28.2836,28.7027,29.1253,29.5515,29.9811,30.4142,30.8508,31.2909,31.7345,32.1815,32.632,33.0859,33.5432,34.004,34.4682,34.9358,35.4068,35.8811,36.3588,36.8399,37.3243,37.8121,38.3031,38.7975,39.2951,39.796,40.3002,40.8076,41.3182,41.832,42.3491,42.8693,43.3926,43.9192,44.4488,44.9816,45.5174,46.0563,46.5983,47.1433,47.6913,48.2423,48.7963,49.3533,49.9132,50.476,51.0418,51.6104,52.1818,52.7561,53.3332,53.9132,54.4958,55.0813,55.6694,56.2603,56.8539,57.4501,58.0489,58.6504,59.2545,59.8611,60.4703,61.082,61.6962,62.3128,62.932,63.5535,64.1775,64.8038,65.4325,66.0635,66.6968,67.3324,67.9702,68.6102,69.2525,69.8969,70.5435,71.1922,71.843,72.4959,73.1508,73.8077,74.4666,75.1275,75.7903,76.4551,77.1217,77.7902,78.4605,79.1326,79.8065,80.4821,81.1595,81.8386,82.5193,83.2017,83.8856,84.5712,85.2584,85.947,86.6372,87.3288,88.0219,88.7165,89.4124,90.1097,90.8083,91.5082,92.2095,92.912,93.6157,94.3206,95.0267,95.7339,96.4423,97.1518,97.8623,98.5739,99.2864,100,100.715,101.43,102.146,102.864,103.582,104.301,105.02,105.741,106.462,107.184,107.906,108.63,109.354,110.078,110.803,111.529,112.255,112.982,113.709,114.436,115.164,115.893,116.622,117.351,118.08,118.81,119.54,120.27,121.001,121.731,122.462,123.193,123.924,124.655,125.386,126.118,126.849,127.58,128.312,129.043,129.774,130.505,131.236,131.966,132.697,133.427,134.157,134.887,135.617,136.346,137.075,137.804,138.532,139.26,139.988,140.715,141.441,142.167,142.893,143.618,144.343,145.067,145.79,146.513,147.235,147.957,148.678,149.398,150.117,150.836,151.554,152.271,152.988,153.704,154.418,155.132,155.845,156.558,157.269,157.979,158.689,159.397,160.104,160.811,161.516,162.221,162.924,163.626,164.327,165.028,165.726,166.424,167.121,167.816,168.51,169.203,169.895,170.586,171.275,171.963,172.65,173.335,174.019,174.702,175.383,176.063,176.741,177.419,178.094,178.769,179.441,180.113,180.783,181.451,182.118,182.783,183.447,184.109,184.77,185.429,186.087,186.743,187.397,188.05,188.701,189.35,189.998,190.644,191.288,191.931,192.572,193.211,193.849,194.484,195.118,195.75,196.381,197.009,197.636,198.261,198.884,199.506,200.125,200.743,201.359,201.972,202.584,203.195,203.803,204.409,205.013,205.616,206.216,206.815,207.411,208.006,208.599,209.189,209.778,210.365,210.949,211.532,212.112,212.691,213.268,213.842,214.415,214.985,215.553,216.12,216.684,217.246,217.806,218.364,218.92,219.473,220.025,220.574,221.122,221.667,222.21,222.751,223.29,223.826,224.361,224.893,225.423,225.951,226.477,227,227.522,228.041,228.558,229.073,229.585,230.096,230.604,231.11,231.614,232.115,232.615,233.112,233.606,234.099,234.589,235.078,235.564,236.047,236.529,237.008,237.485,237.959,238.432,238.902,239.37,239.836,240.299,240.76,241.219,241.675,242.13,242.582,243.031,243.479,243.924,244.367,244.808,245.246,245.682,246.116,246.548,246.977,247.404,247.829,248.251,248.671,249.089,249.505,249.918,250.329,250.738,251.144,251.548,251.95,252.35,252.747,253.142,253.535,253.925,254.314,254.7,255.083,255.465,255.844,256.221,256.595,256.968,257.338,257.706,258.071,258.434,258.795,259.154,259.511,259.865,260.217,260.567,260.914,261.259,261.602]},{name:"C",description:"CIE deprecated standard Illuminant C, approximately 6774K, at 5nm resolution",startnm:380,endnm:780,step:5,range:1e3,temp:6769.2,whitePoint:i.c,data:[33,39.92,47.4,55.17,63.3,71.81,80.6,89.53,98.1,105.8,112.4,117.75,121.5,123.45,124,123.6,123.1,123.3,123.8,124.09,123.9,122.92,120.7,116.9,112.1,106.98,102.3,98.81,96.9,96.78,98,99.94,102.1,103.95,105.2,105.67,105.3,104.11,102.3,100.15,97.8,95.43,93.2,91.22,89.7,88.83,88.4,88.19,88.1,88.06,88,87.86,87.8,87.99,88.2,88.2,87.9,87.22,86.3,85.3,84,82.21,80.2,78.24,76.3,74.36,72.4,70.4,68.3,66.3,64.4,62.8,61.5,60.2,59.2,58.5,58.1,58,58.2,58.5,59.1]},{name:"D50",description:"CIE standard D50 illuminator, approximating light at the horizon at 5nm resolution",isDefault:!0,startnm:380,endnm:780,step:5,range:1e3,temp:5e3,whitePoint:i.d50,data:[24.5,27.2,29.8,39.6,49.3,52.9,56.5,58.3,60,58.9,57.8,66.3,74.8,81,87.2,88.9,90.6,91,91.4,93.3,95.2,93.6,92,93.9,95.7,96.2,96.6,96.9,97.1,99.6,102.1,101.5,100.8,101.6,102.3,101.2,100,98.9,97.7,98.3,98.9,96.2,93.5,95.6,97.7,98.5,99.3,99.2,99,97.4,95.7,97.3,98.8,97.3,95.7,97,98.2,100.6,103,101.1,99.1,93.3,87.4,89.5,91.6,92.3,92.9,84.9,76.8,81.7,86.6,89.6,92.6,85.4,78.2,68,57.7,70.3,82.9,80.6,78.3]},{name:"D55",description:"CIE standard Illuminant D55, mid-morning/mid-afternoon daylight, at 5nm resolution",startnm:380,endnm:780,step:5,range:1e3,temp:5500,whitePoint:i.d55,data:[32.58,35.34,38.09,49.52,60.95,64.75,68.55,70.07,71.58,69.75,67.91,76.76,85.61,91.8,97.99,99.23,100.46,100.19,99.91,101.33,102.74,100.41,98.08,99.38,100.68,100.69,100.7,100.34,99.99,102.1,104.21,103.16,102.1,102.53,102.97,101.48,100,98.61,97.22,97.48,97.75,94.59,91.43,92.93,94.42,94.78,95.14,94.68,94.22,92.33,90.45,91.39,92.33,90.59,88.85,89.59,90.32,92.13,93.95,91.95,89.96,84.82,79.68,81.26,82.84,83.84,84.84,77.54,70.24,74.77,79.3,82.15,84.99,78.44,71.88,62.34,52.79,64.36,75.93,73.87,71.82]},{name:"D65",description:"CIE standard Illuminant D65, at 5nm resolution",startnm:300,endnm:830,step:5,range:1e3,temp:6500,whitePoint:i.d65,data:[.0341,1.6643,3.2945,11.7652,20.236,28.6447,37.0535,38.5011,39.9488,42.4302,44.9117,45.775,46.6383,49.3637,52.0891,51.0323,49.9755,52.3118,54.6482,68.7015,82.7549,87.1204,91.486,92.4589,93.4318,90.057,86.6823,95.7736,104.865,110.936,117.008,117.41,117.812,116.336,114.861,115.392,115.923,112.367,108.811,109.082,109.354,108.578,107.802,106.296,104.79,106.239,107.689,106.047,104.405,104.225,104.046,102.023,100,98.1671,96.3342,96.0611,95.788,92.2368,88.6856,89.3459,90.0062,89.8026,89.5991,88.6489,87.6987,85.4936,83.2886,83.4939,83.6992,81.863,80.0268,80.1207,80.2146,81.2462,82.2778,80.281,78.2842,74.0027,69.7213,70.6652,71.6091,72.979,74.349,67.9765,61.604,65.7448,69.8856,72.4863,75.087,69.3398,63.5927,55.0054,46.4182,56.6118,66.8054,65.0941,63.3828,63.8434,64.304,61.8779,59.4519,55.7054,51.959,54.6998,57.4406,58.8765,60.3125]}],n=[{name:"2",description:"CIE 1931 standard 2° observer tristimulus response values",isDefault:!0,startnm:360,endnm:830,step:1,range:1e3,X:[1299e-7,1458e-7,1638e-7,184e-6,2067e-7,2321e-7,2607e-7,2931e-7,3294e-7,3699e-7,4149e-7,4642e-7,519e-6,5819e-7,6552e-7,7416e-7,845e-6,9645e-7,.0010949,.0012312,.001368,.0015021,.0016423,.0018024,.0019958,.002236,.0025354,.0028926,.0033008,.0037532,.004243,.0047624,.00533,.0059787,.0067411,.00765,.0087514,.0100289,.0114217,.012869,.01431,.0157044,.0171474,.0187812,.020748,.02319,.0262074,.0297825,.0338809,.0384682,.04351,.0489956,.0550226,.0617188,.069212,.07763,.0869581,.0971767,.1084063,.1207672,.13438,.1493582,.1653957,.1819831,.198611,.21477,.2301868,.2448797,.2587773,.2718079,.2839,.2949438,.3048965,.3137873,.3216454,.3285,.3343513,.3392101,.3431213,.3461296,.34828,.3495999,.3501474,.350013,.349287,.34806,.3463733,.3442624,.3418088,.3390941,.3362,.3331977,.3300411,.3266357,.3228868,.3187,.3140251,.308884,.3032904,.2972579,.2908,.2839701,.2767214,.2689178,.2604227,.2511,.2408475,.2298512,.2184072,.2068115,.19536,.1842136,.1733273,.1626881,.1522833,.1421,.1321786,.1225696,.1132752,.1042979,.09564,.0872996,.079308,.0717178,.064581,.05795,.0518621,.0462815,.0411509,.0364128,.03201,.0279172,.0241444,.020687,.0175404,.0147,.0121618,.00992,.0079672,.0062963,.0049,.0037772,.0029453,.0024249,.0022363,.0024,.0029255,.0038366,.0051748,.0069821,.0093,.0121495,.0155359,.0194775,.0239928,.0291,.0348149,.0411202,.047985,.0553786,.06327,.071635,.0804622,.08974,.0994565,.1096,.1201674,.1311145,.1423679,.1538542,.1655,.1772571,.18914,.2011694,.2133658,.2257499,.2383209,.2510668,.2639922,.2771017,.2904,.3038912,.3175726,.3314384,.3454828,.3597,.3740839,.3886396,.4033784,.4183115,.4334499,.4487953,.464336,.480064,.4959713,.5120501,.5282959,.5446916,.5612094,.5778215,.5945,.6112209,.6279758,.6447602,.6615697,.6784,.6952392,.7120586,.7288284,.7455188,.7621,.7785432,.7948256,.8109264,.8268248,.8425,.8579325,.8730816,.8878944,.9023181,.9163,.9297995,.9427984,.9552776,.9672179,.9786,.9893856,.9995488,1.0090892,1.0180064,1.0263,1.0339827,1.040986,1.047188,1.0524667,1.0567,1.0597944,1.0617992,1.0628068,1.0629096,1.0622,1.0607352,1.0584436,1.0552244,1.0509768,1.0456,1.0390369,1.0313608,1.0226662,1.0130477,1.0026,.9913675,.9793314,.9664916,.9528479,.9384,.923194,.907244,.890502,.87292,.8544499,.835084,.814946,.794186,.772954,.7514,.7295836,.7075888,.6856022,.6638104,.6424,.6215149,.6011138,.5811052,.5613977,.5419,.5225995,.5035464,.4847436,.4661939,.4479,.4298613,.412098,.394644,.3775333,.3608,.3444563,.3285168,.3130192,.2980011,.2835,.2695448,.2561184,.2431896,.2307272,.2187,.2070971,.1959232,.1851708,.1748323,.1649,.1553667,.14623,.13749,.1291467,.1212,.1136397,.106465,.0996904,.0933306,.0874,.081901,.0768043,.0720771,.0676866,.0636,.0598069,.0562822,.052971,.0498186,.04677,.0437841,.0408754,.0380726,.0354046,.0329,.0305642,.0283806,.0263448,.0244528,.0227,.0210843,.0195999,.0182373,.0169872,.01584,.0147906,.0138313,.0129487,.0121292,.0113592,.0106294,.0099388,.0092884,.0086789,.0081109,.0075824,.0070887,.0066273,.0061954,.0057903,.0054098,.0050526,.0047175,.0044035,.0041095,.0038339,.0035757,.0033343,.0031091,.0028993,.0027043,.002523,.0023542,.0021966,.0020492,.001911,.0017814,.0016601,.0015465,.00144,.00134,.0012463,.0011585,.0010764,9999e-7,9287e-7,8624e-7,8008e-7,7434e-7,6901e-7,6405e-7,5945e-7,5519e-7,5124e-7,476e-6,4425e-7,4115e-7,383e-6,3566e-7,3323e-7,3098e-7,2889e-7,2695e-7,2516e-7,2348e-7,2192e-7,2045e-7,1908e-7,1781e-7,1662e-7,155e-6,1446e-7,1349e-7,1259e-7,1174e-7,1096e-7,1022e-7,9539e-8,8902e-8,8308e-8,7751e-8,7231e-8,6746e-8,6293e-8,5871e-8,5477e-8,511e-7,4768e-8,4449e-8,4151e-8,3873e-8,3614e-8,3372e-8,3146e-8,2935e-8,2738e-8,2552e-8,2379e-8,2218e-8,2067e-8,1927e-8,1797e-8,1675e-8,1562e-8,1456e-8,1357e-8,1265e-8,118e-7,11e-6,1025e-8,956e-8,8912e-9,8308e-9,7746e-9,7221e-9,6732e-9,6276e-9,5851e-9,5455e-9,5086e-9,4741e-9,442e-8,4121e-9,3842e-9,3582e-9,3339e-9,3113e-9,2902e-9,2706e-9,2523e-9,2352e-9,2192e-9,2044e-9,1905e-9,1777e-9,1656e-9,1544e-9,1439e-9,1342e-9,1251e-9],Y:[3917e-9,4394e-9,493e-8,5532e-9,6208e-9,6965e-9,7813e-9,8767e-9,984e-8,1104e-8,1239e-8,1389e-8,1556e-8,1744e-8,1958e-8,2202e-8,2484e-8,2804e-8,3153e-8,3522e-8,39e-6,4283e-8,4691e-8,5159e-8,5718e-8,64e-6,7234e-8,8221e-8,9351e-8,1061e-7,12e-5,135e-6,1515e-7,1702e-7,1918e-7,217e-6,2469e-7,2812e-7,3185e-7,3573e-7,396e-6,4337e-7,473e-6,5179e-7,5722e-7,64e-5,7246e-7,8255e-7,9412e-7,.0010699,.00121,.0013621,.0015308,.0017204,.0019353,.00218,.0024548,.002764,.0031178,.0035264,.004,.0045462,.0051593,.0058293,.0065462,.0073,.0080865,.0089087,.0097677,.0106644,.0116,.0125732,.0135827,.0146297,.0157151,.01684,.0180074,.0192145,.0204539,.0217182,.023,.0242946,.0256102,.0269586,.0283513,.0298,.0313108,.0328837,.0345211,.0362257,.038,.0398467,.041768,.043766,.0458427,.048,.0502437,.052573,.0549806,.0574587,.06,.062602,.0652775,.0680421,.0709111,.0739,.077016,.0802664,.0836668,.0872328,.09098,.0949176,.0990458,.1033674,.1078846,.1126,.117532,.1226744,.1279928,.1334528,.13902,.1446764,.1504693,.1564619,.1627177,.1693,.1762431,.1835581,.1912735,.199418,.20802,.2171199,.2267345,.2368571,.2474812,.2586,.2701849,.2822939,.2950505,.308578,.323,.3384021,.3546858,.3716986,.3892875,.4073,.4256299,.4443096,.4633944,.4829395,.503,.5235693,.544512,.56569,.5869653,.6082,.6293456,.6503068,.6708752,.6908424,.71,.7281852,.7454636,.7619694,.7778368,.7932,.8081104,.8224962,.8363068,.8494916,.862,.8738108,.8849624,.8954936,.9054432,.9148501,.9237348,.9320924,.9399226,.9472252,.954,.9602561,.9660074,.9712606,.9760225,.9803,.9840924,.9874182,.9903128,.9928116,.9949501,.9967108,.9980983,.999112,.9997482,1,.9998567,.9993046,.9983255,.9968987,.995,.9926005,.9897426,.9864444,.9827241,.9786,.9740837,.9691712,.9638568,.9581349,.952,.9454504,.9384992,.9311628,.9234576,.9154,.9070064,.8982772,.8892048,.8797816,.87,.8598613,.849392,.838622,.8275813,.8163,.8047947,.793082,.781192,.7691547,.757,.7447541,.7324224,.7200036,.7074965,.6949,.6822192,.6694716,.6566744,.6438448,.631,.6181555,.6053144,.5924756,.5796379,.5668,.5539611,.5411372,.5283528,.5156323,.503,.4904688,.4780304,.4656776,.4534032,.4412,.42908,.417036,.405032,.393032,.381,.3689184,.3568272,.3447768,.3328176,.321,.3093381,.2978504,.2865936,.2756245,.265,.2547632,.2448896,.2353344,.2260528,.217,.2081616,.1995488,.1911552,.1829744,.175,.1672235,.1596464,.1522776,.1451259,.1382,.1315003,.1250248,.1187792,.1127691,.107,.1014762,.0961886,.091123,.0862649,.0816,.0771206,.0728255,.0687101,.0647698,.061,.0573962,.053955,.0506738,.0475497,.04458,.0417587,.039085,.0365638,.0342005,.032,.0299626,.0280766,.0263294,.0247081,.0232,.0218008,.0205011,.0192811,.0181207,.017,.0159038,.0148372,.0138107,.0128348,.01192,.0110683,.0102734,.0095333,.0088462,.00821,.0076238,.0070854,.0065915,.0061385,.005723,.0053431,.0049958,.0046764,.0043801,.004102,.0038385,.0035891,.0033542,.0031341,.002929,.0027381,.0025599,.0023932,.0022373,.002091,.0019536,.0018246,.0017036,.0015902,.001484,.0013845,.0012913,.0012041,.0011227,.001047,9766e-7,9111e-7,8501e-7,7932e-7,74e-5,6901e-7,6433e-7,5995e-7,5585e-7,52e-5,4839e-7,4501e-7,4183e-7,3887e-7,3611e-7,3354e-7,3114e-7,2892e-7,2685e-7,2492e-7,2313e-7,2147e-7,1993e-7,185e-6,1719e-7,1598e-7,1486e-7,1383e-7,1288e-7,12e-5,1119e-7,1043e-7,9734e-8,9085e-8,848e-7,7915e-8,7386e-8,6892e-8,643e-7,6e-5,5598e-8,5223e-8,4872e-8,4545e-8,424e-7,3956e-8,3692e-8,3445e-8,3215e-8,3e-5,2799e-8,2611e-8,2436e-8,2272e-8,212e-7,1978e-8,1845e-8,1722e-8,1606e-8,1499e-8,1399e-8,1305e-8,1218e-8,1136e-8,106e-7,9886e-9,9217e-9,8592e-9,8009e-9,7466e-9,696e-8,6488e-9,6049e-9,5639e-9,5258e-9,4902e-9,457e-8,426e-8,3972e-9,3703e-9,3452e-9,3218e-9,3e-6,2797e-9,2608e-9,2431e-9,2267e-9,2113e-9,197e-8,1837e-9,1712e-9,1596e-9,1488e-9,1387e-9,1293e-9,1206e-9,1124e-9,1048e-9,9.771e-7,9.109e-7,8.493e-7,7.917e-7,7.381e-7,6.881e-7,6.415e-7,5.981e-7,5.576e-7,5.198e-7,4.846e-7,4.518e-7],Z:[6061e-7,6809e-7,7651e-7,86e-5,9666e-7,.001086,.0012206,.0013727,.0015436,.0017343,.001946,.0021778,.0024358,.002732,.0030781,.003486,.0039752,.0045409,.0051583,.0058029,.00645,.0070832,.0077455,.0085012,.0094145,.01055,.0119658,.0136559,.0155881,.0177302,.02005,.0225114,.0252029,.0282797,.031897,.03621,.0414377,.0475037,.0541199,.060998,.06785,.0744863,.0813616,.0891536,.0985405,.1102,.1246133,.1417017,.1613035,.1832568,.2074,.2336921,.2626114,.2947746,.3307985,.3713,.4162091,.4654642,.5196948,.5795303,.6456,.7184838,.7967133,.8778459,.959439,1.0390501,1.1153673,1.1884971,1.2581233,1.3239296,1.3856,1.4426352,1.4948035,1.5421903,1.5848807,1.62296,1.6564048,1.6852959,1.7098745,1.7303821,1.74706,1.7600446,1.7696233,1.7762637,1.7804334,1.7826,1.7829682,1.7816998,1.7791982,1.7758671,1.77211,1.7682589,1.764039,1.7589438,1.7524663,1.7441,1.7335595,1.7208581,1.7059369,1.6887372,1.6692,1.6475287,1.6234127,1.5960223,1.564528,1.5281,1.4861114,1.4395215,1.3898799,1.3387362,1.28764,1.2374223,1.1878243,1.1387611,1.090148,1.0419,.9941976,.9473473,.9014531,.8566193,.8129501,.7705173,.7294448,.6899136,.6521049,.6162,.5823286,.5504162,.5203376,.4919673,.46518,.4399246,.4161836,.3938822,.3729459,.3533,.3348578,.3175521,.3013375,.2861686,.272,.2588171,.2464838,.2347718,.2234533,.2123,.2011692,.1901196,.1792254,.1685608,.1582,.1481383,.1383758,.1289942,.1200751,.1117,.1039048,.0966675,.0899827,.0838453,.07825,.073209,.0686782,.0645678,.0607884,.05725,.0539044,.0507466,.0477528,.0448986,.04216,.0395073,.0369356,.0344584,.0320887,.02984,.0277118,.0256944,.0237872,.0219893,.0203,.0187181,.0172404,.0158636,.0145846,.0134,.0123072,.0113019,.0103779,.0095293,.00875,.0080352,.0073816,.0067854,.0062428,.00575,.0053036,.0048998,.0045342,.0042024,.0039,.0036232,.0033706,.0031414,.0029348,.00275,.0025852,.0024386,.0023094,.0021968,.0021,.0020177,.0019482,.0018898,.0018409,.0018,.0017663,.0017378,.0017112,.0016831,.00165,.0016101,.0015644,.0015136,.0014585,.0014,.0013367,.00127,.001205,.0011467,.0011,.0010688,.0010494,.0010356,.0010212,.001,9686e-7,9299e-7,8869e-7,8426e-7,8e-4,761e-6,7237e-7,6859e-7,6454e-7,6e-4,5479e-7,4916e-7,4354e-7,3835e-7,34e-5,3073e-7,2832e-7,2654e-7,2518e-7,24e-5,2295e-7,2206e-7,212e-6,2022e-7,19e-5,1742e-7,1556e-7,136e-6,1169e-7,1e-4,8613e-8,746e-7,65e-6,5693e-8,5e-5,4416e-8,3948e-8,3572e-8,3264e-8,3e-5,2765e-8,2556e-8,2364e-8,2181e-8,2e-5,1813e-8,162e-7,142e-7,1213e-8,1e-5,7733e-9,54e-7,32e-7,1333e-9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},{name:"10",description:"CIE 1964 10° standard observer tristimulus response values",startnm:360,endnm:830,step:1,range:1e3,X:[122e-9,185e-9,279e-9,417e-9,621e-9,919e-9,1352e-9,1977e-9,2872e-9,415e-8,5959e-9,8506e-9,12069e-9,17023e-9,23868e-9,33266e-9,46087e-9,63472e-9,86892e-9,118246e-9,159952e-9,21508e-8,28749e-8,38199e-8,50455e-8,66244e-8,8645e-7,.0011215,.00144616,.00185359,.0023616,.0029906,.0037645,.0047102,.0058581,.0072423,.0088996,.0108709,.0131989,.0159292,.0191097,.022788,.027011,.031829,.037278,.0434,.050223,.057764,.066038,.075033,.084736,.095041,.105836,.117066,.128682,.140638,.152893,.165416,.178191,.191214,.204492,.21765,.230267,.242311,.253793,.264737,.275195,.285301,.295143,.304869,.314679,.324355,.33357,.342243,.350312,.357719,.364482,.370493,.375727,.380158,.383734,.386327,.387858,.388396,.387978,.386726,.384696,.382006,.378709,.374915,.370702,.366089,.361045,.355518,.349486,.342957,.335893,.328284,.32015,.311475,.302273,.292858,.283502,.274044,.264263,.254085,.243392,.232187,.220488,.208198,.195618,.183034,.170222,.157348,.14465,.132349,.120584,.109456,.099042,.089388,.080507,.072034,.06371,.055694,.048117,.041072,.034642,.028896,.023876,.019628,.016172,.0133,.010759,.008542,.006661,.005132,.003982,.003239,.002934,.003114,.003816,.005095,.006936,.009299,.012147,.015444,.019156,.02325,.02769,.032444,.037465,.042956,.049114,.05592,.063349,.071358,.079901,.088909,.098293,.107949,.117749,.127839,.13845,.149516,.161041,.172953,.185209,.197755,.210538,.22346,.236491,.249633,.262972,.276515,.290269,.304213,.318361,.332705,.347232,.361926,.376772,.391683,.406594,.421539,.436517,.451584,.466782,.482147,.497738,.513606,.529826,.54644,.563426,.580726,.59829,.616053,.633948,.651901,.669824,.687632,.705224,.722773,.740483,.758273,.776083,.793832,.811436,.828822,.845879,.862525,.878655,.894208,.909206,.923672,.937638,.951162,.964283,.977068,.98959,1.002,1.014,1.026,1.039,1.051,1.063,1.074,1.085,1.095,1.104,1.112,1.119,1.124,1.128,1.131,1.133,1.134,1.134,1.133,1.131,1.128,1.124,1.119,1.113,1.106,1.098,1.089,1.079,1.068,1.057,1.044,1.03,1.016,1.001,.98479,.96808,.95074,.9328,.91434,.89539,.87603,.856297,.83635,.81629,.79605,.77561,.75493,.73399,.71278,.69129,.66952,.647467,.62511,.60252,.57989,.55737,.53511,.51324,.49186,.47108,.45096,.431567,.41287,.39475,.37721,.36019,.34369,.32769,.31217,.29711,.2825,.268329,.25459,.2413,.22848,.21614,.2043,.19295,.18211,.17177,.16192,.152568,.14367,.1352,.12713,.11948,.11221,.10531,.098786,.09261,.086773,.0812606,.076048,.071114,.066454,.062062,.05793,.05405,.050412,.047006,.043823,.0408508,.038072,.035468,.033031,.030753,.028623,.026635,.024781,.023052,.021441,.0199413,.018544,.017241,.016027,.014896,.013842,.012862,.011949,.0111,.010311,.00957688,.008894,.0082581,.0076664,.0071163,.0066052,.0061306,.0056903,.0052819,.0049033,.00455263,.0042275,.0039258,.0036457,.0033859,.0031447,.0029208,.002713,.0025202,.0023411,.00217496,.0020206,.0018773,.0017441,.0016205,.0015057,.0013992,.0013004,.0012087,.0011236,.00104476,97156e-8,9036e-7,84048e-8,78187e-8,72745e-8,6769e-7,62996e-8,58637e-8,54587e-8,508258e-9,4733e-7,4408e-7,41058e-8,38249e-8,35638e-8,33211e-8,30955e-8,28858e-8,26909e-8,250969e-9,23413e-8,21847e-8,20391e-8,19035e-8,17773e-8,16597e-8,15502e-8,1448e-7,13528e-8,12639e-8,1181e-7,11037e-8,10315e-8,96427e-9,90151e-9,84294e-9,7883e-8,73729e-9,68969e-9,64526e-9,60376e-9,565e-7,5288e-8,49498e-9,46339e-9,43389e-9,40634e-9,3806e-8,35657e-9,33412e-9,31315e-9,29355e-9,27524e-9,25811e-9,24209e-9,22711e-9,21308e-9,19994e-9,18764e-9,17612e-9,16532e-9,15521e-9,14574e-9,13686e-9,12855e-9,12075e-9,11345e-9,10659e-9,10017e-9,9414e-9,8848e-9,8317e-9,7819e-9,7352e-9,6913e-9,6502e-9,6115e-9,5753e-9,5413e-9,5093e-9,4794e-9,4512e-9,4248e-9,4e-6,3767e-9,3548e-9,3342e-9,3148e-9,2966e-9,2795e-9,2634e-9,2483e-9,2341e-9,2208e-9,2082e-9,1964e-9,1852e-9,1746e-9,1647e-9,1553e-9],Y:[13e-9,2e-8,31e-9,46e-9,68e-9,101e-9,148e-9,216e-9,314e-9,454e-9,651e-9,929e-9,1318e-9,1857e-9,2602e-9,3625e-9,5019e-9,6907e-9,9449e-9,12848e-9,17364e-9,23327e-9,3115e-8,4135e-8,5456e-8,7156e-8,933e-7,12087e-8,15564e-8,1992e-7,2534e-7,3202e-7,4024e-7,5023e-7,6232e-7,7685e-7,9417e-7,.0011478,.0013903,.001674,.0020044,.002386,.002822,.003319,.00388,.004509,.005209,.005985,.006833,.007757,.008756,.009816,.010918,.012058,.013237,.014456,.015717,.017025,.018399,.019848,.021391,.022992,.024598,.026213,.027841,.029497,.031195,.032927,.034738,.036654,.038676,.040792,.042946,.045114,.047333,.049602,.051934,.054337,.056822,.059399,.062077,.064737,.067285,.069764,.072218,.074704,.077272,.079979,.082874,.086,.089456,.092947,.096275,.099535,.102829,.106256,.109901,.113835,.118167,.122932,.128201,.133457,.138323,.143042,.147787,.152761,.158102,.163941,.170362,.177425,.18519,.193025,.200313,.207156,.213644,.21994,.22617,.232467,.239025,.245997,.253589,.261876,.270643,.279645,.288694,.297665,.306469,.315035,.323335,.331366,.339133,.34786,.358326,.370001,.382464,.395379,.408482,.421588,.434619,.447601,.460777,.47434,.4882,.50234,.51674,.53136,.54619,.56118,.57629,.5915,.606741,.62215,.63783,.65371,.66968,.68566,.70155,.71723,.73257,.74746,.761757,.77534,.78822,.80046,.81214,.82333,.83412,.8446,.85487,.86504,.875211,.88537,.89537,.90515,.91465,.92381,.93255,.94081,.94852,.9556,.961988,.96754,.97223,.97617,.97946,.9822,.98452,.98652,.98832,.99002,.991761,.99353,.99523,.99677,.99809,.99911,.99977,1,.99971,.99885,.99734,.99526,.99274,.98975,.9863,.98238,.97798,.97311,.96774,.96189,.955552,.948601,.940981,.932798,.924158,.915175,.905954,.896608,.887249,.877986,.868934,.860164,.851519,.842963,.834393,.825623,.816764,.807544,.797947,.787893,.777405,.76649,.755309,.743845,.73219,.720353,.708281,.696055,.683621,.671048,.658341,.645545,.632718,.619815,.606887,.593878,.580781,.567653,.55449,.541228,.527963,.514634,.501363,.488124,.474935,.461834,.448823,.435917,.423153,.410526,.398057,.385835,.373951,.362311,.350863,.339554,.328309,.317118,.305936,.294737,.283493,.272222,.26099,.249877,.238946,.228254,.217853,.20778,.198072,.188748,.179828,.171285,.163059,.155151,.147535,.140211,.13317,.1264,.119892,.11364,.107633,.10187,.096347,.091063,.08601,.081187,.076583,.072198,.068024,.064052,.060281,.056697,.053292,.050059,.046998,.044096,.041345,.0387507,.0362978,.0339832,.0318004,.0297395,.0277918,.0259551,.0242263,.0226017,.0210779,.0196505,.0183153,.0170686,.0159051,.0148183,.0138008,.0128495,.0119607,.0111303,.0103555,.0096332,.0089599,.0083324,.0077488,.0072046,.0066975,.0062251,.005785,.0053751,.0049941,.0046392,.0043093,.0040028,.00371774,.00345262,.00320583,.00297623,.00276281,.00256456,.00238048,.00220971,.00205132,.00190449,.00176847,.00164236,.00152535,.00141672,.00131595,.00122239,.00113555,.00105494,98014e-8,91066e-8,84619e-8,78629e-8,73068e-8,67899e-8,63101e-8,58644e-8,54511e-8,50672e-8,47111e-8,43805e-8,40741e-8,378962e-9,352543e-9,328001e-9,305208e-9,284041e-9,264375e-9,246109e-9,229143e-9,213376e-9,19873e-8,185115e-9,172454e-9,160678e-9,14973e-8,13955e-8,130086e-9,12129e-8,113106e-9,105501e-9,98428e-9,91853e-9,85738e-9,80048e-9,74751e-9,69819e-9,65222e-9,60939e-9,56942e-9,53217e-9,49737e-9,46491e-9,43464e-9,40635e-9,38e-6,3554e-8,33245e-9,31101e-9,29099e-9,27231e-9,25486e-9,23856e-9,22333e-9,2091e-8,19581e-9,18338e-9,17178e-9,16093e-9,1508e-8,14134e-9,13249e-9,12423e-9,1165e-8,10928e-9,10252e-9,962e-8,9028e-9,8474e-9,7955e-9,7469e-9,7013e-9,6586e-9,6186e-9,5811e-9,5459e-9,513e-8,4821e-9,4531e-9,4259e-9,4004e-9,3765e-9,354e-8,3329e-9,3131e-9,2945e-9,2771e-9,2607e-9,2453e-9,2309e-9,2173e-9,2046e-9,1927e-9,1814e-9,1709e-9,161e-8,1517e-9,1429e-9,1347e-9,1269e-9,1197e-9,1128e-9,1064e-9,1003e-9,946e-9,893e-9,842e-9,795e-9,75e-8,707e-9,667e-9,63e-8],Z:[535e-9,811e-9,1221e-9,1829e-9,2722e-9,4028e-9,5926e-9,8665e-9,12596e-9,18201e-9,26144e-9,3733e-8,52987e-9,74764e-9,10487e-8,14622e-8,20266e-8,27923e-8,38245e-8,52072e-8,704776e-9,94823e-8,.0012682,.0016861,.0022285,.0029278,.0038237,.0049642,.0064067,.0082193,.0104822,.013289,.016747,.02098,.026127,.032344,.039802,.048691,.05921,.071576,.0860109,.10274,.122,.14402,.16899,.19712,.22857,.26347,.3019,.34387,.389366,.43797,.48922,.5429,.59881,.65676,.71658,.77812,.84131,.90611,.972542,1.039,1.103,1.165,1.225,1.282,1.338,1.393,1.446,1.499,1.553,1.607,1.659,1.708,1.755,1.798,1.839,1.877,1.91,1.941,1.967,1.989,2.006,2.017,2.024,2.027,2.026,2.022,2.015,2.006,1.995,1.981,1.965,1.946,1.925,1.901,1.874,1.845,1.814,1.781,1.745,1.709,1.672,1.635,1.596,1.555,1.512,1.467,1.42,1.37,1.318,1.262,1.205,1.147,1.088,1.03,.97383,.91943,.86746,.81828,.772125,.72829,.68604,.64553,.60685,.57006,.53522,.50234,.4714,.44239,.415254,.390024,.366399,.344015,.322689,.302356,.283036,.264816,.247848,.232318,.218502,.205851,.193596,.181736,.170281,.159249,.148673,.138609,.129096,.120215,.112044,.10471,.098196,.092361,.087088,.082248,.077744,.073456,.069268,.06506,.060709,.056457,.052609,.049122,.045954,.04305,.040368,.037839,.035384,.032949,.030451,.028029,.025862,.02392,.022174,.020584,.019127,.01774,.016403,.015064,.013676,.012308,.011056,.009915,.008872,.007918,.00703,.006223,.005453,.004714,.003988,.003289,.002646,.002063,.001533,.001091,711e-6,407e-6,184e-6,47e-6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}];t.exports=class{constructor(){this.version="0.0.1",this.name="Spectral",this.description="Spectral data and calculations"}getIlluminants=function(){return r};getIlluminant=function(t){for(var e=0;e<r.length;e++)if(t===r[e].name)return r[e];return!1};getObservers=function(){return n};getObserver=function(t){for(var e=0;e<n.length;e++)if(t===n[e].name)return n[e];return!1};toSpectral=function(t,e,a,i){return i||(i=(t-e)/(a.length-1)),{startnm:t,endnm:e,step:i,data:a}};calculateXYZ=function(t,e,a){var r,n,s,o,h,u,c,l,p,d,m,g,_,v,f=t.startnm,C=t.endnm,P=0,b=0,S=0,M=0;f<e.startnm&&(f=e.startnm),f<a.startnm&&(f=a.startnm),C>e.endnm&&(C=e.endnm),C>a.endnm&&(C=a.endnm),s=(C-f)/t.step,n=(r=(f-t.startnm)/t.step)+s;for(var y=f,Y=r;Y<=n;Y++){var G=(y-a.startnm)/a.step;G%1!=0?(h=G-(o=Math.floor(G)),m=a.X[o]*(1-h)+a.X[o+1]*h,g=a.Y[o]*(1-h)+a.Y[o+1]*h,_=a.Z[o]*(1-h)+a.Z[o+1]*h):(m=a.X[G],g=a.Y[G],_=a.Z[G]);var D=(y-e.startnm)/e.step;D%1!=0?(h=D-(o=Math.floor(D)),v=e.data[o]*(1-h)+e.data[o+1]*h):v=e.data[D],u=v*g,P+=m*v*t.data[Y],b+=g*v*t.data[Y],S+=_*v*t.data[Y],M+=u,y+=t.step}return l=P*(c=100/M)/100,p=b*c/100,d=S*c/100,i.XYZ(l,p,d,e.whitePoint)}}},369:(t,e,a)=>{"use strict";var i=a(577),r=a(618),n=a(362),s=n.eIntent,o=n.eProfileType,h=n.eColourType,u=n.illuminant,c=n.encoding,l=n.encodingStr;class p{constructor(t){t=t||{},this.builtLut=!0===t.builtLut,this.lutGridPoints3D=isNaN(Number(t.lutGridPoints3D))?33:Number(t.lutGridPoints3D),this.lutGridPoints4D=isNaN(Number(t.lutGridPoints4D))?17:Number(t.lutGridPoints4D),this.interpolation3D=t.interpolation3D?t.interpolation3D.toLowerCase():"tetrahedral",this.interpolation4D=t.interpolation4D?t.interpolation4D.toLowerCase():"tetrahedral",this.interpolationFast=!1!==t.interpolationFast,this.LUTinterpolation3D=t.LUTinterpolation3D?t.LUTinterpolation3D.toLowerCase():this.interpolation3D,this.LUTinterpolation4D=t.LUTinterpolation4D?t.LUTinterpolation4D.toLowerCase():this.interpolation4D,this.labAdaptation=!0===t.labAdaptation,this.displayChromaticAdaptation=!0===t.displayChromaticAdaptation,this.labInputAdaptation=!1!==t.labInputAdaptation,this.dataFormat=t.dataFormat||"object",t.dataFormat||t.useFloats&&(console.log("useFloats is obsolete, use dataFormat instead"),this.dataFormat="objectFloat");var e=!0;switch(this.dataFormat){case"object":e=!0;break;case"objectFloat":e=!0,this.useFloats=!0;break;case"int8":case"int16":case"device":e=!1;break;default:throw'Invalid dataFormat "'+this.dataFormat+'". Must be "object", "objectFloat", "int8", "int16" or "device"'}this.convertInputOutput=e,this.verbose=!0===t.verbose,this.pipelineDebug=!0===t.pipelineDebug,this.optimise=!1!==t.optimise,this.optimiseDebug=[],this.roundOutput=!1!==t.roundOutput,this.precession=isNaN(Number(t.precession))?0:Number(t.precession),Array.isArray(t.BPC)?this.useBPC=t.BPC:this.useBPC=!0===t.BPC,this._BPCAutoEnable=!0,this.usesBPC=!1,this.usesAdaptation=!1,this._expandRGBStages=!0,this._RGBMatrixWhiteAdadaptation=!1,this.clipRGBinPipeline=!0===t.clipRGBinPipeline,this.pipeline=[],this.pipelineHistory=[],this.pipelineCreated=!1,this.debugHistory=[],this.debugHistoryDecimals=6,this.lut=!1,this.inputProfile=null,this.outputProfile=null,this.chain=[],this.customStages=!1,this.inputChannels=0,this.outputChannels=0}getLut(t){var e;if(void 0===t||!1===t)e=this.lut.CLUT;else{var a=Math.pow(10,t);e=this.lut.CLUT.map((function(t){return Math.round(t*a)/a}))}var i=this.cloneLut([]);return i.CLUT=e,i.precision=null,i.inputScale=1,i.outputScale=1,i}getLut16(){for(var t=new Uint16Array(this.lut.CLUT.length),e=0;e<this.lut.CLUT.length;e++)t[e]=65535*this.lut.CLUT[e];var a=this.cloneLut(function(t){var e=new Uint8Array(t.buffer),a="";for(var i of e)a+=String.fromCharCode(i);return btoa(a)}(t),"base64");return a.precision=16,a.inputScale=1,a.outputScale=1/65535,a}getLut8(){for(var t=new Uint8Array(this.lut.CLUT.length),e=0;e<this.lut.CLUT.length;e++)t[e]=Math.round(255*this.lut.CLUT[e]);var a=this.cloneLut(function(t){var e="";for(var a of t)e+=String.fromCharCode(a);return btoa(e)}(t),"base64");return a.precision=8,a.inputScale=1,a.outputScale=1/255,a}setLut(t){if(this.lut=t,t.chain.length<3)throw"Invalid LUT - chain is too short";if(!t.chain[0].hasOwnProperty("profile"))throw"Invalid LUT - First link is not a profile";if(!t.chain[t.chain.length-2].hasOwnProperty("intent"))throw"Invalid LUT - Intent is missing";if(!t.chain[t.chain.length-1].hasOwnProperty("profile"))throw"Invalid LUT - Last link is not a profile";var e=t.chain[0],a=t.chain[t.chain.length-2].intent,i=t.chain[t.chain.length-1];this.chain=t.chain,"base64"===this.lut.encoding&&(16===this.lut.precision?this.lut.CLUT=function(t){let e=atob(t),a=e.length,i=new Uint8Array(a);for(let t=0;t<a;t++)i[t]=e.charCodeAt(t);return new Uint16Array(i.buffer)}(this.lut.CLUT):this.lut.CLUT=function(t){let e=atob(t),a=e.length,i=new Uint8ClampedArray(a);for(let t=0;t<a;t++)i[t]=e.charCodeAt(t);return i}(this.lut.CLUT),this.lut.encoding="number"),this.create(e,i,a)}cloneLut(t,e){return JSON.parse(JSON.stringify(this.lut,(function(a,i){return"CLUT"===a?t:"encoding"===a&&void 0!==e?e:i})))}create(t,e,a,i){return this.createMultiStage([t,a,e],i)}createMultiStage(t,e){var a,r;e=e||[];var n=t.length-1;for(r=0;r<t.length;r++)if("string"==typeof(a=t[r])){if("*"!==a.substring(0,1))throw"Invalid inputProfile "+r+" is a string not a Profile";t[r]=new i(a)}if(this.inputProfile=null,this.outputProfile=null,this.usesBPC=!1,this.usesAdaptation=!1,!1===this.lut){if(!Array.isArray(t))throw"Invalid profileChain, must be an array";if(t.length<3)throw"Invalid profileChain, must have at least items";for(r=0;r<t.length;r++)if(a=t[r],r%2==0){if(!a instanceof i)throw"step "+r+" in chain is not a Profile";if(!a.loaded)throw"Profile "+r+" in chain is not loaded"}else{if("number"!=typeof a)throw"step "+r+" in chain is not an intent";if(a!==s.absolute&&a!==s.perceptual&&a!==s.relative&&a!==s.saturation)throw"step "+r+" in chain is not a valid intent"}if(!t[0]instanceof i)throw"First step in chain is not a Profile";if(!t[n]instanceof i)throw"Last step in chain is not a Profile"}else if(void 0===this.lut.CLUT||null===this.lut.CLUT)throw"Invalid LUT";if(this.chain=t,this.inputProfile=t[0],this.inputChannels=this.getProfileChannels(this.inputProfile),this.outputProfile=t[n],this.outputChannels=this.getProfileChannels(this.outputProfile),this.customStages=e,this.builtLut||!1!==this.lut){!1===this.lut&&(this.createPipeline(t,!1,!1,!1),this.verbose&&(this.optimise?console.log(this.optimiseInfo()):console.log(this.getStageNames(!1,!1)),console.log("Temp Pipeline Created, Building LUT ....")),this.pipelineCreated=!0,this.lut=this.createLut());var o=this.interpolation3D,h=this.interpolation4D;this.interpolation3D=this.LUTinterpolation3D,this.interpolation4D=this.LUTinterpolation4D,this.createPipeline(t,this.convertInputOutput,this.convertInputOutput,!0),this.interpolation3D=o,this.interpolation4D=h}else this.createPipeline(t,this.convertInputOutput,this.convertInputOutput,!1),this.lut=!1;this.pipelineCreated=!0,this.verbose&&(this.optimise?console.log(this.optimiseInfo()):console.log(this.getStageNames(!1,!1)))}createLut(){var t,e,a,r;switch(console.time("create Prebuilt Lut"),this.outputProfile.type){case o.Gray:r=1;break;case o.Duo:r=2;break;case o.Lab:case o.RGBMatrix:case o.RGBLut:r=3;break;case o.CMYK:r=4;break;default:throw"Create Lut Invalid output profile type "+this.outputProfile.type}switch(this.inputProfile.type){case o.Gray:a=1,t=this.create1DDeviceLUT(r,this.lutGridPoints3D),e=[this.lutGridPoints3D];break;case o.Duo:a=2,t=this.create2DDeviceLUT(r,this.lutGridPoints3D),e=[this.lutGridPoints3D,this.lutGridPoints3D];break;case o.Lab:case o.RGBMatrix:case o.RGBLut:a=3,t=this.create3DDeviceLUT(r,this.lutGridPoints3D),e=[this.lutGridPoints3D,this.lutGridPoints3D,this.lutGridPoints3D];break;case o.CMYK:a=4,t=this.create4DDeviceLUT(r,this.lutGridPoints4D),e=[this.lutGridPoints4D,this.lutGridPoints4D,this.lutGridPoints4D,this.lutGridPoints4D];break;default:throw"Create Lut Invalid input profile type "+this.inputProfile.type}console.timeEnd("create Prebuilt Lut");for(var n=[],s=0;s<this.chain.length;s++)this.chain[s]instanceof i?n.push(l(this.chain[s])):n.push(this.chain[s]);var h=e[0],u=h*(e[1]||0),c=u*(e[2]||0);return{chain:n,version:1,inputChannels:a,outputChannels:r,gridPoints:e,g1:h,g2:u,g3:c,go0:r,go1:h*r,go2:u*r,go3:c*r,CLUT:t,encoding:"number",precision:null,outputScale:1,inputScale:1};function l(t){return{header:t.header,name:t.name,type:t.type,intent:t.intent,whitePoint:t.whitePoint,description:t.description,viewingConditions:t.viewingConditions,mediaWhitePoint:t.mediaWhitePoint,PCSEncode:t.PCSEncode,PCSDecode:t.PCSDecode,PCS8BitScale:t.PCS8BitScale,version:t.version}}}create1DDeviceLUT(t,e){var a,i,r=new Float64Array(this.outputProfile.outputChannels*e),n=0,s=1/(e-1);for(a=0;a<e;a++){var o=this.forward([a*s]);for(i=0;i<t;i++)r[n++]=o[i]}return r}create2DDeviceLUT(t,e){var a,i,r,n,s=e*e,o=new Float64Array(this.outputProfile.outputChannels*s),h=0,u=1/(e-1);for(a=0;a<e;a++)for(n=a*u,i=0;i<e;i++){var c=this.forward([n,i*u]);for(r=0;r<t;r++)o[h++]=c[r]}return o}create3DDeviceLUT(t,e){var a,i,r,n,s,o,h=e*e*e,u=new Float64Array(this.outputProfile.outputChannels*h),c=0,l=1/(e-1),p=0;for(a=0;a<e;a++)for(s=a*l,i=0;i<e;i++)for(o=i*l,r=0;r<e;r++){var d=this.forward([s,o,r*l]);for(n=0;n<t;n++)u[c++]=d[n];p++}return this.verbose&&console.log("3D LUT size : "+p+" points @ "+e+" "+e+" "+e),u}create4DDeviceLUT(t,e){var a,i,r,n,s,o,h,u,c,l=e*e*e*e,p=new Float64Array(this.outputProfile.outputChannels*l),d=0,m=1/(e-1),g=this.pipeline,_=g.length,v=[0,0,0,0];for(a=0;a<e;a++)for(o=a*m,i=0;i<e;i++)for(h=i*m,r=0;r<e;r++)for(u=r*m,n=0;n<e;n++){for(v=[o,h,u,n*m],c=0;c<_;c++)v=g[c].funct.call(this,v,g[c].stageData,g[c]);for(s=0;s<t;s++)p[d++]=v[s]}return p}forward(t){if(!this.pipelineCreated)throw"No Pipeline";var e,a,i,r=this.pipeline,n=r.length,s=t;if(this.pipelineDebug)for(this.pipelineHistory=[s],this.debugHistory=[],a=0;a<n;a++)e=(i=r[a]).funct.call(this,s,i.stageData,i),""!==i.debugFormat&&this.addDebugHistory(i.debugFormat,i.stageName,s,e),this.pipelineHistory.push(e),s=e;else for(a=0;a<n;a++)s=r[a].funct.call(this,s,r[a].stageData,r[a]);return s}transform(t){return this.forward(t)}transformArrayViaLUT(t,e,a,i,r){var n=this.lut;if(!n)throw"No LUT loaded";i=i||a&&e;var s=e?n.inputChannels+1:n.inputChannels,o=a?n.outputChannels+1:n.outputChannels;void 0===r&&(r=Math.floor(t.length/s));var h=new Uint8ClampedArray(r*o),u=n.inputChannels,c=n.outputChannels;switch(u){case 1:this.linearInterp1DArray_NCh_loop(t,0,h,0,r,n,e,a,i);break;case 2:this.bilinearInterp2DArray_NCh_loop(t,0,h,0,r,n,e,a,i);break;case 3:switch(c){case 3:this.tetrahedralInterp3DArray_3Ch_loop(t,0,h,0,r,n,e,a,i);break;case 4:this.tetrahedralInterp3DArray_4Ch_loop(t,0,h,0,r,n,e,a,i);break;default:this.tetrahedralInterp3DArray_NCh_loop(t,0,h,0,r,n,e,a,i)}break;case 4:switch(c){case 3:this.tetrahedralInterp4DArray_3Ch_loop(t,0,h,0,r,n,e,a,i);break;case 4:this.tetrahedralInterp4DArray_4Ch_loop(t,0,h,0,r,n,e,a,i);break;default:this.tetrahedralInterp4DArray_NCh_loop(t,0,h,0,r,n,e,a,i)}break;default:throw"Invalid inputChannels "+u}return h}transformArray(t,e,a,i,r,n){if(!this.pipelineCreated)throw"No Pipeline";if("object"===this.dataFormat||"objectFloat"===this.dataFormat)throw"forwardArray can only be used with int8 or int16 dataFormat";if(i&&!e)throw"preserveAlpha is true but inputArray has no alpha channel";var s,o,h,u,c,l,p,d,m,g=this.pipeline,_=g.length,v=0,f=0;if("object"===this.dataFormat||"objectFloat"===this.dataFormat){for(void 0===r&&(r=t.length),m=new Array(r),u=0;u<r;u++){for(s=t[u],o=0;o<_;o++)s=g[o].funct.call(this,s,g[o].stageData,g[o]);m[u]=s}return m}switch(c=this.inputChannels,l=this.outputChannels,p=e?this.inputChannels+1:this.inputChannels,d=i?this.outputChannels+1:this.outputChannels,void 0===r&&(r=Math.floor(t.length/p)),n){case"int8":m=new Uint8ClampedArray(r*d);break;case"int16":m=new Uint16Array(r*d);break;case"float32":m=new Float32Array(r*d);break;case"float64":m=new Float64Array(r*d);break;case"same":var C=t.constructor.name;switch(C){case"Uint8Array":m=new Uint8ClampedArray(r*d);break;case"Uint16Array":m=new Uint16Array(r*d);break;case"Float32Array":m=new Float32Array(r*d);break;case"Float64Array":m=new Float64Array(r*d);break;default:throw"Unknown inputArray type "+C}break;default:m=new Array(r*d)}switch(c){case 1:for(u=0;u<r;u++){for(s=[t[v++]],o=0;o<_;o++)s=g[o].funct.call(this,s,g[o].stageData,g[o]);for(h=0;h<l;h++)m[f++]=s[h];i?m[f++]=t[v++]:(e&&v++,a&&(m[f++]=255))}break;case 2:for(u=0;u<r;u++){for(s=[t[v++],t[v++]],o=0;o<_;o++)s=g[o].funct.call(this,s,g[o].stageData,g[o]);for(h=0;h<l;h++)m[f++]=s[h];i?m[f++]=t[v++]:(e&&v++,a&&(m[f++]=255))}break;case 3:for(u=0;u<r;u++){for(s=[t[v++],t[v++],t[v++]],o=0;o<_;o++)s=g[o].funct.call(this,s,g[o].stageData,g[o]);for(h=0;h<l;h++)m[f++]=s[h];i?m[f++]=t[v++]:(e&&v++,a&&(m[f++]=255))}break;case 4:for(u=0;u<r;u++){for(s=[t[v++],t[v++],t[v++],t[v++]],o=0;o<_;o++)s=g[o].funct.call(this,s,g[o].stageData,g[o]);for(h=0;h<l;h++)m[f++]=s[h];i?m[f++]=t[v++]:(e&&v++,a&&(m[f++]=255))}}return m}intent2LUTIndex(t){return[s.perceptual,s.relative,s.saturation,s.relative][t]}intent2String(t){return["perceptual","relative","saturation","relative"][t]||"unknown "+t}chainInfo(){for(var t="--------- PROFILE CHAIN ---------\n",e=0;e<this.chain.length;e++)this.chain[e]instanceof i?t+="Profile: "+this.chain[e].name+"\n":t+="Intent: "+this.intent2String(this.chain[e])+"\n";return t}historyInfo(){var t,e=0,a=["--------- PIPELINE HISTORY ---------"];for(t=0;t<this.debugHistory.length;t++)this.debugHistory[t].indexOf("|")>e&&(e=this.debugHistory[t].indexOf("|"));for(t=0;t<this.debugHistory.length;t++){var i=this.debugHistory[t].split("|");i.length>1&&(i[0]=(i[0]+" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .").substring(0,e)+" ",i[1]=i[1].trim()),a.push(i.join(""))}return a.join("\n")}optimiseInfo=function(){return this.optimiseDebug.join("\n")};debugInfo(){return this.chainInfo()+"\n\n"+this.optimiseInfo()+"\n\n"+this.getStageNames(!0,!1)+(this.pipelineDebug?"\n\n"+this.historyInfo():"")}getStageNames(t,e){for(var a,i=[],r=0;r<this.pipeline.length;r++)a=t&&!1!==this.pipeline[r].inputEncoding?l[this.pipeline[r].inputEncoding]+" > "+this.pipeline[r].stageName+" > "+l[this.pipeline[r].outputEncoding]:this.pipeline[r].stageName,e&&(a+=" "+this.pipeline[r].debugFormat),i.push(r+": "+a);return i.join("\n")}createPipeline(t,e,a,r){this.pipeline=[];var n=t.length-1,o={pcsEncoding:null};if(this.pipelineDebug&&this.addStage(!1,"Start",this.stage_debug,"[PipeLine Input]| {data}",!1),e&&"device"!==this.dataFormat?(r||this.insertCustomStage("beforeInput2Device",o,!1),this.createPipeline_Input_to_Device(o,t[0])):o.pcsEncoding=this.getInput2DevicePCSInfo(t[0]),r){if(!1===this.lut)throw"No LUT";if(!Array.isArray(this.lut.chain))throw"LUT has no profile chain";if(this.lut.chain.length<2)throw"LUT chain is too short";var h=this.lut.chain[0],u=this.lut.chain[this.lut.chain.length-1];if(!h instanceof i)throw"LUT Chain does not start with a profile";if(!u instanceof i)throw"LUT Chain does not end with a profile";this.createPipeline_Device_to_Device_via_LUT(o,h,u)}else for(var l=0,p=0;p<t.length-1;p+=2){var d={inputProfile:t[p],intent:t[p+1],outputProfile:t[p+2]};if(this.insertCustomStage("beforeDevice2PCS",o,l),this.createPipeline_Device_to_PCS(o,d.inputProfile,d.outputProfile,d.intent),this.insertCustomStage("afterDevice2PCS",o,l),o.pcsEncoding===c.PCSXYZ||o.pcsEncoding===c.PCSv4||o.pcsEncoding===c.PCSv2){var m;if(m=Array.isArray(this.useBPC)?this.useBPC[l]:this.useBPC,this._BPCAutoEnable)switch(d.intent){case s.saturation:case s.perceptual:4!==d.inputProfile.version&&4!==d.outputProfile.version||(m=!0),this.isGreyTRCwithNOLUT(d.inputProfile,d.intent)&&(m=!0);break;case s.absolute:m=!1}m&&this.createPipeline_BlackPointCompensation(o,d.inputProfile,d.outputProfile,d.intent),this.insertCustomStage("PCS",o,l),this.createPipeline_chromaticAdaptation(o,d.inputProfile,d.outputProfile,d.intent)}this.insertCustomStage("beforePCS2Device",o,l),this.createPipeline_PCS_to_Device(o,d.inputProfile,d.outputProfile,d.intent),this.insertCustomStage("afterPCS2Device",o,l),l++}a&&"device"!==this.dataFormat&&(this.createPipeline_Device_to_Output(o,t[n]),r||this.insertCustomStage("afterDevice2Output",o,!1)),this.pipelineDebug&&this.addStage(!1,"END",this.stage_debug,"[PipeLine Output]| {data}",!1),this.optimise&&this.optimisePipeline(),this.verifyPipeline()}verifyPipeline(){for(var t=this.pipeline.length-1,e=0;e<t;e++)if(!1!==this.pipeline[e].outputEncoding&&!1!==this.pipeline[e+1].inputEncoding){if("function"!=typeof this.pipeline[e].funct)throw"No Function on stage @ "+e+" "+this.pipeline[e].stageName;if(this.pipeline[e].outputEncoding!==this.pipeline[e+1].inputEncoding)throw console.log(this.getStageNames(!0,!0)),"Incompatible Stages @ Stage "+e+" ("+this.pipeline[e].stageName+" "+l[this.pipeline[e].outputEncoding]+" > "+l[this.pipeline[e+1].inputEncoding]+" "+this.pipeline[e+1].stageName+")"}}optimisePipeline(){for(var t=this,e=!0,a=this.pipeline.length,i=this.getStageNames(),n=["linearInterp1D","bilinearInterp2D","trilinearInterp3D","tetrahedralInterp3D","trilinearInterp4D","tetrahedralInterp4D"];!0===e;){e=!1,e|=this.optimiseFindPattern("stage_null",!1,(function(t,e,a){return a.outputEncoding=e.inputEncoding,a.stageName+=" >> ALIAS "+l[e.inputEncoding],a.optimised=!0,[e]})),e|=this.optimiseFindPattern("stage_LabD50_to_PCSv4","stage_PCSv4_to_LabD50",(function(){return[]})),e|=this.optimiseFindPattern("stage_PCSv4_to_LabD50","stage_LabD50_to_PCSv4",(function(){return[]})),e|=this.optimiseFindPattern("stage_PCSv2_to_PCSv4","stage_PCSv4_to_PCSv2",(function(){return[]})),e|=this.optimiseFindPattern("stage_PCSv4_to_PCSv2","stage_PCSv2_to_PCSv4",(function(){return[]})),e|=this.optimiseFindPattern("stage_PCSXYZ_to_PCSv4","stage_PCSv4_to_PCSXYZ",(function(){return[]})),e|=this.optimiseFindPattern("stage_PCSXYZ_to_PCSv4","stage_PCSv4_to_PCSv2",(function(e,a){return[t.createStage(e.inputEncoding,"stage_PCSXYZ_to_PCSv2",t.stage_PCSXYZ_to_PCSv2,null,a.outputEncoding," *[optimised : {name}]|({last}) > ({data})",!0)]})),e|=this.optimiseFindPattern("stage_LabD50_to_PCSv4","stage_PCSv4_to_PCSXYZ",(function(e,a){return[t.createStage(e.inputEncoding,"stage_LabD50_to_PCSXYZ",t.stage_LabD50_to_PCSXYZ,null,a.outputEncoding," *[optimised : {name}]|({last}) > ({data})",!0)]})),e|=this.optimiseFindPattern("stage_PCSv2_to_PCSv4","stage_PCSv4_to_cmsLab",(function(e,a){return[t.createStage(e.inputEncoding,"stage_PCSv2_to_cmsLab",t.stage_PCSv2_to_cmsLab,null,a.outputEncoding," *[optimised : {name}]|({last}) > ({data})",!0)]})),e|=this.optimiseFindPattern("stage_LabD50_to_PCSv2","stage_PCSv2_to_PCSv4",(function(e,a){return[t.createStage(e.inputEncoding,"stage_LabD50_to_PCSv4",t.stage_LabD50_to_PCSv4,null,a.outputEncoding," *[optimised : {name}]|({last}) > ({data})",!0)]})),e|=this.optimiseFindPattern("stage_LabD50_to_PCSv4","stage_PCSv4_to_PCSv2",(function(e,a){return[t.createStage(e.inputEncoding,"stage_LabD50_to_PCSv2",t.stage_LabD50_to_PCSv2,null,a.outputEncoding," *[optimised : {name}]|({last}) > ({data})",!0)]})),e|=this.optimiseFindPattern("stage_LabD50_to_PCSv4","stage_PCSv4_to_cmsLab",(function(e,a){return[t.createStage(e.inputEncoding,"stage_LabD50_to_cmsLab",t.stage_LabD50_to_cmsLab,null,a.outputEncoding," *[optimised : {name}]|({last}) > ({data})",!0)]})),e|=this.optimiseFindPattern("stage_LabD50_to_PCSv2","stage_PCSv2_to_cmsLab",(function(e,a){return[t.createStage(e.inputEncoding,"stage_LabD50_to_cmsLab",t.stage_LabD50_to_cmsLab,null,a.outputEncoding," *[optimised : {name}]|({last}) > ({data})",!0)]})),e|=this.optimiseFindPattern("stage_matrix_rgb","stage_matrix_rgb",(function(e,a){var i=e.stageData,n=a.stageData,s=r.multiplyMatrices(n,i);return[t.createStage(e.inputEncoding,"stage_matrix_rgb",t.stage_matrix_rgb,s,a.outputEncoding," *[optimised : {name}]|({last}) > ({data})",!0)]}));for(var s=0;s<n.length;s++){var o=n[s];e|=this.optimiseFindPattern("stage_Int_to_Device",o,(function(e,a){var i=a.stageData,r=e.stageData;return i.inputScale=1/r,[t.createStage(e.inputEncoding,o,a.funct,i,a.outputEncoding," *[optimised : {name}]|({last}) > ({data})",!0)]})),e|=this.optimiseFindPattern(o,"stage_device_to_int",(function(e,a){var i=e.stageData,r=a.stageData;i.outputScale=i.outputScale*r,i.outputScale>.99&&i.outputScale<1.01&&(i.outputScale=1);var n="stage_device"+i.outputChannels+"_to_int";return[t.createStage(e.inputEncoding,o,e.funct,i,a.outputEncoding," *[optimised : {name}]|({last}) > ({data})",!0),t.createStage(a.outputEncoding,n,t[n],1,a.outputEncoding," *[optimised : {name}]|({last}) > ({data})",!0)]}))}}this.optimiseDebug=["==========================================================================================","** OPTIMISED PIPELINE - REMOVED "+(a-this.pipeline.length)+" STAGES **","BEFORE OPTIMISE\n"+i,"------------------------------------------------------------------------------------------","AFTER OPTIMISE\n"+this.getStageNames(),"=========================================================================================="]}optimiseFindPattern(t,e,a){for(var i=0;i<this.pipeline.length-1;i++)if(this.pipeline[i].stageName===t&&(this.pipeline[i+1].stageName===e||!1===e)){var r=i>1&&this.pipeline[i-1],n=this.pipeline[i+1],s=a(this.pipeline[i],n,r),o=this.pipeline.slice(0,i),h=this.pipeline.slice(i+2);return this.pipeline=o.concat(s,h),!0}return!1}createPipeline_Device_to_Device_via_LUT(t,e,a){if(!this.lut)throw"No LUT";switch(this.lut.inputChannels){case 1:this.addStageLUT(!1,this.getInput2DevicePCSInfo(e),this.lut,this.getDevice2OutputPCSInfo(a)," [Prebuilt LUT1D : {name}]|({last}) > ({data})");break;case 2:this.addStageLUT(!1,this.getInput2DevicePCSInfo(e),this.lut,this.getDevice2OutputPCSInfo(a)," [Prebuilt LUT2D : {name}]|({last}) > ({data})");break;case 3:this.addStageLUT(!1,this.getInput2DevicePCSInfo(e),this.lut,this.getDevice2OutputPCSInfo(a)," [Prebuilt LUT3D : {name}]|({last}) > ({data})");break;case 4:this.addStageLUT(!1,this.getInput2DevicePCSInfo(e),this.lut,this.getDevice2OutputPCSInfo(a)," [Prebuilt LUT4D : {name}]|({last}) > ({data})");break;default:throw"Can not use Prebuilt LUT - Unknown LUT inputChannels "+this.lut.inputChannels}t.pcsEncoding=this.getDevice2OutputPCSInfo(a)}createPipeline_Input_to_Device(t,e){switch(e.type){case o.XYZ:this.addStage(c.cmsXYZ,"stage_XYZ_to_PCSXYZ",this.stage_XYZ_to_PCSXYZ,null,c.PCSXYZ," [Input2Device : XYZ : {name}]|({last}) > ({data})"),t.pcsEncoding=c.PCSXYZ;break;case o.Lab:this.labInputAdaptation?(this.addStage(c.cmsLab,"stage_cmsLab_to_LabD50",this.stage_cmsLab_to_LabD50,null,c.LabD50," [Input2Device : Lab : {name}]| ({last}) > ({data})"),this.addStage(c.LabD50,"stage_LabD50_to_PCSv4",this.stage_LabD50_to_PCSv4,null,c.PCSv4," [Input2Device : Lab : {name}]|({last}) > ({data})")):this.addStage(c.cmsLab,"stage_LabD50_to_PCSv4",this.stage_LabD50_to_PCSv4,null,c.PCSv4," [Input2Device : Lab : {name}]|({last}) > ({data})"),t.pcsEncoding=c.PCSv4;break;case o.RGBMatrix:switch(t.pcsEncoding=c.device,this.dataFormat){case"object":case"objectFloat":this.addStage(c.cmsLab,"stage_RGB_to_Device",this.stage_RGB_to_Device,null,t.pcsEncoding," [Input2Device : RGBMatrix : {name}]|({last}) > ({data})");break;case"int8":this.addStage(c.cmsLab,"stage_Int_to_Device",this.stage_Int_to_Device,255,t.pcsEncoding," [int8 to Device : RGBMatrix : {name}]|({last}) > ({data})");break;case"int16":this.addStage(c.cmsLab,"stage_Int_to_Device",this.stage_Int_to_Device,65535,t.pcsEncoding," [int16 to Device : RGBMatrix : {name}]|({last}) > ({data})")}break;case o.Gray:switch(t.pcsEncoding=c.device,this.dataFormat){case"object":case"objectFloat":this.addStage(c.cmsRGB,"stage_Gray_to_Device",this.stage_Gray_to_Device,null,t.pcsEncoding," [Input2Device : Gray : {name}]|({last}) > ({data})");break;case"int8":this.addStage(c.cmsLab,"stage_Int_to_Device",this.stage_Int_to_Device,255,t.pcsEncoding," [in8 2Device : Gray : {name}]|({last}) > ({data})");break;case"int16":this.addStage(c.cmsLab,"stage_Int_to_Device",this.stage_Int_to_Device,65535,t.pcsEncoding," [in16 2Device : Gray : {name}]|({last}) > ({data})")}break;case o.Duo:switch(t.pcsEncoding=c.device,this.dataFormat){case"object":case"objectFloat":this.addStage(c.cmsRGB,"stage_Duo_to_Device",this.stage_Duo_to_Device,null,t.pcsEncoding," [Input2Device : Duo : {name}]|({last}) > ({data})");break;case"int8":this.addStage(c.cmsLab,"stage_Int_to_Device",this.stage_Int_to_Device,255,t.pcsEncoding," [in8 2Device : Duo : {name}]|({last}) > ({data})");break;case"int16":this.addStage(c.cmsLab,"stage_Int_to_Device",this.stage_Int_to_Device,65535,t.pcsEncoding," [in16 2Device : Duo : {name}]|({last}) > ({data})")}break;case o.RGBLut:switch(t.pcsEncoding=c.device,this.dataFormat){case"object":case"objectFloat":this.addStage(c.cmsRGB,"stage_RGB_to_Device",this.stage_RGB_to_Device,null,t.pcsEncoding," [Input2Device : RGBLut : {name}]|({last}) > ({data})");break;case"int8":this.addStage(c.cmsLab,"stage_Int_to_Device",this.stage_Int_to_Device,255,t.pcsEncoding," [in8 2Device : RGBLut : {name}]|({last}) > ({data})");break;case"int16":this.addStage(c.cmsLab,"stage_Int_to_Device",this.stage_Int_to_Device,65535,t.pcsEncoding," [in16 2Device : RGBLut : {name}]|({last}) > ({data})")}break;case o.CMYK:switch(t.pcsEncoding=c.device,this.dataFormat){case"object":case"objectFloat":this.addStage(c.cmsCMYK,"stage_CMYK_to_Device",this.stage_CMYK_to_Device,null,t.pcsEncoding," [Input2Device : CMYK : {name}]|({last}) > ({data})");break;case"int8":this.addStage(c.cmsCMYK,"stage_Int_to_Device",this.stage_Int_to_Device,255,t.pcsEncoding," [in8 2Device : CMYK : {name}]|({last}) > ({data})");break;case"int16":this.addStage(c.cmsCMYK,"stage_Int_to_Device",this.stage_Int_to_Device,65535,t.pcsEncoding," [in16 2Device : CMYK : {name}]|({last}) > ({data})")}}}getProfileChannels(t){switch(t.type){case o.Gray:return 1;case o.Duo:return 2;case o.XYZ:case o.Lab:case o.RGBMatrix:case o.RGBLut:return 3;case o.CMYK:return 4}throw"Unknown profile type "+t.type+"in getProfileChannels"}getInput2DevicePCSInfo(t){switch(t.type){case o.Lab:return c.PCSv4;case o.XYZ:return c.PCSXYZ;case o.Gray:case o.Duo:case o.RGBMatrix:case o.RGBLut:case o.CMYK:return c.device}throw"Unknown profile type "+profile.type+"in getInput2DevicePCSInfo"}getDevice2OutputPCSInfo(t){switch(t.type){case o.Lab:return 2===t.version?c.PCSv2:c.PCSv4;case o.XYZ:return c.PCSXYZ;case o.Gray:case o.Duo:case o.RGBMatrix:case o.RGBLut:case o.CMYK:return c.device}throw"Unknown profile type "+profile.type+"in getDevice2OutputPCSInfo"}isGreyTRCwithNOLUT(t,e){return t.Gray.kTRC&&!t.A2B[this.intent2LUTIndex(e)]}insertCustomStage(t,e,a){if(this.customStages&&this.customStages.length>0)for(var i=0;i<this.customStages.length;i++){var r=this.customStages[i];r.location===t&&this.addStage(e.pcsEncoding,"Custom:"+r.description,r.stageFn,r.stageData,e.pcsEncoding),!1!==a&&r.location+"("+a+")"===t&&this.addStage(e.pcsEncoding,"Custom:"+r.description,r.stageFn,r.stageData,e.pcsEncoding)}}createPipeline_chromaticAdaptation(t,e,a){this.displayChromaticAdaptation&&(r.compareWhitePoints(e.mediaWhitePoint,a.mediaWhitePoint)||(this.pipeline_Convert_PCS_to(t,c.PCSXYZ),this.addStage(c.PCSXYZ,"stage_ChromaticAdaptation",this.stage_chromaticAdaptation,{inputWhitePoint:e.mediaWhitePoint,outputWhitePoint:a.mediaWhitePoint},c.PCSXYZ," [ChromaticAdaptation : {name}]|({last}) > ({data})")))}createPipeline_BlackPointCompensation(t,e,a,i){if(a.type!==o.Duo&&e.type!==o.Duo&&(e.type!==o.RGBMatrix||a.type!==o.RGBMatrix)){var r=this.detectBlackpoint(e,i),n=this.detectOutputBlackpoint(a,i);if(!1!==r&&!1!==n&&(r.X!==n.X||r.Y!==n.Y||r.Z!==n.Z)){var s,h,u,l,p,d,m,g,_;this.pipeline_Convert_PCS_to(t,c.PCSXYZ),m=r.X-.9642,g=r.Y-1,_=r.Z-.8249;var v={scale:{X:s=(n.X-.9642)/m,Y:h=(n.Y-1)/g,Z:u=(n.Z-.8249)/_},offset:{X:l=-.9642*(n.X-r.X)/m,Y:p=-1*(n.Y-r.Y)/g,Z:d=-.8249*(n.Z-r.Z)/_}};if(this.pipelineDebug){var f=this.debugHistoryDecimals;this.addStage(c.PCSXYZ,"Black Point Info:",this.stage_history,"NaN scale.ax = "+s.toFixed(f)+" scale.ay = "+h.toFixed(f)+" scale.az = "+u.toFixed(f)+" offset.bx = "+l.toFixed(f)+" offset.by = "+p.toFixed(f)+" offset.bz = "+d.toFixed(f),c.PCSXYZ,"")}this.addStage(c.PCSXYZ,"stage_BPC",this.stage_ApplyBPCScale_PCSXYZ_to_PCSXYZ,v,c.PCSXYZ," [BPC : ApplyBPCScale : {name}]| ({last}) > {data}"),t.pcsEncoding=c.PCSXYZ,this.usesBPC=!0}}}createPipeline_Device_to_PCS(t,e,a,i){switch(e.type){case o.Lab:this.createPipeline_Device_to_PCS_via_Lab(t,e);break;case o.RGBMatrix:this.createPipeline_Device_to_PCS_via_RGBMatrix(t,e,a);break;case o.Gray:if(this.isGreyTRCwithNOLUT(e,i))return void this.createPipeline_Gray_to_PCS(t,e,a,i);case o.Duo:case o.RGBLut:case o.CMYK:2===e.version?this.createPipeline_Device_to_PCS_via_V2Lut(t,e,a,i):this.createPipeline_Device_to_PCS_via_V4Lut(t,e,a,i);break;default:throw"Unknown profile type "+e.type+"in createPipeline_Device_to_PCS"}return"XYZ"===e.pcs&&t.pcsEncoding===c.PCSXYZ&&(this.addStage(c.PCSXYZ,"stage_PCSXYZ_to_PCSv4",this.stage_PCSXYZ_to_PCSv4,null,c.PCSv4," [PCSv4_to_Device : XYZ : {name}]|({last}) > ({data})"),t.pcsEncoding=c.PCSv4),t}createPipeline_Device_to_PCS_via_Lab(t,e){switch(e.pcs){case"XYZ":this.pipeline_Convert_PCS_to(t,c.PCSXYZ);break;case"LAB":this.pipeline_Convert_PCS_to(t,c.PCSv4);break;default:throw"Unknown PCS "+e.pcs+" in createPipeline_Device_to_PCS_via_Lab"}}createPipeline_Device_to_PCS_via_RGBMatrix(t,e){if(t.pcsEncoding!==c.device)throw"Device to PSC RGBMatrix expects device encoding";if(this._expandRGBStages){var a=e.RGBMatrix.XYZMatrix,i=r.matrixScaleValues(a,.5000076295109483);e.rgb.rTRC&&e.rgb.rTRC.use?this.addStage(c.device,"stage_curves_v4",this.stage_curves_v4,[e.rgb.rTRC,e.rgb.gTRC,e.rgb.bTRC],c.device," *[optimised : {name}]|({last}) > ({data})",!0):this.addStage(c.device,"stage_Gamma_Inverse",this.stage_Gamma_Inverse,e.RGBMatrix,c.device," *[optimised : {name}]|({last}) > ({data})",!0),this.addStage(c.device,"stage_matrix_rgb",this.stage_matrix_rgb,i,c.PCSXYZ," *[optimised : {name}]|({last}) > ({data})",!0),t.pcsEncoding=c.PCSXYZ}else this.addStage(c.device,"stage_RGBDevice_to_PCSv4",this.stage_RGBDevice_to_PCSv4,e,c.PCSXYZ," [DevicetoPCS : RGBMatrix : {name}]|({last}) > ({data})"),t.pcsEncoding=c.PCSXYZ}createPipeline_Device_to_PCS_via_V2Lut(t,e,a,i){if(t.pcsEncoding!==c.device)throw console.log(this.getStageNames(!0)),"createPipeline_Version2_CH4toPCSv4: expects device encoding not "+l[t.pcsEncoding];var r=e.A2B[this.intent2LUTIndex(i)];switch(this.addStage(c.device,"stage_curve_v2",this.stage_curve_v2,r.inputCurve,c.device," [V2_Device_to_PCSv4 : {name}]| ({last}) > ({data})"),"XYZ"===e.pcs?t.pcsEncoding=c.PCSXYZ:t.pcsEncoding=2===e.PCSDecode?c.PCSv2:c.PCSv4,r.inputChannels){case 1:case 2:case 3:case 4:this.addStageLUT(!1,c.device,r,t.pcsEncoding," [V2_Device_to_PCSv4 : {name}]|({last}) > ({data})");break;default:throw"UnSupported number of Input Channels "+r.inputChannels}this.addStage(t.pcsEncoding,"stage_curve_v2",this.stage_curve_v2,r.outputCurve,t.pcsEncoding," [V2_Device_to_PCSv4 : {name}]|({last}) > ({data}) ({data:f>16})"),this.createPipeline_Absolute_Adaptation_Input(t,e,i)}createPipeline_Device_to_PCS_via_V4Lut(t,e,a,i){if(t.pcsEncoding!==c.device)throw console.log(this.getStageNames(!0)),"V4_CH4_to_PCSv4: expects device encoding not "+l[t.pcsEncoding];var r=e.A2B[this.intent2LUTIndex(i)];if(!r)throw"No LUT in createPipeline_Device_to_PCS_via_V4Lut for the intent "+i;if(!1===r.aCurves||this.isPassThrough(r.aCurves)||this.addStage(c.device,"stage_curves_v4",this.stage_curves_v4,r.aCurves,c.device," [V4_Device_to_PCSv4 : aCurves : {name}]|({last}) > ({data}) ({data:f>16})"),"XYZ"===e.pcs?t.pcsEncoding=c.PCSXYZ:t.pcsEncoding=c.PCSv4,!1!==r.CLUT4)switch(r.inputChannels){case 1:case 2:case 3:case 4:this.addStageLUT(!1,c.device,r,t.pcsEncoding," [V4_Device_to_PCSv4 : {name}]|({last}) > ({data})");break;default:throw"Unsupported number of Output Channels"}!1===r.mCurves||this.isPassThrough(r.mCurves)||this.addStage(t.pcsEncoding,"stage_curves_v4",this.stage_curves_v4,r.mCurves,t.pcsEncoding," [V4_Device_to_PCSv4 : mCurves : {name}]|({last}) > ({data}) ({data:f>16})"),!1!==r.matrix&&(this.isIdentityMatrix(r.matrix)||this.addStage(t.pcsEncoding,"stage_Matrix",this.matrixHasOffsets(r.matrix)?this.stage_matrix_v4:this.stage_matrix_v4_noOffsets,r.matrix,t.pcsEncoding," [V4_Device_to_PCSv4 : Matrix : {name}]|({last}) > ({data}) ({data:f>16})")),!1===r.bCurves||this.isPassThrough(r.bCurves)||this.addStage(t.pcsEncoding,"stage_curves_v4",this.stage_curves_v4,r.bCurves,t.pcsEncoding," [V4_Device_to_PCSv4 : bCurves : {name}]|({last}) > ({data}) ({data:f>16})"),this.createPipeline_Absolute_Adaptation_Input(t,e,i)}createPipeline_Gray_to_PCS(t,e,a,i){if(t.pcsEncoding!==c.device)throw console.log(this.getStageNames(!0)),"Gray_to_PCSv4: expects device encoding not "+l[t.pcsEncoding];"XYZ"===e.pcs?(this.addStage(c.device,"stage_grayTRC_to_PCSXYZ_Via_Y",this.stage_grayTRC_to_PCSXYZ_Via_Y,[e.Gray.kTRC],c.PCSXYZ," [Gray_to_PCSv4 : {name}]|({last}) > ({data}) ({data:f>16})"),i===s.absolute&&this.addStage(c.PCSXYZ,"stage_absoluteAdaptationIn_PCSXYZ_to_PCSXYZ",this.stage_absoluteAdaptationIn_PCSXYZ_to_PCSXYZ,e,c.PCSXYZ," [Gray_to_PCSv4 : {name}]|({last}) > ({data}) ({data:f>16})"),t.pcsEncoding=c.PCSXYZ):(this.addStage(c.device,"stage_curves_v4",this.stage_grayTRC_to_PCSV4_Via_L,[e.Gray.kTRC],c.PCSv4," [Gray_to_PCSv4 : {name}]|({last}) > ({data}) ({data:f>16})"),t.pcsEncoding=c.PCSv4,this.createPipeline_Absolute_Adaptation_Input(t,e,i))}isPassThrough(t){for(var e=!0,a=0;a<t.length;a++)e=e&&t[a].passThrough;return e}createPipeline_PCS_to_Device(t,e,a,i){if(t.pcsEncoding===c.PCSv4&&t.pcsEncoding===c.PCSXYZ)throw console.log(this.getStageNames(!0)),"createPipeline_PCS_to_Device: expects PCSv4 or PCSXYZ not "+l[t.pcsEncoding];switch(a.type){case o.Lab:return void this.createPipeline_PCS_to_Lab(t);case o.RGBMatrix:return void this.createPipeline_PCS_to_Device_via_RGBMatrix(t,e,a);case o.Gray:if(this.isGreyTRCwithNOLUT(a,i))return void this.createPipeline_PCS_to_Gray_via_kTRC(t,e,a,i);case o.Duo:case o.RGBLut:case o.CMYK:return 2===a.version?void this.createPipeline_PCS_to_Device_via_V2LUT(t,e,a,i):void this.createPipeline_PCS_to_Device_via_V4LUT(t,e,a,i);default:throw"Unknown profile type "+a.type+"in createPipeline_PCS_to_Device"}}createPipeline_PCS_to_Lab(t){this.pipeline_Convert_PCS_to(t,c.PCSv4)}createPipeline_PCS_to_Device_via_RGBMatrix(t,e,a){if(this._expandRGBStages){var i=a.RGBMatrix.XYZMatrixInv,n=r.matrixScaleValues(i,1.999969482421875);this.pipeline_Convert_PCS_to(t,c.PCSXYZ),this.addStage(c.PCSXYZ,"stage_matrix_rgb",this.stage_matrix_rgb,n,c.device," *[PCS_to_RGBDevice : {name}]|({last}) > ({data})",!0),a.rgb.rTRCInv&&a.rgb.rTRCInv.use?this.addStage(c.device,"stage_curves_v4",this.stage_curves_v4,[a.rgb.rTRCInv,a.rgb.gTRCInv,a.rgb.bTRCInv],c.device," *[optimised : {name}]|({last}) > ({data})",!0):this.addStage(c.device,"stage_Gamma",this.stage_Gamma,a.RGBMatrix,c.device," *[optimised : {name}]|({last}) > ({data})",!0)}else this.pipeline_Convert_PCS_to(t,c.PCSv4),this.addStage(c.PCSv4,"stage_PCSv4_to_RGBDevice",this.stage_PCSv4_to_RGBDevice,a,c.device," [PCS_to_RGBDevice : {name}]|({last}) > ({data})");t.pcsEncoding=c.device}createPipeline_PCS_to_Device_via_V4LUT(t,e,a,i){this.createPipeline_Absolute_Adaptation_Output_Any_to_PCSv4(t,a,i);var r=a.B2A[this.intent2LUTIndex(i)];this.pipelineConvert_PCSV4_to_OutputProfile_PCS(t,r,a),!1===r.bCurves||this.isPassThrough(r.bCurves)||this.addStage(t.pcsEncoding,"stage_curves_v4",this.stage_curves_v4,r.bCurves,t.pcsEncoding," [PCSv4_to_Device_via_V4LUT : bCurves : {name}]|({last}) > ({data}) ({data:f>16})"),!1!==r.matrix&&(this.isIdentityMatrix(r.matrix)||this.addStage(t.pcsEncoding,"stage_Matrix",this.matrixHasOffsets(r.matrix)?this.stage_matrix_v4:this.stage_matrix_v4_noOffsets,r.matrix,t.pcsEncoding," [PCSv4_to_Device_via_V4LUT : Matrix : {name}]|({last}) > ({data}) ({data:f>16})")),!1===r.mCurves||this.isPassThrough(r.mCurves)||this.addStage(t.pcsEncoding,"stage_curves_v4",this.stage_curves_v4,r.mCurves,t.pcsEncoding," [PCSv4_to_Device_via_V4LUT : mCurves : {name}]|({last}) > ({data}) ({data:f>16})"),!1!==r.CLUT4?this.addStageLUT(!0,t.pcsEncoding,r,c.device," [PCSv4_to_Device_via_V4LUT : LUT : {name}]|({last}) > ({data})"):t.pcsEncoding=c.device,!1===r.aCurves||this.isPassThrough(r.aCurves)||this.addStage(c.device,"stage_curves_v4",this.stage_curves_v4,r.aCurves,c.device," [PCSv4_to_Device_via_V4LUT : aCurves : {name}]|({last}) > ({data}) ({data:f>16})"),t.pcsEncoding=c.device}isIdentityMatrix(t){return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&1===t[4]&&0===t[5]&&0===t[6]&&0===t[7]&&1===t[8]&&0===t[9]&&0===t[10]&&0===t[11]}matrixHasOffsets(t){return 0!==t[9]||0!==t[10]||0!==t[11]}createPipeline_PCS_to_Device_via_V2LUT(t,e,a,i){this.createPipeline_Absolute_Adaptation_Output_Any_to_PCSv4(t,a,i);var r=a.B2A[this.intent2LUTIndex(i)];if(this.pipelineConvert_PCSV4_to_OutputProfile_PCS(t,r,a),t.pcsEncoding!==c.PCSv2&&t.pcsEncoding!==c.PCSXYZ)throw console.log(this.getStageNames(!0)),"createPipeline_PCS_to_Device_via_V2LUT: expects PCSv2 or PCSXYZ not "+l[t.pcsEncoding];this.addStage(t.pcsEncoding,"stage_curve_v2",this.stage_curve_v2,r.inputCurve,t.pcsEncoding," [PCSv4_to_Device_via_V2LUT : {name}]| ({last}) > ({data})"),this.addStageLUT(!0,t.pcsEncoding,r,c.device," [PCSv4_to_Device_via_V2LUT : {name}]|({last}) > ({data})"),t.pcsEncoding=c.device,this.addStage(c.device,"stage_curve_v2",this.stage_curve_v2,r.outputCurve,t.pcsEncoding," [PCSv4_to_Device_via_V2LUT : {name}]|({last}) > ({data}) ({data:f>16})")}createPipeline_PCS_to_Gray_via_kTRC(t,e,a,i){if(t.pcsEncoding!==c.PCSv2&&t.pcsEncoding!==c.PCSv4&&t.pcsEncoding!==c.PCSXYZ)throw console.log(this.getStageNames(!0)),"PCSv4_to_Gray: expects PCSv2,PCSv4,PCSXYZ encoding not "+l[t.pcsEncoding];"XYZ"===a.pcs?(this.pipeline_Convert_PCS_to(t,c.PCSXYZ),i===s.absolute&&this.addStage(c.PCSXYZ,"stage_absoluteAdaptationOut_PCSXYZ_to_PCSXYZ",this.stage_absoluteAdaptationOut_PCSXYZ_to_PCSXYZ,a,c.PCSXYZ," [PCSv4_to_Gray : {name}]|({last}) > ({data})"),this.addStage(c.PCSXYZ,"stage_PCSXYZ_to_grayTRC_via_Y",this.stage_PCSXYZ_to_grayTRC_via_Y,[a.Gray.inv_kTRC],c.device," [PCSv4_to_Gray : {name}]|({last}) > ({data}) ({data:f>16})"),t.pcsEncoding=c.device):(this.createPipeline_Absolute_Adaptation_Output_Any_to_PCSv4(t,a,i),this.addStage(t.pcsEncoding,"stage_PCSV4_to_grayTRC_via_L",this.stage_PCSV4_to_grayTRC_via_L,[a.Gray.inv_kTRC],c.device," [PCSv4_to_Gray : {name}]|({last}) > ({data}) ({data:f>16})"),t.pcsEncoding=c.device)}createPipeline_Absolute_Adaptation_Input(t,e,a){a===s.absolute&&(this.pipeline_Convert_PCS_to(t,c.PCSXYZ),this.pipelineDebug&&this.addStage(c.PCSXYZ,"Input_Absolute_Adaptation:",this.stage_history," [Input_Absolute_Adaptation] .................................. Xa = "+e.absoluteAdaptationIn.Xa+", Ya = "+e.absoluteAdaptationIn.Ya+", Za = "+e.absoluteAdaptationIn.Za,c.PCSXYZ,""),this.usesAdaptation=!0,this.addStage(c.PCSXYZ,"stage_absoluteAdaptationIn_PCSXYZ_to_PCSXYZ",this.stage_absoluteAdaptationIn_PCSXYZ_to_PCSXYZ,e,c.PCSXYZ," [InputAdaptation : {name}]| ({last}) > ({data})"),t.pcsEncoding=c.PCSXYZ)}createPipeline_Absolute_Adaptation_Output_Any_to_PCSv4(t,e,a){if(a===s.absolute){if(t.pcsEncoding!==c.PCSv2&&t.pcsEncoding!==c.PCSv4&&t.pcsEncoding!==c.PCSXYZ)throw"createPipeline_Absolute_Adaptation_Output_Any_to_PCSv4, Encoding must be PCSXYZ, PCSv2 or PVCSv4 not "+l[t.pcsEncoding];this.pipeline_Convert_PCS_to(t,c.PCSXYZ),this.pipelineDebug&&this.addStage(c.PCSXYZ,"Output_Absolute_Adaptation:",this.stage_history,"NaNXa = "+e.absoluteAdaptationOut.Xa+", Ya = "+e.absoluteAdaptationOut.Ya+", Za = "+e.absoluteAdaptationOut.Za,c.PCSXYZ,""),this.usesAdaptation=!0,this.addStage(c.PCSXYZ,"stage_absoluteAdaptationOut_PCSXYZ_to_PCSXYZ",this.stage_absoluteAdaptationOut_PCSXYZ_to_PCSXYZ,e,c.PCSXYZ," [OutputAdaptation : {name}]| ({last}) > ({data})"),this.addStage(c.PCSXYZ,"stage_PCSXYZ_to_PCSv4",this.stage_PCSXYZ_to_PCSv4,null,c.PCSv4," [OutputAdaptation : {name}]| ({last}) > ({data})"),t.pcsEncoding=c.PCSv4}}pipeline_Convert_PCS_to(t,e){var a=this.createConvert_PCS_stage(t,e);a&&this.pushStage(a)}createConvert_PCS_stage(t,e){switch(e){case c.PCSXYZ:switch(t.pcsEncoding){case c.PCSv2:return t.pcsEncoding=c.PCSXYZ,this.createStage(c.PCSv2,"stage_PCSv2_to_PCSXYZ",this.stage_PCSv2_to_PCSXYZ,null,c.PCSXYZ," [Convert PCS : stage_PCSv2_to_PCSXYZ] ({last}) > ({data})");case c.PCSv4:return t.pcsEncoding=c.PCSXYZ,this.createStage(c.PCSv4,"stage_PCSv4_to_PCSXYZ",this.stage_PCSv4_to_PCSXYZ,null,c.PCSXYZ," [Convert PCS : stage_PCSv4_to_PCSXYZ] ({last}) > ({data})");case c.PCSXYZ:return!1;default:throw"pipelineConvert_PCSV4_to_OutputProfile_PCS, unexpected XYZ encoding "+l[t.pcsEncoding]}case c.PCSv2:switch(t.pcsEncoding){case c.PCSv2:return!1;case c.PCSv4:return t.pcsEncoding=c.PCSv2,this.createStage(c.PCSv4,"stage_PCSv4_to_PCSv2",this.stage_PCSv4_to_PCSv2,null,t.pcsEncoding," [Convert PCS : {name}] ({last}) > ({data})");case c.PCSXYZ:return t.pcsEncoding=c.PCSv2,this.createStage(c.PCSXYZ,"stage_PCSXYZ_to_PCSv2",this.stage_PCSXYZ_to_PCSv2,null,c.PCSv2," [Convert PCS : {name}] ({last}) > ({data})");default:throw"CheckPCSVersion, Unexpected LAB Encoding "+l[t.pcsEncoding]}case c.PCSv4:switch(t.pcsEncoding){case c.PCSXYZ:return t.pcsEncoding=c.PCSv4,this.createStage(c.PCSXYZ,"stage_PCSXYZ_to_PCSv4",this.stage_PCSXYZ_to_PCSv4,null,c.PCSv4," [Convert PCS : {name}] ({last}) > ({data})");case c.PCSv2:return t.pcsEncoding=c.PCSv4,this.createStage(c.PCSv2,"stage_PCSv2_to_PCSv4",this.stage_PCSv2_to_PCSv4,null,c.PCSv4," [Convert PCS : {name}] ({last}) > ({data})");case c.PCSv4:return!1;default:throw"Convert PCS, Unexpected LAB Encoding "+l[t.pcsEncoding]}default:throw"pipelineConvert_PCS, unexpected destination PCS encoding "+l[e]}}pipelineConvert_PCSV4_to_OutputProfile_PCS(t,e,a){var i;switch(a.pcs){case"XYZ":this.pipeline_Convert_PCS_to(t,c.PCSXYZ);break;case"LAB":switch(a.version){case 2:8===e.precision?(i=this.createConvert_PCS_stage(t,c.PCSv4))?(t.pcsEncoding=c.PCSv2,i.outputEncoding=c.PCSv2):(t.pcsEncoding=c.PCSv2,this.addStage(c.PCSv4,"stage_null",this.stage_null,null,t.pcsEncoding," [CheckPCSVersion : {name}] ({last}) > ({data})")):i=this.createConvert_PCS_stage(t,c.PCSv2),i&&this.pushStage(i);break;case 4:this.pipeline_Convert_PCS_to(t,c.PCSv4);break;default:throw"pipelineConvert_PCSV4_to_OutputProfile_PCS, unexpected profile version "+a.version}}}createPipeline_Device_to_Output(t,e){var a,i;if("int8"===this.dataFormat||"int16"===this.dataFormat){switch(e.outputChannels){case 1:a=this.stage_device1_to_int,i="[stage_device1_to_int "+this.dataFormat+" : {name}]| ({last}) > {data}";break;case 2:a=this.stage_device2_to_int,i="[stage_device2_to_int "+this.dataFormat+" : {name}]| ({last}) > {data}";break;case 3:a=this.stage_device3_to_int,i="[stage_device3_to_int "+this.dataFormat+" : {name}]| ({last}) > {data}";break;case 4:a=this.stage_device4_to_int,i="[stage_device4_to_int "+this.dataFormat+" : {name}]| ({last}) > {data}";break;default:a=this.stage_deviceN_to_int,i="[stage_deviceN_to_int "+this.dataFormat+" : {name}]| ({last}) > {data}"}var r="int8"===this.dataFormat?255:65535}switch(e.type){case o.Gray:if(t.pcsEncoding!==c.device)throw console.log(this.getStageNames(!0)),"[Device2Output: Gray ] Input must be Device not "+l[t.pcsEncoding];switch(this.dataFormat){case"object":this.addStage(c.device,(this.roundOutput,"stage_device_to_Gray"),this.roundOutput?this.stage_device_to_Gray_round:this.stage_device_to_Gray,this.precession,c.cmsRGB," [Device2Output : Gray : {name}]| ({last}) > {data}");break;case"objectFloat":this.addStage(c.device,"stage_device_to_Grayf",this.stage_device_to_Grayf,this.precession,c.cmsRGB," [Device2Output : Gray : {name}]| ({last}) > {data}");break;case"int8":case"int16":this.addStage(c.device,"stage_device_to_int",a,r,c.device,i)}break;case o.Duo:if(t.pcsEncoding!==c.device)throw console.log(this.getStageNames(!0)),"[Device2Output: Duo ] Input must be Device not "+l[t.pcsEncoding];switch(this.dataFormat){case"object":this.addStage(c.device,(this.roundOutput,"stage_device_to_Duo"),this.roundOutput?this.stage_device_to_Duo_round:this.stage_device_to_Duo,this.precession,c.cmsRGB," [Device2Output : Duo : {name}]| ({last}) > {data}");break;case"objectFloat":this.addStage(c.device,"stage_device_to_Duof",this.stage_device_to_Duof,this.precession,c.cmsRGB," [Device2Output : Duo : {name}]| ({last}) > {data}");break;case"int8":case"int16":this.addStage(c.device,"stage_device_to_int",a,r,c.device,i)}break;case o.Lab:if(t.pcsEncoding!==c.PCSv2&&t.pcsEncoding!==c.PCSv4)throw console.log(this.getStageNames(!0)),"[Device2Output: Lab ] Input must be PCS/V2 or PCS/V4 not "+l[t.pcsEncoding];switch(this.dataFormat){case"object":case"objectFloat":t.pcsEncoding===c.PCSv2?this.addStage(c.PCSv2,"stage_PCSv2_to_cmsLab",this.stage_PCSv2_to_cmsLab,null,c.cmsLab," [Device2Output : Lab : {name}]|({last:r}) / ({last}) > {data}"):this.addStage(c.PCSv4,"stage_PCSv4_to_cmsLab",this.stage_PCSv4_to_cmsLab,null,c.cmsLab," [Device2Output : Lab : {name}]| ({last}) > {data}");break;case"int8":case"int16":this.addStage(t.pcsEncoding,"stage_device_to_int",a,r,c.device,i)}break;case o.RGBMatrix:case o.RGBLut:if(t.pcsEncoding!==c.device)throw console.log(this.getStageNames(!0)),"[Device2Output: RGB ] Input must be Device not "+l[t.pcsEncoding];switch(this.dataFormat){case"object":this.addStage(c.device,(this.roundOutput,"stage_device_to_RGB"),this.roundOutput?this.stage_device_to_RGB_round:this.stage_device_to_RGB,this.precession,c.cmsRGB," [Device2Output : RGB : {name}]| ({last}) > {data}");break;case"objectFloat":this.addStage(c.device,"stage_device_to_RGBf",this.stage_device_to_RGBf,this.precession,c.cmsRGB," [Device2Output : RGB : {name}]| ({last}) > {data}");break;case"int8":case"int16":this.addStage(c.device,"stage_device_to_int",a,r,c.device,i)}break;case o.CMYK:if(t.pcsEncoding!==c.device)throw console.log(this.getStageNames(!0)),"[Device2Output: CMYK ] Input must be Device not "+l[t.pcsEncoding];switch(this.dataFormat){case"object":this.addStage(c.device,(this.roundOutput,"stage_device_to_CMYK"),this.roundOutput?this.stage_device_to_CMYK_round:this.stage_device_to_CMYK,this.precession,c.cmsCMYK," [Device2Output : CMYK : {name}]| ({last}) > {data}");break;case"objectFloat":this.addStage(c.device,"stage_device_to_CMYKf",this.stage_device_to_CMYKf,this.precession,c.cmsCMYK," [Device2Output : CMYK : {name}]| ({last}) > {data}");break;case"int8":case"int16":this.addStage(c.device,"stage_device_to_int",a,r,c.device,i)}}}addStageLUT(t,e,a,i,r){switch(a.inputChannels){case 1:this.addStage(e,"linearInterp1D",this.linearInterp1D_NCh,a,i,r);break;case 2:this.addStage(e,"bilinearInterp2D",this.bilinearInterp2D_NCh,a,i,r);break;case 3:var n=!t||e!==c.PCSv4&&e!==c.PCSv2?this.interpolation3D:"trilinear";switch(n){case"tetrahedral":if(this.interpolationFast){switch(a.outputChannels){case 3:this.addStage(e,"tetrahedralInterp3D",this.tetrahedralInterp3D_3Ch,a,i,r);break;case 4:this.addStage(e,"tetrahedralInterp3D",this.tetrahedralInterp3D_4Ch,a,i,r);break;default:this.addStage(e,"tetrahedralInterp3D",this.tetrahedralInterp3D_NCh,a,i,r)}break}this.addStage(e,"tetrahedralInterp3D",this.tetrahedralInterp3D_3or4Ch,a,i,r);break;case"trilinear":a.outputChannels,this.addStage(e,"trilinearInterp3D",this.trilinearInterp3D_NCh,a,i,r);break;default:throw'Unknown 3D interpolation method "'+n+'"'}break;case 4:switch(this.interpolation4D){case"tetrahedral":if(this.interpolationFast)switch(a.outputChannels){case 3:this.addStage(e,"tetrahedralInterp4D",this.tetrahedralInterp4D_3Ch,a,i,r);break;case 4:this.addStage(e,"tetrahedralInterp4D",this.tetrahedralInterp4D_4Ch,a,i,r);break;default:this.addStage(e,"tetrahedralInterp4D",this.tetrahedralInterp4D_NCh,a,i,r)}else this.addStage(e,"tetrahedralInterp4D",this.tetrahedralInterp4D_3or4Ch,a,i,r);break;case"trilinear":this.addStage(e,"trilinearInterp4D",this.trilinearInterp4D_3or4Ch,a,i,r);break;default:throw'Unknown 4D interpolation method "'+this.interpolation4D+'"'}break;default:throw'Unsupported number of input channels "'+a.inputChannels+'"'}}pushStage(t){this.pipeline.push(t)}addStage(t,e,a,i,r,n){this.pushStage(this.createStage(t,e,a,i,r,n,!1))}createStage(t,e,a,i,r,n,s){return{inputEncoding:t,funct:a,stageData:i,outputEncoding:r,stageName:e,debugFormat:n=n||"",optimised:s}}stage_debug(t,e){return this.addDebugHistory(e,"stage_debug",null,t),t}addDebugHistory(t,e,a,i){t.indexOf("{name}")>=0&&(t=t.replace("{name}",e));for(var r=t.split("{"),n=1;n<r.length;n++){var s=r[n].split("}"),o=s[0].split(":");switch(o[0].toLowerCase()){case"last":s[0]=m(a,o[1],this.debugHistoryDecimals);break;case"data":s[0]=m(i,o[1],this.debugHistoryDecimals)}r[n]=s.join("")}this.debugHistory.push(r.join(""))}stage_null(t){return t}stage_history(t,e){return this.debugHistory.push(e),t}stage_device_to_Gray(t){return{G:255*t[0],type:h.Gray}}stage_device_to_Grayf(t){return{Gf:t[0],type:h.Grayf}}stage_device_to_Gray_round(t,e){return{G:d(255*t[0],e),type:h.Gray}}stage_Gray_to_Device(t){if(t.type===h.Gray)return[t.G/255];throw"stage_Gray_to_Device: cmsInput expects _cmsGray"}stage_device_to_Duo(t){return{a:100*t[0],b:100*t[1],type:h.Duo}}stage_device_to_Duof(t){return{af:t[0],bf:t[1],type:h.Duof}}stage_device_to_Duo_round(t,e){return{a:d(100*t[0],e),b:d(100*t[1],e),type:h.Duo}}stage_Duo_to_Device(t){if(t.type===h.Duo)return[t.a/100,t.b/100];if(t.type===h.Duof)return[t.af,t.bf];throw"stage_Duo_to_Device: cmsInput expects _cmsDuo"}stage_device_to_RGB(t){return{R:255*t[0],G:255*t[1],B:255*t[2],type:h.RGB}}stage_device_to_RGB_round(t,e){return{R:d(255*t[0],e),G:d(255*t[1],e),B:d(255*t[2],e),type:h.RGB}}stage_device_to_RGBf(t){return{Rf:t[0],Gf:t[1],Bf:t[2],type:h.RGBf}}stage_RGB_to_Device(t){if(t.type===h.RGB)return[t.R/255,t.G/255,t.B/255];if(t.type===h.RGBf)return[t.Rf,t.Gf,t.Bf];throw"InputtoPCS: cmsInput is not of type RGB or RGBf"}stage_device_to_CMYKf(t){return{Cf:t[0],Mf:t[1],Yf:t[2],Kf:t[3],type:h.CMYKf}}stage_device_to_CMYK(t){return{C:100*t[0],M:100*t[1],Y:100*t[2],K:100*t[3],type:h.CMYK}}stage_device_to_CMYK_round(t,e){return{C:d(100*t[0],e),M:d(100*t[1],e),Y:d(100*t[2],e),K:d(100*t[3],e),type:h.CMYK}}stage_CMYK_to_Device(t){if(t.type===h.CMYK)return[t.C/100,t.M/100,t.Y/100,t.K/100];if(t.type===h.CMYKf)return[t.Cf,t.Mf,t.Yf,t.Kf];throw"stage_CMYK_to_Device: cmsInput expects _cmsCMYK or _cmsCMYKf "}stage_device1_to_int(t,e){return[Math.round(t[0]*e)]}stage_device2_to_int(t,e){return[Math.round(t[0]*e),Math.round(t[1]*e)]}stage_device3_to_int(t,e){return[Math.round(t[0]*e),Math.round(t[1]*e),Math.round(t[2]*e)]}stage_device4_to_int(t,e){return[Math.round(t[0]*e),Math.round(t[1]*e),Math.round(t[2]*e),Math.round(t[3]*e)]}stage_deviceN_to_int(t,e){for(var a=new Array(t.length),i=0;i<t.length;i++)a[i]=Math.round(t[i]*e);return a}stage_Int_to_Device(t,e){return 3===t.length?[t[0]/e,t[1]/e,t[2]/e]:[t[0]/e,t[1]/e,t[2]/e,t[3]/e]}XYZ(t,e,a){return{type:h.XYZ,X:t,Y:e,Z:a}}Lab(t,e,a,i){return{type:h.Lab,L:t,a:e,b:a,whitePoint:i||u.d50}}XYZ2Lab(t,e){var a=.008856451679035631;e=e||u.d50;var i=t.X/e.X,r=t.Y/e.Y,n=t.Z/e.Z;return i=i<=a?841/108*i+16/116:Math.pow(i,1/3),{L:116*(r=r<=a?841/108*r+16/116:Math.pow(r,1/3))-16,a:500*(i-r),b:200*(r-(n=n<=a?841/108*n+16/116:Math.pow(n,1/3))),whitePoint:e,type:h.Lab}}Lab2XYZ(t,e){e=e||t.whitePoint||u.d50;var a=24/116,i=(t.L+16)/116,r=i+.002*t.a,n=i-.005*t.b;return{X:(r<=a?108/841*(r-16/116):r*r*r)*e.X,Y:(i<=a?108/841*(i-16/116):i*i*i)*e.Y,Z:(n<=a?108/841*(n-16/116):n*n*n)*e.Z,type:h.XYZ}}RGBDevice_to_PCSv4_or_LabD50(t,e,a,i){var n,s,o,h,c,l,p,d;if(e.rgb.rTRC&&e.rgb.rTRC.use?(l=(c=this.stage_curves_v4(t,[e.rgb.rTRC,e.rgb.rTRC,e.rgb.rTRC]))[0],p=c[1],d=c[2]):(l=Math.min(Math.max(t[0],0),1),p=Math.min(Math.max(t[1],0),1),d=Math.min(Math.max(t[2],0),1)),e.RGBMatrix.issRGB)n=r.sRGBGamma(l),s=r.sRGBGamma(p),o=r.sRGBGamma(d);else{var m=1/e.RGBMatrix.gamma;n=Math.pow(l,m),s=Math.pow(p,m),o=Math.pow(d,m)}var g={X:n*(h=i?e.RGBMatrix.matrixV4:e.RGBMatrix.XYZMatrix).m00+s*h.m01+o*h.m02,Y:n*h.m10+s*h.m11+o*h.m12,Z:n*h.m20+s*h.m21+o*h.m22};if(i){var _=this.d50;this.compareWhitePoints(_,e.mediaWhitePoint)||(g=r.adaptation(g,e.mediaWhitePoint,_))}if(a)return this.XYZ2Lab(g,u.d50);var v=this.XYZ2Lab(g,u.d50);return[v.L/100,(v.a+128)/255,(v.b+128)/255]}PCSv4_to_RGBDevice(t,e,a){var i,n,s,o,h=this.Lab2XYZ({L:100*t[0],a:255*t[1]-128,b:255*t[2]-128},u.d50);if(a){var c=u.d50;r.compareWhitePoints(c,e.mediaWhitePoint)||(h=r.adaptation(h,c,e.mediaWhitePoint)),o=e.RGBMatrix.matrixInv}else o=e.RGBMatrix.XYZMatrixInv;return i=h.X*o.m00+h.Y*o.m01+h.Z*o.m02,n=h.X*o.m10+h.Y*o.m11+h.Z*o.m12,s=h.X*o.m20+h.Y*o.m21+h.Z*o.m22,e.rgb.rTRCInv&&e.rgb.rTRCInv.use?this.stage_curves_v4([i,n,s],[e.rgb.rTRCInv,e.rgb.rTRCInv,e.rgb.rTRCInv]):(i=Math.min(Math.max(i,0),1),n=Math.min(Math.max(n,0),1),s=Math.min(Math.max(s,0),1),e.RGBMatrix.issRGB?[r.sRGBGammaInv(i),r.sRGBGammaInv(n),r.sRGBGammaInv(s)]:[Math.pow(i,e.RGBMatrix.gamma),Math.pow(n,e.RGBMatrix.gamma),Math.pow(s,e.RGBMatrix.gamma)])}RGBDevice_to_RGBDevice(t,e){var a,i,n,s,o,h,u,c;if(e.input.curvesInv){var l=this.stage_curves_v4(t,e.output.curvesInv);h=l[0],u=l[1],c=l[2]}else e.input.issRGB?(h=r.sRGBGammaInv(t[0]),u=r.sRGBGammaInv(t[1]),c=r.sRGBGammaInv(t[2])):(o=e.input.gamma,h=Math.pow(t[0],o),u=Math.pow(t[1],o),c=Math.pow(t[2],o));return a=h*(s=e.matrix).m00+u*s.m01+c*s.m02,i=h*s.m10+u*s.m11+c*s.m12,n=h*s.m20+u*s.m21+c*s.m22,a=Math.min(Math.max(a,0),1),i=Math.min(Math.max(i,0),1),n=Math.min(Math.max(n,0),1),e.output.curves?this.stage_curves_v4([a,i,n],e.output.curves):e.output.issRGB?[r.sRGBGamma(a),r.sRGBGamma(i),r.sRGBGamma(n)]:[Math.pow(a,1/e.output.gamma),Math.pow(i,1/e.output.gamma),Math.pow(n,1/e.output.gamma)]}stage_Gamma(t,e){var a=Math.min(Math.max(t[0],0),1),i=Math.min(Math.max(t[1],0),1),n=Math.min(Math.max(t[2],0),1);return e.issRGB?[r.sRGBGamma(a),r.sRGBGamma(i),r.sRGBGamma(n)]:[Math.pow(a,1/e.gamma),Math.pow(i,1/e.gamma),Math.pow(n,1/e.gamma)]}stage_Gamma_Inverse(t,e){var a=Math.min(Math.max(t[0],0),1),i=Math.min(Math.max(t[1],0),1),n=Math.min(Math.max(t[2],0),1);return e.issRGB?[r.sRGBGammaInv(a),r.sRGBGammaInv(i),r.sRGBGammaInv(n)]:[Math.pow(a,e.gamma),Math.pow(i,e.gamma),Math.pow(n,e.gamma)]}stage_matrix_rgb(t,e){var a,i,r;return a=t[0],i=t[1],r=t[2],[a*e.m00+i*e.m01+r*e.m02,a*e.m10+i*e.m11+r*e.m12,a*e.m20+i*e.m21+r*e.m22]}stage_chromaticAdaptation(t,e){var a=this.XYZ(1.999969482421875*t[0],1.999969482421875*t[1],1.999969482421875*t[2]);return[(a=r.adaptation(a,e.inWhitePoint,e.outWhitePoint)).X/1.999969482421875,a.Y/1.999969482421875,a.Z/1.999969482421875]}stage_absoluteAdaptationIn_PCSXYZ_to_PCSXYZ(t,e){return[t[0]*=e.absoluteAdaptationIn.Xa,t[1]*=e.absoluteAdaptationIn.Ya,t[2]*=e.absoluteAdaptationIn.Za]}stage_absoluteAdaptationOut_PCSXYZ_to_PCSXYZ(t,e){return[t[0]*=e.absoluteAdaptationOut.Xa,t[1]*=e.absoluteAdaptationOut.Ya,t[2]*=e.absoluteAdaptationOut.Za]}stage_ApplyBPCScale_PCSXYZ_to_PCSXYZ(t,e){return[(e.scale.X*(1.999969482421875*t[0])+e.offset.X)/1.999969482421875,(e.scale.Y*(1.999969482421875*t[1])+e.offset.Y)/1.999969482421875,(e.scale.Z*(1.999969482421875*t[2])+e.offset.Z)/1.999969482421875]}stage_grayTRC_to_PCSXYZ_Via_Y(t,e){var a=this.stage_curves_v4([t[0]],e)[0];return[u.d50.X*a/1.999969482421875,u.d50.Y*a/1.999969482421875,u.d50.Z*a/1.999969482421875]}stage_grayTRC_to_PCSV4_Via_L(t,e){return[this.stage_curves_v4([t[0]],e)[0],.5,.5]}stage_PCSXYZ_to_grayTRC_via_Y(t,e){var a=1.999969482421875*t[1];return[this.stage_curves_v4([a],e)[0]]}stage_PCSV4_to_grayTRC_via_L(t,e){var a=t[0];return[this.stage_curves_v4([a],e)[0]]}stage_PCSv4_to_PCSv2(t){return[.9961089494163424*t[0],.9961089494163424*t[1],.9961089494163424*t[2]]}stage_PCSv2_to_PCSv4(t){return[1.00390625*t[0],1.00390625*t[1],1.00390625*t[2]]}stage_LabD50_to_PCSXYZ(t){var e=this.Lab2XYZ(t);return[e.X/1.999969482421875,e.Y/1.999969482421875,e.Z/1.999969482421875]}stage_XYZ_to_PCSXYZ(t){return[t.X/1.999969482421875,t.Y/1.999969482421875,t.Z/1.999969482421875]}stage_PCSv2_to_PCSXYZ(t){var e=this.Lab2XYZ(this.Lab(100.390625*t[0],255.99609375*t[1]-128,255.99609375*t[2]-128,u.d50));return[e.X/1.999969482421875,e.Y/1.999969482421875,e.Z/1.999969482421875]}stage_PCSv4_to_PCSXYZ(t){var e=this.Lab2XYZ(this.Lab(100*t[0],255*t[1]-128,255*t[2]-128,u.d50));return[e.X/1.999969482421875,e.Y/1.999969482421875,e.Z/1.999969482421875]}stage_PCSXYZ_to_PCSv4(t){var e=this.XYZ(1.999969482421875*t[0],1.999969482421875*t[1],1.999969482421875*t[2]),a=this.XYZ2Lab(e,u.d50);return[a.L/100,(a.a+128)/255,(a.b+128)/255]}stage_PCSXYZ_to_LabD50(t){var e=this.XYZ(1.999969482421875*t[0],1.999969482421875*t[1],1.999969482421875*t[2]);return this.XYZ2Lab(e,u.d50)}stage_PCSXYZ_to_PCSv2(t){var e=this.XYZ(1.999969482421875*t[0],1.999969482421875*t[1],1.999969482421875*t[2]),a=this.XYZ2Lab(e,u.d50);return[652.8*a.L/65535,256*(a.a+128)/65535,256*(a.b+128)/65535]}stage_PCSv2_to_LabD50(t){return{L:100.390625*t[0],a:255.99609375*t[1]-128,b:255.99609375*t[2]-128}}stage_PCSv2_to_cmsLab(t){return{L:100.390625*t[0],a:255.99609375*t[1]-128,b:255.99609375*t[2]-128,type:h.Lab,whitePoint:u.d50}}stage_PCSv4_to_LabD50(t){return{L:100*t[0],a:255*t[1]-128,b:255*t[2]-128}}stage_PCSv4_to_cmsLab(t){return{L:100*t[0],a:255*t[1]-128,b:255*t[2]-128,type:h.Lab,whitePoint:u.d50}}stage_cmsLab_to_LabD50(t){if(t.type===h.Lab)return r.Lab2LabD50(t);throw"stage_cmsLab_to_LabD50: input is not of type Lab"}stage_PCSv4_to_RGBDevice(t,e){return this.PCSv4_to_RGBDevice(t,e,this.RGBMatrixWhiteAdadaptation)}stage_RGBDevice_to_PCSv4(t,e){return this.RGBDevice_to_PCSv4_or_LabD50(t,e,!1,this.RGBMatrixWhiteAdadaptation)}stage_LabD50_to_PCSv4(t){return[t.L/100,(t.a+128)/255,(t.b+128)/255]}stage_LabD50_to_PCSv2(t){return[652.8*t.L/65535,256*(t.a+128)/65535,256*(t.b+128)/65535]}stage_LabD50_to_cmsLab(t){return{L:t.L,a:t.a,b:t.b,type:h.Lab,whitePoint:u.d50}}stage_matrix_v4(t,e){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[9],e[3]*t[0]+e[4]*t[1]+e[5]*t[2]+e[10],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]+e[11]]}stage_matrix_v4_noOffsets(t,e){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}evalMatrix(t,e){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}invertMatrix(t){var e=1/(t[0]*(t[8]*t[4]-t[7]*t[5])-t[3]*(t[8]*t[1]-t[7]*t[2])+t[6]*(t[5]*t[1]-t[4]*t[2]));return[e*(t[8]*t[4]-t[7]*t[5]),-e*(t[8]*t[1]-t[7]*t[2]),e*(t[5]*t[1]-t[4]*t[2]),-e*(t[8]*t[3]-t[6]*t[5]),e*(t[8]*t[0]-t[6]*t[2]),-e*(t[5]*t[0]-t[3]*t[2]),e*(t[7]*t[3]-t[6]*t[4]),-e*(t[7]*t[0]-t[6]*t[1]),e*(t[4]*t[0]-t[3]*t[1])]}invertMatrix3(t){var e=1/(t[0]*(t[9]*t[4]-t[7]*t[4])-t[3]*(t[9]*t[1]-t[7]*t[2])+t[6]*(t[4]*t[1]-t[4]*t[2]));return[e*(t[9]*t[4]-t[7]*t[4]),-e*(t[9]*t[1]-t[7]*t[2]),e*(t[4]*t[1]-t[4]*t[2]),-e*(t[9]*t[3]-t[6]*t[4]),e*(t[9]*t[0]-t[6]*t[2]),-e*(t[4]*t[0]-t[3]*t[2]),e*(t[7]*t[3]-t[6]*t[4]),-e*(t[7]*t[0]-t[6]*t[1]),e*(t[4]*t[0]-t[3]*t[1])]}stage_curves_parametric(t,e){for(var a=t.length,i=new Array(a),r=0;r<a;r++){var n=e[r];i[r]=n.curveFn(n.params,t[r])}return i}stage_curves_v4(t,e){var a,i=e.length;a=3===i?[0,0,0]:[0,0,0,0];for(var r=0;r<i;r++){var n=e[r];if(n.curveFn)a[r]=n.curveFn(n.params,t[r]);else{var s=n.count-1,o=t[r];if(o>=1)a[r]=n.dataf[s];else if(o<=0)a[r]=n.dataf[0];else{var h=o*s,u=Math.floor(h),c=e[r].dataf[u];a[r]=c+(h-u)*(e[r].dataf[u+1]-c)}}}return a}stage_curve_v2(t,e){for(var a=0,i=e.channels,r=e.entries,n=r-1,s=e.tablef,o=new Array(i),h=0;h<i;h++){var u=t[h];if(u>=1)o[h]=s[a+n];else if(u<=0)o[h]=s[a];else{var c=u*n,l=Math.floor(c),p=c-l,d=s[a+l],m=s[a+l+1];o[h]=d+(m-d)*p}a+=r}return o}trilinearInterp3D_NCh(t,e){var a,i,r,n,s,o,h,u,c,l,p,d,m,g,_,v,f,C,P,b,S,M,y=e.outputScale,Y=e.outputChannels,G=e.g1-1,D=G*e.inputScale,R=e.CLUT,B=e.go0,x=e.go1,L=e.go2;a=(l=Math.min(Math.max(t[0],0),1)*D)-(n=~~l),s=n===G?n*=L:(n*=L)+L,i=(p=Math.min(Math.max(t[1],0),1)*D)-(o=~~p),h=o===G?o*=x:(o*=x)+x,r=(d=Math.min(Math.max(t[2],0),1)*D)-(u=~~d),c=u===G?u*=B:(u*=B)+B;for(var X=new Array(Y),Z=0;Z<Y;Z++)m=R[n+o+u],g=R[n+o+c],_=R[n+h+u],v=R[n+h+c],f=R[s+o+u],C=R[s+o+c],S=(P=m+a*(f-m))+i*(_+a*(R[s+h+u]-_)-P),M=(b=g+a*(C-g))+i*(v+a*(R[s+h+c]-v)-b),X[Z]=(S+r*(M-S))*y,n++,s++;return X}trilinearInterp3D_3or4Ch(t,e,a){a=void 0===a?0:a;var i,r,n,s,o,h,u,c,l,p,d,m,g,_,v,f,C,P,b,S,M,y,Y,G,D=e.inputChannels,R=e.outputChannels,B=e.gridPoints[0],x=e.CLUT,L=B,X=B*L,Z=B*X,w=t[0]*e.inputScale,I=t[1]*e.inputScale,T=t[2]*e.inputScale;return w=Math.min(Math.max(w,0),1),I=Math.min(Math.max(I,0),1),T=Math.min(Math.max(T,0),1),I*=B-1,T*=B-1,u=(w*=B-1)-(i=Math.floor(w)),c=I-(r=Math.floor(I)),l=T-(n=Math.floor(T)),s=i+(t[0]>=1?0:1),o=r+(t[1]>=1?0:1),h=n+(t[2]>=1?0:1),p=A(i,r,n,a,x,D,R),d=A(i,r,h,a,x,D,R),m=A(i,o,n,a,x,D,R),g=A(i,o,h,a,x,D,R),_=A(s,r,n,a,x,D,R),v=A(s,r,h,a,x,D,R),f=A(s,o,n,a,x,D,R),C=A(s,o,h,a,x,D,R),P=E(u,p,_),b=E(u,d,v),S=E(u,m,f),M=E(u,g,C),y=E(c,P,S),Y=E(c,b,M),G=E(l,y,Y),3===R?[G[0]*=e.outputScale,G[1]*=e.outputScale,G[2]*=e.outputScale]:[G[0]*=e.outputScale,G[1]*=e.outputScale,G[2]*=e.outputScale,G[3]*=e.outputScale];function E(t,e,a){return 3===R?[e[0]+t*(a[0]-e[0]),e[1]+t*(a[1]-e[1]),e[2]+t*(a[2]-e[2])]:[e[0]+t*(a[0]-e[0]),e[1]+t*(a[1]-e[1]),e[2]+t*(a[2]-e[2]),e[3]+t*(a[3]-e[3])]}function A(t,e,a,i,r,n,s){var o;return o=3===n?(t*X+e*L+a)*s:(i*Z+t*X+e*L+a)*s,3===s?[r[o],r[o+1],r[o+2]]:[r[o],r[o+1],r[o+2],r[o+3]]}}trilinearInterp4D_3or4Ch(t,e){var a,i,r,n,s;r=n=Math.max(0,Math.min(1,t[0]*e.inputScale)),s=(n*=e.g1-1)-(a=Math.floor(n)),i=r>=1?a:a+1;var o=[t[1],t[2],t[3]],h=this.trilinearInterp3D_3or4Ch(o,e,a);if(0===s)return h;var u=this.trilinearInterp3D_3or4Ch(o,e,i);return 3===e.outputChannels?[h[0]+(u[0]-h[0])*s,h[1]+(u[1]-h[1])*s,h[2]+(u[2]-h[2])*s]:(h[0]=h[0]+(u[0]-h[0])*s,h[1]=h[1]+(u[1]-h[1])*s,h[2]=h[2]+(u[2]-h[2])*s,h[3]=h[3]+(u[3]-h[3])*s,h)}tetrahedralInterp3D_Master(t,e,a){var i,r,n,s,o,h,u,c,l,p,d,m,g,_,v,f,C,P,b,S,M=e.inputChannels,y=e.outputChannels,Y=e.gridPoints[0],G=e.CLUT,D=Y,R=Y*D,B=Y*R;return s=3===e.outputChannels?[0,0,0]:[0,0,0,0],P=v=t[0]*e.inputScale,b=f=t[1]*e.inputScale,S=C=t[2]*e.inputScale,v=Math.min(Math.max(v,0),1),f=Math.min(Math.max(f,0),1),C=Math.min(Math.max(C,0),1),f*=Y-1,C*=Y-1,i=(v*=Y-1)-(l=Math.floor(v)),p=l+(P>=1?0:1),r=f-(d=Math.floor(f)),m=d+(b>=1?0:1),n=C-(g=Math.floor(C)),_=g+(S>=1?0:1),o=x(l,d,g,a),i>=r&&r>=n?(h=L(x(p,d,g,a),o),u=L(x(p,m,g,a),x(p,d,g,a)),c=L(x(p,m,_,a),x(p,m,g,a))):i>=n&&n>=r?(h=L(x(p,d,g,a),o),u=L(x(p,m,_,a),x(p,d,_,a)),c=L(x(p,d,_,a),x(p,d,g,a))):n>=i&&i>=r?(h=L(x(p,d,_,a),x(l,d,_,a)),u=L(x(p,m,_,a),x(p,d,_,a)),c=L(x(l,d,_,a),o)):r>=i&&i>=n?(h=L(x(p,m,g,a),x(l,m,g,a)),u=L(x(l,m,g,a),o),c=L(x(p,m,_,a),x(p,m,g,a))):r>=n&&n>=i?(h=L(x(p,m,_,a),x(l,m,_,a)),u=L(x(l,m,g,a),o),c=L(x(l,m,_,a),x(l,m,g,a))):n>=r&&r>=i?(h=L(x(p,m,_,a),x(l,m,_,a)),u=L(x(l,m,_,a),x(l,d,_,a)),c=L(x(l,d,_,a),o)):h=u=c=[0,0,0,0],s[0]=(o[0]+h[0]*i+u[0]*r+c[0]*n)*e.outputScale,s[1]=(o[1]+h[1]*i+u[1]*r+c[1]*n)*e.outputScale,s[2]=(o[2]+h[2]*i+u[2]*r+c[2]*n)*e.outputScale,3===e.outputChannels||(s[3]=(o[3]+h[3]*i+u[3]*r+c[3]*n)*e.outputScale),s;function x(t,a,i,r){var n;return n=3===M?(t*R+a*D+i)*y:(r*B+t*R+a*D+i)*y,3===e.outputChannels?[G[n],G[n+1],G[n+2]]:[G[n],G[n+1],G[n+2],G[n+3]]}function L(t,a){var i=[];return i[0]=t[0]-a[0],i[1]=t[1]-a[1],i[2]=t[2]-a[2],3===e.outputChannels||(i[3]=t[3]-a[3]),i}}tetrahedralInterp3D_3or4Ch(t,e,a){var i,r,n,s,o,h,u,c,l,p,d,m,g,_,v,f,C,P,b,S,M,y,Y,G,D=e.inputScale,R=e.outputScale,B=e.inputChannels,x=e.outputChannels,L=e.g1-1,X=e.CLUT,Z=e.g1,w=e.g2,I=e.g3;return C=_=t[0]*D,P=v=t[1]*D,b=f=t[2]*D,_=Math.min(Math.max(_,0),1),v=Math.min(Math.max(v,0),1),f=Math.min(Math.max(f,0),1),v*=L,f*=L,i=(_*=L)-(c=Math.floor(_)),l=c+(C>=1?0:1),r=v-(p=Math.floor(v)),d=p+(P>=1?0:1),n=f-(m=Math.floor(f)),g=m+(b>=1?0:1),S=c,M=p,y=m,Y=a,G=3===B?(S*w+M*Z+y)*x:(Y*I+S*w+M*Z+y)*x,s=3===x?[X[G++],X[G++],X[G]]:[X[G++],X[G++],X[G++],X[G]],i>=r&&r>=n?(o=T(l,p,m,a,s),h=E(l,d,m,a,l,p,m,a),u=E(l,d,g,a,l,d,m,a)):i>=n&&n>=r?(o=T(l,p,m,a,s),h=E(l,d,g,a,l,p,g,a),u=E(l,p,g,a,l,p,m,a)):n>=i&&i>=r?(o=E(l,p,g,a,c,p,g,a),h=E(l,d,g,a,l,p,g,a),u=T(c,p,g,a,s)):r>=i&&i>=n?(o=E(l,d,m,a,c,d,m,a),h=T(c,d,m,a,s),u=E(l,d,g,a,l,d,m,a)):r>=n&&n>=i?(o=E(l,d,g,a,c,d,g,a),h=T(c,d,m,a,s),u=E(c,d,g,a,c,d,m,a)):n>=r&&r>=i?(o=E(l,d,g,a,c,d,g,a),h=E(c,d,g,a,c,p,g,a),u=T(c,p,g,a,s)):o=h=u=[0,0,0,0],3===x?[(s[0]+o[0]*i+h[0]*r+u[0]*n)*R,(s[1]+o[1]*i+h[1]*r+u[1]*n)*R,(s[2]+o[2]*i+h[2]*r+u[2]*n)*R]:[(s[0]+o[0]*i+h[0]*r+u[0]*n)*R,(s[1]+o[1]*i+h[1]*r+u[1]*n)*R,(s[2]+o[2]*i+h[2]*r+u[2]*n)*R,(s[3]+o[3]*i+h[3]*r+u[3]*n)*R];function T(t,e,a,i,r){var n,s,o,h;return n=3===B?(t*w+e*Z+a)*x:(i*I+t*w+e*Z+a)*x,s=X[n++]-r[0],o=X[n++]-r[1],h=X[n++]-r[2],3===x?[s,o,h]:[s,o,h,X[n]-r[3]]}function E(t,e,a,i,r,n,s,o){var h,u,c,l,p;return 3===B?(h=(t*w+e*Z+a)*x,u=(r*w+n*Z+s)*x):(h=(i*I+t*w+e*Z+a)*x,u=(o*I+r*w+n*Z+s)*x),c=X[h++]-X[u++],l=X[h++]-X[u++],p=X[h++]-X[u++],3===x?[c,l,p]:[c,l,p,X[h]-X[u]]}}linearInterp1D_NCh(t,e){var a,i,r,n,s,o,h,u=e.outputScale,c=e.outputChannels,l=e.g1-1,p=l*e.inputScale,d=e.CLUT,m=e.go0;a=(i=Math.min(Math.max(t[0],0),1)*p)-(r=~~i),n=r===l?r*=m:(r*=m)+m;var g=new Array(c);for(h=0;h<c;h++)s=d[r++],o=d[n++],g[h]=(s+(o-s)*a)*u;return g}bilinearInterp2D_NCh(t,e){var a,i,r,n,s,o,h,u,c,l,p,d,m,g,_,v,f,C,P=e.outputScale,b=e.outputChannels,S=e.g1-1,M=S*e.inputScale,y=e.CLUT,Y=e.go0,G=e.go1;a=(h=Math.min(Math.max(t[0],0),1)*M)-(r=~~h),n=r===S?r*=G:(r*=G)+G,i=(u=Math.min(Math.max(t[1],0),1)*M)-(s=~~u),o=s===S?s*=Y:(s*=Y)+Y;var D=new Array(b);for(c=r+s,l=r+o,p=n+s,d=n+o,C=0;C<b;C++)m=y[c++],g=y[l++],_=y[p++],v=y[d++],f=m+(_-m)*a,D[C]=(f+(g+(v-g)*a-f)*i)*P;return D}tetrahedralInterp3D_NCh(t,e){var a,i,r,n,s,o,h,u,c,l,p,d,m,g,_,v,f,C,P,b,S,M=e.outputScale,y=e.outputChannels,Y=e.g1-1,G=Y*e.inputScale,D=e.CLUT,R=e.go0,B=e.go1,x=e.go2;a=(l=Math.min(Math.max(t[0],0),1)*G)-(n=~~l),s=n===Y?n*=x:(n*=x)+x,i=(p=Math.min(Math.max(t[1],0),1)*G)-(o=~~p),h=o===Y?o*=B:(o*=B)+B,r=(d=Math.min(Math.max(t[2],0),1)*G)-(u=~~d),c=u===Y?u*=R:(u*=R)+R,m=n+o+u;var L=new Array(y);if(a>=i&&i>=r)for(g=s+o+u,_=s+h+u,f=s+h+c,S=0;S<y;S++)C=D[g++],P=D[_++],b=D[m++],L[S]=(b+(C-b)*a+(P-C)*i+(D[f++]-P)*r)*M;else if(a>=r&&r>=i)for(g=s+o+u,_=s+h+c,v=s+o+c,S=0;S<y;S++)C=D[v++],P=D[g++],b=D[m++],L[S]=(b+(P-b)*a+(D[_++]-C)*i+(C-P)*r)*M;else if(a>=i&&r>=a)for(g=s+o+c,_=n+o+c,v=s+h+c,S=0;S<y;S++)C=D[g++],P=D[_++],b=D[m++],L[S]=(b+(C-P)*a+(D[v++]-C)*i+(P-b)*r)*M;else if(i>=a&&a>=r)for(g=s+h+u,_=n+h+u,f=s+h+c,S=0;S<y;S++)C=D[_++],P=D[g++],b=D[m++],L[S]=(b+(P-C)*a+(C-b)*i+(D[f++]-P)*r)*M;else if(i>=r&&r>=a)for(g=s+h+c,_=n+h+c,v=n+h+u,S=0;S<y;S++)C=D[_++],P=D[v++],b=D[m++],L[S]=(b+(D[g++]-C)*a+(P-b)*i+(C-P)*r)*M;else if(r>=i&&i>=a)for(g=s+h+c,_=n+h+c,f=n+o+c,S=0;S<y;S++)C=D[_++],P=D[f++],b=D[m++],L[S]=(b+(D[g++]-C)*a+(C-P)*i+(P-b)*r)*M;else for(S=0;S<y;S++)L[S]=D[m++]*M;return L}tetrahedralInterp3D_4Ch(t,e){var a,i,r,n,s,o,h,u,c,l,p,d,m,g,_,v,f,C,P,b,S,M,y=e.outputScale,Y=e.g1-1,G=Y*e.inputScale,D=e.CLUT,R=e.go0,B=e.go1,x=e.go2;a=(l=Math.min(1,Math.max(0,t[0]))*G)-(n=~~l),s=n===Y?n*=x:(n*=x)+x,i=(p=Math.min(1,Math.max(0,t[1]))*G)-(o=~~p),h=o===Y?o*=B:(o*=B)+B,r=(d=Math.min(1,Math.max(0,t[2]))*G)-(u=~~d),c=u===Y?u*=R:(u*=R)+R,m=n+o+u,f=D[m++],C=D[m++],P=D[m++],b=D[m];var L=new Array(4);return a>=i&&i>=r?(m=s+o+u,g=s+h+u,v=s+h+c,S=D[m++],M=D[g++],L[0]=(f+(S-f)*a+(M-S)*i+(D[v++]-M)*r)*y,S=D[m++],M=D[g++],L[1]=(C+(S-C)*a+(M-S)*i+(D[v++]-M)*r)*y,S=D[m++],M=D[g++],L[2]=(P+(S-P)*a+(M-S)*i+(D[v++]-M)*r)*y,S=D[m],M=D[g],L[3]=(b+(S-b)*a+(M-S)*i+(D[v]-M)*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c,S=D[g++],M=D[v++],L[0]=(f+(D[m++]-S)*a+(S-M)*i+(M-f)*r)*y,S=D[g++],M=D[v++],L[1]=(C+(D[m++]-S)*a+(S-M)*i+(M-C)*r)*y,S=D[g++],M=D[v++],L[2]=(P+(D[m++]-S)*a+(S-M)*i+(M-P)*r)*y,S=D[g],M=D[v],L[3]=(b+(D[m]-S)*a+(S-M)*i+(M-b)*r)*y):(L[0]=f*y,L[1]=C*y,L[2]=P*y,L[3]=b*y),L}tetrahedralInterp3D_3Ch(t,e){var a,i,r,n,s,o,h,u,c,l,p,d,m,g,_,v,f,C,P,b,S,M=e.outputScale,y=e.g1-1,Y=y*e.inputScale,G=e.CLUT,D=e.go0,R=e.go1,B=e.go2;a=(l=Math.min(1,Math.max(0,t[0]))*Y)-(n=~~l),s=n===y?n*=B:(n*=B)+B,i=(p=Math.min(1,Math.max(0,t[1]))*Y)-(o=~~p),h=o===y?o*=R:(o*=R)+R,r=(d=Math.min(1,Math.max(0,t[2]))*Y)-(u=~~d),c=u===y?u*=D:(u*=D)+D,m=n+o+u,f=G[m++],C=G[m++],P=G[m];var x=new Array(3);return a>=i&&i>=r?(m=s+o+u,g=s+h+u,v=s+h+c,b=G[m++],S=G[g++],x[0]=(f+(b-f)*a+(S-b)*i+(G[v++]-S)*r)*M,b=G[m++],S=G[g++],x[1]=(C+(b-C)*a+(S-b)*i+(G[v++]-S)*r)*M,b=G[m],S=G[g],x[2]=(P+(b-P)*a+(S-b)*i+(G[v]-S)*r)*M):a>=r&&r>=i?(m=s+o+u,g=s+h+c,_=s+o+c,b=G[_++],S=G[m++],x[0]=(f+(S-f)*a+(G[g++]-b)*i+(b-S)*r)*M,b=G[_++],S=G[m++],x[1]=(C+(S-C)*a+(G[g++]-b)*i+(b-S)*r)*M,b=G[_],S=G[m],x[2]=(P+(S-P)*a+(G[g]-b)*i+(b-S)*r)*M):a>=i&&r>=a?(m=s+o+c,g=n+o+c,_=s+h+c,b=G[m++],S=G[g++],x[0]=(f+(b-S)*a+(G[_++]-b)*i+(S-f)*r)*M,b=G[m++],S=G[g++],x[1]=(C+(b-S)*a+(G[_++]-b)*i+(S-C)*r)*M,b=G[m],S=G[g],x[2]=(P+(b-S)*a+(G[_]-b)*i+(S-P)*r)*M):i>=a&&a>=r?(m=s+h+u,g=n+h+u,v=s+h+c,b=G[g++],S=G[m++],x[0]=(f+(S-b)*a+(b-f)*i+(G[v++]-S)*r)*M,b=G[g++],S=G[m++],x[1]=(C+(S-b)*a+(b-C)*i+(G[v++]-S)*r)*M,b=G[g],S=G[m],x[2]=(P+(S-b)*a+(b-P)*i+(G[v]-S)*r)*M):i>=r&&r>=a?(m=s+h+c,g=n+h+c,_=n+h+u,b=G[g++],S=G[_++],x[0]=(f+(G[m++]-b)*a+(S-f)*i+(b-S)*r)*M,b=G[g++],S=G[_++],x[1]=(C+(G[m++]-b)*a+(S-C)*i+(b-S)*r)*M,b=G[g],S=G[_],x[2]=(P+(G[m]-b)*a+(S-P)*i+(b-S)*r)*M):r>=i&&i>=a?(m=s+h+c,g=n+h+c,v=n+o+c,b=G[g++],S=G[v++],x[0]=(f+(G[m++]-b)*a+(b-S)*i+(S-f)*r)*M,b=G[g++],S=G[v++],x[1]=(C+(G[m++]-b)*a+(b-S)*i+(S-C)*r)*M,b=G[g],S=G[v],x[2]=(P+(G[m]-b)*a+(b-S)*i+(S-P)*r)*M):(x[0]=f*M,x[1]=C*M,x[2]=P*M),x}tetrahedralInterp4D_3Ch(t,e){var a,i,r,n,s,o,h,u,c,l,p,d,m,g,_,v,f,C,P,b,S,M,y,Y,G,D,R,B,x,L,X,Z=e.outputScale,w=e.g1-1,I=w*e.inputScale,T=e.CLUT,E=e.go0,A=e.go1,k=e.go2,U=e.go3,F=U-e.outputChannels+1;p=(_=Math.min(1,Math.max(0,t[0]))*I)-(n=~~_),X=!(n===w),u=(d=Math.min(1,Math.max(0,t[1]))*I)-(a=~~d),i=a===w?a*=k:(a*=k)+k,c=(m=Math.min(1,Math.max(0,t[2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v+=W,f+=W,P+=W,Z=k[f++],w=k[P++],V[0]=(Y+(B+(k[v++]-Z)*u+(Z-w)*c+(w-B)*l-Y)*p)*T,Z=k[f++],w=k[P++],V[1]=(G+(x+(k[v++]-Z)*u+(Z-w)*c+(w-x)*l-G)*p)*T,Z=k[f++],w=k[P++],V[2]=(D+(L+(k[v++]-Z)*u+(Z-w)*c+(w-L)*l-D)*p)*T,Z=k[f],w=k[P],V[3]=(R+(X+(k[v]-Z)*u+(Z-w)*c+(w-X)*l-R)*p)*T):(V[0]=Y*T,V[1]=G*T,V[2]=D*T,V[3]=R*T)):I?(V[0]=b+(B-b)*p*T,V[1]=S+(x-S)*p*T,V[2]=M+(L-M)*p*T,V[3]=y+(X-y)*p*T):(V[0]=b*T,V[1]=S*T,V[2]=M*T,V[3]=y*T),V}tetrahedralInterp4D_NCh(t,e){var a,i,r,n,s,o,h,u,c,l,p,d,m,g,_,v,f,C,P,b,S,M,y,Y,G,D,R=e.outputScale,B=e.g1-1,x=B*e.inputScale,L=e.outputChannels,X=e.CLUT,Z=e.go0,w=e.go1,I=e.go2,T=e.go3,E=T-e.outputChannels;p=(_=Math.min(1,Math.max(0,t[0]))*x)-(n=~~_),u=(d=Math.min(1,Math.max(0,t[1]))*x)-(a=~~d),i=a===B?a*=I:(a*=I)+I,c=(m=Math.min(1,Math.max(0,t[2]))*x)-(r=~~m),s=r===B?r*=w:(r*=w)+w,l=(g=Math.min(1,Math.max(0,t[3]))*x)-(o=~~g),h=o===B?o*=Z:(o*=Z)+Z;var A=(D=!(n===B))?1:R;v=a+r+o+(n*=T);var k=new Array(L);if(u>=c&&c>=l){for(f=i+r+o+n,C=i+s+o+n,b=i+s+h+n,G=0;G<L;G++)S=X[f++],M=X[C++],y=X[v++],k[G]=(y+(S-y)*u+(M-S)*c+(X[b++]-M)*l)*A;if(D)for(v+=E,f+=E,C+=E,b+=E,G=0;G<L;G++)S=X[f++],M=X[C++],y=X[v++],Y=k[G],k[G]=(Y+(y+(S-y)*u+(M-S)*c+(X[b++]-M)*l-Y)*p)*R}else if(u>=l&&l>=c){for(f=i+r+o+n,C=i+s+h+n,P=i+r+h+n,G=0;G<L;G++)S=X[P++],M=X[f++],y=X[v++],k[G]=(y+(M-y)*u+(X[C++]-S)*c+(S-M)*l)*A;if(D)for(v+=E,f+=E,C+=E,P+=E,G=0;G<L;G++)S=X[P++],M=X[f++],y=X[v++],Y=k[G],k[G]=(Y+(y+(M-y)*u+(X[C++]-S)*c+(S-M)*l-Y)*p)*R}else if(u>=c&&l>=u){for(f=i+r+h+n,C=a+r+h+n,P=i+s+h+n,G=0;G<L;G++)S=X[f++],M=X[C++],y=X[v++],k[G]=(y+(S-M)*u+(X[P++]-S)*c+(M-y)*l)*A;if(D)for(v+=E,f+=E,C+=E,P+=E,G=0;G<L;G++)S=X[f++],M=X[C++],y=X[v++],Y=k[G],k[G]=(Y+(y+(S-M)*u+(X[P++]-S)*c+(M-y)*l-Y)*p)*R}else if(c>=u&&u>=l){for(f=i+s+o+n,C=a+s+o+n,b=i+s+h+n,G=0;G<L;G++)S=X[C++],M=X[f++],y=X[v++],k[G]=(y+(M-S)*u+(S-y)*c+(X[b++]-M)*l)*A;if(D)for(v+=E,f+=E,C+=E,b+=E,G=0;G<L;G++)S=X[C++],M=X[f++],y=X[v++],Y=k[G],k[G]=(Y+(y+(M-S)*u+(S-y)*c+(X[b++]-M)*l-Y)*p)*R}else if(c>=l&&l>=u){for(f=i+s+h+n,C=a+s+h+n,P=a+s+o+n,G=0;G<L;G++)S=X[C++],M=X[P++],y=X[v++],k[G]=(y+(X[f++]-S)*u+(M-y)*c+(S-M)*l)*A;if(D)for(v+=E,f+=E,C+=E,P+=E,G=0;G<L;G++)S=X[C++],M=X[P++],y=X[v++],Y=k[G],k[G]=(Y+(y+(X[f++]-S)*u+(M-y)*c+(S-M)*l-Y)*p)*R}else if(l>=c&&c>=u){for(f=i+s+h+n,C=a+s+h+n,b=a+r+h+n,G=0;G<L;G++)S=X[C++],M=X[b++],y=X[v++],k[G]=(y+(X[f++]-S)*u+(S-M)*c+(M-y)*l)*A;if(D)for(v+=E,f+=E,C+=E,b+=E,G=0;G<L;G++)S=X[C++],M=X[b++],y=X[v++],Y=k[G],k[G]=(Y+(y+(X[f++]-S)*u+(S-M)*c+(M-y)*l-Y)*p)*R}else if(D){for(G=0;G<L;G++)k[G]=X[v++];for(v+=E,G=0;G<L;G++)y=X[v++],k[G]=(y+(k[G]-y)*p)*R}else for(G=0;G<L;G++)k[G]=X[v++]*R;return k}tetrahedralInterp3DArray_4Ch_loop(t,e,a,i,r,n,s,o,h){for(var u,c,l,p,d,m,g,_,v,f,C,P,b,S,M,y,Y,G,D,R,B,x,L,X,Z,w=n.outputScale,I=(n.g1-1)*n.inputScale,T=n.CLUT,E=n.go0,A=n.go1,k=n.go2,U=0;U<r;U++)u=(f=(b=t[e++])*I)-(p=~~f),p*=k,d=255===b?p:p+k,c=(C=(S=t[e++])*I)-(m=~~C),m*=A,g=255===S?m:m+A,l=(P=(M=t[e++])*I)-(_=~~P),_*=E,v=255===M?_:_+E,y=p+m+_,R=T[y++],B=T[y++],x=T[y++],L=T[y],u>=c&&c>=l?(y=d+m+_,Y=d+g+_,D=d+g+v,X=T[y++],Z=T[Y++],a[i++]=(R+(X-R)*u+(Z-X)*c+(T[D++]-Z)*l)*w,X=T[y++],Z=T[Y++],a[i++]=(B+(X-B)*u+(Z-X)*c+(T[D++]-Z)*l)*w,X=T[y++],Z=T[Y++],a[i++]=(x+(X-x)*u+(Z-X)*c+(T[D++]-Z)*l)*w,X=T[y],Z=T[Y],a[i++]=(L+(X-L)*u+(Z-X)*c+(T[D]-Z)*l)*w):u>=l&&l>=c?(y=d+m+_,Y=d+g+v,G=d+m+v,X=T[G++],Z=T[y++],a[i++]=(R+(Z-R)*u+(T[Y++]-X)*c+(X-Z)*l)*w,X=T[G++],Z=T[y++],a[i++]=(B+(Z-B)*u+(T[Y++]-X)*c+(X-Z)*l)*w,X=T[G++],Z=T[y++],a[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]-X)*u+(X-Z)*c+(Z-B)*l)*w,X=T[Y++],Z=T[D++],a[i++]=(x+(T[y++]-X)*u+(X-Z)*c+(Z-x)*l)*w,X=T[Y],Z=T[D],a[i++]=(L+(T[y]-X)*u+(X-Z)*c+(Z-L)*l)*w):(a[i++]=R*w,a[i++]=B*w,a[i++]=x*w,a[i++]=L*w),h?a[i++]=t[e++]:(s&&e++,o&&(a[i++]=255))}linearInterp1DArray_NCh_loop(t,e,a,i,r,n,s,o,h){for(var u,c,l=n.outputChannels,p=0;p<r;p++){for(u=this.linearInterp1D_NCh([t[e++]],n),c=0;c<l;c++)a[i++]=u[c];h?a[i++]=t[e++]:(s&&e++,o&&(a[i++]=255))}}bilinearInterp2DArray_NCh_loop(t,e,a,i,r,n,s,o,h){var u,c,l,p=n.outputChannels;u=new Uint8ClampedArray(2);for(var d=0;d<r;d++){for(u[0]=t[e++],u[1]=t[e++],c=this.bilinearInterp2D_NCh(u,n),l=0;l<p;l++)a[i++]=c[l];h?a[i++]=t[e++]:(s&&e++,o&&(a[i++]=255))}}tetrahedralInterp3DArray_NCh_loop(t,e,a,i,r,n,s,o,h){var u,c,l,p=n.outputChannels;u=new Uint8ClampedArray(3);for(var d=0;d<r;d++){for(u[0]=t[e++],u[1]=t[e++],u[2]=t[e++],c=this.tetrahedralInterp3D_NCh(u,n),l=0;l<p;l++)a[i++]=c[l];h?a[i++]=t[e++]:(s&&e++,o&&(a[i++]=255))}}tetrahedralInterp4DArray_NCh_loop(t,e,a,i,r,n,s,o,h){var u,c,l,p=n.outputChannels;u=new Uint8ClampedArray(4);for(var d=0;d<r;d++){for(u[0]=t[e++],u[1]=t[e++],u[2]=t[e++],u[3]=t[e++],c=this.tetrahedralInterp4D_NCh(u,n),l=0;l<p;l++)a[i++]=c[l];h?a[i++]=t[e++]:(s&&e++,o&&(a[i++]=255))}}tetrahedralInterp3DArray_3Ch_loop(t,e,a,i,r,n,s,o,h){for(var u,c,l,p,d,m,g,_,v,f,C,P,b,S,M,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(L-x)*c+(I[D]-X)*l)*Z):c>=l&&l>=u?(y=d+g+v,Y=p+g+v,G=p+g+_,L=I[Y++],X=I[G++],a[i++]=(R+(I[y++]-L)*u+(X-R)*c+(L-X)*l)*Z,L=I[Y++],X=I[G++],a[i++]=(B+(I[y++]-L)*u+(X-B)*c+(L-X)*l)*Z,L=I[Y],X=I[G],a[i++]=(x+(I[y]-L)*u+(X-x)*c+(L-X)*l)*Z):l>=c&&c>=u?(y=d+g+v,Y=p+g+v,D=p+m+v,L=I[Y++],X=I[D++],a[i++]=(R+(I[y++]-L)*u+(L-X)*c+(X-R)*l)*Z,L=I[Y++],X=I[D++],a[i++]=(B+(I[y++]-L)*u+(L-X)*c+(X-B)*l)*Z,L=I[Y],X=I[D],a[i++]=(x+(I[y]-L)*u+(L-X)*c+(X-x)*l)*Z):(a[i++]=R*Z,a[i++]=B*Z,a[i++]=x*Z);h?a[i++]=t[e++]:(s&&e++,o&&(a[i++]=255))}tetrahedralInterp4DArray_3Ch_loop(t,e,a,i,r,n,s,o,h){for(var u,c,l,p,d,m,g,_,v,f,C,P,b,S,M,y,Y,G,D,R,B,x,L,X,Z,w,I,T,E,A,k,U,F,N,O,W=n.outputScale,V=(n.g1-1)*n.inputScale,K=n.CLUT,j=n.go0,H=n.go1,q=n.go2,z=n.go3,J=z-n.outputChannels+1,Q=0;Q<r;Q++)C=(M=(D=t[e++])*V)-(p=~~M),_=(P=(y=t[e++])*V)-(u=~~P),u*=q,c=255===y?u:u+q,v=(b=(Y=t[e++])*V)-(l=~~b),l*=H,d=255===Y?l:l+H,f=(S=(G=t[e++])*V)-(m=~~S),m*=j,g=255===G?m:m+j,R=u+l+m+(p*=z),X=K[R++],Z=K[R++],w=K[R],255===D||0===C?O=!1:(R+=J,A=K[R++],k=K[R++],U=K[R],O=!0),_>=v&&v>=f?(R=c+l+m+p,B=c+d+m+p,L=c+d+g+p,I=X+((F=K[R++])-X)*_+((N=K[B++])-F)*v+(K[L++]-N)*f,T=Z+((F=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-X)*f,F=K[B++],N=K[L++],T=Z+(K[R++]-F)*_+(F-N)*v+(N-Z)*f,F=K[B],N=K[L],E=w+(K[R]-F)*_+(F-N)*v+(N-w)*f,O?(R+=J,B+=J,L+=J,F=K[B++],N=K[L++],a[i++]=(I+(A+(K[R++]-F)*_+(F-N)*v+(N-A)*f-I)*C)*W,F=K[B++],N=K[L++],a[i++]=(T+(k+(K[R++]-F)*_+(F-N)*v+(N-k)*f-T)*C)*W,F=K[B++],N=K[L++],a[i++]=(E+(U+(K[R++]-F)*_+(F-N)*v+(N-U)*f-E)*C)*W):(a[i++]=I*W,a[i++]=T*W,a[i++]=E*W)):O?(a[i++]=X+(A-X)*C*W,a[i++]=Z+(k-Z)*C*W,a[i++]=w+(U-w)*C*W):(a[i++]=X*W,a[i++]=Z*W,a[i++]=w*W),h?a[i++]=t[e++]:(s&&e++,o&&(a[i++]=255))}tetrahedralInterp4DArray_4Ch_loop(t,e,a,i,r,n,s,o,h){for(var u,c,l,p,d,m,g,_,v,f,C,P,b,S,M,y,Y,G,D,R,B,x,L,X,Z,w,I,T,E,A,k,U,F,N,O,W,V,K,j=n.outputScale,H=(n.g1-1)*n.inputScale,q=n.CLUT,z=n.go0,J=n.go1,Q=n.go2,$=n.go3,tt=$-n.outputChannels+1,et=0;et<r;et++)C=(M=(D=t[e++])*H)-(p=~~M),_=(P=(y=t[e++])*H)-(u=~~P),u*=Q,c=255===y?u:u+Q,v=(b=(Y=t[e++])*H)-(l=~~b),l*=J,d=255===Y?l:l+J,f=(S=(G=t[e++])*H)-(m=~~S),m*=z,g=255===G?m:m+z,R=u+l+m+(p*=$),R=u+l+m+p,X=q[R++],Z=q[R++],w=q[R++],I=q[R],255===D||0===C?K=!1:(R+=tt,U=q[R++],F=q[R++],N=q[R++],O=q[R],K=!0),_>=v&&v>=f?(R=c+l+m+p,B=c+d+m+p,L=c+d+g+p,T=X+((W=q[R++])-X)*_+((V=q[B++])-W)*v+(q[L++]-V)*f,E=Z+((W=q[R++])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a[i++]=k*j)):K?(a[i++]=X+(U-X)*C*j,a[i++]=Z+(F-Z)*C*j,a[i++]=w+(N-w)*C*j,a[i++]=I+(O-I)*C*j):(a[i++]=X*j,a[i++]=Z*j,a[i++]=w*j,a[i++]=I*j),h?a[i++]=t[e++]:(s&&e++,o&&(a[i++]=255))}tetrahedralInterp3DArray_4Ch_16bit(t,e,a,i,r,n){for(var s,o,h,u,c,l,p,d,m,g,_,v,f,C,P,b,S,M,y,Y,G,D,R,B,x,L,X,Z,w,I,T,E,A,k=n.outputScale,U=n.outputChannels,F=n.g1-1,N=n.CLUT,O=n.go1,W=n.go2,V=0;V<r;V++){if(g=(f=t[e++])*F/255,_=(C=t[e++])*F/255,v=(P=t[e++])*F/255,u=Math.floor(g),s=f,c=255===f?u:u+1,l=Math.floor(_),o=C,p=255===C?l:l+1,d=Math.floor(v),h=P,m=255===P?d:d+1,m*=U,b=u*W+l*O+(d*=U),M=N[b++],y=N[b++],Y=N[b++],G=N[b],s>=o&&o>=h)b=c*W+l*O+d,D=N[b++]-M,R=N[b++]-y,B=N[b++]-Y,x=N[b]-G,b=c*W+p*O+d,S=c*W+l*O+d,L=N[b++]-N[S++],X=N[b++]-N[S++],Z=N[b++]-N[S++],w=N[b]-N[S],b=c*W+p*O+m,S=c*W+p*O+d,I=N[b++]-N[S++],T=N[b++]-N[S++],E=N[b++]-N[S++],A=N[b]-N[S];else if(s>=h&&h>=o)b=c*W+l*O+d,D=N[b++]-M,R=N[b++]-y,B=N[b++]-Y,x=N[b]-G,b=c*W+p*O+m,S=c*W+l*O+m,L=N[b++]-N[S++],X=N[b++]-N[S++],Z=N[b++]-N[S++],w=N[b]-N[S],b=c*W+l*O+m,S=c*W+l*O+d,I=N[b++]-N[S++],T=N[b++]-N[S++],E=N[b++]-N[S++],A=N[b]-N[S];else if(h>=s&&s>=o)b=c*W+l*O+m,S=u*W+l*O+m,D=N[b++]-N[S++],R=N[b++]-N[S++],B=N[b++]-N[S++],x=N[b]-N[S],b=c*W+p*O+m,S=c*W+l*O+m,L=N[b++]-N[S++],X=N[b++]-N[S++],Z=N[b++]-N[S++],w=N[b]-N[S],b=u*W+l*O+m,I=N[b++]-M,T=N[b++]-y,E=N[b++]-Y,A=N[b]-G;else if(o>=s&&s>=h)b=c*W+p*O+d,S=u*W+p*O+d,D=N[b++]-N[S++],R=N[b++]-N[S++],B=N[b++]-N[S++],x=N[b++]-N[S],b=u*W+p*O+d,L=N[b++]-M,X=N[b++]-y,Z=N[b++]-Y,w=N[b]-G,b=c*W+p*O+m,S=c*W+p*O+d,I=N[b++]-N[S++],T=N[b++]-N[S++],E=N[b++]-N[S++],A=N[b]-N[S];else if(o>=h&&h>=s)b=c*W+p*O+m,S=u*W+p*O+m,D=N[b++]-N[S++],R=N[b++]-N[S++],B=N[b++]-N[S++],x=N[b]-N[S],b=u*W+p*O+d,L=N[b++]-M,X=N[b++]-y,Z=N[b++]-Y,w=N[b]-G,b=u*W+p*O+m,S=u*W+p*O+d,I=N[b++]-N[S++],T=N[b++]-N[S++],E=N[b++]-N[S++],A=N[b]-N[S];else{if(!(h>=o&&o>=s)){a[i++]=M*k,a[i++]=y*k,a[i++]=Y*k,a[i++]=G*k;continue}b=c*W+p*O+m,S=u*W+p*O+m,D=N[b++]-N[S++],R=N[b++]-N[S++],B=N[b++]-N[S++],x=N[b]-N[S],b=u*W+p*O+m,S=u*W+l*O+m,L=N[b++]-N[S++],X=N[b++]-N[S++],Z=N[b++]-N[S++],w=N[b]-N[S],b=u*W+l*O+m,I=N[b++]-M,T=N[b++]-y,E=N[b++]-Y,A=N[b]-G}var K;K=D*s+L*o+I*h+32769,a[i++]=256*M+K+(K>>16)>>16,K=R*s+X*o+T*h+32769,a[i++]=256*y+K+(K>>16)>>16,K=B*s+Z*o+E*h+32769,a[i++]=256*Y+K+(K>>16)>>16,K=x*s+w*o+A*h+32769,a[i++]=256*G+K+(K>>16)>>16}}tetrahedralInterp3D_NCh_F16(t,e){var a,i,r,n,s,o,h,u,c,l,p,d,m,g,_,v,f,C,P,b,S,M=e.outputScale,y=e.outputChannels,Y=e.g1-1,G=e.CLUT,D=e.go0,R=e.go1,B=e.go2;a=(l=Math.min(Math.max(t[0],0),65535)*Y/65535)-(n=~~l),s=n===Y?n*=B:(n*=B)+B,i=(p=Math.min(Math.max(t[1],0),65535)*Y/65535)-(o=~~p),h=o===Y?o*=R:(o*=R)+R,r=(d=Math.min(Math.max(t[2],0),65535)*Y/65535)-(u=~~d),c=u===Y?u*=D:(u*=D)+D,m=n+o+u;var x=new Array(y);if(a>=i&&i>=r)for(g=s+o+u,_=s+h+u,f=s+h+c,S=0;S<y;S++)C=G[g++],P=G[_++],b=G[m++],x[S]=(b+(C-b)*a+(P-C)*i+(G[f++]-P)*r)*M;else if(a>=r&&r>=i)for(g=s+o+u,_=s+h+c,v=s+o+c,S=0;S<y;S++)C=G[v++],P=G[g++],b=G[m++],x[S]=(b+(P-b)*a+(G[_++]-C)*i+(C-P)*r)*M;else if(a>=i&&r>=a)for(g=s+o+c,_=n+o+c,v=s+h+c,S=0;S<y;S++)C=G[g++],P=G[_++],b=G[m++],x[S]=(b+(C-P)*a+(G[v++]-C)*i+(P-b)*r)*M;else if(i>=a&&a>=r)for(g=s+h+u,_=n+h+u,f=s+h+c,S=0;S<y;S++)C=G[_++],P=G[g++],b=G[m++],x[S]=(b+(P-C)*a+(C-b)*i+(G[f++]-P)*r)*M;else if(i>=r&&r>=a)for(g=s+h+c,_=n+h+c,v=n+h+u,S=0;S<y;S++)C=G[_++],P=G[v++],b=G[m++],x[S]=(b+(G[g++]-C)*a+(P-b)*i+(C-P)*r)*M;else if(r>=i&&i>=a)for(g=s+h+c,_=n+h+c,f=n+o+c,S=0;S<y;S++)C=G[_++],P=G[f++],b=G[m++],x[S]=(b+(G[g++]-C)*a+(C-P)*i+(P-b)*r)*M;else for(S=0;S<y;S++)x[S]=G[m++]*M;return x}tetrahedralInterp4D_3or4Ch_Master(t,e){var a,i,r,n,s;r=n=Math.max(0,Math.min(1,t[0]*e.inputScale)),s=(n*=e.g1-1)-(a=Math.floor(n)),i=r>=1?a:a+1;var o=[t[1],t[2],t[3]],h=this.tetrahedralInterp3D_Master(o,e,a);if(0===s)return h;var u=this.tetrahedralInterp3D_Master(o,e,i);return h[0]=h[0]+(u[0]-h[0])*s,h[1]=h[1]+(u[1]-h[1])*s,h[2]=h[2]+(u[2]-h[2])*s,3===e.outputChannels||(h[3]=h[3]+(u[3]-h[3])*s),h}tetrahedralInterp4D_3or4Ch(t,e){var a,i,r,n,s;r=n=Math.max(0,Math.min(1,t[0]*e.inputScale)),s=(n*=e.g1-1)-(a=Math.floor(n)),i=r>=1?a:a+1;var o=[t[1],t[2],t[3]],h=this.tetrahedralInterp3D_3or4Ch(o,e,a);if(0===s)return h;var u=this.tetrahedralInterp3D_3or4Ch(o,e,i);return h[0]=h[0]+(u[0]-h[0])*s,h[1]=h[1]+(u[1]-h[1])*s,h[2]=h[2]+(u[2]-h[2])*s,3===e.outputChannels||(h[3]=h[3]+(u[3]-h[3])*s),h}detectOutputBlackpoint(t,e){var a,r=this,n=this.XYZ(0,0,0);if(!t)return n;if("link"===t.header.pClass||"abst"===t.header.pClass||"nmcl"===t.header.pClass)return n;if(e===s.absolute)return n;if(t.type===o.RGBMatrix)return n;if(4===t.version&&(e===s.perceptual||e===s.saturation))return t.type===o.RGBMatrix?(a=this.RGBDevice_to_PCSv4_or_LabD50([0,0,0],t,!0),this.Lab2XYZ(a)):this.XYZ(.00336,.0034731,.00287);var h,c=!!t.B2A[this.intent2LUTIndex(e)];if(t.type!==o.Gray&&t.type!==o.RGBLut&&t.type!==o.CMYK||!c)return this.detectBlackpoint(t,e);h=e===s.relative?this.XYZ2Lab(this.detectBlackpoint(t,e),u.d50):this.Lab(0,0,0);var l=new i("*Lab"),d=new p({precession:3}),m=new p({precession:3});d._BPCAutoEnable=!1,m._BPCAutoEnable=!1,d.create(l,t,e),m.create(t,l,s.relative);var g=[],_=[],v=this.Lab(0,0,0);v.a=Math.min(50,Math.max(-50,h.a)),v.b=Math.min(50,Math.max(-50,h.b));for(var f=0;f<256;f++){v.L=100*f/255;var C=d.forward(v),P=m.forward(C);g[f]=v.L,_[f]=P.L}for(f=254;f>0;--f)_[f]=Math.min(_[f],_[f+1]);if(!(_[0]<_[255]))return n;var b=!0,S=_[0],M=_[255];if(e===s.relative){for(f=0;f<256;f++)if(!(g[f]<=S+.2*(M-S)||g[f]-_[f]<4)){b=!1;break}if(b)return this.Lab2XYZ(h)}var y,Y,G=[];for(f=0;f<256;f++)G[f]=(_[f]-S)/(M-S);e===s.relative?(Y=.1,y=.5):(Y=.03,y=.25);var D=0,R=[],B=[];for(f=0;f<256;f++){var x=G[f];x>=Y&&x<y&&(R[D]=g[f],B[D]=G[f],D++)}return D<3?n:(v.L=function(t,e,a){var i,n,s,o,h,u=0,c=0,l=0,p=0,d=0,m=0,g=0;if(t<4)return 0;for(h=0;h<t;h++){var _=e[h],v=a[h];u+=_,c+=_*_,l+=_*_*_,p+=_*_*_*_,d+=v,m+=v*_,g+=v*_*_}var f=[t,u,c,u,c,l,c,l,p],C=r.invertMatrix(f),P=r.evalMatrix([d,m,g],C);if(n=P[2],s=P[1],o=P[0],n<1e-10)return Math.min(0,Math.max(50,-o/s));if((i=s*s-4*n*o)<=0)return 0;var b=(-s+Math.sqrt(i))/(2*n);return Math.max(0,Math.min(50,b))}(D,R,B),v.L<0&&(v.L=0),v.a=h.a,v.b=h.b,this.Lab2XYZ(v))}detectBlackpoint(t,e){var a=this.XYZ(0,0,0);return t?"link"===t.header.pClass||"abst"===t.header.pClass||"nmcl"===t.header.pClass||e===s.absolute||t.type===o.RGBMatrix?a:4!==t.version||e!==s.perceptual&&e!==s.saturation?"prtr"===t.header.pClass&&t.type===o.CMYK&&e===s.relative?this.Lab2XYZ(this.findInkLimitedBlackpoint(t)):this.Lab2XYZ(this.findMaxColourantBlackpoint(t,e)):t.type===o.RGBMatrix?this.Lab2XYZ(this.RGBDevice_to_PCSv4_or_LabD50([0,0,0],t,!0)):this.XYZ(.00336,.0034731,.00287):a}findMaxColourantBlackpoint(t,e){var a,n;switch(t.type){case o.Gray:a=r.Gray(100),n=r.Gray(0);break;case o.Duo:a=r.Duo(100,100),n=r.Duo(0,0);break;case o.RGBLut:a=r.RGB(255,255,255),n=r.RGB(0,0,0);break;case o.CMYK:a=r.CMYK(0,0,0,0),n=r.CMYK(100,100,100,100);break;case o.Lab:throw new Error("Lab profiles not supported by Black Point Compensation");default:throw new Error(t.type+" not supported by Black Point Compensation")}var s=new i("*Lab"),h=new p({precession:3});h._BPCAutoEnable=!1,h.create(t,s,e);var u=h.forward(n),c=h.forward(a);return c.L<u.L&&(u=c),u.a=0,u.b=0,(u.L>50||u.L<0)&&(u.L=0),u}findInkLimitedBlackpoint(t){var e=new i("*Lab"),a=new p({precession:3}),r=new p({precession:3});r._BPCAutoEnable=!1,r._BPCAutoEnable=!1,a.create(e,t,s.perceptual),r.create(t,e,s.relative);var n=a.forward(this.Lab(0,0,0)),o=r.forward(n);return o.L>50&&(o.L=50),o.a=o.b=0,o}}function d(t,e){var a=Math.pow(10,e);return Math.round(t*a)/a}function m(t,e,a){if(void 0===a&&(a=6),null===t)return"<NULL>";if(t.type)return r.cmsColor2String(t);if(t.hasOwnProperty("L"))return"LabD50: "+s(t.L)+", "+s(t.a)+", "+s(t.b);for(var i="",n=0;n<t.length;n++){switch(e){case"r":case"round":i+=Math.round(t[n]);break;case"f>16":case"float>16":i+=Math.round(65535*t[n]);break;default:i+=s(t[n])}n<t.length-1&&(i+=", ")}return i;function s(t){return isNaN(t)?t:t.toFixed(a)}}t.exports=p},618:(t,e,a)=>{"use strict";var i=a(362),r=i.eIntent,n=i.eColourType;function s(t,e){var a=Math.pow(10,e);return Math.round(t*a)/a}var o={intent2String:function(t){switch(t){case r.perceptual:return"Perceptual";case r.relative:return"Relative";case r.saturation:return"Saturation";case r.absolute:return"Absolute"}return"Unknown"},BradfordMtxAdapt:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},BradfordMtxAdaptInv:{m00:.9869929,m01:.4323053,m02:-.0085287,m10:-.1470543,m11:.5183603,m12:.0400428,m20:.1599627,m21:.0492912,m22:.9684867},cmsColor2String:function(t,e){switch(void 0===e&&(e=4),t.type){case n.CMYK:return a("CMYK",t,["C","M","Y","K"]);case n.CMYKf:return a("CMYKf",t,["Cf","Mf","Yf","Kf"]);case n.RGB:return a("RGB",t,["R","G","B"]);case n.RGBf:return a("RGBf",t,["Rf","Gf","Bf"]);case n.Gray:return a("Gray",t,["G"]);case n.Lab:return a("Lab",t,["L","a","b"])+(t.whitePoint?" ("+t.whitePoint.desc+")":"");case n.LCH:return a("LCH",t,["L","C","H"])+(t.whitePoint?" ("+t.whitePoint.desc+")":"");case n.XYZ:return a("XYZ",t,["X","Y","Z"]);default:return t.toString()}function a(t,a,i,r){for(var n=[],o=0;o<i.length;o++)r?n.push(i[o]+": "+s(a[i[o]],e)):n.push(s(a[i[o]],e));return t+": "+n.join(", ")}},whitepoint2String:function(t){return"(White "+t.desc+" X"+t.X.toFixed(4)+" Y"+t.Y.toFixed(4)+" Z"+t.Z.toFixed(4)+")"},XYZ:function(t,e,a,i){return{type:n.XYZ,X:t,Y:e,Z:a,whitePoint:i||this.d50}},Lab:function(t,e,a,i,r){return!1===r?{type:n.Lab,L:t,a:e,b:a,whitePoint:i||this.d50}:{type:n.Lab,L:t>100?100:t<0?0:t,a:e>127?127:e<-128?-128:e,b:a>127?127:a<-128?-128:a,whitePoint:i||this.d50}},Lch:function(t,e,a,i){return{type:n.LCH,L:t>100?100:t<0?0:t,C:e<0?0:e,H:a>360?a%360:a<0?(a+3600)%360:a,whitePoint:i||this.d50}}};o.LCH=o.Lch,o.Gray=function(t,e){return!1===e?{type:n.Gray,G:t}:{type:n.Gray,G:t>255?255:t<0?0:Math.round(t)}},o.Duo=function(t,e,a){return!1===a?{type:n.Duo,a:t,b:e}:{type:n.Duo,a:t>100?100:t<0?0:Math.round(t),b:e>100?100:e<0?0:Math.round(e)}},o.RGB2Hex=function(t){return"#"+((1<<24)+(t.R<<16)+(t.G<<8)+t.B|0).toString(16).slice(1)},o.RGB=function(t,e,a,i){return!1===i?{type:n.RGB,R:t,G:e,B:a}:{type:n.RGB,R:t>255?255:t<0?0:Math.round(t),G:e>255?255:e<0?0:Math.round(e),B:a>255?255:a<0?0:Math.round(a)}},o.RGBFloat=function(t,e,a){return{type:n.RGBf,Rf:t,Gf:e,Bf:a}},o.RGBbyte2Float=function(t,e,a){return{type:n.RGBf,Rf:t/255,Gf:e/255,Bf:a/255}},o.CMYK=function(t,e,a,i,r){return!1===r?{type:n.CMYK,C:t,M:e,Y:a,K:i}:{type:n.CMYK,C:t>100?100:t<0?0:Math.round(t),M:e>100?100:e<0?0:Math.round(e),Y:a>100?100:a<0?0:Math.round(a),K:i>100?100:i<0?0:Math.round(i)}},o.xyY=function(t,e,a){return{type:n.xyY,x:t,y:e,Y:a}},o.getWhitePoint=function(t){switch(t.toLowerCase()){case"a":return this.a;case"b":return this.b;case"c":return this.c;case"d50":return this.d50;case"d55":return this.d55;case"d75":return this.d75;case"e":return this.e;case"f2":return this.f2;case"f7":return this.f7;case"f11":return this.f11;default:return this.d65}},o.a={desc:"a",Y:1,X:1.0985,Z:.35585},o.b={desc:"b",Y:1,X:.99072,Z:.85223},o.c={desc:"c",Y:1,X:.98074,Z:1.18232},o.d50={desc:"d50",Y:1,X:.96422,Z:.82521},o.d55={desc:"d55",Y:1,X:.95682,Z:.92149},o.d65={desc:"d65",Y:1,X:.95047,Z:1.08883},o.d75={desc:"d75",Y:1,X:.94972,Z:1.22638},o.e={desc:"e",Y:1,X:1,Z:1},o.f2={desc:"f2",Y:1,X:.99186,Z:.67393},o.f7={desc:"f7",Y:1,X:.95041,Z:1.08747},o.f11={desc:"f11",Y:1,X:1.00962,Z:.6435},o.getWhitePointFromIlluminant=function(t){return e(t.X,1.0985)?this.a:e(t.X,.9907)?this.b:e(t.X,.98074)?this.c:e(t.X,.96422)?this.d50:e(t.X,.95682)?this.d55:e(t.X,.94972)?this.d75:e(t.X,1)?this.e:e(t.X,.99186)?this.f2:e(t.X,.95041)?this.f7:e(t.X,1.00962)?this.f11:{desc:"",Y:t.Y,X:t.X,Z:t.Z};function e(t,e){return t>e-.001&&t<e+.001}},o.XYZ2xyY=function(t,e){var a=t.X+t.Y+t.Z,i={x:0,y:0,Y:0};return a>0?(i.x=t.X/a,i.y=t.Y/a):(i.x=e.X/(e.X+1+e.Z),i.y=1/(e.X+1+e.Z)),i.Y=t.Y,this.xyY(i.x,i.y,i.Y)},o.xyY2XYZ=function(t){var e,a,i;return t.y<1e-6?e=a=i=0:(e=t.x*t.Y/t.y,a=t.Y,i=(1-t.x-t.y)*t.Y/t.y),this.XYZ(e,a,i)},o.XYZ2Lab=function(t,e){var a=216/24389,i=24389/27,r=t.X/e.X,s=t.Y/e.Y,o=t.Z/e.Z,h=r>a?Math.pow(r,1/3):(i*r+16)/116,u=s>a?Math.pow(s,1/3):(i*s+16)/116;return{L:116*u-16,a:500*(h-u),b:200*(u-(o>a?Math.pow(o,1/3):(i*o+16)/116)),whitePoint:e,type:n.Lab}},o.Lab2XYZ=function(t){var e=216/24389,a=24389/27,i=(t.L+16)/116,r=.002*t.a+i,s=i-.005*t.b,o=r*r*r,h=s*s*s,u=o>e?o:(116*r-16)/a,c=t.L>8?Math.pow((t.L+16)/116,3):t.L/a,l=h>e?h:(116*s-16)/a,p=t.whitePoint||this.d50;return{X:u*p.X,Y:c*p.Y,Z:l*p.Z,type:n.XYZ}},o.Lab2LabD50=function(t){var e=this.d50;if(!this.compareWhitePoints(e,t.whitePoint)){var a=o.Lab2XYZ(t);a=o.adaptation(a,t.whitePoint,e),t=o.XYZ2Lab(a,e)}return{L:t.L,a:t.a,b:t.b}},o.Lab2Lab=function(t,e){if(t.whitePoint.X!==e.X||t.whitePoint.Z!==e.Z){var a=o.Lab2XYZ(t);return a=o.adaptation(a,t.whitePoint,e),o.XYZ2Lab(a,e)}return t},o.Lab2LCH=function(t){var e=Math.sqrt(t.a*t.a+t.b*t.b),a=180*Math.atan2(t.b,t.a)/Math.PI;return a<0&&(a+=360),this.Lch(t.L,e,a)},o.LCH2Lab=function(t){var e=t.C*Math.cos(t.H*Math.PI/180),a=t.C*Math.sin(t.H*Math.PI/180);return this.Lab(t.L,e,a)},o.RGB2Lab=function(t,e,a){var i;return a?(i=this.RGBf2XYZ({Rf:t.R/255,Gf:t.G/255,Bf:t.B/255},e,a),this.compareWhitePoints(a,e.mediaWhitePoint)||(i=this.adaptation(i,e.mediaWhitePoint,a))):(a=e.mediaWhitePoint,i=this.RGBf2XYZ({Rf:t.R/255,Gf:t.G/255,Bf:t.B/255},e,a)),this.XYZ2Lab(i,a)},o.RGB2XYZ_bytes=function(t,e,a){return this.RGBf2XYZ({Rf:t.R/255,Gf:t.G/255,Bf:t.B/255,type:n.RGBf},e,a)},o.XYZ2RGB_bytes=function(t,e,a){return o.RGB2byte(o.XYZ2RGBf(t,e,a,!0))},o.Lab2RGBf=function(t,e,a){var i=this.Lab2XYZ(t);return this.XYZ2RGBf(i,t.whitePoint,e,a)},o.RGB2byte=function(t){return this.RGB(255*t.Rf,255*t.Gf,255*t.Bf)},o.cmsRGB2Hex=function(t){return"#"+(t.R<=15?"0"+t.R.toString(16):t.R.toString(16))+(t.G<=15?"0"+t.G.toString(16):t.G.toString(16))+(t.B<=15?"0"+t.B.toString(16):t.B.toString(16))},o.adaptation=function(t,e,a){var i=this.BradfordMtxAdapt,r=this.BradfordMtxAdaptInv,s=e.X*i.m00+e.Y*i.m10+e.Z*i.m20,o=e.X*i.m01+e.Y*i.m11+e.Z*i.m21,h=e.X*i.m02+e.Y*i.m12+e.Z*i.m22,u=a.X*i.m00+a.Y*i.m10+a.Z*i.m20,c=a.X*i.m01+a.Y*i.m11+a.Z*i.m21,l=a.X*i.m02+a.Y*i.m12+a.Z*i.m22,p=t.X*i.m00+t.Y*i.m10+t.Z*i.m20,d=t.X*i.m01+t.Y*i.m11+t.Z*i.m21,m=t.X*i.m02+t.Y*i.m12+t.Z*i.m22;return d*=c/o,m*=l/h,{X:(p*=u/s)*r.m00+d*r.m10+m*r.m20,Y:p*r.m01+d*r.m11+m*r.m21,Z:p*r.m02+d*r.m12+m*r.m22,type:n.XYZ}},o.XYZ2RGBDevice=function(t,e,a,i){this.compareWhitePoints(e,a.mediaWhitePoint)||(t=this.adaptation(t,e,a.mediaWhitePoint));var r=a.RGBMatrix.matrixInv,n=t.X*r.m00+t.Y*r.m01+t.Z*r.m02,s=t.X*r.m10+t.Y*r.m11+t.Z*r.m12,o=t.X*r.m20+t.Y*r.m21+t.Z*r.m22;return!1!==i&&(n=(n=n>1?1:n)<0?0:n,s=(s=s>1?1:s)<0?0:s,o=(o=o>1?1:o)<0?0:o),a.RGBMatrix.issRGB?(n=this.sRGBGamma(n),s=this.sRGBGamma(s),o=this.sRGBGamma(o)):(n=this.gamma(n,a.RGBMatrix.gamma),s=this.gamma(s,a.RGBMatrix.gamma),o=this.gamma(o,a.RGBMatrix.gamma)),[n,s,o]},o.XYZ2RGBf=function(t,e,a,i){e=e||this.D50,this.compareWhitePoints(e,a.mediaWhitePoint)||(t=this.adaptation(t,e,a.mediaWhitePoint));var r=a.RGBMatrix.matrixInv,n=t.X*r.m00+t.Y*r.m01+t.Z*r.m02,s=t.X*r.m10+t.Y*r.m11+t.Z*r.m12,o=t.X*r.m20+t.Y*r.m21+t.Z*r.m22;return!1!==i&&(n=(n=n>1?1:n)<0?0:n,s=(s=s>1?1:s)<0?0:s,o=(o=o>1?1:o)<0?0:o),a.RGBMatrix.issRGB?(n=this.sRGBGamma(n),s=this.sRGBGamma(s),o=this.sRGBGamma(o)):(n=this.gamma(n,a.RGBMatrix.gamma),s=this.gamma(s,a.RGBMatrix.gamma),o=this.gamma(o,a.RGBMatrix.gamma)),this.RGBFloat(n,s,o)},o.RGBDevice2XYZ=function(t,e,a){var i,r,s;e.RGBMatrix.issRGB?(i=this.sRGBGammaInv(t[0]),r=this.sRGBGammaInv(t[1]),s=this.sRGBGammaInv(t[2])):(i=this.gammaInv(t[0],e.RGBMatrix.gamma),r=this.gammaInv(t[1],e.RGBMatrix.gamma),s=this.gammaInv(t[2],e.RGBMatrix.gamma));var o=e.RGBMatrix.matrixV4,h={X:i*o.m00+r*o.m01+s*o.m02,Y:i*o.m10+r*o.m11+s*o.m12,Z:i*o.m20+r*o.m21+s*o.m22,type:n.XYZ};return this.compareWhitePoints(a,e.mediaWhitePoint)||(h=this.adaptation(h,e.mediaWhitePoint,a)),h},o.RGBf2XYZ=function(t,e,a){var i=t.Rf,r=t.Gf,s=t.Bf;e.RGBMatrix.issRGB?(i=this.sRGBGammaInv(i),r=this.sRGBGammaInv(r),s=this.sRGBGammaInv(s)):(i=this.gammaInv(i,e.RGBMatrix.gamma),r=this.gammaInv(r,e.RGBMatrix.gamma),s=this.gammaInv(s,e.RGBMatrix.gamma));var o=e.RGBMatrix.matrixV4,h={X:i*o.m00+r*o.m01+s*o.m02,Y:i*o.m10+r*o.m11+s*o.m12,Z:i*o.m20+r*o.m21+s*o.m22,type:n.XYZ};return this.compareWhitePoints(a,e.mediaWhitePoint)||(h=this.adaptation(h,e.mediaWhitePoint,a)),h},o.Lab2RGB=function(t,e,a){a=a||0;var i=this.Lab2RGBDevice(t,e);return{R:s(255*i[0],a),G:s(255*i[0],a),B:s(255*i[0],a),type:n.RGB}},o.Lab2sRGB=function(t){var e=(t.L+16)/116,a=t.a/500+e,i=e-t.b/200;e=Math.pow(e,3)>.008856?Math.pow(e,3):(e-16/116)/7.787,a=Math.pow(a,3)>.008856?Math.pow(a,3):(a-16/116)/7.787,i=Math.pow(i,3)>.008856?Math.pow(i,3):(i-16/116)/7.787;var r=3.2406*(a*=.95047)+-1.5372*e+-.4986*(i*=1.08883),n=-.9689*a+1.8758*e+.0415*i,s=.0557*a+-.204*e+1.057*i;return r>.0031308?r=1.055*Math.pow(r,1/2.4)-.055:r*=12.92,n>.0031308?n=1.055*Math.pow(n,1/2.4)-.055:n*=12.92,s>.0031308?s=1.055*Math.pow(s,1/2.4)-.055:s*=12.92,{R:r=Math.min(255,Math.max(0,Math.round(255*r))),G:n=Math.min(255,Math.max(0,Math.round(255*n))),B:s=Math.min(255,Math.max(0,Math.round(255*s)))}},o.Lab2RGBDevice=function(t,e){var a=216/24389,i=24389/27,r=(t.L+16)/116,s=.002*t.a+r,h=r-.005*t.b,u=s*s*s,c=h*h*h,l=u>a?u:(116*s-16)/i,p=t.L>8?Math.pow((t.L+16)/116,3):t.L/i,d=c>a?c:(116*h-16)/i,m=t.whitePoint||o.d50,g={X:l*m.X,Y:p,Z:d*m.Z,type:n.XYZ};this.compareWhitePoints(m,e.mediaWhitePoint)||(g=this.adaptation(g,m,e.mediaWhitePoint));var _=e.RGBMatrix.matrixInv,v=g.X*_.m00+g.Y*_.m01+g.Z*_.m02,f=g.X*_.m10+g.Y*_.m11+g.Z*_.m12,C=g.X*_.m20+g.Y*_.m21+g.Z*_.m22;return v=(v=v>1?1:v)<0?0:v,f=(f=f>1?1:f)<0?0:f,C=(C=C>1?1:C)<0?0:C,e.RGBMatrix.issRGB?(v=this.sRGBGamma(v),f=this.sRGBGamma(f),C=this.sRGBGamma(C)):(v=this.gamma(v,e.RGBMatrix.gamma),f=this.gamma(f,e.RGBMatrix.gamma),C=this.gamma(C,e.RGBMatrix.gamma)),[v,f,C]},o.compareWhitePoints=function(t,e,a){return a=a||.001,!(Math.abs(t.X-e.X)>a)&&!(Math.abs(t.Y-e.Y)>a)&&Math.abs(t.Z-e.Z)<=a},o.RGBDevice2LabD50=function(t,e){var a,i,r;e.RGBMatrix.issRGB?(a=this.sRGBGammaInv(t[0]),i=this.sRGBGammaInv(t[1]),r=this.sRGBGammaInv(t[2])):(a=this.gammaInv(t[0],e.RGBMatrix.gamma),i=this.gammaInv(t[1],e.RGBMatrix.gamma),r=this.gammaInv(t[2],e.RGBMatrix.gamma));var s=e.RGBMatrix.matrixV4,o={X:a*s.m00+i*s.m01+r*s.m02,Y:a*s.m10+i*s.m11+r*s.m12,Z:a*s.m20+i*s.m21+r*s.m22},h=this.d50;this.compareWhitePoints(h,e.mediaWhitePoint)||(o=this.adaptation(o,e.mediaWhitePoint,h));var u=216/24389,c=24389/27,l=o.X/h.X,p=o.Y/h.Y,d=o.Z/h.Z,m=l>u?Math.pow(l,1/3):(c*l+16)/116,g=p>u?Math.pow(p,1/3):(c*p+16)/116;return{L:116*g-16,a:500*(m-g),b:200*(g-(d>u?Math.pow(d,1/3):(c*d+16)/116)),type:n.Lab,whitePoint:h}},o.RGBf2Lab=function(t,e,a){var i,r,s;e.RGBMatrix.issRGB?(i=this.sRGBGammaInv(t.Rf),r=this.sRGBGammaInv(t.Gf),s=this.sRGBGammaInv(t.Bf)):(i=this.gammaInv(t.Rf,e.RGBMatrix.gamma),r=this.gammaInv(t.Gf,e.RGBMatrix.gamma),s=this.gammaInv(t.Bf,e.RGBMatrix.gamma));var o=e.RGBMatrix.matrixV4,h={X:i*o.m00+r*o.m01+s*o.m02,Y:i*o.m10+r*o.m11+s*o.m12,Z:i*o.m20+r*o.m21+s*o.m22};a?this.compareWhitePoints(a,e.mediaWhitePoint)||(h=this.adaptation(h,e.mediaWhitePoint,a)):a=e.mediaWhitePoint;var u=216/24389,c=24389/27,l=h.X/a.X,p=h.Y,d=h.Z/a.Z,m=l>u?Math.pow(l,1/3):(c*l+16)/116,g=p>u?Math.pow(p,1/3):(c*p+16)/116;return{L:116*g-16,a:500*(m-g),b:200*(g-(d>u?Math.pow(d,1/3):(c*d+16)/116)),type:n.Lab,whitePoint:a}},o.gamma=function(t,e){return Math.pow(t,1/e)},o.gammaInv=function(t,e){return Math.pow(t,e)},o.sRGBGamma=function(t){return t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055},o.sRGBGammaInv=function(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},o.computeMatrix=function(t){var e={m00:t.RGBMatrix.cRx/t.RGBMatrix.cRy,m01:t.RGBMatrix.cGx/t.RGBMatrix.cGy,m02:t.RGBMatrix.cBx/t.RGBMatrix.cBy,m10:1,m11:1,m12:1,m20:(1-t.RGBMatrix.cRx-t.RGBMatrix.cRy)/t.RGBMatrix.cRy,m21:(1-t.RGBMatrix.cGx-t.RGBMatrix.cGy)/t.RGBMatrix.cGy,m22:(1-t.RGBMatrix.cBx-t.RGBMatrix.cBy)/t.RGBMatrix.cBy},a=this.invertMatrix(e),i=t.mediaWhitePoint.X*a.m00+t.mediaWhitePoint.Y*a.m01+t.mediaWhitePoint.Z*a.m02,r=t.mediaWhitePoint.X*a.m10+t.mediaWhitePoint.Y*a.m11+t.mediaWhitePoint.Z*a.m12,n=t.mediaWhitePoint.X*a.m20+t.mediaWhitePoint.Y*a.m21+t.mediaWhitePoint.Z*a.m22;t.RGBMatrix.matrixV4={m00:i*e.m00,m01:r*e.m01,m02:n*e.m02,m10:i*e.m10,m11:r*e.m11,m12:n*e.m12,m20:i*e.m20,m21:r*e.m21,m22:n*e.m22},t.RGBMatrix.matrixInv=this.invertMatrix(t.RGBMatrix.matrixV4),t.RGBMatrix.XYZMatrix={m00:t.rgb.rXYZ.X,m01:t.rgb.gXYZ.X,m02:t.rgb.bXYZ.X,m10:t.rgb.rXYZ.Y,m11:t.rgb.gXYZ.Y,m12:t.rgb.bXYZ.Y,m20:t.rgb.rXYZ.Z,m21:t.rgb.gXYZ.Z,m22:t.rgb.bXYZ.Z},t.RGBMatrix.XYZMatrixInv=this.invertMatrix(t.RGBMatrix.XYZMatrix)},o.invertMatrix=function(t){var e=1/(t.m00*(t.m22*t.m11-t.m21*t.m12)-t.m10*(t.m22*t.m01-t.m21*t.m02)+t.m20*(t.m12*t.m01-t.m11*t.m02));return{m00:e*(t.m22*t.m11-t.m21*t.m12),m01:-e*(t.m22*t.m01-t.m21*t.m02),m02:e*(t.m12*t.m01-t.m11*t.m02),m10:-e*(t.m22*t.m10-t.m20*t.m12),m11:e*(t.m22*t.m00-t.m20*t.m02),m12:-e*(t.m12*t.m00-t.m10*t.m02),m20:e*(t.m21*t.m10-t.m20*t.m11),m21:-e*(t.m21*t.m00-t.m20*t.m01),m22:e*(t.m11*t.m00-t.m10*t.m01)}},o.matrixScaleValues=function(t,e){return{m00:t.m00*e,m01:t.m01*e,m02:t.m02*e,m10:t.m10*e,m11:t.m11*e,m12:t.m12*e,m20:t.m20*e,m21:t.m21*e,m22:t.m22*e}},o.matrix2Object=function(t){return{m00:t[0][0],m01:t[0][1],m02:t[0][2],m10:t[1][0],m11:t[1][1],m12:t[1][2],m20:t[2][0],m21:t[2][1],m22:t[2][2]}},o.objectToMatrix=function(t){return[[t.m00,t.m01,t.m02],[t.m10,t.m11,t.m12],[t.m20,t.m21,t.m22]]},o.multiplyMatrices=function(t,e){return this.matrix2Object(this.multiplyMatricesArray(this.objectToMatrix(t),this.objectToMatrix(e)))},o.multiplyMatricesArray=function(t,e){let a=[];for(let i=0;i<t.length;i++){a[i]=[];for(let r=0;r<e[0].length;r++){let n=0;for(let a=0;a<t[0].length;a++)n+=t[i][a]*e[a][r];a[i][r]=n}}return a},o.transpose=function(t){var e=t.m01;t.m01=t.m10,t.m10=e,e=t.m02,t.m02=t.m20,t.m20=e,e=t.m12,t.m12=t.m21,t.m21=e},o.deltaE1976=function(t,e){var a=t.L-e.L,i=t.a-e.a,r=t.b-e.b;return Math.sqrt(a*a+i*i+r*r)},o.deltaE1994=function(t,e,a){var i=!0===a?.048:.045,r=!0===a?.014:.015,n=!0===a?2:1,s=Math.sqrt(t.a*t.a+t.b*t.b),o=Math.sqrt(e.a*e.a+e.b*e.b),h=t.a-e.a,u=t.b-e.b,c=s-o,l=h*h+u*u-c*c,p=l>0?Math.sqrt(l):0,d=(t.L-e.L)/(1*n),m=c/(1*(1+i*s)),g=p/(1*(1+r*s));return Math.sqrt(d*d+m*m+g*g)},o.deltaE2000=function(t,e){var a=.5*(t.L+e.L),i=.5*(Math.sqrt(t.a*t.a+t.b*t.b)+Math.sqrt(e.a*e.a+e.b*e.b)),r=i*i*i*i*i*i*i,n=.5*(1-Math.sqrt(r/(r+6103515625))),s=t.a*(1+n),o=e.a*(1+n),h=Math.sqrt(s*s+t.b*t.b),u=Math.sqrt(o*o+e.b*e.b),c=.5*(h+u),l=180*Math.atan2(t.b,s)/Math.PI;l<0&&(l+=360);var p=180*Math.atan2(e.b,o)/Math.PI;p<0&&(p+=360);var d,m=Math.abs(l-p)>180?.5*(l+p+360):.5*(l+p),g=1-.17*Math.cos(Math.PI*(m-30)/180)+.24*Math.cos(Math.PI*(2*m)/180)+.32*Math.cos(Math.PI*(3*m+6)/180)-.2*Math.cos(Math.PI*(4*m-63)/180);d=Math.abs(p-l)<=180?p-l:p<=l?p-l+360:p-l-360;var _=e.L-t.L,v=u-h,f=2*Math.sqrt(h*u)*Math.sin(Math.PI*(.5*d)/180),C=1+.015*(a-50)*(a-50)/Math.sqrt(20+(a-50)*(a-50)),P=1+.045*c,b=1+.015*c*g,S=30*Math.exp(-(m-275)/25*((m-275)/25)),M=c*c*c*c*c*c*c,y=-2*Math.sqrt(M/(M+6103515625))*Math.sin(Math.PI*(2*S)/180);return Math.sqrt(_/(1*C)*(_/(1*C))+v/(1*P)*(v/(1*P))+f/(1*b)*(f/(1*b))+v/(1*P)*(f/(1*b))*y)},o.deltaECMC=function(t,e,a,i){void 0===a&&(a=2),void 0===i&&(i=1);for(var r=Math.sqrt(t.a*t.a+t.b*t.b),n=Math.sqrt(e.a*e.a+e.b*e.b),s=t.L<16?.511:.040975*t.L/(1+.01765*t.L),o=.0638*r/(1+.0131*r)+.638,h=r<1e-6?0:180*Math.atan2(t.b,t.a)/Math.PI;h<0;)h+=360;for(;h>=360;)h-=360;var u=h>=164&&h<=345?.56+Math.abs(.2*Math.cos(Math.PI*(h+168)/180)):.36+Math.abs(.4*Math.cos(Math.PI*(h+35)/180)),c=r*r*r*r,l=Math.sqrt(c/(c+1900)),p=o*(l*u+1-l),d=t.L-e.L,m=r-n,g=t.a-e.a,_=t.b-e.b,v=g*g+_*_-m*m,f=d/(a*s),C=m/(i*o),P=p;return Math.sqrt(f*f+C*C+v/(P*P))},o.wavelength2RGB=function(t){var e,a,i,r;return t>=380&&t<440?(e=-(t-440)/60,a=0,i=1):t>=440&&t<490?(e=0,a=(t-440)/50,i=1):t>=490&&t<510?(e=0,a=1,i=-(t-510)/20):t>=510&&t<580?(e=(t-510)/70,a=1,i=0):t>=580&&t<645?(e=1,a=-(t-645)/65,i=0):t>=645&&t<781?(e=1,a=0,i=0):(e=0,a=0,i=0),r=t>=380&&t<420?.3+.7*(t-380)/40:t>=420&&t<701?1:t>=701&&t<781?.3+.7*(780-t)/80:0,{type:n.RGB,R:0===e?0:Math.round(255*Math.pow(e*r,.8)),G:0===a?0:Math.round(255*Math.pow(a*r,.8)),B:0===i?0:Math.round(255*Math.pow(i*r,.8))}},t.exports=o},153:t=>{t.exports={XYZNumber:function(t,e){return{X:this.s15Fixed16Number(this.uint32(t,e)),Y:this.s15Fixed16Number(this.uint32(t,e+4)),Z:this.s15Fixed16Number(this.uint32(t,e+8))}},chars:function(t,e,a){for(var i="",r=0;r<a;r++)i+=String.fromCharCode(t[e]),e++;return i},unicodeChars:function(t,e,a){for(var i="",r=0;r<a;r++)i+=String.fromCharCode((t[e]<<8)+t[e+1]),e+=2;return i},array:function(t,e,a){for(var i=[],r=0;r<a;r++)i.push(t[e]),e++;return i},uInt8Array:function(t,e,a){return new Uint8Array(t.buffer.slice(e,e+a))},uInt16Array:function(t,e,a){for(var i=2*a,r=new Uint8Array(t.buffer.slice(e,e+i)),n=0;n<i;n+=2){var s=r[n];r[n]=r[n+1],r[n+1]=s}return new Uint16Array(r.buffer)},uint32:function(t,e){return t[e+3]+(t[e+2]<<8)+(t[e+1]<<16)+(t[e]<<24)},uint16:function(t,e){return t[e+1]+(t[e]<<8)},u8Fixed8Number:function(t,e){return t[e]+t[e+1]/256},s15Fixed16Number:function(t){return t>2147483648?(4294967296-t)/-65536:t/65536},float32:function(t,e){return new DataView(t.buffer).getFloat32(e)},float64:function(t,e){return new DataView(t.buffer).getFloat64(e)},s15Array:function(t,e,a){for(var i=[],r=8;r<a;r+=4)i.push(this.s15Fixed16Number(this.uint32(t,e+r)));return{sig:this.chars(t,e,4),values:i}},XYZType:function(t,e){return this.XYZNumber(t,e+8)},text:function(t,e){var a=this.chars(t,e,4);switch(a){case"desc":return this._textDescriptionType(t,e);case"text":return this._textType(t,e);case"mluc":return this._multiLocalizedUnicodeText(t,e);default:return console.log("Unknown Text Type "+a),{sig:a,text:"<Unknown Text Type>"}}},_multiLocalizedUnicodeText:function(t,e){for(var a=this.uint32(t,e+8),i=this.uint32(t,e+12),r=[],n=e+16,s="",o=0;o<a;o++){var h=this.chars(t,n,2),u=this.uint32(t,n+4)/2,c=this.uint32(t,n+8),l=this.unicodeChars(t,e+c,u);"en"===h&&""===s&&(s=l),r.push({languageCode:h,countryCode:this.chars(t,n+2,2),text:l}),n+=i}return""===s&&(s=r[0].text),{sig:this.chars(t,e,4),text:s,languages:r}},_textType:function(t,e){return{sig:this.chars(t,e,4),text:this.nts(t,e+8)}},_textDescriptionType:function(t,e){var a=this.uint32(t,e+8);return{sig:this.chars(t,e,4),text:this.nts(t,e+12),length:a}},nts:function(t,e,a){a=a||1024;for(var i="",r=0;r<a;r++){if(0===t[e])return i;i+=String.fromCharCode(t[e]),e++}return i},matrixV2:function(t,e){for(var a=[],i=0;i<9;i++)a[i]=this.s15Fixed16Number(this.uint32(t,e)),e+=4;return a},matrixV4:function(t,e){for(var a=[],i=0;i<12;i++)a[i]=this.s15Fixed16Number(this.uint32(t,e)),e+=4;return a},viewingConditions:function(t,e){return{sig:this.chars(t,e,4),illuminant:this.XYZNumber(t,e+8),surround:this.XYZNumber(t,e+20),measurement:this.illuminant2Text(this.uint32(t,e+32))}},measurement:function(t,e){return{sig:this.chars(t,e,4),observer:this.observer2Text(this.uint32(t,e+8)),tristimulus:this.XYZNumber(t,e+12),geometry:this.geometry2Text(this.uint32(t,e+24)),flare:this.flare2Text(this.uint32(t,e+28)),illuminant:this.illuminant2Text(this.uint32(t,e+32))}},observer2Text:function(t){switch(t){case 1:return"CIE 1931 standard colorimetric observer";case 2:return"CIE 1964 standard colorimetric observer";default:return"Unknown"}},geometry2Text:function(t){switch(t){case 1:return"0°:45° or 45°:0°";case 2:return"0°:d or d:0°";default:return"Unknown"}},flare2Text:function(t){return 0===t?"0 (0 %)":"1,0 (or 100 %)"},illuminant2Text:function(t){return["Unknown","D50","D65","D93","F2","D55","A","Equi-Power (E)","F8"][t]},curves:function(t,e,a,i){for(var r=[],n=e,s=0;s<a;s++){var o=this.curve(t,n,i);r.push(o);var h=o.byteLength;if(!1===h)break;h%4!=0&&(h+=4-h%4),n+=h}return r},inverseCurve:function(t,e){for(var a,i,r,n,s=1/(e-1),o=[],h=0,u=0,c=t.length-1,l=t[0]<t[c],p=0;p<e;p++){var d=p*s,m=_(d,t);if(m>=0){if(r=m/c,n=(m+1)/c,(a=t[m])===(i=t[m+1])){o.push(l?n:r);continue}u=n-(h=(n-r)/(i-a))*i}var g=Math.min(1,Math.max(0,h*d+u));o.push(g)}return o;function _(t,e){if(e.length<=1)return-1;var a;if(e[0]<e[e.length-1])for(a=0;a<e.length-2;a++){if(t>=e[a]&&t<=e[a+1])return a;if(e[a+1]<e[a]&&t>=e[a+1]&&t<=e[a])return a}else for(a=0;a<e.length-2;a++)if(e[a]<=e[a+1]){if(t>=e[a]&&t<=e[a+1])return a}else if(e[a+1]<e[a]&&t>=e[a+1]&&t<=e[a])return a;return-1}},curve:function(t,e,a,i){var r=this.chars(t,e,4),n={use:!1,count:0,data:!1,dataf:[],gamma:0,inverted:a,passThrough:!1,curveFn:!1,params:!1,byteLength:!1};switch(r){case"curv":if(n.count=this.uint32(t,e+8),n.byteLength=12+2*n.count,0===n.count)n.gamma=1,n.passThrough=!0;else if(1===n.count)n.gamma=this.u8Fixed8Number(t,e+12);else{for(n.use=!0,n.data=this.uInt16Array(t,e+12,n.count),n.dataf=new Float64Array(n.count),o=0;o<n.data.length;o++)n.dataf[o]=n.data[o]/65535;if(a&&(i=i||4096,n.dataf=this.inverseCurve(n.dataf,i),n.count=n.dataf.length),n.count>3){var s=n.data[n.count/2];n.gamma=0-Math.log(s/65535)/.69315}2===n.count&&0===n.data[0]&&65535===n.data[1]&&(n.passThrough=!0)}break;case"para":var o;n.use=!0;var h=this.uint16(t,e+8),u=[1,3,4,5,7][h];if(void 0===u){console.log("Unknown parametricCurveType function type "+h);break}for(n.byteLength=12+4*u,n.params=[],o=0;o<u;o++){var c=e+12+4*o;n.params.push(this.s15Fixed16Number(this.uint32(t,c)))}switch(h){case 0:n.gamma=n.params[0],1===n.gamma&&(n.passThrough=!0);break;case 1:n.curveFn=a?function(t,e){return(Math.pow(e,1/t[0])-t[2])/t[1]}:function(t,e){if(e>=-t[2]/t[1]){var a=t[1]*e+t[2];return a>0?Math.pow(a,t[0]):0}return 0};break;case 2:n.curveFn=a?function(t,e){var a=t[1]*t[4]+t[2],i=0;return a>=0&&(i=Math.pow(a,t[0])),e>=i?(Math.pow(e,1/t[0])-t[2])/t[1]:e/t[3]}:function(t,e){if(e>=t[4]){var a=t[1]*e+t[2];return a>0?Math.pow(a,t[0]):0}return t[3]*e};break;case 3:n.curveFn=a?function(t,e){if(e>=t[3]*t[4]+t[6]){var a=e-t[5];return a<0?0:(Math.pow(a,1/t[0])-t[2])/t[1]}return(e-t[6])/t[3]}:function(t,e){if(e>=t[4]){var a=t[1]*e+t[2];return a>0?Math.pow(a,t[0])+t[5]:t[5]}return t[3]*e+t[6]};break;case 4:n.curveFn=a?function(t,e){if(e>=t[3]*t[4]+t[6]){var a=e-t[5];return a<0||t[0]<1e-4||t[1]<1e-4?0:(Math.pow(a,1/t[0])-t[2])/t[1]}return t[3]<1e-4?0:(e-t[6])/t[3]}:function(t,e){if(e>=t[4]){var a=t[1]*e+t[2];return a>0?Math.pow(a,t[0])+t[5]:t[5]}return e*t[3]+t[6]};break;default:throw"parametricCurveType function type "+h+" not implemented"}break;default:throw"Unknown CURVE type"+r}return n},lut:function(t,e){var a,i,r,n,s,o,h,u,c,l,p=this.chars(t,e,4),d={type:p},m=[];switch(p){case"mft2":for(d.precision=16,d.inputScale=1,d.outputScale=1/65535,d.inputChannels=t[e+8],d.outputChannels=t[e+9],a=t[e+10],i=0;i<d.inputChannels;i++)m.push(a);d.gridPoints=m,d.matrix=this.matrixV2(t,e+12),d.inputTableEntries=this.uint16(t,e+48),d.outputTableEntries=this.uint16(t,e+50);var g=e+52;for(u=d.inputTableEntries*d.inputChannels,d.inputCurve={channels:d.inputChannels,entries:this.uint16(t,e+48),table:this.uInt16Array(t,g,u),tablef:new Float64Array(u),outputScale:1/65535},g+=2*u,i=0;i<d.inputCurve.table.length;i++)d.inputCurve.tablef[i]=d.inputCurve.table[i]/65535;for(l=Math.pow(d.gridPoints[0],d.inputChannels)*d.outputChannels,d.CLUT=this.uInt16Array(t,g,l),g+=2*l,c=d.outputTableEntries*d.outputChannels,d.outputCurve={channels:d.outputChannels,entries:this.uint16(t,e+50),table:this.uInt16Array(t,g,c),tablef:new Float64Array(c),outputScale:1/65535},i=0;i<d.outputCurve.table.length;i++)d.outputCurve.tablef[i]=d.outputCurve.table[i]/65535;break;case"mft1":for(d.precision=8,d.inputScale=1,d.outputScale=1/255,d.inputChannels=t[e+8],d.outputChannels=t[e+9],a=t[e+10],i=0;i<d.inputChannels;i++)m.push(a);for(d.gridPoints=m,d.matrix=this.matrixV2(t,e+12),d.inputTableEntries=256,d.outputTableEntries=256,u=d.inputTableEntries*d.inputChannels,d.inputCurve={channels:d.inputChannels,entries:256,table:this.uInt8Array(t,e+48,u),tablef:new Float64Array(u),outputScale:1/255},i=0;i<d.inputCurve.table.length;i++)d.inputCurve.tablef[i]=d.inputCurve.table[i]/255;for(l=Math.pow(d.gridPoints[0],d.inputChannels)*d.outputChannels,d.CLUT=this.uInt8Array(t,e+48+u,l),c=d.outputTableEntries*d.outputChannels,d.outputCurve={channels:d.outputChannels,entries:256,table:this.uInt8Array(t,e+48+u+l,c),tablef:new Float64Array(c),outputScale:1/255},i=0;i<d.outputCurve.table.length;i++)d.outputCurve.tablef[i]=d.outputCurve.table[i]/255;break;case"mAB ":d.inputChannels=t[e+8],d.outputChannels=t[e+9],r=this.uint32(t,e+12),n=this.uint32(t,e+16),s=this.uint32(t,e+20),o=this.uint32(t,e+24),h=this.uint32(t,e+28),d.bCurves=0!==r&&this.curves(t,e+r,d.outputChannels,!1),d.matrix=0!==n&&this.matrixV4(t,e+n),0===o?d.CLUT=!1:this.CLUT4(d,t,e+o,d.inputChannels,d.outputChannels),d.mCurves=0!==s&&this.curves(t,e+s,d.outputChannels,!1),d.aCurves=0!==h&&this.curves(t,e+h,d.inputChannels,!1);break;case"mBA ":d.inputChannels=t[e+8],d.outputChannels=t[e+9],r=this.uint32(t,e+12),n=this.uint32(t,e+16),s=this.uint32(t,e+20),o=this.uint32(t,e+24),h=this.uint32(t,e+28),d.bCurves=0!==r&&this.curves(t,e+r,d.inputChannels,!1),d.matrix=0!==n&&this.matrixV4(t,e+n),0===o?d.CLUT=!1:this.CLUT4(d,t,e+o,d.inputChannels,d.outputChannels),d.mCurves=0!==s&&this.curves(t,e+s,d.inputChannels,!1),d.aCurves=0!==h&&this.curves(t,e+h,d.outputChannels,!1);break;default:console.log("Unsupported LUT Tag "+p)}return d.g1=d.gridPoints[0],d.g2=d.g1*d.gridPoints[1],d.g3=d.g2*d.gridPoints[2],d.g4=d.g3*d.gridPoints[3],d.go0=d.outputChannels,d.go1=d.g1*d.outputChannels,d.go2=d.g2*d.outputChannels,d.go3=d.g3*d.outputChannels,d},CLUT4:function(t,e,a,i,r){for(var n=[],s=e[a+16],o=0;o<i;o++)n.push(e[a+o]);var h=n[0];for(o=1;o<i;o++)h*=n[o];1===s?(t.CLUT=this.uInt8Array(e,a+20,h*r),t.inputScale=1,t.outputScale=1/255):(t.CLUT=this.uInt16Array(e,a+20,h*r),t.inputScale=1,t.outputScale=1/65535),t.precision=8*s,t.gridPoints=n},multiProcessElement:function(t,e){for(var a=[],i=this.uint16(t,e+8),r=this.uint16(t,e+10),n=this.uint32(t,e+12),s=[],o=0;o<n;o++)s.push({offset:this.uint32(t,e+16+4*o),size:this.uint32(t,e+16+4*o+4)});for(o=0;o<n;o++){var h=e+s[o].offset,u=this.chars(t,h,4);switch(u){case"cvst":case"matf":case"clut":a.push({sig:u});break;case"bACS":case"eACS":break;default:console.log("Unknown MultiProcess Element "+u)}}return{inputChannels:i,outputChannels:r,elements:a}}}},362:t=>{t.exports={eColourType:{None:0,XYZ:1,Lab:2,LCH:3,Gray:4,RGB:5,CMYK:6,custom:7,RGBf:8,CMYKf:9,Spectrum:10,Greyf:11,Duo:12,Duof:13,xyY:14},eProfileType:{Lab:0,RGBMatrix:1,RGBLut:2,CMYK:3,Gray:4,Duo:5,XYZ:6},eIntent:{perceptual:0,relative:1,saturation:2,absolute:3},intent2String:function(t){return["Perceptual","Relative","Saturation","Absolute"][t]||"unknown"},illuminant:{a:{desc:"a",Y:1,X:1.0985,Z:.35585},b:{desc:"b",Y:1,X:.99072,Z:.85223},c:{desc:"c",Y:1,X:.98074,Z:1.18232},d50:{desc:"d50",Y:1,X:.96422,Z:.82521},d55:{desc:"d55",Y:1,X:.95682,Z:.92149},d65:{desc:"d65",Y:1,X:.95047,Z:1.08883},d75:{desc:"d75",Y:1,X:.94972,Z:1.22638},e:{desc:"e",Y:1,X:1,Z:1},f2:{desc:"f2",Y:1,X:.99186,Z:.67393},f7:{desc:"f7",Y:1,X:.95041,Z:1.08747},f11:{desc:"f11",Y:1,X:1.00962,Z:.6435}},encoding:{device:0,PCSv2:1,PCSv4:2,PCSXYZ:3,LabD50:3,cmsLab:4,cmsRGB:5,cmsCMYK:6,cmsXYZ:7},encodingStr:["device","PCSv2","PCSv4","PCSXYZ","LabD50","cmsLab","cmsRGB","cmsCMYK","cmsXYZ"]}},660:(t,e,a)=>{var i=a(362);t.exports={convert:a(618),Spectral:a(706),Loader:a(155),Profile:a(577),Transform:a(369),eColourType:i.eColourType,eProfileType:i.eProfileType,eIntent:i.eIntent,encoding:i.encoding,encodingStr:i.encodingStr}}},e={},a=function a(i){var r=e[i];if(void 0!==r)return r.exports;var n=e[i]={exports:{}};return t[i](n,n.exports,a),n.exports}(660);jsColorEngine=a})();