cmkit
Version:
common web developer tool box.
1 lines • 21.3 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0}),Object.assign=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),r=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],o=0;o<r;){var i=e[o];if(t.call(n,i,o,e))return o;o++}return-1}}),function(s){"use strict";Number.prototype.fixlen=function(t){return("number"!=typeof t||t<1)&&(t=2),(Array(t).join("0")+this).slice(-t)},Number.prototype.round=function(t){("number"!=typeof t||t<0)&&(t=0);var e=Math.pow(10,t);return Math.round(this*e)/e},Number.prototype.floor=function(t){("number"!=typeof t||t<0)&&(t=0);var e=Math.pow(10,t);return Math.floor(this*e)/e},Number.prototype.ceil=function(t){("number"!=typeof t||t<0)&&(t=0);var e=Math.pow(10,t);return Math.ceil(this*e)/e},Number.prototype.comma=function(){var t=this.toString().split(".")[0],e="";if(t.length<=3)e=t||"0";else{for(;3<t.length;)e=","+t.slice(-3)+e,t=t.slice(0,t.length-3);e=t+e}return e},Object.defineProperty(Number.prototype,"symidx",{get:function(){if(3<this&&this<=20)return"th";switch(this%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},enumerable:!0,configurable:!0}),Number.prototype.kmgtify=function(t){if(void 0===t&&(t=3),3!==t&&4!==t&&5!==t&&6!==t)throw new Error("maxlen must be intger between 3 and 6");return this<Math.pow(10,t)?s.kmgtfmt(this,""):this<Math.pow(10,t+3)?s.kmgtfmt(this/1e3,"K"):this<Math.pow(10,t+6)?s.kmgtfmt(this/1e6,"M"):this<Math.pow(10,t+9)?s.kmgtfmt(this/1e9,"G"):this<Math.pow(10,t+12)?s.kmgtfmt(this/1e12,"T"):cm.kmgtfmt(this,"")},Number.prototype.kmbtify=function(t){if(!Number.isFinite(this)||Number.isNaN(this))return this.toString();if(void 0===t&&(t=3),3!==t&&4!==t&&5!==t&&6!==t)throw new Error("maxlen must be intger between 3 and 6");var e=Math.floor(Math.log10(this));if(e<t)return s.kmbtfmt(this,"");var r=Math.floor((e-t)/3)+1;switch(r){case 1:return s.kmbtfmt(this/Math.pow(10,3*r),"k");case 2:return s.kmbtfmt(this/Math.pow(10,3*r),"m");case 3:return s.kmbtfmt(this/Math.pow(10,3*r),"b");case 4:return s.kmbtfmt(this/Math.pow(10,3*r),"t");default:var n=r-5,o=Math.floor(n/26),i=n%26;return s.kmbtfmt(this/Math.pow(10,3*r),String.fromCharCode(o+97)+String.fromCharCode(97+i))}},String.prototype.fixlen=function(t){return("number"!=typeof t||t<1)&&(t=2),(Array(t).join("0")+this).slice(-t)},String.prototype.parsed=function(){var t={};if(0==this.length)return t;var e=this.split("?"),r=e[0].split("://");if(r.length<2)return t;t.schema=r[0];var n=r[1].split("/");if(t.host=n[0],1<n.length&&(t.query=n[n.length-1]),e.length<2)return t;for(var o=e[1].split("&"),i=0;i<o.length;i++){var s=o[i].split("=");if(!(s.length<2)){var a=s[0],u=s[1];a&&(t[a]=u)}}return t},Object.defineProperty(Array.prototype,"first",{get:function(){if(0<this.length)return this[0]},enumerable:!0,configurable:!0}),Object.defineProperty(Array.prototype,"last",{get:function(){if(0<this.length)return this[this.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(Array.prototype,"ranidx",{get:function(){return 0===this.length?-1:Math.floor(Math.random()*this.length)},enumerable:!0,configurable:!0}),Object.defineProperty(Array.prototype,"random",{get:function(){return this[this.ranidx]},enumerable:!0,configurable:!0}),Array.prototype.insert=function(t,e){"number"==typeof e&&(e<0||e>this.length||this.splice(e,0,t))},Array.prototype.append=function(t){return this.push.apply(this,t)},Array.prototype.remove=function(t){if("number"==typeof t&&!(t<0||t>=this.length))return this.splice(t,1)[0]},Array.prototype.delete=function(e){if(0===this.length)return-1;var t=this.findIndex(function(t){return t===e});return 0<=t&&this.splice(t,1),t},Array.prototype.contains=function(e){return 0!==this.length&&0<=this.findIndex(function(t){return t===e})},Date.prototype.format=function(t){var e={MM:this.getMonth()+1,dd:this.getDate(),hh:this.getHours(),mm:this.getMinutes(),ss:this.getSeconds()};for(var r in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length))),e)new RegExp("("+r+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[r]:("00"+e[r]).substr((""+e[r]).length)));return t},Object.defineProperty(Date.prototype,"hhmmss",{get:function(){var t=this.getUTCHours(),e=this.getUTCMinutes(),r=this.getUTCSeconds();return t.fixlen(2)+":"+e.fixlen(2)+":"+r.fixlen(2)},enumerable:!0,configurable:!0}),Object.defineProperty(Date.prototype,"hhmm",{get:function(){var t=this.getUTCHours(),e=this.getUTCMinutes();return t.fixlen(2)+":"+e.fixlen(2)},enumerable:!0,configurable:!0}),Object.defineProperty(Date.prototype,"mmss",{get:function(){var t=this.getUTCMinutes(),e=this.getUTCSeconds();return t.fixlen(2)+":"+e.fixlen(2)},enumerable:!0,configurable:!0})}(window.cm=window.cm||{}),function(r){"use strict";r.log=function(){r.debug&&console.log.apply(console,arguments)},r.warn=function(){r.debug&&console.warn.apply(console,arguments)},r.call=function(){var t=arguments.length;if(!(t<=0)){var e=arguments[0];if("function"==typeof e)if(1===t)e();else{for(var r=[],n=1;n<t;n++)r.push(arguments[n]);e.apply(null,r)}}},r.okstr=function(t){switch(typeof t){case"string":return 0!==t.length;case"number":return!isNaN(t);default:return!1}},r.okint=function(t){switch(typeof t){case"string":return/^[-+]?\d+$/.test(t);case"number":return Number.isInteger(t);default:return!1}},r.oknum=function(t){switch(typeof t){case"string":return/^[-+]?\d+(\.\d+)?$/.test(t);case"number":return!isNaN(t);default:return!1}},r.config=function(t,e){r.apihost=t,r.debug=!!e},r.debug=!0,Object.defineProperty(r,"isslim",{get:function(){var t=window.screen;return 1.78<Math.max(t.width,t.height)/Math.min(t.width,t.height)},enumerable:!0,configurable:!0}),r.kmgtfmt=function(t,e){return t.comma()+e},r.kmbtfmt=function(t,e){return t.comma()+e}}(window.cm=window.cm||{});var __extends=this&&this.__extends||function(){var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};return function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}();!function(l){var t=(e.prototype.setData=function(t){this.data=t},e.prototype.localize=function(){if(!this.data)return console.warn("i18n data not found! you mast setData for i18n"),"";var t=arguments[0];if(!t)return"";var e=this.data[t];if(!e||"string"!=typeof e)return"";if(1===arguments.length)return e;for(var r=1;r<arguments.length;r++)e=e.replace("{"+(r-1)+"}",arguments[r]);return e},e);function e(t){this.data=t}l.I18n=t,l.i18n=new t;var a=(r.prototype.removeByTarget=function(t,e){if(Array.isArray(t))for(var r=t.length-1;0<=r;r--)t[r].target===e&&t.splice(r,1)},r);function r(){var i=this;i.observers={},i.on=function(t,e,r,n){var o=i.observers[t]||(i.observers[t]=[]);-1===o.findIndex(function(t){return t.target===e&&t.once===!!n})&&o.push({callback:r,target:e,once:!!n})},i.off=function(t,e){if("string"==typeof t)e?i.removeByTarget(i.observers[t],e):i.observers[t]=[];else if("object"==typeof t)for(var r in i.observers)i.removeByTarget(i.observers[r],t)},i.once=function(t,e,r){i.on(t,e,r,!0)},i.emit=function(t){if("string"==typeof t){var e=i.observers[t];if(Array.isArray(e)){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);for(n=0;n<e.length;n++){var o=e[n];o.callback.apply(o.target,r)}for(n=e.length-1;0<=n;n--)e[n].once&&e.splice(n,1)}}},i.offall=function(){i.observers={}}}l.Emitter=a;var n,i,o,s,u,c,f=(__extends(p,n=a),p);function p(){return null!==n&&n.apply(this,arguments)||this}function h(){var c=this;this.upload=function(n,t){var e=t.opts||{};e.headers=Object.assign(c.headers,e.headers),e.headers.method="POST";var o=Object.assign(c.options,e);if(c.before(n,o)){var r=new FormData,i=c.params(t.params);if(r.append(t.name,t.data),i)for(var s in i)r.append(s,i[s]);var a=h.post(c.url(n),r,o),u=new Promise(function(e,r){a[0].then(function(t){return(o&&o.parser||c.resolve.bind(c))(t)}).then(function(t){e(t),c.after(n,t)}).catch(function(t){r(t),c.after(n,t)})});return new h.UploadTask(u,a[1])}},this.anyreq=function(t){return c.anytask(t.path,t.data,t.opts)},this.objreq=function(t){if("function"!=typeof t.meta)throw new Error("the meta of objreq must be a Constructor");return c.objtask(t.meta,t.path,t.data,t.opts)},this.aryreq=function(t){if("function"!=typeof t.meta)throw new Error("the meta of aryreq must be a Constructor");return c.arytask(t.meta,t.path,t.data,t.opts)},this.mapreq=function(t){if("function"!=typeof t.meta)throw new Error("the meta of mapreq must be a Constructor");return c.maptask(t.meta,t.path,t.data,t.opts)},this.anytask=function(n,t,e){(e=e||{}).headers=Object.assign(c.headers,e.headers);var o=Object.assign(c.options,e);if(c.before(n,e)){var i=h.http(c.url(n),c.params(t),o),r=new Promise(function(e,r){i[0].then(function(t){return(o&&o.parser||c.resolve.bind(c))(t)}).then(function(t){e(t),c.after(n,t)}).catch(function(t){try{c.reject(t)}catch(t){r(t)}c.after(n,t)})});return new h.DataTask(r,i[1])}},this.objtask=function(n,o,t,e){(e=e||{}).headers=Object.assign(c.headers,e.headers);var i=Object.assign(c.options,e);if(c.before(o,e)){var s=h.http(c.url(o),c.params(t),i),r=new Promise(function(e,r){s[0].then(function(t){return(i&&i.parser||c.resolve.bind(c))(t)}).then(function(t){return new n(t)}).then(function(t){e(t),c.after(o,t)}).catch(function(t){try{c.reject(t)}catch(t){r(t)}c.after(o,t)})});return new h.DataTask(r,s[1])}},this.arytask=function(n,o,t,e){(e=e||{}).headers=Object.assign(c.headers,e.headers);var i=Object.assign(c.options,e);if(c.before(o,i)){var s=h.http(c.url(o),c.params(t),i),r=new Promise(function(e,r){s[0].then(function(t){return(i&&i.parser||c.resolve.bind(c))(t)}).then(function(t){return Array.isArray(t)?t.map(function(t){return new n(t)}):[]}).then(function(t){e(t),c.after(o,t)}).catch(function(t){try{c.reject(t)}catch(t){r(t)}c.after(o,t)})});return new h.DataTask(r,s[1])}},this.maptask=function(s,n,t,a){(a=a||{}).headers=Object.assign(c.headers,a.headers);var o=Object.assign(c.options,a);if(c.before(n,o)){var i=h.http(c.url(n),c.params(t),o),e=new Promise(function(e,r){i[0].then(function(t){return(o&&o.parser||c.resolve.bind(c))(t)}).then(function(t){var n={},o=a&&a.mapkey||"id";if(Array.isArray(t))t.forEach(function(t){var e=new s(t),r=e[o];r?n[r]=e:l.warn("the mapkey:",o,"not exist in object:",e)});else if("object"==typeof t)for(var e in t){var r=new s(t[e]),i=r[o];i?n[i]=r:l.warn("the mapkey:",o,"not exist in object:",r)}return n}).then(function(t){e(t),c.after(n,t)}).catch(function(t){try{c.reject(t)}catch(t){r(t)}c.after(n,t)})});return new h.DataTask(e,i[1])}}}function y(t,e){var r=this;this._retrying=!1,this.retryable=!1,this.binaryType="arraybuffer",this.buildurl=t,this.protocols=e,this.retry=new y.Retry(this.onRetryCallback.bind(this),this.onRetryFailed.bind(this)),this.open=function(){r.readyState!==y.CONNECTING&&r.readyState!==y.OPEN&&"function"==typeof r.buildurl&&(r.ws&&(r.ws.onopen=void 0,r.ws.onclose=void 0,r.ws.onerror=void 0,r.ws.onmessage=void 0),r.ws=new WebSocket(r.buildurl(),r.protocols),r.ws.onclose=r.onCloseCallback.bind(r),r.ws.onerror=r.onErrorCallback.bind(r),r.ws.onmessage=r.onMessageCallback.bind(r),r.ws.onopen=r.onOpenCallback.bind(r),r.ws.binaryType=r.binaryType)},this.close=function(t,e){r.ws&&r.ws.readyState!==y.CLOSED&&r.ws.readyState!==y.CLOSING&&r.ws.close(t,e)},this.send=function(t){r.ws&&r.ws.send(t)}}function m(t,e){if(e){var i=new t;Object.assign(i,e);var s=t[o];if(s){function r(t){var e=i[t];if(!e)return"continue";var r=s[t];if(Array.isArray(e))i[t]=e.map(function(t){return m(r.cls,t)});else if(r.map){var n=i[t]={};for(var o in e)n[o]=m(r.cls,e[o])}else i[t]=m(r.cls,e)}for(var n in s)r(n)}return i}}function d(t){var e=t&&t[s];if(!e)throw new Error("The Class:"+t.name+" did't mark with decorate @store(clsname,primary)");return e}function g(t,e){return t&&e?t+"."+e:null}function b(t){var e=i._storage.getItem(t);return e&&JSON.parse(e)}function v(t,e){var r=e&&JSON.stringify(e);i._storage.setItem(t,r)}function w(t){i._storage.removeItem(t)}l.NoticeCenter=f,l.notice=new f,l.Network=(Object.defineProperty(h.prototype,"options",{get:function(){return{method:this.method,mapkey:this.mapkey,timeout:this.timeout,restype:this.restype,loading:this.loading}},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"headers",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"method",{get:function(){return"POST"},enumerable:!0,configurable:!0}),h.prototype.url=function(t){throw new Error("Network.url(path:string) must be implement")},h.prototype.resolve=function(t){return t},h.prototype.reject=function(t){throw t},h.prototype.params=function(t){return t},h.prototype.before=function(){return!0},h.prototype.after=function(){},h),function(f){var p=(r.abort=function(t){return new r("abort",t,"The request has been abort!")},r.timeout=function(t){return new r("timeout",t,"Request timeout!")},r.service=function(t,e){return new r("service",t,e)},Object.defineProperty(r.prototype,"message",{get:function(){return this.info&&this.info.message},enumerable:!0,configurable:!0}),r);function r(t,e,r){this.type=t,this.status=e,this.info=r}f.Error=p;function t(t,e){this.promiss=t,this.handler=e,this[Symbol.toStringTag]="Promise";var r=this;this.then=function(t,e){return r.promiss.then(t,e)},this.catch=function(t){return r.promiss.catch(t)},this.abort=function(){r.handler.abort()},this.onProgress=function(t){r.handler.onprogress=t}}f.DataTask=t;var n,e=(__extends(o,n=t),o);function o(){var e=null!==n&&n.apply(this,arguments)||this;return e.onProgress=function(t){e.handler.upload.onprogress=t},e}function i(t){switch(typeof t){case"bigint":case"string":case"number":case"boolean":return!0;default:return!1}}function s(t,e,r){if(i(r))t=t+"&"+e+"="+r;else if(Array.isArray(r))for(var n=0;n<r.length;n++)i(r[n])&&(t=t+"&"+e+"="+r[n]);return t}function c(t){if(!t)return"";var e=Object.keys(t);if(0===e.length)return"";for(var r=s("",e[0],t[e[0]]),n=1;n<e.length;n++){var o=e[n];r=s(r,o,t[o])}return"?"+r.substring(1)}f.UploadTask=e,f.http=function(t,e,r){return f.impl?f.impl.request(t,e,r):"GET"===(r&&r.method)?f.get(t,e,r):f.post(t,e,r)},f.encodeQuery=c,f.replaceImpl=function(t){if("object"!=typeof t)throw new p("invalid Network implementation");if("function"!=typeof t.get||"function"!=typeof t.post)throw new p("invalid Network implementation");f.impl=t},f.get=function(i,s,a){var u;return[new Promise(function(e,r){var n=new XMLHttpRequest;(u=n).onabort=function(){return r(f.Error.abort(n.status))},n.ontimeout=function(){return r(f.Error.timeout(n.status))},n.onerror=function(t){return r(f.Error.service(n.status,t))},n.onloadend=function(){l.log("\nrequest:url=",i,"\nrequest:data=",t,"\nresponse=",n.response);var t="json"===n.responseType?n.response:n.responseText;200<=n.status&&n.status<300||304===n.status?e(t):r(p.service(n.status,t))},i+=c(s),n.open("GET",i,!0),n.timeout=a&&a.timeout||0,n.responseType=a&&a.restype||"json";var t=a&&a.headers||{};for(var o in t)n.setRequestHeader(o,t[o]);n.send()}),u]};var h=0;f.post=function(s,a,u){var c;return[new Promise(function(e,r){var n=new XMLHttpRequest;(c=n).onabort=function(){return r(f.Error.abort(n.status))},n.ontimeout=function(){return r(f.Error.timeout(n.status))},n.onerror=function(t){return r(f.Error.service(n.status,t))},n.onloadend=function(){l.log("\nrequest:url=",s,"\nrequest:data=",t,"\nresponse=",n.response);var t="json"===n.responseType?n.response:n.responseText;200<=n.status&&n.status<300||304===n.status?e(t):r(p.service(n.status,t))},n.open(u.method,s,!0),n.timeout=u&&u.timeout||0,n.responseType=u&&u.restype||"json";var t=u&&u.headers||{};for(var o in t)n.setRequestHeader(o,t[o]);if(a instanceof FormData)n.send(a);else{t["Content-Type"]||n.setRequestHeader("Content-Type","application/json");var i=a||{};i._reqidx=h++,n.send(JSON.stringify(i))}}),c]}}(l.Network),l.Socket=(y.prototype.onRetryCallback=function(){this.open(),this._retrying=!0},y.prototype.onRetryFailed=function(t){this._retrying=!1,"function"==typeof this.onclose&&this.onclose(t,"retry")},y.prototype.onOpenCallback=function(t){"function"==typeof this.onopen&&this.onopen.call(null,t,this._retrying),this._retrying=!1},y.prototype.onCloseCallback=function(t){if(this.retryable&&t.code<3e3)this.retry.attempt(t);else if("function"==typeof this.onclose){this._retrying=!1;var e="server";"ping"!==t.reason&&"user"!==t.reason||(e=t.reason),this.onclose(t,e)}},y.prototype.onErrorCallback=function(){"function"==typeof this.onerror&&this.onerror.apply(null,arguments)},y.prototype.onMessageCallback=function(){"function"==typeof this.onmessage&&this.onmessage.apply(null,arguments)},Object.defineProperty(y.prototype,"isRetrying",{get:function(){return this._retrying},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"protocol",{get:function(){return this.ws&&this.ws.protocol},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"extensions",{get:function(){return this.ws&&this.ws.extensions},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"readyState",{get:function(){return this.ws&&this.ws.readyState||WebSocket.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"bufferedAmount",{get:function(){return this.ws&&this.ws.bufferedAmount},enumerable:!0,configurable:!0}),y),function(n){n.OPEN=WebSocket.OPEN,n.CLOSED=WebSocket.CLOSED,n.CLOSING=WebSocket.CLOSING,n.CONNECTING=WebSocket.CONNECTING;var t=(e.prototype.random=function(t,e){return Math.floor((.5+.5*Math.random())*Math.pow(2,t)*e)},e);function e(t,e){var r=this;this.delay=100,this.chance=8,this.count=0,this.allow=!0,this.reset=function(){r.count=0},this.attempt=function(t){this.allow&&r.count<r.chance?setTimeout(function(){return r.onAttempt(t)},r.random(r.count++,r.delay)):r.onFailed(t)},this.onAttempt=t,this.onFailed=e}n.Retry=t;var o,i=function(t){var e=this;this.allow=!0,this.timer=null,this.timeout=null,this.interval=30,this.socket=t,this.send=function(){if(!e.timeout&&e.socket.readyState===n.OPEN){var t='{"type":"PING"}';e.socket.send(t),l.log("Send PING:",t),e.timeout=setTimeout(function(){l.log("PING timeout"),e.timeout=null,e.socket.close(1e3,"ping")},3e3)}},this.receive=function(t){l.log("Received PONG",t),e.timeout&&(clearTimeout(e.timeout),e.timeout=null)},this.start=function(){e.allow&&!e.timer&&(e.timer=setInterval(e.send.bind(e),1e3*e.interval))},this.stop=function(){e.timer&&(clearInterval(e.timer),e.timer=null)}},r=(__extends(s,o=a),s.prototype.onError=function(t){},s.prototype.onOpened=function(t,e){},s.prototype.onClosed=function(t){},s.prototype.onMessage=function(t){},Object.defineProperty(s.prototype,"isConnected",{get:function(){return this.socket.readyState===n.OPEN},enumerable:!0,configurable:!0}),s);function s(){var r=null!==o&&o.apply(this,arguments)||this;r.stop=function(){r.socket.readyState!==n.CLOSED&&r.socket.readyState!==n.CLOSING&&(r.socket.retryable=!1,r.socket.close(1e3,"user"),r.ping.stop())},r.start=function(){r.isLogin&&!r.socket.isRetrying&&r.socket.readyState!==n.OPEN&&r.socket.readyState!==n.CONNECTING&&(r.socket.retry.reset(),r.socket.retryable=!0,r.socket.open(),r.ping.start())},r.socket=new n(function(){return r.buildurl()}),r.ping=new i(r.socket),r.socket.onopen=function(t,e){l.log("Socket Client Opend",t),r.onOpened(t,e)},r.socket.onerror=function(t){l.warn("Socket Client Connect Failed!",t),r.onError(t)},r.socket.onmessage=function(t){if(l.log("Socket Client Received message=",t),"string"==typeof t.data){var e=JSON.parse(t.data);"PONG"==e.type?r.ping.receive(e):r.onMessage(e)}},r.socket.onclose=function(t,e){l.log("Socket Client Closed",t),r.ping.stop(),r.onClosed(t,e)}}n.Client=r}(l.Socket),l.orm={},i=l.orm,o="__orm_field",s="__orm_class",u="__orm_index",c={},i._storage=window.localStorage,i.store=function(e,r){if(!l.okstr(e))throw new Error("The clskey:"+e+" invalid!");if(!l.okstr(r))throw new Error("The privkey:"+r+" invalid!");if(c[e])throw new Error("The clskey:"+e+" already exist!!You can't mark different class with same name!!");return c[e]=!0,function(t){t[s]=e,t[u]=r}},i.field=function(r,n){return function(t,e){(t.constructor[o]||(t.constructor[o]={}))[e]={map:!!n,cls:r}}},i.save=function(t){if(t){var e=d(t.constructor),r=g(e,t[function(t){var e=t&&t[u];if(!e)throw new Error("The privkey:"+e+" of "+t.name+" is invalid!");return e}(t.constructor)]),n=b(e)||{};n[r]=!0,v(e,n),v(r,t)}},i.find=function(t,e){return m(t,b(g(d(t),e)))},i.ids=function(t){var e=b(d(t));return e?Object.keys(e):[]},i.all=function(t){for(var e=[],r=0,n=i.ids(t);r<n.length;r++){var o=m(t,b(n[r]));o&&e.push(o)}return e},i.count=function(t){return i.ids(t).length},i.clear=function(t){var e=d(t),r=b(e);if(r)for(var n in r)w(n);w(e)},i.remove=function(t,e){var r=d(t),n=g(r,e),o=b(r);o&&o[n]&&(delete o[n],w(n),v(r,o))}}(window.cm||(window.cm={}));