1 line
No EOL
24 KiB
JavaScript
1 line
No EOL
24 KiB
JavaScript
!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MaplibreInspect=t()}(function(){return function r(o,i,s){function a(e,t){if(!i[e]){if(!o[e]){var n="function"==typeof require&&require;if(!t&&n)return n(e,!0);if(u)return u(e,!0);throw(n=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",n}n=i[e]={exports:{}},o[e][0].call(n.exports,function(t){return a(o[e][1][t]||t)},n,n.exports,r,o,i,s)}return i[e].exports}for(var u="function"==typeof require&&require,t=0;t<s.length;t++)a(s[t]);return a}({1:[function(t,e,n){"use strict";t=t("./lib/MaplibreInspect");e.exports=t},{"./lib/MaplibreInspect":3}],2:[function(t,e,n){"use strict";function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n,r=arguments[e];for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function o(t){var e,n;t=r({show:!0,onToggle:function(){}},t),this._btn=((n=document.createElement("button")).className="maplibregl-ctrl-icon maplibregl-ctrl-inspect",n.type="button",n["aria-label"]="Inspect",n),this._btn.onclick=t.onToggle,this.elem=(e=this._btn,n=t.show,(t=document.createElement("div")).className="maplibregl-ctrl maplibregl-ctrl-group",t.appendChild(e),n||(t.style.display="none"),t)}o.prototype.setInspectIcon=function(){this._btn.className="maplibregl-ctrl-icon maplibregl-ctrl-inspect"},o.prototype.setMapIcon=function(){this._btn.className="maplibregl-ctrl-icon maplibregl-ctrl-map"},e.exports=o},{}],3:[function(t,e,n){"use strict";function i(){return(i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n,r=arguments[e];for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var r=t("./stylegen"),o=t("./InspectButton"),s=t("lodash.isequal"),a=t("./renderPopup"),u=t("./colors");function c(t){if(!(this instanceof c))throw new Error("MaplibreInspect needs to be called with the new keyword");var e=null;window.maplibregl?e=new window.maplibregl.Popup({closeButton:!1,closeOnClick:!1}):t.popup||console.error("Maplibre GL JS can not be found. Make sure to include it or pass an initialized MaplibreGL Popup to MaplibreInspect if you are using moduleis."),this.options=i({showInspectMap:!1,showInspectButton:!0,showInspectMapPopup:!0,showMapPopup:!1,showMapPopupOnHover:!0,showInspectMapPopupOnHover:!0,blockHoverPopupOnClick:!1,backgroundColor:"#fff",assignLayerColor:u.brightColor,buildInspectStyle:r.generateInspectStyle,renderPopup:a,popup:e,selectThreshold:5,useInspectStyle:!0,queryParameters:{},sources:{}},t),this.sources=this.options.sources,this.assignLayerColor=this.options.assignLayerColor,this.toggleInspector=this.toggleInspector.bind(this),this._popup=this.options.popup,this._popupBlocked=!1,this._showInspectMap=this.options.showInspectMap,this._onSourceChange=this._onSourceChange.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onRightClick=this._onRightClick.bind(this),this._onStyleChange=this._onStyleChange.bind(this),this._originalStyle=null,this._toggle=new o({show:this.options.showInspectButton,onToggle:this.toggleInspector.bind(this)})}c.prototype.toggleInspector=function(){this._showInspectMap=!this._showInspectMap,this.render()},c.prototype._inspectStyle=function(){var t=r.generateColoredLayers(this.sources,this.assignLayerColor);return this.options.buildInspectStyle(this._map.getStyle(),t,{backgroundColor:this.options.backgroundColor})},c.prototype.render=function(){var t;this._showInspectMap?(this.options.useInspectStyle&&this._map.setStyle(i(t=this._inspectStyle(),{metadata:i({},t.metadata,{"maplibregl-inspect:inspect":!0})})),this._toggle.setMapIcon()):this._originalStyle&&(this._popup&&this._popup.remove(),this.options.useInspectStyle&&this._map.setStyle(this._originalStyle),this._toggle.setInspectIcon())},c.prototype._onSourceChange=function(t){var r=this.sources,o=this._map,e=o.getStyle(),n=Object.keys(e.sources),e=i({},r);"visibility"!==t.sourceDataType&&t.isSourceLoaded&&(Object.keys(o.style.sourceCaches).forEach(function(t){var e=o.style.sourceCaches[t]||{_source:{}},n=e._source.vectorLayerIds;n?r[t]=n:"geojson"===e._source.type&&(r[t]=[])}),Object.keys(r).forEach(function(t){-1===n.indexOf(t)&&delete r[t]}),!s(e,r)&&0<Object.keys(r).length&&this.render())},c.prototype._onStyleChange=function(){var t,e=this._map.getStyle();(t=e).metadata&&t.metadata["maplibregl-inspect:inspect"]||(this._originalStyle=e)},c.prototype._onRightClick=function(){this.options.showMapPopupOnHover||this.options.showInspectMapPopupOnHover||this.options.blockHoverPopupOnClick||this._popup&&this._popup.remove()},c.prototype._onMousemove=function(t){if(this._showInspectMap){if(!this.options.showInspectMapPopup)return;if("mousemove"===t.type&&!this.options.showInspectMapPopupOnHover)return;"click"===t.type&&this.options.showInspectMapPopupOnHover&&this.options.blockHoverPopupOnClick&&(this._popupBlocked=!this._popupBlocked)}else{if(!this.options.showMapPopup)return;if("mousemove"===t.type&&!this.options.showMapPopupOnHover)return;"click"===t.type&&this.options.showMapPopupOnHover&&this.options.blockHoverPopupOnClick&&(this._popupBlocked=!this._popupBlocked)}var e;!this._popupBlocked&&this._popup&&(e=0===this.options.selectThreshold?t.point:[[t.point.x-this.options.selectThreshold,t.point.y+this.options.selectThreshold],[t.point.x+this.options.selectThreshold,t.point.y-this.options.selectThreshold]],e=this._map.queryRenderedFeatures(e,this.options.queryParameters)||[],this._map.getCanvas().style.cursor=e.length?"pointer":"",e.length?(this._popup.setLngLat(t.lngLat),"string"==typeof(e=this.options.renderPopup(e))?this._popup.setHTML(e):this._popup.setDOMContent(e),this._popup.addTo(this._map)):this._popup.remove())},c.prototype.onAdd=function(t){return this._map=t,0===Object.keys(this.sources).length&&(t.on("tiledata",this._onSourceChange),t.on("sourcedata",this._onSourceChange)),t.on("styledata",this._onStyleChange),t.on("load",this._onStyleChange),t.on("mousemove",this._onMousemove),t.on("click",this._onMousemove),t.on("contextmenu",this._onRightClick),this._toggle.elem},c.prototype.onRemove=function(){this._map.off("styledata",this._onStyleChange),this._map.off("load",this._onStyleChange),this._map.off("tiledata",this._onSourceChange),this._map.off("sourcedata",this._onSourceChange),this._map.off("mousemove",this._onMousemove),this._map.off("click",this._onMousemove),this._map.off("contextmenu",this._onRightClick);var t=this._toggle.elem;t.parentNode.removeChild(t),this._map=void 0},e.exports=c},{"./InspectButton":2,"./colors":4,"./renderPopup":5,"./stylegen":6,"lodash.isequal":7}],4:[function(t,e,n){"use strict";var o=t("randomcolor");n.brightColor=function(t,e){var n="bright",r=null;return/water|ocean|lake|sea|river/.test(t)&&(r="blue"),/state|country|place/.test(t)&&(r="pink"),/road|highway|transport/.test(t)&&(r="orange"),/contour|building/.test(t)&&(r="monochrome"),/building/.test(t)&&(n="dark"),/contour|landuse/.test(t)&&(r="yellow"),/wood|forest|park|landcover/.test(t)&&(r="green"),"rgba("+o({luminosity:n,hue:r,seed:t,format:"rgbArray"}).concat([e||1]).join(", ")+")"}},{randomcolor:8}],5:[function(t,e,n){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){return'<div class="maplibregl-inspect_property"><div class="maplibregl-inspect_property-name">'+t+'</div><div class="maplibregl-inspect_property-value">'+(null==(e=e)?e:e instanceof Date?e.toLocaleString():"object"===r(e)||"number"==typeof e||"string"==typeof e?e.toString():e)+"</div></div>"}function i(t){return t.map(function(t){return'<div class="maplibregl-inspect_feature">'+(n='<div class="maplibregl-inspect_layer">'+((e=t).layer["source-layer"]||e.layer.source)+"</div>",r=o("$type",e.geometry.type),t=Object.keys(e.properties).map(function(t){return o(t,e.properties[t])}),[n,r].concat(t).join(""))+"</div>";var e,n,r}).join("")}e.exports=function(t){return'<div class="maplibregl-inspect_popup">'+i(t)+"</div>"}},{}],6:[function(t,e,n){"use strict";function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n,r=arguments[e];for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function a(t,e,n){t={id:[e,n,"circle"].join("_"),source:e,type:"circle",paint:{"circle-color":t,"circle-radius":2},filter:["==","$type","Point"]};return n&&(t["source-layer"]=n),t}function u(t,e,n,r){t={id:[n,r,"polygon"].join("_"),source:n,type:"fill",paint:{"fill-color":t,"fill-antialias":!0,"fill-outline-color":t},filter:["==","$type","Polygon"]};return r&&(t["source-layer"]=r),t}function c(t,e,n){t={id:[e,n,"line"].join("_"),source:e,layout:{"line-join":"round","line-cap":"round"},type:"line",paint:{"line-color":t},filter:["==","$type","LineString"]};return n&&(t["source-layer"]=n),t}n.polygonLayer=u,n.lineLayer=c,n.circleLayer=a,n.generateInspectStyle=function(n,t,e){var e={id:"background",type:"background",paint:{"background-color":(e=o({backgroundColor:"#fff"},e)).backgroundColor}},r={};return Object.keys(n.sources).forEach(function(t){var e=n.sources[t];"vector"!==e.type&&"geojson"!==e.type||(r[t]=e)}),o(n,{layers:[e].concat(t),soources:r})},n.generateColoredLayers=function(e,n){var r=[],o=[],i=[];function s(t){t=n.bind(null,t);return{circle:t(.8),line:t(.6),polygon:t(.3),polygonOutline:t(.6),default:t(1)}}return Object.keys(e).forEach(function(n){var t=e[n];t&&0!==t.length?t.forEach(function(t){var e=s(t);o.push(a(e.circle,n,t)),i.push(c(e.line,n,t)),r.push(u(e.polygon,e.polygonOutline,n,t))}):(t=s(n),o.push(a(t.circle,n)),i.push(c(t.line,n)),r.push(u(t.polygon,t.polygonOutline,n)))}),r.concat(i).concat(o)}},{}],7:[function(t,Ft,Ht){!function($t){!function(){var r="__lodash_hash_undefined__",b=1,d=2,h=9007199254740991,p="[object Arguments]",f="[object Array]",e="[object AsyncFunction]",y="[object Boolean]",g="[object Date]",_="[object Error]",n="[object Function]",o="[object GeneratorFunction]",v="[object Map]",m="[object Number]",i="[object Null]",w="[object Object]",s="[object Promise]",a="[object Proxy]",j="[object RegExp]",k="[object Set]",O="[object String]",M="[object Symbol]",u="[object Undefined]",c="[object WeakMap]",I="[object ArrayBuffer]",S="[object DataView]",l=/^\[object .+?Constructor\]$/,C=/^(?:0|[1-9]\d*)$/,P={};P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0,P[p]=P[f]=P[I]=P[y]=P[S]=P[g]=P[_]=P[n]=P[v]=P[m]=P[w]=P[j]=P[k]=P[O]=P[c]=!1;var t="object"==typeof $t&&$t&&$t.Object===Object&&$t,A="object"==typeof self&&self&&self.Object===Object&&self,z=t||A||Function("return this")(),L="object"==typeof Ht&&Ht&&!Ht.nodeType&&Ht,x=L&&"object"==typeof Ft&&Ft&&!Ft.nodeType&&Ft,R=x&&x.exports===L,E=R&&t.process,T=function(){try{return E&&E.binding&&E.binding("util")}catch(t){}}(),A=T&&T.isTypedArray;function B(t){var n=-1,r=Array(t.size);return t.forEach(function(t,e){r[++n]=[e,t]}),r}function $(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var F,H,x=Array.prototype,L=Function.prototype,N=Object.prototype,t=z["__core-js_shared__"],q=L.toString,D=N.hasOwnProperty,U=(T=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+T:"",G=N.toString,V=RegExp("^"+q.call(D).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),L=R?z.Buffer:void 0,t=z.Symbol,W=z.Uint8Array,J=N.propertyIsEnumerable,X=x.splice,K=t?t.toStringTag:void 0,Q=Object.getOwnPropertySymbols,T=L?L.isBuffer:void 0,Y=(F=Object.keys,H=Object,function(t){return F(H(t))}),R=kt(z,"DataView"),Z=kt(z,"Map"),x=kt(z,"Promise"),L=kt(z,"Set"),z=kt(z,"WeakMap"),tt=kt(Object,"create"),et=It(R),nt=It(Z),rt=It(x),ot=It(L),it=It(z),t=t?t.prototype:void 0,st=t?t.valueOf:void 0;function at(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function ut(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function ct(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function lt(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new ct;++e<n;)this.add(t[e])}function pt(t){t=this.__data__=new ut(t);this.size=t.size}function ht(t,e){var n,r,o,i=Pt(t),s=!i&&Ct(t),a=!i&&!s&&At(t),u=!i&&!s&&!a&&Tt(t),c=i||s||a||u,l=c?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],p=l.length;for(n in t)!e&&!D.call(t,n)||c&&("length"==n||a&&("offset"==n||"parent"==n)||u&&("buffer"==n||"byteLength"==n||"byteOffset"==n)||(r=n,!!(o=null==(o=p)?h:o)&&("number"==typeof r||C.test(r))&&-1<r&&r%1==0&&r<o))||l.push(n);return l}function ft(t,e){for(var n=t.length;n--;)if(St(t[n][0],e))return n;return-1}function yt(t,e,n){e=e(t);return Pt(t)?e:function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}(e,n(t))}function dt(t){return null==t?void 0===t?u:i:K&&K in Object(t)?function(t){var e=D.call(t,K),n=t[K];try{var r=!(t[K]=void 0)}catch(t){}var o=G.call(t);r&&(e?t[K]=n:delete t[K]);return o}(t):G.call(t)}function gt(t){return Rt(t)&&dt(t)==p}function _t(t,e,n,r,o){return t===e||(null==t||null==e||!Rt(t)&&!Rt(e)?t!=t&&e!=e:function(t,e,n,r,o,i){var s=Pt(t),a=Pt(e),u=s?f:Mt(t),c=a?f:Mt(e),l=(u=u==p?w:u)==w,a=(c=c==p?w:c)==w,c=u==c;if(c&&At(t)){if(!At(e))return!1;l=!(s=!0)}if(c&&!l)return i=i||new pt,s||Tt(t)?mt(t,e,n,r,o,i):function(t,e,n,r,o,i,s){switch(n){case S:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case I:return t.byteLength==e.byteLength&&i(new W(t),new W(e))?!0:!1;case y:case g:case m:return St(+t,+e);case _:return t.name==e.name&&t.message==e.message;case j:case O:return t==e+"";case v:var a=B;case k:var u=r&b;if(a=a||$,t.size!=e.size&&!u)return!1;u=s.get(t);if(u)return u==e;r|=d,s.set(t,e);a=mt(a(t),a(e),r,o,i,s);return s.delete(t),a;case M:if(st)return st.call(t)==st.call(e)}return!1}(t,e,u,n,r,o,i);if(!(n&b)){l=l&&D.call(t,"__wrapped__"),a=a&&D.call(e,"__wrapped__");if(l||a){l=l?t.value():t,a=a?e.value():e;return i=i||new pt,o(l,a,n,r,i)}}return c&&(i=i||new pt,function(t,e,n,r,o,i){var s=n&b,a=wt(t),u=a.length,c=wt(e).length;if(u!=c&&!s)return!1;var l=u;for(;l--;){var p=a[l];if(!(s?p in e:D.call(e,p)))return!1}var h=i.get(t);if(h&&i.get(e))return h==e;var f=!0;i.set(t,e),i.set(e,t);var y=s;for(;++l<u;){p=a[l];var d,g=t[p],_=e[p];if(!(void 0===(d=r?s?r(_,g,p,e,t,i):r(g,_,p,t,e,i):d)?g===_||o(g,_,n,r,i):d)){f=!1;break}y=y||"constructor"==p}f&&!y&&(c=t.constructor,h=e.constructor,c!=h&&"constructor"in t&&"constructor"in e&&!("function"==typeof c&&c instanceof c&&"function"==typeof h&&h instanceof h)&&(f=!1));return i.delete(t),i.delete(e),f}(t,e,n,r,o,i))}(t,e,n,r,_t,o))}function bt(t){var e;return xt(t)&&(e=t,!(U&&U in e))&&(zt(t)?V:l).test(It(t))}function vt(t){if(n="function"==typeof(n=(e=t)&&e.constructor)&&n.prototype||N,e!==n)return Y(t);var e,n,r,o=[];for(r in Object(t))D.call(t,r)&&"constructor"!=r&&o.push(r);return o}function mt(t,e,n,r,o,i){var s=n&b,a=t.length,u=e.length;if(a!=u&&!(s&&a<u))return!1;u=i.get(t);if(u&&i.get(e))return u==e;var c=-1,l=!0,p=n&d?new lt:void 0;for(i.set(t,e),i.set(e,t);++c<a;){var h,f=t[c],y=e[c];if(void 0!==(h=r?s?r(y,f,c,e,t,i):r(f,y,c,t,e,i):h)){if(h)continue;l=!1;break}if(p){if(!function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return 1}(e,function(t,e){return!p.has(e)&&(f===t||o(f,t,n,r,i))&&p.push(e)})){l=!1;break}}else if(f!==y&&!o(f,y,n,r,i)){l=!1;break}}return i.delete(t),i.delete(e),l}function wt(t){return yt(t,Bt,Ot)}function jt(t,e){var n,r=t.__data__;return("string"==(t=typeof(n=e))||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==n:null===n)?r["string"==typeof e?"string":"hash"]:r.map}function kt(t,e){e=e,e=null==(t=t)?void 0:t[e];return bt(e)?e:void 0}at.prototype.clear=function(){this.__data__=tt?tt(null):{},this.size=0},at.prototype.delete=function(t){return t=this.has(t)&&delete this.__data__[t],this.size-=t?1:0,t},at.prototype.get=function(t){var e=this.__data__;if(tt){var n=e[t];return n===r?void 0:n}return D.call(e,t)?e[t]:void 0},at.prototype.has=function(t){var e=this.__data__;return tt?void 0!==e[t]:D.call(e,t)},at.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=tt&&void 0===e?r:e,this},ut.prototype.clear=function(){this.__data__=[],this.size=0},ut.prototype.delete=function(t){var e=this.__data__;return!((t=ft(e,t))<0)&&(t==e.length-1?e.pop():X.call(e,t,1),--this.size,!0)},ut.prototype.get=function(t){var e=this.__data__;return(t=ft(e,t))<0?void 0:e[t][1]},ut.prototype.has=function(t){return-1<ft(this.__data__,t)},ut.prototype.set=function(t,e){var n=this.__data__,r=ft(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},ct.prototype.clear=function(){this.size=0,this.__data__={hash:new at,map:new(Z||ut),string:new at}},ct.prototype.delete=function(t){return t=jt(this,t).delete(t),this.size-=t?1:0,t},ct.prototype.get=function(t){return jt(this,t).get(t)},ct.prototype.has=function(t){return jt(this,t).has(t)},ct.prototype.set=function(t,e){var n=jt(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},lt.prototype.add=lt.prototype.push=function(t){return this.__data__.set(t,r),this},lt.prototype.has=function(t){return this.__data__.has(t)},pt.prototype.clear=function(){this.__data__=new ut,this.size=0},pt.prototype.delete=function(t){var e=this.__data__,t=e.delete(t);return this.size=e.size,t},pt.prototype.get=function(t){return this.__data__.get(t)},pt.prototype.has=function(t){return this.__data__.has(t)},pt.prototype.set=function(t,e){var n=this.__data__;if(n instanceof ut){var r=n.__data__;if(!Z||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new ct(r)}return n.set(t,e),this.size=n.size,this};var Ot=Q?function(e){return null==e?[]:(e=Object(e),function(t,e){for(var n=-1,r=null==t?0:t.length,o=0,i=[];++n<r;){var s=t[n];e(s,n,t)&&(i[o++]=s)}return i}(Q(e),function(t){return J.call(e,t)}))}:function(){return[]},Mt=dt;function It(t){if(null!=t){try{return q.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function St(t,e){return t===e||t!=t&&e!=e}(R&&Mt(new R(new ArrayBuffer(1)))!=S||Z&&Mt(new Z)!=v||x&&Mt(x.resolve())!=s||L&&Mt(new L)!=k||z&&Mt(new z)!=c)&&(Mt=function(t){var e=dt(t),t=e==w?t.constructor:void 0,t=t?It(t):"";if(t)switch(t){case et:return S;case nt:return v;case rt:return s;case ot:return k;case it:return c}return e});var Ct=gt(function(){return arguments}())?gt:function(t){return Rt(t)&&D.call(t,"callee")&&!J.call(t,"callee")},Pt=Array.isArray;var At=T||function(){return!1};function zt(t){if(xt(t)){t=dt(t);return t==n||t==o||t==e||t==a}}function Lt(t){return"number"==typeof t&&-1<t&&t%1==0&&t<=h}function xt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Rt(t){return null!=t&&"object"==typeof t}var Et,Tt=A?(Et=A,function(t){return Et(t)}):function(t){return Rt(t)&&Lt(t.length)&&!!P[dt(t)]};function Bt(t){return(null!=(e=t)&&Lt(e.length)&&!zt(e)?ht:vt)(t);var e}Ft.exports=function(t,e){return _t(t,e)}}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(t,e,n){var r,o,i;r=this,o=function(){var a=null,u={};t("monochrome",null,[[0,0],[100,0]]),t("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]),t("orange",[18,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]),t("yellow",[46,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]),t("green",[62,178],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]),t("blue",[178,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]),t("purple",[257,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]),t("pink",[282,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]);function c(t){if(void 0!==(t=t||{}).seed&&null!==t.seed&&t.seed===parseInt(t.seed,10))a=t.seed;else if("string"==typeof t.seed)a=function(t){for(var e=0,n=0;n!==t.length&&!(e>=Number.MAX_SAFE_INTEGER);n++)e+=t.charCodeAt(n);return e}(t.seed);else{if(void 0!==t.seed&&null!==t.seed)throw new TypeError("The seed value must be an integer or string");a=null}var e,n;if(null===t.count||void 0===t.count)return function(t,e){switch(e.format){case"hsvArray":return t;case"hslArray":return d(t);case"hsl":var n=d(t);return"hsl("+n[0]+", "+n[1]+"%, "+n[2]+"%)";case"hsla":var r=d(t),o=e.alpha||Math.random();return"hsla("+r[0]+", "+r[1]+"%, "+r[2]+"%, "+o+")";case"rgbArray":return f(t);case"rgb":return"rgb("+f(t).join(", ")+")";case"rgba":r=f(t),o=e.alpha||Math.random();return"rgba("+r.join(", ")+", "+o+")";default:return function(t){t=f(t);function e(t){t=t.toString(16);return 1==t.length?"0"+t:t}return"#"+e(t[0])+e(t[1])+e(t[2])}(t)}}([e=function(t){{if(0<l.length){var e=h(i=function(t){if(isNaN(t)){if("string"==typeof t)if(u[t]){var e=u[t];if(e.hueRange)return e.hueRange}else if(t.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i))return p(y(t)[0]).hueRange}else{e=parseInt(t);if(e<360&&0<e)return p(t).hueRange}return[0,360]}(t.hue)),n=(i[1]-i[0])/l.length,r=parseInt((e-i[0])/n);!0===l[r]?r=(r+2)%l.length:l[r]=!0;var o=(i[0]+r*n)%359,n=(i[0]+(r+1)*n)%359;return e=(e=h(i=[o,n]))<0?360+e:e}var i=function(t){if("number"==typeof parseInt(t)){var e=parseInt(t);if(e<360&&0<e)return[e,e]}if("string"==typeof t)if(u[t]){e=u[t];if(e.hueRange)return e.hueRange}else if(t.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)){t=y(t)[0];return[t,t]}return[0,360]}(t.hue);return e=(e=h(i))<0?360+e:e}}(t),n=function(t,e){if("monochrome"===e.hue)return 0;if("random"===e.luminosity)return h([0,100]);var t=function(t){return p(t).saturationRange}(t),n=t[0],r=t[1];switch(e.luminosity){case"bright":n=55;break;case"dark":n=r-10;break;case"light":r=55}return h([n,r])}(e,t),function(t,e,n){var r=function(t,e){for(var n=p(t).lowerBounds,r=0;r<n.length-1;r++){var o=n[r][0],i=n[r][1],s=n[r+1][0],a=n[r+1][1];if(o<=e&&e<=s){s=(a-i)/(s-o);return s*e+(i-s*o)}}return 0}(t,e),o=100;switch(n.luminosity){case"dark":o=r+20;break;case"light":r=(o+r)/2;break;case"random":r=0,o=100}return h([r,o])}(e,n,t)],t);for(var r=t.count,o=[],i=0;i<t.count;i++)l.push(!1);for(t.count=null;r>o.length;){var s=c(t);null!==a&&(t.seed=a),o.push(s)}return t.count=r,o}var l=[];function p(t){for(var e in 334<=t&&t<=360&&(t-=360),u){var n=u[e];if(n.hueRange&&t>=n.hueRange[0]&&t<=n.hueRange[1])return u[e]}return"Color not found"}function h(t){if(null===a){var e=Math.random();return e+=.618033988749895,e%=1,Math.floor(t[0]+e*(t[1]+1-t[0]))}var n=t[1]||1,e=t[0]||0,t=(a=(9301*a+49297)%233280)/233280;return Math.floor(e+t*(n-e))}function t(t,e,n){var r=n[0][0],o=n[n.length-1][0],i=n[n.length-1][1],s=n[0][1];u[t]={hueRange:e,lowerBounds:n,saturationRange:[r,o],brightnessRange:[i,s]}}function f(t){var e=t[0];360===(e=0===e?1:e)&&(e=359),e/=360;var n=t[1]/100,r=t[2]/100,t=Math.floor(6*e),e=6*e-t,o=r*(1-n),i=r*(1-e*n),s=r*(1-(1-e)*n),a=256,u=256,c=256;switch(t){case 0:a=r,u=s,c=o;break;case 1:a=i,u=r,c=o;break;case 2:a=o,u=r,c=s;break;case 3:a=o,u=i,c=r;break;case 4:a=s,u=o,c=r;break;case 5:a=r,u=o,c=i}return[Math.floor(255*a),Math.floor(255*u),Math.floor(255*c)]}function y(t){t=3===(t=t.replace(/^#/,"")).length?t.replace(/(.)/g,"$1$1"):t;var e=parseInt(t.substr(0,2),16)/255,n=parseInt(t.substr(2,2),16)/255,r=parseInt(t.substr(4,2),16)/255,o=Math.max(e,n,r),i=o-Math.min(e,n,r),s=o?i/o:0;switch(o){case e:return[(n-r)/i%6*60||0,s,o];case n:return[60*((r-e)/i+2)||0,s,o];case r:return[60*((e-n)/i+4)||0,s,o]}}function d(t){var e=t[0],n=t[1]/100,r=t[2]/100,t=(2-n)*r;return[e,Math.round(n*r/(t<1?t:2-t)*1e4)/100,t/2*100]}return c},"object"==typeof n?(i=o(),(n="object"==typeof e&&e&&e.exports?e.exports=i:n).randomColor=i):r.randomColor=o()},{}]},{},[1])(1)}); |