define(["exports","./Cartesian2-2b41fabe","./Cartographic-1d953166","./Check-2514d21d","./when-d186add7","./Math-7f5f2992"],(function(e,o,t,n,r,a){"use strict";var d=1/256,c={octEncodeInRange:function(e,o,r){n.o.defined("vector",e),n.o.defined("result",r);var d=t.t.magnitudeSquared(e);if(Math.abs(d-1)>a.e.EPSILON6)throw new n.t("vector must be normalized.");if(r.x=e.x/(Math.abs(e.x)+Math.abs(e.y)+Math.abs(e.z)),r.y=e.y/(Math.abs(e.x)+Math.abs(e.y)+Math.abs(e.z)),e.z<0){var c=r.x,i=r.y;r.x=(1-Math.abs(i))*a.e.signNotZero(c),r.y=(1-Math.abs(c))*a.e.signNotZero(i)}return r.x=a.e.toSNorm(r.x,o),r.y=a.e.toSNorm(r.y,o),r},octEncode:function(e,o){return c.octEncodeInRange(e,255,o)}},i=new o.o,f=new Uint8Array(1);function u(e){return f[0]=e,f[0]}c.octEncodeToCartesian4=function(e,o){return c.octEncodeInRange(e,65535,i),o.x=u(i.x*d),o.y=u(i.x),o.z=u(i.y*d),o.w=u(i.y),o},c.octDecodeInRange=function(e,o,r,d){if(n.o.defined("result",d),e<0||e>r||o<0||o>r)throw new n.t("x and y must be unsigned normalized integers between 0 and "+r);if(d.x=a.e.fromSNorm(e,r),d.y=a.e.fromSNorm(o,r),d.z=1-(Math.abs(d.x)+Math.abs(d.y)),d.z<0){var c=d.x;d.x=(1-Math.abs(d.y))*a.e.signNotZero(c),d.y=(1-Math.abs(c))*a.e.signNotZero(d.y)}return t.t.normalize(d,d)},c.octDecode=function(e,o,t){return c.octDecodeInRange(e,o,255,t)},c.octDecodeFromCartesian4=function(e,o){n.o.typeOf.object("encoded",e),n.o.typeOf.object("result",o);var t=e.x,r=e.y,a=e.z,d=e.w;if(t<0||t>255||r<0||r>255||a<0||a>255||d<0||d>255)throw new n.t("x, y, z, and w must be unsigned normalized integers between 0 and 255");var i=256*t+r,f=256*a+d;return c.octDecodeInRange(i,f,65535,o)},c.octPackFloat=function(e){return n.o.defined("encoded",e),256*e.x+e.y};var s=new o.o;function h(e){return e>>1^-(1&e)}c.octEncodeFloat=function(e){return c.octEncode(e,s),c.octPackFloat(s)},c.octDecodeFloat=function(e,o){n.o.defined("value",e);var t=e/256,r=Math.floor(t),a=256*(t-r);return c.octDecode(r,a,o)},c.octPack=function(e,o,t,r){n.o.defined("v1",e),n.o.defined("v2",o),n.o.defined("v3",t),n.o.defined("result",r);var a=c.octEncodeFloat(e),d=c.octEncodeFloat(o),i=c.octEncode(t,s);return r.x=65536*i.x+a,r.y=65536*i.y+d,r},c.octUnpack=function(e,o,t,r){n.o.defined("packed",e),n.o.defined("v1",o),n.o.defined("v2",t),n.o.defined("v3",r);var a=e.x/65536,d=Math.floor(a),i=65536*(a-d);a=e.y/65536;var f=Math.floor(a),u=65536*(a-f);c.octDecodeFloat(i,o),c.octDecodeFloat(u,t),c.octDecode(d,f,r)},c.compressTextureCoordinates=function(e){return n.o.defined("textureCoordinates",e),4096*(4095*e.x|0)+(4095*e.y|0)},c.decompressTextureCoordinates=function(e,o){n.o.defined("compressed",e),n.o.defined("result",o);var t=e/4096,r=Math.floor(t);return o.x=r/4095,o.y=(e-4096*r)/4095,o},c.zigZagDeltaDecode=function(e,o,t){n.o.defined("uBuffer",e),n.o.defined("vBuffer",o),n.o.typeOf.number.equals("uBuffer.length","vBuffer.length",e.length,o.length),r.e(t)&&n.o.typeOf.number.equals("uBuffer.length","heightBuffer.length",e.length,t.length);for(var a=e.length,d=0,c=0,i=0,f=0;f<a;++f)d+=h(e[f]),c+=h(o[f]),e[f]=d,o[f]=c,r.e(t)&&(i+=h(t[f]),t[f]=i)},c.octShortToFloat=function(e){return a.e.clamp(3051850947599719e-20*e,-1,1)},c.octShortDecode=function(e,o,r){if(n.o.defined("result",r),r.x=c.octShortToFloat(e),r.y=c.octShortToFloat(o),r.z=1-(Math.abs(r.x)+Math.abs(r.y)),r.z<0){var d=r.x;r.x=(1-Math.abs(r.y))*a.e.signNotZero(d),r.y=(1-Math.abs(d))*a.e.signNotZero(r.y)}return t.t.normalize(r,r)},e.t=c}));
