Files
mixly3/boards/default/python_pyodide/main.bundle.40a87a6a.js

15099 lines
2.5 MiB
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(()=>{var __webpack_modules__={936:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{cv_destroy_all:()=>cv_destroy_all,cv_face_classifier:()=>cv_face_classifier,cv_face_detect:()=>cv_face_detect,cv_face_detect_all:()=>cv_face_detect_all,cv_line_rect:()=>cv_line_rect,cv_read_image:()=>cv_read_image,cv_show_image:()=>cv_show_image,cv_text:()=>cv_text,cv_waitkey:()=>cv_waitkey,cv_write_image:()=>cv_write_image});const cv_read_image=function(t,e){return e.definitions_.import_cv2="import cv2",["cv2.imread("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},cv_show_image=function(t,e){return e.definitions_.import_cv2="import cv2","cv2.imshow("+e.valueToCode(this,"data",e.ORDER_ATOMIC)+","+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")\n"},cv_write_image=function(t,e){return e.definitions_.import_cv2="import cv2","cv2.imwrite("+e.valueToCode(this,"data",e.ORDER_ATOMIC)+","+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")\n"},cv_waitkey=function(t,e){return e.definitions_.import_cv2="import cv2","cv2.waitKey("+e.valueToCode(this,"data",e.ORDER_ATOMIC)+")\n"},cv_destroy_all=function(t,e){e.definitions_.import_cv2="import cv2";return"cv2.destroyAllWindows()\n"},cv_line_rect=function(_,generator){generator.definitions_.import_cv2="import cv2";var file=generator.valueToCode(this,"FILE",generator.ORDER_ATOMIC),x1=generator.valueToCode(this,"x1",generator.ORDER_ATOMIC),y1=generator.valueToCode(this,"y1",generator.ORDER_ATOMIC),x2=generator.valueToCode(this,"x2",generator.ORDER_ATOMIC),y2=generator.valueToCode(this,"y2",generator.ORDER_ATOMIC),thick=generator.valueToCode(this,"thick",generator.ORDER_ATOMIC),color=this.getFieldValue("FIELDNAME"),color1=eval("0x"+color[1]+color[2]),color2=eval("0x"+color[3]+color[4]),color3=eval("0x"+color[5]+color[6]),direction=this.getFieldValue("DIR"),code="cv2."+direction+"("+file+",("+x1+","+y1+"),("+x2+","+y2+"),("+color3+","+color2+","+color1+"),"+thick+")\n";return code},cv_text=function(_,generator){generator.definitions_.import_cv2="import cv2";var file=generator.valueToCode(this,"FILE",generator.ORDER_ATOMIC),x1=generator.valueToCode(this,"x1",generator.ORDER_ATOMIC),y1=generator.valueToCode(this,"y1",generator.ORDER_ATOMIC),data=generator.valueToCode(this,"data",generator.ORDER_ATOMIC),size=generator.valueToCode(this,"size",generator.ORDER_ATOMIC),thick=generator.valueToCode(this,"thick",generator.ORDER_ATOMIC),color=this.getFieldValue("FIELDNAME"),color1=eval("0x"+color[1]+color[2]),color2=eval("0x"+color[3]+color[4]),color3=eval("0x"+color[5]+color[6]),font=this.getFieldValue("font"),code="cv2.putText("+file+","+data+",("+x1+","+y1+"),cv2.FONT_HERSHEY_"+font+","+size+",("+color3+","+color2+","+color1+"),"+thick+")\n";return code},cv_face_classifier=function(t,e){return e.definitions_.import_cv2="import cv2",["cv2.CascadeClassifier("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},cv_face_detect=function(t,e){e.definitions_.import_cv2="import cv2";var n=e.valueToCode(this,"FILE",e.ORDER_ATOMIC);return[e.valueToCode(this,"FACE",e.ORDER_ATOMIC)+".detectMultiScale("+n+",scaleFactor="+e.valueToCode(this,"SCALE",e.ORDER_ATOMIC)+",minNeighbors="+e.valueToCode(this,"NEIGHBOR",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},cv_face_detect_all=function(t,e){e.definitions_.import_cv2="import cv2";var n=e.valueToCode(this,"FILE",e.ORDER_ATOMIC);return[e.valueToCode(this,"FACE",e.ORDER_ATOMIC)+".detectMultiScale("+n+",scaleFactor="+e.valueToCode(this,"SCALE",e.ORDER_ATOMIC)+",minNeighbors="+e.valueToCode(this,"NEIGHBOR",e.ORDER_ATOMIC)+",minSize=("+e.valueToCode(this,"x1",e.ORDER_ATOMIC)+","+e.valueToCode(this,"y1",e.ORDER_ATOMIC)+"),maxSize=("+e.valueToCode(this,"x2",e.ORDER_ATOMIC)+","+e.valueToCode(this,"y2",e.ORDER_ATOMIC)+"))",e.ORDER_ATOMIC]}},153:(t,e,n)=>{"use strict";const{SymbolDispose:i}=n(4184),{AbortError:s,codes:r}=n(6605),{isNodeStream:a,isWebStream:o,kControllerErrorFunction:l}=n(6569),u=n(9700),{ERR_INVALID_ARG_TYPE:h}=r;let p;t.exports.addAbortSignal=function(e,n){if(((t,e)=>{if("object"!=typeof t||!("aborted"in t))throw new h(e,"AbortSignal",t)})(e,"signal"),!a(n)&&!o(n))throw new h("stream",["ReadableStream","WritableStream","Stream"],n);return t.exports.addAbortSignalNoValidate(e,n)},t.exports.addAbortSignalNoValidate=function(t,e){if("object"!=typeof t||!("aborted"in t))return e;const r=a(e)?()=>{e.destroy(new s(void 0,{cause:t.reason}))}:()=>{e[l](new s(void 0,{cause:t.reason}))};if(t.aborted)r();else{p=p||n(798).addAbortListener;const s=p(t,r);u(e,s[i])}return e}},1515:(t,e,n)=>{"use strict";const{StringPrototypeSlice:i,SymbolIterator:s,TypedArrayPrototypeSet:r,Uint8Array:a}=n(4184),{Buffer:o}=n(8287),{inspect:l}=n(798);t.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(t){const e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}unshift(t){const e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}shift(){if(0===this.length)return;const t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}clear(){this.head=this.tail=null,this.length=0}join(t){if(0===this.length)return"";let e=this.head,n=""+e.data;for(;null!==(e=e.next);)n+=t+e.data;return n}concat(t){if(0===this.length)return o.alloc(0);const e=o.allocUnsafe(t>>>0);let n=this.head,i=0;for(;n;)r(e,n.data,i),i+=n.data.length,n=n.next;return e}consume(t,e){const n=this.head.data;if(t<n.length){const e=n.slice(0,t);return this.head.data=n.slice(t),e}return t===n.length?this.shift():e?this._getString(t):this._getBuffer(t)}first(){return this.head.data}*[s](){for(let t=this.head;t;t=t.next)yield t.data}_getString(t){let e="",n=this.head,s=0;do{const r=n.data;if(!(t>r.length)){t===r.length?(e+=r,++s,n.next?this.head=n.next:this.head=this.tail=null):(e+=i(r,0,t),this.head=n,n.data=i(r,t));break}e+=r,t-=r.length,++s}while(null!==(n=n.next));return this.length-=s,e}_getBuffer(t){const e=o.allocUnsafe(t),n=t;let i=this.head,s=0;do{const o=i.data;if(!(t>o.length)){t===o.length?(r(e,o,n-t),++s,i.next?this.head=i.next:this.head=this.tail=null):(r(e,new a(o.buffer,o.byteOffset,t),n-t),this.head=i,i.data=o.slice(t));break}r(e,o,n-t),t-=o.length,++s}while(null!==(i=i.next));return this.length-=s,e}[Symbol.for("nodejs.util.inspect.custom")](t,e){return l(this,{...e,depth:0,customInspect:!1})}}},6864:(t,e,n)=>{"use strict";const{pipeline:i}=n(872),s=n(4992),{destroyer:r}=n(2430),{isNodeStream:a,isReadable:o,isWritable:l,isWebStream:u,isTransformStream:h,isWritableStream:p,isReadableStream:c}=n(6569),{AbortError:d,codes:{ERR_INVALID_ARG_VALUE:f,ERR_MISSING_ARGS:m}}=n(6605),g=n(9700);t.exports=function(...t){if(0===t.length)throw new m("streams");if(1===t.length)return s.from(t[0]);const e=[...t];if("function"==typeof t[0]&&(t[0]=s.from(t[0])),"function"==typeof t[t.length-1]){const e=t.length-1;t[e]=s.from(t[e])}for(let n=0;n<t.length;++n)if(a(t[n])||u(t[n])){if(n<t.length-1&&!(o(t[n])||c(t[n])||h(t[n])))throw new f(`streams[${n}]`,e[n],"must be readable");if(n>0&&!(l(t[n])||p(t[n])||h(t[n])))throw new f(`streams[${n}]`,e[n],"must be writable")}let n,_,T,y,I;const E=t[0],b=i(t,(function(t){const e=y;y=null,e?e(t):t?I.destroy(t):w||v||I.destroy()})),v=!!(l(E)||p(E)||h(E)),w=!!(o(b)||c(b)||h(b));if(I=new s({writableObjectMode:!(null==E||!E.writableObjectMode),readableObjectMode:!(null==b||!b.readableObjectMode),writable:v,readable:w}),v){if(a(E))I._write=function(t,e,i){E.write(t,e)?i():n=i},I._final=function(t){E.end(),_=t},E.on("drain",(function(){if(n){const t=n;n=null,t()}}));else if(u(E)){const t=(h(E)?E.writable:E).getWriter();I._write=async function(e,n,i){try{await t.ready,t.write(e).catch((()=>{})),i()}catch(t){i(t)}},I._final=async function(e){try{await t.ready,t.close().catch((()=>{})),_=e}catch(t){e(t)}}}const t=h(b)?b.readable:b;g(t,(()=>{if(_){const t=_;_=null,t()}}))}if(w)if(a(b))b.on("readable",(function(){if(T){const t=T;T=null,t()}})),b.on("end",(function(){I.push(null)})),I._read=function(){for(;;){const t=b.read();if(null===t)return void(T=I._read);if(!I.push(t))return}};else if(u(b)){const t=(h(b)?b.readable:b).getReader();I._read=async function(){for(;;)try{const{value:e,done:n}=await t.read();if(!I.push(e))return;if(n)return void I.push(null)}catch{return}}}return I._destroy=function(t,e){t||null===y||(t=new d),T=null,n=null,_=null,null===y?e(t):(y=e,a(b)&&r(b,t))},I}},2430:(t,e,n)=>{"use strict";const i=n(5606),{aggregateTwoErrors:s,codes:{ERR_MULTIPLE_CALLBACK:r},AbortError:a}=n(6605),{Symbol:o}=n(4184),{kIsDestroyed:l,isDestroyed:u,isFinished:h,isServerRequest:p}=n(6569),c=o("kDestroy"),d=o("kConstruct");function f(t,e,n){t&&(t.stack,e&&!e.errored&&(e.errored=t),n&&!n.errored&&(n.errored=t))}function m(t,e,n){let s=!1;function r(e){if(s)return;s=!0;const r=t._readableState,a=t._writableState;f(e,a,r),a&&(a.closed=!0),r&&(r.closed=!0),"function"==typeof n&&n(e),e?i.nextTick(g,t,e):i.nextTick(_,t)}try{t._destroy(e||null,r)}catch(e){r(e)}}function g(t,e){T(t,e),_(t)}function _(t){const e=t._readableState,n=t._writableState;n&&(n.closeEmitted=!0),e&&(e.closeEmitted=!0),(null!=n&&n.emitClose||null!=e&&e.emitClose)&&t.emit("close")}function T(t,e){const n=t._readableState,i=t._writableState;null!=i&&i.errorEmitted||null!=n&&n.errorEmitted||(i&&(i.errorEmitted=!0),n&&(n.errorEmitted=!0),t.emit("error",e))}function y(t,e,n){const s=t._readableState,r=t._writableState;if(null!=r&&r.destroyed||null!=s&&s.destroyed)return this;null!=s&&s.autoDestroy||null!=r&&r.autoDestroy?t.destroy(e):e&&(e.stack,r&&!r.errored&&(r.errored=e),s&&!s.errored&&(s.errored=e),n?i.nextTick(T,t,e):T(t,e))}function I(t){let e=!1;function n(n){if(e)return void y(t,null!=n?n:new r);e=!0;const s=t._readableState,a=t._writableState,o=a||s;s&&(s.constructed=!0),a&&(a.constructed=!0),o.destroyed?t.emit(c,n):n?y(t,n,!0):i.nextTick(E,t)}try{t._construct((t=>{i.nextTick(n,t)}))}catch(t){i.nextTick(n,t)}}function E(t){t.emit(d)}function b(t){return(null==t?void 0:t.setHeader)&&"function"==typeof t.abort}function v(t){t.emit("close")}function w(t,e){t.emit("error",e),i.nextTick(v,t)}t.exports={construct:function(t,e){if("function"!=typeof t._construct)return;const n=t._readableState,s=t._writableState;n&&(n.constructed=!1),s&&(s.constructed=!1),t.once(d,e),t.listenerCount(d)>1||i.nextTick(I,t)},destroyer:function(t,e){t&&!u(t)&&(e||h(t)||(e=new a),p(t)?(t.socket=null,t.destroy(e)):b(t)?t.abort():b(t.req)?t.req.abort():"function"==typeof t.destroy?t.destroy(e):"function"==typeof t.close?t.close():e?i.nextTick(w,t,e):i.nextTick(v,t),t.destroyed||(t[l]=!0))},destroy:function(t,e){const n=this._readableState,i=this._writableState,r=i||n;return null!=i&&i.destroyed||null!=n&&n.destroyed?("function"==typeof e&&e(),this):(f(t,i,n),i&&(i.destroyed=!0),n&&(n.destroyed=!0),r.constructed?m(this,t,e):this.once(c,(function(n){m(this,s(n,t),e)})),this)},undestroy:function(){const t=this._readableState,e=this._writableState;t&&(t.constructed=!0,t.closed=!1,t.closeEmitted=!1,t.destroyed=!1,t.errored=null,t.errorEmitted=!1,t.reading=!1,t.ended=!1===t.readable,t.endEmitted=!1===t.readable),e&&(e.constructed=!0,e.destroyed=!1,e.closed=!1,e.closeEmitted=!1,e.errored=null,e.errorEmitted=!1,e.finalCalled=!1,e.prefinished=!1,e.ended=!1===e.writable,e.ending=!1===e.writable,e.finished=!1===e.writable)},errorOrDestroy:y}},4992:(t,e,n)=>{"use strict";const{ObjectDefineProperties:i,ObjectGetOwnPropertyDescriptor:s,ObjectKeys:r,ObjectSetPrototypeOf:a}=n(4184);t.exports=u;const o=n(6566),l=n(394);a(u.prototype,o.prototype),a(u,o);{const t=r(l.prototype);for(let e=0;e<t.length;e++){const n=t[e];u.prototype[n]||(u.prototype[n]=l.prototype[n])}}function u(t){if(!(this instanceof u))return new u(t);o.call(this,t),l.call(this,t),t?(this.allowHalfOpen=!1!==t.allowHalfOpen,!1===t.readable&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),!1===t.writable&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}let h,p;function c(){return void 0===h&&(h={}),h}i(u.prototype,{writable:{__proto__:null,...s(l.prototype,"writable")},writableHighWaterMark:{__proto__:null,...s(l.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...s(l.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...s(l.prototype,"writableBuffer")},writableLength:{__proto__:null,...s(l.prototype,"writableLength")},writableFinished:{__proto__:null,...s(l.prototype,"writableFinished")},writableCorked:{__proto__:null,...s(l.prototype,"writableCorked")},writableEnded:{__proto__:null,...s(l.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...s(l.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set(t){this._readableState&&this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}}),u.fromWeb=function(t,e){return c().newStreamDuplexFromReadableWritablePair(t,e)},u.toWeb=function(t){return c().newReadableWritablePairFromDuplex(t)},u.from=function(t){return p||(p=n(4512)),p(t,"body")}},4512:(t,e,n)=>{const i=n(5606),s=n(8287),{isReadable:r,isWritable:a,isIterable:o,isNodeStream:l,isReadableNodeStream:u,isWritableNodeStream:h,isDuplexNodeStream:p,isReadableStream:c,isWritableStream:d}=n(6569),f=n(9700),{AbortError:m,codes:{ERR_INVALID_ARG_TYPE:g,ERR_INVALID_RETURN_VALUE:_}}=n(6605),{destroyer:T}=n(2430),y=n(4992),I=n(6566),E=n(394),{createDeferredPromise:b}=n(798),v=n(3182),w=globalThis.Blob||s.Blob,S=void 0!==w?function(t){return t instanceof w}:function(t){return!1},x=globalThis.AbortController||n(5568).AbortController,{FunctionPrototypeCall:R}=n(4184);class O extends y{constructor(t){super(t),!1===(null==t?void 0:t.readable)&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),!1===(null==t?void 0:t.writable)&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}function A(t){const e=t.readable&&"function"!=typeof t.readable.read?I.wrap(t.readable):t.readable,n=t.writable;let i,s,o,l,u,h=!!r(e),p=!!a(n);function c(t){const e=l;l=null,e?e(t):t&&u.destroy(t)}return u=new O({readableObjectMode:!(null==e||!e.readableObjectMode),writableObjectMode:!(null==n||!n.writableObjectMode),readable:h,writable:p}),p&&(f(n,(t=>{p=!1,t&&T(e,t),c(t)})),u._write=function(t,e,s){n.write(t,e)?s():i=s},u._final=function(t){n.end(),s=t},n.on("drain",(function(){if(i){const t=i;i=null,t()}})),n.on("finish",(function(){if(s){const t=s;s=null,t()}}))),h&&(f(e,(t=>{h=!1,t&&T(e,t),c(t)})),e.on("readable",(function(){if(o){const t=o;o=null,t()}})),e.on("end",(function(){u.push(null)})),u._read=function(){for(;;){const t=e.read();if(null===t)return void(o=u._read);if(!u.push(t))return}}),u._destroy=function(t,r){t||null===l||(t=new m),o=null,i=null,s=null,null===l?r(t):(l=r,T(n,t),T(e,t))},u}t.exports=function t(e,n){if(p(e))return e;if(u(e))return A({readable:e});if(h(e))return A({writable:e});if(l(e))return A({writable:!1,readable:!1});if(c(e))return A({readable:I.fromWeb(e)});if(d(e))return A({writable:E.fromWeb(e)});if("function"==typeof e){const{value:t,write:s,final:r,destroy:a}=function(t){let{promise:e,resolve:n}=b();const s=new x,r=s.signal,a=t(async function*(){for(;;){const t=e;e=null;const{chunk:s,done:a,cb:o}=await t;if(i.nextTick(o),a)return;if(r.aborted)throw new m(void 0,{cause:r.reason});({promise:e,resolve:n}=b()),yield s}}(),{signal:r});return{value:a,write(t,e,i){const s=n;n=null,s({chunk:t,done:!1,cb:i})},final(t){const e=n;n=null,e({done:!0,cb:t})},destroy(t,e){s.abort(),e(t)}}}(e);if(o(t))return v(O,t,{objectMode:!0,write:s,final:r,destroy:a});const l=null==t?void 0:t.then;if("function"==typeof l){let e;const n=R(l,t,(t=>{if(null!=t)throw new _("nully","body",t)}),(t=>{T(e,t)}));return e=new O({objectMode:!0,readable:!1,write:s,final(t){r((async()=>{try{await n,i.nextTick(t,null)}catch(e){i.nextTick(t,e)}}))},destroy:a})}throw new _("Iterable, AsyncIterable or AsyncFunction",n,t)}if(S(e))return t(e.arrayBuffer());if(o(e))return v(O,e,{objectMode:!0,writable:!1});if(c(null==e?void 0:e.readable)&&d(null==e?void 0:e.writable))return O.fromWeb(e);if("object"==typeof(null==e?void 0:e.writable)||"object"==typeof(null==e?void 0:e.readable)){return A({readable:null!=e&&e.readable?u(null==e?void 0:e.readable)?null==e?void 0:e.readable:t(e.readable):void 0,writable:null!=e&&e.writable?h(null==e?void 0:e.writable)?null==e?void 0:e.writable:t(e.writable):void 0})}const s=null==e?void 0:e.then;if("function"==typeof s){let t;return R(s,e,(e=>{null!=e&&t.push(e),t.push(null)}),(e=>{T(t,e)})),t=new O({objectMode:!0,writable:!1,read(){}})}throw new g(n,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)}},9700:(t,e,n)=>{const i=n(5606),{AbortError:s,codes:r}=n(6605),{ERR_INVALID_ARG_TYPE:a,ERR_STREAM_PREMATURE_CLOSE:o}=r,{kEmptyObject:l,once:u}=n(798),{validateAbortSignal:h,validateFunction:p,validateObject:c,validateBoolean:d}=n(6283),{Promise:f,PromisePrototypeThen:m,SymbolDispose:g}=n(4184),{isClosed:_,isReadable:T,isReadableNodeStream:y,isReadableStream:I,isReadableFinished:E,isReadableErrored:b,isWritable:v,isWritableNodeStream:w,isWritableStream:S,isWritableFinished:x,isWritableErrored:R,isNodeStream:O,willEmitClose:A,kIsClosedPromise:M}=n(6569);let C;const N=()=>{};function k(t,e,r){var d,f;if(2===arguments.length?(r=e,e=l):null==e?e=l:c(e,"options"),p(r,"callback"),h(e.signal,"options.signal"),r=u(r),I(t)||S(t))return function(t,e,r){let a=!1,o=N;if(e.signal)if(o=()=>{a=!0,r.call(t,new s(void 0,{cause:e.signal.reason}))},e.signal.aborted)i.nextTick(o);else{C=C||n(798).addAbortListener;const i=C(e.signal,o),s=r;r=u(((...e)=>{i[g](),s.apply(t,e)}))}const l=(...e)=>{a||i.nextTick((()=>r.apply(t,e)))};return m(t[M].promise,l,l),N}(t,e,r);if(!O(t))throw new a("stream",["ReadableStream","WritableStream","Stream"],t);const k=null!==(d=e.readable)&&void 0!==d?d:y(t),D=null!==(f=e.writable)&&void 0!==f?f:w(t),L=t._writableState,F=t._readableState,P=()=>{t.writable||V()};let $=A(t)&&y(t)===k&&w(t)===D,B=x(t,!1);const V=()=>{B=!0,t.destroyed&&($=!1),(!$||t.readable&&!k)&&(k&&!U||r.call(t))};let U=E(t,!1);const Y=()=>{U=!0,t.destroyed&&($=!1),(!$||t.writable&&!D)&&(D&&!B||r.call(t))},G=e=>{r.call(t,e)};let H=_(t);const W=()=>{H=!0;const e=R(t)||b(t);return e&&"boolean"!=typeof e?r.call(t,e):k&&!U&&y(t,!0)&&!E(t,!1)?r.call(t,new o):!D||B||x(t,!1)?void r.call(t):r.call(t,new o)},z=()=>{H=!0;const e=R(t)||b(t);if(e&&"boolean"!=typeof e)return r.call(t,e);r.call(t)},X=()=>{t.req.on("finish",V)};!function(t){return t.setHeader&&"function"==typeof t.abort}(t)?D&&!L&&(t.on("end",P),t.on("close",P)):(t.on("complete",V),$||t.on("abort",W),t.req?X():t.on("request",X)),$||"boolean"!=typeof t.aborted||t.on("aborted",W),t.on("end",Y),t.on("finish",V),!1!==e.error&&t.on("error",G),t.on("close",W),H?i.nextTick(W):null!=L&&L.errorEmitted||null!=F&&F.errorEmitted?$||i.nextTick(z):(k||$&&!T(t)||!B&&!1!==v(t))&&(D||$&&!v(t)||!U&&!1!==T(t))?F&&t.req&&t.aborted&&i.nextTick(z):i.nextTick(z);const j=()=>{r=N,t.removeListener("aborted",W),t.removeListener("complete",V),t.removeListener("abort",W),t.removeListener("request",X),t.req&&t.req.removeListener("finish",V),t.removeListener("end",P),t.removeListener("close",P),t.removeListener("finish",V),t.removeListener("end",Y),t.removeListener("error",G),t.removeListener("close",W)};if(e.signal&&!H){const a=()=>{const n=r;j(),n.call(t,new s(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)i.nextTick(a);else{C=C||n(798).addAbortListener;const i=C(e.signal,a),s=r;r=u(((...e)=>{i[g](),s.apply(t,e)}))}}return j}t.exports=k,t.exports.finished=function(t,e){var n;let i=!1;return null===e&&(e=l),null!==(n=e)&&void 0!==n&&n.cleanup&&(d(e.cleanup,"cleanup"),i=e.cleanup),new f(((n,s)=>{const r=k(t,e,(t=>{i&&r(),t?s(t):n()}))}))}},3182:(t,e,n)=>{"use strict";const i=n(5606),{PromisePrototypeThen:s,SymbolAsyncIterator:r,SymbolIterator:a}=n(4184),{Buffer:o}=n(8287),{ERR_INVALID_ARG_TYPE:l,ERR_STREAM_NULL_VALUES:u}=n(6605).codes;t.exports=function(t,e,n){let h,p;if("string"==typeof e||e instanceof o)return new t({objectMode:!0,...n,read(){this.push(e),this.push(null)}});if(e&&e[r])p=!0,h=e[r]();else{if(!e||!e[a])throw new l("iterable",["Iterable"],e);p=!1,h=e[a]()}const c=new t({objectMode:!0,highWaterMark:1,...n});let d=!1;return c._read=function(){d||(d=!0,async function(){for(;;){try{const{value:t,done:e}=p?await h.next():h.next();if(e)c.push(null);else{const e=t&&"function"==typeof t.then?await t:t;if(null===e)throw d=!1,new u;if(c.push(e))continue;d=!1}}catch(t){c.destroy(t)}break}}())},c._destroy=function(t,e){s(async function(t){const e=null!=t,n="function"==typeof h.throw;if(e&&n){const{value:e,done:n}=await h.throw(t);if(await e,n)return}if("function"==typeof h.return){const{value:t}=await h.return();await t}}(t),(()=>i.nextTick(e,t)),(n=>i.nextTick(e,n||t)))},c}},2913:(t,e,n)=>{"use strict";const{ArrayIsArray:i,ObjectSetPrototypeOf:s}=n(4184),{EventEmitter:r}=n(7007);function a(t){r.call(this,t)}function o(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?i(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}s(a.prototype,r.prototype),s(a,r),a.prototype.pipe=function(t,e){const n=this;function i(e){t.writable&&!1===t.write(e)&&n.pause&&n.pause()}function s(){n.readable&&n.resume&&n.resume()}n.on("data",i),t.on("drain",s),t._isStdio||e&&!1===e.end||(n.on("end",l),n.on("close",u));let a=!1;function l(){a||(a=!0,t.end())}function u(){a||(a=!0,"function"==typeof t.destroy&&t.destroy())}function h(t){p(),0===r.listenerCount(this,"error")&&this.emit("error",t)}function p(){n.removeListener("data",i),t.removeListener("drain",s),n.removeListener("end",l),n.removeListener("close",u),n.removeListener("error",h),t.removeListener("error",h),n.removeListener("end",p),n.removeListener("close",p),t.removeListener("close",p)}return o(n,"error",h),o(t,"error",h),n.on("end",p),n.on("close",p),t.on("close",p),t.emit("pipe",n),t},t.exports={Stream:a,prependListener:o}},5589:(t,e,n)=>{"use strict";const i=globalThis.AbortController||n(5568).AbortController,{codes:{ERR_INVALID_ARG_VALUE:s,ERR_INVALID_ARG_TYPE:r,ERR_MISSING_ARGS:a,ERR_OUT_OF_RANGE:o},AbortError:l}=n(6605),{validateAbortSignal:u,validateInteger:h,validateObject:p}=n(6283),c=n(4184).Symbol("kWeak"),d=n(4184).Symbol("kResistStopPropagation"),{finished:f}=n(9700),m=n(6864),{addAbortSignalNoValidate:g}=n(153),{isWritable:_,isNodeStream:T}=n(6569),{deprecate:y}=n(798),{ArrayPrototypePush:I,Boolean:E,MathFloor:b,Number:v,NumberIsNaN:w,Promise:S,PromiseReject:x,PromiseResolve:R,PromisePrototypeThen:O,Symbol:A}=n(4184),M=A("kEmpty"),C=A("kEof");function N(t,e){if("function"!=typeof t)throw new r("fn",["Function","AsyncFunction"],t);null!=e&&p(e,"options"),null!=(null==e?void 0:e.signal)&&u(e.signal,"options.signal");let i=1;null!=(null==e?void 0:e.concurrency)&&(i=b(e.concurrency));let s=i-1;return null!=(null==e?void 0:e.highWaterMark)&&(s=b(e.highWaterMark)),h(i,"options.concurrency",1),h(s,"options.highWaterMark",0),s+=i,async function*(){const r=n(798).AbortSignalAny([null==e?void 0:e.signal].filter(E)),a=this,o=[],u={signal:r};let h,p,c=!1,d=0;function f(){c=!0,m()}function m(){d-=1,g()}function g(){p&&!c&&d<i&&o.length<s&&(p(),p=null)}!async function(){try{for await(let e of a){if(c)return;if(r.aborted)throw new l;try{if(e=t(e,u),e===M)continue;e=R(e)}catch(t){e=x(t)}d+=1,O(e,m,f),o.push(e),h&&(h(),h=null),!c&&(o.length>=s||d>=i)&&await new S((t=>{p=t}))}o.push(C)}catch(t){const e=x(t);O(e,m,f),o.push(e)}finally{c=!0,h&&(h(),h=null)}}();try{for(;;){for(;o.length>0;){const t=await o[0];if(t===C)return;if(r.aborted)throw new l;t!==M&&(yield t),o.shift(),g()}await new S((t=>{h=t}))}}finally{c=!0,p&&(p(),p=null)}}.call(this)}async function k(t,e=void 0){for await(const n of D.call(this,t,e))return!0;return!1}function D(t,e){if("function"!=typeof t)throw new r("fn",["Function","AsyncFunction"],t);return N.call(this,(async function(e,n){return await t(e,n)?e:M}),e)}class L extends a{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}function F(t){if(t=v(t),w(t))return 0;if(t<0)throw new o("number",">= 0",t);return t}t.exports.streamReturningOperators={asIndexedPairs:y((function(t=void 0){return null!=t&&p(t,"options"),null!=(null==t?void 0:t.signal)&&u(t.signal,"options.signal"),async function*(){let e=0;for await(const i of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new l({cause:t.signal.reason});yield[e++,i]}}.call(this)}),"readable.asIndexedPairs will be removed in a future version."),drop:function(t,e=void 0){return null!=e&&p(e,"options"),null!=(null==e?void 0:e.signal)&&u(e.signal,"options.signal"),t=F(t),async function*(){var n;if(null!=e&&null!==(n=e.signal)&&void 0!==n&&n.aborted)throw new l;for await(const n of this){var i;if(null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted)throw new l;t--<=0&&(yield n)}}.call(this)},filter:D,flatMap:function(t,e){const n=N.call(this,t,e);return async function*(){for await(const t of n)yield*t}.call(this)},map:N,take:function(t,e=void 0){return null!=e&&p(e,"options"),null!=(null==e?void 0:e.signal)&&u(e.signal,"options.signal"),t=F(t),async function*(){var n;if(null!=e&&null!==(n=e.signal)&&void 0!==n&&n.aborted)throw new l;for await(const n of this){var i;if(null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted)throw new l;if(t-- >0&&(yield n),t<=0)return}}.call(this)},compose:function(t,e){if(null!=e&&p(e,"options"),null!=(null==e?void 0:e.signal)&&u(e.signal,"options.signal"),T(t)&&!_(t))throw new s("stream",t,"must be writable");const n=m(this,t);return null!=e&&e.signal&&g(e.signal,n),n}},t.exports.promiseReturningOperators={every:async function(t,e=void 0){if("function"!=typeof t)throw new r("fn",["Function","AsyncFunction"],t);return!await k.call(this,(async(...e)=>!await t(...e)),e)},forEach:async function(t,e){if("function"!=typeof t)throw new r("fn",["Function","AsyncFunction"],t);for await(const n of N.call(this,(async function(e,n){return await t(e,n),M}),e));},reduce:async function(t,e,n){var s;if("function"!=typeof t)throw new r("reducer",["Function","AsyncFunction"],t);null!=n&&p(n,"options"),null!=(null==n?void 0:n.signal)&&u(n.signal,"options.signal");let a=arguments.length>1;if(null!=n&&null!==(s=n.signal)&&void 0!==s&&s.aborted){const t=new l(void 0,{cause:n.signal.reason});throw this.once("error",(()=>{})),await f(this.destroy(t)),t}const o=new i,h=o.signal;if(null!=n&&n.signal){const t={once:!0,[c]:this,[d]:!0};n.signal.addEventListener("abort",(()=>o.abort()),t)}let m=!1;try{for await(const i of this){var g;if(m=!0,null!=n&&null!==(g=n.signal)&&void 0!==g&&g.aborted)throw new l;a?e=await t(e,i,{signal:h}):(e=i,a=!0)}if(!m&&!a)throw new L}finally{o.abort()}return e},toArray:async function(t){null!=t&&p(t,"options"),null!=(null==t?void 0:t.signal)&&u(t.signal,"options.signal");const e=[];for await(const i of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new l(void 0,{cause:t.signal.reason});I(e,i)}return e},some:k,find:async function(t,e){for await(const n of D.call(this,t,e))return n}}},6898:(t,e,n)=>{"use strict";const{ObjectSetPrototypeOf:i}=n(4184);t.exports=r;const s=n(208);function r(t){if(!(this instanceof r))return new r(t);s.call(this,t)}i(r.prototype,s.prototype),i(r,s),r.prototype._transform=function(t,e,n){n(null,t)}},872:(t,e,n)=>{const i=n(5606),{ArrayIsArray:s,Promise:r,SymbolAsyncIterator:a,SymbolDispose:o}=n(4184),l=n(9700),{once:u}=n(798),h=n(2430),p=n(4992),{aggregateTwoErrors:c,codes:{ERR_INVALID_ARG_TYPE:d,ERR_INVALID_RETURN_VALUE:f,ERR_MISSING_ARGS:m,ERR_STREAM_DESTROYED:g,ERR_STREAM_PREMATURE_CLOSE:_},AbortError:T}=n(6605),{validateFunction:y,validateAbortSignal:I}=n(6283),{isIterable:E,isReadable:b,isReadableNodeStream:v,isNodeStream:w,isTransformStream:S,isWebStream:x,isReadableStream:R,isReadableFinished:O}=n(6569),A=globalThis.AbortController||n(5568).AbortController;let M,C,N;function k(t,e,n){let i=!1;t.on("close",(()=>{i=!0}));return{destroy:e=>{i||(i=!0,h.destroyer(t,e||new g("pipe")))},cleanup:l(t,{readable:e,writable:n},(t=>{i=!t}))}}function D(t){if(E(t))return t;if(v(t))return async function*(t){C||(C=n(6566));yield*C.prototype[a].call(t)}(t);throw new d("val",["Readable","Iterable","AsyncIterable"],t)}async function L(t,e,n,{end:i}){let s,a=null;const o=t=>{if(t&&(s=t),a){const t=a;a=null,t()}},u=()=>new r(((t,e)=>{s?e(s):a=()=>{s?e(s):t()}}));e.on("drain",o);const h=l(e,{readable:!1},o);try{e.writableNeedDrain&&await u();for await(const n of t)e.write(n)||await u();i&&(e.end(),await u()),n()}catch(t){n(s!==t?c(s,t):t)}finally{h(),e.off("drain",o)}}async function F(t,e,n,{end:i}){S(e)&&(e=e.writable);const s=e.getWriter();try{for await(const e of t)await s.ready,s.write(e).catch((()=>{}));await s.ready,i&&await s.close(),n()}catch(t){try{await s.abort(t),n(t)}catch(t){n(t)}}}function P(t,e,r){if(1===t.length&&s(t[0])&&(t=t[0]),t.length<2)throw new m("streams");const a=new A,l=a.signal,u=null==r?void 0:r.signal,h=[];function c(){V(new T)}let g,_,y;I(u,"options.signal"),N=N||n(798).addAbortListener,u&&(g=N(u,c));const O=[];let C,P=0;function B(t){V(t,0==--P)}function V(t,n){var s;if(!t||_&&"ERR_STREAM_PREMATURE_CLOSE"!==_.code||(_=t),_||n){for(;O.length;)O.shift()(_);null===(s=g)||void 0===s||s[o](),a.abort(),n&&(_||h.forEach((t=>t())),i.nextTick(e,_,y))}}for(let H=0;H<t.length;H++){const W=t[H],z=H<t.length-1,X=H>0,j=z||!1!==(null==r?void 0:r.end),q=H===t.length-1;if(w(W)){if(j){const{destroy:K,cleanup:Q}=k(W,z,X);O.push(K),b(W)&&q&&h.push(Q)}function U(t){t&&"AbortError"!==t.name&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code&&B(t)}W.on("error",U),b(W)&&q&&h.push((()=>{W.removeListener("error",U)}))}if(0===H)if("function"==typeof W){if(C=W({signal:l}),!E(C))throw new f("Iterable, AsyncIterable or Stream","source",C)}else C=E(W)||v(W)||S(W)?W:p.from(W);else if("function"==typeof W){var Y;if(S(C))C=D(null===(Y=C)||void 0===Y?void 0:Y.readable);else C=D(C);if(C=W(C,{signal:l}),z){if(!E(C,!0))throw new f("AsyncIterable",`transform[${H-1}]`,C)}else{var G;M||(M=n(6898));const J=new M({objectMode:!0}),Z=null===(G=C)||void 0===G?void 0:G.then;if("function"==typeof Z)P++,Z.call(C,(t=>{y=t,null!=t&&J.write(t),j&&J.end(),i.nextTick(B)}),(t=>{J.destroy(t),i.nextTick(B,t)}));else if(E(C,!0))P++,L(C,J,B,{end:j});else{if(!R(C)&&!S(C))throw new f("AsyncIterable or Promise","destination",C);{const nt=C.readable||C;P++,L(nt,J,B,{end:j})}}C=J;const{destroy:tt,cleanup:et}=k(C,!1,!0);O.push(tt),q&&h.push(et)}}else if(w(W)){if(v(C)){P+=2;const it=$(C,W,B,{end:j});b(W)&&q&&h.push(it)}else if(S(C)||R(C)){const st=C.readable||C;P++,L(st,W,B,{end:j})}else{if(!E(C))throw new d("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],C);P++,L(C,W,B,{end:j})}C=W}else if(x(W)){if(v(C))P++,F(D(C),W,B,{end:j});else if(R(C)||E(C))P++,F(C,W,B,{end:j});else{if(!S(C))throw new d("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],C);P++,F(C.readable,W,B,{end:j})}C=W}else C=p.from(W)}return(null!=l&&l.aborted||null!=u&&u.aborted)&&i.nextTick(c),C}function $(t,e,n,{end:s}){let r=!1;if(e.on("close",(()=>{r||n(new _)})),t.pipe(e,{end:!1}),s){function a(){r=!0,e.end()}O(t)?i.nextTick(a):t.once("end",a)}else n();return l(t,{readable:!0,writable:!1},(e=>{const i=t._readableState;e&&"ERR_STREAM_PREMATURE_CLOSE"===e.code&&i&&i.ended&&!i.errored&&!i.errorEmitted?t.once("end",n).once("error",n):n(e)})),l(e,{readable:!1,writable:!0},n)}t.exports={pipelineImpl:P,pipeline:function(...t){return P(t,u(function(t){return y(t[t.length-1],"streams[stream.length - 1]"),t.pop()}(t)))}}},6566:(t,e,n)=>{const i=n(5606),{ArrayPrototypeIndexOf:s,NumberIsInteger:r,NumberIsNaN:a,NumberParseInt:o,ObjectDefineProperties:l,ObjectKeys:u,ObjectSetPrototypeOf:h,Promise:p,SafeSet:c,SymbolAsyncDispose:d,SymbolAsyncIterator:f,Symbol:m}=n(4184);t.exports=q,q.ReadableState=j;const{EventEmitter:g}=n(7007),{Stream:_,prependListener:T}=n(2913),{Buffer:y}=n(8287),{addAbortSignal:I}=n(153),E=n(9700);let b=n(798).debuglog("stream",(t=>{b=t}));const v=n(1515),w=n(2430),{getHighWaterMark:S,getDefaultHighWaterMark:x}=n(9153),{aggregateTwoErrors:R,codes:{ERR_INVALID_ARG_TYPE:O,ERR_METHOD_NOT_IMPLEMENTED:A,ERR_OUT_OF_RANGE:M,ERR_STREAM_PUSH_AFTER_EOF:C,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:N},AbortError:k}=n(6605),{validateObject:D}=n(6283),L=m("kPaused"),{StringDecoder:F}=n(8707),P=n(3182);h(q.prototype,_.prototype),h(q,_);const $=()=>{},{errorOrDestroy:B}=w,V=1,U=16,Y=32,G=64,H=2048,W=4096,z=65536;function X(t){return{enumerable:!1,get(){return!!(this.state&t)},set(e){e?this.state|=t:this.state&=~t}}}function j(t,e,i){"boolean"!=typeof i&&(i=e instanceof n(4992)),this.state=H|W|U|Y,t&&t.objectMode&&(this.state|=V),i&&t&&t.readableObjectMode&&(this.state|=V),this.highWaterMark=t?S(this,t,"readableHighWaterMark",i):x(!1),this.buffer=new v,this.length=0,this.pipes=[],this.flowing=null,this[L]=null,t&&!1===t.emitClose&&(this.state&=~H),t&&!1===t.autoDestroy&&(this.state&=~W),this.errored=null,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new F(t.encoding),this.encoding=t.encoding)}function q(t){if(!(this instanceof q))return new q(t);const e=this instanceof n(4992);this._readableState=new j(t,this,e),t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.construct&&(this._construct=t.construct),t.signal&&!e&&I(t.signal,this)),_.call(this,t),w.construct(this,(()=>{this._readableState.needReadable&&et(this,this._readableState)}))}function K(t,e,n,i){b("readableAddChunk",e);const s=t._readableState;let r;if(s.state&V||("string"==typeof e?(n=n||s.defaultEncoding,s.encoding!==n&&(i&&s.encoding?e=y.from(e,n).toString(s.encoding):(e=y.from(e,n),n=""))):e instanceof y?n="":_._isUint8Array(e)?(e=_._uint8ArrayToBuffer(e),n=""):null!=e&&(r=new O("chunk",["string","Buffer","Uint8Array"],e))),r)B(t,r);else if(null===e)s.state&=-9,function(t,e){if(b("onEofChunk"),e.ended)return;if(e.decoder){const t=e.decoder.end();t&&t.length&&(e.buffer.push(t),e.length+=e.objectMode?1:t.length)}e.ended=!0,e.sync?Z(t):(e.needReadable=!1,e.emittedReadable=!0,tt(t))}(t,s);else if(s.state&V||e&&e.length>0)if(i)if(4&s.state)B(t,new N);else{if(s.destroyed||s.errored)return!1;Q(t,s,e,!0)}else if(s.ended)B(t,new C);else{if(s.destroyed||s.errored)return!1;s.state&=-9,s.decoder&&!n?(e=s.decoder.write(e),s.objectMode||0!==e.length?Q(t,s,e,!1):et(t,s)):Q(t,s,e,!1)}else i||(s.state&=-9,et(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function Q(t,e,n,i){e.flowing&&0===e.length&&!e.sync&&t.listenerCount("data")>0?(e.state&z?e.awaitDrainWriters.clear():e.awaitDrainWriters=null,e.dataEmitted=!0,t.emit("data",n)):(e.length+=e.objectMode?1:n.length,i?e.buffer.unshift(n):e.buffer.push(n),e.state&G&&Z(t)),et(t,e)}l(j.prototype,{objectMode:X(V),ended:X(2),endEmitted:X(4),reading:X(8),constructed:X(U),sync:X(Y),needReadable:X(G),emittedReadable:X(128),readableListening:X(256),resumeScheduled:X(512),errorEmitted:X(1024),emitClose:X(H),autoDestroy:X(W),destroyed:X(8192),closed:X(16384),closeEmitted:X(32768),multiAwaitDrain:X(z),readingMore:X(1<<17),dataEmitted:X(1<<18)}),q.prototype.destroy=w.destroy,q.prototype._undestroy=w.undestroy,q.prototype._destroy=function(t,e){e(t)},q.prototype[g.captureRejectionSymbol]=function(t){this.destroy(t)},q.prototype[d]=function(){let t;return this.destroyed||(t=this.readableEnded?null:new k,this.destroy(t)),new p(((e,n)=>E(this,(i=>i&&i!==t?n(i):e(null)))))},q.prototype.push=function(t,e){return K(this,t,e,!1)},q.prototype.unshift=function(t,e){return K(this,t,e,!0)},q.prototype.isPaused=function(){const t=this._readableState;return!0===t[L]||!1===t.flowing},q.prototype.setEncoding=function(t){const e=new F(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;const n=this._readableState.buffer;let i="";for(const t of n)i+=e.write(t);return n.clear(),""!==i&&n.push(i),this._readableState.length=i.length,this};function J(t,e){return t<=0||0===e.length&&e.ended?0:e.state&V?1:a(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}function Z(t){const e=t._readableState;b("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(b("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(tt,t))}function tt(t){const e=t._readableState;b("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||e.errored||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,at(t)}function et(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,i.nextTick(nt,t,e))}function nt(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){const n=e.length;if(b("maybeReadMore read 0"),t.read(0),n===e.length)break}e.readingMore=!1}function it(t){const e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!1===e[L]?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function st(t){b("readable nexttick read 0"),t.read(0)}function rt(t,e){b("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),at(t),e.flowing&&!e.reading&&t.read(0)}function at(t){const e=t._readableState;for(b("flow",e.flowing);e.flowing&&null!==t.read(););}function ot(t,e){"function"!=typeof t.read&&(t=q.wrap(t,{objectMode:!0}));const n=async function*(t,e){let n,i=$;function s(e){this===t?(i(),i=$):i=e}t.on("readable",s);const r=E(t,{writable:!1},(t=>{n=t?R(n,t):null,i(),i=$}));try{for(;;){const e=t.destroyed?null:t.read();if(null!==e)yield e;else{if(n)throw n;if(null===n)return;await new p(s)}}}catch(t){throw n=R(n,t),n}finally{!n&&!1===(null==e?void 0:e.destroyOnReturn)||void 0!==n&&!t._readableState.autoDestroy?(t.off("readable",s),r()):w.destroyer(t,null)}}(t,e);return n.stream=t,n}function lt(t,e){if(0===e.length)return null;let n;return e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n}function ut(t){const e=t._readableState;b("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(ht,e,t))}function ht(t,e){if(b("endReadableNT",t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&0===t.length)if(t.endEmitted=!0,e.emit("end"),e.writable&&!1===e.allowHalfOpen)i.nextTick(pt,e);else if(t.autoDestroy){const t=e._writableState;(!t||t.autoDestroy&&(t.finished||!1===t.writable))&&e.destroy()}}function pt(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}let ct;function dt(){return void 0===ct&&(ct={}),ct}q.prototype.read=function(t){b("read",t),void 0===t?t=NaN:r(t)||(t=o(t,10));const e=this._readableState,n=t;if(t>e.highWaterMark&&(e.highWaterMark=function(t){if(t>1073741824)throw new M("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,++t}(t)),0!==t&&(e.state&=-129),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return b("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?ut(this):Z(this),null;if(0===(t=J(t,e))&&e.ended)return 0===e.length&&ut(this),null;let i,s=!!(e.state&G);if(b("need readable",s),(0===e.length||e.length-t<e.highWaterMark)&&(s=!0,b("length less than watermark",s)),e.ended||e.reading||e.destroyed||e.errored||!e.constructed)s=!1,b("reading, ended or constructing",s);else if(s){b("do read"),e.state|=8|Y,0===e.length&&(e.state|=G);try{this._read(e.highWaterMark)}catch(t){B(this,t)}e.state&=~Y,e.reading||(t=J(n,e))}return i=t>0?lt(t,e):null,null===i?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&ut(this)),null===i||e.errorEmitted||e.closeEmitted||(e.dataEmitted=!0,this.emit("data",i)),i},q.prototype._read=function(t){throw new A("_read()")},q.prototype.pipe=function(t,e){const n=this,s=this._readableState;1===s.pipes.length&&(s.multiAwaitDrain||(s.multiAwaitDrain=!0,s.awaitDrainWriters=new c(s.awaitDrainWriters?[s.awaitDrainWriters]:[]))),s.pipes.push(t),b("pipe count=%d opts=%j",s.pipes.length,e);const r=(!e||!1!==e.end)&&t!==i.stdout&&t!==i.stderr?o:g;function a(e,i){b("onunpipe"),e===n&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,function(){b("cleanup"),t.removeListener("close",f),t.removeListener("finish",m),l&&t.removeListener("drain",l);t.removeListener("error",d),t.removeListener("unpipe",a),n.removeListener("end",o),n.removeListener("end",g),n.removeListener("data",p),u=!0,l&&s.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&l()}())}function o(){b("onend"),t.end()}let l;s.endEmitted?i.nextTick(r):n.once("end",r),t.on("unpipe",a);let u=!1;function h(){u||(1===s.pipes.length&&s.pipes[0]===t?(b("false write response, pause",0),s.awaitDrainWriters=t,s.multiAwaitDrain=!1):s.pipes.length>1&&s.pipes.includes(t)&&(b("false write response, pause",s.awaitDrainWriters.size),s.awaitDrainWriters.add(t)),n.pause()),l||(l=function(t,e){return function(){const n=t._readableState;n.awaitDrainWriters===e?(b("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(b("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),n.awaitDrainWriters&&0!==n.awaitDrainWriters.size||!t.listenerCount("data")||t.resume()}}(n,t),t.on("drain",l))}function p(e){b("ondata");const n=t.write(e);b("dest.write",n),!1===n&&h()}function d(e){if(b("onerror",e),g(),t.removeListener("error",d),0===t.listenerCount("error")){const n=t._writableState||t._readableState;n&&!n.errorEmitted?B(t,e):t.emit("error",e)}}function f(){t.removeListener("finish",m),g()}function m(){b("onfinish"),t.removeListener("close",f),g()}function g(){b("unpipe"),n.unpipe(t)}return n.on("data",p),T(t,"error",d),t.once("close",f),t.once("finish",m),t.emit("pipe",n),!0===t.writableNeedDrain?h():s.flowing||(b("pipe resume"),n.resume()),t},q.prototype.unpipe=function(t){const e=this._readableState;if(0===e.pipes.length)return this;if(!t){const t=e.pipes;e.pipes=[],this.pause();for(let e=0;e<t.length;e++)t[e].emit("unpipe",this,{hasUnpiped:!1});return this}const n=s(e.pipes,t);return-1===n||(e.pipes.splice(n,1),0===e.pipes.length&&this.pause(),t.emit("unpipe",this,{hasUnpiped:!1})),this},q.prototype.on=function(t,e){const n=_.prototype.on.call(this,t,e),s=this._readableState;return"data"===t?(s.readableListening=this.listenerCount("readable")>0,!1!==s.flowing&&this.resume()):"readable"===t&&(s.endEmitted||s.readableListening||(s.readableListening=s.needReadable=!0,s.flowing=!1,s.emittedReadable=!1,b("on readable",s.length,s.reading),s.length?Z(this):s.reading||i.nextTick(st,this))),n},q.prototype.addListener=q.prototype.on,q.prototype.removeListener=function(t,e){const n=_.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(it,this),n},q.prototype.off=q.prototype.removeListener,q.prototype.removeAllListeners=function(t){const e=_.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(it,this),e},q.prototype.resume=function(){const t=this._readableState;return t.flowing||(b("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(rt,t,e))}(this,t)),t[L]=!1,this},q.prototype.pause=function(){return b("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(b("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[L]=!0,this},q.prototype.wrap=function(t){let e=!1;t.on("data",(n=>{!this.push(n)&&t.pause&&(e=!0,t.pause())})),t.on("end",(()=>{this.push(null)})),t.on("error",(t=>{B(this,t)})),t.on("close",(()=>{this.destroy()})),t.on("destroy",(()=>{this.destroy()})),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};const n=u(t);for(let e=1;e<n.length;e++){const i=n[e];void 0===this[i]&&"function"==typeof t[i]&&(this[i]=t[i].bind(t))}return this},q.prototype[f]=function(){return ot(this)},q.prototype.iterator=function(t){return void 0!==t&&D(t,"options"),ot(this,t)},l(q.prototype,{readable:{__proto__:null,get(){const t=this._readableState;return!(!t||!1===t.readable||t.destroyed||t.errorEmitted||t.endEmitted)},set(t){this._readableState&&(this._readableState.readable=!!t)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!(!1===this._readableState.readable||!this._readableState.destroyed&&!this._readableState.errored||this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.objectMode}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return!!this._readableState&&this._readableState.closed}},destroyed:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.destroyed},set(t){this._readableState&&(this._readableState.destroyed=t)}},readableEnded:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.endEmitted}}}),l(j.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return!1!==this[L]},set(t){this[L]=!!t}}}),q._fromList=lt,q.from=function(t,e){return P(q,t,e)},q.fromWeb=function(t,e){return dt().newStreamReadableFromReadableStream(t,e)},q.toWeb=function(t,e){return dt().newReadableStreamFromStreamReadable(t,e)},q.wrap=function(t,e){var n,i;return new q({objectMode:null===(n=null!==(i=t.readableObjectMode)&&void 0!==i?i:t.objectMode)||void 0===n||n,...e,destroy(e,n){w.destroyer(t,e),n(e)}}).wrap(t)}},9153:(t,e,n)=>{"use strict";const{MathFloor:i,NumberIsInteger:s}=n(4184),{validateInteger:r}=n(6283),{ERR_INVALID_ARG_VALUE:a}=n(6605).codes;let o=16384,l=16;function u(t){return t?l:o}t.exports={getHighWaterMark:function(t,e,n,r){const o=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,r,n);if(null!=o){if(!s(o)||o<0){throw new a(r?`options.${n}`:"options.highWaterMark",o)}return i(o)}return u(t.objectMode)},getDefaultHighWaterMark:u,setDefaultHighWaterMark:function(t,e){r(e,"value",0),t?l=e:o=e}}},208:(t,e,n)=>{"use strict";const{ObjectSetPrototypeOf:i,Symbol:s}=n(4184);t.exports=u;const{ERR_METHOD_NOT_IMPLEMENTED:r}=n(6605).codes,a=n(4992),{getHighWaterMark:o}=n(9153);i(u.prototype,a.prototype),i(u,a);const l=s("kCallback");function u(t){if(!(this instanceof u))return new u(t);const e=t?o(this,t,"readableHighWaterMark",!0):null;0===e&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),a.call(this,t),this._readableState.sync=!1,this[l]=null,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",p)}function h(t){"function"!=typeof this._flush||this.destroyed?(this.push(null),t&&t()):this._flush(((e,n)=>{e?t?t(e):this.destroy(e):(null!=n&&this.push(n),this.push(null),t&&t())}))}function p(){this._final!==h&&h.call(this)}u.prototype._final=h,u.prototype._transform=function(t,e,n){throw new r("_transform()")},u.prototype._write=function(t,e,n){const i=this._readableState,s=this._writableState,r=i.length;this._transform(t,e,((t,e)=>{t?n(t):(null!=e&&this.push(e),s.ended||r===i.length||i.length<i.highWaterMark?n():this[l]=n)}))},u.prototype._read=function(){if(this[l]){const t=this[l];this[l]=null,t()}}},6569:(t,e,n)=>{"use strict";const{SymbolAsyncIterator:i,SymbolIterator:s,SymbolFor:r}=n(4184),a=r("nodejs.stream.destroyed"),o=r("nodejs.stream.errored"),l=r("nodejs.stream.readable"),u=r("nodejs.stream.writable"),h=r("nodejs.stream.disturbed"),p=r("nodejs.webstream.isClosedPromise"),c=r("nodejs.webstream.controllerErrorFunction");function d(t,e=!1){var n;return!(!t||"function"!=typeof t.pipe||"function"!=typeof t.on||e&&("function"!=typeof t.pause||"function"!=typeof t.resume)||t._writableState&&!1===(null===(n=t._readableState)||void 0===n?void 0:n.readable)||t._writableState&&!t._readableState)}function f(t){var e;return!(!t||"function"!=typeof t.write||"function"!=typeof t.on||t._readableState&&!1===(null===(e=t._writableState)||void 0===e?void 0:e.writable))}function m(t){return t&&(t._readableState||t._writableState||"function"==typeof t.write&&"function"==typeof t.on||"function"==typeof t.pipe&&"function"==typeof t.on)}function g(t){return!(!t||m(t)||"function"!=typeof t.pipeThrough||"function"!=typeof t.getReader||"function"!=typeof t.cancel)}function _(t){return!(!t||m(t)||"function"!=typeof t.getWriter||"function"!=typeof t.abort)}function T(t){return!(!t||m(t)||"object"!=typeof t.readable||"object"!=typeof t.writable)}function y(t){if(!m(t))return null;const e=t._writableState,n=t._readableState,i=e||n;return!!(t.destroyed||t[a]||null!=i&&i.destroyed)}function I(t){if(!f(t))return null;if(!0===t.writableEnded)return!0;const e=t._writableState;return(null==e||!e.errored)&&("boolean"!=typeof(null==e?void 0:e.ended)?null:e.ended)}function E(t,e){if(!d(t))return null;const n=t._readableState;return(null==n||!n.errored)&&("boolean"!=typeof(null==n?void 0:n.endEmitted)?null:!!(n.endEmitted||!1===e&&!0===n.ended&&0===n.length))}function b(t){return t&&null!=t[l]?t[l]:"boolean"!=typeof(null==t?void 0:t.readable)?null:!y(t)&&(d(t)&&t.readable&&!E(t))}function v(t){return t&&null!=t[u]?t[u]:"boolean"!=typeof(null==t?void 0:t.writable)?null:!y(t)&&(f(t)&&t.writable&&!I(t))}function w(t){return"boolean"==typeof t._closed&&"boolean"==typeof t._defaultKeepAlive&&"boolean"==typeof t._removedConnection&&"boolean"==typeof t._removedContLen}function S(t){return"boolean"==typeof t._sent100&&w(t)}t.exports={isDestroyed:y,kIsDestroyed:a,isDisturbed:function(t){var e;return!(!t||!(null!==(e=t[h])&&void 0!==e?e:t.readableDidRead||t.readableAborted))},kIsDisturbed:h,isErrored:function(t){var e,n,i,s,r,a,l,u,h,p;return!(!t||!(null!==(e=null!==(n=null!==(i=null!==(s=null!==(r=null!==(a=t[o])&&void 0!==a?a:t.readableErrored)&&void 0!==r?r:t.writableErrored)&&void 0!==s?s:null===(l=t._readableState)||void 0===l?void 0:l.errorEmitted)&&void 0!==i?i:null===(u=t._writableState)||void 0===u?void 0:u.errorEmitted)&&void 0!==n?n:null===(h=t._readableState)||void 0===h?void 0:h.errored)&&void 0!==e?e:null===(p=t._writableState)||void 0===p?void 0:p.errored))},kIsErrored:o,isReadable:b,kIsReadable:l,kIsClosedPromise:p,kControllerErrorFunction:c,kIsWritable:u,isClosed:function(t){if(!m(t))return null;if("boolean"==typeof t.closed)return t.closed;const e=t._writableState,n=t._readableState;return"boolean"==typeof(null==e?void 0:e.closed)||"boolean"==typeof(null==n?void 0:n.closed)?(null==e?void 0:e.closed)||(null==n?void 0:n.closed):"boolean"==typeof t._closed&&w(t)?t._closed:null},isDuplexNodeStream:function(t){return!(!t||"function"!=typeof t.pipe||!t._readableState||"function"!=typeof t.on||"function"!=typeof t.write)},isFinished:function(t,e){return m(t)?!!y(t)||(!1===(null==e?void 0:e.readable)||!b(t))&&(!1===(null==e?void 0:e.writable)||!v(t)):null},isIterable:function(t,e){return null!=t&&(!0===e?"function"==typeof t[i]:!1===e?"function"==typeof t[s]:"function"==typeof t[i]||"function"==typeof t[s])},isReadableNodeStream:d,isReadableStream:g,isReadableEnded:function(t){if(!d(t))return null;if(!0===t.readableEnded)return!0;const e=t._readableState;return!(!e||e.errored)&&("boolean"!=typeof(null==e?void 0:e.ended)?null:e.ended)},isReadableFinished:E,isReadableErrored:function(t){var e,n;return m(t)?t.readableErrored?t.readableErrored:null!==(e=null===(n=t._readableState)||void 0===n?void 0:n.errored)&&void 0!==e?e:null:null},isNodeStream:m,isWebStream:function(t){return g(t)||_(t)||T(t)},isWritable:v,isWritableNodeStream:f,isWritableStream:_,isWritableEnded:I,isWritableFinished:function(t,e){if(!f(t))return null;if(!0===t.writableFinished)return!0;const n=t._writableState;return(null==n||!n.errored)&&("boolean"!=typeof(null==n?void 0:n.finished)?null:!!(n.finished||!1===e&&!0===n.ended&&0===n.length))},isWritableErrored:function(t){var e,n;return m(t)?t.writableErrored?t.writableErrored:null!==(e=null===(n=t._writableState)||void 0===n?void 0:n.errored)&&void 0!==e?e:null:null},isServerRequest:function(t){var e;return"boolean"==typeof t._consuming&&"boolean"==typeof t._dumped&&void 0===(null===(e=t.req)||void 0===e?void 0:e.upgradeOrConnect)},isServerResponse:S,willEmitClose:function(t){if(!m(t))return null;const e=t._writableState,n=t._readableState,i=e||n;return!i&&S(t)||!!(i&&i.autoDestroy&&i.emitClose&&!1===i.closed)},isTransformStream:T}},394:(t,e,n)=>{const i=n(5606),{ArrayPrototypeSlice:s,Error:r,FunctionPrototypeSymbolHasInstance:a,ObjectDefineProperty:o,ObjectDefineProperties:l,ObjectSetPrototypeOf:u,StringPrototypeToLowerCase:h,Symbol:p,SymbolHasInstance:c}=n(4184);t.exports=D,D.WritableState=N;const{EventEmitter:d}=n(7007),f=n(2913).Stream,{Buffer:m}=n(8287),g=n(2430),{addAbortSignal:_}=n(153),{getHighWaterMark:T,getDefaultHighWaterMark:y}=n(9153),{ERR_INVALID_ARG_TYPE:I,ERR_METHOD_NOT_IMPLEMENTED:E,ERR_MULTIPLE_CALLBACK:b,ERR_STREAM_CANNOT_PIPE:v,ERR_STREAM_DESTROYED:w,ERR_STREAM_ALREADY_FINISHED:S,ERR_STREAM_NULL_VALUES:x,ERR_STREAM_WRITE_AFTER_END:R,ERR_UNKNOWN_ENCODING:O}=n(6605).codes,{errorOrDestroy:A}=g;function M(){}u(D.prototype,f.prototype),u(D,f);const C=p("kOnFinished");function N(t,e,i){"boolean"!=typeof i&&(i=e instanceof n(4992)),this.objectMode=!(!t||!t.objectMode),i&&(this.objectMode=this.objectMode||!(!t||!t.writableObjectMode)),this.highWaterMark=t?T(this,t,"writableHighWaterMark",i):y(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const s=!(!t||!1!==t.decodeStrings);this.decodeStrings=!s,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=$.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,k(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!t||!1!==t.emitClose,this.autoDestroy=!t||!1!==t.autoDestroy,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[C]=[]}function k(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}function D(t){const e=this instanceof n(4992);if(!e&&!a(D,this))return new D(t);this._writableState=new N(t,this,e),t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final),"function"==typeof t.construct&&(this._construct=t.construct),t.signal&&_(t.signal,this)),f.call(this,t),g.construct(this,(()=>{const t=this._writableState;t.writing||Y(this,t),W(this,t)}))}function L(t,e,n,s){const r=t._writableState;if("function"==typeof n)s=n,n=r.defaultEncoding;else{if(n){if("buffer"!==n&&!m.isEncoding(n))throw new O(n)}else n=r.defaultEncoding;"function"!=typeof s&&(s=M)}if(null===e)throw new x;if(!r.objectMode)if("string"==typeof e)!1!==r.decodeStrings&&(e=m.from(e,n),n="buffer");else if(e instanceof m)n="buffer";else{if(!f._isUint8Array(e))throw new I("chunk",["string","Buffer","Uint8Array"],e);e=f._uint8ArrayToBuffer(e),n="buffer"}let a;return r.ending?a=new R:r.destroyed&&(a=new w("write")),a?(i.nextTick(s,a),A(t,a,!0),a):(r.pendingcb++,function(t,e,n,i,s){const r=e.objectMode?1:n.length;e.length+=r;const a=e.length<e.highWaterMark;a||(e.needDrain=!0);e.writing||e.corked||e.errored||!e.constructed?(e.buffered.push({chunk:n,encoding:i,callback:s}),e.allBuffers&&"buffer"!==i&&(e.allBuffers=!1),e.allNoop&&s!==M&&(e.allNoop=!1)):(e.writelen=r,e.writecb=s,e.writing=!0,e.sync=!0,t._write(n,i,e.onwrite),e.sync=!1);return a&&!e.errored&&!e.destroyed}(t,r,e,n,s))}function F(t,e,n,i,s,r,a){e.writelen=i,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new w("write")):n?t._writev(s,e.onwrite):t._write(s,r,e.onwrite),e.sync=!1}function P(t,e,n,i){--e.pendingcb,i(n),U(e),A(t,n)}function $(t,e){const n=t._writableState,s=n.sync,r=n.writecb;"function"==typeof r?(n.writing=!1,n.writecb=null,n.length-=n.writelen,n.writelen=0,e?(e.stack,n.errored||(n.errored=e),t._readableState&&!t._readableState.errored&&(t._readableState.errored=e),s?i.nextTick(P,t,n,e,r):P(t,n,e,r)):(n.buffered.length>n.bufferedIndex&&Y(t,n),s?null!==n.afterWriteTickInfo&&n.afterWriteTickInfo.cb===r?n.afterWriteTickInfo.count++:(n.afterWriteTickInfo={count:1,cb:r,stream:t,state:n},i.nextTick(B,n.afterWriteTickInfo)):V(t,n,1,r))):A(t,new b)}function B({stream:t,state:e,count:n,cb:i}){return e.afterWriteTickInfo=null,V(t,e,n,i)}function V(t,e,n,i){for(!e.ending&&!t.destroyed&&0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"));n-- >0;)e.pendingcb--,i();e.destroyed&&U(e),W(t,e)}function U(t){if(t.writing)return;for(let n=t.bufferedIndex;n<t.buffered.length;++n){var e;const{chunk:i,callback:s}=t.buffered[n],r=t.objectMode?1:i.length;t.length-=r,s(null!==(e=t.errored)&&void 0!==e?e:new w("write"))}const n=t[C].splice(0);for(let e=0;e<n.length;e++){var i;n[e](null!==(i=t.errored)&&void 0!==i?i:new w("end"))}k(t)}function Y(t,e){if(e.corked||e.bufferProcessing||e.destroyed||!e.constructed)return;const{buffered:n,bufferedIndex:i,objectMode:r}=e,a=n.length-i;if(!a)return;let o=i;if(e.bufferProcessing=!0,a>1&&t._writev){e.pendingcb-=a-1;const i=e.allNoop?M:t=>{for(let e=o;e<n.length;++e)n[e].callback(t)},r=e.allNoop&&0===o?n:s(n,o);r.allBuffers=e.allBuffers,F(t,e,!0,e.length,r,"",i),k(e)}else{do{const{chunk:i,encoding:s,callback:a}=n[o];n[o++]=null;F(t,e,!1,r?1:i.length,i,s,a)}while(o<n.length&&!e.writing);o===n.length?k(e):o>256?(n.splice(0,o),e.bufferedIndex=0):e.bufferedIndex=o}e.bufferProcessing=!1}function G(t){return t.ending&&!t.destroyed&&t.constructed&&0===t.length&&!t.errored&&0===t.buffered.length&&!t.finished&&!t.writing&&!t.errorEmitted&&!t.closeEmitted}function H(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.finalCalled=!0,function(t,e){let n=!1;function s(s){if(n)A(t,null!=s?s:b());else if(n=!0,e.pendingcb--,s){const n=e[C].splice(0);for(let t=0;t<n.length;t++)n[t](s);A(t,s,e.sync)}else G(e)&&(e.prefinished=!0,t.emit("prefinish"),e.pendingcb++,i.nextTick(z,t,e))}e.sync=!0,e.pendingcb++;try{t._final(s)}catch(t){s(t)}e.sync=!1}(t,e)))}function W(t,e,n){G(e)&&(H(t,e),0===e.pendingcb&&(n?(e.pendingcb++,i.nextTick(((t,e)=>{G(e)?z(t,e):e.pendingcb--}),t,e)):G(e)&&(e.pendingcb++,z(t,e))))}function z(t,e){e.pendingcb--,e.finished=!0;const n=e[C].splice(0);for(let t=0;t<n.length;t++)n[t]();if(t.emit("finish"),e.autoDestroy){const e=t._readableState;(!e||e.autoDestroy&&(e.endEmitted||!1===e.readable))&&t.destroy()}}N.prototype.getBuffer=function(){return s(this.buffered,this.bufferedIndex)},o(N.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}}),o(D,c,{__proto__:null,value:function(t){return!!a(this,t)||this===D&&(t&&t._writableState instanceof N)}}),D.prototype.pipe=function(){A(this,new v)},D.prototype.write=function(t,e,n){return!0===L(this,t,e,n)},D.prototype.cork=function(){this._writableState.corked++},D.prototype.uncork=function(){const t=this._writableState;t.corked&&(t.corked--,t.writing||Y(this,t))},D.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=h(t)),!m.isEncoding(t))throw new O(t);return this._writableState.defaultEncoding=t,this},D.prototype._write=function(t,e,n){if(!this._writev)throw new E("_write()");this._writev([{chunk:t,encoding:e}],n)},D.prototype._writev=null,D.prototype.end=function(t,e,n){const s=this._writableState;let a;if("function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t){const n=L(this,t,e);n instanceof r&&(a=n)}return s.corked&&(s.corked=1,this.uncork()),a||(s.errored||s.ending?s.finished?a=new S("end"):s.destroyed&&(a=new w("end")):(s.ending=!0,W(this,s,!0),s.ended=!0)),"function"==typeof n&&(a||s.finished?i.nextTick(n,a):s[C].push(n)),this},l(D.prototype,{closed:{__proto__:null,get(){return!!this._writableState&&this._writableState.closed}},destroyed:{__proto__:null,get(){return!!this._writableState&&this._writableState.destroyed},set(t){this._writableState&&(this._writableState.destroyed=t)}},writable:{__proto__:null,get(){const t=this._writableState;return!(!t||!1===t.writable||t.destroyed||t.errored||t.ending||t.ended)},set(t){this._writableState&&(this._writableState.writable=!!t)}},writableFinished:{__proto__:null,get(){return!!this._writableState&&this._writableState.finished}},writableObjectMode:{__proto__:null,get(){return!!this._writableState&&this._writableState.objectMode}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return!!this._writableState&&this._writableState.ending}},writableNeedDrain:{__proto__:null,get(){const t=this._writableState;return!!t&&(!t.destroyed&&!t.ending&&t.needDrain)}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!(!1===this._writableState.writable||!this._writableState.destroyed&&!this._writableState.errored||this._writableState.finished)}}});const X=g.destroy;let j;function q(){return void 0===j&&(j={}),j}D.prototype.destroy=function(t,e){const n=this._writableState;return!n.destroyed&&(n.bufferedIndex<n.buffered.length||n[C].length)&&i.nextTick(U,n),X.call(this,t,e),this},D.prototype._undestroy=g.undestroy,D.prototype._destroy=function(t,e){e(t)},D.prototype[d.captureRejectionSymbol]=function(t){this.destroy(t)},D.fromWeb=function(t,e){return q().newStreamWritableFromWritableStream(t,e)},D.toWeb=function(t){return q().newWritableStreamFromStreamWritable(t)}},6283:(t,e,n)=>{"use strict";const{ArrayIsArray:i,ArrayPrototypeIncludes:s,ArrayPrototypeJoin:r,ArrayPrototypeMap:a,NumberIsInteger:o,NumberIsNaN:l,NumberMAX_SAFE_INTEGER:u,NumberMIN_SAFE_INTEGER:h,NumberParseInt:p,ObjectPrototypeHasOwnProperty:c,RegExpPrototypeExec:d,String:f,StringPrototypeToUpperCase:m,StringPrototypeTrim:g}=n(4184),{hideStackFrames:_,codes:{ERR_SOCKET_BAD_PORT:T,ERR_INVALID_ARG_TYPE:y,ERR_INVALID_ARG_VALUE:I,ERR_OUT_OF_RANGE:E,ERR_UNKNOWN_SIGNAL:b}}=n(6605),{normalizeEncoding:v}=n(798),{isAsyncFunction:w,isArrayBufferView:S}=n(798).types,x={};const R=/^[0-7]+$/;const O=_(((t,e,n=h,i=u)=>{if("number"!=typeof t)throw new y(e,"number",t);if(!o(t))throw new E(e,"an integer",t);if(t<n||t>i)throw new E(e,`>= ${n} && <= ${i}`,t)})),A=_(((t,e,n=-2147483648,i=2147483647)=>{if("number"!=typeof t)throw new y(e,"number",t);if(!o(t))throw new E(e,"an integer",t);if(t<n||t>i)throw new E(e,`>= ${n} && <= ${i}`,t)})),M=_(((t,e,n=!1)=>{if("number"!=typeof t)throw new y(e,"number",t);if(!o(t))throw new E(e,"an integer",t);const i=n?1:0,s=4294967295;if(t<i||t>s)throw new E(e,`>= ${i} && <= ${s}`,t)}));function C(t,e){if("string"!=typeof t)throw new y(e,"string",t)}const N=_(((t,e,n)=>{if(!s(n,t)){const i=r(a(n,(t=>"string"==typeof t?`'${t}'`:f(t))),", ");throw new I(e,t,"must be one of: "+i)}}));function k(t,e){if("boolean"!=typeof t)throw new y(e,"boolean",t)}function D(t,e,n){return null!=t&&c(t,e)?t[e]:n}const L=_(((t,e,n=null)=>{const s=D(n,"allowArray",!1),r=D(n,"allowFunction",!1);if(!D(n,"nullable",!1)&&null===t||!s&&i(t)||"object"!=typeof t&&(!r||"function"!=typeof t))throw new y(e,"Object",t)})),F=_(((t,e)=>{if(null!=t&&"object"!=typeof t&&"function"!=typeof t)throw new y(e,"a dictionary",t)})),P=_(((t,e,n=0)=>{if(!i(t))throw new y(e,"Array",t);if(t.length<n){throw new I(e,t,`must be longer than ${n}`)}}));const $=_(((t,e="buffer")=>{if(!S(t))throw new y(e,["Buffer","TypedArray","DataView"],t)}));const B=_(((t,e)=>{if(void 0!==t&&(null===t||"object"!=typeof t||!("aborted"in t)))throw new y(e,"AbortSignal",t)})),V=_(((t,e)=>{if("function"!=typeof t)throw new y(e,"Function",t)})),U=_(((t,e)=>{if("function"!=typeof t||w(t))throw new y(e,"Function",t)})),Y=_(((t,e)=>{if(void 0!==t)throw new y(e,"undefined",t)}));const G=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function H(t,e){if(void 0===t||!d(G,t))throw new I(e,t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}t.exports={isInt32:function(t){return t===(0|t)},isUint32:function(t){return t===t>>>0},parseFileMode:function(t,e,n){if(void 0===t&&(t=n),"string"==typeof t){if(null===d(R,t))throw new I(e,t,"must be a 32-bit unsigned integer or an octal string");t=p(t,8)}return M(t,e),t},validateArray:P,validateStringArray:function(t,e){P(t,e);for(let n=0;n<t.length;n++)C(t[n],`${e}[${n}]`)},validateBooleanArray:function(t,e){P(t,e);for(let n=0;n<t.length;n++)k(t[n],`${e}[${n}]`)},validateAbortSignalArray:function(t,e){P(t,e);for(let n=0;n<t.length;n++){const i=t[n],s=`${e}[${n}]`;if(null==i)throw new y(s,"AbortSignal",i);B(i,s)}},validateBoolean:k,validateBuffer:$,validateDictionary:F,validateEncoding:function(t,e){const n=v(e),i=t.length;if("hex"===n&&i%2!=0)throw new I("encoding",e,`is invalid for data of length ${i}`)},validateFunction:V,validateInt32:A,validateInteger:O,validateNumber:function(t,e,n=void 0,i){if("number"!=typeof t)throw new y(e,"number",t);if(null!=n&&t<n||null!=i&&t>i||(null!=n||null!=i)&&l(t))throw new E(e,`${null!=n?`>= ${n}`:""}${null!=n&&null!=i?" && ":""}${null!=i?`<= ${i}`:""}`,t)},validateObject:L,validateOneOf:N,validatePlainFunction:U,validatePort:function(t,e="Port",n=!0){if("number"!=typeof t&&"string"!=typeof t||"string"==typeof t&&0===g(t).length||+t!=+t>>>0||t>65535||0===t&&!n)throw new T(e,t,n);return 0|t},validateSignalName:function(t,e="signal"){if(C(t,e),void 0===x[t]){if(void 0!==x[m(t)])throw new b(t+" (signals must use all capital letters)");throw new b(t)}},validateString:C,validateUint32:M,validateUndefined:Y,validateUnion:function(t,e,n){if(!s(n,t))throw new y(e,`('${r(n,"|")}')`,t)},validateAbortSignal:B,validateLinkHeaderValue:function(t){if("string"==typeof t)return H(t,"hints"),t;if(i(t)){const e=t.length;let n="";if(0===e)return n;for(let i=0;i<e;i++){const s=t[i];H(s,"hints"),n+=s,i!==e-1&&(n+=", ")}return n}throw new I("hints",t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}}},6248:(t,e,n)=>{"use strict";const i=n(4612),s=n(105),r=i.Readable.destroy;t.exports=i.Readable,t.exports._uint8ArrayToBuffer=i._uint8ArrayToBuffer,t.exports._isUint8Array=i._isUint8Array,t.exports.isDisturbed=i.isDisturbed,t.exports.isErrored=i.isErrored,t.exports.isReadable=i.isReadable,t.exports.Readable=i.Readable,t.exports.Writable=i.Writable,t.exports.Duplex=i.Duplex,t.exports.Transform=i.Transform,t.exports.PassThrough=i.PassThrough,t.exports.addAbortSignal=i.addAbortSignal,t.exports.finished=i.finished,t.exports.destroy=i.destroy,t.exports.destroy=r,t.exports.pipeline=i.pipeline,t.exports.compose=i.compose,Object.defineProperty(i,"promises",{configurable:!0,enumerable:!0,get:()=>s}),t.exports.Stream=i.Stream,t.exports.default=t.exports},6605:(t,e,n)=>{"use strict";const{format:i,inspect:s,AggregateError:r}=n(798),a=globalThis.AggregateError||r,o=Symbol("kIsNodeError"),l=["string","function","number","object","Function","Object","boolean","bigint","symbol"],u=/^([A-Z][a-z0-9]*)+$/,h={};function p(t,e){if(!t)throw new h.ERR_INTERNAL_ASSERTION(e)}function c(t){let e="",n=t.length;const i="-"===t[0]?1:0;for(;n>=i+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function d(t,e,n){n||(n=Error);class s extends n{constructor(...n){super(function(t,e,n){if("function"==typeof e)return p(e.length<=n.length,`Code: ${t}; The provided arguments length (${n.length}) does not match the required ones (${e.length}).`),e(...n);const s=(e.match(/%[dfijoOs]/g)||[]).length;return p(s===n.length,`Code: ${t}; The provided arguments length (${n.length}) does not match the required ones (${s}).`),0===n.length?e:i(e,...n)}(t,e,n))}toString(){return`${this.name} [${t}]: ${this.message}`}}Object.defineProperties(s.prototype,{name:{value:n.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),s.prototype.code=t,s.prototype[o]=!0,h[t]=s}function f(t){const e="__node_internal_"+t.name;return Object.defineProperty(t,"name",{value:e}),t}class m extends Error{constructor(t="The operation was aborted",e=void 0){if(void 0!==e&&"object"!=typeof e)throw new h.ERR_INVALID_ARG_TYPE("options","Object",e);super(t,e),this.code="ABORT_ERR",this.name="AbortError"}}d("ERR_ASSERTION","%s",Error),d("ERR_INVALID_ARG_TYPE",((t,e,n)=>{p("string"==typeof t,"'name' must be a string"),Array.isArray(e)||(e=[e]);let i="The ";t.endsWith(" argument")?i+=`${t} `:i+=`"${t}" ${t.includes(".")?"property":"argument"} `,i+="must be ";const r=[],a=[],o=[];for(const t of e)p("string"==typeof t,"All expected entries have to be of type string"),l.includes(t)?r.push(t.toLowerCase()):u.test(t)?a.push(t):(p("object"!==t,'The value "object" should be written as "Object"'),o.push(t));if(a.length>0){const t=r.indexOf("object");-1!==t&&(r.splice(r,t,1),a.push("Object"))}if(r.length>0){switch(r.length){case 1:i+=`of type ${r[0]}`;break;case 2:i+=`one of type ${r[0]} or ${r[1]}`;break;default:{const t=r.pop();i+=`one of type ${r.join(", ")}, or ${t}`}}(a.length>0||o.length>0)&&(i+=" or ")}if(a.length>0){switch(a.length){case 1:i+=`an instance of ${a[0]}`;break;case 2:i+=`an instance of ${a[0]} or ${a[1]}`;break;default:{const t=a.pop();i+=`an instance of ${a.join(", ")}, or ${t}`}}o.length>0&&(i+=" or ")}switch(o.length){case 0:break;case 1:o[0].toLowerCase()!==o[0]&&(i+="an "),i+=`${o[0]}`;break;case 2:i+=`one of ${o[0]} or ${o[1]}`;break;default:{const t=o.pop();i+=`one of ${o.join(", ")}, or ${t}`}}if(null==n)i+=`. Received ${n}`;else if("function"==typeof n&&n.name)i+=`. Received function ${n.name}`;else if("object"==typeof n){var h;if(null!==(h=n.constructor)&&void 0!==h&&h.name)i+=`. Received an instance of ${n.constructor.name}`;else{i+=`. Received ${s(n,{depth:-1})}`}}else{let t=s(n,{colors:!1});t.length>25&&(t=`${t.slice(0,25)}...`),i+=`. Received type ${typeof n} (${t})`}return i}),TypeError),d("ERR_INVALID_ARG_VALUE",((t,e,n="is invalid")=>{let i=s(e);i.length>128&&(i=i.slice(0,128)+"...");return`The ${t.includes(".")?"property":"argument"} '${t}' ${n}. Received ${i}`}),TypeError),d("ERR_INVALID_RETURN_VALUE",((t,e,n)=>{var i;return`Expected ${t} to be returned from the "${e}" function but got ${null!=n&&null!==(i=n.constructor)&&void 0!==i&&i.name?`instance of ${n.constructor.name}`:"type "+typeof n}.`}),TypeError),d("ERR_MISSING_ARGS",((...t)=>{let e;p(t.length>0,"At least one arg needs to be specified");const n=t.length;switch(t=(Array.isArray(t)?t:[t]).map((t=>`"${t}"`)).join(" or "),n){case 1:e+=`The ${t[0]} argument`;break;case 2:e+=`The ${t[0]} and ${t[1]} arguments`;break;default:{const n=t.pop();e+=`The ${t.join(", ")}, and ${n} arguments`}}return`${e} must be specified`}),TypeError),d("ERR_OUT_OF_RANGE",((t,e,n)=>{let i;return p(e,'Missing "range" argument'),Number.isInteger(n)&&Math.abs(n)>2**32?i=c(String(n)):"bigint"==typeof n?(i=String(n),(n>2n**32n||n<-(2n**32n))&&(i=c(i)),i+="n"):i=s(n),`The value of "${t}" is out of range. It must be ${e}. Received ${i}`}),RangeError),d("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),d("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),d("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),d("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),d("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),d("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),d("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),d("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),d("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),d("ERR_STREAM_WRITE_AFTER_END","write after end",Error),d("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),t.exports={AbortError:m,aggregateTwoErrors:f((function(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;const n=new a([e,t],e.message);return n.code=e.code,n}return t||e})),hideStackFrames:f,codes:h}},4184:t=>{"use strict";t.exports={ArrayIsArray:t=>Array.isArray(t),ArrayPrototypeIncludes:(t,e)=>t.includes(e),ArrayPrototypeIndexOf:(t,e)=>t.indexOf(e),ArrayPrototypeJoin:(t,e)=>t.join(e),ArrayPrototypeMap:(t,e)=>t.map(e),ArrayPrototypePop:(t,e)=>t.pop(e),ArrayPrototypePush:(t,e)=>t.push(e),ArrayPrototypeSlice:(t,e,n)=>t.slice(e,n),Error,FunctionPrototypeCall:(t,e,...n)=>t.call(e,...n),FunctionPrototypeSymbolHasInstance:(t,e)=>Function.prototype[Symbol.hasInstance].call(t,e),MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties:(t,e)=>Object.defineProperties(t,e),ObjectDefineProperty:(t,e,n)=>Object.defineProperty(t,e,n),ObjectGetOwnPropertyDescriptor:(t,e)=>Object.getOwnPropertyDescriptor(t,e),ObjectKeys:t=>Object.keys(t),ObjectSetPrototypeOf:(t,e)=>Object.setPrototypeOf(t,e),Promise,PromisePrototypeCatch:(t,e)=>t.catch(e),PromisePrototypeThen:(t,e,n)=>t.then(e,n),PromiseReject:t=>Promise.reject(t),PromiseResolve:t=>Promise.resolve(t),ReflectApply:Reflect.apply,RegExpPrototypeTest:(t,e)=>t.test(e),SafeSet:Set,String,StringPrototypeSlice:(t,e,n)=>t.slice(e,n),StringPrototypeToLowerCase:t=>t.toLowerCase(),StringPrototypeToUpperCase:t=>t.toUpperCase(),StringPrototypeTrim:t=>t.trim(),Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet:(t,e,n)=>t.set(e,n),Boolean,Uint8Array}},798:(t,e,n)=>{"use strict";const i=n(8287),{kResistStopPropagation:s,SymbolDispose:r}=n(4184),a=globalThis.AbortSignal||n(5568).AbortSignal,o=globalThis.AbortController||n(5568).AbortController,l=Object.getPrototypeOf((async function(){})).constructor,u=globalThis.Blob||i.Blob,h=void 0!==u?function(t){return t instanceof u}:function(t){return!1},p=(t,e)=>{if(void 0!==t&&(null===t||"object"!=typeof t||!("aborted"in t)))throw new ERR_INVALID_ARG_TYPE(e,"AbortSignal",t)};class c extends Error{constructor(t){if(!Array.isArray(t))throw new TypeError("Expected input to be an Array, got "+typeof t);let e="";for(let n=0;n<t.length;n++)e+=` ${t[n].stack}\n`;super(e),this.name="AggregateError",this.errors=t}}t.exports={AggregateError:c,kEmptyObject:Object.freeze({}),once(t){let e=!1;return function(...n){e||(e=!0,t.apply(this,n))}},createDeferredPromise:function(){let t,e;return{promise:new Promise(((n,i)=>{t=n,e=i})),resolve:t,reject:e}},promisify:t=>new Promise(((e,n)=>{t(((t,...i)=>t?n(t):e(...i)))})),debuglog:()=>function(){},format:(t,...e)=>t.replace(/%([sdifj])/g,(function(...[t,n]){const i=e.shift();if("f"===n)return i.toFixed(6);if("j"===n)return JSON.stringify(i);if("s"===n&&"object"==typeof i){return`${i.constructor!==Object?i.constructor.name:""} {}`.trim()}return i.toString()})),inspect(t){switch(typeof t){case"string":if(t.includes("'")){if(!t.includes('"'))return`"${t}"`;if(!t.includes("`")&&!t.includes("${"))return`\`${t}\``}return`'${t}'`;case"number":return isNaN(t)?"NaN":Object.is(t,-0)?String(t):t;case"bigint":return`${String(t)}n`;case"boolean":case"undefined":return String(t);case"object":return"{}"}},types:{isAsyncFunction:t=>t instanceof l,isArrayBufferView:t=>ArrayBuffer.isView(t)},isBlob:h,deprecate:(t,e)=>t,addAbortListener:n(7007).addAbortListener||function(t,e){if(void 0===t)throw new ERR_INVALID_ARG_TYPE("signal","AbortSignal",t);let n;return p(t,"signal"),((t,e)=>{if("function"!=typeof t)throw new ERR_INVALID_ARG_TYPE(e,"Function",t)})(e,"listener"),t.aborted?queueMicrotask((()=>e())):(t.addEventListener("abort",e,{__proto__:null,once:!0,[s]:!0}),n=()=>{t.removeEventListener("abort",e)}),{__proto__:null,[r](){var t;null===(t=n)||void 0===t||t()}}},AbortSignalAny:a.any||function(t){if(1===t.length)return t[0];const e=new o,n=()=>e.abort();return t.forEach((t=>{p(t,"signals"),t.addEventListener("abort",n,{once:!0})})),e.signal.addEventListener("abort",(()=>{t.forEach((t=>t.removeEventListener("abort",n)))}),{once:!0}),e.signal}},t.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")},4612:(t,e,n)=>{const{Buffer:i}=n(8287),{ObjectDefineProperty:s,ObjectKeys:r,ReflectApply:a}=n(4184),{promisify:{custom:o}}=n(798),{streamReturningOperators:l,promiseReturningOperators:u}=n(5589),{codes:{ERR_ILLEGAL_CONSTRUCTOR:h}}=n(6605),p=n(6864),{setDefaultHighWaterMark:c,getDefaultHighWaterMark:d}=n(9153),{pipeline:f}=n(872),{destroyer:m}=n(2430),g=n(9700),_=n(105),T=n(6569),y=t.exports=n(2913).Stream;y.isDestroyed=T.isDestroyed,y.isDisturbed=T.isDisturbed,y.isErrored=T.isErrored,y.isReadable=T.isReadable,y.isWritable=T.isWritable,y.Readable=n(6566);for(const b of r(l)){const v=l[b];function I(...t){if(new.target)throw h();return y.Readable.from(a(v,this,t))}s(I,"name",{__proto__:null,value:v.name}),s(I,"length",{__proto__:null,value:v.length}),s(y.Readable.prototype,b,{__proto__:null,value:I,enumerable:!1,configurable:!0,writable:!0})}for(const w of r(u)){const S=u[w];function I(...t){if(new.target)throw h();return a(S,this,t)}s(I,"name",{__proto__:null,value:S.name}),s(I,"length",{__proto__:null,value:S.length}),s(y.Readable.prototype,w,{__proto__:null,value:I,enumerable:!1,configurable:!0,writable:!0})}y.Writable=n(394),y.Duplex=n(4992),y.Transform=n(208),y.PassThrough=n(6898),y.pipeline=f;const{addAbortSignal:E}=n(153);y.addAbortSignal=E,y.finished=g,y.destroy=m,y.compose=p,y.setDefaultHighWaterMark=c,y.getDefaultHighWaterMark=d,s(y,"promises",{__proto__:null,configurable:!0,enumerable:!0,get:()=>_}),s(f,o,{__proto__:null,enumerable:!0,get:()=>_.pipeline}),s(g,o,{__proto__:null,enumerable:!0,get:()=>_.finished}),y.Stream=y,y._isUint8Array=function(t){return t instanceof Uint8Array},y._uint8ArrayToBuffer=function(t){return i.from(t.buffer,t.byteOffset,t.byteLength)}},105:(t,e,n)=>{"use strict";const{ArrayPrototypePop:i,Promise:s}=n(4184),{isIterable:r,isNodeStream:a,isWebStream:o}=n(6569),{pipelineImpl:l}=n(872),{finished:u}=n(9700);n(4612),t.exports={finished:u,pipeline:function(...t){return new s(((e,n)=>{let s,u;const h=t[t.length-1];if(h&&"object"==typeof h&&!a(h)&&!r(h)&&!o(h)){const e=i(t);s=e.signal,u=e.end}l(t,((t,i)=>{t?n(t):e(i)}),{signal:s,end:u})}))}}},8707:(t,e,n)=>{"use strict";var i=n(5242).Buffer,s=i.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(i.isEncoding===s||!s(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=l,this.end=u,e=4;break;case"utf8":this.fillLast=o,e=4;break;case"base64":this.text=h,this.end=p,e=3;break;default:return this.write=c,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function o(t){var e=this.lastTotal-this.lastNeed,n=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"<22>";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"<22>";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"<22>"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function l(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function h(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function p(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function c(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.StringDecoder=r,r.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<t.length?e?e+this.text(t,n):this.text(t,n):e||""},r.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"<22>":e},r.prototype.text=function(t,e){var n=function(t,e,n){var i=e.length-1;if(i<n)return 0;var s=a(e[i]);if(s>=0)return s>0&&(t.lastNeed=s-1),s;if(--i<n||-2===s)return 0;if(s=a(e[i]),s>=0)return s>0&&(t.lastNeed=s-2),s;if(--i<n||-2===s)return 0;if(s=a(e[i]),s>=0)return s>0&&(2===s?s=0:t.lastNeed=s-3),s;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var i=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)},r.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},5568:t=>{"use strict";const{AbortController:e,AbortSignal:n}="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0;t.exports=e,t.exports.AbortSignal=n,t.exports.default=e},4083:(t,e,n)=>{var i;
/*!
* async
* https://github.com/caolan/async
*
* Copyright 2010-2014 Caolan McMahon
* Released under the MIT license
*/!function(){var s,r={};function a(){}function o(t){return t}function l(t){return!!t}function u(t){return!t}var h="object"==typeof self&&self.self===self&&self||"object"==typeof n.g&&n.g.global===n.g&&n.g||this;function p(t){return function(){if(null===t)throw new Error("Callback was already called.");t.apply(this,arguments),t=null}}function c(t){return function(){null!==t&&(t.apply(this,arguments),t=null)}}null!=h&&(s=h.async),r.noConflict=function(){return h.async=s,r};var d=Object.prototype.toString,f=Array.isArray||function(t){return"[object Array]"===d.call(t)};function m(t){return f(t)||"number"==typeof t.length&&t.length>=0&&t.length%1==0}function g(t,e){for(var n=-1,i=t.length;++n<i;)e(t[n],n,t)}function _(t,e){for(var n=-1,i=t.length,s=Array(i);++n<i;)s[n]=e(t[n],n,t);return s}function T(t){return _(Array(t),(function(t,e){return e}))}function y(t,e){for(var n=0;n<t.length;n++)if(t[n]===e)return n;return-1}var I=Object.keys||function(t){var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e};function E(t){var e,n,i=-1;return m(t)?(e=t.length,function(){return++i<e?i:null}):(n=I(t),e=n.length,function(){return++i<e?n[i]:null})}function b(t,e){return e=null==e?t.length-1:+e,function(){for(var n=Math.max(arguments.length-e,0),i=Array(n),s=0;s<n;s++)i[s]=arguments[s+e];switch(e){case 0:return t.call(this,i);case 1:return t.call(this,arguments[0],i)}}}function v(t){return function(e,n,i){return t(e,i)}}var w="function"==typeof setImmediate&&setImmediate,S=w?function(t){w(t)}:function(t){setTimeout(t,0)};function x(t){return function(e,n,i){i=c(i||a);var s=E(e=e||[]);if(t<=0)return i(null);var r=!1,o=0,l=!1;!function a(){if(r&&o<=0)return i(null);for(;o<t&&!l;){var u=s();if(null===u)return r=!0,void(o<=0&&i(null));o+=1,n(e[u],u,p((function(t){o-=1,t?(i(t),l=!0):a()})))}}()}}function R(t){return function(e,n,i){return t(r.eachOf,e,n,i)}}function O(t){return function(e,n,i,s){return t(x(n),e,i,s)}}function A(t){return function(e,n,i){return t(r.eachOfSeries,e,n,i)}}function M(t,e,n,i){i=c(i||a);var s=m(e=e||[])?[]:{};t(e,(function(t,e,i){n(t,(function(t,n){s[e]=n,i(t)}))}),(function(t){i(t,s)}))}function C(t,e,n,i){var s=[];t(e,(function(t,e,i){n(t,(function(n){n&&s.push({index:e,value:t}),i()}))}),(function(){i(_(s.sort((function(t,e){return t.index-e.index})),(function(t){return t.value})))}))}function N(t,e,n,i){C(t,e,(function(t,e){n(t,(function(t){e(!t)}))}),i)}function k(t,e,n){return function(i,s,r,a){function o(){a&&a(n(!1,void 0))}function l(t,i,s){if(!a)return s();r(t,(function(i){a&&e(i)&&(a(n(!0,t)),a=r=!1),s()}))}arguments.length>3?t(i,s,l,o):(a=r,r=s,t(i,l,o))}}function D(t,e){return e}function L(t,e,n){n=n||a;var i=m(e)?[]:{};t(e,(function(t,e,n){t(b((function(t,s){s.length<=1&&(s=s[0]),i[e]=s,n(t)})))}),(function(t){n(t,i)}))}function F(t,e,n,i){var s=[];t(e,(function(t,e,i){n(t,(function(t,e){s=s.concat(e||[]),i(t)}))}),(function(t){i(t,s)}))}function P(t,e,n){if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");function i(t,e,n,i){if(null!=i&&"function"!=typeof i)throw new Error("task callback must be a function");if(t.started=!0,f(e)||(e=[e]),0===e.length&&t.idle())return r.setImmediate((function(){t.drain()}));g(e,(function(e){var s={data:e,callback:i||a};n?t.tasks.unshift(s):t.tasks.push(s),t.tasks.length===t.concurrency&&t.saturated()})),r.setImmediate(t.process)}function s(t,e){return function(){o-=1;var n=!1,i=arguments;g(e,(function(t){g(l,(function(e,i){e!==t||n||(l.splice(i,1),n=!0)})),t.callback.apply(t,i)})),t.tasks.length+o===0&&t.drain(),t.process()}}var o=0,l=[],u={tasks:[],concurrency:e,payload:n,saturated:a,empty:a,drain:a,started:!1,paused:!1,push:function(t,e){i(u,t,!1,e)},kill:function(){u.drain=a,u.tasks=[]},unshift:function(t,e){i(u,t,!0,e)},process:function(){for(;!u.paused&&o<u.concurrency&&u.tasks.length;){var e=u.payload?u.tasks.splice(0,u.payload):u.tasks.splice(0,u.tasks.length),n=_(e,(function(t){return t.data}));0===u.tasks.length&&u.empty(),o+=1,l.push(e[0]);var i=p(s(u,e));t(n,i)}},length:function(){return u.tasks.length},running:function(){return o},workersList:function(){return l},idle:function(){return u.tasks.length+o===0},pause:function(){u.paused=!0},resume:function(){if(!1!==u.paused){u.paused=!1;for(var t=Math.min(u.concurrency,u.tasks.length),e=1;e<=t;e++)r.setImmediate(u.process)}}};return u}function $(t){return b((function(e,n){e.apply(null,n.concat([b((function(e,n){"object"==typeof console&&(e?console.error&&console.error(e):console[t]&&g(n,(function(e){console[t](e)})))}))]))}))}function B(t){return function(e,n,i){t(T(e),n,i)}}function V(t){return b((function(e,n){var i=b((function(n){var i=this,s=n.pop();return t(e,(function(t,e,s){t.apply(i,n.concat([s]))}),s)}));return n.length?i.apply(this,n):i}))}function U(t){return b((function(e){var n=e.pop();e.push((function(){var t=arguments;i?r.setImmediate((function(){n.apply(null,t)})):n.apply(null,t)}));var i=!0;t.apply(this,e),i=!1}))}"object"==typeof process&&"function"==typeof process.nextTick?r.nextTick=process.nextTick:r.nextTick=S,r.setImmediate=w?S:r.nextTick,r.forEach=r.each=function(t,e,n){return r.eachOf(t,v(e),n)},r.forEachSeries=r.eachSeries=function(t,e,n){return r.eachOfSeries(t,v(e),n)},r.forEachLimit=r.eachLimit=function(t,e,n,i){return x(e)(t,v(n),i)},r.forEachOf=r.eachOf=function(t,e,n){n=c(n||a);for(var i,s=E(t=t||[]),r=0;null!=(i=s());)r+=1,e(t[i],i,p(o));function o(t){r--,t?n(t):null===i&&r<=0&&n(null)}0===r&&n(null)},r.forEachOfSeries=r.eachOfSeries=function(t,e,n){n=c(n||a);var i=E(t=t||[]),s=i();!function a(){var o=!0;if(null===s)return n(null);e(t[s],s,p((function(t){if(t)n(t);else{if(null===(s=i()))return n(null);o?r.setImmediate(a):a()}}))),o=!1}()},r.forEachOfLimit=r.eachOfLimit=function(t,e,n,i){x(e)(t,n,i)},r.map=R(M),r.mapSeries=A(M),r.mapLimit=O(M),r.inject=r.foldl=r.reduce=function(t,e,n,i){r.eachOfSeries(t,(function(t,i,s){n(e,t,(function(t,n){e=n,s(t)}))}),(function(t){i(t,e)}))},r.foldr=r.reduceRight=function(t,e,n,i){var s=_(t,o).reverse();r.reduce(s,e,n,i)},r.transform=function(t,e,n,i){3===arguments.length&&(i=n,n=e,e=f(t)?[]:{}),r.eachOf(t,(function(t,i,s){n(e,t,i,s)}),(function(t){i(t,e)}))},r.select=r.filter=R(C),r.selectLimit=r.filterLimit=O(C),r.selectSeries=r.filterSeries=A(C),r.reject=R(N),r.rejectLimit=O(N),r.rejectSeries=A(N),r.any=r.some=k(r.eachOf,l,o),r.someLimit=k(r.eachOfLimit,l,o),r.all=r.every=k(r.eachOf,u,u),r.everyLimit=k(r.eachOfLimit,u,u),r.detect=k(r.eachOf,o,D),r.detectSeries=k(r.eachOfSeries,o,D),r.detectLimit=k(r.eachOfLimit,o,D),r.sortBy=function(t,e,n){function i(t,e){var n=t.criteria,i=e.criteria;return n<i?-1:n>i?1:0}r.map(t,(function(t,n){e(t,(function(e,i){e?n(e):n(null,{value:t,criteria:i})}))}),(function(t,e){if(t)return n(t);n(null,_(e.sort(i),(function(t){return t.value})))}))},r.auto=function(t,e,n){"function"==typeof arguments[1]&&(n=e,e=null),n=c(n||a);var i=I(t),s=i.length;if(!s)return n(null);e||(e=s);var o={},l=0,u=!1,h=[];function p(t){h.unshift(t)}function d(){s--,g(h.slice(0),(function(t){t()}))}p((function(){s||n(null,o)})),g(i,(function(i){if(!u){for(var s,a=f(t[i])?t[i]:[t[i]],c=b((function(t,e){if(l--,e.length<=1&&(e=e[0]),t){var s={};h=function(t,e){s[e]=t},g(I(a=o),(function(t){h(a[t],t)})),s[i]=e,u=!0,n(t,s)}else o[i]=e,r.setImmediate(d);var a,h})),m=a.slice(0,a.length-1),_=m.length;_--;){if(!(s=t[m[_]]))throw new Error("Has nonexistent dependency in "+m.join(", "));if(f(s)&&y(s,i)>=0)throw new Error("Has cyclic dependencies")}T()?(l++,a[a.length-1](c,o)):p((function t(){T()&&(l++,(e=y(h,t))>=0&&h.splice(e,1),a[a.length-1](c,o));var e}))}function T(){return l<e&&(t=function(t,e){return t&&o.hasOwnProperty(e)},n=!0,g(m,(function(e,i,s){n=t(n,e,i,s)})),n)&&!o.hasOwnProperty(i);var t,n}}))},r.retry=function(t,e,n){var i=[],s={times:5,interval:0};var a=arguments.length;if(a<1||a>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");function o(t,e){function n(t,n){return function(i){t((function(t,e){i(!t||n,{err:t,result:e})}),e)}}function a(t){return function(e){setTimeout((function(){e(null)}),t)}}for(;s.times;){var o=!(s.times-=1);i.push(n(s.task,o)),!o&&s.interval>0&&i.push(a(s.interval))}r.series(i,(function(e,n){n=n[n.length-1],(t||s.callback)(n.err,n.result)}))}return a<=2&&"function"==typeof t&&(n=e,e=t),"function"!=typeof t&&function(t,e){if("number"==typeof e)t.times=parseInt(e,10)||5;else{if("object"!=typeof e)throw new Error("Unsupported argument type for 'times': "+typeof e);t.times=parseInt(e.times,10)||5,t.interval=parseInt(e.interval,10)||0}}(s,t),s.callback=n,s.task=e,s.callback?o():o},r.waterfall=function(t,e){if(e=c(e||a),!f(t)){var n=new Error("First argument to waterfall must be an array of functions");return e(n)}if(!t.length)return e();!function t(n){return b((function(i,s){if(i)e.apply(null,[i].concat(s));else{var r=n.next();r?s.push(t(r)):s.push(e),U(n).apply(null,s)}}))}(r.iterator(t))()},r.parallel=function(t,e){L(r.eachOf,t,e)},r.parallelLimit=function(t,e,n){L(x(e),t,n)},r.series=function(t,e){L(r.eachOfSeries,t,e)},r.iterator=function(t){return function e(n){function i(){return t.length&&t[n].apply(null,arguments),i.next()}return i.next=function(){return n<t.length-1?e(n+1):null},i}(0)},r.apply=b((function(t,e){return b((function(n){return t.apply(null,e.concat(n))}))})),r.concat=R(F),r.concatSeries=A(F),r.whilst=function(t,e,n){if(n=n||a,t()){var i=b((function(s,r){s?n(s):t.apply(this,r)?e(i):n.apply(null,[null].concat(r))}));e(i)}else n(null)},r.doWhilst=function(t,e,n){var i=0;return r.whilst((function(){return++i<=1||e.apply(this,arguments)}),t,n)},r.until=function(t,e,n){return r.whilst((function(){return!t.apply(this,arguments)}),e,n)},r.doUntil=function(t,e,n){return r.doWhilst(t,(function(){return!e.apply(this,arguments)}),n)},r.during=function(t,e,n){n=n||a;var i=b((function(e,i){e?n(e):(i.push(s),t.apply(this,i))})),s=function(t,s){t?n(t):s?e(i):n(null)};t(s)},r.doDuring=function(t,e,n){var i=0;r.during((function(t){i++<1?t(null,!0):e.apply(this,arguments)}),t,n)},r.queue=function(t,e){return P((function(e,n){t(e[0],n)}),e,1)},r.priorityQueue=function(t,e){function n(t,e){return t.priority-e.priority}var i=r.queue(t,e);return i.push=function(t,e,s){!function(t,e,i,s){if(null!=s&&"function"!=typeof s)throw new Error("task callback must be a function");if(t.started=!0,f(e)||(e=[e]),0===e.length)return r.setImmediate((function(){t.drain()}));g(e,(function(e){var o={data:e,priority:i,callback:"function"==typeof s?s:a};t.tasks.splice(function(t,e,n){for(var i=-1,s=t.length-1;i<s;){var r=i+(s-i+1>>>1);n(e,t[r])>=0?i=r:s=r-1}return i}(t.tasks,o,n)+1,0,o),t.tasks.length===t.concurrency&&t.saturated(),r.setImmediate(t.process)}))}(i,t,e,s)},delete i.unshift,i},r.cargo=function(t,e){return P(t,1,e)},r.log=$("log"),r.dir=$("dir"),r.memoize=function(t,e){var n={},i={},s=Object.prototype.hasOwnProperty;e=e||o;var a=b((function(a){var o=a.pop(),l=e.apply(null,a);s.call(n,l)?r.setImmediate((function(){o.apply(null,n[l])})):s.call(i,l)?i[l].push(o):(i[l]=[o],t.apply(null,a.concat([b((function(t){n[l]=t;var e=i[l];delete i[l];for(var s=0,r=e.length;s<r;s++)e[s].apply(null,t)}))])))}));return a.memo=n,a.unmemoized=t,a},r.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},r.times=B(r.map),r.timesSeries=B(r.mapSeries),r.timesLimit=function(t,e,n,i){return r.mapLimit(T(t),e,n,i)},r.seq=function(){var t=arguments;return b((function(e){var n=this,i=e[e.length-1];"function"==typeof i?e.pop():i=a,r.reduce(t,e,(function(t,e,i){e.apply(n,t.concat([b((function(t,e){i(t,e)}))]))}),(function(t,e){i.apply(n,[t].concat(e))}))}))},r.compose=function(){return r.seq.apply(null,Array.prototype.reverse.call(arguments))},r.applyEach=V(r.eachOf),r.applyEachSeries=V(r.eachOfSeries),r.forever=function(t,e){var n=p(e||a),i=U(t);!function t(e){if(e)return n(e);i(t)}()},r.ensureAsync=U,r.constant=b((function(t){var e=[null].concat(t);return function(t){return t.apply(this,e)}})),r.wrapSync=r.asyncify=function(t){return b((function(e){var n,i,s,r=e.pop();try{n=t.apply(this,e)}catch(t){return r(t)}("function"===(s=typeof(i=n))||"object"===s&&i)&&"function"==typeof n.then?n.then((function(t){r(null,t)})).catch((function(t){r(t.message?t:new Error(t))})):r(null,n)}))},t.exports?t.exports=r:void 0===(i=function(){return r}.apply(e,[]))||(t.exports=i)}()},7526:(t,e)=>{"use strict";e.byteLength=function(t){var e=o(t),n=e[0],i=e[1];return 3*(n+i)/4-i},e.toByteArray=function(t){var e,n,r=o(t),a=r[0],l=r[1],u=new s(function(t,e,n){return 3*(e+n)/4-n}(0,a,l)),h=0,p=l>0?a-4:a;for(n=0;n<p;n+=4)e=i[t.charCodeAt(n)]<<18|i[t.charCodeAt(n+1)]<<12|i[t.charCodeAt(n+2)]<<6|i[t.charCodeAt(n+3)],u[h++]=e>>16&255,u[h++]=e>>8&255,u[h++]=255&e;2===l&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,u[h++]=255&e);1===l&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,u[h++]=e>>8&255,u[h++]=255&e);return u},e.fromByteArray=function(t){for(var e,i=t.length,s=i%3,r=[],a=16383,o=0,u=i-s;o<u;o+=a)r.push(l(t,o,o+a>u?u:o+a));1===s?(e=t[i-1],r.push(n[e>>2]+n[e<<4&63]+"==")):2===s&&(e=(t[i-2]<<8)+t[i-1],r.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return r.join("")};for(var n=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)n[a]=r[a],i[r.charCodeAt(a)]=a;function o(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function l(t,e,i){for(var s,r,a=[],o=e;o<i;o+=3)s=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),a.push(n[(r=s)>>18&63]+n[r>>12&63]+n[r>>6&63]+n[63&r]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},8287:(t,e,n)=>{"use strict";
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/const i=n(7526),s=n(251),r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=l,e.SlowBuffer=function(t){+t!=t&&(t=0);return l.alloc(+t)},e.INSPECT_MAX_BYTES=50;const a=2147483647;function o(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,l.prototype),e}function l(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return p(t)}return u(t,e,n)}function u(t,e,n){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|m(t,e);let i=o(n);const s=i.write(t,e);s!==n&&(i=i.slice(0,s));return i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(q(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer))return d(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return d(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return l.from(i,e,n);const s=function(t){if(l.isBuffer(t)){const e=0|f(t.length),n=o(e);return 0===n.length||t.copy(n,0,0,e),n}if(void 0!==t.length)return"number"!=typeof t.length||K(t.length)?o(0):c(t);if("Buffer"===t.type&&Array.isArray(t.data))return c(t.data)}(t);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return l.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function p(t){return h(t),o(t<0?0:0|f(t))}function c(t){const e=t.length<0?0:0|f(t.length),n=o(e);for(let i=0;i<e;i+=1)n[i]=255&t[i];return n}function d(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let i;return i=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(i,l.prototype),i}function f(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function m(t,e){if(l.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;let s=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return X(t).length;default:if(s)return i?-1:z(t).length;e=(""+e).toLowerCase(),s=!0}}function g(t,e,n){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,n);case"utf8":case"utf-8":return x(this,e,n);case"ascii":return O(this,e,n);case"latin1":case"binary":return A(this,e,n);case"base64":return S(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function _(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function T(t,e,n,i,s){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),K(n=+n)&&(n=s?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(s)return-1;n=t.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof e&&(e=l.from(e,i)),l.isBuffer(e))return 0===e.length?-1:y(t,e,n,i,s);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):y(t,[e],n,i,s);throw new TypeError("val must be string, number or Buffer")}function y(t,e,n,i,s){let r,a=1,o=t.length,l=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;a=2,o/=2,l/=2,n/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(s){let i=-1;for(r=n;r<o;r++)if(u(t,r)===u(e,-1===i?0:r-i)){if(-1===i&&(i=r),r-i+1===l)return i*a}else-1!==i&&(r-=r-i),i=-1}else for(n+l>o&&(n=o-l),r=n;r>=0;r--){let n=!0;for(let i=0;i<l;i++)if(u(t,r+i)!==u(e,i)){n=!1;break}if(n)return r}return-1}function I(t,e,n,i){n=Number(n)||0;const s=t.length-n;i?(i=Number(i))>s&&(i=s):i=s;const r=e.length;let a;for(i>r/2&&(i=r/2),a=0;a<i;++a){const i=parseInt(e.substr(2*a,2),16);if(K(i))return a;t[n+a]=i}return a}function E(t,e,n,i){return j(z(e,t.length-n),t,n,i)}function b(t,e,n,i){return j(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,i)}function v(t,e,n,i){return j(X(e),t,n,i)}function w(t,e,n,i){return j(function(t,e){let n,i,s;const r=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)n=t.charCodeAt(a),i=n>>8,s=n%256,r.push(s),r.push(i);return r}(e,t.length-n),t,n,i)}function S(t,e,n){return 0===e&&n===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,n))}function x(t,e,n){n=Math.min(t.length,n);const i=[];let s=e;for(;s<n;){const e=t[s];let r=null,a=e>239?4:e>223?3:e>191?2:1;if(s+a<=n){let n,i,o,l;switch(a){case 1:e<128&&(r=e);break;case 2:n=t[s+1],128==(192&n)&&(l=(31&e)<<6|63&n,l>127&&(r=l));break;case 3:n=t[s+1],i=t[s+2],128==(192&n)&&128==(192&i)&&(l=(15&e)<<12|(63&n)<<6|63&i,l>2047&&(l<55296||l>57343)&&(r=l));break;case 4:n=t[s+1],i=t[s+2],o=t[s+3],128==(192&n)&&128==(192&i)&&128==(192&o)&&(l=(15&e)<<18|(63&n)<<12|(63&i)<<6|63&o,l>65535&&l<1114112&&(r=l))}}null===r?(r=65533,a=1):r>65535&&(r-=65536,i.push(r>>>10&1023|55296),r=56320|1023&r),i.push(r),s+=a}return function(t){const e=t.length;if(e<=R)return String.fromCharCode.apply(String,t);let n="",i=0;for(;i<e;)n+=String.fromCharCode.apply(String,t.slice(i,i+=R));return n}(i)}e.kMaxLength=a,l.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),l.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),l.poolSize=8192,l.from=function(t,e,n){return u(t,e,n)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array),l.alloc=function(t,e,n){return function(t,e,n){return h(t),t<=0?o(t):void 0!==e?"string"==typeof n?o(t).fill(e,n):o(t).fill(e):o(t)}(t,e,n)},l.allocUnsafe=function(t){return p(t)},l.allocUnsafeSlow=function(t){return p(t)},l.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==l.prototype},l.compare=function(t,e){if(q(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),q(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(t)||!l.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,i=e.length;for(let s=0,r=Math.min(n,i);s<r;++s)if(t[s]!==e[s]){n=t[s],i=e[s];break}return n<i?-1:i<n?1:0},l.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},l.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return l.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const i=l.allocUnsafe(e);let s=0;for(n=0;n<t.length;++n){let e=t[n];if(q(e,Uint8Array))s+e.length>i.length?(l.isBuffer(e)||(e=l.from(e)),e.copy(i,s)):Uint8Array.prototype.set.call(i,e,s);else{if(!l.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,s)}s+=e.length}return i},l.byteLength=m,l.prototype._isBuffer=!0,l.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)_(this,e,e+1);return this},l.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)_(this,e,e+3),_(this,e+1,e+2);return this},l.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)_(this,e,e+7),_(this,e+1,e+6),_(this,e+2,e+5),_(this,e+3,e+4);return this},l.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?x(this,0,t):g.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(t){if(!l.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===l.compare(this,t)},l.prototype.inspect=function(){let t="";const n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},r&&(l.prototype[r]=l.prototype.inspect),l.prototype.compare=function(t,e,n,i,s){if(q(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),e<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&e>=n)return 0;if(i>=s)return-1;if(e>=n)return 1;if(this===t)return 0;let r=(s>>>=0)-(i>>>=0),a=(n>>>=0)-(e>>>=0);const o=Math.min(r,a),u=this.slice(i,s),h=t.slice(e,n);for(let t=0;t<o;++t)if(u[t]!==h[t]){r=u[t],a=h[t];break}return r<a?-1:a<r?1:0},l.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},l.prototype.indexOf=function(t,e,n){return T(this,t,e,n,!0)},l.prototype.lastIndexOf=function(t,e,n){return T(this,t,e,n,!1)},l.prototype.write=function(t,e,n,i){if(void 0===e)i="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)i=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}const s=this.length-e;if((void 0===n||n>s)&&(n=s),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let r=!1;for(;;)switch(i){case"hex":return I(this,t,e,n);case"utf8":case"utf-8":return E(this,t,e,n);case"ascii":case"latin1":case"binary":return b(this,t,e,n);case"base64":return v(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,n);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),r=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const R=4096;function O(t,e,n){let i="";n=Math.min(t.length,n);for(let s=e;s<n;++s)i+=String.fromCharCode(127&t[s]);return i}function A(t,e,n){let i="";n=Math.min(t.length,n);for(let s=e;s<n;++s)i+=String.fromCharCode(t[s]);return i}function M(t,e,n){const i=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>i)&&(n=i);let s="";for(let i=e;i<n;++i)s+=Q[t[i]];return s}function C(t,e,n){const i=t.slice(e,n);let s="";for(let t=0;t<i.length-1;t+=2)s+=String.fromCharCode(i[t]+256*i[t+1]);return s}function N(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function k(t,e,n,i,s,r){if(!l.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||e<r)throw new RangeError('"value" argument is out of bounds');if(n+i>t.length)throw new RangeError("Index out of range")}function D(t,e,n,i,s){Y(e,i,s,t,n,7);let r=Number(e&BigInt(4294967295));t[n++]=r,r>>=8,t[n++]=r,r>>=8,t[n++]=r,r>>=8,t[n++]=r;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=a,a>>=8,t[n++]=a,a>>=8,t[n++]=a,a>>=8,t[n++]=a,n}function L(t,e,n,i,s){Y(e,i,s,t,n,7);let r=Number(e&BigInt(4294967295));t[n+7]=r,r>>=8,t[n+6]=r,r>>=8,t[n+5]=r,r>>=8,t[n+4]=r;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=a,a>>=8,t[n+2]=a,a>>=8,t[n+1]=a,a>>=8,t[n]=a,n+8}function F(t,e,n,i,s,r){if(n+i>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function P(t,e,n,i,r){return e=+e,n>>>=0,r||F(t,0,n,4),s.write(t,e,n,i,23,4),n+4}function $(t,e,n,i,r){return e=+e,n>>>=0,r||F(t,0,n,8),s.write(t,e,n,i,52,8),n+8}l.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const i=this.subarray(t,e);return Object.setPrototypeOf(i,l.prototype),i},l.prototype.readUintLE=l.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||N(t,e,this.length);let i=this[t],s=1,r=0;for(;++r<e&&(s*=256);)i+=this[t+r]*s;return i},l.prototype.readUintBE=l.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||N(t,e,this.length);let i=this[t+--e],s=1;for(;e>0&&(s*=256);)i+=this[t+--e]*s;return i},l.prototype.readUint8=l.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readBigUInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,s=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))})),l.prototype.readBigUInt64BE=J((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],s=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(i)<<BigInt(32))+BigInt(s)})),l.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||N(t,e,this.length);let i=this[t],s=1,r=0;for(;++r<e&&(s*=256);)i+=this[t+r]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*e)),i},l.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||N(t,e,this.length);let i=e,s=1,r=this[t+--i];for(;i>0&&(s*=256);)r+=this[t+--i]*s;return s*=128,r>=s&&(r-=Math.pow(2,8*e)),r},l.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readBigInt64LE=J((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),l.prototype.readBigInt64BE=J((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)})),l.prototype.readFloatLE=function(t,e){return t>>>=0,e||N(t,4,this.length),s.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),s.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),s.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),s.read(this,t,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e>>>=0,n>>>=0,!i){k(this,t,e,n,Math.pow(2,8*n)-1,0)}let s=1,r=0;for(this[e]=255&t;++r<n&&(s*=256);)this[e+r]=t/s&255;return e+n},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e>>>=0,n>>>=0,!i){k(this,t,e,n,Math.pow(2,8*n)-1,0)}let s=n-1,r=1;for(this[e+s]=255&t;--s>=0&&(r*=256);)this[e+s]=t/r&255;return e+n},l.prototype.writeUint8=l.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,1,255,0),this[e]=255&t,e+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeBigUInt64LE=J((function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeBigUInt64BE=J((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);k(this,t,e,n,i-1,-i)}let s=0,r=1,a=0;for(this[e]=255&t;++s<n&&(r*=256);)t<0&&0===a&&0!==this[e+s-1]&&(a=1),this[e+s]=(t/r|0)-a&255;return e+n},l.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);k(this,t,e,n,i-1,-i)}let s=n-1,r=1,a=0;for(this[e+s]=255&t;--s>=0&&(r*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/r|0)-a&255;return e+n},l.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},l.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},l.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||k(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeBigInt64LE=J((function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeBigInt64BE=J((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeFloatLE=function(t,e,n){return P(this,t,e,!0,n)},l.prototype.writeFloatBE=function(t,e,n){return P(this,t,e,!1,n)},l.prototype.writeDoubleLE=function(t,e,n){return $(this,t,e,!0,n)},l.prototype.writeDoubleBE=function(t,e,n){return $(this,t,e,!1,n)},l.prototype.copy=function(t,e,n,i){if(!l.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);const s=i-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),s},l.prototype.fill=function(t,e,n,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!l.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){const e=t.charCodeAt(0);("utf8"===i&&e<128||"latin1"===i)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let s;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=e;s<n;++s)this[s]=t;else{const r=l.isBuffer(t)?t:l.from(t,i),a=r.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<n-e;++s)this[s+e]=r[s%a]}return this};const B={};function V(t,e,n){B[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function U(t){let e="",n=t.length;const i="-"===t[0]?1:0;for(;n>=i+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function Y(t,e,n,i,s,r){if(t>n||t<e){const i="bigint"==typeof e?"n":"";let s;throw s=r>3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(r+1)}${i}`:`>= -(2${i} ** ${8*(r+1)-1}${i}) and < 2 ** ${8*(r+1)-1}${i}`:`>= ${e}${i} and <= ${n}${i}`,new B.ERR_OUT_OF_RANGE("value",s,t)}!function(t,e,n){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||H(e,t.length-(n+1))}(i,s,r)}function G(t,e){if("number"!=typeof t)throw new B.ERR_INVALID_ARG_TYPE(e,"number",t)}function H(t,e,n){if(Math.floor(t)!==t)throw G(t,n),new B.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new B.ERR_BUFFER_OUT_OF_BOUNDS;throw new B.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}V("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),V("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),V("ERR_OUT_OF_RANGE",(function(t,e,n){let i=`The value of "${t}" is out of range.`,s=n;return Number.isInteger(n)&&Math.abs(n)>2**32?s=U(String(n)):"bigint"==typeof n&&(s=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(s=U(s)),s+="n"),i+=` It must be ${e}. Received ${s}`,i}),RangeError);const W=/[^+/0-9A-Za-z-_]/g;function z(t,e){let n;e=e||1/0;const i=t.length;let s=null;const r=[];for(let a=0;a<i;++a){if(n=t.charCodeAt(a),n>55295&&n<57344){if(!s){if(n>56319){(e-=3)>-1&&r.push(239,191,189);continue}if(a+1===i){(e-=3)>-1&&r.push(239,191,189);continue}s=n;continue}if(n<56320){(e-=3)>-1&&r.push(239,191,189),s=n;continue}n=65536+(s-55296<<10|n-56320)}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,n<128){if((e-=1)<0)break;r.push(n)}else if(n<2048){if((e-=2)<0)break;r.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;r.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;r.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return r}function X(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(W,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function j(t,e,n,i){let s;for(s=0;s<i&&!(s+n>=e.length||s>=t.length);++s)e[s+n]=t[s];return s}function q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function K(t){return t!=t}const Q=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const i=16*n;for(let s=0;s<16;++s)e[i+s]=t[n]+t[s]}return e}();function J(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},6570:t=>{"use strict";function e(t,e,i){i=i||2;var r,a,o,l,p,c,f,m=e&&e.length,g=m?e[0]*i:t.length,_=n(t,0,g,i,!0),T=[];if(!_||_.next===_.prev)return T;if(m&&(_=function(t,e,i,s){var r,a,o,l=[];for(r=0,a=e.length;r<a;r++)(o=n(t,e[r]*s,r<a-1?e[r+1]*s:t.length,s,!1))===o.next&&(o.steiner=!0),l.push(d(o));for(l.sort(u),r=0;r<l.length;r++)i=h(l[r],i);return i}(t,e,_,i)),t.length>80*i){r=o=t[0],a=l=t[1];for(var y=i;y<g;y+=i)(p=t[y])<r&&(r=p),(c=t[y+1])<a&&(a=c),p>o&&(o=p),c>l&&(l=c);f=0!==(f=Math.max(o-r,l-a))?32767/f:0}return s(_,T,i,r,a,f,0),T}function n(t,e,n,i,s){var r,a;if(s===x(t,e,n,i)>0)for(r=e;r<n;r+=i)a=v(r,t[r],t[r+1],a);else for(r=n-i;r>=e;r-=i)a=v(r,t[r],t[r+1],a);return a&&_(a,a.next)&&(w(a),a=a.next),a}function i(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!_(i,i.next)&&0!==g(i.prev,i,i.next))i=i.next;else{if(w(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function s(t,e,n,u,h,p,d){if(t){!d&&p&&function(t,e,n,i){var s=t;do{0===s.z&&(s.z=c(s.x,s.y,e,n,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,n,i,s,r,a,o,l,u=1;do{for(n=t,t=null,r=null,a=0;n;){for(a++,i=n,o=0,e=0;e<u&&(o++,i=i.nextZ);e++);for(l=u;o>0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(s=n,n=n.nextZ,o--):(s=i,i=i.nextZ,l--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;n=i}r.nextZ=null,u*=2}while(a>1)}(s)}(t,u,h,p);for(var f,m,g=t;t.prev!==t.next;)if(f=t.prev,m=t.next,p?a(t,u,h,p):r(t))e.push(f.i/n|0),e.push(t.i/n|0),e.push(m.i/n|0),w(t),t=m.next,g=m.next;else if((t=m)===g){d?1===d?s(t=o(i(t),e,n),e,n,u,h,p,2):2===d&&l(t,e,n,u,h,p):s(i(t),e,n,u,h,p,1);break}}}function r(t){var e=t.prev,n=t,i=t.next;if(g(e,n,i)>=0)return!1;for(var s=e.x,r=n.x,a=i.x,o=e.y,l=n.y,u=i.y,h=s<r?s<a?s:a:r<a?r:a,p=o<l?o<u?o:u:l<u?l:u,c=s>r?s>a?s:a:r>a?r:a,d=o>l?o>u?o:u:l>u?l:u,m=i.next;m!==e;){if(m.x>=h&&m.x<=c&&m.y>=p&&m.y<=d&&f(s,o,r,l,a,u,m.x,m.y)&&g(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function a(t,e,n,i){var s=t.prev,r=t,a=t.next;if(g(s,r,a)>=0)return!1;for(var o=s.x,l=r.x,u=a.x,h=s.y,p=r.y,d=a.y,m=o<l?o<u?o:u:l<u?l:u,_=h<p?h<d?h:d:p<d?p:d,T=o>l?o>u?o:u:l>u?l:u,y=h>p?h>d?h:d:p>d?p:d,I=c(m,_,e,n,i),E=c(T,y,e,n,i),b=t.prevZ,v=t.nextZ;b&&b.z>=I&&v&&v.z<=E;){if(b.x>=m&&b.x<=T&&b.y>=_&&b.y<=y&&b!==s&&b!==a&&f(o,h,l,p,u,d,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,v.x>=m&&v.x<=T&&v.y>=_&&v.y<=y&&v!==s&&v!==a&&f(o,h,l,p,u,d,v.x,v.y)&&g(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;b&&b.z>=I;){if(b.x>=m&&b.x<=T&&b.y>=_&&b.y<=y&&b!==s&&b!==a&&f(o,h,l,p,u,d,b.x,b.y)&&g(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=E;){if(v.x>=m&&v.x<=T&&v.y>=_&&v.y<=y&&v!==s&&v!==a&&f(o,h,l,p,u,d,v.x,v.y)&&g(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function o(t,e,n){var s=t;do{var r=s.prev,a=s.next.next;!_(r,a)&&T(r,s,s.next,a)&&E(r,a)&&E(a,r)&&(e.push(r.i/n|0),e.push(s.i/n|0),e.push(a.i/n|0),w(s),w(s.next),s=t=a),s=s.next}while(s!==t);return i(s)}function l(t,e,n,r,a,o){var l=t;do{for(var u=l.next.next;u!==l.prev;){if(l.i!==u.i&&m(l,u)){var h=b(l,u);return l=i(l,l.next),h=i(h,h.next),s(l,e,n,r,a,o,0),void s(h,e,n,r,a,o,0)}u=u.next}l=l.next}while(l!==t)}function u(t,e){return t.x-e.x}function h(t,e){var n=function(t,e){var n,i=e,s=t.x,r=t.y,a=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){var o=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(o<=s&&o>a&&(a=o,n=i.x<i.next.x?i:i.next,o===s))return n}i=i.next}while(i!==e);if(!n)return null;var l,u=n,h=n.x,c=n.y,d=1/0;i=n;do{s>=i.x&&i.x>=h&&s!==i.x&&f(r<c?s:a,r,h,c,r<c?a:s,r,i.x,i.y)&&(l=Math.abs(r-i.y)/(s-i.x),E(i,t)&&(l<d||l===d&&(i.x>n.x||i.x===n.x&&p(n,i)))&&(n=i,d=l)),i=i.next}while(i!==u);return n}(t,e);if(!n)return e;var s=b(n,t);return i(s,s.next),i(n,n.next)}function p(t,e){return g(t.prev,t,e.prev)<0&&g(e.next,t,t.next)<0}function c(t,e,n,i,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function d(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function f(t,e,n,i,s,r,a,o){return(s-a)*(e-o)>=(t-a)*(r-o)&&(t-a)*(i-o)>=(n-a)*(e-o)&&(n-a)*(r-o)>=(s-a)*(i-o)}function m(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&T(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(E(t,e)&&E(e,t)&&function(t,e){var n=t,i=!1,s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{n.y>r!=n.next.y>r&&n.next.y!==n.y&&s<(n.next.x-n.x)*(r-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(g(t.prev,t,e.prev)||g(t,e.prev,e))||_(t,e)&&g(t.prev,t,t.next)>0&&g(e.prev,e,e.next)>0)}function g(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function _(t,e){return t.x===e.x&&t.y===e.y}function T(t,e,n,i){var s=I(g(t,e,n)),r=I(g(t,e,i)),a=I(g(n,i,t)),o=I(g(n,i,e));return s!==r&&a!==o||(!(0!==s||!y(t,n,e))||(!(0!==r||!y(t,i,e))||(!(0!==a||!y(n,t,i))||!(0!==o||!y(n,e,i)))))}function y(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function I(t){return t>0?1:t<0?-1:0}function E(t,e){return g(t.prev,t,t.next)<0?g(t,e,t.next)>=0&&g(t,t.prev,e)>=0:g(t,e,t.prev)<0||g(t,t.next,e)<0}function b(t,e){var n=new S(t.i,t.x,t.y),i=new S(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,n.next=s,s.prev=n,i.next=n,n.prev=i,r.next=i,i.prev=r,i}function v(t,e,n,i){var s=new S(t,e,n);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function w(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function S(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function x(t,e,n,i){for(var s=0,r=e,a=n-i;r<n;r+=i)s+=(t[a]-t[r])*(t[r+1]+t[a+1]),a=r;return s}t.exports=e,t.exports.default=e,e.deviation=function(t,e,n,i){var s=e&&e.length,r=s?e[0]*n:t.length,a=Math.abs(x(t,0,r,n));if(s)for(var o=0,l=e.length;o<l;o++){var u=e[o]*n,h=o<l-1?e[o+1]*n:t.length;a-=Math.abs(x(t,u,h,n))}var p=0;for(o=0;o<i.length;o+=3){var c=i[o]*n,d=i[o+1]*n,f=i[o+2]*n;p+=Math.abs((t[c]-t[f])*(t[d+1]-t[c+1])-(t[c]-t[d])*(t[f+1]-t[c+1]))}return 0===a&&0===p?0:Math.abs((p-a)/a)},e.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,s=0;s<t.length;s++){for(var r=0;r<t[s].length;r++)for(var a=0;a<e;a++)n.vertices.push(t[s][r][a]);s>0&&(i+=t[s-1].length,n.holes.push(i))}return n}},228:t=>{"use strict";var e=Object.prototype.hasOwnProperty,n="~";function i(){}function s(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function r(t,e,i,r,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new s(i,r||t,a),l=n?n+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),o.prototype.eventNames=function(){var t,i,s=[];if(0===this._eventsCount)return s;for(i in t=this._events)e.call(t,i)&&s.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(t)):s},o.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,r=i.length,a=new Array(r);s<r;s++)a[s]=i[s].fn;return a},o.prototype.listenerCount=function(t){var e=n?n+t:t,i=this._events[e];return i?i.fn?1:i.length:0},o.prototype.emit=function(t,e,i,s,r,a){var o=n?n+t:t;if(!this._events[o])return!1;var l,u,h=this._events[o],p=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),p){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,i),!0;case 4:return h.fn.call(h.context,e,i,s),!0;case 5:return h.fn.call(h.context,e,i,s,r),!0;case 6:return h.fn.call(h.context,e,i,s,r,a),!0}for(u=1,l=new Array(p-1);u<p;u++)l[u-1]=arguments[u];h.fn.apply(h.context,l)}else{var c,d=h.length;for(u=0;u<d;u++)switch(h[u].once&&this.removeListener(t,h[u].fn,void 0,!0),p){case 1:h[u].fn.call(h[u].context);break;case 2:h[u].fn.call(h[u].context,e);break;case 3:h[u].fn.call(h[u].context,e,i);break;case 4:h[u].fn.call(h[u].context,e,i,s);break;default:if(!l)for(c=1,l=new Array(p-1);c<p;c++)l[c-1]=arguments[c];h[u].fn.apply(h[u].context,l)}}return!0},o.prototype.on=function(t,e,n){return r(this,t,e,n,!1)},o.prototype.once=function(t,e,n){return r(this,t,e,n,!0)},o.prototype.removeListener=function(t,e,i,s){var r=n?n+t:t;if(!this._events[r])return this;if(!e)return a(this,r),this;var o=this._events[r];if(o.fn)o.fn!==e||s&&!o.once||i&&o.context!==i||a(this,r);else{for(var l=0,u=[],h=o.length;l<h;l++)(o[l].fn!==e||s&&!o[l].once||i&&o[l].context!==i)&&u.push(o[l]);u.length?this._events[r]=1===u.length?u[0]:u:a(this,r)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&a(this,e)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o},7007:t=>{"use strict";var e,n="object"==typeof Reflect?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};e=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var s=Number.isNaN||function(t){return t!=t};function r(){r.init.call(this)}t.exports=r,t.exports.once=function(t,e){return new Promise((function(n,i){function s(n){t.removeListener(e,r),i(n)}function r(){"function"==typeof t.removeListener&&t.removeListener("error",s),n([].slice.call(arguments))}m(t,e,r,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&m(t,"error",e,n)}(t,s,{once:!0})}))},r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var a=10;function o(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?r.defaultMaxListeners:t._maxListeners}function u(t,e,n,i){var s,r,a,u;if(o(n),void 0===(r=t._events)?(r=t._events=Object.create(null),t._eventsCount=0):(void 0!==r.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),r=t._events),a=r[e]),void 0===a)a=r[e]=n,++t._eventsCount;else if("function"==typeof a?a=r[e]=i?[n,a]:[a,n]:i?a.unshift(n):a.push(n),(s=l(t))>0&&a.length>s&&!a.warned){a.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=a.length,u=h,console&&console.warn&&console.warn(u)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},s=h.bind(i);return s.listener=n,i.wrapFn=s,s}function c(t,e,n){var i=t._events;if(void 0===i)return[];var s=i[e];return void 0===s?[]:"function"==typeof s?n?[s.listener||s]:[s]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(s):f(s,s.length)}function d(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function f(t,e){for(var n=new Array(e),i=0;i<e;++i)n[i]=t[i];return n}function m(t,e,n,i){if("function"==typeof t.on)i.once?t.once(e,n):t.on(e,n);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function s(r){i.once&&t.removeEventListener(e,s),n(r)}))}}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),r.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},r.prototype.getMaxListeners=function(){return l(this)},r.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var s="error"===t,r=this._events;if(void 0!==r)s=s&&void 0===r.error;else if(!s)return!1;if(s){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var l=r[t];if(void 0===l)return!1;if("function"==typeof l)i(l,this,e);else{var u=l.length,h=f(l,u);for(n=0;n<u;++n)i(h[n],this,e)}return!0},r.prototype.addListener=function(t,e){return u(this,t,e,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(t,e){return u(this,t,e,!0)},r.prototype.once=function(t,e){return o(e),this.on(t,p(this,t,e)),this},r.prototype.prependOnceListener=function(t,e){return o(e),this.prependListener(t,p(this,t,e)),this},r.prototype.removeListener=function(t,e){var n,i,s,r,a;if(o(e),void 0===(i=this._events))return this;if(void 0===(n=i[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(s=-1,r=n.length-1;r>=0;r--)if(n[r]===e||n[r].listener===e){a=n[r].listener,s=r;break}if(s<0)return this;0===s?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,s),1===n.length&&(i[t]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",t,a||e)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(t){var e,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var s,r=Object.keys(n);for(i=0;i<r.length;++i)"removeListener"!==(s=r[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);return this},r.prototype.listeners=function(t){return c(this,t,!0)},r.prototype.rawListeners=function(t){return c(this,t,!1)},r.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},r.prototype.listenerCount=d,r.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},251:(t,e)=>{
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
e.read=function(t,e,n,i,s){var r,a,o=8*s-i-1,l=(1<<o)-1,u=l>>1,h=-7,p=n?s-1:0,c=n?-1:1,d=t[e+p];for(p+=c,r=d&(1<<-h)-1,d>>=-h,h+=o;h>0;r=256*r+t[e+p],p+=c,h-=8);for(a=r&(1<<-h)-1,r>>=-h,h+=i;h>0;a=256*a+t[e+p],p+=c,h-=8);if(0===r)r=1-u;else{if(r===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,i),r-=u}return(d?-1:1)*a*Math.pow(2,r-i)},e.write=function(t,e,n,i,s,r){var a,o,l,u=8*r-s-1,h=(1<<u)-1,p=h>>1,c=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:r-1,f=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+p>=1?c/l:c*Math.pow(2,1-p))*l>=2&&(a++,l/=2),a+p>=h?(o=0,a=h):a+p>=1?(o=(e*l-1)*Math.pow(2,s),a+=p):(o=e*Math.pow(2,p-1)*Math.pow(2,s),a=0));s>=8;t[n+d]=255&o,d+=f,o/=256,s-=8);for(a=a<<s|o,u+=s;u>0;t[n+d]=255&a,d+=f,a/=256,u-=8);t[n+d-f]|=128*m}},8570:t=>{t.exports=n;var e=null;try{e=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(t){}function n(t,e,n){this.low=0|t,this.high=0|e,this.unsigned=!!n}function i(t){return!0===(t&&t.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=i;var s={},r={};function a(t,e){var n,i,a;return e?(a=0<=(t>>>=0)&&t<256)&&(i=r[t])?i:(n=l(t,(0|t)<0?-1:0,!0),a&&(r[t]=n),n):(a=-128<=(t|=0)&&t<128)&&(i=s[t])?i:(n=l(t,t<0?-1:0,!1),a&&(s[t]=n),n)}function o(t,e){if(isNaN(t))return e?_:g;if(e){if(t<0)return _;if(t>=d)return b}else{if(t<=-f)return v;if(t+1>=f)return E}return t<0?o(-t,e).neg():l(t%c|0,t/c|0,e)}function l(t,e,i){return new n(t,e,i)}n.fromInt=a,n.fromNumber=o,n.fromBits=l;var u=Math.pow;function h(t,e,n){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return g;if("number"==typeof e?(n=e,e=!1):e=!!e,(n=n||10)<2||36<n)throw RangeError("radix");var i;if((i=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return h(t.substring(1),e,n).neg();for(var s=o(u(n,8)),r=g,a=0;a<t.length;a+=8){var l=Math.min(8,t.length-a),p=parseInt(t.substring(a,a+l),n);if(l<8){var c=o(u(n,l));r=r.mul(c).add(o(p))}else r=(r=r.mul(s)).add(o(p))}return r.unsigned=e,r}function p(t,e){return"number"==typeof t?o(t,e):"string"==typeof t?h(t,e):l(t.low,t.high,"boolean"==typeof e?e:t.unsigned)}n.fromString=h,n.fromValue=p;var c=4294967296,d=c*c,f=d/2,m=a(1<<24),g=a(0);n.ZERO=g;var _=a(0,!0);n.UZERO=_;var T=a(1);n.ONE=T;var y=a(1,!0);n.UONE=y;var I=a(-1);n.NEG_ONE=I;var E=l(-1,2147483647,!1);n.MAX_VALUE=E;var b=l(-1,-1,!0);n.MAX_UNSIGNED_VALUE=b;var v=l(0,-2147483648,!1);n.MIN_VALUE=v;var w=n.prototype;w.toInt=function(){return this.unsigned?this.low>>>0:this.low},w.toNumber=function(){return this.unsigned?(this.high>>>0)*c+(this.low>>>0):this.high*c+(this.low>>>0)},w.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(v)){var e=o(t),n=this.div(e),i=n.mul(e).sub(this);return n.toString(t)+i.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var s=o(u(t,6),this.unsigned),r=this,a="";;){var l=r.div(s),h=(r.sub(l.mul(s)).toInt()>>>0).toString(t);if((r=l).isZero())return h+a;for(;h.length<6;)h="0"+h;a=""+h+a}},w.getHighBits=function(){return this.high},w.getHighBitsUnsigned=function(){return this.high>>>0},w.getLowBits=function(){return this.low},w.getLowBitsUnsigned=function(){return this.low>>>0},w.getNumBitsAbs=function(){if(this.isNegative())return this.eq(v)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&!(t&1<<e);e--);return 0!=this.high?e+33:e+1},w.isZero=function(){return 0===this.high&&0===this.low},w.eqz=w.isZero,w.isNegative=function(){return!this.unsigned&&this.high<0},w.isPositive=function(){return this.unsigned||this.high>=0},w.isOdd=function(){return!(1&~this.low)},w.isEven=function(){return!(1&this.low)},w.equals=function(t){return i(t)||(t=p(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},w.eq=w.equals,w.notEquals=function(t){return!this.eq(t)},w.neq=w.notEquals,w.ne=w.notEquals,w.lessThan=function(t){return this.comp(t)<0},w.lt=w.lessThan,w.lessThanOrEqual=function(t){return this.comp(t)<=0},w.lte=w.lessThanOrEqual,w.le=w.lessThanOrEqual,w.greaterThan=function(t){return this.comp(t)>0},w.gt=w.greaterThan,w.greaterThanOrEqual=function(t){return this.comp(t)>=0},w.gte=w.greaterThanOrEqual,w.ge=w.greaterThanOrEqual,w.compare=function(t){if(i(t)||(t=p(t)),this.eq(t))return 0;var e=this.isNegative(),n=t.isNegative();return e&&!n?-1:!e&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},w.comp=w.compare,w.negate=function(){return!this.unsigned&&this.eq(v)?v:this.not().add(T)},w.neg=w.negate,w.add=function(t){i(t)||(t=p(t));var e=this.high>>>16,n=65535&this.high,s=this.low>>>16,r=65535&this.low,a=t.high>>>16,o=65535&t.high,u=t.low>>>16,h=0,c=0,d=0,f=0;return d+=(f+=r+(65535&t.low))>>>16,c+=(d+=s+u)>>>16,h+=(c+=n+o)>>>16,h+=e+a,l((d&=65535)<<16|(f&=65535),(h&=65535)<<16|(c&=65535),this.unsigned)},w.subtract=function(t){return i(t)||(t=p(t)),this.add(t.neg())},w.sub=w.subtract,w.multiply=function(t){if(this.isZero())return g;if(i(t)||(t=p(t)),e)return l(e.mul(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned);if(t.isZero())return g;if(this.eq(v))return t.isOdd()?v:g;if(t.eq(v))return this.isOdd()?v:g;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(m)&&t.lt(m))return o(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,s=65535&this.high,r=this.low>>>16,a=65535&this.low,u=t.high>>>16,h=65535&t.high,c=t.low>>>16,d=65535&t.low,f=0,_=0,T=0,y=0;return T+=(y+=a*d)>>>16,_+=(T+=r*d)>>>16,T&=65535,_+=(T+=a*c)>>>16,f+=(_+=s*d)>>>16,_&=65535,f+=(_+=r*c)>>>16,_&=65535,f+=(_+=a*h)>>>16,f+=n*d+s*c+r*h+a*u,l((T&=65535)<<16|(y&=65535),(f&=65535)<<16|(_&=65535),this.unsigned)},w.mul=w.multiply,w.divide=function(t){if(i(t)||(t=p(t)),t.isZero())throw Error("division by zero");var n,s,r;if(e)return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?l((this.unsigned?e.div_u:e.div_s)(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?_:g;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return _;if(t.gt(this.shru(1)))return y;r=_}else{if(this.eq(v))return t.eq(T)||t.eq(I)?v:t.eq(v)?T:(n=this.shr(1).div(t).shl(1)).eq(g)?t.isNegative()?T:I:(s=this.sub(t.mul(n)),r=n.add(s.div(t)));if(t.eq(v))return this.unsigned?_:g;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();r=g}for(s=this;s.gte(t);){n=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),h=a<=48?1:u(2,a-48),c=o(n),d=c.mul(t);d.isNegative()||d.gt(s);)d=(c=o(n-=h,this.unsigned)).mul(t);c.isZero()&&(c=T),r=r.add(c),s=s.sub(d)}return r},w.div=w.divide,w.modulo=function(t){return i(t)||(t=p(t)),e?l((this.unsigned?e.rem_u:e.rem_s)(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},w.mod=w.modulo,w.rem=w.modulo,w.not=function(){return l(~this.low,~this.high,this.unsigned)},w.and=function(t){return i(t)||(t=p(t)),l(this.low&t.low,this.high&t.high,this.unsigned)},w.or=function(t){return i(t)||(t=p(t)),l(this.low|t.low,this.high|t.high,this.unsigned)},w.xor=function(t){return i(t)||(t=p(t)),l(this.low^t.low,this.high^t.high,this.unsigned)},w.shiftLeft=function(t){return i(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?l(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):l(0,this.low<<t-32,this.unsigned)},w.shl=w.shiftLeft,w.shiftRight=function(t){return i(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?l(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):l(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},w.shr=w.shiftRight,w.shiftRightUnsigned=function(t){if(i(t)&&(t=t.toInt()),0===(t&=63))return this;var e=this.high;return t<32?l(this.low>>>t|e<<32-t,e>>>t,this.unsigned):l(32===t?e:e>>>t-32,0,this.unsigned)},w.shru=w.shiftRightUnsigned,w.shr_u=w.shiftRightUnsigned,w.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},w.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},w.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},w.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},w.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},n.fromBytes=function(t,e,i){return i?n.fromBytesLE(t,e):n.fromBytesBE(t,e)},n.fromBytesLE=function(t,e){return new n(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)},n.fromBytesBE=function(t,e){return new n(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)}},5228:t=>{"use strict";
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/var e=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach((function(t){i[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(t){return!1}}()?Object.assign:function(t,s){for(var r,a,o=function(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),l=1;l<arguments.length;l++){for(var u in r=Object(arguments[l]))n.call(r,u)&&(o[u]=r[u]);if(e){a=e(r);for(var h=0;h<a.length;h++)i.call(r,a[h])&&(o[a[h]]=r[a[h]])}}return o}},4678:t=>{"use strict";t.exports=(t,e={})=>{if(!t)return;const n={key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/,loose:/^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?:\/\/)?([^/?#]*)([^?#]*)(?:\?([^#]*))?(?:#(.*))?/}},i=(e.strictMode?n.parser.strict:n.parser.loose).exec(t);if(!i)return;const s={};if(s[n.key[0]]=t,s[n.key[1]]=i[1]||"",s[n.key[2]]=i[2]||"",s[n.key[8]]=i[3]||"",s[n.key[12]]=i[4]||"",s[n.key[13]]=i[5]||"",s[n.key[2]]){const t=/^(?:(([^:@]*)(?::([^:@]*))?)?@)?([^:/?#]*)(?::(\d*))?/.exec(s[n.key[2]]);t&&(s[n.key[3]]=t[1]||"",s[n.key[4]]=t[2]||"",s[n.key[5]]=t[3]||"",s[n.key[6]]=t[4]||"",s[n.key[7]]=t[5]||"")}return s[n.q.name]={},s[n.key[12]].replace(n.q.parser,(function(t,e,i){e&&(s[n.q.name][e]=i)})),s}},5585:t=>{"use strict";var e=Object.prototype.hasOwnProperty,n="function"!=typeof Object.create&&"~";function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(){}s.prototype._events=void 0,s.prototype.eventNames=function(){var t,i=this._events,s=[];if(!i)return s;for(t in i)e.call(i,t)&&s.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(i)):s},s.prototype.listeners=function(t,e){var i=n?n+t:t,s=this._events&&this._events[i];if(e)return!!s;if(!s)return[];if(s.fn)return[s.fn];for(var r=0,a=s.length,o=new Array(a);r<a;r++)o[r]=s[r].fn;return o},s.prototype.emit=function(t,e,i,s,r,a){var o=n?n+t:t;if(!this._events||!this._events[o])return!1;var l,u,h=this._events[o],p=arguments.length;if("function"==typeof h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),p){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,i),!0;case 4:return h.fn.call(h.context,e,i,s),!0;case 5:return h.fn.call(h.context,e,i,s,r),!0;case 6:return h.fn.call(h.context,e,i,s,r,a),!0}for(u=1,l=new Array(p-1);u<p;u++)l[u-1]=arguments[u];h.fn.apply(h.context,l)}else{var c,d=h.length;for(u=0;u<d;u++)switch(h[u].once&&this.removeListener(t,h[u].fn,void 0,!0),p){case 1:h[u].fn.call(h[u].context);break;case 2:h[u].fn.call(h[u].context,e);break;case 3:h[u].fn.call(h[u].context,e,i);break;default:if(!l)for(c=1,l=new Array(p-1);c<p;c++)l[c-1]=arguments[c];h[u].fn.apply(h[u].context,l)}}return!0},s.prototype.on=function(t,e,s){var r=new i(e,s||this),a=n?n+t:t;return this._events||(this._events=n?{}:Object.create(null)),this._events[a]?this._events[a].fn?this._events[a]=[this._events[a],r]:this._events[a].push(r):this._events[a]=r,this},s.prototype.once=function(t,e,s){var r=new i(e,s||this,!0),a=n?n+t:t;return this._events||(this._events=n?{}:Object.create(null)),this._events[a]?this._events[a].fn?this._events[a]=[this._events[a],r]:this._events[a].push(r):this._events[a]=r,this},s.prototype.removeListener=function(t,e,i,s){var r=n?n+t:t;if(!this._events||!this._events[r])return this;var a=this._events[r],o=[];if(e)if(a.fn)(a.fn!==e||s&&!a.once||i&&a.context!==i)&&o.push(a);else for(var l=0,u=a.length;l<u;l++)(a[l].fn!==e||s&&!a[l].once||i&&a[l].context!==i)&&o.push(a[l]);return o.length?this._events[r]=1===o.length?o[0]:o:delete this._events[r],this},s.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[n?n+t:t]:this._events=n?{}:Object.create(null),this):this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prototype.setMaxListeners=function(){return this},s.prefixed=n,t.exports=s},6192:(t,e,n)=>{var i={VERSION:n(1045).rE,PI_2:2*Math.PI,RAD_TO_DEG:180/Math.PI,DEG_TO_RAD:Math.PI/180,TARGET_FPMS:.06,RENDERER_TYPE:{UNKNOWN:0,WEBGL:1,CANVAS:2},BLEND_MODES:{NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},DRAW_MODES:{POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},SCALE_MODES:{DEFAULT:0,LINEAR:0,NEAREST:1},RETINA_PREFIX:/@(.+)x/,RESOLUTION:1,FILTER_RESOLUTION:1,DEFAULT_RENDER_OPTIONS:{view:null,resolution:1,antialias:!1,forceFXAA:!1,autoResize:!1,transparent:!1,backgroundColor:0,clearBeforeRender:!0,preserveDrawingBuffer:!1,roundPixels:!1},SHAPES:{POLY:0,RECT:1,CIRC:2,ELIP:3,RREC:4},SPRITE_BATCH_SIZE:2e3};t.exports=i},7673:(t,e,n)=>{var i=n(4650),s=n(2295),r=n(7443),a=new i.Matrix;function o(){s.call(this),this.children=[]}o.prototype=Object.create(s.prototype),o.prototype.constructor=o,t.exports=o,Object.defineProperties(o.prototype,{width:{get:function(){return this.scale.x*this.getLocalBounds().width},set:function(t){var e=this.getLocalBounds().width;this.scale.x=0!==e?t/e:1,this._width=t}},height:{get:function(){return this.scale.y*this.getLocalBounds().height},set:function(t){var e=this.getLocalBounds().height;this.scale.y=0!==e?t/e:1,this._height=t}}}),o.prototype.onChildrenChange=function(){},o.prototype.addChild=function(t){return this.addChildAt(t,this.children.length)},o.prototype.addChildAt=function(t,e){if(t===this)return t;if(e>=0&&e<=this.children.length)return t.parent&&t.parent.removeChild(t),t.parent=this,this.children.splice(e,0,t),this.onChildrenChange(e),t.emit("added",this),t;throw new Error(t+"addChildAt: The index "+e+" supplied is out of bounds "+this.children.length)},o.prototype.swapChildren=function(t,e){if(t!==e){var n=this.getChildIndex(t),i=this.getChildIndex(e);if(n<0||i<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be children of the caller.");this.children[n]=e,this.children[i]=t,this.onChildrenChange(n<i?n:i)}},o.prototype.getChildIndex=function(t){var e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied DisplayObject must be a child of the caller");return e},o.prototype.setChildIndex=function(t,e){if(e<0||e>=this.children.length)throw new Error("The supplied index is out of bounds");var n=this.getChildIndex(t);this.children.splice(n,1),this.children.splice(e,0,t),this.onChildrenChange(e)},o.prototype.getChildAt=function(t){if(t<0||t>=this.children.length)throw new Error("getChildAt: Supplied index "+t+" does not exist in the child list, or the supplied DisplayObject is not a child of the caller");return this.children[t]},o.prototype.removeChild=function(t){var e=this.children.indexOf(t);if(-1!==e)return this.removeChildAt(e)},o.prototype.removeChildAt=function(t){var e=this.getChildAt(t);return e.parent=null,this.children.splice(t,1),this.onChildrenChange(t),e.emit("removed",this),e},o.prototype.removeChildren=function(t,e){var n,i,s=t||0,r="number"==typeof e?e:this.children.length,a=r-s;if(a>0&&a<=r){for(n=this.children.splice(s,a),i=0;i<n.length;++i)n[i].parent=null;for(this.onChildrenChange(t),i=0;i<n.length;++i)n[i].emit("removed",this);return n}if(0===a&&0===this.children.length)return[];throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},o.prototype.generateTexture=function(t,e,n){var i=this.getLocalBounds(),s=new r(t,0|i.width,0|i.height,n,e);return a.tx=-i.x,a.ty=-i.y,s.render(this,a),s},o.prototype.updateTransform=function(){if(this.visible){this.displayObjectUpdateTransform();for(var t=0,e=this.children.length;t<e;++t)this.children[t].updateTransform()}},o.prototype.containerUpdateTransform=o.prototype.updateTransform,o.prototype.getBounds=function(){if(!this._currentBounds){if(0===this.children.length)return i.Rectangle.EMPTY;for(var t,e,n,s=1/0,r=1/0,a=-1/0,o=-1/0,l=!1,u=0,h=this.children.length;u<h;++u){this.children[u].visible&&(l=!0,s=s<(t=this.children[u].getBounds()).x?s:t.x,r=r<t.y?r:t.y,a=a>(e=t.width+t.x)?a:e,o=o>(n=t.height+t.y)?o:n)}if(!l)return i.Rectangle.EMPTY;var p=this._bounds;p.x=s,p.y=r,p.width=a-s,p.height=o-r,this._currentBounds=p}return this._currentBounds},o.prototype.containerGetBounds=o.prototype.getBounds,o.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=i.Matrix.IDENTITY;for(var e=0,n=this.children.length;e<n;++e)this.children[e].updateTransform();return this.worldTransform=t,this._currentBounds=null,this.getBounds(i.Matrix.IDENTITY)},o.prototype.renderWebGL=function(t){var e,n;if(this.visible&&!(this.worldAlpha<=0)&&this.renderable)if(this._mask||this._filters){for(t.currentRenderer.flush(),this._filters&&this._filters.length&&t.filterManager.pushFilter(this,this._filters),this._mask&&t.maskManager.pushMask(this,this._mask),t.currentRenderer.start(),this._renderWebGL(t),e=0,n=this.children.length;e<n;e++)this.children[e].renderWebGL(t);t.currentRenderer.flush(),this._mask&&t.maskManager.popMask(this,this._mask),this._filters&&t.filterManager.popFilter(),t.currentRenderer.start()}else for(this._renderWebGL(t),e=0,n=this.children.length;e<n;++e)this.children[e].renderWebGL(t)},o.prototype._renderWebGL=function(t){},o.prototype._renderCanvas=function(t){},o.prototype.renderCanvas=function(t){if(this.visible&&!(this.alpha<=0)&&this.renderable){this._mask&&t.maskManager.pushMask(this._mask,t),this._renderCanvas(t);for(var e=0,n=this.children.length;e<n;++e)this.children[e].renderCanvas(t);this._mask&&t.maskManager.popMask(t)}},o.prototype.destroy=function(t){if(s.prototype.destroy.call(this),t)for(var e=0,n=this.children.length;e<n;++e)this.children[e].destroy(t);this.removeChildren(),this.children=null}},2295:(t,e,n)=>{var i=n(4650),s=n(7443),r=n(5585),a=n(6192),o=new i.Matrix,l={worldTransform:new i.Matrix,worldAlpha:1,children:[]};function u(){r.call(this),this.position=new i.Point,this.scale=new i.Point(1,1),this.pivot=new i.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.renderable=!0,this.parent=null,this.worldAlpha=1,this.worldTransform=new i.Matrix,this.filterArea=null,this._sr=0,this._cr=1,this._bounds=new i.Rectangle(0,0,1,1),this._currentBounds=null,this._mask=null}u.prototype=Object.create(r.prototype),u.prototype.constructor=u,t.exports=u,Object.defineProperties(u.prototype,{x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},worldVisible:{get:function(){var t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}},mask:{get:function(){return this._mask},set:function(t){this._mask&&(this._mask.renderable=!0),this._mask=t,this._mask&&(this._mask.renderable=!1)}},filters:{get:function(){return this._filters&&this._filters.slice()},set:function(t){this._filters=t&&t.slice()}}}),u.prototype.updateTransform=function(){var t,e,n,i,s,r,o=this.parent.worldTransform,l=this.worldTransform;this.rotation%a.PI_2?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),t=this._cr*this.scale.x,e=this._sr*this.scale.x,n=-this._sr*this.scale.y,i=this._cr*this.scale.y,s=this.position.x,r=this.position.y,(this.pivot.x||this.pivot.y)&&(s-=this.pivot.x*t+this.pivot.y*n,r-=this.pivot.x*e+this.pivot.y*i),l.a=t*o.a+e*o.c,l.b=t*o.b+e*o.d,l.c=n*o.a+i*o.c,l.d=n*o.b+i*o.d,l.tx=s*o.a+r*o.c+o.tx,l.ty=s*o.b+r*o.d+o.ty):(t=this.scale.x,i=this.scale.y,s=this.position.x-this.pivot.x*t,r=this.position.y-this.pivot.y*i,l.a=t*o.a,l.b=t*o.b,l.c=i*o.c,l.d=i*o.d,l.tx=s*o.a+r*o.c+o.tx,l.ty=s*o.b+r*o.d+o.ty),this.worldAlpha=this.alpha*this.parent.worldAlpha,this._currentBounds=null},u.prototype.displayObjectUpdateTransform=u.prototype.updateTransform,u.prototype.getBounds=function(t){return i.Rectangle.EMPTY},u.prototype.getLocalBounds=function(){return this.getBounds(i.Matrix.IDENTITY)},u.prototype.toGlobal=function(t){return this.parent?this.displayObjectUpdateTransform():(this.parent=l,this.displayObjectUpdateTransform(),this.parent=null),this.worldTransform.apply(t)},u.prototype.toLocal=function(t,e){return e&&(t=e.toGlobal(t)),this.parent?this.displayObjectUpdateTransform():(this.parent=l,this.displayObjectUpdateTransform(),this.parent=null),this.worldTransform.applyInverse(t)},u.prototype.renderWebGL=function(t){},u.prototype.renderCanvas=function(t){},u.prototype.generateTexture=function(t,e,n){var i=this.getLocalBounds(),r=new s(t,0|i.width,0|i.height,e,n);return o.tx=-i.x,o.ty=-i.y,r.render(this,o),r},u.prototype.setParent=function(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t},u.prototype.destroy=function(){this.position=null,this.scale=null,this.pivot=null,this.parent=null,this._bounds=null,this._currentBounds=null,this._mask=null,this.worldTransform=null,this.filterArea=null}},6720:(t,e,n)=>{var i=n(7673),s=n(2699),r=n(1549),a=n(4694),o=n(7240),l=n(4650),u=n(6192),h=new l.Point;function p(){i.call(this),this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this._prevTint=16777215,this.blendMode=u.BLEND_MODES.NORMAL,this.currentPath=null,this._webGL={},this.isMask=!1,this.boundsPadding=0,this._localBounds=new l.Rectangle(0,0,1,1),this.dirty=!0,this.glDirty=!1,this.boundsDirty=!0,this.cachedSpriteDirty=!1}p.prototype=Object.create(i.prototype),p.prototype.constructor=p,t.exports=p,p.prototype.clone=function(){var t=new p;t.renderable=this.renderable,t.fillAlpha=this.fillAlpha,t.lineWidth=this.lineWidth,t.lineColor=this.lineColor,t.tint=this.tint,t.blendMode=this.blendMode,t.isMask=this.isMask,t.boundsPadding=this.boundsPadding,t.dirty=!0,t.glDirty=!0,t.cachedSpriteDirty=this.cachedSpriteDirty;for(var e=0;e<this.graphicsData.length;++e)t.graphicsData.push(this.graphicsData[e].clone());return t.currentPath=t.graphicsData[t.graphicsData.length-1],t.updateLocalBounds(),t},p.prototype.lineStyle=function(t,e,n){if(this.lineWidth=t||0,this.lineColor=e||0,this.lineAlpha=void 0===n?1:n,this.currentPath)if(this.currentPath.shape.points.length){var i=new l.Polygon(this.currentPath.shape.points.slice(-2));i.closed=!1,this.drawShape(i)}else this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha;return this},p.prototype.moveTo=function(t,e){var n=new l.Polygon([t,e]);return n.closed=!1,this.drawShape(n),this},p.prototype.lineTo=function(t,e){return this.currentPath.shape.points.push(t,e),this.dirty=!0,this},p.prototype.quadraticCurveTo=function(t,e,n,i){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);var s,r,a=this.currentPath.shape.points;0===a.length&&this.moveTo(0,0);for(var o=a[a.length-2],l=a[a.length-1],u=0,h=1;h<=20;++h)s=o+(t-o)*(u=h/20),r=l+(e-l)*u,a.push(s+(t+(n-t)*u-s)*u,r+(e+(i-e)*u-r)*u);return this.dirty=this.boundsDirty=!0,this},p.prototype.bezierCurveTo=function(t,e,n,i,s,r){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var a,o,l,u,h,p=this.currentPath.shape.points,c=p[p.length-2],d=p[p.length-1],f=0,m=1;m<=20;++m)l=(o=(a=1-(f=m/20))*a)*a,h=(u=f*f)*f,p.push(l*c+3*o*f*t+3*a*u*n+h*s,l*d+3*o*f*e+3*a*u*i+h*r);return this.dirty=this.boundsDirty=!0,this},p.prototype.arcTo=function(t,e,n,i,s){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(t,e):this.moveTo(t,e);var r=this.currentPath.shape.points,a=r[r.length-2],o=r[r.length-1]-e,l=a-t,u=i-e,h=n-t,p=Math.abs(o*h-l*u);if(p<1e-8||0===s)r[r.length-2]===t&&r[r.length-1]===e||r.push(t,e);else{var c=o*o+l*l,d=u*u+h*h,f=o*u+l*h,m=s*Math.sqrt(c)/p,g=s*Math.sqrt(d)/p,_=m*f/c,T=g*f/d,y=m*h+g*l,I=m*u+g*o,E=l*(g+_),b=o*(g+_),v=h*(m+T),w=u*(m+T),S=Math.atan2(b-I,E-y),x=Math.atan2(w-I,v-y);this.arc(y+t,I+e,s,S,x,l*u>h*o)}return this.dirty=this.boundsDirty=!0,this},p.prototype.arc=function(t,e,n,i,s,r){if(i===s)return this;!(r=r||!1)&&s<=i?s+=2*Math.PI:r&&i<=s&&(i+=2*Math.PI);var a=r?-1*(i-s):s-i,o=40*Math.ceil(Math.abs(a)/(2*Math.PI));if(0===a)return this;var l=t+Math.cos(i)*n,u=e+Math.sin(i)*n;this.currentPath?this.currentPath.shape.points.push(l,u):this.moveTo(l,u);for(var h=this.currentPath.shape.points,p=a/(2*o),c=2*p,d=Math.cos(p),f=Math.sin(p),m=o-1,g=m%1/m,_=0;_<=m;_++){var T=p+i+c*(_+g*_),y=Math.cos(T),I=-Math.sin(T);h.push((d*y+f*I)*n+t,(d*-I+f*y)*n+e)}return this.dirty=this.boundsDirty=!0,this},p.prototype.beginFill=function(t,e){return this.filling=!0,this.fillColor=t||0,this.fillAlpha=void 0===e?1:e,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},p.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},p.prototype.drawRect=function(t,e,n,i){return this.drawShape(new l.Rectangle(t,e,n,i)),this},p.prototype.drawRoundedRect=function(t,e,n,i,s){return this.drawShape(new l.RoundedRectangle(t,e,n,i,s)),this},p.prototype.drawCircle=function(t,e,n){return this.drawShape(new l.Circle(t,e,n)),this},p.prototype.drawEllipse=function(t,e,n,i){return this.drawShape(new l.Ellipse(t,e,n,i)),this},p.prototype.drawPolygon=function(t){var e=t,n=!0;if(e instanceof l.Polygon&&(n=e.closed,e=e.points),!Array.isArray(e)){e=new Array(arguments.length);for(var i=0;i<e.length;++i)e[i]=arguments[i]}var s=new l.Polygon(e);return s.closed=n,this.drawShape(s),this},p.prototype.clear=function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[],this},p.prototype.generateTexture=function(t,e,n){e=e||1;var i=this.getLocalBounds(),o=new r(i.width*e,i.height*e),l=s.fromCanvas(o.canvas,n);return l.baseTexture.resolution=e,o.context.scale(e,e),o.context.translate(-i.x,-i.y),a.renderGraphics(this,o.context),l},p.prototype._renderWebGL=function(t){this.glDirty&&(this.dirty=!0,this.glDirty=!1),t.setObjectRenderer(t.plugins.graphics),t.plugins.graphics.render(this)},p.prototype._renderCanvas=function(t){if(!0!==this.isMask){this._prevTint!==this.tint&&(this.dirty=!0);var e=t.context,n=this.worldTransform,i=t.blendModes[this.blendMode];i!==e.globalCompositeOperation&&(e.globalCompositeOperation=i);var s=t.resolution;e.setTransform(n.a*s,n.b*s,n.c*s,n.d*s,n.tx*s,n.ty*s),a.renderGraphics(this,e)}},p.prototype.getBounds=function(t){if(!this._currentBounds){if(!this.renderable)return l.Rectangle.EMPTY;this.boundsDirty&&(this.updateLocalBounds(),this.glDirty=!0,this.cachedSpriteDirty=!0,this.boundsDirty=!1);var e=this._localBounds,n=e.x,i=e.width+e.x,s=e.y,r=e.height+e.y,a=t||this.worldTransform,o=a.a,u=a.b,h=a.c,p=a.d,c=a.tx,d=a.ty,f=o*i+h*r+c,m=p*r+u*i+d,g=o*n+h*r+c,_=p*r+u*n+d,T=o*n+h*s+c,y=p*s+u*n+d,I=o*i+h*s+c,E=p*s+u*i+d,b=f,v=m,w=f,S=m;w=I<(w=T<(w=g<w?g:w)?T:w)?I:w,S=E<(S=y<(S=_<S?_:S)?y:S)?E:S,b=I>(b=T>(b=g>b?g:b)?T:b)?I:b,v=E>(v=y>(v=_>v?_:v)?y:v)?E:v,this._bounds.x=w,this._bounds.width=b-w,this._bounds.y=S,this._bounds.height=v-S,this._currentBounds=this._bounds}return this._currentBounds},p.prototype.containsPoint=function(t){this.worldTransform.applyInverse(t,h);for(var e=this.graphicsData,n=0;n<e.length;n++){var i=e[n];if(i.fill&&(i.shape&&i.shape.contains(h.x,h.y)))return!0}return!1},p.prototype.updateLocalBounds=function(){var t=1/0,e=-1/0,n=1/0,i=-1/0;if(this.graphicsData.length)for(var s,r,a,o,l,h,p=0;p<this.graphicsData.length;p++){var c=this.graphicsData[p],d=c.type,f=c.lineWidth;if(s=c.shape,d===u.SHAPES.RECT||d===u.SHAPES.RREC)a=s.x-f/2,o=s.y-f/2,t=a<t?a:t,e=a+(l=s.width+f)>e?a+l:e,n=o<n?o:n,i=o+(h=s.height+f)>i?o+h:i;else if(d===u.SHAPES.CIRC)a=s.x,o=s.y,t=a-(l=s.radius+f/2)<t?a-l:t,e=a+l>e?a+l:e,n=o-(h=s.radius+f/2)<n?o-h:n,i=o+h>i?o+h:i;else if(d===u.SHAPES.ELIP)a=s.x,o=s.y,t=a-(l=s.width+f/2)<t?a-l:t,e=a+l>e?a+l:e,n=o-(h=s.height+f/2)<n?o-h:n,i=o+h>i?o+h:i;else{r=s.points;for(var m=0;m<r.length;m+=2)t=(a=r[m])-f<t?a-f:t,e=a+f>e?a+f:e,n=(o=r[m+1])-f<n?o-f:n,i=o+f>i?o+f:i}}else t=0,e=0,n=0,i=0;var g=this.boundsPadding;this._localBounds.x=t-g,this._localBounds.width=e-t+2*g,this._localBounds.y=n-g,this._localBounds.height=i-n+2*g},p.prototype.drawShape=function(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null;var e=new o(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(e),e.type===u.SHAPES.POLY&&(e.shape.closed=e.shape.closed||this.filling,this.currentPath=e),this.dirty=this.boundsDirty=!0,e},p.prototype.destroy=function(){i.prototype.destroy.apply(this,arguments);for(var t=0;t<this.graphicsData.length;++t)this.graphicsData[t].destroy();for(var e in this._webgl)for(var n=0;n<this._webgl[e].data.length;++n)this._webgl[e].data[n].destroy();this.graphicsData=null,this.currentPath=null,this._webgl=null,this._localBounds=null}},7240:t=>{function e(t,e,n,i,s,r,a){this.lineWidth=t,this.lineColor=e,this.lineAlpha=n,this._lineTint=e,this.fillColor=i,this.fillAlpha=s,this._fillTint=i,this.fill=r,this.shape=a,this.type=a.type}e.prototype.constructor=e,t.exports=e,e.prototype.clone=function(){return new e(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},e.prototype.destroy=function(){this.shape=null}},4237:(t,e,n)=>{var i=n(501),s=n(4650),r=n(6192),a=n(1830),o=n(5092),l=n(5075),u=n(6570);function h(t){a.call(this,t),this.graphicsDataPool=[],this.primitiveShader=null,this.complexPrimitiveShader=null,this.maximumSimplePolySize=200}h.prototype=Object.create(a.prototype),h.prototype.constructor=h,t.exports=h,o.registerPlugin("graphics",h),h.prototype.onContextChange=function(){},h.prototype.destroy=function(){a.prototype.destroy.call(this);for(var t=0;t<this.graphicsDataPool.length;++t)this.graphicsDataPool[t].destroy();this.graphicsDataPool=null},h.prototype.render=function(t){var e,n=this.renderer,s=n.gl,r=n.shaderManager.plugins.primitiveShader;t.dirty&&this.updateGraphics(t);var a=t._webGL[s.id];n.blendModeManager.setBlendMode(t.blendMode);for(var o=0,l=a.data.length;o<l;o++)e=a.data[o],1===a.data[o].mode?(n.stencilManager.pushStencil(t,e),s.uniform1f(n.shaderManager.complexPrimitiveShader.uniforms.alpha._location,t.worldAlpha*e.alpha),s.drawElements(s.TRIANGLE_FAN,4,s.UNSIGNED_SHORT,2*(e.indices.length-4)),n.stencilManager.popStencil(t,e)):(r=n.shaderManager.primitiveShader,n.shaderManager.setShader(r),s.uniformMatrix3fv(r.uniforms.translationMatrix._location,!1,t.worldTransform.toArray(!0)),s.uniformMatrix3fv(r.uniforms.projectionMatrix._location,!1,n.currentRenderTarget.projectionMatrix.toArray(!0)),s.uniform3fv(r.uniforms.tint._location,i.hex2rgb(t.tint)),s.uniform1f(r.uniforms.alpha._location,t.worldAlpha),s.bindBuffer(s.ARRAY_BUFFER,e.buffer),s.vertexAttribPointer(r.attributes.aVertexPosition,2,s.FLOAT,!1,24,0),s.vertexAttribPointer(r.attributes.aColor,4,s.FLOAT,!1,24,8),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.indexBuffer),s.drawElements(s.TRIANGLE_STRIP,e.indices.length,s.UNSIGNED_SHORT,0)),n.drawCount++},h.prototype.updateGraphics=function(t){var e,n,i=this.renderer.gl,s=t._webGL[i.id];if(s||(s=t._webGL[i.id]={lastIndex:0,data:[],gl:i}),t.dirty=!1,t.clearDirty){for(t.clearDirty=!1,e=0;e<s.data.length;e++){var a=s.data[e];a.reset(),this.graphicsDataPool.push(a)}s.data=[],s.lastIndex=0}for(e=s.lastIndex;e<t.graphicsData.length;e++){var o=t.graphicsData[e];if(o.type===r.SHAPES.POLY){if(o.points=o.shape.points.slice(),o.shape.closed&&(o.points[0]===o.points[o.points.length-2]&&o.points[1]===o.points[o.points.length-1]||o.points.push(o.points[0],o.points[1])),o.fill)if(o.points.length>=6)if(o.points.length<2*this.maximumSimplePolySize)n=this.switchMode(s,0),this.buildPoly(o,n)||(n=this.switchMode(s,1),this.buildComplexPoly(o,n));else n=this.switchMode(s,1),this.buildComplexPoly(o,n);o.lineWidth>0&&(n=this.switchMode(s,0),this.buildLine(o,n))}else n=this.switchMode(s,0),o.type===r.SHAPES.RECT?this.buildRectangle(o,n):o.type===r.SHAPES.CIRC||o.type===r.SHAPES.ELIP?this.buildCircle(o,n):o.type===r.SHAPES.RREC&&this.buildRoundedRectangle(o,n);s.lastIndex++}for(e=0;e<s.data.length;e++)(n=s.data[e]).dirty&&n.upload()},h.prototype.switchMode=function(t,e){var n;return t.data.length?((n=t.data[t.data.length-1]).points.length>32e4||n.mode!==e||1===e)&&((n=this.graphicsDataPool.pop()||new l(t.gl)).mode=e,t.data.push(n)):((n=this.graphicsDataPool.pop()||new l(t.gl)).mode=e,t.data.push(n)),n.dirty=!0,n},h.prototype.buildRectangle=function(t,e){var n=t.shape,s=n.x,r=n.y,a=n.width,o=n.height;if(t.fill){var l=i.hex2rgb(t.fillColor),u=t.fillAlpha,h=l[0]*u,p=l[1]*u,c=l[2]*u,d=e.points,f=e.indices,m=d.length/6;d.push(s,r),d.push(h,p,c,u),d.push(s+a,r),d.push(h,p,c,u),d.push(s,r+o),d.push(h,p,c,u),d.push(s+a,r+o),d.push(h,p,c,u),f.push(m,m,m+1,m+2,m+3,m+3)}if(t.lineWidth){var g=t.points;t.points=[s,r,s+a,r,s+a,r+o,s,r+o,s,r],this.buildLine(t,e),t.points=g}},h.prototype.buildRoundedRectangle=function(t,e){var n=t.shape,s=n.x,r=n.y,a=n.width,o=n.height,l=n.radius,h=[];if(h.push(s,r+l),this.quadraticBezierCurve(s,r+o-l,s,r+o,s+l,r+o,h),this.quadraticBezierCurve(s+a-l,r+o,s+a,r+o,s+a,r+o-l,h),this.quadraticBezierCurve(s+a,r+l,s+a,r,s+a-l,r,h),this.quadraticBezierCurve(s+l,r,s,r,s,r+l+1e-10,h),t.fill){var p=i.hex2rgb(t.fillColor),c=t.fillAlpha,d=p[0]*c,f=p[1]*c,m=p[2]*c,g=e.points,_=e.indices,T=g.length/6,y=u(h,null,2),I=0;for(I=0;I<y.length;I+=3)_.push(y[I]+T),_.push(y[I]+T),_.push(y[I+1]+T),_.push(y[I+2]+T),_.push(y[I+2]+T);for(I=0;I<h.length;I++)g.push(h[I],h[++I],d,f,m,c)}if(t.lineWidth){var E=t.points;t.points=h,this.buildLine(t,e),t.points=E}},h.prototype.quadraticBezierCurve=function(t,e,n,i,s,r,a){var o,l,u,h,p,c,d=a||[];function f(t,e,n){return t+(e-t)*n}for(var m=0,g=0;g<=20;g++)o=f(t,n,m=g/20),l=f(e,i,m),u=f(n,s,m),h=f(i,r,m),p=f(o,u,m),c=f(l,h,m),d.push(p,c);return d},h.prototype.buildCircle=function(t,e){var n,s,a=t.shape,o=a.x,l=a.y;t.type===r.SHAPES.CIRC?(n=a.radius,s=a.radius):(n=a.width,s=a.height);var u=Math.floor(30*Math.sqrt(a.radius))||Math.floor(15*Math.sqrt(a.width+a.height)),h=2*Math.PI/u,p=0;if(t.fill){var c=i.hex2rgb(t.fillColor),d=t.fillAlpha,f=c[0]*d,m=c[1]*d,g=c[2]*d,_=e.points,T=e.indices,y=_.length/6;for(T.push(y),p=0;p<u+1;p++)_.push(o,l,f,m,g,d),_.push(o+Math.sin(h*p)*n,l+Math.cos(h*p)*s,f,m,g,d),T.push(y++,y++);T.push(y-1)}if(t.lineWidth){var I=t.points;for(t.points=[],p=0;p<u+1;p++)t.points.push(o+Math.sin(h*p)*n,l+Math.cos(h*p)*s);this.buildLine(t,e),t.points=I}},h.prototype.buildLine=function(t,e){var n=0,r=t.points;if(0!==r.length){var a=new s.Point(r[0],r[1]),o=new s.Point(r[r.length-2],r[r.length-1]);if(a.x===o.x&&a.y===o.y){(r=r.slice()).pop(),r.pop();var l=(o=new s.Point(r[r.length-2],r[r.length-1])).x+.5*(a.x-o.x),u=o.y+.5*(a.y-o.y);r.unshift(l,u),r.push(l,u)}var h,p,c,d,f,m,g,_,T,y,I,E,b,v,w,S,x,R,O,A,M,C,N=e.points,k=e.indices,D=r.length/2,L=r.length,F=N.length/6,P=t.lineWidth/2,$=i.hex2rgb(t.lineColor),B=t.lineAlpha,V=$[0]*B,U=$[1]*B,Y=$[2]*B;for(c=r[0],d=r[1],f=r[2],T=-(d-(m=r[3])),y=c-f,T/=C=Math.sqrt(T*T+y*y),y/=C,T*=P,y*=P,N.push(c-T,d-y,V,U,Y,B),N.push(c+T,d+y,V,U,Y,B),n=1;n<D-1;n++)c=r[2*(n-1)],d=r[2*(n-1)+1],f=r[2*n],m=r[2*n+1],g=r[2*(n+1)],_=r[2*(n+1)+1],T=-(d-m),y=c-f,T/=C=Math.sqrt(T*T+y*y),y/=C,T*=P,y*=P,I=-(m-_),E=f-g,I/=C=Math.sqrt(I*I+E*E),E/=C,x=(-T+c)*(-y+m)-(-T+f)*(-y+d),A=(-(I*=P)+g)*(-(E*=P)+m)-(-I+f)*(-E+_),M=(w=-y+d-(-y+m))*(O=-I+f-(-I+g))-(R=-E+_-(-E+m))*(S=-T+f-(-T+c)),Math.abs(M)<.1?(M+=10.1,N.push(f-T,m-y,V,U,Y,B),N.push(f+T,m+y,V,U,Y,B)):((h=(S*A-O*x)/M)-f)*(h-f)+((p=(R*x-w*A)/M)-m)+(p-m)>19600?(b=T-I,v=y-E,b/=C=Math.sqrt(b*b+v*v),v/=C,b*=P,v*=P,N.push(f-b,m-v),N.push(V,U,Y,B),N.push(f+b,m+v),N.push(V,U,Y,B),N.push(f-b,m-v),N.push(V,U,Y,B),L++):(N.push(h,p),N.push(V,U,Y,B),N.push(f-(h-f),m-(p-m)),N.push(V,U,Y,B));for(c=r[2*(D-2)],d=r[2*(D-2)+1],f=r[2*(D-1)],T=-(d-(m=r[2*(D-1)+1])),y=c-f,T/=C=Math.sqrt(T*T+y*y),y/=C,T*=P,y*=P,N.push(f-T,m-y),N.push(V,U,Y,B),N.push(f+T,m+y),N.push(V,U,Y,B),k.push(F),n=0;n<L;n++)k.push(F++);k.push(F-1)}},h.prototype.buildComplexPoly=function(t,e){var n=t.points.slice();if(!(n.length<6)){var s=e.indices;e.points=n,e.alpha=t.fillAlpha,e.color=i.hex2rgb(t.fillColor);for(var r,a,o=1/0,l=-1/0,u=1/0,h=-1/0,p=0;p<n.length;p+=2)o=(r=n[p])<o?r:o,l=r>l?r:l,u=(a=n[p+1])<u?a:u,h=a>h?a:h;n.push(o,u,l,u,l,h,o,h);var c=n.length/2;for(p=0;p<c;p++)s.push(p)}},h.prototype.buildPoly=function(t,e){var n=t.points;if(!(n.length<6)){var s=e.points,r=e.indices,a=n.length/2,o=i.hex2rgb(t.fillColor),l=t.fillAlpha,h=o[0]*l,p=o[1]*l,c=o[2]*l,d=u(n,null,2);if(!d)return!1;var f=s.length/6,m=0;for(m=0;m<d.length;m+=3)r.push(d[m]+f),r.push(d[m]+f),r.push(d[m+1]+f),r.push(d[m+2]+f),r.push(d[m+2]+f);for(m=0;m<a;m++)s.push(n[2*m],n[2*m+1],h,p,c,l);return!0}}},5075:t=>{function e(t){this.gl=t,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0,this.glPoints=null,this.glIndices=null}e.prototype.constructor=e,t.exports=e,e.prototype.reset=function(){this.points.length=0,this.indices.length=0},e.prototype.upload=function(){var t=this.gl;this.glPoints=new Float32Array(this.points),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,this.glPoints,t.STATIC_DRAW),this.glIndices=new Uint16Array(this.indices),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.glIndices,t.STATIC_DRAW),this.dirty=!1},e.prototype.destroy=function(){this.color=null,this.points=null,this.indices=null,this.gl.deleteBuffer(this.buffer),this.gl.deleteBuffer(this.indexBuffer),this.gl=null,this.buffer=null,this.indexBuffer=null,this.glPoints=null,this.glIndices=null}},4651:(t,e,n)=>{
/**
* @file Main export of the PIXI core library
* @author Mat Groves <mat@goodboydigital.com>
* @copyright 2013-2015 GoodBoyDigital
* @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License}
*/
var i=t.exports=Object.assign(n(6192),n(4650),{utils:n(501),ticker:n(2410),DisplayObject:n(2295),Container:n(7673),Sprite:n(2861),ParticleContainer:n(3326),SpriteRenderer:n(7920),ParticleRenderer:n(2952),Text:n(9252),Graphics:n(6720),GraphicsData:n(7240),GraphicsRenderer:n(4237),Texture:n(2699),BaseTexture:n(1936),RenderTexture:n(7443),VideoBaseTexture:n(3367),TextureUvs:n(1507),CanvasRenderer:n(8010),CanvasGraphics:n(4694),CanvasBuffer:n(1549),WebGLRenderer:n(5092),ShaderManager:n(3779),Shader:n(8306),ObjectRenderer:n(1830),RenderTarget:n(7955),AbstractFilter:n(580),FXAAFilter:n(1438),SpriteMaskFilter:n(5207),autoDetectRenderer:function(t,e,n,s){return t=t||800,e=e||600,!s&&i.utils.isWebGLSupported()?new i.WebGLRenderer(t,e,n):new i.CanvasRenderer(t,e,n)}})},2825:(t,e,n)=>{var i=n(8840);function s(){this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0}s.prototype.constructor=s,t.exports=s,s.prototype.fromArray=function(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]},s.prototype.toArray=function(t,e){this.array||(this.array=new Float32Array(9));var n=e||this.array;return t?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n},s.prototype.apply=function(t,e){e=e||new i;var n=t.x,s=t.y;return e.x=this.a*n+this.c*s+this.tx,e.y=this.b*n+this.d*s+this.ty,e},s.prototype.applyInverse=function(t,e){e=e||new i;var n=1/(this.a*this.d+this.c*-this.b),s=t.x,r=t.y;return e.x=this.d*n*s+-this.c*n*r+(this.ty*this.c-this.tx*this.d)*n,e.y=this.a*n*r+-this.b*n*s+(-this.ty*this.a+this.tx*this.b)*n,e},s.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},s.prototype.scale=function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},s.prototype.rotate=function(t){var e=Math.cos(t),n=Math.sin(t),i=this.a,s=this.c,r=this.tx;return this.a=i*e-this.b*n,this.b=i*n+this.b*e,this.c=s*e-this.d*n,this.d=s*n+this.d*e,this.tx=r*e-this.ty*n,this.ty=r*n+this.ty*e,this},s.prototype.append=function(t){var e=this.a,n=this.b,i=this.c,s=this.d;return this.a=t.a*e+t.b*i,this.b=t.a*n+t.b*s,this.c=t.c*e+t.d*i,this.d=t.c*n+t.d*s,this.tx=t.tx*e+t.ty*i+this.tx,this.ty=t.tx*n+t.ty*s+this.ty,this},s.prototype.prepend=function(t){var e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){var n=this.a,i=this.c;this.a=n*t.a+this.b*t.c,this.b=n*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this},s.prototype.invert=function(){var t=this.a,e=this.b,n=this.c,i=this.d,s=this.tx,r=t*i-e*n;return this.a=i/r,this.b=-e/r,this.c=-n/r,this.d=t/r,this.tx=(n*this.ty-i*s)/r,this.ty=-(t*this.ty-e*s)/r,this},s.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},s.prototype.clone=function(){var t=new s;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t},s.prototype.copy=function(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t},s.IDENTITY=new s,s.TEMP_MATRIX=new s},8840:t=>{function e(t,e){this.x=t||0,this.y=e||0}e.prototype.constructor=e,t.exports=e,e.prototype.clone=function(){return new e(this.x,this.y)},e.prototype.copy=function(t){this.set(t.x,t.y)},e.prototype.equals=function(t){return t.x===this.x&&t.y===this.y},e.prototype.set=function(t,e){this.x=t||0,this.y=e||(0!==e?this.x:0)}},4650:(t,e,n)=>{t.exports={Point:n(8840),Matrix:n(2825),Circle:n(5385),Ellipse:n(8419),Polygon:n(3671),Rectangle:n(2068),RoundedRectangle:n(1347)}},5385:(t,e,n)=>{var i=n(2068),s=n(6192);function r(t,e,n){this.x=t||0,this.y=e||0,this.radius=n||0,this.type=s.SHAPES.CIRC}r.prototype.constructor=r,t.exports=r,r.prototype.clone=function(){return new r(this.x,this.y,this.radius)},r.prototype.contains=function(t,e){if(this.radius<=0)return!1;var n=this.x-t,i=this.y-e;return(n*=n)+(i*=i)<=this.radius*this.radius},r.prototype.getBounds=function(){return new i(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius)}},8419:(t,e,n)=>{var i=n(2068),s=n(6192);function r(t,e,n,i){this.x=t||0,this.y=e||0,this.width=n||0,this.height=i||0,this.type=s.SHAPES.ELIP}r.prototype.constructor=r,t.exports=r,r.prototype.clone=function(){return new r(this.x,this.y,this.width,this.height)},r.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;var n=(t-this.x)/this.width,i=(e-this.y)/this.height;return(n*=n)+(i*=i)<=1},r.prototype.getBounds=function(){return new i(this.x-this.width,this.y-this.height,this.width,this.height)}},3671:(t,e,n)=>{var i=n(8840),s=n(6192);function r(t){var e=t;if(!Array.isArray(e)){e=new Array(arguments.length);for(var n=0;n<e.length;++n)e[n]=arguments[n]}if(e[0]instanceof i){for(var r=[],a=0,o=e.length;a<o;a++)r.push(e[a].x,e[a].y);e=r}this.closed=!0,this.points=e,this.type=s.SHAPES.POLY}r.prototype.constructor=r,t.exports=r,r.prototype.clone=function(){return new r(this.points.slice())},r.prototype.contains=function(t,e){for(var n=!1,i=this.points.length/2,s=0,r=i-1;s<i;r=s++){var a=this.points[2*s],o=this.points[2*s+1],l=this.points[2*r],u=this.points[2*r+1];o>e!=u>e&&t<(l-a)*(e-o)/(u-o)+a&&(n=!n)}return n}},2068:(t,e,n)=>{var i=n(6192);function s(t,e,n,s){this.x=t||0,this.y=e||0,this.width=n||0,this.height=s||0,this.type=i.SHAPES.RECT}s.prototype.constructor=s,t.exports=s,s.EMPTY=new s(0,0,0,0),s.prototype.clone=function(){return new s(this.x,this.y,this.width,this.height)},s.prototype.contains=function(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height)}},1347:(t,e,n)=>{var i=n(6192);function s(t,e,n,s,r){this.x=t||0,this.y=e||0,this.width=n||0,this.height=s||0,this.radius=r||20,this.type=i.SHAPES.RREC}s.prototype.constructor=s,t.exports=s,s.prototype.clone=function(){return new s(this.x,this.y,this.width,this.height,this.radius)},s.prototype.contains=function(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height)}},3326:(t,e,n)=>{var i=n(7673),s=n(6192);function r(t,e,n){i.call(this);(n=n||15e3)>16384&&(n=16384),n>(t=t||15e3)&&(n=t),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=n,this._buffers=null,this._bufferToUpdate=0,this.interactiveChildren=!1,this.blendMode=s.BLEND_MODES.NORMAL,this.roundPixels=!0,this.setProperties(e)}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.setProperties=function(t){t&&(this._properties[0]="scale"in t?!!t.scale:this._properties[0],this._properties[1]="position"in t?!!t.position:this._properties[1],this._properties[2]="rotation"in t?!!t.rotation:this._properties[2],this._properties[3]="uvs"in t?!!t.uvs:this._properties[3],this._properties[4]="alpha"in t?!!t.alpha:this._properties[4])},r.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},r.prototype.renderWebGL=function(t){this.visible&&!(this.worldAlpha<=0)&&this.children.length&&this.renderable&&(t.setObjectRenderer(t.plugins.particle),t.plugins.particle.render(this))},r.prototype.onChildrenChange=function(t){var e=Math.floor(t/this._batchSize);e<this._bufferToUpdate&&(this._bufferToUpdate=e)},r.prototype.renderCanvas=function(t){if(this.visible&&!(this.worldAlpha<=0)&&this.children.length&&this.renderable){var e=t.context,n=this.worldTransform,i=!0,s=0,r=0,a=0,o=0;e.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var l=0;l<this.children.length;++l){var u=this.children[l];if(u.visible){var h=u.texture.frame;if(e.globalAlpha=this.worldAlpha*u.alpha,u.rotation%(2*Math.PI)==0)i&&(e.setTransform(n.a,n.b,n.c,n.d,n.tx,n.ty),i=!1),s=u.anchor.x*(-h.width*u.scale.x)+u.position.x+.5,r=u.anchor.y*(-h.height*u.scale.y)+u.position.y+.5,a=h.width*u.scale.x,o=h.height*u.scale.y;else{i||(i=!0),u.displayObjectUpdateTransform();var p=u.worldTransform;t.roundPixels?e.setTransform(p.a,p.b,p.c,p.d,0|p.tx,0|p.ty):e.setTransform(p.a,p.b,p.c,p.d,p.tx,p.ty),s=u.anchor.x*-h.width+.5,r=u.anchor.y*-h.height+.5,a=h.width,o=h.height}e.drawImage(u.texture.baseTexture.source,h.x,h.y,h.width,h.height,s,r,a,o)}}}},r.prototype.destroy=function(){if(i.prototype.destroy.apply(this,arguments),this._buffers)for(var t=0;t<this._buffers.length;++t)this._buffers[t].destroy();this._properties=null,this._buffers=null}},3361:t=>{function e(t,e,n,i){this.gl=t,this.vertSize=2,this.vertByteSize=4*this.vertSize,this.size=i,this.dynamicProperties=[],this.staticProperties=[];for(var s=0;s<e.length;s++){var r=e[s];n[s]?this.dynamicProperties.push(r):this.staticProperties.push(r)}this.staticStride=0,this.staticBuffer=null,this.staticData=null,this.dynamicStride=0,this.dynamicBuffer=null,this.dynamicData=null,this.initBuffers()}e.prototype.constructor=e,t.exports=e,e.prototype.initBuffers=function(){var t,e,n=this.gl,i=0;for(this.dynamicStride=0,t=0;t<this.dynamicProperties.length;t++)(e=this.dynamicProperties[t]).offset=i,i+=e.size,this.dynamicStride+=e.size;this.dynamicData=new Float32Array(this.size*this.dynamicStride*4),this.dynamicBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this.dynamicBuffer),n.bufferData(n.ARRAY_BUFFER,this.dynamicData,n.DYNAMIC_DRAW);var s=0;for(this.staticStride=0,t=0;t<this.staticProperties.length;t++)(e=this.staticProperties[t]).offset=s,s+=e.size,this.staticStride+=e.size;this.staticData=new Float32Array(this.size*this.staticStride*4),this.staticBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this.staticBuffer),n.bufferData(n.ARRAY_BUFFER,this.staticData,n.DYNAMIC_DRAW)},e.prototype.uploadDynamic=function(t,e,n){for(var i=this.gl,s=0;s<this.dynamicProperties.length;s++){var r=this.dynamicProperties[s];r.uploadFunction(t,e,n,this.dynamicData,this.dynamicStride,r.offset)}i.bindBuffer(i.ARRAY_BUFFER,this.dynamicBuffer),i.bufferSubData(i.ARRAY_BUFFER,0,this.dynamicData)},e.prototype.uploadStatic=function(t,e,n){for(var i=this.gl,s=0;s<this.staticProperties.length;s++){var r=this.staticProperties[s];r.uploadFunction(t,e,n,this.staticData,this.staticStride,r.offset)}i.bindBuffer(i.ARRAY_BUFFER,this.staticBuffer),i.bufferSubData(i.ARRAY_BUFFER,0,this.staticData)},e.prototype.bind=function(){var t,e,n=this.gl;for(n.bindBuffer(n.ARRAY_BUFFER,this.dynamicBuffer),t=0;t<this.dynamicProperties.length;t++)e=this.dynamicProperties[t],n.vertexAttribPointer(e.attribute,e.size,n.FLOAT,!1,4*this.dynamicStride,4*e.offset);for(n.bindBuffer(n.ARRAY_BUFFER,this.staticBuffer),t=0;t<this.staticProperties.length;t++)e=this.staticProperties[t],n.vertexAttribPointer(e.attribute,e.size,n.FLOAT,!1,4*this.staticStride,4*e.offset)},e.prototype.destroy=function(){this.dynamicProperties=null,this.dynamicData=null,this.gl.deleteBuffer(this.dynamicBuffer),this.staticProperties=null,this.staticData=null,this.gl.deleteBuffer(this.staticBuffer)}},2952:(t,e,n)=>{var i=n(1830),s=n(5092),r=n(3646),a=n(3361),o=n(4650);function l(t){i.call(this,t);this.indices=new Uint16Array(98304);for(var e=0,n=0;e<98304;e+=6,n+=4)this.indices[e+0]=n+0,this.indices[e+1]=n+1,this.indices[e+2]=n+2,this.indices[e+3]=n+0,this.indices[e+4]=n+2,this.indices[e+5]=n+3;this.shader=null,this.indexBuffer=null,this.properties=null,this.tempMatrix=new o.Matrix}l.prototype=Object.create(i.prototype),l.prototype.constructor=l,t.exports=l,s.registerPlugin("particle",l),l.prototype.onContextChange=function(){var t=this.renderer.gl;this.shader=new r(this.renderer.shaderManager),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),this.properties=[{attribute:this.shader.attributes.aVertexPosition,size:2,uploadFunction:this.uploadVertices,offset:0},{attribute:this.shader.attributes.aPositionCoord,size:2,uploadFunction:this.uploadPosition,offset:0},{attribute:this.shader.attributes.aRotation,size:1,uploadFunction:this.uploadRotation,offset:0},{attribute:this.shader.attributes.aTextureCoord,size:2,uploadFunction:this.uploadUvs,offset:0},{attribute:this.shader.attributes.aColor,size:1,uploadFunction:this.uploadAlpha,offset:0}]},l.prototype.start=function(){var t=this.renderer.gl;t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var e=this.shader;this.renderer.shaderManager.setShader(e)},l.prototype.render=function(t){var e=t.children,n=e.length,i=t._maxSize,s=t._batchSize;if(0!==n){n>i&&(n=i),t._buffers||(t._buffers=this.generateBuffers(t)),this.renderer.blendModeManager.setBlendMode(t.blendMode);var r=this.renderer.gl,a=t.worldTransform.copy(this.tempMatrix);a.prepend(this.renderer.currentRenderTarget.projectionMatrix),r.uniformMatrix3fv(this.shader.uniforms.projectionMatrix._location,!1,a.toArray(!0)),r.uniform1f(this.shader.uniforms.uAlpha._location,t.worldAlpha);var o=e[0]._texture.baseTexture;if(o._glTextures[r.id])r.bindTexture(r.TEXTURE_2D,o._glTextures[r.id]);else{if(!this.renderer.updateTexture(o))return;t._properties[0]&&t._properties[3]||(t._bufferToUpdate=0)}for(var l=0,u=0;l<n;l+=s,u+=1){var h=n-l;h>s&&(h=s);var p=t._buffers[u];p.uploadDynamic(e,l,h),t._bufferToUpdate===u&&(p.uploadStatic(e,l,h),t._bufferToUpdate=u+1),p.bind(this.shader),r.drawElements(r.TRIANGLES,6*h,r.UNSIGNED_SHORT,0),this.renderer.drawCount++}}},l.prototype.generateBuffers=function(t){var e,n=this.renderer.gl,i=[],s=t._maxSize,r=t._batchSize,o=t._properties;for(e=0;e<s;e+=r)i.push(new a(n,this.properties,o,r));return i},l.prototype.uploadVertices=function(t,e,n,i,s,r){for(var a,o,l,u,h,p,c,d,f,m=0;m<n;m++)o=(a=t[e+m])._texture,u=a.scale.x,h=a.scale.y,o.trim?(p=(c=(l=o.trim).x-a.anchor.x*l.width)+o.crop.width,d=(f=l.y-a.anchor.y*l.height)+o.crop.height):(p=o._frame.width*(1-a.anchor.x),c=o._frame.width*-a.anchor.x,d=o._frame.height*(1-a.anchor.y),f=o._frame.height*-a.anchor.y),i[r]=c*u,i[r+1]=f*h,i[r+s]=p*u,i[r+s+1]=f*h,i[r+2*s]=p*u,i[r+2*s+1]=d*h,i[r+3*s]=c*u,i[r+3*s+1]=d*h,r+=4*s},l.prototype.uploadPosition=function(t,e,n,i,s,r){for(var a=0;a<n;a++){var o=t[e+a].position;i[r]=o.x,i[r+1]=o.y,i[r+s]=o.x,i[r+s+1]=o.y,i[r+2*s]=o.x,i[r+2*s+1]=o.y,i[r+3*s]=o.x,i[r+3*s+1]=o.y,r+=4*s}},l.prototype.uploadRotation=function(t,e,n,i,s,r){for(var a=0;a<n;a++){var o=t[e+a].rotation;i[r]=o,i[r+s]=o,i[r+2*s]=o,i[r+3*s]=o,r+=4*s}},l.prototype.uploadUvs=function(t,e,n,i,s,r){for(var a=0;a<n;a++){var o=t[e+a]._texture._uvs;o?(i[r]=o.x0,i[r+1]=o.y0,i[r+s]=o.x1,i[r+s+1]=o.y1,i[r+2*s]=o.x2,i[r+2*s+1]=o.y2,i[r+3*s]=o.x3,i[r+3*s+1]=o.y3,r+=4*s):(i[r]=0,i[r+1]=0,i[r+s]=0,i[r+s+1]=0,i[r+2*s]=0,i[r+2*s+1]=0,i[r+3*s]=0,i[r+3*s+1]=0,r+=4*s)}},l.prototype.uploadAlpha=function(t,e,n,i,s,r){for(var a=0;a<n;a++){var o=t[e+a].alpha;i[r]=o,i[r+s]=o,i[r+2*s]=o,i[r+3*s]=o,r+=4*s}},l.prototype.destroy=function(){this.renderer.gl&&this.renderer.gl.deleteBuffer(this.indexBuffer),i.prototype.destroy.apply(this,arguments),this.shader.destroy(),this.indices=null,this.tempMatrix=null}},3646:(t,e,n)=>{var i=n(8297);function s(t){i.call(this,t,["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","uniform mat3 projectionMatrix;","varying vec2 vTextureCoord;","varying float vColor;","void main(void){"," vec2 v = aVertexPosition;"," v.x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);"," v.y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);"," v = v + aPositionCoord;"," gl_Position = vec4((projectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"].join("\n"),["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","uniform float uAlpha;","void main(void){"," vec4 color = texture2D(uSampler, vTextureCoord) * vColor * uAlpha;"," if (color.a == 0.0) discard;"," gl_FragColor = color;","}"].join("\n"),{uAlpha:{type:"1f",value:1}},{aPositionCoord:0,aRotation:0})}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s},6820:(t,e,n)=>{var i=n(501),s=n(4650),r=n(6192),a=n(5585);function o(t,e,n,o){if(a.call(this),i.sayHello(t),o)for(var l in r.DEFAULT_RENDER_OPTIONS)void 0===o[l]&&(o[l]=r.DEFAULT_RENDER_OPTIONS[l]);else o=r.DEFAULT_RENDER_OPTIONS;this.type=r.RENDERER_TYPE.UNKNOWN,this.width=e||800,this.height=n||600,this.view=o.view||document.createElement("canvas"),this.resolution=o.resolution,this.transparent=o.transparent,this.autoResize=o.autoResize||!1,this.blendModes=null,this.preserveDrawingBuffer=o.preserveDrawingBuffer,this.clearBeforeRender=o.clearBeforeRender,this.roundPixels=o.roundPixels,this._backgroundColor=0,this._backgroundColorRgb=[0,0,0],this._backgroundColorString="#000000",this.backgroundColor=o.backgroundColor||this._backgroundColor,this._tempDisplayObjectParent={worldTransform:new s.Matrix,worldAlpha:1,children:[]},this._lastObjectRendered=this._tempDisplayObjectParent}o.prototype=Object.create(a.prototype),o.prototype.constructor=o,t.exports=o,Object.defineProperties(o.prototype,{backgroundColor:{get:function(){return this._backgroundColor},set:function(t){this._backgroundColor=t,this._backgroundColorString=i.hex2string(t),i.hex2rgb(t,this._backgroundColorRgb)}}}),o.prototype.resize=function(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px")},o.prototype.destroy=function(t){t&&this.view.parentNode&&this.view.parentNode.removeChild(this.view),this.type=r.RENDERER_TYPE.UNKNOWN,this.width=0,this.height=0,this.view=null,this.resolution=0,this.transparent=!1,this.autoResize=!1,this.blendModes=null,this.preserveDrawingBuffer=!1,this.clearBeforeRender=!1,this.roundPixels=!1,this._backgroundColor=0,this._backgroundColorRgb=null,this._backgroundColorString=null}},8010:(t,e,n)=>{var i=n(6820),s=n(6871),r=n(501),a=n(4650),o=n(6192);function l(t,e,n){n=n||{},i.call(this,"Canvas",t,e,n),this.type=o.RENDERER_TYPE.CANVAS,this.context=this.view.getContext("2d",{alpha:this.transparent}),this.refresh=!0,this.maskManager=new s,this.smoothProperty="imageSmoothingEnabled",this.context.imageSmoothingEnabled||(this.context.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":this.context.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":this.context.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":this.context.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")),this.initPlugins(),this._mapBlendModes(),this._tempDisplayObjectParent={worldTransform:new a.Matrix,worldAlpha:1},this.resize(t,e)}l.prototype=Object.create(i.prototype),l.prototype.constructor=l,t.exports=l,r.pluginTarget.mixin(l),l.prototype.render=function(t){var e=t.parent;this._lastObjectRendered=t,t.parent=this._tempDisplayObjectParent,t.updateTransform(),t.parent=e,this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,this.context.globalCompositeOperation=this.blendModes[o.BLEND_MODES.NORMAL],navigator.isCocoonJS&&this.view.screencanvas&&(this.context.fillStyle="black",this.context.clear()),this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):(this.context.fillStyle=this._backgroundColorString,this.context.fillRect(0,0,this.width,this.height))),this.renderDisplayObject(t,this.context)},l.prototype.destroy=function(t){this.destroyPlugins(),i.prototype.destroy.call(this,t),this.context=null,this.refresh=!0,this.maskManager.destroy(),this.maskManager=null,this.smoothProperty=null},l.prototype.renderDisplayObject=function(t,e){var n=this.context;this.context=e,t.renderCanvas(this),this.context=n},l.prototype.resize=function(t,e){i.prototype.resize.call(this,t,e),this.smoothProperty&&(this.context[this.smoothProperty]=o.SCALE_MODES.DEFAULT===o.SCALE_MODES.LINEAR)},l.prototype._mapBlendModes=function(){this.blendModes||(this.blendModes={},r.canUseNewCanvasBlendModes()?(this.blendModes[o.BLEND_MODES.NORMAL]="source-over",this.blendModes[o.BLEND_MODES.ADD]="lighter",this.blendModes[o.BLEND_MODES.MULTIPLY]="multiply",this.blendModes[o.BLEND_MODES.SCREEN]="screen",this.blendModes[o.BLEND_MODES.OVERLAY]="overlay",this.blendModes[o.BLEND_MODES.DARKEN]="darken",this.blendModes[o.BLEND_MODES.LIGHTEN]="lighten",this.blendModes[o.BLEND_MODES.COLOR_DODGE]="color-dodge",this.blendModes[o.BLEND_MODES.COLOR_BURN]="color-burn",this.blendModes[o.BLEND_MODES.HARD_LIGHT]="hard-light",this.blendModes[o.BLEND_MODES.SOFT_LIGHT]="soft-light",this.blendModes[o.BLEND_MODES.DIFFERENCE]="difference",this.blendModes[o.BLEND_MODES.EXCLUSION]="exclusion",this.blendModes[o.BLEND_MODES.HUE]="hue",this.blendModes[o.BLEND_MODES.SATURATION]="saturate",this.blendModes[o.BLEND_MODES.COLOR]="color",this.blendModes[o.BLEND_MODES.LUMINOSITY]="luminosity"):(this.blendModes[o.BLEND_MODES.NORMAL]="source-over",this.blendModes[o.BLEND_MODES.ADD]="lighter",this.blendModes[o.BLEND_MODES.MULTIPLY]="source-over",this.blendModes[o.BLEND_MODES.SCREEN]="source-over",this.blendModes[o.BLEND_MODES.OVERLAY]="source-over",this.blendModes[o.BLEND_MODES.DARKEN]="source-over",this.blendModes[o.BLEND_MODES.LIGHTEN]="source-over",this.blendModes[o.BLEND_MODES.COLOR_DODGE]="source-over",this.blendModes[o.BLEND_MODES.COLOR_BURN]="source-over",this.blendModes[o.BLEND_MODES.HARD_LIGHT]="source-over",this.blendModes[o.BLEND_MODES.SOFT_LIGHT]="source-over",this.blendModes[o.BLEND_MODES.DIFFERENCE]="source-over",this.blendModes[o.BLEND_MODES.EXCLUSION]="source-over",this.blendModes[o.BLEND_MODES.HUE]="source-over",this.blendModes[o.BLEND_MODES.SATURATION]="source-over",this.blendModes[o.BLEND_MODES.COLOR]="source-over",this.blendModes[o.BLEND_MODES.LUMINOSITY]="source-over"))}},1549:t=>{function e(t,e){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.canvas.width=t,this.canvas.height=e}e.prototype.constructor=e,t.exports=e,Object.defineProperties(e.prototype,{width:{get:function(){return this.canvas.width},set:function(t){this.canvas.width=t}},height:{get:function(){return this.canvas.height},set:function(t){this.canvas.height=t}}}),e.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},e.prototype.resize=function(t,e){this.canvas.width=t,this.canvas.height=e},e.prototype.destroy=function(){this.context=null,this.canvas=null}},4694:(t,e,n)=>{var i=n(6192),s={};t.exports=s,s.renderGraphics=function(t,e){var n=t.worldAlpha;t.dirty&&(this.updateGraphicsTint(t),t.dirty=!1);for(var s=0;s<t.graphicsData.length;s++){var r=t.graphicsData[s],a=r.shape,o=r._fillTint,l=r._lineTint;if(e.lineWidth=r.lineWidth,r.type===i.SHAPES.POLY){e.beginPath();var u=a.points;e.moveTo(u[0],u[1]);for(var h=1;h<u.length/2;h++)e.lineTo(u[2*h],u[2*h+1]);a.closed&&e.lineTo(u[0],u[1]),u[0]===u[u.length-2]&&u[1]===u[u.length-1]&&e.closePath(),r.fill&&(e.globalAlpha=r.fillAlpha*n,e.fillStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.fill()),r.lineWidth&&(e.globalAlpha=r.lineAlpha*n,e.strokeStyle="#"+("00000"+(0|l).toString(16)).substr(-6),e.stroke())}else if(r.type===i.SHAPES.RECT)(r.fillColor||0===r.fillColor)&&(e.globalAlpha=r.fillAlpha*n,e.fillStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.fillRect(a.x,a.y,a.width,a.height)),r.lineWidth&&(e.globalAlpha=r.lineAlpha*n,e.strokeStyle="#"+("00000"+(0|l).toString(16)).substr(-6),e.strokeRect(a.x,a.y,a.width,a.height));else if(r.type===i.SHAPES.CIRC)e.beginPath(),e.arc(a.x,a.y,a.radius,0,2*Math.PI),e.closePath(),r.fill&&(e.globalAlpha=r.fillAlpha*n,e.fillStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.fill()),r.lineWidth&&(e.globalAlpha=r.lineAlpha*n,e.strokeStyle="#"+("00000"+(0|l).toString(16)).substr(-6),e.stroke());else if(r.type===i.SHAPES.ELIP){var p=2*a.width,c=2*a.height,d=a.x-p/2,f=a.y-c/2;e.beginPath();var m=.5522848,g=p/2*m,_=c/2*m,T=d+p,y=f+c,I=d+p/2,E=f+c/2;e.moveTo(d,E),e.bezierCurveTo(d,E-_,I-g,f,I,f),e.bezierCurveTo(I+g,f,T,E-_,T,E),e.bezierCurveTo(T,E+_,I+g,y,I,y),e.bezierCurveTo(I-g,y,d,E+_,d,E),e.closePath(),r.fill&&(e.globalAlpha=r.fillAlpha*n,e.fillStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.fill()),r.lineWidth&&(e.globalAlpha=r.lineAlpha*n,e.strokeStyle="#"+("00000"+(0|l).toString(16)).substr(-6),e.stroke())}else if(r.type===i.SHAPES.RREC){var b=a.x,v=a.y,w=a.width,S=a.height,x=a.radius,R=Math.min(w,S)/2|0;x=x>R?R:x,e.beginPath(),e.moveTo(b,v+x),e.lineTo(b,v+S-x),e.quadraticCurveTo(b,v+S,b+x,v+S),e.lineTo(b+w-x,v+S),e.quadraticCurveTo(b+w,v+S,b+w,v+S-x),e.lineTo(b+w,v+x),e.quadraticCurveTo(b+w,v,b+w-x,v),e.lineTo(b+x,v),e.quadraticCurveTo(b,v,b,v+x),e.closePath(),(r.fillColor||0===r.fillColor)&&(e.globalAlpha=r.fillAlpha*n,e.fillStyle="#"+("00000"+(0|o).toString(16)).substr(-6),e.fill()),r.lineWidth&&(e.globalAlpha=r.lineAlpha*n,e.strokeStyle="#"+("00000"+(0|l).toString(16)).substr(-6),e.stroke())}}},s.renderGraphicsMask=function(t,e){var n=t.graphicsData.length;if(0!==n){e.beginPath();for(var s=0;s<n;s++){var r=t.graphicsData[s],a=r.shape;if(r.type===i.SHAPES.POLY){var o=a.points;e.moveTo(o[0],o[1]);for(var l=1;l<o.length/2;l++)e.lineTo(o[2*l],o[2*l+1]);o[0]===o[o.length-2]&&o[1]===o[o.length-1]&&e.closePath()}else if(r.type===i.SHAPES.RECT)e.rect(a.x,a.y,a.width,a.height),e.closePath();else if(r.type===i.SHAPES.CIRC)e.arc(a.x,a.y,a.radius,0,2*Math.PI),e.closePath();else if(r.type===i.SHAPES.ELIP){var u=2*a.width,h=2*a.height,p=a.x-u/2,c=a.y-h/2,d=.5522848,f=u/2*d,m=h/2*d,g=p+u,_=c+h,T=p+u/2,y=c+h/2;e.moveTo(p,y),e.bezierCurveTo(p,y-m,T-f,c,T,c),e.bezierCurveTo(T+f,c,g,y-m,g,y),e.bezierCurveTo(g,y+m,T+f,_,T,_),e.bezierCurveTo(T-f,_,p,y+m,p,y),e.closePath()}else if(r.type===i.SHAPES.RREC){var I=a.x,E=a.y,b=a.width,v=a.height,w=a.radius,S=Math.min(b,v)/2|0;w=w>S?S:w,e.moveTo(I,E+w),e.lineTo(I,E+v-w),e.quadraticCurveTo(I,E+v,I+w,E+v),e.lineTo(I+b-w,E+v),e.quadraticCurveTo(I+b,E+v,I+b,E+v-w),e.lineTo(I+b,E+w),e.quadraticCurveTo(I+b,E,I+b-w,E),e.lineTo(I+w,E),e.quadraticCurveTo(I,E,I,E+w),e.closePath()}}}},s.updateGraphicsTint=function(t){if(16777215!==t.tint||t._prevTint!==t.tint){t._prevTint=t.tint;for(var e=(t.tint>>16&255)/255,n=(t.tint>>8&255)/255,i=(255&t.tint)/255,s=0;s<t.graphicsData.length;s++){var r=t.graphicsData[s],a=0|r.fillColor,o=0|r.lineColor;r._fillTint=((a>>16&255)/255*e*255<<16)+((a>>8&255)/255*n*255<<8)+(255&a)/255*i*255,r._lineTint=((o>>16&255)/255*e*255<<16)+((o>>8&255)/255*n*255<<8)+(255&o)/255*i*255}}}},6871:(t,e,n)=>{var i=n(4694);function s(){}s.prototype.constructor=s,t.exports=s,s.prototype.pushMask=function(t,e){e.context.save();var n=t.alpha,s=t.worldTransform,r=e.resolution;e.context.setTransform(s.a*r,s.b*r,s.c*r,s.d*r,s.tx*r,s.ty*r),t.texture||(i.renderGraphicsMask(t,e.context),e.context.clip()),t.worldAlpha=n},s.prototype.popMask=function(t){t.context.restore()},s.prototype.destroy=function(){}},7809:(t,e,n)=>{var i=n(501),s={};t.exports=s,s.getTintedTexture=function(t,e){var n=t.texture,i="#"+("00000"+(0|(e=s.roundColor(e))).toString(16)).substr(-6);if(n.tintCache=n.tintCache||{},n.tintCache[i])return n.tintCache[i];var r=s.canvas||document.createElement("canvas");if(s.tintMethod(n,e,r),s.convertTintToImage){var a=new Image;a.src=r.toDataURL(),n.tintCache[i]=a}else n.tintCache[i]=r,s.canvas=null;return r},s.tintWithMultiply=function(t,e,n){var i=n.getContext("2d"),s=t.baseTexture.resolution,r=t.crop.clone();r.x*=s,r.y*=s,r.width*=s,r.height*=s,n.width=r.width,n.height=r.height,i.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),i.fillRect(0,0,r.width,r.height),i.globalCompositeOperation="multiply",i.drawImage(t.baseTexture.source,r.x,r.y,r.width,r.height,0,0,r.width,r.height),i.globalCompositeOperation="destination-atop",i.drawImage(t.baseTexture.source,r.x,r.y,r.width,r.height,0,0,r.width,r.height)},s.tintWithOverlay=function(t,e,n){var i=n.getContext("2d"),s=t.baseTexture.resolution,r=t.crop.clone();r.x*=s,r.y*=s,r.width*=s,r.height*=s,n.width=r.width,n.height=r.height,i.globalCompositeOperation="copy",i.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),i.fillRect(0,0,r.width,r.height),i.globalCompositeOperation="destination-atop",i.drawImage(t.baseTexture.source,r.x,r.y,r.width,r.height,0,0,r.width,r.height)},s.tintWithPerPixel=function(t,e,n){var s=n.getContext("2d"),r=t.baseTexture.resolution,a=t.crop.clone();a.x*=r,a.y*=r,a.width*=r,a.height*=r,n.width=a.width,n.height=a.height,s.globalCompositeOperation="copy",s.drawImage(t.baseTexture.source,a.x,a.y,a.width,a.height,0,0,a.width,a.height);for(var o=i.hex2rgb(e),l=o[0],u=o[1],h=o[2],p=s.getImageData(0,0,a.width,a.height),c=p.data,d=0;d<c.length;d+=4)c[d+0]*=l,c[d+1]*=u,c[d+2]*=h;s.putImageData(p,0,0)},s.roundColor=function(t){var e=s.cacheStepsPerColorChannel,n=i.hex2rgb(t);return n[0]=Math.min(255,n[0]/e*e),n[1]=Math.min(255,n[1]/e*e),n[2]=Math.min(255,n[2]/e*e),i.rgb2hex(n)},s.cacheStepsPerColorChannel=8,s.convertTintToImage=!1,s.canUseMultiply=i.canUseNewCanvasBlendModes(),s.tintMethod=s.canUseMultiply?s.tintWithMultiply:s.tintWithPerPixel},5092:(t,e,n)=>{var i=n(6820),s=n(3779),r=n(9240),a=n(5468),o=n(4598),l=n(5396),u=n(7955),h=n(1830),p=n(1438),c=n(501),d=n(6192);function f(t,e,n){n=n||{},i.call(this,"WebGL",t,e,n),this.type=d.RENDERER_TYPE.WEBGL,this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this),this.view.addEventListener("webglcontextlost",this.handleContextLost,!1),this.view.addEventListener("webglcontextrestored",this.handleContextRestored,!1),this._useFXAA=!!n.forceFXAA&&n.antialias,this._FXAAFilter=null,this._contextOptions={alpha:this.transparent,antialias:n.antialias,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:n.preserveDrawingBuffer},this.drawCount=0,this.shaderManager=new s(this),this.maskManager=new r(this),this.stencilManager=new a(this),this.filterManager=new o(this),this.blendModeManager=new l(this),this.currentRenderTarget=null,this.currentRenderer=new h(this),this.initPlugins(),this._createContext(),this._initContext(),this._mapGlModes(),this._renderTargetStack=[]}f.prototype=Object.create(i.prototype),f.prototype.constructor=f,t.exports=f,c.pluginTarget.mixin(f),f.glContextId=0,f.prototype._createContext=function(){var t=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=t,!t)throw new Error("This browser does not support webGL. Try using the canvas renderer");this.glContextId=f.glContextId++,t.id=this.glContextId,t.renderer=this},f.prototype._initContext=function(){var t=this.gl;t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.enable(t.BLEND),this.renderTarget=new u(t,this.width,this.height,null,this.resolution,!0),this.setRenderTarget(this.renderTarget),this.emit("context",t),this.resize(this.width,this.height),this._useFXAA||(this._useFXAA=this._contextOptions.antialias&&!t.getContextAttributes().antialias),this._useFXAA&&(window.console.warn("FXAA antialiasing being used instead of native antialiasing"),this._FXAAFilter=[new p])},f.prototype.render=function(t){if(!this.gl.isContextLost()){this.drawCount=0,this._lastObjectRendered=t,this._useFXAA&&(this._FXAAFilter[0].uniforms.resolution.value.x=this.width,this._FXAAFilter[0].uniforms.resolution.value.y=this.height,t.filterArea=this.renderTarget.size,t.filters=this._FXAAFilter);var e=t.parent;t.parent=this._tempDisplayObjectParent,t.updateTransform(),t.parent=e;var n=this.gl;this.setRenderTarget(this.renderTarget),this.clearBeforeRender&&(this.transparent?n.clearColor(0,0,0,0):n.clearColor(this._backgroundColorRgb[0],this._backgroundColorRgb[1],this._backgroundColorRgb[2],1),n.clear(n.COLOR_BUFFER_BIT)),this.renderDisplayObject(t,this.renderTarget)}},f.prototype.renderDisplayObject=function(t,e,n){this.setRenderTarget(e),n&&e.clear(),this.filterManager.setFilterStack(e.filterStack),t.renderWebGL(this),this.currentRenderer.flush()},f.prototype.setObjectRenderer=function(t){this.currentRenderer!==t&&(this.currentRenderer.stop(),this.currentRenderer=t,this.currentRenderer.start())},f.prototype.setRenderTarget=function(t){this.currentRenderTarget!==t&&(this.currentRenderTarget=t,this.currentRenderTarget.activate(),this.stencilManager.setMaskStack(t.stencilMaskStack))},f.prototype.resize=function(t,e){i.prototype.resize.call(this,t,e),this.filterManager.resize(t,e),this.renderTarget.resize(t,e),this.currentRenderTarget===this.renderTarget&&(this.renderTarget.activate(),this.gl.viewport(0,0,this.width,this.height))},f.prototype.updateTexture=function(t){if((t=t.baseTexture||t).hasLoaded){var e=this.gl;return t._glTextures[e.id]||(t._glTextures[e.id]=e.createTexture(),t.on("update",this.updateTexture,this),t.on("dispose",this.destroyTexture,this)),e.bindTexture(e.TEXTURE_2D,t._glTextures[e.id]),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultipliedAlpha),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.source),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t.scaleMode===d.SCALE_MODES.LINEAR?e.LINEAR:e.NEAREST),t.mipmap&&t.isPowerOfTwo?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===d.SCALE_MODES.LINEAR?e.LINEAR_MIPMAP_LINEAR:e.NEAREST_MIPMAP_NEAREST),e.generateMipmap(e.TEXTURE_2D)):e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===d.SCALE_MODES.LINEAR?e.LINEAR:e.NEAREST),t.isPowerOfTwo?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),t._glTextures[e.id]}},f.prototype.destroyTexture=function(t){(t=t.baseTexture||t).hasLoaded&&t._glTextures[this.gl.id]&&this.gl.deleteTexture(t._glTextures[this.gl.id])},f.prototype.handleContextLost=function(t){t.preventDefault()},f.prototype.handleContextRestored=function(){for(var t in this._initContext(),c.BaseTextureCache)c.BaseTextureCache[t]._glTextures.length=0},f.prototype.destroy=function(t){for(var e in this.destroyPlugins(),this.view.removeEventListener("webglcontextlost",this.handleContextLost),this.view.removeEventListener("webglcontextrestored",this.handleContextRestored),c.BaseTextureCache){var n=c.BaseTextureCache[e];n.off("update",this.updateTexture,this),n.off("dispose",this.destroyTexture,this)}i.prototype.destroy.call(this,t),this.uid=0,this.shaderManager.destroy(),this.maskManager.destroy(),this.stencilManager.destroy(),this.filterManager.destroy(),this.blendModeManager.destroy(),this.shaderManager=null,this.maskManager=null,this.filterManager=null,this.blendModeManager=null,this.currentRenderer=null,this.handleContextLost=null,this.handleContextRestored=null,this._contextOptions=null,this.drawCount=0,this.gl.useProgram(null),this.gl=null},f.prototype._mapGlModes=function(){var t=this.gl;this.blendModes||(this.blendModes={},this.blendModes[d.BLEND_MODES.NORMAL]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.ADD]=[t.SRC_ALPHA,t.DST_ALPHA],this.blendModes[d.BLEND_MODES.MULTIPLY]=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.SCREEN]=[t.SRC_ALPHA,t.ONE],this.blendModes[d.BLEND_MODES.OVERLAY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.DARKEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.LIGHTEN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.COLOR_DODGE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.COLOR_BURN]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.HARD_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.SOFT_LIGHT]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.DIFFERENCE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.EXCLUSION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.HUE]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.SATURATION]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.COLOR]=[t.ONE,t.ONE_MINUS_SRC_ALPHA],this.blendModes[d.BLEND_MODES.LUMINOSITY]=[t.ONE,t.ONE_MINUS_SRC_ALPHA]),this.drawModes||(this.drawModes={},this.drawModes[d.DRAW_MODES.POINTS]=t.POINTS,this.drawModes[d.DRAW_MODES.LINES]=t.LINES,this.drawModes[d.DRAW_MODES.LINE_LOOP]=t.LINE_LOOP,this.drawModes[d.DRAW_MODES.LINE_STRIP]=t.LINE_STRIP,this.drawModes[d.DRAW_MODES.TRIANGLES]=t.TRIANGLES,this.drawModes[d.DRAW_MODES.TRIANGLE_STRIP]=t.TRIANGLE_STRIP,this.drawModes[d.DRAW_MODES.TRIANGLE_FAN]=t.TRIANGLE_FAN)}},580:(t,e,n)=>{var i=n(8297);function s(t,e,n){this.shaders=[],this.padding=0,this.uniforms=n||{},this.vertexSrc=t||i.defaultVertexSrc,this.fragmentSrc=e||i.defaultFragmentSrc}s.prototype.constructor=s,t.exports=s,s.prototype.getShader=function(t){var e=t.gl,n=this.shaders[e.id];return n||(n=new i(t.shaderManager,this.vertexSrc,this.fragmentSrc,this.uniforms,this.attributes),this.shaders[e.id]=n),n},s.prototype.applyFilter=function(t,e,n,i){var s=this.getShader(t);t.filterManager.applyFilter(s,e,n,i)},s.prototype.syncUniform=function(t){for(var e=0,n=this.shaders.length;e<n;++e)this.shaders[e].syncUniform(t)}},1438:(t,e,n)=>{var i=n(580),s=n(7425);function r(){i.call(this,s.readFileSync("//FXAA.vert","utf8"),s.readFileSync("//FXAA.frag","utf8"),{resolution:{type:"v2",value:{x:1,y:1}}})}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n){var i=t.filterManager,s=this.getShader(t);i.applyFilter(s,e,n)}},5207:(t,e,n)=>{var i=n(580),s=n(4650),r=n(7425);function a(t){var e=new s.Matrix;i.call(this,r.readFileSync("//spriteMaskFilter.vert","utf8"),r.readFileSync("//spriteMaskFilter.frag","utf8"),{mask:{type:"sampler2D",value:t._texture},alpha:{type:"f",value:1},otherMatrix:{type:"mat3",value:e.toArray(!0)}}),this.maskSprite=t,this.maskMatrix=e}a.prototype=Object.create(i.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.applyFilter=function(t,e,n){var i=t.filterManager;this.uniforms.mask.value=this.maskSprite._texture,i.calculateMappedMatrix(e.frame,this.maskSprite,this.maskMatrix),this.uniforms.otherMatrix.value=this.maskMatrix.toArray(!0),this.uniforms.alpha.value=this.maskSprite.worldAlpha;var s=this.getShader(t);i.applyFilter(s,e,n)},Object.defineProperties(a.prototype,{map:{get:function(){return this.uniforms.mask.value},set:function(t){this.uniforms.mask.value=t}},offset:{get:function(){return this.uniforms.offset.value},set:function(t){this.uniforms.offset.value=t}}})},5396:(t,e,n)=>{var i=n(1103);function s(t){i.call(this,t),this.currentBlendMode=99999}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s,s.prototype.setBlendMode=function(t){if(this.currentBlendMode===t)return!1;this.currentBlendMode=t;var e=this.renderer.blendModes[this.currentBlendMode];return this.renderer.gl.blendFunc(e[0],e[1]),!0}},4598:(t,e,n)=>{var i=n(1103),s=n(7955),r=n(6192),a=n(3885),o=n(4650);function l(t){i.call(this,t),this.filterStack=[],this.filterStack.push({renderTarget:t.currentRenderTarget,filter:[],bounds:null}),this.texturePool=[],this.textureSize=new o.Rectangle(0,0,t.width,t.height),this.currentFrame=null}l.prototype=Object.create(i.prototype),l.prototype.constructor=l,t.exports=l,l.prototype.onContextChange=function(){this.texturePool.length=0;var t=this.renderer.gl;this.quad=new a(t)},l.prototype.setFilterStack=function(t){this.filterStack=t},l.prototype.pushFilter=function(t,e){var n=t.filterArea?t.filterArea.clone():t.getBounds();n.x=0|n.x,n.y=0|n.y,n.width=0|n.width,n.height=0|n.height;var i=0|e[0].padding;if(n.x-=i,n.y-=i,n.width+=2*i,n.height+=2*i,this.renderer.currentRenderTarget.transform){var s=this.renderer.currentRenderTarget.transform;n.x+=s.tx,n.y+=s.ty,this.capFilterArea(n),n.x-=s.tx,n.y-=s.ty}else this.capFilterArea(n);if(n.width>0&&n.height>0){this.currentFrame=n;var r=this.getRenderTarget();this.renderer.setRenderTarget(r),r.clear(),this.filterStack.push({renderTarget:r,filter:e})}else this.filterStack.push({renderTarget:null,filter:e})},l.prototype.popFilter=function(){var t=this.filterStack.pop(),e=this.filterStack[this.filterStack.length-1],n=t.renderTarget;if(t.renderTarget){var i=e.renderTarget,s=this.renderer.gl;this.currentFrame=n.frame,this.quad.map(this.textureSize,n.frame),s.bindBuffer(s.ARRAY_BUFFER,this.quad.vertexBuffer),s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,this.quad.indexBuffer);var a=t.filter;if(s.vertexAttribPointer(this.renderer.shaderManager.defaultShader.attributes.aVertexPosition,2,s.FLOAT,!1,0,0),s.vertexAttribPointer(this.renderer.shaderManager.defaultShader.attributes.aTextureCoord,2,s.FLOAT,!1,0,32),s.vertexAttribPointer(this.renderer.shaderManager.defaultShader.attributes.aColor,4,s.FLOAT,!1,0,64),this.renderer.blendModeManager.setBlendMode(r.BLEND_MODES.NORMAL),1===a.length)a[0].uniforms.dimensions&&(a[0].uniforms.dimensions.value[0]=this.renderer.width,a[0].uniforms.dimensions.value[1]=this.renderer.height,a[0].uniforms.dimensions.value[2]=this.quad.vertices[0],a[0].uniforms.dimensions.value[3]=this.quad.vertices[5]),a[0].applyFilter(this.renderer,n,i),this.returnRenderTarget(n);else{for(var o=n,l=this.getRenderTarget(!0),u=0;u<a.length-1;u++){var h=a[u];h.uniforms.dimensions&&(h.uniforms.dimensions.value[0]=this.renderer.width,h.uniforms.dimensions.value[1]=this.renderer.height,h.uniforms.dimensions.value[2]=this.quad.vertices[0],h.uniforms.dimensions.value[3]=this.quad.vertices[5]),h.applyFilter(this.renderer,o,l);var p=o;o=l,l=p}a[a.length-1].applyFilter(this.renderer,o,i),this.returnRenderTarget(o),this.returnRenderTarget(l)}return t.filter}},l.prototype.getRenderTarget=function(t){var e=this.texturePool.pop()||new s(this.renderer.gl,this.textureSize.width,this.textureSize.height,r.SCALE_MODES.LINEAR,this.renderer.resolution*r.FILTER_RESOLUTION);return e.frame=this.currentFrame,t&&e.clear(!0),e},l.prototype.returnRenderTarget=function(t){this.texturePool.push(t)},l.prototype.applyFilter=function(t,e,n,i){var s=this.renderer.gl;this.renderer.setRenderTarget(n),i&&n.clear(),this.renderer.shaderManager.setShader(t),t.uniforms.projectionMatrix.value=this.renderer.currentRenderTarget.projectionMatrix.toArray(!0),t.syncUniforms(),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,e.texture),s.drawElements(s.TRIANGLES,6,s.UNSIGNED_SHORT,0),this.renderer.drawCount++},l.prototype.calculateMappedMatrix=function(t,e,n){var i=e.worldTransform.copy(o.Matrix.TEMP_MATRIX),s=e._texture.baseTexture,r=n.identity(),a=this.textureSize.height/this.textureSize.width;r.translate(t.x/this.textureSize.width,t.y/this.textureSize.height),r.scale(1,a);var l=this.textureSize.width/s.width,u=this.textureSize.height/s.height;return i.tx/=s.width*l,i.ty/=s.width*l,i.invert(),r.prepend(i),r.scale(1,1/a),r.scale(l,u),r.translate(e.anchor.x,e.anchor.y),r},l.prototype.capFilterArea=function(t){t.x<0&&(t.width+=t.x,t.x=0),t.y<0&&(t.height+=t.y,t.y=0),t.x+t.width>this.textureSize.width&&(t.width=this.textureSize.width-t.x),t.y+t.height>this.textureSize.height&&(t.height=this.textureSize.height-t.y)},l.prototype.resize=function(t,e){this.textureSize.width=t,this.textureSize.height=e;for(var n=0;n<this.texturePool.length;n++)this.texturePool[n].resize(t,e)},l.prototype.destroy=function(){this.quad.destroy(),i.prototype.destroy.call(this),this.filterStack=null,this.offsetY=0;for(var t=0;t<this.texturePool.length;t++)this.texturePool[t].destroy();this.texturePool=null}},9240:(t,e,n)=>{var i=n(1103),s=n(5207);function r(t){i.call(this,t),this.stencilStack=[],this.reverse=!0,this.count=0,this.alphaMaskPool=[]}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.pushMask=function(t,e){e.texture?this.pushSpriteMask(t,e):this.pushStencilMask(t,e)},r.prototype.popMask=function(t,e){e.texture?this.popSpriteMask(t,e):this.popStencilMask(t,e)},r.prototype.pushSpriteMask=function(t,e){var n=this.alphaMaskPool.pop();n||(n=[new s(e)]),n[0].maskSprite=e,this.renderer.filterManager.pushFilter(t,n)},r.prototype.popSpriteMask=function(){var t=this.renderer.filterManager.popFilter();this.alphaMaskPool.push(t)},r.prototype.pushStencilMask=function(t,e){this.renderer.stencilManager.pushMask(e)},r.prototype.popStencilMask=function(t,e){this.renderer.stencilManager.popMask(e)}},3779:(t,e,n)=>{var i=n(1103),s=n(8297),r=n(7151),a=n(9691),o=n(501);function l(t){i.call(this,t),this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var e=0;e<this.maxAttibs;e++)this.attribState[e]=!1;this.stack=[],this._currentId=-1,this.currentShader=null}l.prototype=Object.create(i.prototype),l.prototype.constructor=l,o.pluginTarget.mixin(l),t.exports=l,l.prototype.onContextChange=function(){this.initPlugins();var t=this.renderer.gl;this.maxAttibs=t.getParameter(t.MAX_VERTEX_ATTRIBS),this.attribState=[];for(var e=0;e<this.maxAttibs;e++)this.attribState[e]=!1;this.defaultShader=new s(this),this.primitiveShader=new a(this),this.complexPrimitiveShader=new r(this)},l.prototype.setAttribs=function(t){var e;for(e=0;e<this.tempAttribState.length;e++)this.tempAttribState[e]=!1;for(var n in t)this.tempAttribState[t[n]]=!0;var i=this.renderer.gl;for(e=0;e<this.attribState.length;e++)this.attribState[e]!==this.tempAttribState[e]&&(this.attribState[e]=this.tempAttribState[e],this.attribState[e]?i.enableVertexAttribArray(e):i.disableVertexAttribArray(e))},l.prototype.setShader=function(t){return this._currentId!==t.uid&&(this._currentId=t.uid,this.currentShader=t,this.renderer.gl.useProgram(t.program),this.setAttribs(t.attributes),!0)},l.prototype.destroy=function(){this.primitiveShader.destroy(),this.complexPrimitiveShader.destroy(),i.prototype.destroy.call(this),this.destroyPlugins(),this.attribState=null,this.tempAttribState=null}},5468:(t,e,n)=>{var i=n(1103),s=n(501);function r(t){i.call(this,t),this.stencilMaskStack=null}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.setMaskStack=function(t){this.stencilMaskStack=t;var e=this.renderer.gl;0===t.stencilStack.length?e.disable(e.STENCIL_TEST):e.enable(e.STENCIL_TEST)},r.prototype.pushStencil=function(t,e){this.renderer.currentRenderTarget.attachStencilBuffer();var n=this.renderer.gl,i=this.stencilMaskStack;this.bindGraphics(t,e),0===i.stencilStack.length&&(n.enable(n.STENCIL_TEST),n.clear(n.STENCIL_BUFFER_BIT),i.reverse=!0,i.count=0),i.stencilStack.push(e);var s=i.count;n.colorMask(!1,!1,!1,!1),n.stencilFunc(n.ALWAYS,0,255),n.stencilOp(n.KEEP,n.KEEP,n.INVERT),1===e.mode?(n.drawElements(n.TRIANGLE_FAN,e.indices.length-4,n.UNSIGNED_SHORT,0),i.reverse?(n.stencilFunc(n.EQUAL,255-s,255),n.stencilOp(n.KEEP,n.KEEP,n.DECR)):(n.stencilFunc(n.EQUAL,s,255),n.stencilOp(n.KEEP,n.KEEP,n.INCR)),n.drawElements(n.TRIANGLE_FAN,4,n.UNSIGNED_SHORT,2*(e.indices.length-4)),i.reverse?n.stencilFunc(n.EQUAL,255-(s+1),255):n.stencilFunc(n.EQUAL,s+1,255),i.reverse=!i.reverse):(i.reverse?(n.stencilFunc(n.EQUAL,s,255),n.stencilOp(n.KEEP,n.KEEP,n.INCR)):(n.stencilFunc(n.EQUAL,255-s,255),n.stencilOp(n.KEEP,n.KEEP,n.DECR)),n.drawElements(n.TRIANGLE_STRIP,e.indices.length,n.UNSIGNED_SHORT,0),i.reverse?n.stencilFunc(n.EQUAL,s+1,255):n.stencilFunc(n.EQUAL,255-(s+1),255)),n.colorMask(!0,!0,!0,!0),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),i.count++},r.prototype.bindGraphics=function(t,e){var n,i=this.renderer.gl;1===e.mode?(n=this.renderer.shaderManager.complexPrimitiveShader,this.renderer.shaderManager.setShader(n),i.uniformMatrix3fv(n.uniforms.translationMatrix._location,!1,t.worldTransform.toArray(!0)),i.uniformMatrix3fv(n.uniforms.projectionMatrix._location,!1,this.renderer.currentRenderTarget.projectionMatrix.toArray(!0)),i.uniform3fv(n.uniforms.tint._location,s.hex2rgb(t.tint)),i.uniform3fv(n.uniforms.color._location,e.color),i.uniform1f(n.uniforms.alpha._location,t.worldAlpha),i.bindBuffer(i.ARRAY_BUFFER,e.buffer),i.vertexAttribPointer(n.attributes.aVertexPosition,2,i.FLOAT,!1,8,0),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.indexBuffer)):(n=this.renderer.shaderManager.primitiveShader,this.renderer.shaderManager.setShader(n),i.uniformMatrix3fv(n.uniforms.translationMatrix._location,!1,t.worldTransform.toArray(!0)),i.uniformMatrix3fv(n.uniforms.projectionMatrix._location,!1,this.renderer.currentRenderTarget.projectionMatrix.toArray(!0)),i.uniform3fv(n.uniforms.tint._location,s.hex2rgb(t.tint)),i.uniform1f(n.uniforms.alpha._location,t.worldAlpha),i.bindBuffer(i.ARRAY_BUFFER,e.buffer),i.vertexAttribPointer(n.attributes.aVertexPosition,2,i.FLOAT,!1,24,0),i.vertexAttribPointer(n.attributes.aColor,4,i.FLOAT,!1,24,8),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.indexBuffer))},r.prototype.popStencil=function(t,e){var n=this.renderer.gl,i=this.stencilMaskStack;if(i.stencilStack.pop(),i.count--,0===i.stencilStack.length)n.disable(n.STENCIL_TEST);else{var s=i.count;this.bindGraphics(t,e),n.colorMask(!1,!1,!1,!1),1===e.mode?(i.reverse=!i.reverse,i.reverse?(n.stencilFunc(n.EQUAL,255-(s+1),255),n.stencilOp(n.KEEP,n.KEEP,n.INCR)):(n.stencilFunc(n.EQUAL,s+1,255),n.stencilOp(n.KEEP,n.KEEP,n.DECR)),n.drawElements(n.TRIANGLE_FAN,4,n.UNSIGNED_SHORT,2*(e.indices.length-4)),n.stencilFunc(n.ALWAYS,0,255),n.stencilOp(n.KEEP,n.KEEP,n.INVERT),n.drawElements(n.TRIANGLE_FAN,e.indices.length-4,n.UNSIGNED_SHORT,0),this.renderer.drawCount+=2,i.reverse?n.stencilFunc(n.EQUAL,s,255):n.stencilFunc(n.EQUAL,255-s,255)):(i.reverse?(n.stencilFunc(n.EQUAL,s+1,255),n.stencilOp(n.KEEP,n.KEEP,n.DECR)):(n.stencilFunc(n.EQUAL,255-(s+1),255),n.stencilOp(n.KEEP,n.KEEP,n.INCR)),n.drawElements(n.TRIANGLE_STRIP,e.indices.length,n.UNSIGNED_SHORT,0),this.renderer.drawCount++,i.reverse?n.stencilFunc(n.EQUAL,s,255):n.stencilFunc(n.EQUAL,255-s,255)),n.colorMask(!0,!0,!0,!0),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)}},r.prototype.destroy=function(){i.prototype.destroy.call(this),this.stencilMaskStack.stencilStack=null},r.prototype.pushMask=function(t){this.renderer.setObjectRenderer(this.renderer.plugins.graphics),t.dirty&&this.renderer.plugins.graphics.updateGraphics(t,this.renderer.gl),t._webGL[this.renderer.gl.id].data.length&&this.pushStencil(t,t._webGL[this.renderer.gl.id].data[0])},r.prototype.popMask=function(t){this.renderer.setObjectRenderer(this.renderer.plugins.graphics),this.popStencil(t,t._webGL[this.renderer.gl.id].data[0])}},1103:t=>{function e(t){this.renderer=t,this.renderer.on("context",this.onContextChange,this)}e.prototype.constructor=e,t.exports=e,e.prototype.onContextChange=function(){},e.prototype.destroy=function(){this.renderer.off("context",this.onContextChange,this),this.renderer=null}},7151:(t,e,n)=>{var i=n(8306);function s(t){i.call(this,t,["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform mat3 projectionMatrix;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"].join("\n"),["precision mediump float;","varying vec4 vColor;","void main(void){"," gl_FragColor = vColor;","}"].join("\n"),{tint:{type:"3f",value:[0,0,0]},alpha:{type:"1f",value:0},color:{type:"3f",value:[0,0,0]},translationMatrix:{type:"mat3",value:new Float32Array(9)},projectionMatrix:{type:"mat3",value:new Float32Array(9)}},{aVertexPosition:0})}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s},9691:(t,e,n)=>{var i=n(8306);function s(t){i.call(this,t,["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform mat3 projectionMatrix;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"].join("\n"),["precision mediump float;","varying vec4 vColor;","void main(void){"," gl_FragColor = vColor;","}"].join("\n"),{tint:{type:"3f",value:[0,0,0]},alpha:{type:"1f",value:0},translationMatrix:{type:"mat3",value:new Float32Array(9)},projectionMatrix:{type:"mat3",value:new Float32Array(9)}},{aVertexPosition:0,aColor:0})}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s},8306:(t,e,n)=>{var i=n(501);function s(t,e,n,s,r){if(!e||!n)throw new Error("Pixi.js Error. Shader requires vertexSrc and fragmentSrc");this.uid=i.uid(),this.gl=t.renderer.gl,this.shaderManager=t,this.program=null,this.uniforms=s||{},this.attributes=r||{},this.textureCount=1,this.vertexSrc=e,this.fragmentSrc=n,this.init()}s.prototype.constructor=s,t.exports=s,s.prototype.init=function(){this.compile(),this.gl.useProgram(this.program),this.cacheUniformLocations(Object.keys(this.uniforms)),this.cacheAttributeLocations(Object.keys(this.attributes))},s.prototype.cacheUniformLocations=function(t){for(var e=0;e<t.length;++e)this.uniforms[t[e]]._location=this.gl.getUniformLocation(this.program,t[e])},s.prototype.cacheAttributeLocations=function(t){for(var e=0;e<t.length;++e)this.attributes[t[e]]=this.gl.getAttribLocation(this.program,t[e])},s.prototype.compile=function(){var t=this.gl,e=this._glCompile(t.VERTEX_SHADER,this.vertexSrc),n=this._glCompile(t.FRAGMENT_SHADER,this.fragmentSrc),i=t.createProgram();return t.attachShader(i,e),t.attachShader(i,n),t.linkProgram(i),t.getProgramParameter(i,t.LINK_STATUS)||(console.error("Pixi.js Error: Could not initialize shader."),console.error("gl.VALIDATE_STATUS",t.getProgramParameter(i,t.VALIDATE_STATUS)),console.error("gl.getError()",t.getError()),""!==t.getProgramInfoLog(i)&&console.warn("Pixi.js Warning: gl.getProgramInfoLog()",t.getProgramInfoLog(i)),t.deleteProgram(i),i=null),t.deleteShader(e),t.deleteShader(n),this.program=i},s.prototype.syncUniform=function(t){var e,n,s=t._location,r=t.value,a=this.gl;switch(t.type){case"b":case"bool":case"boolean":a.uniform1i(s,r?1:0);break;case"i":case"1i":a.uniform1i(s,r);break;case"f":case"1f":a.uniform1f(s,r);break;case"2f":a.uniform2f(s,r[0],r[1]);break;case"3f":a.uniform3f(s,r[0],r[1],r[2]);break;case"4f":a.uniform4f(s,r[0],r[1],r[2],r[3]);break;case"v2":a.uniform2f(s,r.x,r.y);break;case"v3":a.uniform3f(s,r.x,r.y,r.z);break;case"v4":a.uniform4f(s,r.x,r.y,r.z,r.w);break;case"1iv":case"iv1":a.uniform1iv(s,r);break;case"2iv":a.uniform2iv(s,r);break;case"3iv":case"iv":a.uniform3iv(s,r);break;case"4iv":a.uniform4iv(s,r);break;case"1fv":case"fv1":a.uniform1fv(s,r);break;case"2fv":a.uniform2fv(s,r);break;case"3fv":case"fv":a.uniform3fv(s,r);break;case"4fv":a.uniform4fv(s,r);break;case"m2":case"mat2":case"Matrix2fv":a.uniformMatrix2fv(s,t.transpose,r);break;case"m3":case"mat3":case"Matrix3fv":a.uniformMatrix3fv(s,t.transpose,r);break;case"m4":case"mat4":case"Matrix4fv":a.uniformMatrix4fv(s,t.transpose,r);break;case"c":"number"==typeof r&&(r=i.hex2rgb(r)),a.uniform3f(s,r[0],r[1],r[2]);break;case"v2v":for(t._array||(t._array=new Float32Array(2*r.length)),e=0,n=r.length;e<n;++e)t._array[2*e]=r[e].x,t._array[2*e+1]=r[e].y;a.uniform2fv(s,t._array);break;case"v3v":for(t._array||(t._array=new Float32Array(3*r.length)),e=0,n=r.length;e<n;++e)t._array[3*e]=r[e].x,t._array[3*e+1]=r[e].y,t._array[3*e+2]=r[e].z;a.uniform3fv(s,t._array);break;case"v4v":for(t._array||(t._array=new Float32Array(4*r.length)),e=0,n=r.length;e<n;++e)t._array[4*e]=r[e].x,t._array[4*e+1]=r[e].y,t._array[4*e+2]=r[e].z,t._array[4*e+3]=r[e].w;a.uniform4fv(s,t._array);break;case"t":case"sampler2D":if(!t.value||!t.value.baseTexture.hasLoaded)break;a.activeTexture(a["TEXTURE"+this.textureCount]);var o=t.value.baseTexture._glTextures[a.id];o||(this.initSampler2D(t),o=t.value.baseTexture._glTextures[a.id]),a.bindTexture(a.TEXTURE_2D,o),a.uniform1i(t._location,this.textureCount),this.textureCount++;break;default:console.warn("Pixi.js Shader Warning: Unknown uniform type: "+t.type)}},s.prototype.syncUniforms=function(){for(var t in this.textureCount=1,this.uniforms)this.syncUniform(this.uniforms[t])},s.prototype.initSampler2D=function(t){var e=this.gl,n=t.value.baseTexture;if(n.hasLoaded)if(t.textureData){var i=t.textureData;n._glTextures[e.id]=e.createTexture(),e.bindTexture(e.TEXTURE_2D,n._glTextures[e.id]),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultipliedAlpha),e.texImage2D(e.TEXTURE_2D,0,i.luminance?e.LUMINANCE:e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n.source),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,i.magFilter?i.magFilter:e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,i.wrapS?i.wrapS:e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,i.wrapS?i.wrapS:e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,i.wrapT?i.wrapT:e.CLAMP_TO_EDGE)}else this.shaderManager.renderer.updateTexture(n)},s.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.gl=null,this.uniforms=null,this.attributes=null,this.vertexSrc=null,this.fragmentSrc=null},s.prototype._glCompile=function(t,e){var n=this.gl.createShader(t);return this.gl.shaderSource(n,e),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)?n:(console.log(this.gl.getShaderInfoLog(n)),null)}},8297:(t,e,n)=>{var i=n(8306);function s(t,e,n,r,a){var o={uSampler:{type:"sampler2D",value:0},projectionMatrix:{type:"mat3",value:new Float32Array([1,0,0,0,1,0,0,0,1])}};if(r)for(var l in r)o[l]=r[l];var u={aVertexPosition:0,aTextureCoord:0,aColor:0};if(a)for(var h in a)u[h]=a[h];e=e||s.defaultVertexSrc,n=n||s.defaultFragmentSrc,i.call(this,t,e,n,o,u)}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s,s.defaultVertexSrc=["precision lowp float;","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform mat3 projectionMatrix;","varying vec2 vTextureCoord;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"].join("\n"),s.defaultFragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void){"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"].join("\n")},1830:(t,e,n)=>{var i=n(1103);function s(t){i.call(this,t)}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s,s.prototype.start=function(){},s.prototype.stop=function(){this.flush()},s.prototype.flush=function(){},s.prototype.render=function(t){}},3885:t=>{function e(t){this.gl=t,this.vertices=new Float32Array([0,0,200,0,200,200,0,200]),this.uvs=new Float32Array([0,0,1,0,1,1,0,1]),this.colors=new Float32Array([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]),this.indices=new Uint16Array([0,1,2,0,3,2]),this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,128,t.DYNAMIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),this.upload()}e.prototype.constructor=e,e.prototype.map=function(t,e){var n=0,i=0;this.uvs[0]=n,this.uvs[1]=i,this.uvs[2]=n+e.width/t.width,this.uvs[3]=i,this.uvs[4]=n+e.width/t.width,this.uvs[5]=i+e.height/t.height,this.uvs[6]=n,this.uvs[7]=i+e.height/t.height,n=e.x,i=e.y,this.vertices[0]=n,this.vertices[1]=i,this.vertices[2]=n+e.width,this.vertices[3]=i,this.vertices[4]=n+e.width,this.vertices[5]=i+e.height,this.vertices[6]=n,this.vertices[7]=i+e.height,this.upload()},e.prototype.upload=function(){var t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices),t.bufferSubData(t.ARRAY_BUFFER,32,this.uvs),t.bufferSubData(t.ARRAY_BUFFER,64,this.colors)},e.prototype.destroy=function(){var t=this.gl;t.deleteBuffer(this.vertexBuffer),t.deleteBuffer(this.indexBuffer)},t.exports=e},7955:(t,e,n)=>{var i=n(4650),s=n(501),r=n(6192),a=n(8614),o=function(t,e,n,o,l,u){(this.gl=t,this.frameBuffer=null,this.texture=null,this.size=new i.Rectangle(0,0,1,1),this.resolution=l||r.RESOLUTION,this.projectionMatrix=new i.Matrix,this.transform=null,this.frame=null,this.stencilBuffer=null,this.stencilMaskStack=new a,this.filterStack=[{renderTarget:this,filter:[],bounds:this.size}],this.scaleMode=o||r.SCALE_MODES.DEFAULT,this.root=u,this.root)||(this.frameBuffer=t.createFramebuffer(),this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,o===r.SCALE_MODES.LINEAR?t.LINEAR:t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,o===r.SCALE_MODES.LINEAR?t.LINEAR:t.NEAREST),s.isPowerOfTwo(e,n)?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT)):(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),t.bindFramebuffer(t.FRAMEBUFFER,this.frameBuffer),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.texture,0));this.resize(e,n)};o.prototype.constructor=o,t.exports=o,o.prototype.clear=function(t){var e=this.gl;t&&e.bindFramebuffer(e.FRAMEBUFFER,this.frameBuffer),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)},o.prototype.attachStencilBuffer=function(){if(!this.stencilBuffer&&!this.root){var t=this.gl;this.stencilBuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.stencilBuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,this.stencilBuffer),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,this.size.width*this.resolution,this.size.height*this.resolution)}},o.prototype.activate=function(){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.frameBuffer);var e=this.frame||this.size;this.calculateProjection(e),this.transform&&this.projectionMatrix.append(this.transform),t.viewport(0,0,e.width*this.resolution,e.height*this.resolution)},o.prototype.calculateProjection=function(t){var e=this.projectionMatrix;e.identity(),this.root?(e.a=1/t.width*2,e.d=-1/t.height*2,e.tx=-1-t.x*e.a,e.ty=1-t.y*e.d):(e.a=1/t.width*2,e.d=1/t.height*2,e.tx=-1-t.x*e.a,e.ty=-1-t.y*e.d)},o.prototype.resize=function(t,e){if(t|=0,e|=0,this.size.width!==t||this.size.height!==e){if(this.size.width=t,this.size.height=e,!this.root){var n=this.gl;n.bindTexture(n.TEXTURE_2D,this.texture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t*this.resolution,e*this.resolution,0,n.RGBA,n.UNSIGNED_BYTE,null),this.stencilBuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,this.stencilBuffer),n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,t*this.resolution,e*this.resolution))}var i=this.frame||this.size;this.calculateProjection(i)}},o.prototype.destroy=function(){var t=this.gl;t.deleteRenderbuffer(this.stencilBuffer),t.deleteFramebuffer(this.frameBuffer),t.deleteTexture(this.texture),this.frameBuffer=null,this.texture=null}},8614:t=>{function e(){this.stencilStack=[],this.reverse=!0,this.count=0}e.prototype.constructor=e,t.exports=e},2861:(t,e,n)=>{var i=n(4650),s=n(2699),r=n(7673),a=n(7809),o=n(501),l=n(6192),u=new i.Point;function h(t){r.call(this),this.anchor=new i.Point,this._texture=null,this._width=0,this._height=0,this.tint=16777215,this.blendMode=l.BLEND_MODES.NORMAL,this.shader=null,this.cachedTint=16777215,this.texture=t||s.EMPTY}h.prototype=Object.create(r.prototype),h.prototype.constructor=h,t.exports=h,Object.defineProperties(h.prototype,{width:{get:function(){return Math.abs(this.scale.x)*this.texture._frame.width},set:function(t){this.scale.x=o.sign(this.scale.x)*t/this.texture._frame.width,this._width=t}},height:{get:function(){return Math.abs(this.scale.y)*this.texture._frame.height},set:function(t){this.scale.y=o.sign(this.scale.y)*t/this.texture._frame.height,this._height=t}},texture:{get:function(){return this._texture},set:function(t){this._texture!==t&&(this._texture=t,this.cachedTint=16777215,t&&(t.baseTexture.hasLoaded?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}}),h.prototype._onTextureUpdate=function(){this._width&&(this.scale.x=o.sign(this.scale.x)*this._width/this.texture.frame.width),this._height&&(this.scale.y=o.sign(this.scale.y)*this._height/this.texture.frame.height)},h.prototype._renderWebGL=function(t){t.setObjectRenderer(t.plugins.sprite),t.plugins.sprite.render(this)},h.prototype.getBounds=function(t){if(!this._currentBounds){var e,n,i,s,r=this._texture._frame.width,a=this._texture._frame.height,o=r*(1-this.anchor.x),l=r*-this.anchor.x,u=a*(1-this.anchor.y),h=a*-this.anchor.y,p=t||this.worldTransform,c=p.a,d=p.b,f=p.c,m=p.d,g=p.tx,_=p.ty;if(0===d&&0===f)c<0&&(c*=-1),m<0&&(m*=-1),e=c*l+g,n=c*o+g,i=m*h+_,s=m*u+_;else{var T=c*l+f*h+g,y=m*h+d*l+_,I=c*o+f*h+g,E=m*h+d*o+_,b=c*o+f*u+g,v=m*u+d*o+_,w=c*l+f*u+g,S=m*u+d*l+_;e=w<(e=b<(e=I<(e=T)?I:e)?b:e)?w:e,i=S<(i=v<(i=E<(i=y)?E:i)?v:i)?S:i,n=w>(n=b>(n=I>(n=T)?I:n)?b:n)?w:n,s=S>(s=v>(s=E>(s=y)?E:s)?v:s)?S:s}if(this.children.length){var x=this.containerGetBounds();o=x.x,l=x.x+x.width,e=e<o?e:o,i=i<(u=x.y)?i:u,n=n>l?n:l,s=s>(h=x.y+x.height)?s:h}var R=this._bounds;R.x=e,R.width=n-e,R.y=i,R.height=s-i,this._currentBounds=R}return this._currentBounds},h.prototype.getLocalBounds=function(){return this._bounds.x=-this._texture._frame.width*this.anchor.x,this._bounds.y=-this._texture._frame.height*this.anchor.y,this._bounds.width=this._texture._frame.width,this._bounds.height=this._texture._frame.height,this._bounds},h.prototype.containsPoint=function(t){this.worldTransform.applyInverse(t,u);var e,n=this._texture._frame.width,i=this._texture._frame.height,s=-n*this.anchor.x;return u.x>s&&u.x<s+n&&(e=-i*this.anchor.y,u.y>e&&u.y<e+i)},h.prototype._renderCanvas=function(t){if(!(this.texture.crop.width<=0||this.texture.crop.height<=0)){var e=t.blendModes[this.blendMode];if(e!==t.context.globalCompositeOperation&&(t.context.globalCompositeOperation=e),this.texture.valid){var n,i,s,r,o=this._texture,u=this.worldTransform;t.context.globalAlpha=this.worldAlpha;var h=o.baseTexture.scaleMode===l.SCALE_MODES.LINEAR;if(t.smoothProperty&&t.context[t.smoothProperty]!==h&&(t.context[t.smoothProperty]=h),o.rotate){var p=u.a,c=u.b;u.a=-u.c,u.b=-u.d,u.c=p,u.d=c,s=o.crop.height,r=o.crop.width,n=o.trim?o.trim.y-this.anchor.y*o.trim.height:this.anchor.y*-o._frame.height,i=o.trim?o.trim.x-this.anchor.x*o.trim.width:this.anchor.x*-o._frame.width}else s=o.crop.width,r=o.crop.height,n=o.trim?o.trim.x-this.anchor.x*o.trim.width:this.anchor.x*-o._frame.width,i=o.trim?o.trim.y-this.anchor.y*o.trim.height:this.anchor.y*-o._frame.height;t.roundPixels?(t.context.setTransform(u.a,u.b,u.c,u.d,u.tx*t.resolution|0,u.ty*t.resolution|0),n|=0,i|=0):t.context.setTransform(u.a,u.b,u.c,u.d,u.tx*t.resolution,u.ty*t.resolution);var d=o.baseTexture.resolution;16777215!==this.tint?(this.cachedTint!==this.tint&&(this.cachedTint=this.tint,this.tintedTexture=a.getTintedTexture(this,this.tint)),t.context.drawImage(this.tintedTexture,0,0,s*d,r*d,n*t.resolution,i*t.resolution,s*t.resolution,r*t.resolution)):t.context.drawImage(o.baseTexture.source,o.crop.x*d,o.crop.y*d,s*d,r*d,n*t.resolution,i*t.resolution,s*t.resolution,r*t.resolution)}}},h.prototype.destroy=function(t,e){r.prototype.destroy.call(this),this.anchor=null,t&&this._texture.destroy(e),this._texture=null,this.shader=null},h.fromFrame=function(t){var e=o.TextureCache[t];if(!e)throw new Error('The frameId "'+t+'" does not exist in the texture cache');return new h(e)},h.fromImage=function(t,e,n){return new h(s.fromImage(t,e,n))}},7920:(t,e,n)=>{var i=n(1830),s=n(5092),r=n(6192);function a(t){i.call(this,t),this.vertSize=5,this.vertByteSize=4*this.vertSize,this.size=r.SPRITE_BATCH_SIZE;var e=4*this.size*this.vertByteSize,n=6*this.size;this.vertices=new ArrayBuffer(e),this.positions=new Float32Array(this.vertices),this.colors=new Uint32Array(this.vertices),this.indices=new Uint16Array(n);for(var s=0,a=0;s<n;s+=6,a+=4)this.indices[s+0]=a+0,this.indices[s+1]=a+1,this.indices[s+2]=a+2,this.indices[s+3]=a+0,this.indices[s+4]=a+2,this.indices[s+5]=a+3;this.currentBatchSize=0,this.sprites=[],this.shader=null}a.prototype=Object.create(i.prototype),a.prototype.constructor=a,t.exports=a,s.registerPlugin("sprite",a),a.prototype.onContextChange=function(){var t=this.renderer.gl;this.shader=this.renderer.shaderManager.defaultShader,this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW),this.currentBlendMode=99999},a.prototype.render=function(t){var e=t._texture;this.currentBatchSize>=this.size&&this.flush();var n=e._uvs;if(n){var i,s,r,a,o=t.anchor.x,l=t.anchor.y;if(e.trim&&void 0===t.tileScale){var u=e.trim;i=(s=u.x-o*u.width)+e.crop.width,r=(a=u.y-l*u.height)+e.crop.height}else i=e._frame.width*(1-o),s=e._frame.width*-o,r=e._frame.height*(1-l),a=e._frame.height*-l;var h=this.currentBatchSize*this.vertByteSize,p=t.worldTransform,c=p.a,d=p.b,f=p.c,m=p.d,g=p.tx,_=p.ty,T=this.colors,y=this.positions;this.renderer.roundPixels?(y[h]=c*s+f*a+g|0,y[h+1]=m*a+d*s+_|0,y[h+5]=c*i+f*a+g|0,y[h+6]=m*a+d*i+_|0,y[h+10]=c*i+f*r+g|0,y[h+11]=m*r+d*i+_|0,y[h+15]=c*s+f*r+g|0,y[h+16]=m*r+d*s+_|0):(y[h]=c*s+f*a+g,y[h+1]=m*a+d*s+_,y[h+5]=c*i+f*a+g,y[h+6]=m*a+d*i+_,y[h+10]=c*i+f*r+g,y[h+11]=m*r+d*i+_,y[h+15]=c*s+f*r+g,y[h+16]=m*r+d*s+_),y[h+2]=n.x0,y[h+3]=n.y0,y[h+7]=n.x1,y[h+8]=n.y1,y[h+12]=n.x2,y[h+13]=n.y2,y[h+17]=n.x3,y[h+18]=n.y3;var I=t.tint;T[h+4]=T[h+9]=T[h+14]=T[h+19]=(I>>16)+(65280&I)+((255&I)<<16)+(255*t.worldAlpha<<24),this.sprites[this.currentBatchSize++]=t}},a.prototype.flush=function(){if(0!==this.currentBatchSize){var t,e,n,i,s=this.renderer.gl;if(this.currentBatchSize>.5*this.size)s.bufferSubData(s.ARRAY_BUFFER,0,this.vertices);else{var r=this.positions.subarray(0,this.currentBatchSize*this.vertByteSize);s.bufferSubData(s.ARRAY_BUFFER,0,r)}for(var a,o=0,l=0,u=null,h=this.renderer.blendModeManager.currentBlendMode,p=null,c=!1,d=!1,f=0,m=this.currentBatchSize;f<m;f++)e=(a=this.sprites[f])._texture.baseTexture,c=h!==(n=a.blendMode),d=p!==(i=a.shader||this.shader),(u!==e||c||d)&&(this.renderBatch(u,o,l),l=f,o=0,u=e,c&&(h=n,this.renderer.blendModeManager.setBlendMode(h)),d&&((t=(p=i).shaders?p.shaders[s.id]:p)||(t=p.getShader(this.renderer)),this.renderer.shaderManager.setShader(t),t.uniforms.projectionMatrix.value=this.renderer.currentRenderTarget.projectionMatrix.toArray(!0),t.syncUniforms(),s.activeTexture(s.TEXTURE0))),o++;this.renderBatch(u,o,l),this.currentBatchSize=0}},a.prototype.renderBatch=function(t,e,n){if(0!==e){var i=this.renderer.gl;t._glTextures[i.id]?i.bindTexture(i.TEXTURE_2D,t._glTextures[i.id]):this.renderer.updateTexture(t),i.drawElements(i.TRIANGLES,6*e,i.UNSIGNED_SHORT,6*n*2),this.renderer.drawCount++}},a.prototype.start=function(){var t=this.renderer.gl;t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var e=this.vertByteSize;t.vertexAttribPointer(this.shader.attributes.aVertexPosition,2,t.FLOAT,!1,e,0),t.vertexAttribPointer(this.shader.attributes.aTextureCoord,2,t.FLOAT,!1,e,8),t.vertexAttribPointer(this.shader.attributes.aColor,4,t.UNSIGNED_BYTE,!0,e,16)},a.prototype.destroy=function(){this.renderer.gl.deleteBuffer(this.vertexBuffer),this.renderer.gl.deleteBuffer(this.indexBuffer),i.prototype.destroy.call(this),this.shader.destroy(),this.renderer=null,this.vertices=null,this.positions=null,this.colors=null,this.indices=null,this.vertexBuffer=null,this.indexBuffer=null,this.sprites=null,this.shader=null}},9252:(t,e,n)=>{var i=n(2861),s=n(2699),r=n(4650),a=n(501),o=n(6192);function l(t,e,n){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.resolution=n||o.RESOLUTION,this._text=null,this._style=null;var a=s.fromCanvas(this.canvas);a.trim=new r.Rectangle,i.call(this,a),this.text=t,this.style=e}l.prototype=Object.create(i.prototype),l.prototype.constructor=l,t.exports=l,l.fontPropertiesCache={},l.fontPropertiesCanvas=document.createElement("canvas"),l.fontPropertiesContext=l.fontPropertiesCanvas.getContext("2d"),Object.defineProperties(l.prototype,{width:{get:function(){return this.dirty&&this.updateText(),this.scale.x*this._texture._frame.width},set:function(t){this.scale.x=t/this._texture._frame.width,this._width=t}},height:{get:function(){return this.dirty&&this.updateText(),this.scale.y*this._texture._frame.height},set:function(t){this.scale.y=t/this._texture._frame.height,this._height=t}},style:{get:function(){return this._style},set:function(t){"number"==typeof(t=t||{}).fill&&(t.fill=a.hex2string(t.fill)),"number"==typeof t.stroke&&(t.stroke=a.hex2string(t.stroke)),"number"==typeof t.dropShadowColor&&(t.dropShadowColor=a.hex2string(t.dropShadowColor)),t.font=t.font||"bold 20pt Arial",t.fill=t.fill||"black",t.align=t.align||"left",t.stroke=t.stroke||"black",t.strokeThickness=t.strokeThickness||0,t.wordWrap=t.wordWrap||!1,t.wordWrapWidth=t.wordWrapWidth||100,t.dropShadow=t.dropShadow||!1,t.dropShadowColor=t.dropShadowColor||"#000000",t.dropShadowAngle=t.dropShadowAngle||Math.PI/6,t.dropShadowDistance=t.dropShadowDistance||5,t.padding=t.padding||0,t.textBaseline=t.textBaseline||"alphabetic",t.lineJoin=t.lineJoin||"miter",t.miterLimit=t.miterLimit||10,this._style=t,this.dirty=!0}},text:{get:function(){return this._text},set:function(t){t=t.toString()||" ",this._text!==t&&(this._text=t,this.dirty=!0)}}}),l.prototype.updateText=function(){var t=this._style;this.context.font=t.font;for(var e=(t.wordWrap?this.wordWrap(this._text):this._text).split(/(?:\r\n|\r|\n)/),n=new Array(e.length),i=0,s=this.determineFontProperties(t.font),r=0;r<e.length;r++){var a=this.context.measureText(e[r]).width;n[r]=a,i=Math.max(i,a)}var o=i+t.strokeThickness;t.dropShadow&&(o+=t.dropShadowDistance),this.canvas.width=(o+this.context.lineWidth)*this.resolution;var l,u,h=this.style.lineHeight||s.fontSize+t.strokeThickness,p=h*e.length;if(t.dropShadow&&(p+=t.dropShadowDistance),this.canvas.height=(p+2*this._style.padding)*this.resolution,this.context.scale(this.resolution,this.resolution),navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.font=t.font,this.context.strokeStyle=t.stroke,this.context.lineWidth=t.strokeThickness,this.context.textBaseline=t.textBaseline,this.context.lineJoin=t.lineJoin,this.context.miterLimit=t.miterLimit,t.dropShadow){this.context.fillStyle=t.dropShadowColor;var c=Math.cos(t.dropShadowAngle)*t.dropShadowDistance,d=Math.sin(t.dropShadowAngle)*t.dropShadowDistance;for(r=0;r<e.length;r++)l=t.strokeThickness/2,u=t.strokeThickness/2+r*h+s.ascent,"right"===t.align?l+=i-n[r]:"center"===t.align&&(l+=(i-n[r])/2),t.fill&&this.context.fillText(e[r],l+c,u+d+this._style.padding)}for(this.context.fillStyle=t.fill,r=0;r<e.length;r++)l=t.strokeThickness/2,u=t.strokeThickness/2+r*h+s.ascent,"right"===t.align?l+=i-n[r]:"center"===t.align&&(l+=(i-n[r])/2),t.stroke&&t.strokeThickness&&this.context.strokeText(e[r],l,u+this._style.padding),t.fill&&this.context.fillText(e[r],l,u+this._style.padding);this.updateTexture()},l.prototype.updateTexture=function(){var t=this._texture;t.baseTexture.hasLoaded=!0,t.baseTexture.resolution=this.resolution,t.baseTexture.width=this.canvas.width/this.resolution,t.baseTexture.height=this.canvas.height/this.resolution,t.crop.width=t._frame.width=this.canvas.width/this.resolution,t.crop.height=t._frame.height=this.canvas.height/this.resolution,t.trim.x=0,t.trim.y=-this._style.padding,t.trim.width=t._frame.width,t.trim.height=t._frame.height-2*this._style.padding,this._width=this.canvas.width/this.resolution,this._height=this.canvas.height/this.resolution,t.baseTexture.emit("update",t.baseTexture),this.dirty=!1},l.prototype.renderWebGL=function(t){this.dirty&&this.updateText(),i.prototype.renderWebGL.call(this,t)},l.prototype._renderCanvas=function(t){this.dirty&&this.updateText(),i.prototype._renderCanvas.call(this,t)},l.prototype.determineFontProperties=function(t){var e=l.fontPropertiesCache[t];if(!e){e={};var n=l.fontPropertiesCanvas,i=l.fontPropertiesContext;i.font=t;var s=Math.ceil(i.measureText("|MÉq").width),r=Math.ceil(i.measureText("M").width),a=2*r;r=1.4*r|0,n.width=s,n.height=a,i.fillStyle="#f00",i.fillRect(0,0,s,a),i.font=t,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText("|MÉq",0,r);var o,u,h=i.getImageData(0,0,s,a).data,p=h.length,c=4*s,d=0,f=!1;for(o=0;o<r;o++){for(u=0;u<c;u+=4)if(255!==h[d+u]){f=!0;break}if(f)break;d+=c}for(e.ascent=r-o,d=p-c,f=!1,o=a;o>r;o--){for(u=0;u<c;u+=4)if(255!==h[d+u]){f=!0;break}if(f)break;d-=c}e.descent=o-r,e.fontSize=e.ascent+e.descent,l.fontPropertiesCache[t]=e}return e},l.prototype.wordWrap=function(t){for(var e="",n=t.split("\n"),i=this._style.wordWrapWidth,s=0;s<n.length;s++){for(var r=i,a=n[s].split(" "),o=0;o<a.length;o++){var l=this.context.measureText(a[o]).width,u=l+this.context.measureText(" ").width;0===o||u>r?(o>0&&(e+="\n"),e+=a[o],r=i-l):(r-=u,e+=" "+a[o])}s<n.length-1&&(e+="\n")}return e},l.prototype.getBounds=function(t){return this.dirty&&this.updateText(),i.prototype.getBounds.call(this,t)},l.prototype.destroy=function(t){this.context=null,this.canvas=null,this._style=null,this._texture.destroy(void 0===t||t)}},1936:(t,e,n)=>{var i=n(501),s=n(6192),r=n(5585);function a(t,e,n){r.call(this),this.uid=i.uid(),this.resolution=n||1,this.width=100,this.height=100,this.realWidth=100,this.realHeight=100,this.scaleMode=e||s.SCALE_MODES.DEFAULT,this.hasLoaded=!1,this.isLoading=!1,this.source=null,this.premultipliedAlpha=!0,this.imageUrl=null,this.isPowerOfTwo=!1,this.mipmap=!1,this._glTextures=[],t&&this.loadSource(t)}a.prototype=Object.create(r.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.update=function(){this.realWidth=this.source.naturalWidth||this.source.width,this.realHeight=this.source.naturalHeight||this.source.height,this.width=this.realWidth/this.resolution,this.height=this.realHeight/this.resolution,this.isPowerOfTwo=i.isPowerOfTwo(this.realWidth,this.realHeight),this.emit("update",this)},a.prototype.loadSource=function(t){var e=this.isLoading;if(this.hasLoaded=!1,this.isLoading=!1,e&&this.source&&(this.source.onload=null,this.source.onerror=null),this.source=t,(this.source.complete||this.source.getContext)&&this.source.width&&this.source.height)this._sourceLoaded();else if(!t.getContext){this.isLoading=!0;var n=this;t.onload=function(){t.onload=null,t.onerror=null,n.isLoading&&(n.isLoading=!1,n._sourceLoaded(),n.emit("loaded",n))},t.onerror=function(){t.onload=null,t.onerror=null,n.isLoading&&(n.isLoading=!1,n.emit("error",n))},t.complete&&t.src&&(this.isLoading=!1,t.onload=null,t.onerror=null,t.width&&t.height?(this._sourceLoaded(),e&&this.emit("loaded",this)):e&&this.emit("error",this))}},a.prototype._sourceLoaded=function(){this.hasLoaded=!0,this.update()},a.prototype.destroy=function(){this.imageUrl?(delete i.BaseTextureCache[this.imageUrl],delete i.TextureCache[this.imageUrl],this.imageUrl=null,navigator.isCocoonJS||(this.source.src="")):this.source&&this.source._pixiId&&delete i.BaseTextureCache[this.source._pixiId],this.source=null,this.dispose()},a.prototype.dispose=function(){this.emit("dispose",this),this._glTextures.length=0},a.prototype.updateSourceImage=function(t){this.source.src=t,this.loadSource(this.source)},a.fromImage=function(t,e,n){var s=i.BaseTextureCache[t];if(void 0===e&&0!==t.indexOf("data:")&&(e=!0),!s){var r=new Image;e&&(r.crossOrigin=""),(s=new a(r,n)).imageUrl=t,r.src=t,i.BaseTextureCache[t]=s,s.resolution=i.getResolutionOfUrl(t)}return s},a.fromCanvas=function(t,e){t._pixiId||(t._pixiId="canvas_"+i.uid());var n=i.BaseTextureCache[t._pixiId];return n||(n=new a(t,e),i.BaseTextureCache[t._pixiId]=n),n}},7443:(t,e,n)=>{var i=n(1936),s=n(2699),r=n(7955),a=n(4598),o=n(1549),l=n(4650),u=n(6192),h=new l.Matrix;function p(t,e,n,h,p){if(!t)throw new Error("Unable to create RenderTexture, you must pass a renderer into the constructor.");e=e||100,n=n||100,p=p||u.RESOLUTION;var c=new i;if(c.width=e,c.height=n,c.resolution=p,c.scaleMode=h||u.SCALE_MODES.DEFAULT,c.hasLoaded=!0,s.call(this,c,new l.Rectangle(0,0,e,n)),this.width=e,this.height=n,this.resolution=p,this.render=null,this.renderer=t,this.renderer.type===u.RENDERER_TYPE.WEBGL){var d=this.renderer.gl;this.textureBuffer=new r(d,this.width,this.height,c.scaleMode,this.resolution),this.baseTexture._glTextures[d.id]=this.textureBuffer.texture,this.filterManager=new a(this.renderer),this.filterManager.onContextChange(),this.filterManager.resize(e,n),this.render=this.renderWebGL,this.renderer.currentRenderer.start(),this.renderer.currentRenderTarget.activate()}else this.render=this.renderCanvas,this.textureBuffer=new o(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this._updateUvs()}p.prototype=Object.create(s.prototype),p.prototype.constructor=p,t.exports=p,p.prototype.resize=function(t,e,n){t===this.width&&e===this.height||(this.valid=t>0&&e>0,this.width=this._frame.width=this.crop.width=t,this.height=this._frame.height=this.crop.height=e,n&&(this.baseTexture.width=this.width,this.baseTexture.height=this.height),this.valid&&(this.textureBuffer.resize(this.width,this.height),this.filterManager&&this.filterManager.resize(this.width,this.height)))},p.prototype.clear=function(){this.valid&&(this.renderer.type===u.RENDERER_TYPE.WEBGL&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},p.prototype.renderWebGL=function(t,e,n,i){if(this.valid){if(i=void 0===i||i,//!updateTransform;
this.textureBuffer.transform=e,this.textureBuffer.activate(),t.worldAlpha=1,i){t.worldTransform.identity(),t.currentBounds=null;var s,r,a=t.children;for(s=0,r=a.length;s<r;++s)a[s].updateTransform()}var o=this.renderer.filterManager;this.renderer.filterManager=this.filterManager,this.renderer.renderDisplayObject(t,this.textureBuffer,n),this.renderer.filterManager=o}},p.prototype.renderCanvas=function(t,e,n,i){if(this.valid){i=!!i;var s=h;s.identity(),e&&s.append(e),t.worldTransform=s;var r=t.worldTransform;t.worldAlpha=1;var a,o,l=t.children;for(a=0,o=l.length;a<o;++a)l[a].updateTransform();n&&this.textureBuffer.clear();var u=this.textureBuffer.context,p=this.renderer.resolution;this.renderer.resolution=this.resolution,this.renderer.renderDisplayObject(t,u),this.renderer.resolution=p,t.worldTransform=r}},p.prototype.destroy=function(){s.prototype.destroy.call(this,!0),this.textureBuffer.destroy(),this.filterManager&&this.filterManager.destroy(),this.renderer=null},p.prototype.getImage=function(){var t=new Image;return t.src=this.getBase64(),t},p.prototype.getBase64=function(){return this.getCanvas().toDataURL()},p.prototype.getCanvas=function(){if(this.renderer.type===u.RENDERER_TYPE.WEBGL){var t=this.renderer.gl,e=this.textureBuffer.size.width,n=this.textureBuffer.size.height,i=new Uint8Array(4*e*n);t.bindFramebuffer(t.FRAMEBUFFER,this.textureBuffer.frameBuffer),t.readPixels(0,0,e,n,t.RGBA,t.UNSIGNED_BYTE,i),t.bindFramebuffer(t.FRAMEBUFFER,null);var s=new o(e,n),r=s.context.getImageData(0,0,e,n);return r.data.set(i),s.context.putImageData(r,0,0),s.canvas}return this.textureBuffer.canvas},p.prototype.getPixels=function(){var t,e;if(this.renderer.type===u.RENDERER_TYPE.WEBGL){var n=this.renderer.gl;t=this.textureBuffer.size.width,e=this.textureBuffer.size.height;var i=new Uint8Array(4*t*e);return n.bindFramebuffer(n.FRAMEBUFFER,this.textureBuffer.frameBuffer),n.readPixels(0,0,t,e,n.RGBA,n.UNSIGNED_BYTE,i),n.bindFramebuffer(n.FRAMEBUFFER,null),i}return t=this.textureBuffer.canvas.width,e=this.textureBuffer.canvas.height,this.textureBuffer.canvas.getContext("2d").getImageData(0,0,t,e).data},p.prototype.getPixel=function(t,e){if(this.renderer.type===u.RENDERER_TYPE.WEBGL){var n=this.renderer.gl,i=new Uint8Array(4);return n.bindFramebuffer(n.FRAMEBUFFER,this.textureBuffer.frameBuffer),n.readPixels(t,e,1,1,n.RGBA,n.UNSIGNED_BYTE,i),n.bindFramebuffer(n.FRAMEBUFFER,null),i}return this.textureBuffer.canvas.getContext("2d").getImageData(t,e,1,1).data}},2699:(t,e,n)=>{var i=n(1936),s=n(3367),r=n(1507),a=n(5585),o=n(4650),l=n(501);function u(t,e,n,i,s){a.call(this),this.noFrame=!1,e||(this.noFrame=!0,e=new o.Rectangle(0,0,1,1)),t instanceof u&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=i,this.valid=!1,this.requiresUpdate=!1,this._uvs=null,this.width=0,this.height=0,this.crop=n||e,this.rotate=!!s,t.hasLoaded?(this.noFrame&&(e=new o.Rectangle(0,0,t.width,t.height),t.on("update",this.onBaseTextureUpdated,this)),this.frame=e):t.once("loaded",this.onBaseTextureLoaded,this)}u.prototype=Object.create(a.prototype),u.prototype.constructor=u,t.exports=u,Object.defineProperties(u.prototype,{frame:{get:function(){return this._frame},set:function(t){if(this._frame=t,this.noFrame=!1,this.width=t.width,this.height=t.height,!this.trim&&!this.rotate&&(t.x+t.width>this.baseTexture.width||t.y+t.height>this.baseTexture.height))throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=t&&t.width&&t.height&&this.baseTexture.hasLoaded,this.trim?(this.width=this.trim.width,this.height=this.trim.height,this._frame.width=this.trim.width,this._frame.height=this.trim.height):this.crop=t,this.valid&&this._updateUvs()}}}),u.prototype.update=function(){this.baseTexture.update()},u.prototype.onBaseTextureLoaded=function(t){this.noFrame?this.frame=new o.Rectangle(0,0,t.width,t.height):this.frame=this._frame,this.emit("update",this)},u.prototype.onBaseTextureUpdated=function(t){this._frame.width=t.width,this._frame.height=t.height,this.emit("update",this)},u.prototype.destroy=function(t){this.baseTexture&&(t&&this.baseTexture.destroy(),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture.off("loaded",this.onBaseTextureLoaded,this),this.baseTexture=null),this._frame=null,this._uvs=null,this.trim=null,this.crop=null,this.valid=!1,this.off("dispose",this.dispose,this),this.off("update",this.update,this)},u.prototype.clone=function(){return new u(this.baseTexture,this.frame,this.crop,this.trim,this.rotate)},u.prototype._updateUvs=function(){this._uvs||(this._uvs=new r),this._uvs.set(this.crop,this.baseTexture,this.rotate)},u.fromImage=function(t,e,n){var s=l.TextureCache[t];return s||(s=new u(i.fromImage(t,e,n)),l.TextureCache[t]=s),s},u.fromFrame=function(t){var e=l.TextureCache[t];if(!e)throw new Error('The frameId "'+t+'" does not exist in the texture cache');return e},u.fromCanvas=function(t,e){return new u(i.fromCanvas(t,e))},u.fromVideo=function(t,e){return"string"==typeof t?u.fromVideoUrl(t,e):new u(s.fromVideo(t,e))},u.fromVideoUrl=function(t,e){return new u(s.fromUrl(t,e))},u.addTextureToCache=function(t,e){l.TextureCache[e]=t},u.removeTextureFromCache=function(t){var e=l.TextureCache[t];return delete l.TextureCache[t],delete l.BaseTextureCache[t],e},u.EMPTY=new u(new i)},1507:t=>{function e(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1}t.exports=e,e.prototype.set=function(t,e,n){var i=e.width,s=e.height;n?(this.x0=(t.x+t.height)/i,this.y0=t.y/s,this.x1=(t.x+t.height)/i,this.y1=(t.y+t.width)/s,this.x2=t.x/i,this.y2=(t.y+t.width)/s,this.x3=t.x/i,this.y3=t.y/s):(this.x0=t.x/i,this.y0=t.y/s,this.x1=(t.x+t.width)/i,this.y1=t.y/s,this.x2=(t.x+t.width)/i,this.y2=(t.y+t.height)/s,this.x3=t.x/i,this.y3=(t.y+t.height)/s)}},3367:(t,e,n)=>{var i=n(1936),s=n(501);function r(t,e){if(!t)throw new Error("No video source element specified.");(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),i.call(this,t,e),this.autoUpdate=!1,this._onUpdate=this._onUpdate.bind(this),this._onCanPlay=this._onCanPlay.bind(this),t.complete||(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("play",this._onPlayStart.bind(this)),t.addEventListener("pause",this._onPlayStop.bind(this))),this.__loaded=!1}function a(t,e){e||(e="video/"+t.substr(t.lastIndexOf(".")+1));var n=document.createElement("source");return n.src=t,n.type=e,n}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype._onUpdate=function(){this.autoUpdate&&(window.requestAnimationFrame(this._onUpdate),this.update())},r.prototype._onPlayStart=function(){this.autoUpdate||(window.requestAnimationFrame(this._onUpdate),this.autoUpdate=!0)},r.prototype._onPlayStop=function(){this.autoUpdate=!1},r.prototype._onCanPlay=function(){this.hasLoaded=!0,this.source&&(this.source.removeEventListener("canplay",this._onCanPlay),this.source.removeEventListener("canplaythrough",this._onCanPlay),this.width=this.source.videoWidth,this.height=this.source.videoHeight,this.source.play(),this.__loaded||(this.__loaded=!0,this.emit("loaded",this)))},r.prototype.destroy=function(){this.source&&this.source._pixiId&&(delete s.BaseTextureCache[this.source._pixiId],delete this.source._pixiId),i.prototype.destroy.call(this)},r.fromVideo=function(t,e){t._pixiId||(t._pixiId="video_"+s.uid());var n=s.BaseTextureCache[t._pixiId];return n||(n=new r(t,e),s.BaseTextureCache[t._pixiId]=n),n},r.fromUrl=function(t,e){var n=document.createElement("video");if(Array.isArray(t))for(var i=0;i<t.length;++i)n.appendChild(a(t[i].src||t[i],t[i].mime));else n.appendChild(a(t.src||t,t.mime));return n.load(),n.play(),r.fromVideo(n,e)},r.fromUrls=r.fromUrl},7974:(t,e,n)=>{var i=n(6192),s=n(5585),r="tick";function a(){var t=this;this._tick=function(e){t._requestId=null,t.started&&(t.update(e),t.started&&null===t._requestId&&t._emitter.listeners(r,!0)&&(t._requestId=requestAnimationFrame(t._tick)))},this._emitter=new s,this._requestId=null,this._maxElapsedMS=100,this.autoStart=!1,this.deltaTime=1,this.elapsedMS=1/i.TARGET_FPMS,this.lastTime=0,this.speed=1,this.started=!1}Object.defineProperties(a.prototype,{FPS:{get:function(){return 1e3/this.elapsedMS}},minFPS:{get:function(){return 1e3/this._maxElapsedMS},set:function(t){var e=Math.min(Math.max(0,t)/1e3,i.TARGET_FPMS);this._maxElapsedMS=1/e}}}),a.prototype._requestIfNeeded=function(){null===this._requestId&&this._emitter.listeners(r,!0)&&(this.lastTime=performance.now(),this._requestId=requestAnimationFrame(this._tick))},a.prototype._cancelIfNeeded=function(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)},a.prototype._startIfPossible=function(){this.started?this._requestIfNeeded():this.autoStart&&this.start()},a.prototype.add=function(t,e){return this._emitter.on(r,t,e),this._startIfPossible(),this},a.prototype.addOnce=function(t,e){return this._emitter.once(r,t,e),this._startIfPossible(),this},a.prototype.remove=function(t,e){return this._emitter.off(r,t,e),this._emitter.listeners(r,!0)||this._cancelIfNeeded(),this},a.prototype.start=function(){this.started||(this.started=!0,this._requestIfNeeded())},a.prototype.stop=function(){this.started&&(this.started=!1,this._cancelIfNeeded())},a.prototype.update=function(t){var e;t=t||performance.now(),(e=this.elapsedMS=t-this.lastTime)>this._maxElapsedMS&&(e=this._maxElapsedMS),this.deltaTime=e*i.TARGET_FPMS*this.speed,this._emitter.emit(r,this.deltaTime),this.lastTime=t},t.exports=a},2410:(t,e,n)=>{var i=n(7974),s=new i;s.autoStart=!0,t.exports={shared:s,Ticker:i}},501:(t,e,n)=>{var i=n(6192),s=t.exports={_uid:0,_saidHello:!1,EventEmitter:n(5585),pluginTarget:n(7987),async:n(4083),uid:function(){return++s._uid},hex2rgb:function(t,e){return(e=e||[])[0]=(t>>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255,e},hex2string:function(t){return t=t.toString(16),"#"+(t="000000".substr(0,6-t.length)+t)},rgb2hex:function(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]},canUseNewCanvasBlendModes:function(){if("undefined"==typeof document)return!1;var t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",e="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",n=new Image;n.src=t+"AP804Oa6"+e;var i=new Image;i.src=t+"/wCKxvRF"+e;var s=document.createElement("canvas");s.width=6,s.height=1;var r=s.getContext("2d");r.globalCompositeOperation="multiply",r.drawImage(n,0,0),r.drawImage(i,2,0);var a=r.getImageData(2,0,1,1).data;return 255===a[0]&&0===a[1]&&0===a[2]},getNextPowerOfTwo:function(t){if(t>0&&!(t&t-1))return t;for(var e=1;e<t;)e<<=1;return e},isPowerOfTwo:function(t,e){return t>0&&!(t&t-1)&&e>0&&!(e&e-1)},getResolutionOfUrl:function(t){var e=i.RETINA_PREFIX.exec(t);return e?parseFloat(e[1]):1},sayHello:function(t){if(!s._saidHello){if(navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var e=["\n %c %c %c Pixi.js "+i.VERSION+" - ✰ "+t+" ✰ %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥ \n\n","background: #ff66a5; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff66a5; background: #030307; padding:5px 0;","background: #ff66a5; padding:5px 0;","background: #ffc3dc; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;"];window.console.log.apply(console,e)}else window.console&&window.console.log("Pixi.js "+i.VERSION+" - "+t+" - http://www.pixijs.com/");s._saidHello=!0}},isWebGLSupported:function(){var t={stencil:!0};try{if(!window.WebGLRenderingContext)return!1;var e=document.createElement("canvas"),n=e.getContext("webgl",t)||e.getContext("experimental-webgl",t);return!(!n||!n.getContextAttributes().stencil)}catch(t){return!1}},sign:function(t){return t?t<0?-1:1:0},TextureCache:{},BaseTextureCache:{}}},7987:t=>{t.exports={mixin:function(t){!function(t){t.__plugins={},t.registerPlugin=function(e,n){t.__plugins[e]=n},t.prototype.initPlugins=function(){for(var e in this.plugins=this.plugins||{},t.__plugins)this.plugins[e]=new t.__plugins[e](this)},t.prototype.destroyPlugins=function(){for(var t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null;this.plugins=null}}(t)}}},9513:(t,e,n)=>{var i=n(4651),s=n(8653),r=n(3323),a=n(8319);i.SpriteBatch=function(){throw new ReferenceError("SpriteBatch does not exist any more, please use the new ParticleContainer instead.")},i.AssetLoader=function(){throw new ReferenceError("The loader system was overhauled in pixi v3, please see the new PIXI.loaders.Loader class.")},Object.defineProperties(i,{Stage:{get:function(){return console.warn("You do not need to use a PIXI Stage any more, you can simply render any container."),i.Container}},DisplayObjectContainer:{get:function(){return console.warn("DisplayObjectContainer has been shortened to Container, please use Container from now on."),i.Container}},Strip:{get:function(){return console.warn("The Strip class has been renamed to Mesh and moved to mesh.Mesh, please use mesh.Mesh from now on."),s.Mesh}},Rope:{get:function(){return console.warn("The Rope class has been moved to mesh.Rope, please use mesh.Rope from now on."),s.Rope}},MovieClip:{get:function(){return console.warn("The MovieClip class has been moved to extras.MovieClip, please use extras.MovieClip from now on."),r.MovieClip}},TilingSprite:{get:function(){return console.warn("The TilingSprite class has been moved to extras.TilingSprite, please use extras.TilingSprite from now on."),r.TilingSprite}},BitmapText:{get:function(){return console.warn("The BitmapText class has been moved to extras.BitmapText, please use extras.BitmapText from now on."),r.BitmapText}},blendModes:{get:function(){return console.warn("The blendModes has been moved to BLEND_MODES, please use BLEND_MODES from now on."),i.BLEND_MODES}},scaleModes:{get:function(){return console.warn("The scaleModes has been moved to SCALE_MODES, please use SCALE_MODES from now on."),i.SCALE_MODES}},BaseTextureCache:{get:function(){return console.warn("The BaseTextureCache class has been moved to utils.BaseTextureCache, please use utils.BaseTextureCache from now on."),i.utils.BaseTextureCache}},TextureCache:{get:function(){return console.warn("The TextureCache class has been moved to utils.TextureCache, please use utils.TextureCache from now on."),i.utils.TextureCache}},math:{get:function(){return console.warn("The math namespace is deprecated, please access members already accessible on PIXI."),i}}}),i.Sprite.prototype.setTexture=function(t){this.texture=t,console.warn("setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;")},r.BitmapText.prototype.setText=function(t){this.text=t,console.warn("setText is now deprecated, please use the text property, e.g : myBitmapText.text = 'my text';")},i.Text.prototype.setText=function(t){this.text=t,console.warn("setText is now deprecated, please use the text property, e.g : myText.text = 'my text';")},i.Text.prototype.setStyle=function(t){this.style=t,console.warn("setStyle is now deprecated, please use the style property, e.g : myText.style = style;")},i.Texture.prototype.setFrame=function(t){this.frame=t,console.warn("setFrame is now deprecated, please use the frame property, e.g : myTexture.frame = frame;")},Object.defineProperties(a,{AbstractFilter:{get:function(){return console.warn("filters.AbstractFilter is an undocumented alias, please use AbstractFilter from now on."),i.AbstractFilter}},FXAAFilter:{get:function(){return console.warn("filters.FXAAFilter is an undocumented alias, please use FXAAFilter from now on."),i.FXAAFilter}},SpriteMaskFilter:{get:function(){return console.warn("filters.SpriteMaskFilter is an undocumented alias, please use SpriteMaskFilter from now on."),i.SpriteMaskFilter}}}),i.utils.uuid=function(){return console.warn("utils.uuid() is deprecated, please use utils.uid() from now on."),i.utils.uid()}},3635:(t,e,n)=>{var i=n(4651);function s(t,e){i.Container.call(this),e=e||{},this.textWidth=0,this.textHeight=0,this._glyphs=[],this._font={tint:void 0!==e.tint?e.tint:16777215,align:e.align||"left",name:null,size:0},this.font=e.font,this._text=t,this.maxWidth=0,this.maxLineHeight=0,this.dirty=!1,this.updateText()}s.prototype=Object.create(i.Container.prototype),s.prototype.constructor=s,t.exports=s,Object.defineProperties(s.prototype,{tint:{get:function(){return this._font.tint},set:function(t){this._font.tint="number"==typeof t&&t>=0?t:16777215,this.dirty=!0}},align:{get:function(){return this._font.align},set:function(t){this._font.align=t||"left",this.dirty=!0}},font:{get:function(){return this._font},set:function(t){t&&("string"==typeof t?(t=t.split(" "),this._font.name=1===t.length?t[0]:t.slice(1).join(" "),this._font.size=t.length>=2?parseInt(t[0],10):s.fonts[this._font.name].size):(this._font.name=t.name,this._font.size="number"==typeof t.size?t.size:parseInt(t.size,10)),this.dirty=!0)}},text:{get:function(){return this._text},set:function(t){t=t.toString()||" ",this._text!==t&&(this._text=t,this.dirty=!0)}}}),s.prototype.updateText=function(){for(var t=s.fonts[this._font.name],e=new i.Point,n=null,r=[],a=0,o=0,l=[],u=0,h=this._font.size/t.size,p=-1,c=0,d=0;d<this.text.length;d++){var f=this.text.charCodeAt(d);if(p=/(\s)/.test(this.text.charAt(d))?d:p,/(?:\r\n|\r|\n)/.test(this.text.charAt(d)))l.push(a),o=Math.max(o,a),u++,e.x=0,e.y+=t.lineHeight,n=null;else if(-1!==p&&this.maxWidth>0&&e.x*h>this.maxWidth)r.splice(p,d-p),d=p,p=-1,l.push(a),o=Math.max(o,a),u++,e.x=0,e.y+=t.lineHeight,n=null;else{var m=t.chars[f];m&&(n&&m.kerning[n]&&(e.x+=m.kerning[n]),r.push({texture:m.texture,line:u,charCode:f,position:new i.Point(e.x+m.xOffset,e.y+m.yOffset)}),a=e.x+(m.texture.width+m.xOffset),e.x+=m.xAdvance,c=Math.max(c,m.yOffset+m.texture.height),n=f)}}l.push(a),o=Math.max(o,a);var g=[];for(d=0;d<=u;d++){var _=0;"right"===this._font.align?_=o-l[d]:"center"===this._font.align&&(_=(o-l[d])/2),g.push(_)}var T=r.length,y=this.tint;for(d=0;d<T;d++){var I=this._glyphs[d];I?I.texture=r[d].texture:(I=new i.Sprite(r[d].texture),this._glyphs.push(I)),I.position.x=(r[d].position.x+g[r[d].line])*h,I.position.y=r[d].position.y*h,I.scale.x=I.scale.y=h,I.tint=y,I.parent||this.addChild(I)}for(d=T;d<this._glyphs.length;++d)this.removeChild(this._glyphs[d]);this.textWidth=o*h,this.textHeight=(e.y+t.lineHeight)*h,this.maxLineHeight=c*h},s.prototype.updateTransform=function(){this.validate(),this.containerUpdateTransform()},s.prototype.getLocalBounds=function(){return this.validate(),i.Container.prototype.getLocalBounds.call(this)},s.prototype.validate=function(){this.dirty&&(this.updateText(),this.dirty=!1)},s.fonts={}},7901:(t,e,n)=>{var i=n(4651);function s(t){i.Sprite.call(this,t[0]instanceof i.Texture?t[0]:t[0].texture),this._textures=null,this._durations=null,this.textures=t,this.animationSpeed=1,this.loop=!0,this.onComplete=null,this._currentTime=0,this.playing=!1}s.prototype=Object.create(i.Sprite.prototype),s.prototype.constructor=s,t.exports=s,Object.defineProperties(s.prototype,{totalFrames:{get:function(){return this._textures.length}},textures:{get:function(){return this._textures},set:function(t){if(t[0]instanceof i.Texture)this._textures=t,this._durations=null;else{this._textures=[],this._durations=[];for(var e=0;e<t.length;e++)this._textures.push(t[e].texture),this._durations.push(t[e].time)}}},currentFrame:{get:function(){var t=Math.floor(this._currentTime)%this._textures.length;return t<0&&(t+=this._textures.length),t}}}),s.prototype.stop=function(){this.playing&&(this.playing=!1,i.ticker.shared.remove(this.update,this))},s.prototype.play=function(){this.playing||(this.playing=!0,i.ticker.shared.add(this.update,this))},s.prototype.gotoAndStop=function(t){this.stop(),this._currentTime=t,this._texture=this._textures[this.currentFrame]},s.prototype.gotoAndPlay=function(t){this._currentTime=t,this.play()},s.prototype.update=function(t){var e=this.animationSpeed*t;if(null!==this._durations){var n=this._currentTime%1*this._durations[this.currentFrame];for(n+=e/60*1e3;n<0;)this._currentTime--,n+=this._durations[this.currentFrame];var i=Math.sign(this.animationSpeed*t);for(this._currentTime=Math.floor(this._currentTime);n>=this._durations[this.currentFrame];)n-=this._durations[this.currentFrame]*i,this._currentTime+=i;this._currentTime+=n/this._durations[this.currentFrame]}else this._currentTime+=e;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):this._texture=this._textures[this.currentFrame]},s.prototype.destroy=function(){this.stop(),i.Sprite.prototype.destroy.call(this)},s.fromFrames=function(t){for(var e=[],n=0;n<t.length;++n)e.push(new i.Texture.fromFrame(t[n]));return new s(e)},s.fromImages=function(t){for(var e=[],n=0;n<t.length;++n)e.push(new i.Texture.fromImage(t[n]));return new s(e)}},7377:(t,e,n)=>{var i=n(4651),s=new i.Point,r=n(7809);function a(t,e,n){i.Sprite.call(this,t),this.tileScale=new i.Point(1,1),this.tilePosition=new i.Point(0,0),this._width=e||100,this._height=n||100,this._uvs=new i.TextureUvs,this._canvasPattern=null,this.shader=new i.AbstractFilter(["precision lowp float;","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform mat3 projectionMatrix;","uniform vec4 uFrame;","uniform vec4 uTransform;","varying vec2 vTextureCoord;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vec2 coord = aTextureCoord;"," coord -= uTransform.xy;"," coord /= uTransform.zw;"," vTextureCoord = coord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"].join("\n"),["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform vec4 uFrame;","uniform vec2 uPixelSize;","void main(void){"," vec2 coord = mod(vTextureCoord, uFrame.zw);"," coord = clamp(coord, uPixelSize, uFrame.zw - uPixelSize);"," coord += uFrame.xy;"," gl_FragColor = texture2D(uSampler, coord) * vColor ;","}"].join("\n"),{uFrame:{type:"4fv",value:[0,0,1,1]},uTransform:{type:"4fv",value:[0,0,1,1]},uPixelSize:{type:"2fv",value:[1,1]}})}a.prototype=Object.create(i.Sprite.prototype),a.prototype.constructor=a,t.exports=a,Object.defineProperties(a.prototype,{width:{get:function(){return this._width},set:function(t){this._width=t}},height:{get:function(){return this._height},set:function(t){this._height=t}}}),a.prototype._onTextureUpdate=function(){},a.prototype._renderWebGL=function(t){var e=this._texture;if(e&&e._uvs){var n=e._uvs,i=e._frame.width,s=e._frame.height,r=e.baseTexture.width,a=e.baseTexture.height;e._uvs=this._uvs,e._frame.width=this.width,e._frame.height=this.height,this.shader.uniforms.uPixelSize.value[0]=1/r,this.shader.uniforms.uPixelSize.value[1]=1/a,this.shader.uniforms.uFrame.value[0]=n.x0,this.shader.uniforms.uFrame.value[1]=n.y0,this.shader.uniforms.uFrame.value[2]=n.x1-n.x0,this.shader.uniforms.uFrame.value[3]=n.y2-n.y0,this.shader.uniforms.uTransform.value[0]=this.tilePosition.x%(i*this.tileScale.x)/this._width,this.shader.uniforms.uTransform.value[1]=this.tilePosition.y%(s*this.tileScale.y)/this._height,this.shader.uniforms.uTransform.value[2]=r/this._width*this.tileScale.x,this.shader.uniforms.uTransform.value[3]=a/this._height*this.tileScale.y,t.setObjectRenderer(t.plugins.sprite),t.plugins.sprite.render(this),e._uvs=n,e._frame.width=i,e._frame.height=s}},a.prototype._renderCanvas=function(t){var e=this._texture;if(e.baseTexture.hasLoaded){var n=t.context,s=this.worldTransform,a=t.resolution,o=e.baseTexture,l=this.tilePosition.x/this.tileScale.x%e._frame.width,u=this.tilePosition.y/this.tileScale.y%e._frame.height;if(!this._canvasPattern){var h=new i.CanvasBuffer(e._frame.width,e._frame.height);16777215!==this.tint?(this.cachedTint!==this.tint&&(this.cachedTint=this.tint,this.tintedTexture=r.getTintedTexture(this,this.tint)),h.context.drawImage(this.tintedTexture,0,0)):h.context.drawImage(o.source,-e._frame.x,-e._frame.y),this._canvasPattern=h.context.createPattern(h.canvas,"repeat")}n.globalAlpha=this.worldAlpha,n.setTransform(s.a*a,s.b*a,s.c*a,s.d*a,s.tx*a,s.ty*a),n.scale(this.tileScale.x,this.tileScale.y),n.translate(l+this.anchor.x*-this._width,u+this.anchor.y*-this._height);var p=t.blendModes[this.blendMode];p!==t.context.globalCompositeOperation&&(n.globalCompositeOperation=p),n.fillStyle=this._canvasPattern,n.fillRect(-l,-u,this._width/this.tileScale.x,this._height/this.tileScale.y)}},a.prototype.getBounds=function(){var t,e,n,i,s=this._width,r=this._height,a=s*(1-this.anchor.x),o=s*-this.anchor.x,l=r*(1-this.anchor.y),u=r*-this.anchor.y,h=this.worldTransform,p=h.a,c=h.b,d=h.c,f=h.d,m=h.tx,g=h.ty,_=p*o+d*u+m,T=f*u+c*o+g,y=p*a+d*u+m,I=f*u+c*a+g,E=p*a+d*l+m,b=f*l+c*a+g,v=p*o+d*l+m,w=f*l+c*o+g;t=v<(t=E<(t=y<(t=_)?y:t)?E:t)?v:t,n=w<(n=b<(n=I<(n=T)?I:n)?b:n)?w:n,e=v>(e=E>(e=y>(e=_)?y:e)?E:e)?v:e,i=w>(i=b>(i=I>(i=T)?I:i)?b:i)?w:i;var S=this._bounds;return S.x=t,S.width=e-t,S.y=n,S.height=i-n,this._currentBounds=S,S},a.prototype.containsPoint=function(t){this.worldTransform.applyInverse(t,s);var e,n=this._width,i=this._height,r=-n*this.anchor.x;return s.x>r&&s.x<r+n&&(e=-i*this.anchor.y,s.y>e&&s.y<e+i)},a.prototype.destroy=function(){i.Sprite.prototype.destroy.call(this),this.tileScale=null,this._tileScaleOffset=null,this.tilePosition=null,this._uvs=null},a.fromFrame=function(t,e,n){var s=i.utils.TextureCache[t];if(!s)throw new Error('The frameId "'+t+'" does not exist in the texture cache '+this);return new a(s,e,n)},a.fromImage=function(t,e,n,s,r){return new a(i.Texture.fromImage(t,s,r),e,n)}},4262:(t,e,n)=>{var i=n(4651),s=i.DisplayObject,r=new i.Matrix;s.prototype._cacheAsBitmap=!1,s.prototype._originalRenderWebGL=null,s.prototype._originalRenderCanvas=null,s.prototype._originalUpdateTransform=null,s.prototype._originalHitTest=null,s.prototype._originalDestroy=null,s.prototype._cachedSprite=null,Object.defineProperties(s.prototype,{cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap!==t&&(this._cacheAsBitmap=t,t?(this._originalRenderWebGL=this.renderWebGL,this._originalRenderCanvas=this.renderCanvas,this._originalUpdateTransform=this.updateTransform,this._originalGetBounds=this.getBounds,this._originalDestroy=this.destroy,this._originalContainsPoint=this.containsPoint,this.renderWebGL=this._renderCachedWebGL,this.renderCanvas=this._renderCachedCanvas,this.destroy=this._cacheAsBitmapDestroy):(this._cachedSprite&&this._destroyCachedDisplayObject(),this.renderWebGL=this._originalRenderWebGL,this.renderCanvas=this._originalRenderCanvas,this.getBounds=this._originalGetBounds,this.destroy=this._originalDestroy,this.updateTransform=this._originalUpdateTransform,this.containsPoint=this._originalContainsPoint))}}}),s.prototype._renderCachedWebGL=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObject(t),this._cachedSprite.worldAlpha=this.worldAlpha,t.setObjectRenderer(t.plugins.sprite),t.plugins.sprite.render(this._cachedSprite))},s.prototype._initCachedDisplayObject=function(t){if(!this._cachedSprite){t.currentRenderer.flush();var e=this.getLocalBounds().clone();if(this._filters){var n=this._filters[0].padding;e.x-=n,e.y-=n,e.width+=2*n,e.height+=2*n}var s=t.currentRenderTarget,a=t.filterManager.filterStack,o=new i.RenderTexture(t,0|e.width,0|e.height),l=r;l.tx=-e.x,l.ty=-e.y,this.renderWebGL=this._originalRenderWebGL,o.render(this,l,!0,!0),t.setRenderTarget(s),t.filterManager.filterStack=a,this.renderWebGL=this._renderCachedWebGL,this.updateTransform=this.displayObjectUpdateTransform,this.getBounds=this._getCachedBounds,this._cachedSprite=new i.Sprite(o),this._cachedSprite.worldTransform=this.worldTransform,this._cachedSprite.anchor.x=-e.x/e.width,this._cachedSprite.anchor.y=-e.y/e.height,this.updateTransform(),this.containsPoint=this._cachedSprite.containsPoint.bind(this._cachedSprite)}},s.prototype._renderCachedCanvas=function(t){!this.visible||this.worldAlpha<=0||!this.renderable||(this._initCachedDisplayObjectCanvas(t),this._cachedSprite.worldAlpha=this.worldAlpha,this._cachedSprite.renderCanvas(t))},s.prototype._initCachedDisplayObjectCanvas=function(t){if(!this._cachedSprite){var e=this.getLocalBounds(),n=t.context,s=new i.RenderTexture(t,0|e.width,0|e.height),a=r;a.tx=-e.x,a.ty=-e.y,this.renderCanvas=this._originalRenderCanvas,s.render(this,a,!0),t.context=n,this.renderCanvas=this._renderCachedCanvas,this.updateTransform=this.displayObjectUpdateTransform,this.getBounds=this._getCachedBounds,this._cachedSprite=new i.Sprite(s),this._cachedSprite.worldTransform=this.worldTransform,this._cachedSprite.anchor.x=-e.x/e.width,this._cachedSprite.anchor.y=-e.y/e.height,this.updateTransform(),this.containsPoint=this._cachedSprite.containsPoint.bind(this._cachedSprite)}},s.prototype._getCachedBounds=function(){return this._cachedSprite._currentBounds=null,this._cachedSprite.getBounds()},s.prototype._destroyCachedDisplayObject=function(){this._cachedSprite._texture.destroy(),this._cachedSprite=null},s.prototype._cacheAsBitmapDestroy=function(){this.cacheAsBitmap=!1,this._originalDestroy()}},7231:(t,e,n)=>{var i=n(4651);i.DisplayObject.prototype.name=null,i.Container.prototype.getChildByName=function(t){for(var e=0;e<this.children.length;e++)if(this.children[e].name===t)return this.children[e];return null}},4247:(t,e,n)=>{var i=n(4651);i.DisplayObject.prototype.getGlobalPosition=function(t){return t=t||new i.Point,this.parent?(this.displayObjectUpdateTransform(),t.x=this.worldTransform.tx,t.y=this.worldTransform.ty):(t.x=this.position.x,t.y=this.position.y),t}},3323:(t,e,n)=>{
/**
* @file Main export of the PIXI extras library
* @author Mat Groves <mat@goodboydigital.com>
* @copyright 2013-2015 GoodBoyDigital
* @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License}
*/
n(4262),n(7231),n(4247),t.exports={MovieClip:n(7901),TilingSprite:n(7377),BitmapText:n(3635)}},4350:(t,e,n)=>{var i=n(4651),s=n(9496);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//ascii.frag","utf8"),{dimensions:{type:"4fv",value:new Float32Array([0,0,0,0])},pixelSize:{type:"1f",value:8}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{size:{get:function(){return this.uniforms.pixelSize.value},set:function(t){this.uniforms.pixelSize.value=t}}})},5966:(t,e,n)=>{var i=n(4651),s=n(4356),r=n(6160);function a(){i.AbstractFilter.call(this),this.blurXFilter=new s,this.blurYFilter=new r,this.defaultFilter=new i.AbstractFilter}a.prototype=Object.create(i.AbstractFilter.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.applyFilter=function(t,e,n){var s=t.filterManager.getRenderTarget(!0);this.defaultFilter.applyFilter(t,e,n),this.blurXFilter.applyFilter(t,e,s),t.blendModeManager.setBlendMode(i.BLEND_MODES.SCREEN),this.blurYFilter.applyFilter(t,s,n),t.blendModeManager.setBlendMode(i.BLEND_MODES.NORMAL),t.filterManager.returnRenderTarget(s)},Object.defineProperties(a.prototype,{blur:{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=this.blurYFilter.blur=t}},blurX:{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=t}},blurY:{get:function(){return this.blurYFilter.blur},set:function(t){this.blurYFilter.blur=t}}})},415:(t,e,n)=>{var i=n(4651),s=n(6786);function r(t,e){i.AbstractFilter.call(this,s.readFileSync("//blurDir.vert","utf8"),s.readFileSync("//blurDir.frag","utf8"),{strength:{type:"1f",value:1},dirX:{type:"1f",value:t||0},dirY:{type:"1f",value:e||0}}),this.defaultFilter=new i.AbstractFilter,this.passes=1,this.dirX=t||0,this.dirY=e||0,this.strength=4}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n,i){var s=this.getShader(t);if(this.uniforms.strength.value=this.strength/4/this.passes*(e.frame.width/e.size.width),1===this.passes)t.filterManager.applyFilter(s,e,n,i);else{var r=t.filterManager.getRenderTarget(!0);t.filterManager.applyFilter(s,e,r,i);for(var a=0;a<this.passes-2;a++)t.filterManager.applyFilter(s,r,r,i);t.filterManager.applyFilter(s,r,n,i),t.filterManager.returnRenderTarget(r)}},Object.defineProperties(r.prototype,{blur:{get:function(){return this.strength},set:function(t){this.padding=.5*t,this.strength=t}},dirX:{get:function(){return this.dirX},set:function(t){this.uniforms.dirX.value=t}},dirY:{get:function(){return this.dirY},set:function(t){this.uniforms.dirY.value=t}}})},6762:(t,e,n)=>{var i=n(4651),s=n(4356),r=n(6160);function a(){i.AbstractFilter.call(this),this.blurXFilter=new s,this.blurYFilter=new r}a.prototype=Object.create(i.AbstractFilter.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.applyFilter=function(t,e,n){var i=t.filterManager.getRenderTarget(!0);this.blurXFilter.applyFilter(t,e,i),this.blurYFilter.applyFilter(t,i,n),t.filterManager.returnRenderTarget(i)},Object.defineProperties(a.prototype,{blur:{get:function(){return this.blurXFilter.blur},set:function(t){this.padding=.5*Math.abs(t),this.blurXFilter.blur=this.blurYFilter.blur=t}},passes:{get:function(){return this.blurXFilter.passes},set:function(t){this.blurXFilter.passes=this.blurYFilter.passes=t}},blurX:{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=t}},blurY:{get:function(){return this.blurYFilter.blur},set:function(t){this.blurYFilter.blur=t}}})},4356:(t,e,n)=>{var i=n(4651),s=n(6786);function r(){i.AbstractFilter.call(this,s.readFileSync("//blurX.vert","utf8"),s.readFileSync("//blur.frag","utf8"),{strength:{type:"1f",value:1}}),this.passes=1,this.strength=4}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n,i){var s=this.getShader(t);if(this.uniforms.strength.value=this.strength/4/this.passes*(e.frame.width/e.size.width),1===this.passes)t.filterManager.applyFilter(s,e,n,i);else{for(var r=t.filterManager.getRenderTarget(!0),a=e,o=r,l=0;l<this.passes-1;l++){t.filterManager.applyFilter(s,a,o,!0);var u=o;o=a,a=u}t.filterManager.applyFilter(s,a,n,i),t.filterManager.returnRenderTarget(r)}},Object.defineProperties(r.prototype,{blur:{get:function(){return this.strength},set:function(t){this.padding=.5*Math.abs(t),this.strength=t}}})},6160:(t,e,n)=>{var i=n(4651),s=n(6786);function r(){i.AbstractFilter.call(this,s.readFileSync("//blurY.vert","utf8"),s.readFileSync("//blur.frag","utf8"),{strength:{type:"1f",value:1}}),this.passes=1,this.strength=4}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n,i){var s=this.getShader(t);if(this.uniforms.strength.value=Math.abs(this.strength)/4/this.passes*(e.frame.height/e.size.height),1===this.passes)t.filterManager.applyFilter(s,e,n,i);else{for(var r=t.filterManager.getRenderTarget(!0),a=e,o=r,l=0;l<this.passes-1;l++){t.filterManager.applyFilter(s,a,o,!0);var u=o;o=a,a=u}t.filterManager.applyFilter(s,a,n,i),t.filterManager.returnRenderTarget(r)}},Object.defineProperties(r.prototype,{blur:{get:function(){return this.strength},set:function(t){this.padding=.5*Math.abs(t),this.strength=t}}})},1327:(t,e,n)=>{var i=n(4651),s=n(6786);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//smartBlur.frag","utf8"),{delta:{type:"v2",value:{x:.1,y:0}}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r},9375:(t,e,n)=>{var i=n(4651),s=n(8884);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//colorMatrix.frag","utf8"),{m:{type:"1fv",value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype._loadMatrix=function(t,e){var n=t;(e=!!e)&&(this._multiply(n,this.uniforms.m.value,t),n=this._colorMatrix(n)),this.uniforms.m.value=n},r.prototype._multiply=function(t,e,n){return t[0]=e[0]*n[0]+e[1]*n[5]+e[2]*n[10]+e[3]*n[15],t[1]=e[0]*n[1]+e[1]*n[6]+e[2]*n[11]+e[3]*n[16],t[2]=e[0]*n[2]+e[1]*n[7]+e[2]*n[12]+e[3]*n[17],t[3]=e[0]*n[3]+e[1]*n[8]+e[2]*n[13]+e[3]*n[18],t[4]=e[0]*n[4]+e[1]*n[9]+e[2]*n[14]+e[3]*n[19],t[5]=e[5]*n[0]+e[6]*n[5]+e[7]*n[10]+e[8]*n[15],t[6]=e[5]*n[1]+e[6]*n[6]+e[7]*n[11]+e[8]*n[16],t[7]=e[5]*n[2]+e[6]*n[7]+e[7]*n[12]+e[8]*n[17],t[8]=e[5]*n[3]+e[6]*n[8]+e[7]*n[13]+e[8]*n[18],t[9]=e[5]*n[4]+e[6]*n[9]+e[7]*n[14]+e[8]*n[19],t[10]=e[10]*n[0]+e[11]*n[5]+e[12]*n[10]+e[13]*n[15],t[11]=e[10]*n[1]+e[11]*n[6]+e[12]*n[11]+e[13]*n[16],t[12]=e[10]*n[2]+e[11]*n[7]+e[12]*n[12]+e[13]*n[17],t[13]=e[10]*n[3]+e[11]*n[8]+e[12]*n[13]+e[13]*n[18],t[14]=e[10]*n[4]+e[11]*n[9]+e[12]*n[14]+e[13]*n[19],t[15]=e[15]*n[0]+e[16]*n[5]+e[17]*n[10]+e[18]*n[15],t[16]=e[15]*n[1]+e[16]*n[6]+e[17]*n[11]+e[18]*n[16],t[17]=e[15]*n[2]+e[16]*n[7]+e[17]*n[12]+e[18]*n[17],t[18]=e[15]*n[3]+e[16]*n[8]+e[17]*n[13]+e[18]*n[18],t[19]=e[15]*n[4]+e[16]*n[9]+e[17]*n[14]+e[18]*n[19],t},r.prototype._colorMatrix=function(t){var e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e},r.prototype.brightness=function(t,e){var n=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(n,e)},r.prototype.greyscale=function(t,e){var n=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(n,e)},r.prototype.grayscale=r.prototype.greyscale,r.prototype.blackAndWhite=function(t){this._loadMatrix([.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0],t)},r.prototype.hue=function(t,e){t=(t||0)/180*Math.PI;var n=Math.cos(t),i=Math.sin(t),s=.213,r=.715,a=.072,o=[s+.787*n+i*-s,r+n*-r+i*-r,a+n*-a+.928*i,0,0,s+n*-s+.143*i,r+n*(1-r)+.14*i,a+n*-a+-.283*i,0,0,s+n*-s+-.787*i,r+n*-r+i*r,a+.928*n+i*a,0,0,0,0,0,1,0];this._loadMatrix(o,e)},r.prototype.contrast=function(t,e){var n=(t||0)+1,i=-128*(n-1),s=[n,0,0,0,i,0,n,0,0,i,0,0,n,0,i,0,0,0,1,0];this._loadMatrix(s,e)},r.prototype.saturate=function(t,e){var n=2*(t||0)/3+1,i=-.5*(n-1),s=[n,i,i,0,0,i,n,i,0,0,i,i,n,0,0,0,0,0,1,0];this._loadMatrix(s,e)},r.prototype.desaturate=function(t){this.saturate(-1)},r.prototype.negative=function(t){this._loadMatrix([0,1,1,0,0,1,0,1,0,0,1,1,0,0,0,0,0,0,1,0],t)},r.prototype.sepia=function(t){this._loadMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0],t)},r.prototype.technicolor=function(t){this._loadMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0],t)},r.prototype.polaroid=function(t){this._loadMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0],t)},r.prototype.toBGR=function(t){this._loadMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0],t)},r.prototype.kodachrome=function(t){this._loadMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0],t)},r.prototype.browni=function(t){this._loadMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0],t)},r.prototype.vintage=function(t){this._loadMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0],t)},r.prototype.colorTone=function(t,e,n,i,s){var r=((n=n||16770432)>>16&255)/255,a=(n>>8&255)/255,o=(255&n)/255,l=((i=i||3375104)>>16&255)/255,u=(i>>8&255)/255,h=(255&i)/255,p=[.3,.59,.11,0,0,r,a,o,t=t||.2,0,l,u,h,e=e||.15,0,r-l,a-u,o-h,0,0];this._loadMatrix(p,s)},r.prototype.night=function(t,e){var n=[-2*(t=t||.1),-t,0,0,0,-t,0,t,0,0,0,t,2*t,0,0,0,0,0,1,0];this._loadMatrix(n,e)},r.prototype.predator=function(t,e){var n=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(n,e)},r.prototype.lsd=function(t){this._loadMatrix([2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0],t)},r.prototype.reset=function(){this._loadMatrix([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],!1)},Object.defineProperties(r.prototype,{matrix:{get:function(){return this.uniforms.m.value},set:function(t){this.uniforms.m.value=t}}})},3640:(t,e,n)=>{var i=n(4651),s=n(8884);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//colorStep.frag","utf8"),{step:{type:"1f",value:5}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{step:{get:function(){return this.uniforms.step.value},set:function(t){this.uniforms.step.value=t}}})},6982:(t,e,n)=>{var i=n(4651),s=n(8001);function r(t,e,n){i.AbstractFilter.call(this,null,s.readFileSync("//convolution.frag","utf8"),{matrix:{type:"1fv",value:new Float32Array(t)},texelSize:{type:"v2",value:{x:1/e,y:1/n}}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{matrix:{get:function(){return this.uniforms.matrix.value},set:function(t){this.uniforms.matrix.value=new Float32Array(t)}},width:{get:function(){return 1/this.uniforms.texelSize.value.x},set:function(t){this.uniforms.texelSize.value.x=1/t}},height:{get:function(){return 1/this.uniforms.texelSize.value.y},set:function(t){this.uniforms.texelSize.value.y=1/t}}})},6280:(t,e,n)=>{var i=n(4651),s=n(1613);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//crosshatch.frag","utf8"))}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r},8286:(t,e,n)=>{var i=n(4651),s=n(5312);function r(t,e){var n=new i.Matrix;t.renderable=!1,i.AbstractFilter.call(this,s.readFileSync("//displacement.vert","utf8"),s.readFileSync("//displacement.frag","utf8"),{mapSampler:{type:"sampler2D",value:t.texture},otherMatrix:{type:"mat3",value:n.toArray(!0)},scale:{type:"v2",value:{x:1,y:1}}}),this.maskSprite=t,this.maskMatrix=n,null==e&&(e=20),this.scale=new i.Point(e,e)}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n){var i=t.filterManager;i.calculateMappedMatrix(e.frame,this.maskSprite,this.maskMatrix),this.uniforms.otherMatrix.value=this.maskMatrix.toArray(!0),this.uniforms.scale.value.x=this.scale.x*(1/e.frame.width),this.uniforms.scale.value.y=this.scale.y*(1/e.frame.height);var s=this.getShader(t);i.applyFilter(s,e,n)},Object.defineProperties(r.prototype,{map:{get:function(){return this.uniforms.mapSampler.value},set:function(t){this.uniforms.mapSampler.value=t}}})},3466:(t,e,n)=>{var i=n(4651),s=n(9032);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//dotScreen.frag","utf8"),{scale:{type:"1f",value:1},angle:{type:"1f",value:5},dimensions:{type:"4fv",value:[0,0,0,0]}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{scale:{get:function(){return this.uniforms.scale.value},set:function(t){this.uniforms.scale.value=t}},angle:{get:function(){return this.uniforms.angle.value},set:function(t){this.uniforms.angle.value=t}}})},5038:(t,e,n)=>{var i=n(4651),s=n(574);function r(){i.AbstractFilter.call(this,s.readFileSync("//blurYTint.vert","utf8"),s.readFileSync("//blurYTint.frag","utf8"),{blur:{type:"1f",value:1/512},color:{type:"c",value:[0,0,0]},alpha:{type:"1f",value:.7},offset:{type:"2f",value:[5,5]},strength:{type:"1f",value:1}}),this.passes=1,this.strength=4}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.applyFilter=function(t,e,n,i){var s=this.getShader(t);if(this.uniforms.strength.value=this.strength/4/this.passes*(e.frame.height/e.size.height),1===this.passes)t.filterManager.applyFilter(s,e,n,i);else{for(var r=t.filterManager.getRenderTarget(!0),a=e,o=r,l=0;l<this.passes-1;l++){t.filterManager.applyFilter(s,a,o,i);var u=o;o=a,a=u}t.filterManager.applyFilter(s,a,n,i),t.filterManager.returnRenderTarget(r)}},Object.defineProperties(r.prototype,{blur:{get:function(){return this.strength},set:function(t){this.padding=.5*t,this.strength=t}}})},1726:(t,e,n)=>{var i=n(4651),s=n(4356),r=n(5038);function a(){i.AbstractFilter.call(this),this.blurXFilter=new s,this.blurYTintFilter=new r,this.defaultFilter=new i.AbstractFilter,this.padding=30,this._dirtyPosition=!0,this._angle=45*Math.PI/180,this._distance=10,this.alpha=.75,this.hideObject=!1,this.blendMode=i.BLEND_MODES.MULTIPLY}a.prototype=Object.create(i.AbstractFilter.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.applyFilter=function(t,e,n){var s=t.filterManager.getRenderTarget(!0);this._dirtyPosition&&(this._dirtyPosition=!1,this.blurYTintFilter.uniforms.offset.value[0]=Math.sin(this._angle)*this._distance,this.blurYTintFilter.uniforms.offset.value[1]=Math.cos(this._angle)*this._distance),this.blurXFilter.applyFilter(t,e,s),t.blendModeManager.setBlendMode(this.blendMode),this.blurYTintFilter.applyFilter(t,s,n),t.blendModeManager.setBlendMode(i.BLEND_MODES.NORMAL),this.hideObject||this.defaultFilter.applyFilter(t,e,n),t.filterManager.returnRenderTarget(s)},Object.defineProperties(a.prototype,{blur:{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=this.blurYTintFilter.blur=t}},blurX:{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=t}},blurY:{get:function(){return this.blurYTintFilter.blur},set:function(t){this.blurYTintFilter.blur=t}},color:{get:function(){return i.utils.rgb2hex(this.blurYTintFilter.uniforms.color.value)},set:function(t){this.blurYTintFilter.uniforms.color.value=i.utils.hex2rgb(t)}},alpha:{get:function(){return this.blurYTintFilter.uniforms.alpha.value},set:function(t){this.blurYTintFilter.uniforms.alpha.value=t}},distance:{get:function(){return this._distance},set:function(t){this._dirtyPosition=!0,this._distance=t}},angle:{get:function(){return this._angle},set:function(t){this._dirtyPosition=!0,this._angle=t}}})},5518:(t,e,n)=>{var i=n(4651),s=n(2672);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//gray.frag","utf8"),{gray:{type:"1f",value:1}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{gray:{get:function(){return this.uniforms.gray.value},set:function(t){this.uniforms.gray.value=t}}})},8319:(t,e,n)=>{
/**
* @file Main export of the PIXI filters library
* @author Mat Groves <mat@goodboydigital.com>
* @copyright 2013-2015 GoodBoyDigital
* @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License}
*/
t.exports={AsciiFilter:n(4350),BloomFilter:n(5966),BlurFilter:n(6762),BlurXFilter:n(4356),BlurYFilter:n(6160),BlurDirFilter:n(415),ColorMatrixFilter:n(9375),ColorStepFilter:n(3640),ConvolutionFilter:n(6982),CrossHatchFilter:n(6280),DisplacementFilter:n(8286),DotScreenFilter:n(3466),GrayFilter:n(5518),DropShadowFilter:n(1726),InvertFilter:n(5976),NoiseFilter:n(7898),PixelateFilter:n(240),RGBSplitFilter:n(1952),ShockwaveFilter:n(2942),SepiaFilter:n(3578),SmartBlurFilter:n(1327),TiltShiftFilter:n(6422),TiltShiftXFilter:n(3080),TiltShiftYFilter:n(4407),TwistFilter:n(7326)}},5976:(t,e,n)=>{var i=n(4651),s=n(8215);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//invert.frag","utf8"),{invert:{type:"1f",value:1}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{invert:{get:function(){return this.uniforms.invert.value},set:function(t){this.uniforms.invert.value=t}}})},7898:(t,e,n)=>{var i=n(4651),s=n(1417);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//noise.frag","utf8"),{noise:{type:"1f",value:.5}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{noise:{get:function(){return this.uniforms.noise.value},set:function(t){this.uniforms.noise.value=t}}})},240:(t,e,n)=>{var i=n(4651),s=n(9391);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//pixelate.frag","utf8"),{dimensions:{type:"4fv",value:new Float32Array([0,0,0,0])},pixelSize:{type:"v2",value:{x:10,y:10}}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{size:{get:function(){return this.uniforms.pixelSize.value},set:function(t){this.uniforms.pixelSize.value=t}}})},1952:(t,e,n)=>{var i=n(4651),s=n(3220);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//rgbSplit.frag","utf8"),{red:{type:"v2",value:{x:20,y:20}},green:{type:"v2",value:{x:-20,y:20}},blue:{type:"v2",value:{x:20,y:-20}},dimensions:{type:"4fv",value:[0,0,0,0]}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{red:{get:function(){return this.uniforms.red.value},set:function(t){this.uniforms.red.value=t}},green:{get:function(){return this.uniforms.green.value},set:function(t){this.uniforms.green.value=t}},blue:{get:function(){return this.uniforms.blue.value},set:function(t){this.uniforms.blue.value=t}}})},3578:(t,e,n)=>{var i=n(4651),s=n(3985);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//sepia.frag","utf8"),{sepia:{type:"1f",value:1}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{sepia:{get:function(){return this.uniforms.sepia.value},set:function(t){this.uniforms.sepia.value=t}}})},2942:(t,e,n)=>{var i=n(4651),s=n(32);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//shockwave.frag","utf8"),{center:{type:"v2",value:{x:.5,y:.5}},params:{type:"v3",value:{x:10,y:.8,z:.1}},time:{type:"1f",value:0}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{center:{get:function(){return this.uniforms.center.value},set:function(t){this.uniforms.center.value=t}},params:{get:function(){return this.uniforms.params.value},set:function(t){this.uniforms.params.value=t}},time:{get:function(){return this.uniforms.time.value},set:function(t){this.uniforms.time.value=t}}})},1519:(t,e,n)=>{var i=n(4651),s=n(5650);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//tiltShift.frag","utf8"),{blur:{type:"1f",value:100},gradientBlur:{type:"1f",value:600},start:{type:"v2",value:{x:0,y:window.innerHeight/2}},end:{type:"v2",value:{x:600,y:window.innerHeight/2}},delta:{type:"v2",value:{x:30,y:30}},texSize:{type:"v2",value:{x:window.innerWidth,y:window.innerHeight}}}),this.updateDelta()}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.updateDelta=function(){this.uniforms.delta.value.x=0,this.uniforms.delta.value.y=0},Object.defineProperties(r.prototype,{blur:{get:function(){return this.uniforms.blur.value},set:function(t){this.uniforms.blur.value=t}},gradientBlur:{get:function(){return this.uniforms.gradientBlur.value},set:function(t){this.uniforms.gradientBlur.value=t}},start:{get:function(){return this.uniforms.start.value},set:function(t){this.uniforms.start.value=t,this.updateDelta()}},end:{get:function(){return this.uniforms.end.value},set:function(t){this.uniforms.end.value=t,this.updateDelta()}}})},6422:(t,e,n)=>{var i=n(4651),s=n(3080),r=n(4407);function a(){i.AbstractFilter.call(this),this.tiltShiftXFilter=new s,this.tiltShiftYFilter=new r}a.prototype=Object.create(i.AbstractFilter.prototype),a.prototype.constructor=a,t.exports=a,a.prototype.applyFilter=function(t,e,n){var i=t.filterManager.getRenderTarget(!0);this.tiltShiftXFilter.applyFilter(t,e,i),this.tiltShiftYFilter.applyFilter(t,i,n),t.filterManager.returnRenderTarget(i)},Object.defineProperties(a.prototype,{blur:{get:function(){return this.tiltShiftXFilter.blur},set:function(t){this.tiltShiftXFilter.blur=this.tiltShiftYFilter.blur=t}},gradientBlur:{get:function(){return this.tiltShiftXFilter.gradientBlur},set:function(t){this.tiltShiftXFilter.gradientBlur=this.tiltShiftYFilter.gradientBlur=t}},start:{get:function(){return this.tiltShiftXFilter.start},set:function(t){this.tiltShiftXFilter.start=this.tiltShiftYFilter.start=t}},end:{get:function(){return this.tiltShiftXFilter.end},set:function(t){this.tiltShiftXFilter.end=this.tiltShiftYFilter.end=t}}})},3080:(t,e,n)=>{var i=n(1519);function s(){i.call(this)}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s,s.prototype.updateDelta=function(){var t=this.uniforms.end.value.x-this.uniforms.start.value.x,e=this.uniforms.end.value.y-this.uniforms.start.value.y,n=Math.sqrt(t*t+e*e);this.uniforms.delta.value.x=t/n,this.uniforms.delta.value.y=e/n}},4407:(t,e,n)=>{var i=n(1519);function s(){i.call(this)}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,t.exports=s,s.prototype.updateDelta=function(){var t=this.uniforms.end.value.x-this.uniforms.start.value.x,e=this.uniforms.end.value.y-this.uniforms.start.value.y,n=Math.sqrt(t*t+e*e);this.uniforms.delta.value.x=-e/n,this.uniforms.delta.value.y=t/n}},7326:(t,e,n)=>{var i=n(4651),s=n(6644);function r(){i.AbstractFilter.call(this,null,s.readFileSync("//twist.frag","utf8"),{radius:{type:"1f",value:.5},angle:{type:"1f",value:5},offset:{type:"v2",value:{x:.5,y:.5}}})}r.prototype=Object.create(i.AbstractFilter.prototype),r.prototype.constructor=r,t.exports=r,Object.defineProperties(r.prototype,{offset:{get:function(){return this.uniforms.offset.value},set:function(t){this.uniforms.offset.value=t}},radius:{get:function(){return this.uniforms.radius.value},set:function(t){this.uniforms.radius.value=t}},angle:{get:function(){return this.uniforms.angle.value},set:function(t){this.uniforms.angle.value=t}}})},6619:(t,e,n)=>{n(255);var i=t.exports=n(4651);i.extras=n(3323),i.filters=n(8319),i.interaction=n(4816),i.loaders=n(5296),i.mesh=n(8653),i.loader=new i.loaders.Loader,Object.assign(i,n(9513)),n.g.PIXI=i},9440:(t,e,n)=>{var i=n(4651);function s(){this.global=new i.Point,this.target=null,this.originalEvent=null}s.prototype.constructor=s,t.exports=s,s.prototype.getLocalPosition=function(t,e,n){return t.toLocal(n||this.global,e)}},509:(t,e,n)=>{var i=n(4651),s=n(9440);function r(t,e){e=e||{},this.renderer=t,this.autoPreventDefault=void 0===e.autoPreventDefault||e.autoPreventDefault,this.interactionFrequency=e.interactionFrequency||10,this.mouse=new s,this.eventData={stopped:!1,target:null,type:null,data:this.mouse,stopPropagation:function(){this.stopped=!0}},this.interactiveDataPool=[],this.interactionDOMElement=null,this.eventsAdded=!1,this.onMouseUp=this.onMouseUp.bind(this),this.processMouseUp=this.processMouseUp.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.processMouseDown=this.processMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.processMouseMove=this.processMouseMove.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.processMouseOverOut=this.processMouseOverOut.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.processTouchStart=this.processTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.processTouchEnd=this.processTouchEnd.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.processTouchMove=this.processTouchMove.bind(this),this.last=0,this.currentCursorStyle="inherit",this._tempPoint=new i.Point,this.resolution=1,this.setTargetElement(this.renderer.view,this.renderer.resolution)}Object.assign(i.DisplayObject.prototype,n(4241)),r.prototype.constructor=r,t.exports=r,r.prototype.setTargetElement=function(t,e){this.removeEvents(),this.interactionDOMElement=t,this.resolution=e||1,this.addEvents()},r.prototype.addEvents=function(){this.interactionDOMElement&&(i.ticker.shared.add(this.update,this),window.navigator.msPointerEnabled&&(this.interactionDOMElement.style["-ms-content-zooming"]="none",this.interactionDOMElement.style["-ms-touch-action"]="none"),window.document.addEventListener("mousemove",this.onMouseMove,!0),this.interactionDOMElement.addEventListener("mousedown",this.onMouseDown,!0),this.interactionDOMElement.addEventListener("mouseout",this.onMouseOut,!0),this.interactionDOMElement.addEventListener("touchstart",this.onTouchStart,!0),this.interactionDOMElement.addEventListener("touchend",this.onTouchEnd,!0),this.interactionDOMElement.addEventListener("touchmove",this.onTouchMove,!0),window.addEventListener("mouseup",this.onMouseUp,!0),this.eventsAdded=!0)},r.prototype.removeEvents=function(){this.interactionDOMElement&&(i.ticker.shared.remove(this.update),window.navigator.msPointerEnabled&&(this.interactionDOMElement.style["-ms-content-zooming"]="",this.interactionDOMElement.style["-ms-touch-action"]=""),window.document.removeEventListener("mousemove",this.onMouseMove,!0),this.interactionDOMElement.removeEventListener("mousedown",this.onMouseDown,!0),this.interactionDOMElement.removeEventListener("mouseout",this.onMouseOut,!0),this.interactionDOMElement.removeEventListener("touchstart",this.onTouchStart,!0),this.interactionDOMElement.removeEventListener("touchend",this.onTouchEnd,!0),this.interactionDOMElement.removeEventListener("touchmove",this.onTouchMove,!0),this.interactionDOMElement=null,window.removeEventListener("mouseup",this.onMouseUp,!0),this.eventsAdded=!1)},r.prototype.update=function(t){this._deltaTime+=t,this._deltaTime<this.interactionFrequency||(this._deltaTime=0,this.interactionDOMElement&&(this.didMove?this.didMove=!1:(this.cursor="inherit",this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseOverOut,!0),this.currentCursorStyle!==this.cursor&&(this.currentCursorStyle=this.cursor,this.interactionDOMElement.style.cursor=this.cursor))))},r.prototype.dispatchEvent=function(t,e,n){n.stopped||(n.target=t,n.type=e,t.emit(e,n),t[e]&&t[e](n))},r.prototype.mapPositionToPoint=function(t,e,n){var i=this.interactionDOMElement.getBoundingClientRect();t.x=(e-i.left)*(this.interactionDOMElement.width/i.width)/this.resolution,t.y=(n-i.top)*(this.interactionDOMElement.height/i.height)/this.resolution},r.prototype.processInteractive=function(t,e,n,i,s){if(!e||!e.visible)return!1;var r=e.children,a=!1;if(s=s||e.interactive,e.interactiveChildren)for(var o=r.length-1;o>=0;o--)!a&&i?a=this.processInteractive(t,r[o],n,!0,s):this.processInteractive(t,r[o],n,!1,!1);return s&&(i&&(e.hitArea?(e.worldTransform.applyInverse(t,this._tempPoint),a=e.hitArea.contains(this._tempPoint.x,this._tempPoint.y)):e.containsPoint&&(a=e.containsPoint(t))),e.interactive&&n(e,a)),a},r.prototype.onMouseDown=function(t){this.mouse.originalEvent=t,this.eventData.data=this.mouse,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.autoPreventDefault&&this.mouse.originalEvent.preventDefault(),this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseDown,!0)},r.prototype.processMouseDown=function(t,e){var n=this.mouse.originalEvent,i=2===n.button||3===n.which;e&&(t[i?"_isRightDown":"_isLeftDown"]=!0,this.dispatchEvent(t,i?"rightdown":"mousedown",this.eventData))},r.prototype.onMouseUp=function(t){this.mouse.originalEvent=t,this.eventData.data=this.mouse,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseUp,!0)},r.prototype.processMouseUp=function(t,e){var n=this.mouse.originalEvent,i=2===n.button||3===n.which,s=i?"_isRightDown":"_isLeftDown";e?(this.dispatchEvent(t,i?"rightup":"mouseup",this.eventData),t[s]&&(t[s]=!1,this.dispatchEvent(t,i?"rightclick":"click",this.eventData))):t[s]&&(t[s]=!1,this.dispatchEvent(t,i?"rightupoutside":"mouseupoutside",this.eventData))},r.prototype.onMouseMove=function(t){this.mouse.originalEvent=t,this.eventData.data=this.mouse,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.didMove=!0,this.cursor="inherit",this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseMove,!0),this.currentCursorStyle!==this.cursor&&(this.currentCursorStyle=this.cursor,this.interactionDOMElement.style.cursor=this.cursor)},r.prototype.processMouseMove=function(t,e){this.dispatchEvent(t,"mousemove",this.eventData),this.processMouseOverOut(t,e)},r.prototype.onMouseOut=function(t){this.mouse.originalEvent=t,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.interactionDOMElement.style.cursor="inherit",this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseOverOut,!1)},r.prototype.processMouseOverOut=function(t,e){e?(t._over||(t._over=!0,this.dispatchEvent(t,"mouseover",this.eventData)),t.buttonMode&&(this.cursor=t.defaultCursor)):t._over&&(t._over=!1,this.dispatchEvent(t,"mouseout",this.eventData))},r.prototype.onTouchStart=function(t){this.autoPreventDefault&&t.preventDefault();for(var e=t.changedTouches,n=e.length,i=0;i<n;i++){var s=e[i],r=this.getTouchData(s);r.originalEvent=t,this.eventData.data=r,this.eventData.stopped=!1,this.processInteractive(r.global,this.renderer._lastObjectRendered,this.processTouchStart,!0),this.returnTouchData(r)}},r.prototype.processTouchStart=function(t,e){e&&(t._touchDown=!0,this.dispatchEvent(t,"touchstart",this.eventData))},r.prototype.onTouchEnd=function(t){this.autoPreventDefault&&t.preventDefault();for(var e=t.changedTouches,n=e.length,i=0;i<n;i++){var s=e[i],r=this.getTouchData(s);r.originalEvent=t,this.eventData.data=r,this.eventData.stopped=!1,this.processInteractive(r.global,this.renderer._lastObjectRendered,this.processTouchEnd,!0),this.returnTouchData(r)}},r.prototype.processTouchEnd=function(t,e){e?(this.dispatchEvent(t,"touchend",this.eventData),t._touchDown&&(t._touchDown=!1,this.dispatchEvent(t,"tap",this.eventData))):t._touchDown&&(t._touchDown=!1,this.dispatchEvent(t,"touchendoutside",this.eventData))},r.prototype.onTouchMove=function(t){this.autoPreventDefault&&t.preventDefault();for(var e=t.changedTouches,n=e.length,i=0;i<n;i++){var s=e[i],r=this.getTouchData(s);r.originalEvent=t,this.eventData.data=r,this.eventData.stopped=!1,this.processInteractive(r.global,this.renderer._lastObjectRendered,this.processTouchMove,!0),this.returnTouchData(r)}},r.prototype.processTouchMove=function(t,e){this.dispatchEvent(t,"touchmove",this.eventData)},r.prototype.getTouchData=function(t){var e=this.interactiveDataPool.pop();return e||(e=new s),e.identifier=t.identifier,this.mapPositionToPoint(e.global,t.clientX,t.clientY),navigator.isCocoonJS&&(e.global.x=e.global.x/this.resolution,e.global.y=e.global.y/this.resolution),t.globalX=e.global.x,t.globalY=e.global.y,e},r.prototype.returnTouchData=function(t){this.interactiveDataPool.push(t)},r.prototype.destroy=function(){this.removeEvents(),this.renderer=null,this.mouse=null,this.eventData=null,this.interactiveDataPool=null,this.interactionDOMElement=null,this.onMouseUp=null,this.processMouseUp=null,this.onMouseDown=null,this.processMouseDown=null,this.onMouseMove=null,this.processMouseMove=null,this.onMouseOut=null,this.processMouseOverOut=null,this.onTouchStart=null,this.processTouchStart=null,this.onTouchEnd=null,this.processTouchEnd=null,this.onTouchMove=null,this.processTouchMove=null,this._tempPoint=null},i.WebGLRenderer.registerPlugin("interaction",r),i.CanvasRenderer.registerPlugin("interaction",r)},4816:(t,e,n)=>{
/**
* @file Main export of the PIXI interactions library
* @author Mat Groves <mat@goodboydigital.com>
* @copyright 2013-2015 GoodBoyDigital
* @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License}
*/
t.exports={InteractionData:n(9440),InteractionManager:n(509),interactiveTarget:n(4241)}},4241:t=>{t.exports={interactive:!1,buttonMode:!1,interactiveChildren:!0,defaultCursor:"pointer",_over:!1,_touchDown:!1}},4095:(t,e,n)=>{var i=n(542).Resource,s=n(4651),r=n(3323),a=n(6944);function o(t,e){var n={},i=t.data.getElementsByTagName("info")[0],a=t.data.getElementsByTagName("common")[0];n.font=i.getAttribute("face"),n.size=parseInt(i.getAttribute("size"),10),n.lineHeight=parseInt(a.getAttribute("lineHeight"),10),n.chars={};for(var o=t.data.getElementsByTagName("char"),l=0;l<o.length;l++){var u=parseInt(o[l].getAttribute("id"),10),h=new s.Rectangle(parseInt(o[l].getAttribute("x"),10)+e.frame.x,parseInt(o[l].getAttribute("y"),10)+e.frame.y,parseInt(o[l].getAttribute("width"),10),parseInt(o[l].getAttribute("height"),10));n.chars[u]={xOffset:parseInt(o[l].getAttribute("xoffset"),10),yOffset:parseInt(o[l].getAttribute("yoffset"),10),xAdvance:parseInt(o[l].getAttribute("xadvance"),10),kerning:{},texture:new s.Texture(e.baseTexture,h)}}var p=t.data.getElementsByTagName("kerning");for(l=0;l<p.length;l++){var c=parseInt(p[l].getAttribute("first"),10),d=parseInt(p[l].getAttribute("second"),10),f=parseInt(p[l].getAttribute("amount"),10);n.chars[d].kerning[c]=f}t.bitmapFont=n,r.BitmapText.fonts[n.font]=n}t.exports=function(){return function(t,e){if(!t.data||!t.isXml)return e();if(0===t.data.getElementsByTagName("page").length||0===t.data.getElementsByTagName("info").length||null===t.data.getElementsByTagName("info")[0].getAttribute("face"))return e();var n=a.dirname(t.url);"."===n&&(n=""),this.baseUrl&&n&&("/"===this.baseUrl.charAt(this.baseUrl.length-1)&&(n+="/"),n=n.replace(this.baseUrl,"")),n&&"/"!==n.charAt(n.length-1)&&(n+="/");var r=n+t.data.getElementsByTagName("page")[0].getAttribute("file");if(s.utils.TextureCache[r])o(t,s.utils.TextureCache[r]),e();else{var l={crossOrigin:t.crossOrigin,loadType:i.LOAD_TYPE.IMAGE};this.add(t.name+"_image",r,l,(function(n){o(t,n.texture),e()}))}}}},5296:(t,e,n)=>{
/**
* @file Main export of the PIXI loaders library
* @author Mat Groves <mat@goodboydigital.com>
* @copyright 2013-2015 GoodBoyDigital
* @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License}
*/
t.exports={Loader:n(7397),bitmapFontParser:n(4095),spritesheetParser:n(6695),textureParser:n(3968),Resource:n(542).Resource}},7397:(t,e,n)=>{var i=n(542),s=n(3968),r=n(6695),a=n(4095);function o(t,e){i.call(this,t,e);for(var n=0;n<o._pixiMiddleware.length;++n)this.use(o._pixiMiddleware[n]())}o.prototype=Object.create(i.prototype),o.prototype.constructor=o,t.exports=o,o._pixiMiddleware=[i.middleware.parsing.blob,s,r,a],o.addPixiMiddleware=function(t){o._pixiMiddleware.push(t)};var l=i.Resource;l.setExtensionXhrType("fnt",l.XHR_RESPONSE_TYPE.DOCUMENT)},6695:(t,e,n)=>{var i=n(542).Resource,s=n(6944),r=n(4651);t.exports=function(){return function(t,e){if(!t.data||!t.isJson||!t.data.frames)return e();var n={crossOrigin:t.crossOrigin,loadType:i.LOAD_TYPE.IMAGE},a=s.dirname(t.url.replace(this.baseUrl,"")),o=r.utils.getResolutionOfUrl(t.url);this.add(t.name+"_image",a+"/"+t.data.meta.image,n,(function(n){t.textures={};var i=t.data.frames;for(var s in i){var a=i[s].frame;if(a){var l=null,u=null;if(l=i[s].rotated?new r.Rectangle(a.x,a.y,a.h,a.w):new r.Rectangle(a.x,a.y,a.w,a.h),i[s].trimmed&&(u=new r.Rectangle(i[s].spriteSourceSize.x/o,i[s].spriteSourceSize.y/o,i[s].sourceSize.w/o,i[s].sourceSize.h/o)),i[s].rotated){var h=l.width;l.width=l.height,l.height=h}l.x/=o,l.y/=o,l.width/=o,l.height/=o,t.textures[s]=new r.Texture(n.texture.baseTexture,l,l.clone(),u,i[s].rotated),r.utils.TextureCache[s]=t.textures[s]}}e()}))}}},3968:(t,e,n)=>{var i=n(4651);t.exports=function(){return function(t,e){if(t.data&&t.isImage){var n=new i.BaseTexture(t.data,null,i.utils.getResolutionOfUrl(t.url));n.imageUrl=t.url,t.texture=new i.Texture(n),i.utils.BaseTextureCache[t.url]=n,i.utils.TextureCache[t.url]=t.texture}e()}}},2876:(t,e,n)=>{var i=n(4651),s=new i.Point,r=new i.Polygon;function a(t,e,n,s,r){i.Container.call(this),this._texture=null,this.uvs=n||new Float32Array([0,1,1,1,1,0,0,1]),this.vertices=e||new Float32Array([0,0,100,0,100,100,0,100]),this.indices=s||new Uint16Array([0,1,2,3]),this.dirty=!0,this.blendMode=i.BLEND_MODES.NORMAL,this.canvasPadding=0,this.drawMode=r||a.DRAW_MODES.TRIANGLE_MESH,this.texture=t}a.prototype=Object.create(i.Container.prototype),a.prototype.constructor=a,t.exports=a,Object.defineProperties(a.prototype,{texture:{get:function(){return this._texture},set:function(t){this._texture!==t&&(this._texture=t,t&&(t.baseTexture.hasLoaded?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}}),a.prototype._renderWebGL=function(t){t.setObjectRenderer(t.plugins.mesh),t.plugins.mesh.render(this)},a.prototype._renderCanvas=function(t){var e=t.context,n=this.worldTransform;t.roundPixels?e.setTransform(n.a,n.b,n.c,n.d,0|n.tx,0|n.ty):e.setTransform(n.a,n.b,n.c,n.d,n.tx,n.ty),this.drawMode===a.DRAW_MODES.TRIANGLE_MESH?this._renderCanvasTriangleMesh(e):this._renderCanvasTriangles(e)},a.prototype._renderCanvasTriangleMesh=function(t){for(var e=this.vertices,n=this.uvs,i=e.length/2,s=0;s<i-2;s++){var r=2*s;this._renderCanvasDrawTriangle(t,e,n,r,r+2,r+4)}},a.prototype._renderCanvasTriangles=function(t){for(var e=this.vertices,n=this.uvs,i=this.indices,s=i.length,r=0;r<s;r+=3){var a=2*i[r],o=2*i[r+1],l=2*i[r+2];this._renderCanvasDrawTriangle(t,e,n,a,o,l)}},a.prototype._renderCanvasDrawTriangle=function(t,e,n,i,s,r){var a=this._texture.baseTexture.source,o=this._texture.baseTexture.width,l=this._texture.baseTexture.height,u=e[i],h=e[s],p=e[r],c=e[i+1],d=e[s+1],f=e[r+1],m=n[i]*o,g=n[s]*o,_=n[r]*o,T=n[i+1]*l,y=n[s+1]*l,I=n[r+1]*l;if(this.canvasPadding>0){var E=this.canvasPadding/this.worldTransform.a,b=this.canvasPadding/this.worldTransform.d,v=(u+h+p)/3,w=(c+d+f)/3,S=u-v,x=c-w,R=Math.sqrt(S*S+x*x);u=v+S/R*(R+E),c=w+x/R*(R+b),x=d-w,h=v+(S=h-v)/(R=Math.sqrt(S*S+x*x))*(R+E),d=w+x/R*(R+b),x=f-w,p=v+(S=p-v)/(R=Math.sqrt(S*S+x*x))*(R+E),f=w+x/R*(R+b)}t.save(),t.beginPath(),t.moveTo(u,c),t.lineTo(h,d),t.lineTo(p,f),t.closePath(),t.clip();var O=m*y+T*_+g*I-y*_-T*g-m*I,A=u*y+T*p+h*I-y*p-T*h-u*I,M=m*h+u*_+g*p-h*_-u*g-m*p,C=m*y*p+T*h*_+u*g*I-u*y*_-T*g*p-m*h*I,N=c*y+T*f+d*I-y*f-T*d-c*I,k=m*d+c*_+g*f-d*_-c*g-m*f,D=m*y*f+T*d*_+c*g*I-c*y*_-T*g*f-m*d*I;t.transform(A/O,N/O,M/O,k/O,C/O,D/O),t.drawImage(a,0,0),t.restore()},a.prototype.renderMeshFlat=function(t){var e=this.context,n=t.vertices,i=n.length/2;e.beginPath();for(var s=1;s<i-2;s++){var r=2*s,a=n[r],o=n[r+2],l=n[r+4],u=n[r+1],h=n[r+3],p=n[r+5];e.moveTo(a,u),e.lineTo(o,h),e.lineTo(l,p)}e.fillStyle="#FF0000",e.fill(),e.closePath()},a.prototype._onTextureUpdate=function(){this.updateFrame=!0},a.prototype.getBounds=function(t){if(!this._currentBounds){for(var e=t||this.worldTransform,n=e.a,s=e.b,r=e.c,a=e.d,o=e.tx,l=e.ty,u=-1/0,h=-1/0,p=1/0,c=1/0,d=this.vertices,f=0,m=d.length;f<m;f+=2){var g=d[f],_=d[f+1],T=n*g+r*_+o,y=a*_+s*g+l;p=T<p?T:p,c=y<c?y:c,u=T>u?T:u,h=y>h?y:h}if(p===-1/0||h===1/0)return i.Rectangle.EMPTY;var I=this._bounds;I.x=p,I.width=u-p,I.y=c,I.height=h-c,this._currentBounds=I}return this._currentBounds},a.prototype.containsPoint=function(t){if(!this.getBounds().contains(t.x,t.y))return!1;this.worldTransform.applyInverse(t,s);var e,n,i=this.vertices,o=r.points;if(this.drawMode===a.DRAW_MODES.TRIANGLES){var l=this.indices;for(n=this.indices.length,e=0;e<n;e+=3){var u=2*l[e],h=2*l[e+1],p=2*l[e+2];if(o[0]=i[u],o[1]=i[u+1],o[2]=i[h],o[3]=i[h+1],o[4]=i[p],o[5]=i[p+1],r.contains(s.x,s.y))return!0}}else for(n=i.length,e=0;e<n;e+=6)if(o[0]=i[e],o[1]=i[e+1],o[2]=i[e+2],o[3]=i[e+3],o[4]=i[e+4],o[5]=i[e+5],r.contains(s.x,s.y))return!0;return!1},a.DRAW_MODES={TRIANGLE_MESH:0,TRIANGLES:1}},7005:(t,e,n)=>{var i=n(2876),s=n(4651);function r(t,e){i.call(this,t),this.points=e,this.vertices=new Float32Array(4*e.length),this.uvs=new Float32Array(4*e.length),this.colors=new Float32Array(2*e.length),this.indices=new Uint16Array(2*e.length),this._ready=!0,this.refresh()}r.prototype=Object.create(i.prototype),r.prototype.constructor=r,t.exports=r,r.prototype.refresh=function(){var t=this.points;if(!(t.length<1)&&this._texture._uvs){var e=this.uvs,n=this.indices,i=this.colors,r=this._texture._uvs,a=new s.Point(r.x0,r.y0),o=new s.Point(r.x2-r.x0,r.y2-r.y0);e[0]=0+a.x,e[1]=0+a.y,e[2]=0+a.x,e[3]=1*o.y+a.y,i[0]=1,i[1]=1,n[0]=0,n[1]=1;for(var l,u,h=t.length,p=1;p<h;p++)t[p],u=p/(h-1),e[l=4*p]=u*o.x+a.x,e[l+1]=0+a.y,e[l+2]=u*o.x+a.x,e[l+3]=1*o.y+a.y,i[l=2*p]=1,i[l+1]=1,n[l=2*p]=l,n[l+1]=l+1;this.dirty=!0}},r.prototype._onTextureUpdate=function(){i.prototype._onTextureUpdate.call(this),this._ready&&this.refresh()},r.prototype.updateTransform=function(){var t=this.points;if(!(t.length<1)){for(var e,n,i,s,r,a=t[0],o=0,l=0,u=this.vertices,h=t.length,p=0;p<h;p++)n=t[p],i=4*p,l=-((e=p<t.length-1?t[p+1]:n).x-a.x),o=e.y-a.y,10*(1-p/(h-1))>1&&1,o/=s=Math.sqrt(o*o+l*l),l/=s,o*=r=this._texture.height/2,l*=r,u[i]=n.x+o,u[i+1]=n.y+l,u[i+2]=n.x-o,u[i+3]=n.y-l,a=n;this.containerUpdateTransform()}}},8653:(t,e,n)=>{
/**
* @file Main export of the PIXI extras library
* @author Mat Groves <mat@goodboydigital.com>
* @copyright 2013-2015 GoodBoyDigital
* @license {@link https://github.com/pixijs/pixi.js/blob/master/LICENSE|MIT License}
*/
t.exports={Mesh:n(2876),Rope:n(7005),MeshRenderer:n(6709),MeshShader:n(2003)}},6709:(t,e,n)=>{var i=n(4651),s=n(2876);function r(t){i.ObjectRenderer.call(this,t),this.indices=new Uint16Array(15e3);for(var e=0,n=0;e<15e3;e+=6,n+=4)this.indices[e+0]=n+0,this.indices[e+1]=n+1,this.indices[e+2]=n+2,this.indices[e+3]=n+0,this.indices[e+4]=n+2,this.indices[e+5]=n+3}r.prototype=Object.create(i.ObjectRenderer.prototype),r.prototype.constructor=r,t.exports=r,i.WebGLRenderer.registerPlugin("mesh",r),r.prototype.onContextChange=function(){},r.prototype.render=function(t){t._vertexBuffer||this._initWebGL(t);var e=this.renderer,n=e.gl,i=t._texture.baseTexture,r=e.shaderManager.plugins.meshShader,a=t.drawMode===s.DRAW_MODES.TRIANGLE_MESH?n.TRIANGLE_STRIP:n.TRIANGLES;e.blendModeManager.setBlendMode(t.blendMode),n.uniformMatrix3fv(r.uniforms.translationMatrix._location,!1,t.worldTransform.toArray(!0)),n.uniformMatrix3fv(r.uniforms.projectionMatrix._location,!1,e.currentRenderTarget.projectionMatrix.toArray(!0)),n.uniform1f(r.uniforms.alpha._location,t.worldAlpha),t.dirty?(t.dirty=!1,n.bindBuffer(n.ARRAY_BUFFER,t._vertexBuffer),n.bufferData(n.ARRAY_BUFFER,t.vertices,n.STATIC_DRAW),n.vertexAttribPointer(r.attributes.aVertexPosition,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,t._uvBuffer),n.bufferData(n.ARRAY_BUFFER,t.uvs,n.STATIC_DRAW),n.vertexAttribPointer(r.attributes.aTextureCoord,2,n.FLOAT,!1,0,0),n.activeTexture(n.TEXTURE0),i._glTextures[n.id]?n.bindTexture(n.TEXTURE_2D,i._glTextures[n.id]):this.renderer.updateTexture(i),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t._indexBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.indices,n.STATIC_DRAW)):(n.bindBuffer(n.ARRAY_BUFFER,t._vertexBuffer),n.bufferSubData(n.ARRAY_BUFFER,0,t.vertices),n.vertexAttribPointer(r.attributes.aVertexPosition,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,t._uvBuffer),n.vertexAttribPointer(r.attributes.aTextureCoord,2,n.FLOAT,!1,0,0),n.activeTexture(n.TEXTURE0),i._glTextures[n.id]?n.bindTexture(n.TEXTURE_2D,i._glTextures[n.id]):this.renderer.updateTexture(i),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t._indexBuffer),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.indices)),n.drawElements(a,t.indices.length,n.UNSIGNED_SHORT,0)},r.prototype._initWebGL=function(t){var e=this.renderer.gl;t._vertexBuffer=e.createBuffer(),t._indexBuffer=e.createBuffer(),t._uvBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,t._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,t.vertices,e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,t._uvBuffer),e.bufferData(e.ARRAY_BUFFER,t.uvs,e.STATIC_DRAW),t.colors&&(t._colorBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,t._colorBuffer),e.bufferData(e.ARRAY_BUFFER,t.colors,e.STATIC_DRAW)),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,t.indices,e.STATIC_DRAW)},r.prototype.flush=function(){},r.prototype.start=function(){var t=this.renderer.shaderManager.plugins.meshShader;this.renderer.shaderManager.setShader(t)},r.prototype.destroy=function(){i.ObjectRenderer.prototype.destroy.call(this)}},2003:(t,e,n)=>{var i=n(4651);function s(t){i.Shader.call(this,t,["precision lowp float;","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 translationMatrix;","uniform mat3 projectionMatrix;","varying vec2 vTextureCoord;","void main(void){"," gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vTextureCoord = aTextureCoord;","}"].join("\n"),["precision lowp float;","varying vec2 vTextureCoord;","uniform float alpha;","uniform sampler2D uSampler;","void main(void){"," gl_FragColor = texture2D(uSampler, vTextureCoord) * alpha ;","}"].join("\n"),{alpha:{type:"1f",value:0},translationMatrix:{type:"mat3",value:new Float32Array(9)},projectionMatrix:{type:"mat3",value:new Float32Array(9)}},{aVertexPosition:0,aTextureCoord:0})}s.prototype=Object.create(i.Shader.prototype),s.prototype.constructor=s,t.exports=s,i.ShaderManager.registerPlugin("meshShader",s)},9206:()=>{Math.sign||(Math.sign=function(t){return 0===(t=+t)||isNaN(t)?t:t>0?1:-1})},7537:(t,e,n)=>{Object.assign||(Object.assign=n(5228))},255:(t,e,n)=>{n(7537),n(4377),n(9206)},4377:(t,e,n)=>{if(Date.now&&Date.prototype.getTime||(Date.now=function(){return(new Date).getTime()}),!n.g.performance||!n.g.performance.now){var i=Date.now();n.g.performance||(n.g.performance={}),n.g.performance.now=function(){return Date.now()-i}}for(var s=Date.now(),r=["ms","moz","webkit","o"],a=0;a<r.length&&!n.g.requestAnimationFrame;++a)n.g.requestAnimationFrame=n.g[r[a]+"RequestAnimationFrame"],n.g.cancelAnimationFrame=n.g[r[a]+"CancelAnimationFrame"]||n.g[r[a]+"CancelRequestAnimationFrame"];n.g.requestAnimationFrame||(n.g.requestAnimationFrame=function(t){if("function"!=typeof t)throw new TypeError(t+"is not a function");var e=Date.now(),n=16+s-e;return n<0&&(n=0),s=e,setTimeout((function(){s=Date.now(),t(performance.now())}),n)}),n.g.cancelAnimationFrame||(n.g.cancelAnimationFrame=function(t){clearTimeout(t)})},5606:t=>{var e,n,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function a(t){if(e===setTimeout)return setTimeout(t,0);if((e===s||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:s}catch(t){e=s}try{n="function"==typeof clearTimeout?clearTimeout:r}catch(t){n=r}}();var o,l=[],u=!1,h=-1;function p(){u&&o&&(u=!1,o.length?l=o.concat(l):h=-1,l.length&&c())}function c(){if(!u){var t=a(p);u=!0;for(var e=l.length;e;){for(o=l,l=[];++h<e;)o&&o[h].run();h=-1,e=l.length}o=null,u=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===r||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{return n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function d(t,e){this.fun=t,this.array=e}function f(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];l.push(new d(t,e)),1!==l.length||u||a(c)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=f,i.addListener=f,i.once=f,i.off=f,i.removeListener=f,i.removeAllListeners=f,i.emit=f,i.prependListener=f,i.prependOnceListener=f,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},9610:(t,e,n)=>{"use strict";n.d(e,{D:()=>i});var i=function(){function t(t){var e=this;void 0===t&&(t=!1),this.ignoreMultipleSettles=t,this.isSettled=!1,this.promise=new Promise((function(t,n){e.resolveCallback=t,e.rejectCallback=n}))}return t.prototype.markAsSettled=function(){var t=this.isSettled;if(t&&!this.ignoreMultipleSettles)throw new Error("PromiseDelegate is already settled!");return this.isSettled=!0,!t},Object.defineProperty(t.prototype,"settled",{get:function(){return this.isSettled},enumerable:!1,configurable:!0}),t.prototype.resolve=function(t){this.markAsSettled()&&this.resolveCallback(t)},t.prototype.reject=function(t){this.markAsSettled()&&this.rejectCallback(t)},t}()},5006:t=>{"use strict";var e=Object.prototype.hasOwnProperty,n="~";function i(){}function s(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function r(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),r.prototype.eventNames=function(){var t,i,s=[];if(0===this._eventsCount)return s;for(i in t=this._events)e.call(t,i)&&s.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(t)):s},r.prototype.listeners=function(t,e){var i=n?n+t:t,s=this._events[i];if(e)return!!s;if(!s)return[];if(s.fn)return[s.fn];for(var r=0,a=s.length,o=new Array(a);r<a;r++)o[r]=s[r].fn;return o},r.prototype.emit=function(t,e,i,s,r,a){var o=n?n+t:t;if(!this._events[o])return!1;var l,u,h=this._events[o],p=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),p){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,i),!0;case 4:return h.fn.call(h.context,e,i,s),!0;case 5:return h.fn.call(h.context,e,i,s,r),!0;case 6:return h.fn.call(h.context,e,i,s,r,a),!0}for(u=1,l=new Array(p-1);u<p;u++)l[u-1]=arguments[u];h.fn.apply(h.context,l)}else{var c,d=h.length;for(u=0;u<d;u++)switch(h[u].once&&this.removeListener(t,h[u].fn,void 0,!0),p){case 1:h[u].fn.call(h[u].context);break;case 2:h[u].fn.call(h[u].context,e);break;case 3:h[u].fn.call(h[u].context,e,i);break;case 4:h[u].fn.call(h[u].context,e,i,s);break;default:if(!l)for(c=1,l=new Array(p-1);c<p;c++)l[c-1]=arguments[c];h[u].fn.apply(h[u].context,l)}}return!0},r.prototype.on=function(t,e,i){var r=new s(e,i||this),a=n?n+t:t;return this._events[a]?this._events[a].fn?this._events[a]=[this._events[a],r]:this._events[a].push(r):(this._events[a]=r,this._eventsCount++),this},r.prototype.once=function(t,e,i){var r=new s(e,i||this,!0),a=n?n+t:t;return this._events[a]?this._events[a].fn?this._events[a]=[this._events[a],r]:this._events[a].push(r):(this._events[a]=r,this._eventsCount++),this},r.prototype.removeListener=function(t,e,s,r){var a=n?n+t:t;if(!this._events[a])return this;if(!e)return 0==--this._eventsCount?this._events=new i:delete this._events[a],this;var o=this._events[a];if(o.fn)o.fn!==e||r&&!o.once||s&&o.context!==s||(0==--this._eventsCount?this._events=new i:delete this._events[a]);else{for(var l=0,u=[],h=o.length;l<h;l++)(o[l].fn!==e||r&&!o[l].once||s&&o[l].context!==s)&&u.push(o[l]);u.length?this._events[a]=1===u.length?u[0]:u:0==--this._eventsCount?this._events=new i:delete this._events[a]}return this},r.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&(0==--this._eventsCount?this._events=new i:delete this._events[e])):(this._events=new i,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prototype.setMaxListeners=function(){return this},r.prefixed=n,r.EventEmitter=r,t.exports=r},3723:(t,e,n)=>{"use strict";var i=n(4678),s=n(978),r=n(8664),a=n(5006);function o(t,e){a.call(this),e=e||10,this.baseUrl=t||"",this.progress=0,this.loading=!1,this._progressChunk=0,this._beforeMiddleware=[],this._afterMiddleware=[],this._boundLoadResource=this._loadResource.bind(this),this._buffer=[],this._numToLoad=0,this._queue=s.queue(this._boundLoadResource,e),this.resources={}}o.prototype=Object.create(a.prototype),o.prototype.constructor=o,t.exports=o,o.prototype.add=o.prototype.enqueue=function(t,e,n,i){if(Array.isArray(t)){for(var s=0;s<t.length;++s)this.add(t[s]);return this}if("object"==typeof t&&(i=e||t.callback||t.onComplete,n=t,e=t.url,t=t.name||t.key||t.url),"string"!=typeof e&&(i=n,n=e,e=t),"string"!=typeof e)throw new Error("No url passed to add resource to loader.");if("function"==typeof n&&(i=n,n=null),this.resources[t])throw new Error('Resource with name "'+t+'" already exists.');return e=this._prepareUrl(e),this.resources[t]=new r(t,e,n),"function"==typeof i&&this.resources[t].once("afterMiddleware",i),this._numToLoad++,this._queue.started?(this._queue.push(this.resources[t]),this._progressChunk=(100-this.progress)/(this._queue.length()+this._queue.running())):(this._buffer.push(this.resources[t]),this._progressChunk=100/this._buffer.length),this},o.prototype.before=o.prototype.pre=function(t){return this._beforeMiddleware.push(t),this},o.prototype.after=o.prototype.use=function(t){return this._afterMiddleware.push(t),this},o.prototype.reset=function(){for(var t in this.progress=0,this.loading=!1,this._progressChunk=0,this._buffer.length=0,this._numToLoad=0,this._queue.kill(),this._queue.started=!1,this.resources){var e=this.resources[t];e.off("complete",this._onLoad,this),e.isLoading&&e.abort()}return this.resources={},this},o.prototype.load=function(t){if("function"==typeof t&&this.once("complete",t),this._queue.started)return this;this.emit("start",this),this.loading=!0;for(var e=0;e<this._buffer.length;++e)this._queue.push(this._buffer[e]);return this._buffer.length=0,this},o.prototype._prepareUrl=function(t){var e=i(t,{strictMode:!0});return e.protocol||!e.path||0===e.path.indexOf("//")?t:this.baseUrl.length&&this.baseUrl.lastIndexOf("/")!==this.baseUrl.length-1&&"/"!==t.charAt(0)?this.baseUrl+"/"+t:this.baseUrl+t},o.prototype._loadResource=function(t,e){var n=this;t._dequeue=e,s.eachSeries(this._beforeMiddleware,(function(e,i){e.call(n,t,(function(){i(t.isComplete?{}:null)}))}),(function(){t.isComplete?n._onLoad(t):(t.once("complete",n._onLoad,n),t.load())}))},o.prototype._onComplete=function(){this.loading=!1,this.emit("complete",this,this.resources)},o.prototype._onLoad=function(t){var e=this;s.eachSeries(this._afterMiddleware,(function(n,i){n.call(e,t,i)}),(function(){t.emit("afterMiddleware",t),e._numToLoad--,e.progress+=e._progressChunk,e.emit("progress",e,t),t.error?e.emit("error",t.error,e,t):e.emit("load",e,t),0===e._numToLoad&&(e.progress=100,e._onComplete())})),t._dequeue()},o.LOAD_TYPE=r.LOAD_TYPE,o.XHR_RESPONSE_TYPE=r.XHR_RESPONSE_TYPE},8664:(t,e,n)=>{"use strict";var i=n(5006),s=n(4678),r=!(!window.XDomainRequest||"withCredentials"in new XMLHttpRequest),a=null;function o(t,e,n){if(i.call(this),n=n||{},"string"!=typeof t||"string"!=typeof e)throw new Error("Both name and url are required for constructing a resource.");this.name=t,this.url=e,this.isDataUrl=0===this.url.indexOf("data:"),this.data=null,this.crossOrigin=!0===n.crossOrigin?"anonymous":n.crossOrigin,this.loadType=n.loadType||this._determineLoadType(),this.xhrType=n.xhrType,this.metadata=n.metadata||{},this.error=null,this.xhr=null,this.isJson=!1,this.isXml=!1,this.isImage=!1,this.isAudio=!1,this.isVideo=!1,this.isComplete=!1,this.isLoading=!1,this._dequeue=null,this._boundComplete=this.complete.bind(this),this._boundOnError=this._onError.bind(this),this._boundOnProgress=this._onProgress.bind(this),this._boundXhrOnError=this._xhrOnError.bind(this),this._boundXhrOnAbort=this._xhrOnAbort.bind(this),this._boundXhrOnLoad=this._xhrOnLoad.bind(this),this._boundXdrOnTimeout=this._xdrOnTimeout.bind(this)}function l(t){return t.toString().replace("object ","")}function u(t,e,n){e&&0===e.indexOf(".")&&(e=e.substring(1)),e&&(t[e]=n)}o.prototype=Object.create(i.prototype),o.prototype.constructor=o,t.exports=o,o.prototype.complete=function(){if(this.data&&this.data.removeEventListener&&(this.data.removeEventListener("error",this._boundOnError,!1),this.data.removeEventListener("load",this._boundComplete,!1),this.data.removeEventListener("progress",this._boundOnProgress,!1),this.data.removeEventListener("canplaythrough",this._boundComplete,!1)),this.xhr&&(this.xhr.removeEventListener?(this.xhr.removeEventListener("error",this._boundXhrOnError,!1),this.xhr.removeEventListener("abort",this._boundXhrOnAbort,!1),this.xhr.removeEventListener("progress",this._boundOnProgress,!1),this.xhr.removeEventListener("load",this._boundXhrOnLoad,!1)):(this.xhr.onerror=null,this.xhr.ontimeout=null,this.xhr.onprogress=null,this.xhr.onload=null)),this.isComplete)throw new Error("Complete called again for an already completed resource.");this.isComplete=!0,this.isLoading=!1,this.emit("complete",this)},o.prototype.abort=function(t){if(!this.error){if(this.error=new Error(t),this.xhr)this.xhr.abort();else if(this.xdr)this.xdr.abort();else if(this.data)if(void 0!==this.data.src)this.data.src="";else for(;this.data.firstChild;)this.data.removeChild(this.data.firstChild);this.complete()}},o.prototype.load=function(t){if(!this.isLoading)if(this.isComplete){if(t){var e=this;setTimeout((function(){t(e)}),1)}}else switch(t&&this.once("complete",t),this.isLoading=!0,this.emit("start",this),!1!==this.crossOrigin&&"string"==typeof this.crossOrigin||(this.crossOrigin=this._determineCrossOrigin(this.url)),this.loadType){case o.LOAD_TYPE.IMAGE:this._loadElement("image");break;case o.LOAD_TYPE.AUDIO:this._loadSourceElement("audio");break;case o.LOAD_TYPE.VIDEO:this._loadSourceElement("video");break;case o.LOAD_TYPE.XHR:default:r&&this.crossOrigin?this._loadXdr():this._loadXhr()}},o.prototype._loadElement=function(t){this.metadata.loadElement?this.data=this.metadata.loadElement:"image"===t&&void 0!==window.Image?this.data=new Image:this.data=document.createElement(t),this.crossOrigin&&(this.data.crossOrigin=this.crossOrigin),this.metadata.skipSource||(this.data.src=this.url);var e="is"+t[0].toUpperCase()+t.substring(1);!1===this[e]&&(this[e]=!0),this.data.addEventListener("error",this._boundOnError,!1),this.data.addEventListener("load",this._boundComplete,!1),this.data.addEventListener("progress",this._boundOnProgress,!1)},o.prototype._loadSourceElement=function(t){if(this.metadata.loadElement?this.data=this.metadata.loadElement:"audio"===t&&void 0!==window.Audio?this.data=new Audio:this.data=document.createElement(t),null!==this.data){if(!this.metadata.skipSource)if(navigator.isCocoonJS)this.data.src=Array.isArray(this.url)?this.url[0]:this.url;else if(Array.isArray(this.url))for(var e=0;e<this.url.length;++e)this.data.appendChild(this._createSource(t,this.url[e]));else this.data.appendChild(this._createSource(t,this.url));this["is"+t[0].toUpperCase()+t.substring(1)]=!0,this.data.addEventListener("error",this._boundOnError,!1),this.data.addEventListener("load",this._boundComplete,!1),this.data.addEventListener("progress",this._boundOnProgress,!1),this.data.addEventListener("canplaythrough",this._boundComplete,!1),this.data.load()}else this.abort("Unsupported element "+t)},o.prototype._loadXhr=function(){"string"!=typeof this.xhrType&&(this.xhrType=this._determineXhrType());var t=this.xhr=new XMLHttpRequest;t.open("GET",this.url,!0),this.xhrType===o.XHR_RESPONSE_TYPE.JSON||this.xhrType===o.XHR_RESPONSE_TYPE.DOCUMENT?t.responseType=o.XHR_RESPONSE_TYPE.TEXT:t.responseType=this.xhrType,t.addEventListener("error",this._boundXhrOnError,!1),t.addEventListener("abort",this._boundXhrOnAbort,!1),t.addEventListener("progress",this._boundOnProgress,!1),t.addEventListener("load",this._boundXhrOnLoad,!1),t.send()},o.prototype._loadXdr=function(){"string"!=typeof this.xhrType&&(this.xhrType=this._determineXhrType());var t=this.xhr=new XDomainRequest;t.timeout=5e3,t.onerror=this._boundXhrOnError,t.ontimeout=this._boundXdrOnTimeout,t.onprogress=this._boundOnProgress,t.onload=this._boundXhrOnLoad,t.open("GET",this.url,!0),setTimeout((function(){t.send()}),0)},o.prototype._createSource=function(t,e,n){n||(n=t+"/"+e.substr(e.lastIndexOf(".")+1));var i=document.createElement("source");return i.src=e,i.type=n,i},o.prototype._onError=function(t){this.abort("Failed to load element using "+t.target.nodeName)},o.prototype._onProgress=function(t){t&&t.lengthComputable&&this.emit("progress",this,t.loaded/t.total)},o.prototype._xhrOnError=function(){var t=this.xhr;this.abort(l(t)+" Request failed. Status: "+t.status+', text: "'+t.statusText+'"')},o.prototype._xhrOnAbort=function(){this.abort(l(this.xhr)+" Request was aborted by the user.")},o.prototype._xdrOnTimeout=function(){this.abort(l(this.xhr)+" Request timed out.")},o.prototype._xhrOnLoad=function(){var t=this.xhr,e=void 0===t.status?t.status:200;if(200===e||204===e||0===e&&t.responseText.length>0){if(this.xhrType===o.XHR_RESPONSE_TYPE.TEXT)this.data=t.responseText;else if(this.xhrType===o.XHR_RESPONSE_TYPE.JSON)try{this.data=JSON.parse(t.responseText),this.isJson=!0}catch(t){return void this.abort("Error trying to parse loaded json:",t)}else if(this.xhrType===o.XHR_RESPONSE_TYPE.DOCUMENT)try{if(window.DOMParser){var n=new DOMParser;this.data=n.parseFromString(t.responseText,"text/xml")}else{var i=document.createElement("div");i.innerHTML=t.responseText,this.data=i}this.isXml=!0}catch(t){return void this.abort("Error trying to parse loaded xml:",t)}else this.data=t.response||t.responseText;this.complete()}else this.abort("["+t.status+"]"+t.statusText+":"+t.responseURL)},o.prototype._determineCrossOrigin=function(t,e){if(0===t.indexOf("data:"))return"";e=e||window.location,a||(a=document.createElement("a")),a.href=t;var n=!(t=s(a.href,{strictMode:!0})).port&&""===e.port||t.port===e.port,i=t.protocol?t.protocol+":":"";return t.host===e.hostname&&n&&i===e.protocol?"":"anonymous"},o.prototype._determineXhrType=function(){return o._xhrTypeMap[this._getExtension()]||o.XHR_RESPONSE_TYPE.TEXT},o.prototype._determineLoadType=function(){return o._loadTypeMap[this._getExtension()]||o.LOAD_TYPE.XHR},o.prototype._getExtension=function(){var t=this.url,e="";if(this.isDataUrl){var n=t.indexOf("/");e=t.substring(n+1,t.indexOf(";",n))}else{var i=t.indexOf("?");-1!==i&&(t=t.substring(0,i)),e=t.substring(t.lastIndexOf(".")+1)}return e.toLowerCase()},o.prototype._getMimeFromXhrType=function(t){switch(t){case o.XHR_RESPONSE_TYPE.BUFFER:return"application/octet-binary";case o.XHR_RESPONSE_TYPE.BLOB:return"application/blob";case o.XHR_RESPONSE_TYPE.DOCUMENT:return"application/xml";case o.XHR_RESPONSE_TYPE.JSON:return"application/json";case o.XHR_RESPONSE_TYPE.DEFAULT:case o.XHR_RESPONSE_TYPE.TEXT:default:return"text/plain"}},o.LOAD_TYPE={XHR:1,IMAGE:2,AUDIO:3,VIDEO:4},o.XHR_RESPONSE_TYPE={DEFAULT:"text",BUFFER:"arraybuffer",BLOB:"blob",DOCUMENT:"document",JSON:"json",TEXT:"text"},o._loadTypeMap={gif:o.LOAD_TYPE.IMAGE,png:o.LOAD_TYPE.IMAGE,bmp:o.LOAD_TYPE.IMAGE,jpg:o.LOAD_TYPE.IMAGE,jpeg:o.LOAD_TYPE.IMAGE,tif:o.LOAD_TYPE.IMAGE,tiff:o.LOAD_TYPE.IMAGE,webp:o.LOAD_TYPE.IMAGE,tga:o.LOAD_TYPE.IMAGE,"svg+xml":o.LOAD_TYPE.IMAGE},o._xhrTypeMap={xhtml:o.XHR_RESPONSE_TYPE.DOCUMENT,html:o.XHR_RESPONSE_TYPE.DOCUMENT,htm:o.XHR_RESPONSE_TYPE.DOCUMENT,xml:o.XHR_RESPONSE_TYPE.DOCUMENT,tmx:o.XHR_RESPONSE_TYPE.DOCUMENT,tsx:o.XHR_RESPONSE_TYPE.DOCUMENT,svg:o.XHR_RESPONSE_TYPE.DOCUMENT,gif:o.XHR_RESPONSE_TYPE.BLOB,png:o.XHR_RESPONSE_TYPE.BLOB,bmp:o.XHR_RESPONSE_TYPE.BLOB,jpg:o.XHR_RESPONSE_TYPE.BLOB,jpeg:o.XHR_RESPONSE_TYPE.BLOB,tif:o.XHR_RESPONSE_TYPE.BLOB,tiff:o.XHR_RESPONSE_TYPE.BLOB,webp:o.XHR_RESPONSE_TYPE.BLOB,tga:o.XHR_RESPONSE_TYPE.BLOB,json:o.XHR_RESPONSE_TYPE.JSON,text:o.XHR_RESPONSE_TYPE.TEXT,txt:o.XHR_RESPONSE_TYPE.TEXT},o.setExtensionLoadType=function(t,e){u(o._loadTypeMap,t,e)},o.setExtensionXhrType=function(t,e){u(o._xhrTypeMap,t,e)}},978:t=>{"use strict";function e(){}function n(t){return function(){if(null===t)throw new Error("Callback was already called.");var e=t;t=null,e.apply(this,arguments)}}t.exports={eachSeries:function(t,e,n){var i=0,s=t.length;!function r(a){a||i===s?n&&n(a):e(t[i++],r)}()},queue:function(t,i){if(null==i)i=1;else if(0===i)throw new Error("Concurrency must not be zero");var s=0,r={_tasks:[],concurrency:i,saturated:e,unsaturated:e,buffer:i/4,empty:e,drain:e,error:e,started:!1,paused:!1,push:function(t,e){a(t,!1,e)},kill:function(){r.drain=e,r._tasks=[]},unshift:function(t,e){a(t,!0,e)},process:function(){for(;!r.paused&&s<r.concurrency&&r._tasks.length;){var e=r._tasks.shift();0===r._tasks.length&&r.empty(),(s+=1)===r.concurrency&&r.saturated(),t(e.data,n(o(e)))}},length:function(){return r._tasks.length},running:function(){return s},idle:function(){return r._tasks.length+s===0},pause:function(){!0!==r.paused&&(r.paused=!0)},resume:function(){if(!1!==r.paused){r.paused=!1;for(var t=1;t<=r.concurrency;t++)r.process()}}};function a(t,n,i){if(null!=i&&"function"!=typeof i)throw new Error("task callback must be a function");if(r.started=!0,null==t&&r.idle())setTimeout((function(){r.drain()}),1);else{var s={data:t,callback:"function"==typeof i?i:e};n?r._tasks.unshift(s):r._tasks.push(s),setTimeout((function(){r.process()}),1)}}function o(t){return function(){s-=1,t.callback.apply(t,arguments),null!=arguments[0]&&r.error(arguments[0],t.data),s<=r.concurrency-r.buffer&&r.unsaturated(),r.idle()&&r.drain(),r.process()}}return r}}},9350:t=>{"use strict";t.exports={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encodeBinary:function(t){for(var e,n="",i=new Array(4),s=0,r=0;s<t.length;){for(e=new Array(3),r=0;r<e.length;r++)s<t.length?e[r]=255&t.charCodeAt(s++):e[r]=0;switch(i[0]=e[0]>>2,i[1]=(3&e[0])<<4|e[1]>>4,i[2]=(15&e[1])<<2|e[2]>>6,i[3]=63&e[2],s-(t.length-1)){case 2:i[3]=64,i[2]=64;break;case 1:i[3]=64}for(r=0;r<i.length;r++)n+=this._keyStr.charAt(i[r])}return n}}},542:(t,e,n)=>{"use strict";t.exports=n(3723),t.exports.Resource=n(8664),t.exports.middleware={caching:{memory:n(9911)},parsing:{blob:n(2796)}},t.exports.async=n(978)},9911:t=>{"use strict";var e={};t.exports=function(){return function(t,n){e[t.url]?(t.data=e[t.url],t.complete()):t.once("complete",(function(){e[this.url]=this.data})),n()}}},2796:(t,e,n)=>{"use strict";var i=n(8664),s=n(9350),r=window.URL||window.webkitURL;t.exports=function(){return function(t,e){if(t.data){if(t.xhr&&t.xhrType===i.XHR_RESPONSE_TYPE.BLOB)if(window.Blob&&"string"!=typeof t.data){if(0===t.data.type.indexOf("image")){var n=r.createObjectURL(t.data);return t.blob=t.data,t.data=new Image,t.data.src=n,t.isImage=!0,void(t.data.onload=function(){r.revokeObjectURL(n),t.data.onload=null,e()})}}else{var a=t.xhr.getResponseHeader("content-type");if(a&&0===a.indexOf("image"))return t.data=new Image,t.data.src="data:"+a+";base64,"+s.encodeBinary(t.xhr.responseText),t.isImage=!0,void(t.data.onload=function(){t.data.onload=null,e()})}e()}else e()}}},5242:(t,e,n)=>{
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
var i=n(8287),s=i.Buffer;function r(t,e){for(var n in t)e[n]=t[n]}function a(t,e,n){return s(t,e,n)}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?t.exports=i:(r(i,e),e.Buffer=a),a.prototype=Object.create(s.prototype),r(s,a),a.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return s(t,e,n)},a.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=s(t);return void 0!==e?"string"==typeof n?i.fill(e,n):i.fill(e):i.fill(0),i},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return s(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},7391:(t,e,n)=>{var i=n(7180),s=n(3181),r=n(3031),a=n(9067),o=n(6833),l=n(3717),u=n(4801);u.alea=i,u.xor128=s,u.xorwow=r,u.xorshift7=a,u.xor4096=o,u.tychei=l,t.exports=u},7180:function(t,e,n){var i;!function(t,s){function r(t){var e=this,n=function(){var t=4022871197,e=function(e){e=String(e);for(var n=0;n<e.length;n++){var i=.02519603282416938*(t+=e.charCodeAt(n));i-=t=i>>>0,t=(i*=t)>>>0,t+=4294967296*(i-=t)}return 2.3283064365386963e-10*(t>>>0)};return e}();e.next=function(){var t=2091639*e.s0+2.3283064365386963e-10*e.c;return e.s0=e.s1,e.s1=e.s2,e.s2=t-(e.c=0|t)},e.c=1,e.s0=n(" "),e.s1=n(" "),e.s2=n(" "),e.s0-=n(t),e.s0<0&&(e.s0+=1),e.s1-=n(t),e.s1<0&&(e.s1+=1),e.s2-=n(t),e.s2<0&&(e.s2+=1),n=null}function a(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function o(t,e){var n=new r(t),i=e&&e.state,s=n.next;return s.int32=function(){return 4294967296*n.next()|0},s.double=function(){return s()+11102230246251565e-32*(2097152*s()|0)},s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.alea=o}(0,t=n.nmd(t),n.amdD)},3717:function(t,e,n){var i;!function(t,s){function r(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,i=e.d,s=e.a;return t=t<<25^t>>>7^n,n=n-i|0,i=i<<24^i>>>8^s,s=s-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-i|0,e.d=i<<16^n>>>16^s,e.a=s-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var i=0;i<n.length+20;i++)e.b^=0|n.charCodeAt(i),e.next()}function a(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function o(t,e){var n=new r(t),i=e&&e.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=n.next,s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.tychei=o}(0,t=n.nmd(t),n.amdD)},3181:function(t,e,n){var i;!function(t,s){function r(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var i=0;i<n.length+64;i++)e.x^=0|n.charCodeAt(i),e.next()}function a(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function o(t,e){var n=new r(t),i=e&&e.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=n.next,s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.xor128=o}(0,t=n.nmd(t),n.amdD)},6833:function(t,e,n){var i;!function(t,s){function r(t){var e=this;e.next=function(){var t,n,i=e.w,s=e.X,r=e.i;return e.w=i=i+1640531527|0,n=s[r+34&127],t=s[r=r+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=s[r]=n^t,e.i=r,n+(i^i>>>16)|0},function(t,e){var n,i,s,r,a,o=[],l=128;for(e===(0|e)?(i=e,e=null):(e+="\0",i=0,l=Math.max(l,e.length)),s=0,r=-32;r<l;++r)e&&(i^=e.charCodeAt((r+32)%e.length)),0===r&&(a=i),i^=i<<10,i^=i>>>15,i^=i<<4,i^=i>>>13,r>=0&&(a=a+1640531527|0,s=0==(n=o[127&r]^=i+a)?s+1:0);for(s>=128&&(o[127&(e&&e.length||0)]=-1),s=127,r=512;r>0;--r)i=o[s+34&127],n=o[s=s+1&127],i^=i<<13,n^=n<<17,i^=i>>>15,n^=n>>>12,o[s]=i^n;t.w=a,t.X=o,t.i=s}(e,t)}function a(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),i=e&&e.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=n.next,s.quick=s,i&&(i.X&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.xor4096=o}(0,t=n.nmd(t),n.amdD)},9067:function(t,e,n){var i;!function(t,s){function r(t){var e=this;e.next=function(){var t,n,i=e.x,s=e.i;return t=i[s],n=(t^=t>>>7)^t<<24,n^=(t=i[s+1&7])^t>>>10,n^=(t=i[s+3&7])^t>>>3,n^=(t=i[s+4&7])^t<<7,t=i[s+7&7],n^=(t^=t<<13)^t<<9,i[s]=n,e.i=s+1&7,n},function(t,e){var n,i=[];if(e===(0|e))i[0]=e;else for(e=""+e,n=0;n<e.length;++n)i[7&n]=i[7&n]<<15^e.charCodeAt(n)+i[n+1&7]<<13;for(;i.length<8;)i.push(0);for(n=0;n<8&&0===i[n];++n);for(8==n?i[7]=-1:i[n],t.x=i,t.i=0,n=256;n>0;--n)t.next()}(e,t)}function a(t,e){return e.x=t.x.slice(),e.i=t.i,e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),i=e&&e.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=n.next,s.quick=s,i&&(i.x&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.xorshift7=o}(0,t=n.nmd(t),n.amdD)},3031:function(t,e,n){var i;!function(t,s){function r(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var i=0;i<n.length+64;i++)e.x^=0|n.charCodeAt(i),i==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function a(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function o(t,e){var n=new r(t),i=e&&e.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},s.int32=n.next,s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}s&&s.exports?s.exports=o:n.amdD&&n.amdO?void 0===(i=function(){return o}.call(e,n,e,s))||(s.exports=i):this.xorwow=o}(0,t=n.nmd(t),n.amdD)},4801:function(t,e,n){var i;!function(s,r,a){var o,l=256,u=a.pow(l,6),h=a.pow(2,52),p=2*h,c=l-1;function d(t,e,n){var i=[],c=_(g((e=1==e?{entropy:!0}:e||{}).entropy?[t,T(r)]:null==t?function(){try{var t;return o&&(t=o.randomBytes)?t=t(l):(t=new Uint8Array(l),(s.crypto||s.msCrypto).getRandomValues(t)),T(t)}catch(t){var e=s.navigator,n=e&&e.plugins;return[+new Date,s,n,s.screen,T(r)]}}():t,3),i),d=new f(i),y=function(){for(var t=d.g(6),e=u,n=0;t<h;)t=(t+n)*l,e*=l,n=d.g(1);for(;t>=p;)t/=2,e/=2,n>>>=1;return(t+n)/e};return y.int32=function(){return 0|d.g(4)},y.quick=function(){return d.g(4)/4294967296},y.double=y,_(T(d.S),r),(e.pass||n||function(t,e,n,i){return i&&(i.S&&m(i,d),t.state=function(){return m(d,{})}),n?(a.random=t,e):t})(y,c,"global"in e?e.global:this==a,e.state)}function f(t){var e,n=t.length,i=this,s=0,r=i.i=i.j=0,a=i.S=[];for(n||(t=[n++]);s<l;)a[s]=s++;for(s=0;s<l;s++)a[s]=a[r=c&r+t[s%n]+(e=a[s])],a[r]=e;(i.g=function(t){for(var e,n=0,s=i.i,r=i.j,a=i.S;t--;)e=a[s=c&s+1],n=n*l+a[c&(a[s]=a[r=c&r+e])+(a[r]=e)];return i.i=s,i.j=r,n})(l)}function m(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function g(t,e){var n,i=[],s=typeof t;if(e&&"object"==s)for(n in t)try{i.push(g(t[n],e-1))}catch(t){}return i.length?i:"string"==s?t:t+"\0"}function _(t,e){for(var n,i=t+"",s=0;s<i.length;)e[c&s]=c&(n^=19*e[c&s])+i.charCodeAt(s++);return T(e)}function T(t){return String.fromCharCode.apply(0,t)}if(_(a.random(),r),t.exports){t.exports=d;try{o=n(1234)}catch(t){}}else void 0===(i=function(){return d}.call(e,n,e,t))||(t.exports=i)}("undefined"!=typeof self?self:this,[],Math)},6944:t=>{"use strict";t.exports=path},5817:()=>{},8590:()=>{},4530:()=>{},8108:()=>{},551:()=>{},7425:()=>{},9496:()=>{},6786:()=>{},8884:()=>{},8001:()=>{},1613:()=>{},5312:()=>{},9032:()=>{},574:()=>{},2672:()=>{},8215:()=>{},1417:()=>{},9391:()=>{},3220:()=>{},3985:()=>{},32:()=>{},5650:()=>{},6644:()=>{},1234:()=>{},1045:t=>{"use strict";t.exports={rE:"3.0.8"}}},__webpack_module_cache__={},leafPrototypes,getProto,inProgress,dataWebpackPrefix;function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var n=__webpack_module_cache__[t]={id:t,loaded:!1,exports:{}};return __webpack_modules__[t].call(n.exports,n,n.exports,__webpack_require__),n.loaded=!0,n.exports}__webpack_require__.m=__webpack_modules__,__webpack_require__.amdD=function(){throw new Error("define cannot be used indirect")},__webpack_require__.amdO={},__webpack_require__.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return __webpack_require__.d(e,{a:e}),e},getProto=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,__webpack_require__.t=function(t,e){if(1&e&&(t=this(t)),8&e)return t;if("object"==typeof t&&t){if(4&e&&t.__esModule)return t;if(16&e&&"function"==typeof t.then)return t}var n=Object.create(null);__webpack_require__.r(n);var i={};leafPrototypes=leafPrototypes||[null,getProto({}),getProto([]),getProto(getProto)];for(var s=2&e&&t;"object"==typeof s&&!~leafPrototypes.indexOf(s);s=getProto(s))Object.getOwnPropertyNames(s).forEach((e=>i[e]=()=>t[e]));return i.default=()=>t,__webpack_require__.d(n,i),n},__webpack_require__.d=(t,e)=>{for(var n in e)__webpack_require__.o(e,n)&&!__webpack_require__.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},__webpack_require__.f={},__webpack_require__.e=t=>Promise.all(Object.keys(__webpack_require__.f).reduce(((e,n)=>(__webpack_require__.f[n](t,e),e)),[])),__webpack_require__.u=t=>t+".bundle."+{38:"8f8d27e0",97:"2c190343",195:"9cae47ea",211:"788652b1",317:"a52389ac",837:"202ac045",950:"f4a05602",960:"35ce71c3",974:"0d9230d6"}[t]+".js",__webpack_require__.miniCssF=t=>"styles/"+t+".45554be0.css",__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),inProgress={},dataWebpackPrefix="@mixly/python-pyodide:",__webpack_require__.l=(t,e,n,i)=>{if(inProgress[t])inProgress[t].push(e);else{var s,r;if(void 0!==n)for(var a=document.getElementsByTagName("script"),o=0;o<a.length;o++){var l=a[o];if(l.getAttribute("src")==t||l.getAttribute("data-webpack")==dataWebpackPrefix+n){s=l;break}}s||(r=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,__webpack_require__.nc&&s.setAttribute("nonce",__webpack_require__.nc),s.setAttribute("data-webpack",dataWebpackPrefix+n),s.src=t),inProgress[t]=[e];var u=(e,n)=>{s.onerror=s.onload=null,clearTimeout(h);var i=inProgress[t];if(delete inProgress[t],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach((t=>t(n))),e)return e(n)},h=setTimeout(u.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=u.bind(null,s.onerror),s.onload=u.bind(null,s.onload),r&&document.head.appendChild(s)}},__webpack_require__.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},__webpack_require__.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{var t;__webpack_require__.g.importScripts&&(t=__webpack_require__.g.location+"");var e=__webpack_require__.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&(!t||!/^http(s?):/.test(t));)t=n[i--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),__webpack_require__.p=t})(),(()=>{if("undefined"!=typeof document){var t=t=>new Promise(((e,n)=>{var i=__webpack_require__.miniCssF(t),s=__webpack_require__.p+i;if(((t,e)=>{for(var n=document.getElementsByTagName("link"),i=0;i<n.length;i++){var s=(a=n[i]).getAttribute("data-href")||a.getAttribute("href");if("stylesheet"===a.rel&&(s===t||s===e))return a}var r=document.getElementsByTagName("style");for(i=0;i<r.length;i++){var a;if((s=(a=r[i]).getAttribute("data-href"))===t||s===e)return a}})(i,s))return e();((t,e,n,i,s)=>{var r=document.createElement("link");r.rel="stylesheet",r.type="text/css",__webpack_require__.nc&&(r.nonce=__webpack_require__.nc),r.onerror=r.onload=n=>{if(r.onerror=r.onload=null,"load"===n.type)i();else{var a=n&&n.type,o=n&&n.target&&n.target.href||e,l=new Error("Loading CSS chunk "+t+" failed.\n("+a+": "+o+")");l.name="ChunkLoadError",l.code="CSS_CHUNK_LOAD_FAILED",l.type=a,l.request=o,r.parentNode&&r.parentNode.removeChild(r),s(l)}},r.href=e,n?n.parentNode.insertBefore(r,n.nextSibling):document.head.appendChild(r)})(t,s,null,e,n)})),e={792:0};__webpack_require__.f.miniCss=(n,i)=>{e[n]?i.push(e[n]):0!==e[n]&&{317:1}[n]&&i.push(e[n]=t(n).then((()=>{e[n]=0}),(t=>{throw delete e[n],t})))}}})(),(()=>{var t={792:0};__webpack_require__.f.j=(e,n)=>{var i=__webpack_require__.o(t,e)?t[e]:void 0;if(0!==i)if(i)n.push(i[2]);else{var s=new Promise(((n,s)=>i=t[e]=[n,s]));n.push(i[2]=s);var r=__webpack_require__.p+__webpack_require__.u(e),a=new Error;__webpack_require__.l(r,(n=>{if(__webpack_require__.o(t,e)&&(0!==(i=t[e])&&(t[e]=void 0),i)){var s=n&&("load"===n.type?"missing":n.type),r=n&&n.target&&n.target.src;a.message="Loading chunk "+e+" failed.\n("+s+": "+r+")",a.name="ChunkLoadError",a.type=s,a.request=r,i[1](a)}}),"chunk-"+e,e)}};var e=(e,n)=>{var i,s,[r,a,o]=n,l=0;if(r.some((e=>0!==t[e]))){for(i in a)__webpack_require__.o(a,i)&&(__webpack_require__.m[i]=a[i]);if(o)o(__webpack_require__)}for(e&&e(n);l<r.length;l++)s=r[l],__webpack_require__.o(t,s)&&t[s]&&t[s][0](),t[s]=0},n=self.webpackChunk_mixly_python_pyodide=self.webpackChunk_mixly_python_pyodide||[];n.forEach(e.bind(null,0)),n.push=e.bind(null,n.push.bind(n))})();var __webpack_exports__={};(()=>{"use strict";var t={};__webpack_require__.r(t),__webpack_require__.d(t,{controls_type:()=>ue,controls_typeLists:()=>he,lists_zip:()=>pe,lists_zip_container:()=>ce,lists_zip_item:()=>de,unpack_iterable_object:()=>fe,variables_change:()=>oe,variables_get:()=>re,variables_global:()=>le,variables_set:()=>ae});var e={};__webpack_require__.r(e),__webpack_require__.d(e,{base_setup:()=>_e,controls_delay:()=>Te,controls_end_program:()=>ye,controls_except:()=>Ne,controls_finally:()=>ke,controls_flow_statements:()=>Se,controls_for:()=>xe,controls_forEach:()=>be,controls_for_range:()=>Re,controls_if:()=>Ie,controls_if_else:()=>Me,controls_if_elseif:()=>Ae,controls_if_if:()=>Oe,controls_lambda:()=>Le,controls_main:()=>ge,controls_pass:()=>Fe,controls_range:()=>Ee,controls_repeat_ext:()=>De,controls_thread:()=>Pe,controls_try:()=>Ce,controls_try_finally:()=>we,controls_whileUntil:()=>ve,datetime_fromtimestamp:()=>Ge,do_while:()=>$e,garbage_collection:()=>Be,gene_unique_identifier:()=>He,get_mem_alloc:()=>Ve,get_mem_free:()=>Ue,get_unique_identifier:()=>Ye});var n={};__webpack_require__.r(n),__webpack_require__.d(n,{base_map:()=>cn,generate_cartesian_product:()=>fn,math_arithmetic:()=>qe,math_bit:()=>Qe,math_constant:()=>Xe,math_constant_mp:()=>je,math_constrain:()=>rn,math_dec:()=>Ze,math_degree_to_radian:()=>gn,math_indexer_number:()=>on,math_map:()=>an,math_max_min:()=>en,math_number:()=>ze,math_number_base_conversion:()=>nn,math_radian_to_degree:()=>mn,math_random:()=>sn,math_random_seed:()=>ln,math_round:()=>un,math_selfcalcu:()=>Ke,math_to_int:()=>tn,math_trig:()=>Je,text_to_number:()=>hn,text_to_number_skulpt:()=>pn,turn_to_int:()=>dn});var i={};__webpack_require__.r(i),__webpack_require__.d(i,{ascii_to_char:()=>bn,char_to_ascii:()=>vn,number_to_text:()=>wn,os_system:()=>qn,text:()=>Tn,text_capital:()=>kn,text_center:()=>Dn,text_char:()=>In,text_char_at:()=>Rn,text_char_at2:()=>xn,text_char_at3:()=>Wn,text_compareTo:()=>Hn,text_compare_to:()=>Nn,text_create_with_container:()=>Un,text_create_with_item:()=>Yn,text_encode:()=>Xn,text_equals_starts_ends:()=>Cn,text_eval:()=>jn,text_find:()=>Ln,text_format:()=>Vn,text_format_noreturn:()=>zn,text_join:()=>En,text_join_seq:()=>Fn,text_length:()=>Sn,text_random_char:()=>On,text_replace:()=>Pn,text_split:()=>$n,text_strip:()=>Bn,text_substring:()=>Mn,text_substring2:()=>An,text_substring3:()=>Gn,text_textarea:()=>yn});var s={};__webpack_require__.r(s),__webpack_require__.d(s,{ENUMERATE:()=>Ci,content_in_lists:()=>ki,enumerate:()=>Ni,list_many_input:()=>Ti,list_tolist:()=>bi,list_tolist2:()=>Mi,list_trig:()=>mi,lists_2d_get_col_row_data:()=>ti,lists_2d_get_data_with_col_row:()=>Zn,lists_append_extend:()=>ai,lists_change_to:()=>_i,lists_change_to_general:()=>Ii,lists_clear:()=>pi,lists_create_with:()=>ei,lists_create_with2:()=>vi,lists_create_with_container:()=>ii,lists_create_with_item:()=>si,lists_create_with_noreturn:()=>yi,lists_create_with_text:()=>ni,lists_create_with_text2:()=>wi,lists_del_general:()=>Ei,lists_find:()=>fi,lists_getIndex3:()=>Si,lists_getSublist3:()=>xi,lists_get_index:()=>Qn,lists_get_random_item:()=>oi,lists_get_random_sublist:()=>li,lists_get_sublist:()=>Jn,lists_insert_value:()=>ui,lists_insert_value2:()=>Oi,lists_pop:()=>di,lists_remove_at:()=>ci,lists_remove_at2:()=>Ai,lists_reverse:()=>hi,lists_setIndex3:()=>Ri,lists_set_index:()=>ri,lists_sort:()=>gi});var r={};__webpack_require__.r(r),__webpack_require__.d(r,{dicts_add_change_del:()=>qi,dicts_add_or_change:()=>Ui,dicts_clear:()=>Hi,dicts_create_with:()=>Li,dicts_create_with_container:()=>Fi,dicts_create_with_item:()=>Pi,dicts_create_with_noreturn:()=>Ji,dicts_deldict:()=>ji,dicts_delete:()=>Yi,dicts_get:()=>Bi,dicts_get_default:()=>Vi,dicts_items:()=>Wi,dicts_keys:()=>$i,dicts_length:()=>Xi,dicts_pop:()=>Ki,dicts_setdefault:()=>Qi,dicts_to_json:()=>ts,dicts_to_json2:()=>is,dicts_to_to:()=>ns,dicts_todict:()=>Zi,dicts_update:()=>Gi,dicts_values:()=>zi,json_to_dicts:()=>es});var a={};__webpack_require__.r(a),__webpack_require__.d(a,{logic_boolean:()=>us,logic_compare:()=>rs,logic_compare_continous:()=>as,logic_is:()=>ds,logic_is_in:()=>cs,logic_negate:()=>ls,logic_null:()=>hs,logic_operation:()=>os,logic_tobool:()=>fs,logic_true_or_false:()=>ps});var o={};__webpack_require__.r(o),__webpack_require__.d(o,{sdcard_mount:()=>Ps,sdcard_use_spi_init:()=>Fs,storage_can_write_ornot:()=>vs,storage_change_dir:()=>Ds,storage_close_file:()=>Ss,storage_delete_file:()=>Rs,storage_file_seek:()=>Ms,storage_file_tell:()=>As,storage_file_write:()=>ys,storage_fileopen:()=>gs,storage_fileopen_new:()=>_s,storage_fileopen_new_encoding:()=>Ts,storage_get_a_line:()=>bs,storage_get_contents:()=>Es,storage_get_contents_without_para:()=>Is,storage_get_current_dir:()=>Cs,storage_get_file_size:()=>Os,storage_get_filename:()=>ws,storage_is_file:()=>Ls,storage_list_all_files:()=>xs,storage_make_dir:()=>Ns,storage_open_file_with_os:()=>ms,storage_rename:()=>ks});var l={};__webpack_require__.r(l),__webpack_require__.d(l,{procedures_callnoreturn:()=>Ys,procedures_callreturn:()=>Gs,procedures_defnoreturn:()=>$s,procedures_defreturn:()=>Bs,procedures_ifreturn:()=>Hs,procedures_mutatorarg:()=>Us,procedures_mutatorcontainer:()=>Vs,procedures_return:()=>Ws});var u={};__webpack_require__.r(u),__webpack_require__.d(u,{tuple_change_to:()=>ir,tuple_create_with:()=>Xs,tuple_create_with_container:()=>js,tuple_create_with_item:()=>qs,tuple_create_with_noreturn:()=>or,tuple_create_with_text2:()=>Ks,tuple_create_with_text_return:()=>Qs,tuple_del:()=>tr,tuple_find:()=>sr,tuple_getIndex:()=>Js,tuple_getSublist:()=>ar,tuple_get_random_item:()=>ur,tuple_get_sublist:()=>lr,tuple_input:()=>pr,tuple_join:()=>er,tuple_length:()=>Zs,tuple_max:()=>nr,tuple_totuple:()=>hr,tuple_trig:()=>rr});var h={};__webpack_require__.r(h),__webpack_require__.d(h,{set_add_discard:()=>Er,set_clear:()=>Tr,set_create_with:()=>dr,set_create_with_container:()=>fr,set_create_with_item:()=>mr,set_create_with_text_return:()=>wr,set_length:()=>gr,set_operate:()=>yr,set_operate_update:()=>Ir,set_pop:()=>_r,set_sub:()=>br,set_toset:()=>Sr,set_update:()=>vr});var p={};__webpack_require__.r(p),__webpack_require__.d(p,{html_content:()=>Mr,html_content_more:()=>Cr,html_document:()=>Rr,html_form:()=>kr,html_head_body:()=>Ar,html_style:()=>Nr,html_style_color:()=>Lr,html_style_content:()=>Dr,html_text:()=>Fr,html_title:()=>Or});var c={};__webpack_require__.r(c),__webpack_require__.d(c,{attribute_access:()=>Kr,function_call:()=>Xr,function_call_container:()=>jr,function_call_item:()=>qr,raw_block:()=>Br,raw_empty:()=>Ur,raw_expression:()=>Vr,raw_table:()=>$r,text_comment:()=>Yr,text_print_multiple:()=>Hr,text_print_multiple_container:()=>Wr,text_print_multiple_item:()=>zr,type_check:()=>Gr});var d={};__webpack_require__.r(d),__webpack_require__.d(d,{controls_type:()=>ea,controls_typeLists:()=>na,lists_zip:()=>ia,unpack_iterable_object:()=>sa,variables_change:()=>Zr,variables_get:()=>Qr,variables_global:()=>ta,variables_set:()=>Jr});var f={};__webpack_require__.r(f),__webpack_require__.d(f,{Panic_with_status_code:()=>fa,base_setup:()=>aa,controls_delay:()=>da,controls_flow_statements:()=>ca,controls_for:()=>ua,controls_forEach:()=>ya,controls_for_range:()=>ha,controls_if:()=>oa,controls_interrupts:()=>_a,controls_lambda:()=>Ea,controls_main:()=>ra,controls_millis:()=>ma,controls_nointerrupts:()=>Ta,controls_pass:()=>va,controls_range:()=>Ia,controls_repeat:()=>Ca,controls_repeat_ext:()=>xa,controls_thread:()=>wa,controls_try_finally:()=>la,controls_whileUntil:()=>pa,datetime_fromtimestamp:()=>Na,do_while:()=>Sa,garbage_collection:()=>Ra,gene_unique_identifier:()=>ka,get_mem_alloc:()=>Oa,get_mem_free:()=>Aa,get_unique_identifier:()=>Ma,reset:()=>ga,time_sleep:()=>ba});var m={};__webpack_require__.r(m),__webpack_require__.d(m,{base_map:()=>to,generate_cartesian_product:()=>no,math_arithmetic:()=>$a,math_bit:()=>Pa,math_constant:()=>La,math_constant_mp:()=>Fa,math_constrain:()=>Xa,math_dec:()=>Ya,math_degree_to_radian:()=>so,math_indexer_number:()=>Ka,math_map:()=>za,math_max_min:()=>Ha,math_number:()=>Da,math_number_base_conversion:()=>ja,math_radian_to_degree:()=>io,math_random:()=>Wa,math_random_seed:()=>qa,math_round:()=>Qa,math_selfcalcu:()=>Ba,math_single:()=>Va,math_to_int:()=>Ga,math_trig:()=>Ua,text_to_number:()=>Ja,text_to_number_skulpt:()=>Za,turn_to_int:()=>eo});var g={};__webpack_require__.r(g),__webpack_require__.d(g,{ascii_to_char:()=>uo,char_to_ascii:()=>ho,number_to_text:()=>po,os_system:()=>Lo,text:()=>ro,text_capital:()=>Eo,text_center:()=>bo,text_char:()=>oo,text_char_at:()=>mo,text_char_at2:()=>fo,text_char_at3:()=>No,text_compareTo:()=>Co,text_compare_to:()=>To,text_encode:()=>ko,text_equals_starts_ends:()=>_o,text_eval:()=>Do,text_find:()=>vo,text_format:()=>Oo,text_format_noreturn:()=>Ao,text_join:()=>lo,text_join_seq:()=>wo,text_length:()=>co,text_random_char:()=>go,text_replace:()=>So,text_split:()=>xo,text_strip:()=>Ro,text_substring:()=>Io,text_substring2:()=>yo,text_substring3:()=>Mo,text_textarea:()=>ao});var _={};__webpack_require__.r(_),__webpack_require__.d(_,{content_in_lists:()=>ml,enumerate:()=>fl,list_many_input:()=>el,list_tolist:()=>cl,list_tolist2:()=>dl,list_trig:()=>Jo,lists_2d_get_col_row_data:()=>$o,lists_2d_get_data_with_col_row:()=>Po,lists_append_extend:()=>Go,lists_change_to:()=>tl,lists_change_to_general:()=>il,lists_clear:()=>jo,lists_create_with:()=>Bo,lists_create_with2:()=>rl,lists_create_with_noreturn:()=>nl,lists_create_with_text:()=>Vo,lists_create_with_text2:()=>al,lists_del_general:()=>sl,lists_find:()=>qo,lists_getIndex3:()=>ol,lists_getSublist3:()=>ll,lists_get_index:()=>Uo,lists_get_random_item:()=>Ho,lists_get_random_sublist:()=>Wo,lists_get_sublist:()=>Fo,lists_insert_value:()=>zo,lists_insert_value2:()=>hl,lists_pop:()=>Qo,lists_remove_at:()=>Ko,lists_remove_at2:()=>pl,lists_reverse:()=>Xo,lists_setIndex3:()=>ul,lists_set_index:()=>Yo,lists_sort:()=>Zo});var T={};__webpack_require__.r(T),__webpack_require__.d(T,{dicts_add_change_del:()=>Ol,dicts_add_or_change:()=>Il,dicts_clear:()=>vl,dicts_create_with:()=>gl,dicts_create_with_noreturn:()=>Cl,dicts_deldict:()=>Rl,dicts_delete:()=>El,dicts_get:()=>Tl,dicts_get_default:()=>yl,dicts_items:()=>wl,dicts_keys:()=>_l,dicts_length:()=>xl,dicts_pop:()=>Al,dicts_setdefault:()=>Ml,dicts_to_json:()=>kl,dicts_to_json2:()=>Fl,dicts_to_to:()=>Ll,dicts_todict:()=>Nl,dicts_update:()=>bl,dicts_values:()=>Sl,json_to_dicts:()=>Dl});var y={};__webpack_require__.r(y),__webpack_require__.d(y,{logic_boolean:()=>Ul,logic_compare:()=>Pl,logic_compare_continous:()=>$l,logic_is:()=>Wl,logic_is_in:()=>Hl,logic_negate:()=>Vl,logic_null:()=>Yl,logic_operation:()=>Bl,logic_tobool:()=>zl,logic_true_or_false:()=>Gl});var I={};__webpack_require__.r(I),__webpack_require__.d(I,{sdcard_mount:()=>mu,sdcard_use_spi_init:()=>fu,storage_can_write_ornot:()=>eu,storage_change_dir:()=>uu,storage_close_file:()=>iu,storage_delete_file:()=>ru,storage_file_seek:()=>lu,storage_file_tell:()=>ou,storage_file_write:()=>Ql,storage_fileopen:()=>jl,storage_fileopen_new:()=>ql,storage_fileopen_new_encoding:()=>Kl,storage_get_a_line:()=>tu,storage_get_contents:()=>Zl,storage_get_contents_without_para:()=>Jl,storage_get_current_dir:()=>hu,storage_get_file_size:()=>au,storage_get_filename:()=>nu,storage_is_file:()=>du,storage_list_all_files:()=>su,storage_make_dir:()=>pu,storage_open_file_with_os:()=>Xl,storage_rename:()=>cu});var E={};__webpack_require__.r(E),__webpack_require__.d(E,{procedures_callnoreturn:()=>yu,procedures_callreturn:()=>Tu,procedures_defnoreturn:()=>_u,procedures_defreturn:()=>gu,procedures_ifreturn:()=>Iu,procedures_return:()=>Eu});var b={};__webpack_require__.r(b),__webpack_require__.d(b,{tuple_change_to:()=>Mu,tuple_create_with:()=>bu,tuple_create_with_noreturn:()=>Du,tuple_create_with_text2:()=>vu,tuple_create_with_text_return:()=>wu,tuple_del:()=>Ru,tuple_find:()=>Cu,tuple_getIndex:()=>Su,tuple_getSublist:()=>ku,tuple_get_random_item:()=>Fu,tuple_get_sublist:()=>Lu,tuple_input:()=>$u,tuple_join:()=>Ou,tuple_length:()=>xu,tuple_max:()=>Au,tuple_totuple:()=>Pu,tuple_trig:()=>Nu});var v={};__webpack_require__.r(v),__webpack_require__.d(v,{set_add_discard:()=>Wu,set_clear:()=>Yu,set_create_with:()=>Bu,set_create_with_text_return:()=>ju,set_length:()=>Vu,set_operate:()=>Gu,set_operate_update:()=>Hu,set_pop:()=>Uu,set_sub:()=>zu,set_toset:()=>qu,set_update:()=>Xu});var w={};__webpack_require__.r(w),__webpack_require__.d(w,{html_content:()=>Zu,html_content_more:()=>th,html_document:()=>Ku,html_form:()=>nh,html_head_body:()=>Ju,html_style:()=>eh,html_style_content:()=>ih,html_text:()=>sh,html_title:()=>Qu});var S={};__webpack_require__.r(S),__webpack_require__.d(S,{attribute_access:()=>ph,function_call:()=>hh,raw_block:()=>rh,raw_empty:()=>oh,raw_expression:()=>ah,raw_table:()=>lh,type_check:()=>uh});var x={};__webpack_require__.r(x),__webpack_require__.d(x,{AI_ChooseAndGet:()=>gh,AI_Face_match:()=>bh,AI_ImageClassify:()=>Ih,AI_ImageClassify_Func:()=>Eh,AI_Nlp:()=>Sh,AI_Nlp_Func:()=>Rh,AI_Nlp_Func_sim:()=>Oh,AI_Nlp_Sim:()=>xh,AI_Nlp_Topic:()=>Ah,AI_Nlp_newsSummary:()=>Mh,AI_Ocr:()=>vh,AI_Ocr_Func:()=>wh,AI_Speech_asr:()=>yh,AI_Speech_synthesis:()=>Th,AI_audio:()=>Ch,AI_client:()=>_h,AI_photo:()=>Nh,AI_result:()=>kh});var R={};__webpack_require__.r(R),__webpack_require__.d(R,{algorithm_add_path:()=>Vh,algorithm_add_school:()=>Fh,algorithm_all_books:()=>np,algorithm_all_books_sequence:()=>ip,algorithm_book_scale:()=>mp,algorithm_check_feet:()=>xp,algorithm_chick_calculate:()=>Sp,algorithm_color_seclet:()=>Hp,algorithm_current_school:()=>zh,algorithm_del_path:()=>Uh,algorithm_delete_book:()=>pp,algorithm_delete_books:()=>cp,algorithm_delete_books2:()=>dp,algorithm_divide_books:()=>up,algorithm_find_path:()=>Ph,algorithm_first_book:()=>sp,algorithm_fz_calc:()=>Mp,algorithm_fz_calc_first_min:()=>Cp,algorithm_fz_compare:()=>Np,algorithm_fz_move:()=>Dp,algorithm_fz_set_min:()=>kp,algorithm_get_book_num:()=>yp,algorithm_get_current_location:()=>Yp,algorithm_get_half_books:()=>hp,algorithm_hxdb_add:()=>Bp,algorithm_hxdb_init_soldier:()=>Fp,algorithm_hxdb_last_line:()=>$p,algorithm_hxdb_result:()=>Vp,algorithm_hxdb_stand_in_line:()=>Pp,algorithm_init_fzsf:()=>Ap,algorithm_init_hxdb:()=>Lp,algorithm_init_jttl:()=>bp,algorithm_move_recent:()=>Kh,algorithm_new_path:()=>$h,algorithm_next_book:()=>op,algorithm_no_left:()=>Gh,algorithm_no_path:()=>Xh,algorithm_no_ring2:()=>rp,algorithm_not_home:()=>Qh,algorithm_not_school:()=>Jh,algorithm_number_add:()=>_p,algorithm_number_zero:()=>gp,algorithm_prepare:()=>Lh,algorithm_prepare2:()=>Wh,algorithm_prepare_2_1:()=>jh,algorithm_prepare_2_2:()=>qh,algorithm_print_book2:()=>fp,algorithm_print_divide:()=>Ep,algorithm_print_jttl_answer:()=>Rp,algorithm_print_number:()=>Tp,algorithm_print_path:()=>Hh,algorithm_print_path2:()=>Zh,algorithm_print_sequence:()=>Ip,algorithm_rabbit_add:()=>Op,algorithm_rabbit_number_in_range:()=>wp,algorithm_rabbit_zero:()=>vp,algorithm_return_path:()=>Yh,algorithm_set_path:()=>Bh,algorithm_two_left:()=>lp,algorithm_void_path:()=>Gp,algorithm_yes_ring2:()=>ap,hanoi_init:()=>tp,hanoi_init_offline:()=>Up,hanoi_move:()=>ep});var O={};__webpack_require__.r(O),__webpack_require__.d(O,{requests_attribute:()=>qp,requests_get:()=>Xp,requests_get_old:()=>zp,requests_method:()=>Kp,requests_post:()=>jp});var A={};__webpack_require__.r(A),__webpack_require__.d(A,{cv_destroy_all:()=>nc,cv_face_classifier:()=>rc,cv_face_detect:()=>ac,cv_face_detect_all:()=>oc,cv_line_rect:()=>ic,cv_read_image:()=>Jp,cv_show_image:()=>Zp,cv_text:()=>sc,cv_waitkey:()=>ec,cv_write_image:()=>tc});var M={};__webpack_require__.r(M),__webpack_require__.d(M,{array_create:()=>wc,array_toarray:()=>$c,dataframe_aggregate_func:()=>kd,dataframe_create:()=>pc,dataframe_create_from_index:()=>dc,dataframe_create_from_one_index:()=>cc,dataframe_fillna:()=>yd,dataframe_get:()=>Lc,dataframe_groupby:()=>Nd,dataframe_head_tail:()=>Md,dataframe_info:()=>Id,dataframe_median:()=>Td,dataframe_select:()=>Cd,dataframe_sort_values:()=>Ad,matrix_multiplication:()=>gd,matrix_transpose:()=>md,numpy_argmin_template_match:()=>od,numpy_astype:()=>sd,numpy_c_:()=>dd,numpy_dot:()=>wd,numpy_linalg_det:()=>fd,numpy_linalg_inv:()=>_d,numpy_max:()=>bd,numpy_mean:()=>ld,numpy_mean_digit:()=>ad,numpy_min:()=>Ed,numpy_ones:()=>cd,numpy_random_random:()=>Rd,numpy_reshape:()=>id,numpy_shape:()=>nd,numpy_size:()=>vd,numpy_square:()=>Sd,numpy_std:()=>ud,numpy_sum:()=>xd,numpy_trig:()=>Nc,pandas_drop_columns:()=>pd,pandas_dropna:()=>hd,pandas_readcsv:()=>Dc,pl_axes:()=>Ic,pl_bar:()=>Oc,pl_hist:()=>Mc,pl_label:()=>vc,pl_legend:()=>Ec,pl_pie:()=>Ac,pl_plot:()=>Tc,pl_plot_bar:()=>Sc,pl_plot_easy:()=>_c,pl_plot_scatter:()=>xc,pl_plot_xy:()=>Rc,pl_savefig:()=>Fc,pl_show:()=>yc,pl_subplot:()=>kc,pl_text:()=>Pc,pl_ticks:()=>Cc,pl_title:()=>bc,plot_axes:()=>Yc,plot_bar:()=>qc,plot_cla:()=>Dd,plot_hist:()=>Qc,plot_label:()=>Wc,plot_legend:()=>Gc,plot_pie:()=>Kc,plot_plot:()=>Vc,plot_plot_bar:()=>zc,plot_plot_easy:()=>Bc,plot_plot_scatter:()=>Xc,plot_plot_xy:()=>jc,plot_savefig:()=>td,plot_show:()=>Uc,plot_subplot:()=>Zc,plot_text:()=>ed,plot_ticks:()=>Jc,plot_title:()=>Hc,py_sum:()=>Od,pylab_imshow:()=>rd,series_create:()=>uc,series_create_from_index:()=>hc,series_create_from_text:()=>fc,series_get_num:()=>gc,series_index_value:()=>mc});var C={};__webpack_require__.r(C),__webpack_require__.d(C,{ds_add_node_by_attr:()=>Gd,ds_add_node_by_name:()=>Yd,ds_create_linkedlist:()=>Fd,ds_create_linkedlist_container:()=>Pd,ds_create_linkedlist_item:()=>$d,ds_create_node:()=>Bd,ds_del_node_by_attr:()=>Wd,ds_del_node_by_name:()=>Hd,ds_get_node_attr:()=>Vd,ds_reverse_linkedlist:()=>zd,ds_set_node_attr:()=>Ud});var N={};__webpack_require__.r(N),__webpack_require__.d(N,{factory_block:()=>sf,factory_block_return:()=>rf,factory_block_return_with_textarea:()=>of,factory_block_with_textarea:()=>af,factory_callMethod_noreturn:()=>ef,factory_callMethod_return:()=>nf,factory_create_with_container:()=>Qd,factory_create_with_item:()=>Jd,factory_declare:()=>tf,factory_from_import:()=>jd,factory_function_noreturn:()=>Kd,factory_function_return:()=>Zd,factory_import:()=>qd});var k={};__webpack_require__.r(k),__webpack_require__.d(k,{hardware_arduino_analog_read:()=>ff,hardware_arduino_analog_write:()=>df,hardware_arduino_digital_read:()=>cf,hardware_arduino_digital_write:()=>pf,hardware_arduino_start:()=>uf,inout_highlow:()=>hf});var D={};__webpack_require__.r(D),__webpack_require__.d(D,{inout_input:()=>mf,inout_print:()=>gf,inout_print_container:()=>bf,inout_print_end:()=>Tf,inout_print_inline:()=>_f,inout_print_item:()=>vf,inout_print_many:()=>Ef,inout_type_input:()=>yf,pyinout_type_input:()=>If});var L={};__webpack_require__.r(L),__webpack_require__.d(L,{IOT_EMQX_INIT_AND_CONNECT_BY_MIXLY_CODE:()=>Xf,IOT_EMQX_INIT_AND_CONNECT_BY_SHARE_CODE:()=>zf,IOT_EMQX_PING:()=>Hf,IOT_FORMATTING:()=>Yf,IOT_FORMAT_STRING:()=>Gf,IOT_MIXIO_NTP:()=>Wf,IOT_MIXIO_PUBLISH:()=>Df,IOT_MIXIO_SUBSCRIBE:()=>Lf,IOT_MIXIO_UNSUBSCRIBE:()=>Ff,iot_checkonenet:()=>im,iot_client_onboard:()=>Kf,iot_create_with_item:()=>Nf,iot_http_client:()=>Qf,iot_http_data:()=>Jf,iot_mixio_check:()=>Bf,iot_mixio_connect:()=>kf,iot_mixio_connect_only:()=>$f,iot_mixio_disconnect:()=>Pf,iot_mixio_format_msg:()=>Uf,iot_mixio_format_topic:()=>Vf,iot_mixly_key:()=>qf,iot_mixly_key_py:()=>jf,iot_mqtt_client:()=>Zf,iot_mqtt_data:()=>tm,iot_onenet_check:()=>Rf,iot_onenet_connect:()=>Sf,iot_onenet_disconnect:()=>xf,iot_onenet_publish:()=>Af,iot_onenet_publish_dict:()=>Of,iot_onenetconnect:()=>em,iot_onenetdisconnect:()=>nm,iot_publish:()=>sm,iot_publish_container:()=>Mf,iot_publish_item:()=>Cf});var F={};__webpack_require__.r(F),__webpack_require__.d(F,{pins_analog_read:()=>um,pins_analog_write:()=>lm,pins_digital_read:()=>om,pins_digital_write:()=>am});var P={};__webpack_require__.r(P),__webpack_require__.d(P,{serial_close:()=>dm,serial_open:()=>hm,serial_read_b:()=>cm,serial_write:()=>pm});var B={};__webpack_require__.r(B),__webpack_require__.d(B,{sklearn_DecisionTreeClassifier_Regressor:()=>wm,sklearn_GaussianNB:()=>Rm,sklearn_KMeans:()=>Mm,sklearn_KMeans_fit:()=>Cm,sklearn_KNeighborsClassifier_Regressor:()=>xm,sklearn_LinearRegression:()=>bm,sklearn_RandomForestClassifier_Regressor:()=>Sm,sklearn_Ridge:()=>vm,sklearn_cluster_centers_labels_inertia:()=>$m,sklearn_coef_intercept:()=>Pm,sklearn_data_target:()=>ym,sklearn_fit:()=>Nm,sklearn_fit_no_target:()=>km,sklearn_load:()=>Tm,sklearn_make_blobs:()=>_m,sklearn_make_classification:()=>mm,sklearn_make_regression:()=>gm,sklearn_pca:()=>Om,sklearn_pca_fit_transform:()=>Am,sklearn_predict:()=>Dm,sklearn_save_load_model:()=>Bm,sklearn_score:()=>Lm,sklearn_score_no_target:()=>Fm,sklearn_train_test_split:()=>Im,sklearn_train_test_split_no_target:()=>Em});var V={};__webpack_require__.r(V),__webpack_require__.d(V,{Panic_with_status_code:()=>Hm,base_delay:()=>Um,controls_millis:()=>Ym,controls_mstimer2:()=>zm,controls_mstimer2_start:()=>Xm,controls_mstimer2_stop:()=>jm,reset:()=>Wm,time_localtime:()=>Gm,time_sleep:()=>qm});var U={};__webpack_require__.r(U),__webpack_require__.d(U,{turtle_bgcolor:()=>gg,turtle_bgcolor_hex:()=>Sg,turtle_bgcolor_hex_new:()=>Ig,turtle_circle:()=>dg,turtle_circle_advanced:()=>fg,turtle_clear:()=>og,turtle_clone:()=>yg,turtle_color:()=>vg,turtle_color_hex:()=>wg,turtle_color_seclet:()=>Lg,turtle_create:()=>Qm,turtle_done:()=>Jm,turtle_exitonclick:()=>Zm,turtle_fill:()=>ug,turtle_fillcolor:()=>Tg,turtle_fillcolor_hex:()=>Rg,turtle_fillcolor_hex_new:()=>bg,turtle_getscreen:()=>Fg,turtle_goto:()=>sg,turtle_listen:()=>Vg,turtle_move:()=>tg,turtle_numinput:()=>Mg,turtle_onclick:()=>$g,turtle_onkey:()=>Pg,turtle_ontimer:()=>Bg,turtle_pencolor:()=>_g,turtle_pencolor_hex:()=>xg,turtle_pencolor_hex_new:()=>Eg,turtle_penup:()=>lg,turtle_pos_shape:()=>ag,turtle_rotate:()=>eg,turtle_screen_delay:()=>ig,turtle_screen_savefig:()=>Ug,turtle_setheading:()=>ng,turtle_setxy:()=>rg,turtle_shape:()=>Og,turtle_shapesize:()=>Ag,turtle_size:()=>pg,turtle_size_speed:()=>hg,turtle_speed:()=>cg,turtle_textinput:()=>Cg,turtle_visible:()=>mg,turtle_write:()=>Ng,turtle_write_format:()=>kg,turtle_write_format_skulpt:()=>Dg});var Y={};__webpack_require__.r(Y),__webpack_require__.d(Y,{AI_ChooseAndGet:()=>Yg,AI_Face_match:()=>Xg,AI_ImageClassify:()=>zg,AI_ImageClassify_Func:()=>Zg,AI_Nlp:()=>qg,AI_Nlp_Func:()=>e_,AI_Nlp_Func_sim:()=>n_,AI_Nlp_Sim:()=>Kg,AI_Nlp_Topic:()=>Qg,AI_Nlp_newsSummary:()=>Jg,AI_Ocr:()=>jg,AI_Ocr_Func:()=>t_,AI_Speech_asr:()=>Wg,AI_Speech_synthesis:()=>Hg,AI_audio:()=>i_,AI_client:()=>Gg,AI_photo:()=>s_,AI_result:()=>r_});var G={};__webpack_require__.r(G),__webpack_require__.d(G,{algorithm_add_path:()=>p_,algorithm_add_school:()=>o_,algorithm_all_books:()=>O_,algorithm_all_books_sequence:()=>R_,algorithm_book_scale:()=>$_,algorithm_check_feet:()=>z_,algorithm_chick_calculate:()=>W_,algorithm_color_seclet:()=>uT,algorithm_current_school:()=>__,algorithm_del_path:()=>c_,algorithm_delete_book:()=>F_,algorithm_divide_books:()=>D_,algorithm_find_path:()=>l_,algorithm_first_book:()=>A_,algorithm_fz_calc:()=>K_,algorithm_fz_compare:()=>Q_,algorithm_fz_move:()=>Z_,algorithm_fz_set_min:()=>J_,algorithm_get_current_location:()=>oT,algorithm_get_half_books:()=>L_,algorithm_hxdb_add:()=>sT,algorithm_hxdb_init_soldier:()=>eT,algorithm_hxdb_last_line:()=>iT,algorithm_hxdb_result:()=>rT,algorithm_hxdb_stand_in_line:()=>nT,algorithm_init_fzsf:()=>q_,algorithm_init_hxdb:()=>tT,algorithm_init_jttl:()=>Y_,algorithm_move_recent:()=>E_,algorithm_new_path:()=>u_,algorithm_next_book:()=>N_,algorithm_no_left:()=>f_,algorithm_no_path:()=>T_,algorithm_no_ring2:()=>M_,algorithm_not_home:()=>b_,algorithm_not_school:()=>v_,algorithm_number_add:()=>V_,algorithm_number_zero:()=>B_,algorithm_prepare:()=>a_,algorithm_prepare2:()=>g_,algorithm_prepare_2_1:()=>y_,algorithm_prepare_2_2:()=>I_,algorithm_print_book2:()=>P_,algorithm_print_jttl_answer:()=>X_,algorithm_print_number:()=>U_,algorithm_print_path:()=>m_,algorithm_print_path2:()=>w_,algorithm_rabbit_add:()=>j_,algorithm_rabbit_number_in_range:()=>H_,algorithm_rabbit_zero:()=>G_,algorithm_return_path:()=>d_,algorithm_set_path:()=>h_,algorithm_two_left:()=>k_,algorithm_void_path:()=>lT,algorithm_yes_ring2:()=>C_,hanoi_init:()=>S_,hanoi_init_offline:()=>aT,hanoi_move:()=>x_});var H={};__webpack_require__.r(H),__webpack_require__.d(H,{requests_attribute:()=>dT,requests_get:()=>pT,requests_get_old:()=>hT,requests_method:()=>fT,requests_post:()=>cT});var W={};__webpack_require__.r(W),__webpack_require__.d(W,{array_create:()=>CT,array_toarray:()=>WT,dataframe_aggregate_func:()=>Vy,dataframe_create:()=>TT,dataframe_create_from_index:()=>yT,dataframe_create_from_one_index:()=>IT,dataframe_fillna:()=>xy,dataframe_get:()=>YT,dataframe_groupby:()=>By,dataframe_head_tail:()=>Py,dataframe_info:()=>Ry,dataframe_median:()=>Sy,dataframe_select:()=>$y,dataframe_sort_values:()=>Fy,matrix_multiplication:()=>vy,matrix_transpose:()=>by,numpy_argmin_template_match:()=>fy,numpy_astype:()=>py,numpy_c_:()=>Iy,numpy_dot:()=>Cy,numpy_linalg_det:()=>Ey,numpy_linalg_inv:()=>wy,numpy_max:()=>Ay,numpy_mean:()=>my,numpy_mean_digit:()=>dy,numpy_min:()=>Oy,numpy_ones:()=>yy,numpy_random_random:()=>Dy,numpy_reshape:()=>hy,numpy_shape:()=>uy,numpy_size:()=>My,numpy_square:()=>Ny,numpy_std:()=>gy,numpy_sum:()=>ky,numpy_trig:()=>BT,pandas_drop_columns:()=>Ty,pandas_dropna:()=>_y,pandas_readcsv:()=>UT,pl_axes:()=>ST,pl_bar:()=>LT,pl_hist:()=>PT,pl_label:()=>MT,pl_legend:()=>OT,pl_pie:()=>FT,pl_plot:()=>RT,pl_plot_bar:()=>NT,pl_plot_easy:()=>xT,pl_plot_scatter:()=>kT,pl_plot_xy:()=>DT,pl_savefig:()=>GT,pl_show:()=>wT,pl_subplot:()=>VT,pl_text:()=>HT,pl_ticks:()=>$T,pl_title:()=>AT,plot_axes:()=>XT,plot_bar:()=>ny,plot_cla:()=>Uy,plot_hist:()=>sy,plot_label:()=>JT,plot_legend:()=>KT,plot_pie:()=>iy,plot_plot:()=>qT,plot_plot_bar:()=>ZT,plot_plot_easy:()=>jT,plot_plot_scatter:()=>ty,plot_plot_xy:()=>ey,plot_savefig:()=>oy,plot_show:()=>zT,plot_subplot:()=>ay,plot_text:()=>ly,plot_ticks:()=>ry,plot_title:()=>QT,py_sum:()=>Ly,pylab_imshow:()=>cy,series_create:()=>gT,series_create_from_index:()=>_T,series_create_from_text:()=>ET,series_get_num:()=>vT,series_index_value:()=>bT});var z={};__webpack_require__.r(z),__webpack_require__.d(z,{ds_add_node_by_attr:()=>Xy,ds_add_node_by_name:()=>zy,ds_create_linkedlist:()=>Yy,ds_create_node:()=>Gy,ds_del_node_by_attr:()=>qy,ds_del_node_by_name:()=>jy,ds_get_node_attr:()=>Hy,ds_reverse_linkedlist:()=>Ky,ds_set_node_attr:()=>Wy});var X={};__webpack_require__.r(X),__webpack_require__.d(X,{factory_block:()=>sI,factory_block_return:()=>rI,factory_block_return_with_textarea:()=>oI,factory_block_with_textarea:()=>aI,factory_callMethod_noreturn:()=>nI,factory_callMethod_return:()=>iI,factory_declare:()=>eI,factory_from_import:()=>Qy,factory_function_noreturn:()=>Zy,factory_function_return:()=>tI,factory_import:()=>Jy});var j={};__webpack_require__.r(j),__webpack_require__.d(j,{hardware_arduino_analog_read:()=>cI,hardware_arduino_analog_write:()=>dI,hardware_arduino_digital_read:()=>pI,hardware_arduino_digital_write:()=>hI,hardware_arduino_start:()=>lI,inout_highlow:()=>uI});var q={};__webpack_require__.r(q),__webpack_require__.d(q,{inout_input:()=>fI,inout_print:()=>mI,inout_print_end:()=>_I,inout_print_inline:()=>gI,inout_print_many:()=>II,inout_type_input:()=>TI,pyinout_type_input:()=>yI});var K={};__webpack_require__.r(K),__webpack_require__.d(K,{IOT_EMQX_INIT_AND_CONNECT_BY_MIXLY_CODE:()=>NI,IOT_EMQX_INIT_AND_CONNECT_BY_SHARE_CODE:()=>LI,IOT_EMQX_PING:()=>FI,IOT_FORMATTING:()=>MI,IOT_FORMAT_STRING:()=>CI,IOT_MIXIO_NTP:()=>PI,IOT_MIXIO_PUBLISH:()=>bI,IOT_MIXIO_SUBSCRIBE:()=>vI,IOT_MIXIO_UNSUBSCRIBE:()=>wI,iot_mixio_check:()=>RI,iot_mixio_connect:()=>EI,iot_mixio_connect_only:()=>xI,iot_mixio_disconnect:()=>SI,iot_mixio_format_msg:()=>AI,iot_mixio_format_topic:()=>OI,iot_mixly_key:()=>kI,iot_mixly_key_py:()=>DI});var Q={};__webpack_require__.r(Q),__webpack_require__.d(Q,{pins_analog_read:()=>YI,pins_analog_write:()=>UI,pins_digital:()=>$I,pins_digital_read:()=>VI,pins_digital_write:()=>BI});var J={};__webpack_require__.r(J),__webpack_require__.d(J,{serial_close:()=>zI,serial_open:()=>GI,serial_read_b:()=>WI,serial_write:()=>HI});var Z={};__webpack_require__.r(Z),__webpack_require__.d(Z,{sklearn_DecisionTreeClassifier_Regressor:()=>nE,sklearn_GaussianNB:()=>rE,sklearn_KMeans:()=>lE,sklearn_KMeans_fit:()=>uE,sklearn_KNeighborsClassifier_Regressor:()=>sE,sklearn_LinearRegression:()=>tE,sklearn_RandomForestClassifier_Regressor:()=>iE,sklearn_Ridge:()=>eE,sklearn_cluster_centers_labels_inertia:()=>gE,sklearn_coef_intercept:()=>mE,sklearn_data_target:()=>QI,sklearn_fit:()=>hE,sklearn_fit_no_target:()=>pE,sklearn_load:()=>KI,sklearn_make_blobs:()=>qI,sklearn_make_classification:()=>XI,sklearn_make_regression:()=>jI,sklearn_pca:()=>aE,sklearn_pca_fit_transform:()=>oE,sklearn_predict:()=>cE,sklearn_save_load_model:()=>_E,sklearn_score:()=>dE,sklearn_score_no_target:()=>fE,sklearn_train_test_split:()=>JI,sklearn_train_test_split_no_target:()=>ZI});var tt={};__webpack_require__.r(tt),__webpack_require__.d(tt,{controls_end_program:()=>yE,controls_millis:()=>TE,time_localtime:()=>IE});var et={};__webpack_require__.r(et),__webpack_require__.d(et,{turtle_bgcolor:()=>VE,turtle_bgcolor_hex:()=>HE,turtle_bgcolor_hex_new:()=>XE,turtle_circle:()=>FE,turtle_circle_advanced:()=>$E,turtle_clear:()=>ME,turtle_clone:()=>GE,turtle_color:()=>QE,turtle_color_hex:()=>KE,turtle_color_seclet:()=>rb,turtle_create:()=>EE,turtle_done:()=>bE,turtle_exitonclick:()=>vE,turtle_fill:()=>NE,turtle_fillcolor:()=>YE,turtle_fillcolor_hex:()=>zE,turtle_fillcolor_hex_new:()=>qE,turtle_getscreen:()=>ab,turtle_goto:()=>OE,turtle_listen:()=>hb,turtle_move:()=>wE,turtle_numinput:()=>eb,turtle_onclick:()=>lb,turtle_onkey:()=>ob,turtle_ontimer:()=>ub,turtle_pencolor:()=>UE,turtle_pencolor_hex:()=>WE,turtle_pencolor_hex_new:()=>jE,turtle_penup:()=>CE,turtle_pos_shape:()=>AE,turtle_rotate:()=>SE,turtle_screen_delay:()=>RE,turtle_screen_savefig:()=>pb,turtle_setheading:()=>xE,turtle_setxy:()=>PE,turtle_shape:()=>JE,turtle_shapesize:()=>ZE,turtle_size:()=>DE,turtle_size_speed:()=>kE,turtle_speed:()=>LE,turtle_textinput:()=>tb,turtle_visible:()=>BE,turtle_write:()=>nb,turtle_write_format:()=>ib,turtle_write_format_skulpt:()=>sb});var nt={};__webpack_require__.r(nt),__webpack_require__.d(nt,{COPYFILE_EXCL:()=>Kb,COPYFILE_FICLONE:()=>Qb,COPYFILE_FICLONE_FORCE:()=>Jb,F_OK:()=>zb,O_APPEND:()=>av,O_CREAT:()=>nv,O_DIRECT:()=>dv,O_DIRECTORY:()=>ov,O_DSYNC:()=>pv,O_EXCL:()=>iv,O_NOATIME:()=>lv,O_NOCTTY:()=>sv,O_NOFOLLOW:()=>uv,O_NONBLOCK:()=>fv,O_RDONLY:()=>Zb,O_RDWR:()=>ev,O_SYMLINK:()=>cv,O_SYNC:()=>hv,O_TRUNC:()=>rv,O_WRONLY:()=>tv,R_OK:()=>Xb,S_IFBLK:()=>yv,S_IFCHR:()=>Ev,S_IFDIR:()=>Iv,S_IFIFO:()=>bv,S_IFLNK:()=>_v,S_IFMT:()=>mv,S_IFREG:()=>Tv,S_IFSOCK:()=>gv,S_IRGRP:()=>Cv,S_IROTH:()=>Lv,S_IRUSR:()=>Rv,S_IRWXG:()=>Mv,S_IRWXO:()=>Dv,S_IRWXU:()=>xv,S_ISGID:()=>wv,S_ISUID:()=>vv,S_ISVTX:()=>Sv,S_IWGRP:()=>Nv,S_IWOTH:()=>Fv,S_IWUSR:()=>Ov,S_IXGRP:()=>kv,S_IXOTH:()=>Pv,S_IXUSR:()=>Av,UV_FS_O_FILEMAP:()=>$v,W_OK:()=>jb,X_OK:()=>qb,size_max:()=>Bv});var it={};__webpack_require__.r(it),__webpack_require__.d(it,{FileHandle:()=>ax,access:()=>Nx,appendFile:()=>_x,chmod:()=>xx,chown:()=>wx,constants:()=>nt,copyFile:()=>Lx,cp:()=>Px,exists:()=>lx,lchmod:()=>Rx,lchown:()=>Sx,link:()=>Ex,lstat:()=>hx,lutimes:()=>Ax,mkdir:()=>yx,mkdtemp:()=>Dx,open:()=>fx,opendir:()=>Fx,readFile:()=>mx,readdir:()=>Ix,readlink:()=>vx,realpath:()=>Mx,rename:()=>ox,rm:()=>kx,rmdir:()=>Tx,stat:()=>ux,statfs:()=>$x,symlink:()=>bx,truncate:()=>px,unlink:()=>cx,utimes:()=>Ox,watch:()=>Cx,writeFile:()=>gx});var st={};__webpack_require__.r(st),__webpack_require__.d(st,{BigIntStatsFs:()=>zv,Dir:()=>tx,Dirent:()=>ZS,ReadStream:()=>nx,Stats:()=>Gv,StatsFs:()=>Wv,WriteStream:()=>ix,_synced:()=>qw,access:()=>yR,accessSync:()=>HS,appendFile:()=>qx,appendFileSync:()=>IS,chmod:()=>fR,chmodSync:()=>BS,chown:()=>cR,chownSync:()=>PS,chroot:()=>tS,close:()=>Qx,closeSync:()=>bS,constants:()=>nt,copyFile:()=>OR,copyFileSync:()=>XS,cp:()=>NR,cpSync:()=>QS,createReadStream:()=>wR,createWriteStream:()=>SR,exists:()=>Ux,existsSync:()=>uS,fchmod:()=>sR,fchmodSync:()=>AS,fchown:()=>iR,fchownSync:()=>OS,fdatasync:()=>tR,fdatasyncSync:()=>SS,fstat:()=>Kx,fstatSync:()=>ES,fsync:()=>Zx,fsyncSync:()=>wS,ftruncate:()=>Jx,ftruncateSync:()=>vS,futimes:()=>rR,futimesSync:()=>MS,lchmod:()=>mR,lchmodSync:()=>VS,lchown:()=>dR,lchownSync:()=>$S,link:()=>uR,linkSync:()=>DS,lopenSync:()=>gS,lstat:()=>Gx,lstatSync:()=>pS,lutimes:()=>_R,lutimesSync:()=>YS,mkdir:()=>oR,mkdirSync:()=>NS,mkdtemp:()=>RR,mkdtempSync:()=>zS,mount:()=>zw,mountObject:()=>Jw,mounts:()=>Ww,open:()=>zx,openAsBlob:()=>DR,openSync:()=>mS,opendir:()=>CR,opendirSync:()=>KS,promises:()=>it,read:()=>nR,readFile:()=>Xx,readFileSync:()=>TS,readSync:()=>RS,readdir:()=>lR,readdirSync:()=>kS,readlink:()=>pR,readlinkSync:()=>FS,readv:()=>AR,readvSync:()=>jS,realpath:()=>TR,realpathSync:()=>GS,rename:()=>Vx,renameSync:()=>lS,rm:()=>xR,rmSync:()=>WS,rmdir:()=>aR,rmdirSync:()=>CS,stat:()=>Yx,statSync:()=>hS,statfs:()=>kR,statfsSync:()=>JS,symlink:()=>hR,symlinkSync:()=>LS,truncate:()=>Hx,truncateSync:()=>cS,umount:()=>Xw,unlink:()=>Wx,unlinkSync:()=>dS,unwatchFile:()=>bR,utimes:()=>gR,utimesSync:()=>US,watch:()=>vR,watchFile:()=>ER,write:()=>eR,writeFile:()=>jx,writeFileSync:()=>yS,writeSync:()=>xS,writev:()=>MR,writevSync:()=>qS});var rt={};__webpack_require__.r(rt),__webpack_require__.d(rt,{arraysEqual:()=>vO,arraysEqualWithNull:()=>bO,assert:()=>_O,assertNonNegativeIntegerDimensions:()=>ZO,assertNonNull:()=>yO,assertShapesMatch:()=>TO,bytesFromStringArray:()=>BO,bytesPerElement:()=>$O,checkConversionForErrors:()=>LO,clamp:()=>pO,computeStrides:()=>zO,convertBackendValuesAndArrayBuffer:()=>qO,createScalarValue:()=>ik,createShuffledIndices:()=>RO,decodeString:()=>lk,distSquared:()=>gO,encodeString:()=>ok,fetch:()=>ak,fingerPrint64:()=>nk,flatten:()=>hk,getArrayFromDType:()=>DO,getTypedArrayFromDType:()=>kO,hasEncodingLoss:()=>PO,hexToLong:()=>WN,indexToLoc:()=>eA,inferDtype:()=>GO,inferFromImplicitShape:()=>MO,isBoolean:()=>UO,isFunction:()=>HO,isInt:()=>wO,isNumber:()=>YO,isPromise:()=>nA,isScalarShape:()=>EO,isString:()=>VO,isTypedArray:()=>uk,isValidDtype:()=>FO,locToIndex:()=>tA,makeOnesTypedArray:()=>KO,makeZerosNestedTypedArray:()=>JO,makeZerosTypedArray:()=>QO,nearestDivisor:()=>WO,nearestLargerEven:()=>cO,now:()=>rk,parseAxisParam:()=>CO,randUniform:()=>mO,repeatedTry:()=>AO,rightPad:()=>OO,shuffle:()=>uO,shuffleCombo:()=>hO,sizeFromShape:()=>IO,sizeToSquarishShape:()=>xO,squeezeShape:()=>NO,sum:()=>fO,swap:()=>dO,tanh:()=>SO,toNestedArray:()=>jO,toTypedArray:()=>sk});var at={};__webpack_require__.r(at),__webpack_require__.d(at,{assertTypesMatch:()=>Vk,getTensorsInContainer:()=>Yk,isTensorInList:()=>Uk,makeTypesMatch:()=>Bk});var ot={};__webpack_require__.r(ot),__webpack_require__.d(ot,{isBrowser:()=>Zk,isMobile:()=>Jk,mockIsMobile:()=>Qk});var lt={};__webpack_require__.r(lt),__webpack_require__.d(lt,{Serializable:()=>iF,SerializationMap:()=>sF,getRegisteredName:()=>aF,registerClass:()=>rF});var ut={};__webpack_require__.r(ut),__webpack_require__.d(ut,{assertAndGetBroadcastShape:()=>_F,getBroadcastDims:()=>mF,getReductionAxes:()=>gF});var ht={};__webpack_require__.r(ht),__webpack_require__.d(ht,{CompositeArrayBuffer:()=>cD,browserFiles:()=>RF,browserHTTPRequest:()=>FF,concatenateArrayBuffers:()=>WD,copyModel:()=>ML,decodeWeights:()=>FD,decodeWeightsStream:()=>UD,encodeWeights:()=>LD,fromMemory:()=>VF,fromMemorySync:()=>UF,getLoadHandlers:()=>nL,getModelArtifactsForJSON:()=>qD,getModelArtifactsForJSONSync:()=>jD,getModelArtifactsInfoForJSON:()=>KD,getSaveHandlers:()=>eL,getWeightSpecs:()=>QD,http:()=>LF,isHTTPScheme:()=>kF,listModels:()=>OL,loadWeights:()=>MF,moveModel:()=>CL,registerLoadRouter:()=>tL,registerSaveRouter:()=>ZD,removeModel:()=>AL,weightsLoaderFactory:()=>CF,withSaveHandler:()=>YF,withSaveHandlerSync:()=>GF});var pt={};__webpack_require__.r(pt),__webpack_require__.d(pt,{confusionMatrix:()=>KF});var ct={};__webpack_require__.r(ct),__webpack_require__.d(ct,{draw:()=>rP,fromPixels:()=>aP,fromPixelsAsync:()=>nP,toPixels:()=>sP});var dt={};__webpack_require__.r(dt),__webpack_require__.d(dt,{prepareAndValidate:()=>oP});var ft={};__webpack_require__.r(ft),__webpack_require__.d(ft,{calculateShapes:()=>hP,validateInput:()=>uP,validateUpdateShape:()=>lP});var mt={};__webpack_require__.r(mt),__webpack_require__.d(mt,{assertParamsValid:()=>dP,computeFlatOffset:()=>xP,computeOutShape:()=>mP,getNormalizedAxes:()=>yP,isSliceContinous:()=>SP,maskToAxes:()=>fP,parseSliceParams:()=>RP,sliceInfo:()=>OP,startForAxis:()=>vP,startIndicesWithElidedDims:()=>IP,stopForAxis:()=>wP,stopIndicesWithElidedDims:()=>EP,stridesForAxis:()=>bP,stridesWithElidedDims:()=>gP});var gt={};__webpack_require__.r(gt),__webpack_require__.d(gt,{TEST_EPSILON_FLOAT16:()=>CP,createVideoElement:()=>YP,encodeStrings:()=>UP,expectArrayBuffersEqual:()=>VP,expectArraysClose:()=>NP,expectArraysEqual:()=>FP,expectNumbersClose:()=>PP,expectPromiseToFail:()=>LP,expectValuesInRange:()=>BP,play:()=>GP,testEpsilon:()=>kP});var _t={};__webpack_require__.r(_t),__webpack_require__.d(_t,{conv2d:()=>jU,depthwiseConv2d:()=>QU,matMul:()=>JU});var Tt={};__webpack_require__.r(Tt),__webpack_require__.d(Tt,{collectGatherOpShapeInfo:()=>lH,computeOutShape:()=>oH,segOpComputeOptimalWindowSize:()=>aH});var yt={};__webpack_require__.r(yt),__webpack_require__.d(yt,{ERF_A1:()=>wG,ERF_A2:()=>SG,ERF_A3:()=>xG,ERF_A4:()=>RG,ERF_A5:()=>OG,ERF_P:()=>vG,PARALLELIZE_THRESHOLD:()=>dG,RowPartitionType:()=>lG,SELU_SCALE:()=>bG,SELU_SCALEALPHA:()=>EG,applyActivation:()=>zU,assertAndGetBroadcastShape:()=>_F,assertAxesAreInnerMostDims:()=>gB,assertParamsConsistent:()=>aG,assignToTypedArray:()=>DG,axesAreInnerMostDims:()=>cB,calculateShapes:()=>hP,checkEinsumDimSizes:()=>GG,checkPadOnDimRoundingMode:()=>T$,combineLocations:()=>dB,combineRaggedTensorToTensorShapes:()=>uG,complexWithEvenIndex:()=>CG,complexWithOddIndex:()=>NG,computeConv2DInfo:()=>o$,computeConv3DInfo:()=>l$,computeDefaultPad:()=>u$,computeDilation2DInfo:()=>s$,computeOptimalWindowSize:()=>fG,computeOutAndReduceShapes:()=>fB,computeOutShape:()=>oG,computePool2DInfo:()=>r$,computePool3DInfo:()=>a$,convertConv2DDataFormat:()=>_$,decodeEinsumEquation:()=>UG,eitherStridesOrDilationsAreOne:()=>m$,expandShapeToKeepDim:()=>mB,exponent:()=>FG,exponents:()=>LG,fromStringArrayToUint8:()=>hH,fromUint8ToStringArray:()=>uH,getAxesPermutation:()=>_B,getBroadcastDims:()=>mF,getComplexWithIndex:()=>kG,getEinsumComputePath:()=>HG,getEinsumPermutation:()=>YG,getFusedBiasGradient:()=>WU,getFusedDyActivation:()=>HU,getImageCenter:()=>mG,getInnerMostAxes:()=>yB,getPermuted:()=>_G,getRaggedRank:()=>pG,getReductionAxes:()=>gF,getReshaped:()=>gG,getReshapedPermuted:()=>TG,getRowPartitionTypesHelper:()=>hG,getSliceBeginCoords:()=>yG,getSliceSize:()=>IG,getSparseFillEmptyRowsIndicesDenseShapeMismatch:()=>jG,getSparseFillEmptyRowsNegativeIndexErrorMessage:()=>qG,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:()=>KG,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:()=>ZG,getSparseReshapeInputOutputMismatchErrorMessage:()=>eH,getSparseReshapeInputOutputMultipleErrorMessage:()=>tH,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:()=>QG,getSparseReshapeNegativeOutputDimErrorMessage:()=>JG,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:()=>rH,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:()=>nH,getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:()=>iH,getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:()=>sH,getUndoAxesPermutation:()=>TB,isIdentityPermutation:()=>WG,log:()=>MN,mergeRealAndImagArrays:()=>AG,prepareAndValidate:()=>oP,prepareSplitSize:()=>XG,segment_util:()=>Tt,shouldFuse:()=>XU,slice_util:()=>mt,splitRealAndImagArrays:()=>MG,stridesOrDilationsArePositive:()=>g$,tupleValuesAreOne:()=>f$,upcastType:()=>Lk,validateDefaultValueShape:()=>cG,validateInput:()=>uP,validateUpdateShape:()=>lP,warn:()=>AN});var It={};__webpack_require__.r(It),__webpack_require__.d(It,{nonMaxSuppressionV3Impl:()=>cY,nonMaxSuppressionV4Impl:()=>dY,nonMaxSuppressionV5Impl:()=>fY,whereImpl:()=>NU});var Et={};__webpack_require__.r(Et),__webpack_require__.d(Et,{maxNorm:()=>GX,minMaxNorm:()=>zX,nonNeg:()=>WX,unitNorm:()=>HX});var bt={};__webpack_require__.r(bt),__webpack_require__.d(bt,{constant:()=>qX,glorotNormal:()=>nj,glorotUniform:()=>ej,heNormal:()=>ij,heUniform:()=>sj,identity:()=>ZX,leCunNormal:()=>rj,leCunUniform:()=>aj,ones:()=>jX,orthogonal:()=>oj,randomNormal:()=>QX,randomUniform:()=>KX,truncatedNormal:()=>JX,varianceScaling:()=>tj,zeros:()=>XX});var vt={};__webpack_require__.r(vt),__webpack_require__.d(vt,{Layer:()=>bX,RNN:()=>MK,RNNCell:()=>CK,activation:()=>hJ,add:()=>yJ,alphaDropout:()=>uZ,average:()=>IJ,averagePooling1d:()=>AJ,averagePooling2d:()=>NJ,averagePooling3d:()=>LJ,avgPool1d:()=>MJ,avgPool2d:()=>kJ,avgPool3d:()=>FJ,avgPooling1d:()=>CJ,avgPooling2d:()=>DJ,avgPooling3d:()=>PJ,batchNormalization:()=>xJ,bidirectional:()=>eZ,categoryEncoding:()=>fZ,centerCrop:()=>cZ,concatenate:()=>EJ,conv1d:()=>eJ,conv2d:()=>nJ,conv2dTranspose:()=>iJ,conv3d:()=>sJ,conv3dTranspose:()=>rJ,convLstm2d:()=>QJ,convLstm2dCell:()=>JJ,cropping2D:()=>oJ,dense:()=>pJ,depthwiseConv2d:()=>uJ,dot:()=>SJ,dropout:()=>cJ,elu:()=>qQ,embedding:()=>TJ,flatten:()=>fJ,gaussianDropout:()=>lZ,gaussianNoise:()=>oZ,globalAveragePooling1d:()=>$J,globalAveragePooling2d:()=>BJ,globalMaxPool1d:()=>iZ,globalMaxPool2d:()=>sZ,globalMaxPooling1d:()=>VJ,globalMaxPooling2d:()=>UJ,gru:()=>WJ,gruCell:()=>zJ,input:()=>Rq,inputLayer:()=>jQ,layerNormalization:()=>RJ,leakyReLU:()=>QQ,lstm:()=>XJ,lstmCell:()=>jJ,masking:()=>hZ,maxPool1d:()=>rZ,maxPool2d:()=>aZ,maxPooling1d:()=>YJ,maxPooling2d:()=>GJ,maxPooling3d:()=>HJ,maximum:()=>bJ,minimum:()=>vJ,multiply:()=>wJ,permute:()=>_J,prelu:()=>JQ,randomWidth:()=>mZ,reLU:()=>KQ,repeatVector:()=>mJ,rescaling:()=>pZ,reshape:()=>gJ,resizing:()=>dZ,rnn:()=>ZJ,separableConv2d:()=>aJ,simpleRNN:()=>qJ,simpleRNNCell:()=>KJ,softmax:()=>ZQ,spatialDropout1d:()=>dJ,stackedRNNCells:()=>tZ,thresholdedReLU:()=>tJ,timeDistributed:()=>nZ,upSampling2d:()=>lJ,zeroPadding2d:()=>OJ});var wt={};__webpack_require__.r(wt),__webpack_require__.d(wt,{MAPE:()=>xZ,MSE:()=>AZ,binaryAccuracy:()=>gZ,binaryCrossentropy:()=>_Z,categoricalAccuracy:()=>yZ,categoricalCrossentropy:()=>IZ,cosineProximity:()=>vZ,mape:()=>RZ,meanAbsoluteError:()=>wZ,meanAbsolutePercentageError:()=>SZ,meanSquaredError:()=>OZ,mse:()=>MZ,precision:()=>EZ,r2Score:()=>CZ,recall:()=>bZ,sparseCategoricalAccuracy:()=>TZ});var St={};__webpack_require__.r(St),__webpack_require__.d(St,{modelFromJSON:()=>bq});var xt={};__webpack_require__.r(xt),__webpack_require__.d(xt,{l1:()=>kZ,l1l2:()=>NZ,l2:()=>DZ});var Rt={};__webpack_require__.r(Rt),__webpack_require__.d(Rt,{json:()=>t0});var Ot={};__webpack_require__.r(Ot),__webpack_require__.d(Ot,{json:()=>e0});var At={};__webpack_require__.r(At),__webpack_require__.d(At,{json:()=>n0});var Mt={};__webpack_require__.r(Mt),__webpack_require__.d(Mt,{json:()=>i0});var Ct={};__webpack_require__.r(Ct),__webpack_require__.d(Ct,{json:()=>s0});var Nt={};__webpack_require__.r(Nt),__webpack_require__.d(Nt,{json:()=>r0});var kt={};__webpack_require__.r(kt),__webpack_require__.d(kt,{json:()=>a0});var Dt={};__webpack_require__.r(Dt),__webpack_require__.d(Dt,{json:()=>o0});var Lt={};__webpack_require__.r(Lt),__webpack_require__.d(Lt,{json:()=>l0});var Ft={};__webpack_require__.r(Ft),__webpack_require__.d(Ft,{json:()=>u0});var Pt={};__webpack_require__.r(Pt),__webpack_require__.d(Pt,{json:()=>h0});var $t={};__webpack_require__.r($t),__webpack_require__.d($t,{json:()=>p0});var Bt={};__webpack_require__.r(Bt),__webpack_require__.d(Bt,{json:()=>c0});var Vt={};__webpack_require__.r(Vt),__webpack_require__.d(Vt,{json:()=>d0});var Ut={};__webpack_require__.r(Ut),__webpack_require__.d(Ut,{json:()=>f0});var Yt={};__webpack_require__.r(Yt),__webpack_require__.d(Yt,{json:()=>m0});var Gt={};__webpack_require__.r(Gt),__webpack_require__.d(Gt,{json:()=>g0});var Ht={};__webpack_require__.r(Ht),__webpack_require__.d(Ht,{json:()=>_0});var Wt={};__webpack_require__.r(Wt),__webpack_require__.d(Wt,{json:()=>T0});var zt={};__webpack_require__.r(zt),__webpack_require__.d(zt,{OP_SCOPE_SUFFIX:()=>aD,abs:()=>fF,acos:()=>zP,acosh:()=>XP,add:()=>VL,addN:()=>jP,all:()=>qP,any:()=>KP,argMax:()=>QP,argMin:()=>JP,asin:()=>ZP,asinh:()=>t$,atan:()=>e$,atan2:()=>n$,atanh:()=>i$,avgPool:()=>I$,avgPool3d:()=>E$,basicLSTMCell:()=>x$,batchNorm:()=>O$,batchNorm2d:()=>A$,batchNorm3d:()=>M$,batchNorm4d:()=>C$,batchToSpaceND:()=>R$,bincount:()=>N$,bitwiseAnd:()=>k$,booleanMaskAsync:()=>DU,broadcastArgs:()=>D$,broadcastTo:()=>L$,buffer:()=>FL,cast:()=>PL,ceil:()=>F$,clipByValue:()=>P$,clone:()=>$L,complex:()=>lD,concat:()=>b$,concat1d:()=>$$,concat2d:()=>B$,concat3d:()=>V$,concat4d:()=>U$,conv1d:()=>G$,conv2d:()=>Y$,conv2dTranspose:()=>W$,conv3d:()=>z$,conv3dTranspose:()=>j$,cos:()=>q$,cosh:()=>K$,cosineWindow:()=>UU,cumprod:()=>Q$,cumsum:()=>J$,denseBincount:()=>Z$,depthToSpace:()=>tB,depthwiseConv2d:()=>eB,diag:()=>nB,dilation2d:()=>iB,div:()=>YL,divNoNan:()=>aB,dot:()=>oB,dropout:()=>BU,einsum:()=>lB,elu:()=>uB,enclosingPowerOfTwo:()=>VU,ensureShape:()=>hB,equal:()=>sB,erf:()=>pB,euclideanNorm:()=>SB,exp:()=>xB,expandDims:()=>RB,expm1:()=>OB,eye:()=>MB,fft:()=>lU,fill:()=>uF,floor:()=>CB,floorDiv:()=>UL,fused:()=>_t,gather:()=>NB,gatherND:()=>$U,greater:()=>kB,greaterEqual:()=>DB,ifft:()=>uU,imag:()=>zF,image:()=>JY,inTopKAsync:()=>YU,irfft:()=>hU,isFinite:()=>LB,isInf:()=>FB,isNaN:()=>PB,leakyRelu:()=>$B,less:()=>BB,lessEqual:()=>VB,linalg:()=>ZY,linspace:()=>UB,localResponseNormalization:()=>YB,log:()=>GB,log1p:()=>HB,logSigmoid:()=>zB,logSoftmax:()=>XB,logSumExp:()=>jB,logicalAnd:()=>qB,logicalNot:()=>KB,logicalOr:()=>QB,logicalXor:()=>JB,losses:()=>tG,lowerBound:()=>eV,matMul:()=>HF,max:()=>IB,maxPool:()=>nV,maxPool3d:()=>iV,maxPoolWithArgmax:()=>sV,maximum:()=>TF,mean:()=>rV,meshgrid:()=>lV,min:()=>EB,minimum:()=>uV,mirrorPad:()=>hV,mod:()=>pV,moments:()=>cV,movingAverage:()=>LU,mul:()=>GL,multiRNNCell:()=>dV,multinomial:()=>fV,neg:()=>XF,norm:()=>wB,notEqual:()=>mV,oneHot:()=>WF,ones:()=>oV,onesLike:()=>gV,op:()=>oD,outerProduct:()=>_V,pad:()=>TV,pad1d:()=>yV,pad2d:()=>IV,pad3d:()=>EV,pad4d:()=>bV,pool:()=>wV,pow:()=>pF,prelu:()=>SV,print:()=>BL,prod:()=>xV,raggedGather:()=>RV,raggedRange:()=>OV,raggedTensorToTensor:()=>AV,rand:()=>MV,randomGamma:()=>LV,randomNormal:()=>FV,randomStandardNormal:()=>PV,randomUniform:()=>$V,randomUniformInt:()=>BV,range:()=>VV,real:()=>jF,reciprocal:()=>UV,relu:()=>YV,relu6:()=>GV,reshape:()=>y$,reverse:()=>HV,reverse1d:()=>WV,reverse2d:()=>zV,reverse3d:()=>XV,reverse4d:()=>jV,rfft:()=>cU,round:()=>qV,rsqrt:()=>KV,scalar:()=>tF,scatterND:()=>FU,searchSorted:()=>tV,selu:()=>QV,separableConv2d:()=>JV,setdiff1dAsync:()=>ZV,sigmoid:()=>v$,sign:()=>tU,signal:()=>QY,sin:()=>eU,sinh:()=>nU,slice:()=>w$,slice1d:()=>iU,slice2d:()=>sU,slice3d:()=>rU,slice4d:()=>aU,softmax:()=>oU,softplus:()=>WB,spaceToBatchND:()=>vV,sparse:()=>eG,sparseToDense:()=>PU,spectral:()=>KY,split:()=>pU,sqrt:()=>HL,square:()=>WL,squaredDifference:()=>dU,squeeze:()=>fU,stack:()=>mU,step:()=>gU,stridedSlice:()=>_U,string:()=>nG,sub:()=>cF,sum:()=>bB,tan:()=>TU,tanh:()=>S$,tensor:()=>hD,tensor1d:()=>yU,tensor2d:()=>IU,tensor3d:()=>QF,tensor4d:()=>EU,tensor5d:()=>bU,tensor6d:()=>vU,tensorScatterUpdate:()=>wU,tile:()=>AB,topk:()=>SU,transpose:()=>qF,truncatedNormal:()=>xU,unique:()=>RU,unsortedSegmentSum:()=>OU,unstack:()=>AU,upperBound:()=>MU,variable:()=>CU,where:()=>rB,whereAsync:()=>kU,zeros:()=>aV,zerosLike:()=>zL});var Xt={};__webpack_require__.r(Xt),__webpack_require__.d(Xt,{CSVDataset:()=>Z1,Dataset:()=>U1,FileDataSource:()=>c2,TextLineDataset:()=>z1,URLDataSource:()=>d2,array:()=>G1,csv:()=>f2,func:()=>m2,generator:()=>g2,microphone:()=>T2,version_data:()=>y2,webcam:()=>_2,zip:()=>H1});var jt={};__webpack_require__.r(jt),__webpack_require__.d(jt,{addImpl:()=>$2,bincountImpl:()=>Y2,bincountReduceImpl:()=>G2,bitwiseAndImpl:()=>H2,castImpl:()=>k2,ceilImpl:()=>K2,concatImpl:()=>Z2,equalImpl:()=>t3,expImpl:()=>i3,expm1Impl:()=>a3,floorDivImpl:()=>c3,floorImpl:()=>u3,gatherNdImpl:()=>m3,gatherV2Impl:()=>g3,greaterEqualImpl:()=>I3,greaterImpl:()=>_3,lessEqualImpl:()=>x3,lessImpl:()=>v3,linSpaceImpl:()=>A3,logImpl:()=>M3,maxImpl:()=>k3,maximumImpl:()=>D3,minimumImpl:()=>P3,multiplyImpl:()=>V3,negImpl:()=>H3,notEqualImpl:()=>z3,prodImpl:()=>J3,raggedGatherImpl:()=>i4,raggedRangeImpl:()=>r4,raggedTensorToTensorImpl:()=>h4,rangeImpl:()=>p4,rsqrtImpl:()=>c4,scatterImpl:()=>m4,sigmoidImpl:()=>g4,simpleAbsImpl:()=>v2,sliceImpl:()=>y4,sparseFillEmptyRowsImpl:()=>b4,sparseReshapeImpl:()=>v4,sparseSegmentReductionImpl:()=>w4,sqrtImpl:()=>S4,squaredDifferenceImpl:()=>O4,staticRegexReplaceImpl:()=>C4,stridedSliceImpl:()=>D4,stringNGramsImpl:()=>F4,stringSplitImpl:()=>$4,stringToHashBucketFastImpl:()=>B4,subImpl:()=>V4,tileImpl:()=>H4,topKImpl:()=>X4,transposeImpl:()=>q3,uniqueImpl:()=>j4});var qt={};__webpack_require__.r(qt),__webpack_require__.d(qt,{assertNotComplex:()=>utt,bindCanvasToFramebuffer:()=>P7,bindColorTextureToFramebuffer:()=>$7,bindTextureToProgramUniformSampler:()=>F7,bindTextureUnit:()=>N7,bindVertexBufferToProgramAttribute:()=>C7,callAndCheck:()=>c7,canBeRepresented:()=>m7,createFragmentShader:()=>y7,createFramebuffer:()=>M7,createProgram:()=>b7,createStaticIndexBuffer:()=>x7,createStaticVertexBuffer:()=>S7,createTexture:()=>O7,createVertexShader:()=>T7,getBatchDim:()=>H7,getExtensionOrThrow:()=>_7,getFramebufferErrorMessage:()=>U7,getMaxTexturesInShader:()=>ett,getNumChannels:()=>R7,getProgramUniformLocation:()=>L7,getProgramUniformLocationOrThrow:()=>D7,getRowsCols:()=>W7,getShapeAs3D:()=>z7,getTextureShapeFromLogicalShape:()=>X7,getWebGLDisjointQueryTimerVersion:()=>ntt,getWebGLErrorMessage:()=>g7,getWebGLMaxTextureSize:()=>J7,hasExtension:()=>itt,isCapableOfRenderingToFloatTexture:()=>rtt,isDownloadFloatTextureEnabled:()=>att,isReshapeFree:()=>q7,isWebGLFenceEnabled:()=>ltt,isWebGLVersionEnabled:()=>stt,linkProgram:()=>v7,logShaderSourceAndInfoLog:()=>E7,resetMaxTextureSize:()=>Z7,resetMaxTexturesInShader:()=>ttt,unbindColorTextureFromFramebuffer:()=>B7,unbindTextureUnit:()=>k7,validateFramebuffer:()=>V7,validateProgram:()=>w7,validateTextureSize:()=>A7});var Kt={};__webpack_require__.r(Kt),__webpack_require__.d(Kt,{bindVertexProgramAttributeStreams:()=>net,createBufferFromOutputTexture:()=>ret,createFloat16MatrixTexture:()=>qtt,createFloat16PackedMatrixTexture:()=>eet,createFloat32MatrixTexture:()=>Xtt,createIndexBuffer:()=>Htt,createPackedMatrixTexture:()=>Ztt,createUnsignedBytesMatrixTexture:()=>Qtt,createVertexBuffer:()=>Gtt,createVertexShader:()=>Ytt,downloadByteEncodedFloatMatrixFromOutputTexture:()=>oet,downloadFloat32MatrixFromBuffer:()=>aet,downloadMatrixFromPackedOutputTexture:()=>het,downloadPackedMatrixFromBuffer:()=>uet,getInternalFormatForFloat16MatrixTexture:()=>jtt,getInternalFormatForFloat16PackedMatrixTexture:()=>tet,getInternalFormatForFloat32MatrixTexture:()=>ztt,getInternalFormatForPackedMatrixTexture:()=>Jtt,getInternalFormatForUnsignedBytesMatrixTexture:()=>Ktt,uploadDenseMatrixToTexture:()=>iet,uploadPixelDataToTexture:()=>set});var Qt={};__webpack_require__.r(Qt),__webpack_require__.d(Qt,{Abs:()=>pA,Acos:()=>cA,Acosh:()=>dA,AdadeltaOptimizer:()=>lF,AdagradOptimizer:()=>hF,AdamOptimizer:()=>dF,AdamaxOptimizer:()=>yF,Add:()=>fA,AddN:()=>mA,All:()=>gA,Any:()=>_A,ArgMax:()=>TA,ArgMin:()=>yA,Asin:()=>IA,Asinh:()=>EA,Atan:()=>bA,Atan2:()=>wA,Atanh:()=>vA,AvgPool:()=>SA,AvgPool3D:()=>RA,AvgPool3DGrad:()=>OA,AvgPoolGrad:()=>xA,BatchMatMul:()=>AA,BatchToSpaceND:()=>MA,Bincount:()=>CA,BitwiseAnd:()=>NA,BroadcastArgs:()=>DA,BroadcastTo:()=>kA,Callback:()=>LZ,CallbackList:()=>cj,Cast:()=>LA,Ceil:()=>FA,ClipByValue:()=>PA,Complex:()=>$A,ComplexAbs:()=>BA,Concat:()=>VA,Conv2D:()=>UA,Conv2DBackpropFilter:()=>YA,Conv2DBackpropInput:()=>GA,Conv3D:()=>HA,Conv3DBackpropFilterV2:()=>WA,Conv3DBackpropInputV2:()=>zA,Cos:()=>XA,Cosh:()=>jA,CropAndResize:()=>QA,Cumprod:()=>qA,Cumsum:()=>KA,CustomCallback:()=>mj,DataStorage:()=>aO,DenseBincount:()=>JA,DepthToSpace:()=>ZA,DepthwiseConv2dNative:()=>tM,DepthwiseConv2dNativeBackpropFilter:()=>eM,DepthwiseConv2dNativeBackpropInput:()=>nM,Diag:()=>iM,Dilation2D:()=>sM,Dilation2DBackpropFilter:()=>aM,Dilation2DBackpropInput:()=>rM,Draw:()=>oM,ENV:()=>lA,EarlyStopping:()=>$Z,Einsum:()=>uM,Elu:()=>hM,EluGrad:()=>pM,Environment:()=>sA,Equal:()=>dM,Erf:()=>cM,Exp:()=>fM,ExpandDims:()=>mM,Expm1:()=>gM,FFT:()=>_M,Fill:()=>TM,FlipLeftRight:()=>yM,Floor:()=>IM,FloorDiv:()=>EM,FromPixels:()=>wN,FusedBatchNorm:()=>bM,FusedConv2D:()=>RN,FusedDepthwiseConv2D:()=>ON,GPGPUContext:()=>pet,GatherNd:()=>wM,GatherV2:()=>vM,GraphModel:()=>a1,Greater:()=>SM,GreaterEqual:()=>xM,History:()=>fj,IFFT:()=>OM,Identity:()=>RM,Imag:()=>AM,InputSpec:()=>_X,IsFinite:()=>MM,IsInf:()=>CM,IsNan:()=>NM,KernelBackend:()=>oO,LRN:()=>WM,LRNGrad:()=>zM,LayerVariable:()=>fX,LayersModel:()=>Iq,LeakyRelu:()=>kM,Less:()=>DM,LessEqual:()=>LM,LinSpace:()=>FM,Log:()=>PM,Log1p:()=>$M,LogSoftmax:()=>GM,LogicalAnd:()=>BM,LogicalNot:()=>VM,LogicalOr:()=>UM,LogicalXor:()=>YM,LowerBound:()=>HM,MathBackendCPU:()=>b2,MathBackendWebGL:()=>Lnt,MatrixBandPart:()=>XM,Max:()=>jM,MaxPool:()=>KM,MaxPool3D:()=>JM,MaxPool3DGrad:()=>ZM,MaxPoolGrad:()=>QM,MaxPoolWithArgmax:()=>tC,Maximum:()=>qM,Mean:()=>eC,Min:()=>nC,Minimum:()=>iC,MirrorPad:()=>sC,Mod:()=>rC,MomentumOptimizer:()=>EF,Multinomial:()=>aC,Multiply:()=>oC,Neg:()=>lC,NonMaxSuppressionV3:()=>hC,NonMaxSuppressionV4:()=>pC,NonMaxSuppressionV5:()=>cC,NotEqual:()=>uC,OP_SCOPE_SUFFIX:()=>aD,OneHot:()=>fC,OnesLike:()=>dC,Optimizer:()=>oF,OptimizerConstructors:()=>WP,Pack:()=>mC,PadV2:()=>gC,Pool:()=>_C,Pow:()=>TC,Prelu:()=>yC,Prod:()=>IC,RMSPropOptimizer:()=>bF,RNN:()=>MK,RaggedGather:()=>EC,RaggedRange:()=>bC,RaggedTensorToTensor:()=>vC,Range:()=>wC,Rank:()=>Ak,Real:()=>SC,RealDiv:()=>lM,Reciprocal:()=>xC,Reduction:()=>NY,Relu:()=>RC,Relu6:()=>kC,Reshape:()=>OC,ResizeBilinear:()=>CC,ResizeBilinearGrad:()=>NC,ResizeNearestNeighbor:()=>AC,ResizeNearestNeighborGrad:()=>MC,Reverse:()=>DC,RotateWithOffset:()=>SN,Round:()=>LC,Rsqrt:()=>FC,SGDOptimizer:()=>IF,ScatterNd:()=>PC,SearchSorted:()=>BC,Select:()=>VC,Selu:()=>UC,Sequential:()=>wq,Sigmoid:()=>zC,Sign:()=>WC,Sin:()=>GC,Sinh:()=>HC,Slice:()=>YC,Softmax:()=>JC,Softplus:()=>XC,SpaceToBatchND:()=>KC,SparseFillEmptyRows:()=>ZC,SparseReshape:()=>tN,SparseSegmentMean:()=>eN,SparseSegmentSum:()=>nN,SparseToDense:()=>iN,SplitV:()=>QC,Sqrt:()=>jC,Square:()=>rN,SquaredDifference:()=>sN,StaticRegexReplace:()=>aN,Step:()=>vN,StridedSlice:()=>oN,StringNGrams:()=>lN,StringSplit:()=>uN,StringToHashBucketFast:()=>hN,Sub:()=>pN,Sum:()=>qC,SymbolicTensor:()=>TX,Tan:()=>cN,Tanh:()=>dN,Tensor:()=>xk,TensorBuffer:()=>bk,TensorScatterUpdate:()=>$C,Tile:()=>fN,TopK:()=>mN,Transform:()=>gN,Transpose:()=>_N,Unique:()=>TN,Unpack:()=>yN,UnsortedSegmentSum:()=>IN,UpperBound:()=>EN,Variable:()=>Ok,ZerosLike:()=>bN,_FusedMatMul:()=>xN,abs:()=>fF,acos:()=>zP,acosh:()=>XP,add:()=>VL,addN:()=>jP,all:()=>qP,any:()=>KP,argMax:()=>QP,argMin:()=>JP,asin:()=>ZP,asinh:()=>t$,atan:()=>e$,atan2:()=>n$,atanh:()=>i$,avgPool:()=>I$,avgPool3d:()=>E$,backend:()=>ND,backend_util:()=>yt,basicLSTMCell:()=>x$,batchNorm:()=>O$,batchNorm2d:()=>A$,batchNorm3d:()=>M$,batchNorm4d:()=>C$,batchToSpaceND:()=>R$,bincount:()=>N$,bitwiseAnd:()=>k$,booleanMaskAsync:()=>DU,broadcastArgs:()=>D$,broadcastTo:()=>L$,broadcast_util:()=>ut,browser:()=>ct,buffer:()=>FL,callbacks:()=>BZ,cast:()=>PL,ceil:()=>F$,clipByValue:()=>P$,clone:()=>$L,complex:()=>lD,concat:()=>b$,concat1d:()=>$$,concat2d:()=>B$,concat3d:()=>V$,concat4d:()=>U$,constraints:()=>Et,conv1d:()=>G$,conv2d:()=>Y$,conv2dTranspose:()=>W$,conv3d:()=>z$,conv3dTranspose:()=>j$,copyRegisteredKernels:()=>VN,cos:()=>q$,cosh:()=>K$,cosineWindow:()=>UU,cumprod:()=>Q$,cumsum:()=>J$,customGrad:()=>JL,data:()=>Xt,denseBincount:()=>Z$,deprecationWarn:()=>gD,depthToSpace:()=>tB,depthwiseConv2d:()=>eB,deregisterOp:()=>WZ,device_util:()=>ot,diag:()=>nB,dilation2d:()=>iB,disableDeprecationWarnings:()=>mD,dispose:()=>bD,disposeVariables:()=>_D,div:()=>YL,divNoNan:()=>aB,dot:()=>oB,dropout:()=>BU,einsum:()=>lB,elu:()=>uB,enableDebugMode:()=>fD,enableProdMode:()=>dD,enclosingPowerOfTwo:()=>VU,engine:()=>TD,ensureShape:()=>hB,env:()=>aA,equal:()=>sB,erf:()=>pB,euclideanNorm:()=>SB,exp:()=>xB,expandDims:()=>RB,expm1:()=>OB,eye:()=>MB,fft:()=>lU,fill:()=>uF,findBackend:()=>AD,findBackendFactory:()=>MD,floor:()=>CB,floorDiv:()=>UL,forceHalfFloat:()=>Pnt,fused:()=>_t,gather:()=>NB,gatherND:()=>$U,gather_util:()=>dt,getBackend:()=>RD,getGradient:()=>DN,getKernel:()=>kN,getKernelsForBackend:()=>LN,gpgpu_util:()=>Kt,grad:()=>XL,grads:()=>jL,greater:()=>kB,greaterEqual:()=>DB,ifft:()=>uU,imag:()=>zF,image:()=>JY,inTopKAsync:()=>YU,initializers:()=>bt,input:()=>Rq,io:()=>ht,irfft:()=>hU,isFinite:()=>LB,isInf:()=>FB,isNaN:()=>PB,keep:()=>vD,kernel_impls:()=>It,layers:()=>vt,leakyRelu:()=>$B,less:()=>BB,lessEqual:()=>VB,linalg:()=>ZY,linspace:()=>UB,loadGraphModel:()=>o1,loadGraphModelSync:()=>l1,loadLayersModel:()=>vq,localResponseNormalization:()=>YB,log:()=>GB,log1p:()=>HB,logSigmoid:()=>zB,logSoftmax:()=>XB,logSumExp:()=>jB,logicalAnd:()=>qB,logicalNot:()=>KB,logicalOr:()=>QB,logicalXor:()=>JB,losses:()=>tG,lowerBound:()=>eV,matMul:()=>HF,math:()=>pt,max:()=>IB,maxPool:()=>nV,maxPool3d:()=>iV,maxPoolWithArgmax:()=>sV,maximum:()=>TF,mean:()=>rV,memory:()=>yD,meshgrid:()=>lV,metrics:()=>wt,min:()=>EB,minimum:()=>uV,mirrorPad:()=>hV,mod:()=>pV,model:()=>Sq,models:()=>St,moments:()=>cV,movingAverage:()=>LU,mul:()=>GL,multiRNNCell:()=>dV,multinomial:()=>fV,neg:()=>XF,nextFrame:()=>rG,norm:()=>wB,notEqual:()=>mV,oneHot:()=>WF,ones:()=>oV,onesLike:()=>gV,op:()=>oD,outerProduct:()=>_V,pad:()=>TV,pad1d:()=>yV,pad2d:()=>IV,pad3d:()=>EV,pad4d:()=>bV,pool:()=>wV,pow:()=>pF,prelu:()=>SV,print:()=>BL,prod:()=>xV,profile:()=>ID,raggedGather:()=>RV,raggedRange:()=>OV,raggedTensorToTensor:()=>AV,rand:()=>MV,randomGamma:()=>LV,randomNormal:()=>FV,randomStandardNormal:()=>PV,randomUniform:()=>$V,randomUniformInt:()=>BV,range:()=>VV,ready:()=>xD,real:()=>jF,reciprocal:()=>UV,registerBackend:()=>CD,registerCallbackConstructor:()=>Oq,registerGradient:()=>PN,registerKernel:()=>FN,registerOp:()=>GZ,regularizers:()=>xt,relu:()=>YV,relu6:()=>GV,removeBackend:()=>OD,reshape:()=>y$,reverse:()=>HV,reverse1d:()=>WV,reverse2d:()=>zV,reverse3d:()=>XV,reverse4d:()=>jV,rfft:()=>cU,round:()=>qV,rsqrt:()=>KV,scalar:()=>tF,scatterND:()=>FU,scatter_util:()=>ft,searchSorted:()=>tV,selu:()=>QV,separableConv2d:()=>JV,sequential:()=>xq,serialization:()=>lt,setBackend:()=>SD,setPlatform:()=>kD,setWebGLContext:()=>i7,setdiff1dAsync:()=>ZV,shared:()=>jt,sigmoid:()=>v$,sign:()=>tU,signal:()=>QY,sin:()=>eU,sinh:()=>nU,slice:()=>w$,slice1d:()=>iU,slice2d:()=>sU,slice3d:()=>rU,slice4d:()=>aU,slice_util:()=>mt,softmax:()=>oU,softplus:()=>WB,spaceToBatchND:()=>vV,sparse:()=>eG,sparseToDense:()=>PU,spectral:()=>KY,split:()=>pU,sqrt:()=>HL,square:()=>WL,squaredDifference:()=>dU,squeeze:()=>fU,stack:()=>mU,step:()=>gU,stridedSlice:()=>_U,string:()=>nG,sub:()=>cF,sum:()=>bB,sumOutType:()=>Fk,tan:()=>TU,tanh:()=>S$,tensor:()=>hD,tensor1d:()=>yU,tensor2d:()=>IU,tensor3d:()=>QF,tensor4d:()=>EU,tensor5d:()=>bU,tensor6d:()=>vU,tensorScatterUpdate:()=>wU,tensor_util:()=>at,test_util:()=>gt,tidy:()=>ED,tile:()=>AB,time:()=>wD,topk:()=>SU,train:()=>iG,transpose:()=>qF,truncatedNormal:()=>xU,unique:()=>RU,unregisterGradient:()=>BN,unregisterKernel:()=>$N,unsortedSegmentSum:()=>OU,unstack:()=>AU,upcastType:()=>Lk,upperBound:()=>MU,util:()=>rt,valueAndGrad:()=>qL,valueAndGrads:()=>KL,variable:()=>CU,variableGrads:()=>QL,version:()=>Nut,version_converter:()=>u1,version_core:()=>HP,version_cpu:()=>q4,version_layers:()=>tq,version_webgl:()=>Fnt,webgl:()=>$nt,webgl_util:()=>qt,where:()=>rB,whereAsync:()=>kU,zeros:()=>aV,zerosLike:()=>zL});const Jt=Blockly;Object.assign(Jt.Lang.ZhHans,{PYTHON_PYODIDE_IMAGE:"图像",PYTHON_PYODIDE_LOADING:"Python3内核载入中...",PYTHON_PYODIDE_FILE_SYSTEM:"本地文件系统",PYTHON_PYODIDE_LOAD_FILE_SYSTEM:"载入本地文件夹"}),Object.assign(Jt.Lang.ZhHant,{PYTHON_PYODIDE_IMAGE:"影像",PYTHON_PYODIDE_LOADING:"Python3核心載入...",PYTHON_PYODIDE_FILE_SYSTEM:"本機檔案系統",PYTHON_PYODIDE_LOAD_FILE_SYSTEM:"載入本機資料夾"}),Object.assign(Jt.Lang.En,{PYTHON_PYODIDE_IMAGE:"Image",PYTHON_PYODIDE_LOADING:"Python3 kernel loading...",PYTHON_PYODIDE_FILE_SYSTEM:"Local File System",PYTHON_PYODIDE_LOAD_FILE_SYSTEM:"Load Local Folder"}),Object.assign(Jt.Lang.ZhHans.MSG,{}),Object.assign(Jt.Lang.ZhHant.MSG,{}),Object.assign(Jt.Lang.En.MSG,{});const Zt=Mixly,te={NAME_TYPE:"VARIABLE",allVariables:function(t){var e;if(t.getDescendants)e=t.getDescendants();else{if(!t.getAllBlocks)throw"Not Block or Workspace: "+t;e=t.getAllBlocks()}for(var n=Object.create(null),i=0;i<e.length;i++)for(var s=e[i].getVars(),r=0;r<s.length;r++){var a=s[r];a&&(n[a.toLowerCase()]=a)}var o=[];for(var l in n)o.push(n[l]);return o},renameVariable:function(t,e,n){Jt.Events.setGroup(!0);for(var i=n.getAllBlocks(),s=0;s<i.length;s++)i[s].renameVar(t,e);Jt.Events.setGroup(!1)},flyoutCategory:function(t){var e=te.allVariables(t),n=[];((a=Jt.utils.xml.createElement("block")).setAttribute("type","variables_global"),n.push(a),Jt.Blocks.variables_set)&&((a=Jt.utils.xml.createElement("block")).setAttribute("type","variables_set"),n.push(a));Jt.Blocks.variables_change&&((a=Jt.utils.xml.createElement("block")).setAttribute("type","variables_change"),n.push(a));Jt.Blocks.controls_type&&((a=Jt.utils.xml.createElement("block")).setAttribute("type","controls_type"),n.push(a));Jt.Blocks.controls_typeLists&&((a=Jt.utils.xml.createElement("block")).setAttribute("type","controls_typeLists"),n.push(a));if(Jt.Blocks.lists_zip){(a=Jt.utils.xml.createElement("block")).setAttribute("type","lists_zip"),a.setAttribute("inline","false");var i=Jt.utils.xml.createElement("mutation");i.setAttribute("items",2),a.appendChild(i);for(let t=0;t<2;t++){let e=Jt.utils.xml.createElement("value");e.setAttribute("name",`ADD${t}`),a.appendChild(e)}n.push(a)}Jt.Blocks.unpack_iterable_object&&((a=Jt.utils.xml.createElement("block")).setAttribute("type","unpack_iterable_object"),n.push(a));for(var s=0;s<e.length;s++){if(Jt.Blocks.variables_set){(a=Jt.utils.xml.createElement("block")).setAttribute("type","variables_set"),Jt.Blocks.variables_get&&a.setAttribute("gap",8),(o=Jt.utils.xml.createElement("field",null,e[s])).setAttribute("name","VAR");var r=Jt.utils.xml.createTextNode(e[s]);o.appendChild(r),a.appendChild(o),n.push(a)}if(Jt.Blocks.variables_get){var a,o;(a=Jt.utils.xml.createElement("block")).setAttribute("type","variables_get"),Jt.Blocks.variables_set&&a.setAttribute("gap",24),(o=Jt.utils.xml.createElement("field",null,e[s])).setAttribute("name","VAR");r=Jt.utils.xml.createTextNode(e[s]);o.appendChild(r),a.appendChild(o),n.push(a)}}return n},generateUniqueName:function(t){var e=te.allVariables(t),n="";if(e.length)for(var i=1,s="ijkmnopqrstuvwxyzabcdefgh",r=0,a=s.charAt(r);!n;){for(var o=!1,l=0;l<e.length;l++)if(e[l].toLowerCase()==a){o=!0;break}o?(25==++r&&(r=0,i++),a=s.charAt(r),i>1&&(a+=i)):n=a}else n="i";return n}},ee=te;
/**
* @license
* Visual Blocks Editor
*
* Copyright 2012 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class ne{constructor(t,e){if(this.variablePrefix_=e||"",this.reservedDict_=Object.create(null),t)for(var n=t.split(","),i=0;i<n.length;i++)this.reservedDict_[n[i]]=!0;this.reset()}static equals(t,e){return t.toLowerCase()==e.toLowerCase()}reset(){this.db_=Object.create(null),this.dbReverse_=Object.create(null),this.variableMap_=null}setVariableMap(t){this.variableMap_=t}getNameForUserVariable_(t){if(!this.variableMap_)return null;var e=this.variableMap_.getVariableById(t);return e?e.name:null}getName(t,e){if(e==ee.NAME_TYPE){var n=this.getNameForUserVariable_(t);n&&(t=n)}var i=t.toLowerCase()+"_"+e,s=e==ee.NAME_TYPE||e==ne.DEVELOPER_VARIABLE_TYPE?this.variablePrefix_:"";if(i in this.db_)return s+this.db_[i];var r=this.getDistinctName(t,e);return this.db_[i]=r.substr(s.length),r}getDistinctName(t,e){for(var n=this.safeName_(t),i="";this.dbReverse_[n+i]||n+i in this.reservedDict_;)i=i?i+1:2;return n+=i,this.dbReverse_[n]=!0,(e==ee.NAME_TYPE||e==ne.DEVELOPER_VARIABLE_TYPE?this.variablePrefix_:"")+n}safeName_(t){return t?(t=encodeURI(t.replace(/ /g,"_")).replace(/[^,\w]/g,"_"),-1!="0123456789".indexOf(t[0])&&(t="my_"+t)):t="unnamed",t}}ne.DEVELOPER_VARIABLE_TYPE="DEVELOPER_VARIABLE";const ie=ne,se=330,re={init:function(){this.setColour(se),this.appendDummyInput().appendField(new Jt.FieldTextInput(""),"VAR"),this.setOutput(!0),this.setTooltip(Jt.Msg.VARIABLES_GET_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){ie.equals(t,this.getFieldValue("VAR"))&&this.setFieldValue(e,"VAR")}},ae={init:function(){this.setColour(se),this.appendValueInput("VALUE").appendField(new Jt.FieldTextInput(""),"VAR").appendField(Jt.Msg.MIXLY_VALUE2),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.VARIABLES_SET_TOOLTIP)},getVars:function(){var t=this.getFieldValue("VAR");return null==t?[]:t.split(",")},renameVar:function(t,e){ie.equals(t,this.getFieldValue("VAR"))&&this.setFieldValue(e,"VAR")}},oe={init:function(){this.setColour(se);var t=[[Jt.Msg.LANG_MATH_INT,"int"],[Jt.Msg.LANG_MATH_FLOAT,"float"],[Jt.Msg.LANG_MATH_BOOLEAN,"bool"],[Jt.Msg.LANG_MATH_STRING,"str"],[Jt.Msg.MIXLY_MICROBIT_TYPE_LIST,"list"],[Jt.Msg.MIXLY_MICROBIT_TYPE_TUPLE,"tuple"],[Jt.Msg.MIXLY_MICROBIT_TYPE_DICT,"dict"],[Jt.Msg.blockpy_SET_CREATE_WITH_CONTAINER_TITLE_ADD,"set"],[Jt.Msg.LANG_MATH_BYTE,"bytes"]];this.appendValueInput("MYVALUE").appendField(new Jt.FieldDropdown(t),"OP"),this.setOutput(!0)}},le={init:function(){this.setColour(se),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_PYTHON_GLOBAL).setCheck("var"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip(Jt.Msg.TEXT_PRINT_TOOLTIP)}},ue={init:function(){this.setColour(se),this.appendValueInput("DATA").appendField(Jt.Msg.MICROBIT_PYTHON_TYPE),this.setOutput(!0),this.setTooltip(Jt.Msg.MICROBIT_PYTHON_TYPE)}},he={init:function(){this.setColour(se),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_CONTORL_GET_TYPE).appendField(new Jt.FieldDropdown([[Jt.Msg.LANG_MATH_INT,"int"],[Jt.Msg.MIXLY_MICROBIT_TYPE_FLOAT,"float"],[Jt.Msg.MIXLY_MICROBIT_TYPE_STRING,"str"],[Jt.Msg.MIXLY_MICROBIT_TYPE_LIST,"list"],[Jt.Msg.MIXLY_MICROBIT_TYPE_TUPLE,"tuple"],[Jt.Msg.MIXLY_MICROBIT_TYPE_DICT,"dict"],[Jt.Msg.blockpy_SET_CREATE_WITH_CONTAINER_TITLE_ADD,"set"],[Jt.Msg.LANG_MATH_BYTE,"bytes"],[Jt.Msg.LOGIC_NULL,"type(None)"]]),"type"),this.setInputsInline(!0),this.setOutput(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("type");return Jt.Msg.MICROBIT_controls_TypeLists+{int:Jt.Msg.LANG_MATH_INT,float:Jt.Msg.MIXLY_MICROBIT_TYPE_FLOAT,str:Jt.Msg.MIXLY_MICROBIT_TYPE_STRING,list:Jt.Msg.MIXLY_MICROBIT_TYPE_LIST,tuple:Jt.Msg.MIXLY_MICROBIT_TYPE_TUPLE,dict:Jt.Msg.MIXLY_MICROBIT_TYPE_DICT,set:Jt.Msg.blockpy_SET_CREATE_WITH_CONTAINER_TITLE_ADD,image:Jt.Msg.MIXLY_MICROBIT_IMAGE,bytes:Jt.Msg.LANG_MATH_BYTE,NoneType:Jt.Msg.LOGIC_NULL}[e]}))}},pe={init:function(){this.setColour(se),this.itemCount_=2,this.updateShape_(),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,"List"),this.setMutator(new Jt.icons.MutatorIcon(["lists_zip_item"],this)),this.setTooltip(Jt.Msg.MIXLY_PYTHON_LISTS_ZIP_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("lists_zip_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("lists_zip_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("ADD"+t);)this.removeInput("ADD"+t),t++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(Jt.Msg.MIXLY_PYTHON_LISTS_ZIP);else for(t=0;t<this.itemCount_;t++){var e=this.appendValueInput("ADD"+t);0==t&&e.appendField(Jt.Msg.MIXLY_PYTHON_LISTS_ZIP)}}},ce={init:function(){this.setColour(se),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_LISTS_ZIP),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.MIXLY_MIXPY_INOUT_PRINT_MANY_CONTAINER_TOOLTIP),this.contextMenu=!1}},de={init:function(){this.setColour(se),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_LISTS_ZIP_ITEM),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_LISTS_ZIP_ITEM_TOOLTIP),this.contextMenu=!1}},fe={init:function(){this.setColour(se),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_VARIABLE_UNPACK).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_PYTHON_LISTS_ZIP_ITEM,"*"],[Jt.Msg.MIXLY_MICROBIT_TYPE_DICT,"**"]]),"TYPE"),this.setTooltip(""),this.setOutput(!0)}},me=120,ge={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_NAME_MAIN),this.appendStatementInput("DO").appendField(""),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_CONTROL_SETUP)}},_e={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_SETUP),this.appendStatementInput("DO").appendField(""),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_CONTROL_SETUP)}},Te={init:function(){var t=[[Jt.Msg.MIXLY_mSecond,"delay"],[Jt.Msg.MIXLY_uSecond,"delayMicroseconds"]];this.setColour(me),this.appendValueInput("DELAY_TIME",Number).appendField(Jt.Msg.MIXLY_DELAY).appendField(new Jt.FieldDropdown(t),"UNIT").setCheck(Number),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_CONTROL_DELAY),this.setHelpUrl("https://mixly.readthedocs.io/zh_CN/latest/arduino/03.Control.html#id9"),this.wiki={"zh-hans":{page:["Arduino AVR","控制","延时"]}}}},ye={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_CONTROL_END_PROGRAM),this.setPreviousStatement(!0),this.setTooltip(Jt.Msg.MIXLY_MIXPY_CONTROL_END_TOOLTIP)}},Ie={init:function(){this.setColour(me),this.appendValueInput("IF0").setCheck([Boolean,Number]).appendField(Jt.Msg.CONTROLS_IF_MSG_IF),this.appendStatementInput("DO0").appendField(Jt.Msg.CONTROLS_IF_MSG_THEN),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setHelpUrl("https://mixly.readthedocs.io/zh_CN/latest/arduino/03.Control.html#if"),this.setMutator(new Jt.icons.MutatorIcon(["controls_if_elseif","controls_if_else"],this));var t=this;this.setTooltip((function(){return t.elseifCount_||t.elseCount_?!t.elseifCount_&&t.elseCount_?Jt.Msg.CONTROLS_IF_TOOLTIP_2:t.elseifCount_&&!t.elseCount_?Jt.Msg.CONTROLS_IF_TOOLTIP_3:t.elseifCount_&&t.elseCount_?Jt.Msg.CONTROLS_IF_TOOLTIP_4:"":Jt.Msg.CONTROLS_IF_TOOLTIP_1})),this.elseifCount_=0,this.elseCount_=0},mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var t=document.createElement("mutation");return this.elseifCount_&&t.setAttribute("elseif",this.elseifCount_),this.elseCount_&&t.setAttribute("else",1),t},domToMutation:function(t){var e=this,n=[],i=[];this.elseCount_&&this.removeInput("ELSE");for(var s=this.elseifCount_;s>0;s--)e.getInputTargetBlock("IF"+s)&&e.getInputTargetBlock("IF"+s).previousConnection?n[s]=e.getInputTargetBlock("IF"+s).previousConnection:n[s]=null,this.removeInput("IF"+s),e.getInputTargetBlock("DO"+s)&&e.getInputTargetBlock("DO"+s).previousConnection?i[s]=e.getInputTargetBlock("DO"+s).previousConnection:i[s]=null,this.removeInput("DO"+s);this.elseifCount_=parseInt(t.getAttribute("elseif"),10),this.elseCount_=parseInt(t.getAttribute("else"),10);for(s=1;s<=this.elseifCount_;s++)this.appendValueInput("IF"+s).setCheck([Boolean,Number]).appendField(Jt.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+s).appendField(Jt.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(Jt.Msg.CONTROLS_IF_MSG_ELSE);for(s=n.length-2;s>0;s--)n[s]&&n[s].reconnect(this,"IF"+s);for(s=i.length-2;s>0;s--)i[s]&&i[s].reconnect(this,"DO"+s)},decompose:function(t){var e=t.newBlock("controls_if_if");e.initSvg();for(var n=e.getInput("STACK").connection,i=1;i<=this.elseifCount_;i++){var s=t.newBlock("controls_if_elseif");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}if(this.elseCount_){var r=t.newBlock("controls_if_else");r.initSvg(),n.connect(r.previousConnection)}return e},compose:function(t){this.elseCount_&&this.removeInput("ELSE"),this.elseCount_=0;for(var e=this.elseifCount_;e>0;e--)this.removeInput("IF"+e),this.removeInput("DO"+e);this.elseifCount_=0;for(var n=t.getInputTargetBlock("STACK"),i=[null],s=[null],r=null;n;){switch(n.type){case"controls_if_elseif":this.elseifCount_++,i.push(n.valueConnection_),s.push(n.statementConnection_);break;case"controls_if_else":this.elseCount_++,r=n.statementConnection_;break;default:throw Error("Unknown block type: "+n.type)}n=n.nextConnection&&n.nextConnection.targetBlock()}this.updateShape_(),this.reconnectChildBlocks_(i,s,r)},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=1;e;){switch(e.type){case"controls_if_elseif":var i=this.getInput("IF"+n),s=this.getInput("DO"+n);e.valueConnection_=i&&i.connection.targetConnection,e.statementConnection_=s&&s.connection.targetConnection,n++;break;case"controls_if_else":s=this.getInput("ELSE");e.statementConnection_=s&&s.connection.targetConnection;break;default:throw"Unknown block type."}e=e.nextConnection&&e.nextConnection.targetBlock()}},rebuildShape_:function(){var t=[null],e=[null],n=null;this.getInput("ELSE")&&(n=this.getInput("ELSE").connection.targetConnection);for(var i=1;this.getInput("IF"+i);){var s=this.getInput("IF"+i),r=this.getInput("DO"+i);console.log(s.connection.targetConnection),t.push(s.connection.targetConnection),e.push(r.connection.targetConnection),i++}this.updateShape_(),this.reconnectChildBlocks_(t,e,n)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var t=1;this.getInput("IF"+t);)this.removeInput("IF"+t),this.removeInput("DO"+t),t++;for(t=1;t<=this.elseifCount_;t++)this.appendValueInput("IF"+t).setCheck([Number,Boolean]).appendField(Jt.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+t).appendField(Jt.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(Jt.Msg.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(t,e,n){for(var i=1;i<=this.elseifCount_;i++)t[i]&&t[i].reconnect(this,"IF"+i),e[i]&&e[i].reconnect(this,"DO"+i);n&&n.reconnect(this,"ELSE")}},Ee={init:function(){this.setColour(me),this.appendValueInput("FROM").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.PYTHON_RANGE).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_FROM),this.appendValueInput("TO").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_TO),this.appendValueInput("STEP").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.PYTHON_RANGE_STEP),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_RANGE_TOOLTIP)}},be={init:function(){this.setColour(me),this.appendValueInput("LIST").setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.CONTROLS_FOREACH_INPUT),this.appendValueInput("VAR").appendField(Jt.Msg.CONTROLS_FOREACH_INPUT_ITEM),this.appendStatementInput("DO").appendField(Jt.Msg.MIXLY_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip((function(){return Jt.Msg.CONTROLS_FOR_TOOLTIP.replace("“%1”","")}))},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},ve={init:function(){this.setColour(me),this.appendValueInput("BOOL").setCheck([Boolean,Number]).appendField(Jt.Msg.MIXLY_MICROBIT_JS_CURRENT).appendField(new Jt.FieldDropdown(this.OPERATORS),"MODE"),this.appendStatementInput("DO").appendField(Jt.Msg.LANG_CONTROLS_WHILEUNTIL_TITLE_REPEAT+Jt.Msg.MIXLY_DO),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE");return{WHILE:Jt.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE,UNTIL:Jt.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}[e]}))}},we={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_TRY),this.appendStatementInput("try"),this.appendValueInput("IF1").appendField(Jt.Msg.MIXLY_PYTHON_EXCEPT),this.appendStatementInput("DO1").appendField(""),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["controls_except","controls_finally"],this)),this.setTooltip(Jt.Msg.MIXLY_MIXPY_CONTROL_TRY_TOOLTIP),this.elseifCount_=1,this.elseCount_=0},mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var t=document.createElement("mutation");return this.elseifCount_&&t.setAttribute("elseif",this.elseifCount_),this.elseCount_&&t.setAttribute("else",1),t},domToMutation:function(t){var e=this,n=[],i=[];this.elseCount_&&this.removeInput("ELSE");for(var s=this.elseifCount_;s>0;s--)e.getInputTargetBlock("IF"+s)&&e.getInputTargetBlock("IF"+s).previousConnection?n[s]=e.getInputTargetBlock("IF"+s).previousConnection:n[s]=null,this.removeInput("IF"+s),e.getInputTargetBlock("DO"+s)&&e.getInputTargetBlock("DO"+s).previousConnection?i[s]=e.getInputTargetBlock("DO"+s).previousConnection:i[s]=null,this.removeInput("DO"+s);this.elseifCount_=parseInt(t.getAttribute("elseif"),10),this.elseCount_=parseInt(t.getAttribute("else"),10);for(s=1;s<=this.elseifCount_;s++)this.appendValueInput("IF"+s).setCheck([Boolean,Number]).appendField(Jt.Msg.MIXLY_PYTHON_EXCEPT),this.appendStatementInput("DO"+s).appendField("");this.elseCount_&&this.appendStatementInput("ELSE").appendField(Jt.Msg.MIXLY_PYTHON_FINALLY);for(s=n.length-2;s>0;s--)n[s]&&n[s].reconnect(this,"IF"+s);for(s=i.length-2;s>0;s--)i[s]&&i[s].reconnect(this,"DO"+s)},decompose:function(t){var e=t.newBlock("controls_try");e.initSvg();for(var n=e.getInput("STACK").connection,i=1;i<=this.elseifCount_;i++){var s=t.newBlock("controls_except");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}if(this.elseCount_){var r=t.newBlock("controls_finally");r.initSvg(),n.connect(r.previousConnection)}return e},compose:function(t){this.elseCount_&&this.removeInput("ELSE"),this.elseCount_=0;for(var e=this.elseifCount_;e>0;e--)this.removeInput("IF"+e),this.removeInput("DO"+e);this.elseifCount_=0;for(var n=t.getInputTargetBlock("STACK"),i=[null],s=[null],r=null;n;){switch(n.type){case"controls_except":this.elseifCount_++,i.push(n.valueConnection_),s.push(n.statementConnection_);break;case"controls_finally":this.elseCount_++,r=n.statementConnection_;break;default:throw Error("Unknown block type: "+n.type)}n=n.nextConnection&&n.nextConnection.targetBlock()}this.updateShape_(),this.reconnectChildBlocks_(i,s,r)},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=1;e;){switch(e.type){case"controls_except":var i=this.getInput("IF"+n),s=this.getInput("DO"+n);e.valueConnection_=i&&i.connection.targetConnection,e.statementConnection_=s&&s.connection.targetConnection,n++;break;case"controls_finally":s=this.getInput("ELSE");e.statementConnection_=s&&s.connection.targetConnection;break;default:throw"Unknown block type."}e=e.nextConnection&&e.nextConnection.targetBlock()}},rebuildShape_:function(){var t=[null],e=[null],n=null;this.getInput("ELSE")&&(n=this.getInput("ELSE").connection.targetConnection);for(var i=1;this.getInput("IF"+i);){var s=this.getInput("IF"+i),r=this.getInput("DO"+i);console.log(s.connection.targetConnection),t.push(s.connection.targetConnection),e.push(r.connection.targetConnection),i++}this.updateShape_(),this.reconnectChildBlocks_(t,e,n)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var t=1;this.getInput("IF"+t);)this.removeInput("IF"+t),this.removeInput("DO"+t),t++;for(t=1;t<=this.elseifCount_;t++)this.appendValueInput("IF"+t).setCheck([Number,Boolean]).appendField(Jt.Msg.MIXLY_PYTHON_EXCEPT),this.appendStatementInput("DO"+t).appendField("");this.elseCount_&&this.appendStatementInput("ELSE").appendField(Jt.Msg.MIXLY_PYTHON_FINALLY)},reconnectChildBlocks_:function(t,e,n){for(var i=1;i<=this.elseifCount_;i++)t[i]&&t[i].reconnect(this,"IF"+i),e[i]&&e[i].reconnect(this,"DO"+i);n&&n.reconnect(this,"ELSE")}},Se={init:function(){this.setColour(me);var t=new Jt.FieldDropdown(this.OPERATORS);this.appendDummyInput().appendField(t,"FLOW").appendField(Jt.Msg.LANG_CONTROLS_FLOW_STATEMENTS_INPUT_OFLOOP),this.setPreviousStatement(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_FLOW_STATEMENTS_TOOLTIP);var e=this;this.setTooltip((function(){var t=e.getFieldValue("FLOW");return{BREAK:Jt.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK,CONTINUE:Jt.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}[t]}))},onchange:function(){if(this.workspace){var t=!1,e=this;do{if("controls_repeat"==e.type||"controls_for"==e.type||"controls_forEach"==e.type||"controls_repeat_ext"==e.type||"controls_whileUntil"==e.type||"do_while"==e.type){t=!0;break}e=e.getSurroundParent()}while(e);t?this.setWarningText(null):this.setWarningText(Jt.Msg.LANG_CONTROLS_FLOW_STATEMENTS_WARNING)}}},xe={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_WITH).appendField(new Jt.FieldTextInput("i"),"VAR"),this.appendValueInput("FROM").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_FROM),this.appendValueInput("TO").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_TO),this.appendValueInput("STEP").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_STEP),this.appendStatementInput("DO").appendField(Jt.Msg.MIXLY_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0);var t=this;this.setTooltip((function(){return Jt.Msg.CONTROLS_FOR_TOOLTIP.replace("%1",t.getFieldValue("VAR"))}))},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Re={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_WITH).appendField(new Jt.FieldTextInput("i"),"VAR"),this.appendValueInput("FROM").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_FROM),this.appendValueInput("TO").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_TO),this.appendValueInput("STEP").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_STEP),this.appendStatementInput("DO").appendField(Jt.Msg.MIXLY_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0);var t=this;this.setTooltip((function(){return Jt.Msg.MIXLY_PYTHON_CONTROLS_FOR_RANGE_TOOLTIP.replace("%1",t.getFieldValue("VAR"))}))},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}};ve.OPERATORS=[[Jt.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_WHILE,"WHILE"],[Jt.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL,"UNTIL"]],Se.OPERATORS=[[Jt.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK,"BREAK"],[Jt.Msg.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE,"CONTINUE"]];const Oe={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.CONTROLS_IF_IF_TITLE_IF),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.CONTROLS_IF_IF_TOOLTIP),this.contextMenu=!1}},Ae={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.CONTROLS_IF_ELSEIF_TOOLTIP),this.contextMenu=!1}},Me={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.CONTROLS_IF_ELSE_TITLE_ELSE),this.setPreviousStatement(!0),this.setTooltip(Jt.Msg.CONTROLS_IF_ELSE_TOOLTIP),this.contextMenu=!1}},Ce={init:function(){this.setColour(me),this.appendDummyInput().appendField("try"),this.appendStatementInput("STACK"),this.setPreviousStatement(!1),this.setNextStatement(!1),this.contextMenu=!1}},Ne={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_EXCEPT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.contextMenu=!1,this.setTooltip(Jt.Msg.MIXLY_MIXPY_CONTROL_EXCEPT_TOOLTIP)}},ke={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_FINALLY),this.setPreviousStatement(!0),this.contextMenu=!1,this.setTooltip(Jt.Msg.MIXLY_MIXPY_CONTROL_FINALLY_TOOLTIP)}},De={init:function(){this.jsonInit({message0:Jt.Msg.CONTROLS_REPEAT_TITLE,args0:[{type:"input_value",name:"TIMES"}],previousStatement:null,nextStatement:null,colour:me,tooltip:Jt.Msg.CONTROLS_REPEAT_TOOLTIP,helpUrl:Jt.Msg.CONTROLS_REPEAT_HELPURL}),this.appendStatementInput("DO")}},Le={init:function(){this.setColour(me),this.appendValueInput("BOOL").appendField("lambda"),this.appendStatementInput("DO").appendField(Jt.Msg.MIXLY_STAT),this.setOutput(!0)}},Fe={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_PASS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_PASS_TOOLTIP)}},Pe={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_START),this.appendValueInput("callback").appendField(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_USE),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_PARAMS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_TOOLTIP)}},$e={init:function(){this.appendDummyInput().appendField(Jt.Msg.CONTROLS_REPEAT_TITLE_REPEAT+Jt.Msg.MIXLY_DO),this.appendStatementInput("input_data").setCheck(null),this.appendValueInput("select_data").setCheck(null).appendField(Jt.Msg.CONTROLS_OPERATOR_UNTIL).appendField(new Jt.FieldDropdown([[Jt.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_WHILE,"true"],[Jt.Msg.LANG_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL,"false"]]),"type"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(me),this.setTooltip("do-while loop"),this.setHelpUrl("")}},Be={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_OP_GARBAGE_COLLECT),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ve={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_GET_MEM_ALLOC),this.setOutput(!0)}},Ue={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_GET_MEM_FREE),this.setOutput(!0)}},Ye={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_GET+Jt.Msg.MIXLY_DEVICE+"ID"),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.PROCEDURES_DEFRETURN_RETURN+Jt.Msg.MIXLY_GET_UNIQUE_IDEN)}},Ge={init:function(){this.setColour(me),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_RTC_TIMESTAMP),this.appendDummyInput().appendField(Jt.Msg.MIXLY_TIMESTAMP_TO_DATA),this.setInputsInline(!0),this.setOutput(!0,Number)}},He={init:function(){this.setColour(me),this.appendDummyInput().appendField(Jt.Msg.MIXLY_GET_UNIQUE_IDEN),this.setOutput(!0)}},We=230;Jt.FieldTextInput.math_number_validator=function(t){return String(t)},Jt.FieldTextInput.math_number_validator_include_blank=function(t){if(""===t)return"";return/^-?(0X|0x|0O|0o|0B|0b)?[a-fA-F0-9]{1,}(\.[a-fA-F0-9]+)?$/.test(t)?String(t):null};const ze={init:function(){this.setColour(We),this.appendDummyInput().appendField(new Jt.FieldTextInput("0",Jt.FieldTextInput.math_number_validator),"NUM"),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MATH_NUMBER_TOOLTIP)}},Xe={init:function(){this.setColour(We);this.appendDummyInput("").appendField(Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT).appendField(new Jt.FieldDropdown([["π","pi"],["e","e"]]),"CONSTANT"),this.setOutput(!0,Number);var t=this;this.setTooltip((function(){var e=t.getFieldValue("CONSTANT");return{pi:Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT_PI_TOOLTIP,e:Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT_E_TOOLTIP}[e]}))}},je={init:function(){this.setColour(We);this.appendDummyInput("").appendField(Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT).appendField(new Jt.FieldDropdown([["π","pi"],["e","e"]]),"CONSTANT"),this.setOutput(!0,Number);var t=this;this.setTooltip((function(){var e=t.getFieldValue("CONSTANT");return{pi:Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT_PI_MP_TOOLTIP,e:Jt.Msg.MIXLY_PYTHON_MATH_CONSTANT_E_MP_TOOLTIP}[e]}))}},qe={init:function(){this.setColour(We),this.setOutput(!0),this.appendValueInput("A"),this.appendValueInput("B").appendField(new Jt.FieldDropdown([["+","ADD"],["-","MINUS"],["×","MULTIPLY"],["÷","DIVIDE"],["%","QUYU"],["//","ZHENGCHU"],["**","POWER"]]),"OP"),this.setInputsInline(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("OP");return{ADD:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_ADD,MINUS:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS,MULTIPLY:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY,DIVIDE:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,QUYU:Jt.Msg.MATH_MODULO_TOOLTIP,ZHENGCHU:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,POWER:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_POWER}[e]}))}},Ke={init:function(){this.setColour(We),this.setPreviousStatement(!0),this.setNextStatement(!0),this.appendValueInput("A"),this.appendValueInput("B").appendField(new Jt.FieldDropdown([["+=","ADD"],["-=","MINUS"],["×=","MULTIPLY"],["÷=","DIVIDE"],["%=","QUYU"],["//=","ZHENGCHU"],["**=","POWER"]]),"OP"),this.setInputsInline(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("OP");return{ADD:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_ADD,MINUS:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS,MULTIPLY:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY,DIVIDE:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,QUYU:Jt.Msg.MATH_MODULO_TOOLTIP,ZHENGCHU:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,POWER:Jt.Msg.MATH_ARITHMETIC_TOOLTIP_POWER}[e]}))}},Qe={init:function(){this.setColour(We),this.setOutput(!0,Number),this.appendValueInput("A").setCheck(Number),this.appendValueInput("B").setCheck(Number).appendField(new Jt.FieldDropdown([["&","&"],["|","|"],[">>",">>"],["<<","<<"]]),"OP"),this.setInputsInline(!0),this.setTooltip("位运算")}},Je={init:function(){this.setColour(We),this.setOutput(!0,Number),this.appendValueInput("NUM").setCheck(Number).appendField(new Jt.FieldDropdown([["sin","SIN"],["cos","COS"],["tan","TAN"],["asin","ASIN"],["acos","ACOS"],["atan","ATAN"],["-","-"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]]),"OP");var t=this;this.setTooltip((function(){var e=t.getFieldValue("OP");return{SIN:Jt.Msg.MATH_TRIG_TOOLTIP_SIN,COS:Jt.Msg.MATH_TRIG_TOOLTIP_COS,TAN:Jt.Msg.MATH_TRIG_TOOLTIP_TAN,ASIN:Jt.Msg.MATH_TRIG_TOOLTIP_ASIN,ACOS:Jt.Msg.MATH_TRIG_TOOLTIP_ACOS,ATAN:Jt.Msg.MATH_TRIG_TOOLTIP_ATAN,LN:Jt.Msg.MATH_SINGLE_TOOLTIP_LN}[e]}))}},Ze={init:function(){var t=[[Jt.Msg.MATH_BIN,"bin"],[Jt.Msg.MATH_OCT,"oct"],[Jt.Msg.MATH_HEX,"hex"]];this.setColour(We),this.setOutput(!0,String),this.appendValueInput("NUM").setCheck(Number).appendField(new Jt.FieldDropdown(t),"OP");var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{bin:Jt.Msg.MATH_DEC_TOOLTIP_BIN,oct:Jt.Msg.MATH_DEC_TOOLTIP_OCT,hex:Jt.Msg.MATH_DEC_TOOLTIP_HEX}[t]}))}},tn={init:function(){var t=[[Jt.Msg.LANG_MATH_TO_ROUND,"round"],[Jt.Msg.LANG_MATH_TO_CEIL,"ceil"],[Jt.Msg.LANG_MATH_TO_FLOOR,"floor"],[Jt.Msg.MATH_ABS,"fabs"],[Jt.Msg.MATH_SQRT,"sqrt"]];this.setColour(We),this.appendValueInput("A").setCheck(Number).appendField(new Jt.FieldDropdown(t),"OP"),this.setOutput(!0,Number);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{sqrt:Jt.Msg.MATH_SINGLE_TOOLTIP_ROOT,fabs:Jt.Msg.MATH_SINGLE_TOOLTIP_ABS,sq:Jt.Msg.MATH_SINGLE_TOOLTIP_SQ,round:Jt.Msg.MATH_SINGLE_TOOLTIP_ROUND,ceil:Jt.Msg.MATH_SINGLE_TOOLTIP_CEIL,floor:Jt.Msg.MATH_SINGLE_TOOLTIP_FLOOR}[t]}))}},en={init:function(){var t=[[Jt.Msg.MIXLY_MAX,"max"],[Jt.Msg.MIXLY_MIN,"min"]];this.setColour(We),this.appendValueInput("A").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldDropdown(t),"OP").appendField("("),this.appendValueInput("B").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(","),this.appendDummyInput("").setAlign(Jt.inputs.Align.RIGHT).appendField(")"),this.setInputsInline(!0),this.setOutput(!0,Number);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{max:Jt.Msg.MIXLY_TOOLTIP_MATH_MAX,min:Jt.Msg.MIXLY_TOOLTIP_MATH_MIN}[t]}))}},nn={init:function(){var t=[[Jt.Msg.MATH_TWO,"two"],[Jt.Msg.MATH_EIGHT,"eight"],[Jt.Msg.MATH_TEN,"ten"],[Jt.Msg.MATH_SIXTEEN,"sixteen"]];this.setColour(We),this.appendDummyInput("").appendField(Jt.Msg.MATH_BA),this.appendValueInput("NUM").appendField(new Jt.FieldDropdown(t),"OP").appendField(Jt.Msg.MATH_JinZhi).setCheck(Number),this.appendDummyInput("").appendField(Jt.Msg.MATH_ZHW).appendField(new Jt.FieldDropdown(t),"OP2").appendField(Jt.Msg.MATH_JinZhi),this.setFieldValue("ten","OP2"),this.setOutput(!0),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP"),n={two:Jt.Msg.MATH_Before_two,eight:Jt.Msg.MATH_Before_eight,ten:Jt.Msg.MATH_Before_ten,sixteen:Jt.Msg.MATH_Before_sixteen},i=e.getFieldValue("OP2"),s={two:Jt.Msg.MATH_Behind_two,eight:Jt.Msg.MATH_Behind_eight,ten:Jt.Msg.MATH_Behind_ten,sixteen:Jt.Msg.MATH_Behind_sixteen};return n[t]+s[i]}))}},sn={init:function(){var t=[[Jt.Msg.LANG_MATH_INT,"int"],[Jt.Msg.LANG_MATH_FLOAT,"float"]];this.setColour(We),this.setOutput(!0,Number),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_RANDOM).appendField(new Jt.FieldDropdown(t),"TYPE"),this.appendValueInput("FROM").setCheck(Number).appendField(Jt.Msg.LANG_CONTROLS_FOR_INPUT_FROM),this.appendValueInput("TO").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LANG_MATH_RANDOM_INT_INPUT_TO),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("TYPE"),n={int:Jt.Msg.LANG_MATH_INT,float:Jt.Msg.LANG_MATH_FLOAT_RANDOM};return Jt.Msg.MATH_RANDOM_INT_TOOLTIP+n[t]}))}},rn={init:function(){this.setColour(We),this.setOutput(!0,Number),this.appendValueInput("VALUE").setCheck(Number).appendField(Jt.Msg.LANG_MATH_CONSTRAIN_INPUT_CONSTRAIN),this.appendValueInput("LOW").setCheck(Number).appendField(Jt.Msg.LANG_MATH_CONSTRAIN_INPUT_LOW),this.appendValueInput("HIGH").setCheck(Number).appendField(Jt.Msg.LANG_MATH_CONSTRAIN_INPUT_HIGH),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MATH_CONSTRAIN_TOOLTIP)}},an={init:function(){this.setColour(We),this.appendValueInput("NUM",Number).appendField(Jt.Msg.MIXLY_MAP).setCheck(Number),this.appendValueInput("fromLow",Number).appendField(Jt.Msg.MIXLY_MAP_FROM).setCheck(Number),this.appendValueInput("fromHigh",Number).appendField(",").setCheck(Number),this.appendValueInput("toLow",Number).appendField(Jt.Msg.MIXLY_MAP_TO).setCheck(Number),this.appendValueInput("toHigh",Number).appendField(",").setCheck(Number),this.appendDummyInput("").appendField("]"),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_MATH_MAP)}},on={init:function(){this.setColour(We),this.appendDummyInput().appendField(new Jt.FieldTextInput("0",Jt.FieldTextInput.math_number_validator_include_blank),"NUM"),this.setOutput(!0),this.setTooltip(Jt.Msg.MATH_NUMBER_TOOLTIP)}},ln={init:function(){this.setColour(We),this.appendValueInput("NUM").setCheck(Number).appendField(Jt.Msg.LANG_MATH_RANDOM_SEED),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_MATH_RANDOM_SEED)}},un={init:function(){this.setColour(We),this.setOutput(!0,Number),this.appendValueInput("VALUE").setCheck(Number),this.appendValueInput("VAR").setCheck(Number).appendField(Jt.Msg.MATH_ROUND).appendField(Jt.Msg.TEXT_KEEP),this.appendDummyInput().appendField(Jt.Msg.TEXT_DECIMAL),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MATH_ROUND_NEW_TOOLTIP)}},hn={init:function(){var t=[[Jt.Msg.MIXLY_TO_INT,"int"],[Jt.Msg.MIXLY_TO_FLOAT,"float"],[Jt.Msg.MIXLY_TO_BITES,"b"],[Jt.Msg.LANG_MATH_BYTE+Jt.Msg.MIXLY_TO_INT,"bti"]];this.setColour(We),this.appendValueInput("VAR").appendField(new Jt.FieldDropdown(t),"TOWHAT"),this.setOutput(!0,Number);var e=this;this.setTooltip((function(){var t=e.getFieldValue("TOWHAT");return{int:Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOINT,float:Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOFLOAT,b:Jt.Msg.MIXLY_TOOLTIP_TEXT_TOBYTE}[t]}))}},pn={init:function(){var t=[[Jt.Msg.MIXLY_TO_INT,"int"],[Jt.Msg.MIXLY_TO_FLOAT,"float"]];this.setColour(We),this.appendValueInput("VAR").appendField(new Jt.FieldDropdown(t),"TOWHAT"),this.setOutput(!0,Number);var e=this;this.setTooltip((function(){var t=e.getFieldValue("TOWHAT");return{int:Jt.Msg.MIXLY_TOOLTIP_TEXT_TOINT,float:Jt.Msg.MIXLY_TOOLTIP_TEXT_TOFLOAT}[t]}))}},cn=an,dn={init:function(){this.setColour(We),this.appendValueInput("VAR").appendField(Jt.Msg.LANG_MATH_BYTE+Jt.Msg.MIXLY_TO_HEX),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOHEX)}},fn={init:function(){this.setColour(We),this.itemCount_=1,this.setMutator(new Jt.icons.MutatorIcon(["lists_create_with_item"],this)),this.appendDummyInput("DUMMY").appendField(Jt.Msg.MIXLY_PRODUCT+Jt.Msg.MIXLY_GENERATE_CARTESIAN_PRODUCT),this.appendValueInput("REPEAT").appendField(Jt.Msg.MIXLY_EVERY_PER_ELEPER_ELEMENT),this.appendDummyInput().appendField(Jt.Msg.CONTROLS_REPEAT_TITLE_TIMES),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0),this.setTooltip(Jt.Msg.LISTS_CREATE_WITH_PYTHON_TOOLTIP),this.updateShape_()},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("lists_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("lists_create_with_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput(`ADD${i}`).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput(`ADD${n}`);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else{let t=0;for(;this.getInput(`ADD${t}`);)this.removeInput(`ADD${t}`),t++}if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(Jt.Msg.MIXLY_EMPTY_REMINDER);else for(let t=0;t<this.itemCount_;t++)this.appendValueInput(`ADD${t}`),this.moveInputBefore(`ADD${t}`,"REPEAT")},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},mn={init:function(){this.setColour(We),this.setOutput(!0),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_SET_RADIAN),this.appendDummyInput().appendField(Jt.Msg.MIXLY_TRANS_TO_ANGLE),this.setInputsInline(!0)}},gn={init:function(){this.setColour(We),this.setOutput(!0),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_SET_DEGREE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_TRANS_TO_RADIAN),this.setInputsInline(!0)}},_n=160,Tn={init:function(){this.setColour(_n),this.appendDummyInput().appendField(this.newQuote_(!0)).appendField(new Jt.FieldTextInput(""),"TEXT").appendField(this.newQuote_(!1)),this.setOutput(!0,String),this.setTooltip(Jt.Msg.TEXT_TEXT_TOOLTIP)},newQuote_:function(t){if(t==this.RTL)var e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==";else e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC";return new Jt.FieldImage(e,12,12,'"')}},yn={init:function(){this.setColour(_n),this.appendDummyInput().appendField(this.newQuote_(!0)).appendField(new Jt.FieldMultilineInput("Hello\nMixly"),"VALUE").appendField(this.newQuote_(!1)),this.setOutput(!0,String),this.setTooltip(Jt.Msg.TEXT_LINES_TOOLTIP)},newQuote_:function(t){if(t==this.RTL)var e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==";else e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC";return new Jt.FieldImage(e,12,12,'"')}};Jt.FieldTextInput.char_validator=function(t){if(t.length>1&&"\\"===t.charAt(0)){var e=t.charAt(1);if("0"===e||"b"===e||"f"===e||"n"===e||"r"===e||"t"===e||"\\"===e||"'"===e)return String(t).substring(0,2);if("x"===e&&"0"===t.charAt(2)&&"B"===t.charAt(3))return String(t).substring(0,4)}return String(t).substring(0,1)};const In={init:function(){this.setColour(_n),this.appendDummyInput().appendField(this.newQuote_(!0)).appendField(new Jt.FieldTextInput("",Jt.FieldTextInput.char_validator),"TEXT").appendField(this.newQuote_(!1)),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.TEXT_CHAR_TOOLTIP)},newQuote_:function(t){if(1==t)var e="../../media/quote2.png";else e="../../media/quote3.png";return new Jt.FieldImage(e,7,12,'"')}},En={init:function(){this.setColour(_n),this.appendValueInput("A").setCheck([String,Number]),this.appendValueInput("B").setCheck([String,Number]).appendField(Jt.Msg.MIXLY_TEXT_JOIN),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TEXT_JOIN)}},bn={init:function(){this.setColour(_n),this.appendValueInput("VAR").setCheck(Number).appendField(Jt.Msg.MIXLY_TOCHAR),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TEXT_TOCHAR)}},vn={init:function(){this.setColour(_n),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.MIXLY_TOASCII),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TEXT_TOASCII)}},wn={init:function(){this.setColour(_n),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TOSTRING),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOTEXT)}},Sn={init:function(){this.setColour(_n),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_LENGTH),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TEXT_LENGTH)}},xn={init:function(){this.WHERE_OPTIONS=[[Jt.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Jt.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Jt.Msg.TEXT_GET_INDEX_RANDOM+1+Jt.Msg.TEXT_CHARAT2,"RANDOM"]],this.setHelpUrl(Jt.Msg.LISTS_GET_INDEX_HELPURL),this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendValueInput("AT").setCheck(Number),this.appendDummyInput().appendField(Jt.Msg.LISTS_GET_INDEX_GET,"MODE"),Jt.Msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(Jt.Msg.LISTS_GET_INDEX_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.updateAt_(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=t.getFieldValue("WHERE"),i="";switch(e+" "+n){case"GET FROM_START":case"GET FROM_END":i=Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case"GET RANDOM":i=Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case"GET_REMOVE FROM_START":case"GET_REMOVE FROM_END":i=Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case"GET_REMOVE RANDOM":i=Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM}return"FROM_START"!=n&&"FROM_END"!=n||(i+=" "+Jt.Msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",Jt.Msg.ONE_BASED_INDEXING?"#1":"#0")),i}));var e=this;this.setTooltip((function(){var t=e.getFieldValue("WHERE"),n={FROM_START:Jt.Msg.LISTS_GET_INDEX_FROM_START,FROM_END:Jt.Msg.LISTS_GET_INDEX_FROM_END,RANDOM:Jt.Msg.TEXT_GET_INDEX_RANDOM};return Jt.Msg.PROCEDURES_DEFRETURN_RETURN+Jt.Msg.MIXLY_MICROBIT_TYPE_STRING+n[t]+"n"+Jt.Msg.TEXT_CHARAT2}))},mutationToDom:function(){var t=document.createElement("mutation");t.setAttribute("statement",!this.outputConnection);var e=this.getInput("AT").type==Jt.INPUT_VALUE;return t.setAttribute("at",e),t},domToMutation:function(t){var e="true"==t.getAttribute("statement");this.updateStatement_(e),t="false"!=t.getAttribute("at"),this.updateAt_(t)},updateStatement_:function(t){t!=!this.outputConnection&&(this.unplug(!0,!0),t?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(t){this.removeInput("AT"),this.removeInput("ORDINAL",!0),t?(this.appendValueInput("AT").setCheck(Number),Jt.Msg.TEXT_CHARAT2&&this.appendDummyInput("ORDINAL").appendField(Jt.Msg.TEXT_CHARAT2)):this.appendDummyInput("AT");var e=new Jt.FieldDropdown(this.WHERE_OPTIONS,(function(e){var n="FROM_START"==e||"FROM_END"==e;if(n!=t){var i=this.sourceBlock_;return i.updateAt_(n),i.setFieldValue(e,"WHERE"),null}}));this.getInput("AT").appendField(e,"WHERE"),Jt.Msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}},Rn={init:function(){this.setHelpUrl(Jt.Msg.LISTS_GET_INDEX_HELPURL),this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendValueInput("AT").setCheck(Number).appendField(Jt.Msg.LISTS_GET_INDEX_GET+" "+Jt.Msg.LISTS_GET_INDEX_FROM_START),this.appendDummyInput().appendField(Jt.Msg.TEXT_CHARAT2),this.setOutput(!0),this.setTooltip(Jt.Msg.PROCEDURES_DEFRETURN_RETURN+Jt.Msg.MIXLY_MICROBIT_TYPE_STRING+Jt.Msg.LISTS_GET_INDEX_FROM_START+"n"+Jt.Msg.TEXT_CHARAT2)}},On={init:function(){this.setHelpUrl(Jt.Msg.LISTS_GET_INDEX_HELPURL),this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendDummyInput().appendField(Jt.Msg.TEXT_RANDOM_CHAR),this.setOutput(!0),this.setTooltip(Jt.Msg.TEXT_RANDOM_CHAR_TOOLTIP)}},An={init:function(){this.WHERE_OPTIONS_1=[[Jt.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Jt.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Jt.Msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[Jt.Msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[Jt.Msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[Jt.Msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]],this.setHelpUrl(Jt.Msg.LISTS_GET_SUBLIST_HELPURL),this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),this.setInputsInline(!0),this.setOutput(!0,"List"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(Jt.Msg._GET_TEXT_SUBLIST_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation"),e=this.getInput("AT1").type==Jt.INPUT_VALUE;t.setAttribute("at1",e);var n=this.getInput("AT2").type==Jt.INPUT_VALUE;return t.setAttribute("at2",n),t},domToMutation:function(t){var e="true"==t.getAttribute("at1"),n="true"==t.getAttribute("at2");this.updateAt_(1,e),this.updateAt_(2,n)},updateAt_:function(t,e){this.removeInput("AT"+t),this.removeInput("ORDINAL"+t,!0),e?(this.appendValueInput("AT"+t).setCheck(Number),Jt.Msg.TEXT_CHARAT2&&this.appendDummyInput("ORDINAL"+t).appendField(Jt.Msg.TEXT_CHARAT2)):this.appendDummyInput("AT"+t);var n=new Jt.FieldDropdown(this["WHERE_OPTIONS_"+t],(function(n){var i="FROM_START"==n||"FROM_END"==n;if(i!=e){var s=this.sourceBlock_;return s.updateAt_(t,i),s.setFieldValue(n,"WHERE"+t),null}}));this.getInput("AT"+t).appendField(n,"WHERE"+t),1==t&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2"))}},Mn={init:function(){this.setHelpUrl(Jt.Msg.LISTS_GET_SUBLIST_HELPURL),this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendValueInput("AT1").appendField(Jt.Msg.LISTS_GET_INDEX_GET+" "+Jt.Msg.LISTS_GET_INDEX_FROM_START),this.appendValueInput("AT2").appendField(Jt.Msg.LISTS_GET_SUBLIST_END_FROM_START),this.appendDummyInput().appendField(Jt.Msg.TEXT_CHARAT2),this.setInputsInline(!0),this.setOutput(!0,["List",String]),this.setTooltip(Jt.Msg._GET_TEXT_SUBLIST_TOOLTIP)}},Cn={init:function(){var t=[[Jt.Msg.MIXLY_EQUALS,"==="],[Jt.Msg.MIXLY_STARTSWITH,"startswith"],[Jt.Msg.MIXLY_ENDSWITH,"endswith"]];this.setColour(_n),this.appendValueInput("STR1").setCheck(String),this.appendValueInput("STR2").appendField(new Jt.FieldDropdown(t),"DOWHAT").setCheck(String),this.setOutput(!0,[Boolean,Number]),this.setInputsInline(!0)}},Nn={init:function(){this.setColour(_n),this.appendValueInput("STR1").setCheck(String),this.appendValueInput("STR2").appendField(Jt.Msg.MIXLY_COMPARETO).setCheck(String),this.setOutput(!0,Number),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_COMPARETO_HELP)}},kn={init:function(){var t=[[Jt.Msg.TEXT_UPPER,"upper"],[Jt.Msg.TEXT_TITLE,"title"],[Jt.Msg.TEXT_CAPITALIZE,"capitalize"],[Jt.Msg.TEXT_SWAPCASE,"swapcase"],[Jt.Msg.TEXT_LOWER,"lower"]];this.setColour(_n),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET).appendField(new Jt.FieldDropdown(t),"CAPITAL").setCheck(String),this.setOutput(!0,String);var e=this;this.setTooltip((function(){var t=e.getFieldValue("CAPITAL");return{upper:Jt.Msg.MIXLY_MIXPY_TEXT_UPPER_TOOLTIP,title:Jt.Msg.MIXLY_MIXPY_TEXT_TITLE_TOOLTIP,swapcase:Jt.Msg.MIXLY_MIXPY_TEXT_SWAPCASE_TOOLTIP,capitalize:Jt.Msg.MIXLY_MIXPY_TEXT_CAPITALIZE_TOOLTIP,lower:Jt.Msg.MIXLY_MIXPY_TEXT_LOWER_TOOLTIP}[t]}))}},Dn={init:function(){var t=[[Jt.Msg.TEXT_LJUST,"ljust"],[Jt.Msg.TEXT_CENTER,"center"],[Jt.Msg.TEXT_RJUST,"rjust"]];this.setColour(_n),this.appendValueInput("VAR").appendField(new Jt.FieldDropdown(t),"CENTER").setCheck(String),this.appendValueInput("WID").appendField(Jt.Msg.MIXLY_WIDTH).setCheck(Number),this.appendValueInput("Symbol").appendField(Jt.Msg.MIXLY_RECT_Fill).setCheck(String),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TEXT_CENTER_TOOLTIP)}},Ln={init:function(){this.setColour(_n),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET).setCheck(String),this.appendValueInput("STR").appendField(Jt.Msg.MIXLY_MID+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER).setCheck(String),this.appendDummyInput().appendField(Jt.Msg.MIXLY_LIST_INDEX),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TEXT_FIND_TOOLTIP)}},Fn={init:function(){this.setColour(_n),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_PYTHON_TEXT_JOIN_SEQ_USE_STR).setCheck(String),this.appendValueInput("LIST").appendField(Jt.Msg.MIXLY_PYTHON_TEXT_JOIN_SEQ_SEQ).setCheck("List","Tuple","Set","Dict"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_TEXT_JOIN_SEQ_GET_STR),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TEXT_JOIN_SEQ_TOOLTIP)}},Pn={init:function(){this.setColour(_n),this.appendValueInput("VAR").setCheck(String),this.appendValueInput("STR1").appendField(Jt.Msg.MIXLY_MIXPY_REPLACE).setCheck(String),this.appendValueInput("STR2").appendField(Jt.Msg.LISTS_SET_INDEX_INPUT_TO).setCheck(String),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TEXT_REPLACE_TOOLTIP)}},$n={init:function(){this.setColour(_n),this.appendValueInput("VAR"),this.appendValueInput("VAL").appendField(Jt.Msg.LIST_SPLIT_AS),this.appendDummyInput("").appendField(Jt.Msg.LIST_SPLIT),this.setOutput(!0,"List"),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TEXT_SPLIT_TOOLTIP),this.setInputsInline(!0)}},Bn={init:function(){var t=[[Jt.Msg.TEXT_TRIM_BOTH,"strip"],[Jt.Msg.TEXT_TRIM_LEFT,"lstrip"],[Jt.Msg.TEXT_TRIM_RIGHT,"rstrip"]];this.setColour(_n),this.appendValueInput("VAR"),this.appendDummyInput("").appendField(Jt.Msg.TEXT_STRIM),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"TOWHAT"),this.appendDummyInput("").appendField(Jt.Msg.TEXT_BLANK),this.setOutput(!0,String),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("TOWHAT");return{strip:Jt.Msg.TEXT_TRIM_BOTH_TOOLTIP,lstrip:Jt.Msg.TEXT_TRIM_LEFT_TOOLTIP,rstrip:Jt.Msg.TEXT_TRIM_RIGHT_TOOLTIP}[t]}))}},Vn={init:function(){this.setColour(_n),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROPYTHON_FORMAT),this.appendDummyInput("").appendField(new Jt.FieldTextInput("str"),"VAR"),this.itemCount_=1,this.updateShape_(),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setInputsInline(!0),this.setMutator(new Jt.icons.MutatorIcon(["text_create_with_item"],this)),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TEXT_FORMAT_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("text_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("text_create_with_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("ADD"+t);)this.removeInput("ADD"+t),t++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField();else for(t=0;t<this.itemCount_;t++){var e=this.appendValueInput("ADD"+t);0==t&&e.appendField(Jt.Msg.PROCEDURES_BEFORE_PARAMS)}},getVars:function(){if(null!=this.getFieldValue("VAR"))return-1==this.getFieldValue("VAR").indexOf("'")&&-1==this.getFieldValue("VAR").indexOf('"')?[this.getFieldValue("VAR")]:[]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Un={init:function(){this.setColour(_n),this.appendDummyInput().appendField(Jt.Msg.PROCEDURES_MUTATORCONTAINER_TITLE),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.TUPLE_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},Yn={init:function(){this.setColour(_n),this.appendDummyInput().appendField(Jt.Msg.blockpy_SET_VARIABLES_NAME),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.TUPLE_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},Gn=Mn,Hn=Nn,Wn=Rn,zn={init:function(){this.setColour(_n),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROPYTHON_FORMAT),this.appendValueInput("VAR").setCheck(String),this.itemCount_=1,this.updateShape_(),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setInputsInline(!0),this.setMutator(new Jt.icons.MutatorIcon(["text_create_with_item"],this)),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TEXT_FORMAT_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("text_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("text_create_with_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("ADD"+t);)this.removeInput("ADD"+t),t++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField();else for(t=0;t<this.itemCount_;t++){var e=this.appendValueInput("ADD"+t);0==t&&e.appendField(Jt.Msg.PROCEDURES_BEFORE_PARAMS)}}},Xn={init:function(){this.setColour(_n);var t=[[Jt.Msg.MIXPY_TEXT_ENCODE,"encode"],[Jt.Msg.MIXPY_TEXT_DECODE,"decode"]];this.appendDummyInput().appendField(new Jt.FieldDropdown([["ASCII","ASCII"],["gb2312","gb2312"],["gbk","gbk"],["utf-8","utf-8"],["utf-16","utf-16"],["utf-32","utf-32"]]),"CODE").appendField(" "),this.appendValueInput("VAR").appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.LANG_MATH_STRING),this.setOutput(!0,String),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXPY_TEXT_ENCODE_DECODE_TOOLTIP)}},jn={init:function(){this.setColour(_n),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.MIXLY_PYTHON_TEXT_EVAL),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_TEXT_EVAL_RESULT),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TEXT_EVAL_TOOLTIP)}},qn={init:function(){this.setColour(_n),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.MIXLY_PYTHON_OS_SYSTEM),this.setInputsInline(!0),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_OS_SYSTEM_TOOLTIP)}},Kn=260,Qn={init:function(){this.setHelpUrl(Jt.Msg.LISTS_GET_INDEX_HELPURL),this.setColour(Kn),this.appendValueInput("LIST"),this.appendValueInput("AT").setCheck(Number).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET+" "+Jt.Msg.LISTS_GET_INDEX_FROM_START),this.appendDummyInput().appendField(Jt.Msg.TEXT_CHARAT_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM)}},Jn={init:function(){this.setHelpUrl(Jt.Msg.LISTS_GET_SUBLIST_HELPURL),this.setColour(Kn),this.appendValueInput("LIST"),this.appendDummyInput(""),this.appendValueInput("AT1").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET+" "+Jt.Msg.LISTS_GET_INDEX_FROM_START),this.appendValueInput("AT2").appendField(Jt.Msg.TEXT_CHARAT_TAIL+" "+Jt.Msg.LISTS_GET_SUBLIST_END_FROM_START),this.appendDummyInput().appendField(Jt.Msg.TEXT_CHARAT_TAIL),this.setInputsInline(!0),this.setOutput(!0,"List"),this.setTooltip(Jt.Msg.PYTHON_LISTS_GET_SUBLIST_TOOLTIP)}},Zn={init:function(){this.appendValueInput("LIST").setCheck(null),this.appendValueInput("row").setCheck(null).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET+" "+Jt.Msg.DATAFRAME_RAW),this.appendValueInput("col").setCheck(null).appendField(Jt.Msg.DATAFRAME_COLUMN),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(Kn),this.setTooltip(""),this.setHelpUrl("")}},ti={init:function(){this.appendValueInput("LIST").setCheck(null),this.appendValueInput("row_start").setCheck(null).appendField(Jt.Msg.MIXLY_GET+" "+Jt.Msg.DATAFRAME_RAW+" ["),this.appendValueInput("row_end").setCheck(null).appendField(","),this.appendValueInput("col_start").setCheck(null).appendField(") "+Jt.Msg.DATAFRAME_COLUMN+" ["),this.appendValueInput("col_end").setCheck(null).appendField(","),this.appendDummyInput().appendField(") "+Jt.Msg.DICTS_ADD_VALUE),this.setInputsInline(!0),this.setOutput(!0,"List"),this.setColour(Kn),this.setTooltip(""),this.setHelpUrl("")}},ei={init:function(){this.setColour(Kn),this.appendDummyInput("").appendField(new Jt.FieldTextInput("mylist"),"VAR").appendField("[").appendField("]"),this.itemCount_=3,this.updateShape_(),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["lists_create_with_item"],this)),this.setTooltip(Jt.Msg.LISTS_CREATE_WITH_PYTHON_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("lists_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("lists_create_with_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("ADD"+t);)this.removeInput("ADD"+t),t++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(Jt.Msg.LISTS_CREATE_PYTHON_EMPTY_TITLE);else for(t=0;t<this.itemCount_;t++){var e=this.appendValueInput("ADD"+t);0==t&&e.appendField(Jt.Msg.blockpy_LISTS_CREATE_WITH_INPUT_WITH)}},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},ni={init:function(){this.setColour(Kn),this.appendDummyInput("").appendField(new Jt.FieldTextInput("mylist"),"VAR").appendField(" = [").appendField(new Jt.FieldTextInput("0,0,0"),"TEXT").appendField("]"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_LISTS_CREATE_WITH_TEXT2)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},ii={init:function(){this.setColour(Kn),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_TYPE_LIST),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},si={init:function(){this.setColour(Kn),this.appendDummyInput().appendField(Jt.Msg.LISTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},ri={init:function(){this.setColour(Kn),this.appendValueInput("LIST"),this.appendValueInput("AT").setCheck(Number).appendField(Jt.Msg.MIXLY_MICROBIT_LIST_ASSIGN_AT),this.appendValueInput("TO").appendField(Jt.Msg.MIXLY_MICROBIT_JS_LIST_VALUE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.LANG_LISTS_SET_INDEX_TOOLTIP)}},ai={init:function(){this.setColour(Kn),this.TYPE=[[Jt.Msg.MIXLY_blockpy_set_add,"append"],[Jt.Msg.MIXLY_MICROBIT_LIST_EXTEND,"extend"]],this.appendValueInput("LIST").setCheck("List"),this.appendValueInput("DATA").appendField(new Jt.FieldDropdown(this.TYPE),"OP").appendField(Jt.Msg.MIXLY_MICROBIT_LIST_A_ITEM),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROBIT_JS_LIST_TO_END),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("OP");return{append:Jt.Msg.MIXLY_TOOLTIP_LIST_APPEND,extend:Jt.Msg.LISTS_EXTEND_TOOLTIP}[e]}))}},oi={init:function(){this.setColour(Kn),this.appendValueInput("LIST"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET+" "+Jt.Msg.LISTS_GET_INDEX_RANDOM),this.setTooltip(Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM),this.setOutput(!0)}},li={init:function(){this.setColour(Kn),this.appendValueInput("LIST"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET+Jt.Msg.MIXLY_MICROBIT_RANDOM),this.appendDummyInput().appendField(Jt.Msg.LANG_LISTS_GET_INDEX2+Jt.Msg.LISTS_GET_RANDOM_SUBLIST),this.setTooltip(Jt.Msg.LISTS_GET_RANDOM_SUBLIST_TOOLTIP),this.setOutput(!0,"List")}},ui={init:function(){this.setColour(Kn),this.appendValueInput("LIST"),this.appendValueInput("AT").setCheck(Number).appendField(Jt.Msg.MIXLY_MICROBIT_JS_LIST_INSERT_AT),this.appendValueInput("VALUE").appendField(Jt.Msg.MIXLY_MICROBIT_JS_LIST_VALUE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.LANG_LISTS_SET_INDEX_TOOLTIP),this.setTooltip(Jt.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT)}},hi={init:function(){this.setColour(Kn),this.appendValueInput("VAR").setCheck("List"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_JS_LIST_REVERSE),this.setTooltip(Jt.Msg.LANG_LISTS_CLEAR_TOOLTIP),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},pi={init:function(){this.setColour(Kn),this.appendValueInput("VAR"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROPYTHON_CLEAR),this.setTooltip(Jt.Msg.LANG_LISTS_REVERSE_TOOLTIP),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},ci={init:function(){this.setColour(Kn),this.TYPE=[[Jt.Msg.SERIES_INDEX,"del"],[Jt.Msg.MIXLY_MICROBIT_JS_I2C_VALUE,"remove"]],this.appendValueInput("LIST").setCheck("List"),this.appendValueInput("DATA").appendField(Jt.Msg.MIXLY_MIXPY_LISTS_REMOVE).appendField(new Jt.FieldDropdown(this.TYPE),"OP"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("OP");return{del:Jt.Msg.LISTS_SET_INDEX_TOOLTIP_DELETE,remove:Jt.Msg.MIXLY_TOOLTIP_LIST_REMOVE}[e]}))}},di={init:function(){this.setColour(Kn),this.appendValueInput("LIST"),this.appendValueInput("VALUE").appendField(Jt.Msg.MIXLY_MICROBIT_LIST_POP),this.appendDummyInput().appendField(Jt.Msg.TEXT_CHARAT_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM)}},fi={init:function(){var t=[[Jt.Msg.MIXLY_LIST_INDEX,"INDEX"],[Jt.Msg.MIXLY_LIST_COUNT,"COUNT"]];this.setColour(Kn),this.appendValueInput("VAR").setCheck("List"),this.appendValueInput("data").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET).appendField(Jt.Msg.HTML_VALUE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_DE).appendField(new Jt.FieldDropdown(t),"OP"),this.setInputsInline(!0),this.setOutput(!0,Number);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{INDEX:Jt.Msg.MIXLY_TOOLTIP_LIST_FIND_INDEX,COUNT:Jt.Msg.MIXLY_TOOLTIP_LIST_FIND_COUNT}[t]}))}},mi={init:function(){var t=[[Jt.Msg.MIXLY_LIST_LEN,"LEN"],[Jt.Msg.MATH_ONLIST_OPERATOR_SUM,"SUM"],[Jt.Msg.MATH_ONLIST_OPERATOR_MAX,"MAX"],[Jt.Msg.MATH_ONLIST_OPERATOR_MIN,"MIN"],[Jt.Msg.MATH_ONLIST_OPERATOR_AVERAGE,"AVERAGE"],[Jt.Msg.MATH_ONLIST_OPERATOR_MEDIAN,"MEDIAN"],[Jt.Msg.MATH_ONLIST_OPERATOR_MODE,"MODE"],[Jt.Msg.MATH_ONLIST_OPERATOR_STD_DEV,"STD_DEV"]];this.setColour(Kn),this.setOutput(!0,Number),this.appendValueInput("data"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET).appendField(new Jt.FieldDropdown(t),"OP"),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{LEN:Jt.Msg.LISTS_LENGTH_TOOLTIP,SUM:Jt.Msg.MATH_ONLIST_TOOLTIP_SUM,MAX:Jt.Msg.MATH_ONLIST_TOOLTIP_MAX,MIN:Jt.Msg.MATH_ONLIST_TOOLTIP_MIN,AVERAGE:Jt.Msg.MATH_ONLIST_TOOLTIP_AVERAGE,MEDIAN:Jt.Msg.MATH_ONLIST_TOOLTIP_MEDIAN,MODE:Jt.Msg.MATH_ONLIST_TOOLTIP_MODE,STD_DEV:Jt.Msg.MATH_ONLIST_TOOLTIP_STD_DEV}[t]}))}},gi={init:function(){this.jsonInit({args0:[{type:"input_value",name:"LIST",check:"List"},{type:"field_dropdown",name:"TYPE",options:[[Jt.Msg.LISTS_SORT_TYPE_NUMERIC,"NUMERIC"],[Jt.Msg.LISTS_SORT_TYPE_TEXT,"TEXT"],[Jt.Msg.LISTS_SORT_TYPE_IGNORECASE,"IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[[Jt.Msg.LISTS_SORT_ORDER_ASCENDING,"1"],[Jt.Msg.LISTS_SORT_ORDER_DESCENDING,"-1"]]}],message0:Jt.Msg.LISTS_SORT_TITLE,inputsInline:!0,output:"List",colour:Kn,tooltip:Jt.Msg.LISTS_SORT_TOOLTIP,helpUrl:Jt.Msg.LISTS_SORT_HELPURL})}},_i={init:function(){var t=[[Jt.Msg.MIXLY_MICROBIT_TYPE_TUPLE,"tuple"],[Jt.Msg.blockpy_SET_CREATE_WITH_CONTAINER_TITLE_ADD,"set"],[Jt.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD,"array"]];this.setColour(Kn),this.appendValueInput("VAR").setCheck("List"),this.appendDummyInput("").appendField(Jt.Msg.A_TO_B).appendField(new Jt.FieldDropdown(t),"OP");var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{tuple:Jt.Msg.MIXLY_TOOLTIP_CONVERT_LIST_TO_TUPLE,set:Jt.Msg.MIXLY_TOOLTIP_CONVERT_LIST_TO_SET,array:Jt.Msg.MIXLY_TOOLTIP_CONVERT_LIST_TO_ARRAY}[t]})),this.setInputsInline(!0),this.setOutput(!0)}},Ti={init:function(){this.setColour(Kn),this.appendDummyInput("").appendField("[").appendField(new Jt.FieldTextInput("0,0,0"),"CONTENT").appendField("]"),this.setInputsInline(!0),this.setOutput(!0)}},yi={init:function(){this.setColour(Kn),this.itemCount_=3,this.updateShape_(),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,"List"),this.setMutator(new Jt.icons.MutatorIcon(["lists_create_with_item"],this)),this.setTooltip(Jt.Msg.LISTS_CREATE_WITH_PYTHON_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("lists_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("lists_create_with_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("ADD"+t);)this.removeInput("ADD"+t),t++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(Jt.Msg.LISTS_CREATE_PYTHON_EMPTY_TITLE);else for(t=0;t<this.itemCount_;t++){var e=this.appendValueInput("ADD"+t);0==t&&e.appendField(Jt.Msg.blockpy_LISTS_CREATE_WITH_INPUT_WITH)}},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Ii={init:function(){var t=[[Jt.Msg.MIXLY_MICROBIT_TYPE_LIST,"list"],[Jt.Msg.MIXLY_MICROBIT_TYPE_TUPLE,"tuple"],[Jt.Msg.blockpy_SET_CREATE_WITH_CONTAINER_TITLE_ADD,"set"]];this.setColour(Kn),this.appendValueInput("VAR"),this.appendDummyInput("").appendField(Jt.Msg.A_TO_B).appendField(new Jt.FieldDropdown(t),"OP"),this.setInputsInline(!0),this.setOutput(!0)}},Ei={init:function(){this.setColour(Kn),this.appendValueInput("TUP"),this.appendDummyInput("").appendField(Jt.Msg.OBJECT_DELETE),this.setPreviousStatement(!0),this.setNextStatement(!0)}},bi={init:function(){this.setColour(Kn),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TOLIST),this.setOutput(!0,"List"),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOLIST)}},vi=ei,wi=ni,Si=Qn,xi=Jn,Ri=ri,Oi=ui,Ai=ci,Mi=bi,Ci={init:function(){this.setColour(Kn),this.appendValueInput("VAR").appendField(Jt.Msg.blockpy_USE_LIST),this.appendDummyInput().appendField(Jt.Msg.MIXLY_TO_INDEX_SEQUENCE),this.setInputsInline(!0),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_TOTO_INDEX_SEQUENC_TOOLTIP)}},Ni={init:function(){this.setColour(Kn),this.appendDummyInput().appendField(Jt.Msg.blockpy_USE_LIST),this.appendValueInput("LIST"),this.appendValueInput("VALUE").appendField(Jt.Msg.MIXLY_TO_INDEX_SEQUENCE).appendField(Jt.Msg.MIXLY_INDEX+Jt.Msg.MIXLY_STARTSWITH),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_TOTO_INDEX_SEQUENC_TOOLTIP)}},ki={init:function(){this.setColour(Kn),this.appendValueInput("CON"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_MIXGO_MUSIC_SHOW_IN),this.appendValueInput("LIST"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MID),this.setInputsInline(!0),this.setOutput(!0)}},Di=345,Li={init:function(){this.setColour(Di),this.appendDummyInput("").appendField(new Jt.FieldTextInput("mydict"),"VAR").appendField(new Jt.FieldLabel(Jt.Msg.DICTS_CREATE_WITH_INPUT_WITH),"TIP"),this.itemCount_=3,this.updateShape_(),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["dicts_create_with_item"],this)),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("dicts_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("dicts_create_with_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){this.getInput("EMPTY")&&this.removeInput("EMPTY");for(var t=[],e=0;this.getInput("ADD"+e);e++)t.push(this.getFieldValue("KEY"+e)),this.removeInput("ADD"+e);if(0==this.itemCount_)this.getField("TIP").setValue(Jt.Msg.DICTS_CREATE_EMPTY_TITLE);else{this.getField("TIP").setValue(Jt.Msg.DICTS_CREATE_WITH_INPUT_WITH);for(e=0;e<this.itemCount_;e++)this.appendValueInput("ADD"+e).setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldTextInput(t.length>e?t[e]:0==e?'"key"':'"key'+(e+1)+'"'),"KEY"+e).appendField(":")}},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Fi={init:function(){this.setColour(Di),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_TYPE_DICT),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},Pi={init:function(){this.setColour(Di),this.appendDummyInput().appendField(Jt.Msg.DICTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},$i={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.DICT_KEYS),this.setTooltip(Jt.Msg.DICTS_KEYS_TOOLTIP),this.setOutput(!0,"List")}},Bi={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendValueInput("KEY").appendField(Jt.Msg.DICTS_GET_IN),this.appendDummyInput("").appendField(Jt.Msg.DICTS_ADD_VALUE),this.setOutput(!0),this.setTooltip(Jt.Msg.DICTS_GET_TOOLTIP)}},Vi={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendValueInput("KEY").appendField(Jt.Msg.DICTS_GET_IN),this.appendDummyInput("").appendField(Jt.Msg.DICTS_ADD_VALUE),this.appendValueInput("VAR").appendField(Jt.Msg.DICTS_DEFAULT_VALUE),this.setOutput(!0),this.setTooltip(Jt.Msg.DICTS_GET_DEFAULT_TOOLTIP)}},Ui={init:function(){this.setColour(Di),this.appendValueInput("DICT"),this.appendValueInput("KEY").appendField(Jt.Msg.DICTS_ADD),this.appendDummyInput(),this.appendValueInput("VAR").appendField(Jt.Msg.DICTS_ADD_VALUE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_ADD_OR_CHANGE_TOOLTIP)}},Yi={init:function(){this.setColour(Di),this.appendValueInput("DICT"),this.appendValueInput("KEY").appendField(Jt.Msg.DICTS_DELETE_IN),this.appendDummyInput("").appendField(Jt.Msg.DICTS_DELETE_VALUE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_DELETE_TOOLTIP)}},Gi={init:function(){this.setColour(Di),this.appendValueInput("DICT2").setCheck("Dict").appendField(Jt.Msg.MAKE_DICT),this.appendValueInput("DICT").setCheck("Dict").appendField(Jt.Msg.DICT_UPDATE),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MID),this.setTooltip(Jt.Msg.DICTS_UPDATE_TOOLTIP),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Hi={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.DICT_CLEAR),this.setTooltip(Jt.Msg.DICTS_CLEAR_TOOLTIP),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Wi={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.DICT_ITEMS),this.setTooltip(Jt.Msg.DICTS_ITEMS_TOOLTIP),this.setOutput(!0,"List")}},zi={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.DICT_VALUES),this.setTooltip(Jt.Msg.DICTS_VALUES_TOOLTIP),this.setOutput(!0,"List")}},Xi={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_LENGTH),this.setTooltip(Jt.Msg.DICT_LENGTH_TOOLTIP),this.setOutput(!0,Number)}},ji={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.DICT_DELDICT),this.setTooltip(Jt.Msg.DICTS_DEL_TOOLTIP),this.setPreviousStatement(!0),this.setNextStatement(!0)}},qi={init:function(){this.MODE=[[Jt.Msg.DICTS_ADD_OR_CHANGE,"INSERT"],[Jt.Msg.MIXLY_MICROBIT_JS_DELETE_VAR,"DELETE"]],this.setHelpUrl(Jt.Msg.LISTS_GET_SUBLIST_HELPURL),this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("AT2"),this.appendValueInput("KEY"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE).appendField(Jt.Msg.DICTS_ADD_VALUE),this.updateAt_(!0),this.setInputsInline(!0),this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip((function(){var e="";switch(t.getFieldValue("WHERE")){case"INSERT":e=Jt.Msg.DICTS_ADD_TOOLTIP;break;case"DELETE":e=Jt.Msg.DICTS_DELETE_TOOLTIP}return e}))},mutationToDom:function(){var t=document.createElement("mutation"),e=this.getInput("AT2").type==Jt.INPUT_VALUE;return t.setAttribute("at2",e),t},domToMutation:function(t){var e="true"==t.getAttribute("at2");this.updateAt_(e)},updateAt_:function(t){this.removeInput("AT2"),this.removeInput("ORDINAL",!0),t?this.appendValueInput("AT2").setCheck(Number):this.appendDummyInput("AT2");var e=new Jt.FieldDropdown(this.MODE,(function(e){var n="INSERT"==e;if(n!=t){var i=this.sourceBlock_;return i.updateAt_(n),i.setFieldValue(e,"WHERE"),null}}));this.getInput("AT2").appendField(e,"WHERE")}},Ki={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_DICT_POP),this.appendValueInput("KEY"),this.appendDummyInput("").appendField(Jt.Msg.DICTS_ADD_VALUE),this.setTooltip(Jt.Msg.DICT_POP_TOOLTIP),this.setInputsInline(!0),this.setOutput(!0)}},Qi={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendValueInput("KEY").appendField(Jt.Msg.DICTS_SET_DEFAULT),this.appendDummyInput("").appendField(Jt.Msg.DICTS_DEFAULT_VALUE),this.appendValueInput("VAR"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_SETDEFAULT_TOOLTIP)}},Ji={init:function(){this.setColour(Di),this.appendDummyInput("").appendField(new Jt.FieldLabel(Jt.Msg.MIXLY_MICROBIT_TYPE_DICT),"TIP").appendField(" "),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Dict"),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setMutator(new Jt.icons.MutatorIcon(["dicts_create_with_item"],this)),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("dicts_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("dicts_create_with_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){this.getInput("EMPTY")&&this.removeInput("EMPTY");for(var t=[],e=0;this.getInput("ADD"+e);e++)t.push(this.getFieldValue("KEY"+e)),this.removeInput("ADD"+e);if(0==this.itemCount_)this.getField("TIP").setValue(Jt.Msg.LOGIC_NULL+Jt.Msg.MIXLY_MICROBIT_TYPE_DICT);else{this.getField("TIP").setValue(Jt.Msg.MIXLY_MICROBIT_TYPE_DICT);for(e=0;e<this.itemCount_;e++)this.appendValueInput("ADD"+e).setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldTextInput(t.length>e?t[e]:0==e?'"key"':'"key'+(e+1)+'"'),"KEY"+e).appendField(":")}},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Zi={init:function(){this.setColour(Di),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TODICT),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TODICT)}},ts={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TO_JSON),this.setTooltip(Jt.Msg.MIXLY_TO_JSON_TOOLTIP),this.setOutput(!0)}},es={init:function(){this.setColour(Di),this.appendValueInput("VAR"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_CONVERT_TO_JSON),this.setTooltip(Jt.Msg.MIXLY_CONVERT_TO_JSON_TOOLTIP),this.setOutput(!0)}},ns={init:function(){this.setColour(Di),this.appendValueInput("DICT").setCheck("Dict"),this.appendValueInput("VAR1").appendField("key1"),this.appendValueInput("VAR2").appendField("index"),this.appendValueInput("VAR3").appendField("key2"),this.appendValueInput("VAR4").appendField("key3"),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_CONVERT_TO_JSON_TOOLTIP),this.setOutput(!0)}},is={init:function(){this.setColour(Di),this.appendValueInput("DICT"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TO_JSON),this.setTooltip(Jt.Msg.MIXLY_TO_JSON_TOOLTIP),this.setOutput(!0)}},ss=210,rs={init:function(){var t=Jt.RTL?[["=","EQ"],["≠","NEQ"],[">","LT"],["≥","LTE"],["<","GT"],["≤","GTE"]]:[["=","EQ"],["≠","NEQ"],["<","LT"],["≤","LTE"],[">","GT"],["≥","GTE"]];this.setColour(ss),this.setOutput(!0,Boolean),this.appendValueInput("A"),this.appendValueInput("B").appendField(new Jt.FieldDropdown(t),"OP"),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{EQ:Jt.Msg.LOGIC_COMPARE_TOOLTIP_EQ,NEQ:Jt.Msg.LOGIC_COMPARE_TOOLTIP_NEQ,LT:Jt.Msg.LOGIC_COMPARE_TOOLTIP_LT,LTE:Jt.Msg.LOGIC_COMPARE_TOOLTIP_LTE,GT:Jt.Msg.LOGIC_COMPARE_TOOLTIP_GT,GTE:Jt.Msg.LOGIC_COMPARE_TOOLTIP_GTE}[t]})),this.prevBlocks_=[null,null]}},as={init:function(){var t=Jt.RTL?[[">","LT"],["≥","LTE"],["<","GT"],["≤","GTE"]]:[["<","LT"],["≤","LTE"],[">","GT"],["≥","GTE"]],e=Jt.RTL?[[">","LT"],["≥","LTE"],["<","GT"],["≤","GTE"]]:[["<","LT"],["≤","LTE"],[">","GT"],["≥","GTE"]];this.setColour(ss),this.setOutput(!0,Boolean),this.appendValueInput("A"),this.appendValueInput("B").appendField(new Jt.FieldDropdown(t),"OP1"),this.appendValueInput("C").appendField(new Jt.FieldDropdown(e),"OP2"),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_LOGIC_COMPARE_CONTINOUS_TOOLTIP)}},os={init:function(){var t=[[Jt.Msg.LOGIC_OPERATION_AND,"AND"],[Jt.Msg.LOGIC_OPERATION_OR,"OR"],[Jt.Msg.LOGIC_OPERATION_NOR,"NOR"],[Jt.Msg.LOGIC_OPERATION_XOR,"XOR"]];this.setColour(ss),this.setOutput(!0,Boolean),this.appendValueInput("A").setCheck([Boolean,Number]),this.appendValueInput("B").setCheck([Boolean,Number]).appendField(new Jt.FieldDropdown(t),"OP"),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{AND:Jt.Msg.LOGIC_OPERATION_TOOLTIP_AND,OR:Jt.Msg.LOGIC_OPERATION_TOOLTIP_OR,NOR:Jt.Msg.LOGIC_OPERATION_TOOLTIP_NOR,XOR:Jt.Msg.LOGIC_OPERATION_TOOLTIP_XOR}[t]}))}},ls={init:function(){this.setColour(ss),this.setOutput(!0,Boolean),this.appendValueInput("BOOL").setCheck([Number,Boolean]).appendField(Jt.Msg.LOGIC_NEGATE_TITLE),this.setTooltip(Jt.Msg.LOGIC_NEGATE_TOOLTIP)}},us={init:function(){var t=[[Jt.Msg.LOGIC_BOOLEAN_TRUE,"TRUE"],[Jt.Msg.LOGIC_BOOLEAN_FALSE,"FALSE"]];this.setColour(ss),this.setOutput(!0,Boolean),this.appendDummyInput().appendField(new Jt.FieldDropdown(t),"BOOL"),this.setTooltip(Jt.Msg.LOGIC_BOOLEAN_TOOLTIP)}},hs={init:function(){this.setColour(ss),this.setOutput(!0),this.appendDummyInput().appendField(Jt.Msg.LOGIC_NULL),this.setTooltip(Jt.Msg.LOGIC_NULL_TOOLTIP)}},ps={init:function(){this.setColour(ss),this.appendValueInput("A"),this.appendValueInput("B").appendField(Jt.Msg.LOGIC_TERNARY_IF_TRUE),this.appendValueInput("C").appendField(Jt.Msg.LOGIC_TERNARY_IF_FALSE),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_LOGIT_TRUEORFALSE)}},cs={init:function(){var t=[[Jt.Msg.TEXT_APPEND_TO,"in"],[Jt.Msg.MIXLY_PYTHON_LOGIC_IS_NOT_IN,"not in"]];this.setColour(ss),this.appendValueInput("A"),this.appendValueInput("B").setCheck([String,"List"]).appendField(new Jt.FieldDropdown(t),"BOOL"),this.appendDummyInput("").appendField(Jt.Msg.MICROBIT_LOGIC_IS_IN),this.setOutput(!0,Boolean),this.setInputsInline(!0),this.setTooltip(Jt.Msg.IN)}},ds={init:function(){var t=[[Jt.Msg.MIXLY_PYTHON_LOGIC_IS,"is"],[Jt.Msg.MIXLY_PYTHON_LOGIC_IS_NOT,"is not"]];this.setColour(ss),this.appendValueInput("A"),this.appendValueInput("B").appendField(new Jt.FieldDropdown(t),"BOOL"),this.setOutput(!0,Boolean),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_LOGIC_IS_TOOLTIP)}},fs={init:function(){this.setColour(ss),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TOBOOL),this.setOutput(!0,Boolean),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOBOOL)}},ms={init:function(){this.setColour(0),this.appendValueInput("fn").setCheck(String).appendField(Jt.Msg.MIXLY_PYTHON_STORAGE_OPEN_FILE_WITH_OS+"(For Windows)"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0)}},gs={init:function(){this.setColour(0),this.appendValueInput("FILENAME").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,"r"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,"w"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,"rb"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE,"wb"]]),"MODE"),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_AS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=Jt.Msg.MIXLY_USE,i=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE,s=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE,r=Jt.Msg.MIXLY_BELONG;return n+{r:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,w:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,rb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,wb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE}[e]+r+i+s}))},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},_s={init:function(){this.setColour(0),this.appendValueInput("FILENAME").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,"r"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,"w"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,"rb"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE,"wb"]]),"MODE"),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setInputsInline(!0),this.setOutput(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=Jt.Msg.MIXLY_USE,i=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE,s=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE,r=Jt.Msg.MIXLY_BELONG,a=Jt.Msg.PY_STORAGE_FILE_OBJECT;return n+{r:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,w:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,rb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,wb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE}[e]+r+i+s+a}))}},Ts={init:function(){this.setColour(0),this.appendValueInput("FILENAME").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE);this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,"r"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,"w"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,"rb"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE,"wb"]]),"MODE"),this.appendDummyInput().appendField(Jt.Msg.MIXPY_TEXT_ENCODE).appendField(new Jt.FieldDropdown([["ANSI","ANSI"],["gbk","gbk"],["utf-8","utf-8"]]),"CODE"),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setInputsInline(!0),this.setOutput(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=Jt.Msg.MIXLY_USE,i=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MODE,s=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_OPEN_FILE,r=Jt.Msg.MIXLY_BELONG,a=Jt.Msg.PY_STORAGE_FILE_OBJECT;return n+{r:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_READ,w:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_WRITE,rb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_READ,wb:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_BIT_WRITE}[e]+r+i+s+a}))}},ys={init:function(){this.setColour(0),this.appendValueInput("data").setCheck(String).appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_WRITE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE+Jt.Msg.MIXLY_MICROBIT_TYPE_STRING+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_WRITE)}},Is={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck("Variable").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FROM_FILE),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ALL,"read"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ONE_LINE,"readline"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ALL_LINES,"readlines"]]),"MODE"),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,String)}},Es={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck("Variable").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FROM_FILE),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_NO_MORE_THAN_SIZE,"read"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ONE_LINE_NO_MORE_THAN_SIZE,"readline"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ALL_LINES_NO_MORE_THAN_SIZE,"readlines"]]),"MODE"),this.appendValueInput("SIZE").setCheck(Number),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,String);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FROM_FILE,i=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER;return n+{read:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_NO_MORE_THAN_SIZE,readline:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ONE_LINE_NO_MORE_THAN_SIZE,readlines:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ALL_LINES_NO_MORE_THAN_SIZE}[e]+"x"+i}))}},bs={init:function(){this.setColour(0),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FROM_FILE),this.setNextStatement(!0),this.appendValueInput("SIZE").setCheck(Number).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_ONE_LINE_NO_MORE_THAN_SIZE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MICROBIT_PYTHON_TYPE)}},vs={init:function(){this.setColour(0),this.appendValueInput("FILE").appendField(Jt.Msg.HTML_FILE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CAN_WRITE_ORNOT),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,Boolean),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CAN_WRITE_ORNOT1)}},ws={init:function(){this.setColour(0),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILENAME),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET_FILENAME)}},Ss={init:function(){this.setColour(0),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CLOSE_FILE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CLOSE_FILE)}},xs={init:function(){this.setColour(0),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_LIST_ALL_FILES),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,"List"),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_LIST_ALL_FILES)}};Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_DELETE_FILE;const Rs={init:function(){this.setColour(0),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_DELETE_FILE,"remove"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_DELETE_DIRS,"removedirs"]]),"MODE"),this.appendValueInput("FILE").setCheck(String),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_DELETE_FILE)}},Os={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET_FILE_SIZE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_SIZE),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET_FILE_SIZE+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_SIZE)}},As={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_RETURN_FILE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_PRESENT_LOCATION),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_TELL)}},Ms={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck("Variable").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_SET_FILE_POSITION),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CURRENT_POSITION),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_START,"start"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_CURRENT,"current"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_END,"end"]]),"MODE"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_OFFSET),this.appendValueInput("SIZE").setCheck(Number),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE"),n=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_SET_FILE_POSITION+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CURRENT_POSITION,i=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHARACTER,s=Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_OFFSET;return n+" "+{start:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_START,current:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_CURRENT,end:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_FILE_SEEK_END}[e]+s+"x"+i}))}},Cs={init:function(){this.setColour(0),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET_CURRENT_DIR),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,"List"),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET_CURRENT_DIR)}},Ns={init:function(){this.setColour(0),this.appendValueInput("PATH").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_PATH),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_SET),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MKDIR,"mkdir"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MAKEDIRS,"makedirs"]]),"MODE"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1);var t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE");return Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_PATH+"x"+Jt.Msg.MIXLY_ESP32_SET+{mkdir:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MKDIR,makedirs:Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKEDIRS}[e]}))}},ks={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_RENAME),this.appendValueInput("NEWFILE").setCheck(String).appendField(Jt.Msg.MIXLY_AS),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_RENAME)}},Ds={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHANGE_DIR),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_CHANGE_DIR)}},Ls={init:function(){this.setColour(0),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_IS_OR_NOT),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.HTML_FILE,"isfile"],[Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_IS_DIR,"isdir"]]),"MODE"),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,Boolean);let t=this;this.setTooltip((function(){var e=t.getFieldValue("MODE");return Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH+"x"+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_IS_OR_NOT+{isfile:Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_MKDIR,isdir:Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKEDIRS}[e]}))}},Fs={init:function(){this.setColour(0),this.appendValueInput("SPISUB").appendField(Jt.Msg.CONTROLS_FOR_INPUT_WITH+"SPI").setCheck("var"),this.appendValueInput("PINSUB").appendField("CS"),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE).setCheck("var"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_SETUP+Jt.Msg.LISTS_SET_INDEX_INPUT_TO).appendField(Jt.Msg.MIXLY_SD_CARD),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Ps={init:function(){this.setColour(0),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_SD_CARD),this.appendValueInput("DIR").setCheck(String).appendField(Jt.Msg.MIXLY_SDCARD_MOUNT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip()}},$s={init:function(){var t=Jt.Procedures.findLegalName("",this),e=new Jt.FieldTextInput(t,Jt.Procedures.rename);e.setSpellcheck(!1),this.appendDummyInput().appendField(e,"NAME").appendField("","PARAMS"),this.setMutator(new Jt.icons.MutatorIcon(["procedures_mutatorarg"],this)),(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&Jt.Msg.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText(Jt.Msg.PROCEDURES_DEFNORETURN_COMMENT),this.setStyle("procedure_blocks"),this.setTooltip(Jt.Msg.PROCEDURES_DEFNORETURN_TOOLTIP),this.setHelpUrl(Jt.Msg.PROCEDURES_DEFNORETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null},setStatements_:function(t){this.hasStatements_!==t&&(t?(this.appendStatementInput("STACK").appendField(Jt.Msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=t)},updateParams_:function(){var t="";this.arguments_.length&&(t=Jt.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", ")),Jt.Events.disable();try{this.setFieldValue(t,"PARAMS")}finally{Jt.Events.enable()}},mutationToDom:function(t){var e=Jt.utils.xml.createElement("mutation");t&&e.setAttribute("name",this.getFieldValue("NAME"));for(var n=0;n<this.argumentVarModels_.length;n++){var i=Jt.utils.xml.createElement("arg"),s=this.argumentVarModels_[n];i.setAttribute("name",s.name),i.setAttribute("varid",s.getId()),t&&this.paramIds_&&i.setAttribute("paramId",this.paramIds_[n]),e.appendChild(i)}return this.hasStatements_||e.setAttribute("statements","false"),e},domToMutation:function(t){this.arguments_=[],this.argumentVarModels_=[];for(var e,n=0;e=t.childNodes[n];n++)if("arg"==e.nodeName.toLowerCase()){var i=e.getAttribute("name"),s=e.getAttribute("varid")||e.getAttribute("varId");this.arguments_.push(i);var r=Jt.Variables.getOrCreateVariablePackage(this.workspace,s,i,"");null!=r?this.argumentVarModels_.push(r):console.log("Failed to create a variable with name "+i+", ignoring.")}this.updateParams_(),Jt.Procedures.mutateCallers(this),this.setStatements_("false"!==t.getAttribute("statements"))},saveExtraState:function(){if(!this.argumentVarModels_.length&&this.hasStatements_)return null;const t=Object.create(null);if(this.argumentVarModels_.length){t.params=[];for(let e=0;e<this.argumentVarModels_.length;e++)t.params.push({name:this.argumentVarModels_[e].name,id:this.argumentVarModels_[e].getId()})}return this.hasStatements_||(t.hasStatements=!1),t},loadExtraState:function(t){if(this.arguments_=[],this.argumentVarModels_=[],t.params)for(let e=0;e<t.params.length;e++){const n=t.params[e],i=Jt.Variables.getOrCreateVariablePackage(this.workspace,n.id,n.name,"");this.arguments_.push(i.name),this.argumentVarModels_.push(i)}this.updateParams_(),Jt.Procedures.mutateCallers(this),this.setStatements_(!1!==t.hasStatements)},decompose:function(t){var e=Jt.utils.xml.createElement("block");e.setAttribute("type","procedures_mutatorcontainer");var n=Jt.utils.xml.createElement("statement");n.setAttribute("name","STACK"),e.appendChild(n);for(var i=n,s=0;s<this.arguments_.length;s++){var r=Jt.utils.xml.createElement("block");r.setAttribute("type","procedures_mutatorarg");var a=Jt.utils.xml.createElement("field");a.setAttribute("name","NAME");var o=Jt.utils.xml.createTextNode(this.arguments_[s]);a.appendChild(o),r.appendChild(a);var l=Jt.utils.xml.createElement("next");r.appendChild(l),i.appendChild(r),i=l}var u=Jt.Xml.domToBlock(e,t);return"procedures_defreturn"==this.type?u.setFieldValue(this.hasStatements_,"STATEMENTS"):u.removeInput("STATEMENT_INPUT"),Jt.Procedures.mutateCallers(this),u},compose:function(t){this.arguments_=[],this.paramIds_=[],this.argumentVarModels_=[];for(var e=t.getInputTargetBlock("STACK");e&&!e.isInsertionMarker();){var n=e.getFieldValue("NAME");this.arguments_.push(n);var i=this.workspace.getVariable(n,"");this.argumentVarModels_.push(i),this.paramIds_.push(e.id),e=e.nextConnection&&e.nextConnection.targetBlock()}this.updateParams_(),Jt.Procedures.mutateCallers(this);var s=t.getFieldValue("STATEMENTS");if(null!==s&&(s="TRUE"==s,this.hasStatements_!=s))if(s)this.setStatements_(!0),this.statementConnection_&&this.statementConnection_.reconnect(this,"STACK"),this.statementConnection_=null;else{var r=this.getInput("STACK").connection;if(this.statementConnection_=r.targetConnection,this.statementConnection_){var a=r.targetBlock();a.unplug(),a.bumpNeighbours()}this.setStatements_(!1)}},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!1]},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},renameVarById:function(t,e){var n=this.workspace.getVariableById(t);if(""==n.type){for(var i=n.name,s=this.workspace.getVariableById(e),r=!1,a=0;a<this.argumentVarModels_.length;a++)this.argumentVarModels_[a].getId()==t&&(this.arguments_[a]=s.name,this.argumentVarModels_[a]=s,r=!0);r&&(this.displayRenamedVar_(i,s.name),Jt.Procedures.mutateCallers(this))}},updateVarName:function(t){for(var e=t.name,n=!1,i=0;i<this.argumentVarModels_.length;i++)if(this.argumentVarModels_[i].getId()==t.getId()){var s=this.arguments_[i];this.arguments_[i]=e,n=!0}n&&(this.displayRenamedVar_(s,e),Jt.Procedures.mutateCallers(this))},displayRenamedVar_:function(t,e){this.updateParams_();const n=this.getIcon(Jt.icons.MutatorIcon.TYPE);if(n&&n.bubbleIsVisible())for(var i,s=n.getWorkspace().getAllBlocks(!1),r=0;i=s[r];r++)"procedures_mutatorarg"==i.type&&Jt.Names.equals(t,i.getFieldValue("NAME"))&&i.setFieldValue(e,"NAME")},customContextMenu:function(t){if(!this.isInFlyout){var e={enabled:!0},n=this.getFieldValue("NAME");e.text=Jt.Msg.PROCEDURES_CREATE_DO.replace("%1",n);var i=Jt.utils.xml.createElement("mutation");i.setAttribute("name",n);for(var s=0;s<this.arguments_.length;s++){var r=Jt.utils.xml.createElement("arg");r.setAttribute("name",this.arguments_[s]),i.appendChild(r)}var a=Jt.utils.xml.createElement("block");if(a.setAttribute("type",this.callType_),a.appendChild(i),e.callback=Jt.ContextMenu.callbackFactory(this,a),t.push(e),!this.isCollapsed())for(s=0;s<this.argumentVarModels_.length;s++){var o={enabled:!0},l=this.argumentVarModels_[s];o.text=Jt.Msg.VARIABLES_SET_CREATE_GET.replace("%1",l.name);var u=Jt.Variables.generateVariableFieldDom(l),h=Jt.utils.xml.createElement("block");h.setAttribute("type","variables_get"),h.appendChild(u),o.callback=Jt.ContextMenu.callbackFactory(this,h),t.push(o)}}},callType_:"procedures_callnoreturn"},Bs={init:function(){var t=Jt.Procedures.findLegalName("",this),e=new Jt.FieldTextInput(t,Jt.Procedures.rename);e.setSpellcheck(!1),this.appendDummyInput().appendField(e,"NAME").appendField("","PARAMS"),this.appendValueInput("RETURN").setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.PROCEDURES_DEFRETURN_RETURN),this.setMutator(new Jt.icons.MutatorIcon(["procedures_mutatorarg"],this)),(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&Jt.Msg.PROCEDURES_DEFRETURN_COMMENT&&this.setCommentText(Jt.Msg.PROCEDURES_DEFRETURN_COMMENT),this.setStyle("procedure_blocks"),this.setTooltip(Jt.Msg.PROCEDURES_DEFRETURN_TOOLTIP),this.setHelpUrl(Jt.Msg.PROCEDURES_DEFRETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null},setStatements_:$s.setStatements_,updateParams_:$s.updateParams_,mutationToDom:$s.mutationToDom,domToMutation:$s.domToMutation,decompose:$s.decompose,compose:$s.compose,getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!0]},getVars:$s.getVars,getVarModels:$s.getVarModels,renameVarById:$s.renameVarById,updateVarName:$s.updateVarName,displayRenamedVar_:$s.displayRenamedVar_,customContextMenu:$s.customContextMenu,callType_:"procedures_callreturn"},Vs={init:function(){this.appendDummyInput().appendField(Jt.Msg.PROCEDURES_MUTATORCONTAINER_TITLE),this.appendStatementInput("STACK"),this.appendDummyInput("STATEMENT_INPUT").appendField(Jt.Msg.PROCEDURES_ALLOW_STATEMENTS).appendField(new Jt.FieldCheckbox("TRUE"),"STATEMENTS"),this.setStyle("procedure_blocks"),this.setTooltip(Jt.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP),this.contextMenu=!1}},Us={init:function(){var t=new Jt.FieldTextInput(Jt.Procedures.DEFAULT_ARG,this.validator_);t.oldShowEditorFn_=t.showEditor_;t.showEditor_=function(){this.createdVariables_=[],this.oldShowEditorFn_()},this.appendDummyInput().appendField(Jt.Msg.PROCEDURES_BEFORE_PARAMS).appendField(t,"NAME"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setTooltip(Jt.Msg.PROCEDURES_MUTATORARG_TOOLTIP),this.contextMenu=!1,t.onFinishEditing_=this.deleteIntermediateVars_,t.createdVariables_=[],t.onFinishEditing_("x")},validator_:function(t){var e=this.getSourceBlock(),n=e.workspace.getRootWorkspace();if(!(t=t.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,"")))return null;for(var i=(e.workspace.targetWorkspace||e.workspace).getAllBlocks(!1),s=t.toLowerCase(),r=0;r<i.length;r++)if(i[r].id!=this.getSourceBlock().id){var a=i[r].getFieldValue("NAME");if(a&&a.toLowerCase()==s)return null}if(e.isInFlyout)return t;var o=n.getVariable(t,"");return o&&o.name!=t&&n.renameVariableById(o.getId(),t),o||(o=n.createVariable(t,""))&&this.createdVariables_&&this.createdVariables_.push(o),t},deleteIntermediateVars_:function(t){var e=this.getSourceBlock().workspace.getRootWorkspace();if(e)for(var n=0;n<this.createdVariables_.length;n++){var i=this.createdVariables_[n];i.name!=t&&e.deleteVariableById(i.getId())}}},Ys={init:function(){this.appendDummyInput("TOPROW").appendField("","NAME"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setHelpUrl(Jt.Msg.PROCEDURES_CALLNORETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.quarkConnections_={},this.quarkIds_=null,this.previousEnabledState_=!0},getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(t,e){if(Jt.Names.equals(t,this.getProcedureCall())){this.setFieldValue(e,"NAME");var n=this.outputConnection?Jt.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Jt.Msg.PROCEDURES_CALLNORETURN_TOOLTIP;this.setTooltip(n.replace("%1",e))}},setProcedureParameters_:function(t,e){const n=Jt.Procedures.getDefinition(this.getProcedureCall(),this.workspace),i=n&&n.getIcon(Jt.icons.MutatorIcon.TYPE),s=i&&i.bubbleIsVisible();if(s?this.setCollapsed(!1):(this.quarkConnections_={},this.quarkIds_=null),t.join("\n")!==this.arguments_.join("\n")){if(e.length!==t.length)throw Error("paramNames and paramIds must be the same length.");this.quarkIds_||(this.quarkConnections_={},this.quarkIds_=[]);for(let t=0;t<this.arguments_.length;t++){const n=this.getInput("ARG"+t);if(n){const i=n?.connection?.targetConnection;this.quarkConnections_[this.quarkIds_[t]]=i,s&&i&&!e.includes(this.quarkIds_[t])&&(i.disconnect(),i.getSourceBlock().bumpNeighbours())}}this.arguments_=[].concat(t),this.argumentVarModels_=[];for(var r=0;r<this.arguments_.length;r++){var a=Jt.Variables.getOrCreateVariablePackage(this.workspace,null,this.arguments_[r],"");this.argumentVarModels_.push(a)}if(this.updateShape_(),this.quarkIds_=e,this.quarkIds_)for(let t=0;t<this.arguments_.length;t++){const e=this.quarkIds_[t];if(e in this.quarkConnections_){const n=this.quarkConnections_[e];n?.reconnect(this,"ARG"+t)||delete this.quarkConnections_[e]}}}else this.quarkIds_=e},updateShape_:function(){for(var t=0;t<this.arguments_.length;t++){var e=this.getField("ARGNAME"+t);if(e){Jt.Events.disable();try{e.setValue(this.arguments_[t])}finally{Jt.Events.enable()}}else{e=new Jt.FieldLabel(this.arguments_[t]),this.appendValueInput("ARG"+t).setAlign(Jt.inputs.Align.RIGHT).appendField(e,"ARGNAME"+t).init()}}for(;this.getInput("ARG"+t);)this.removeInput("ARG"+t),t++;var n=this.getInput("TOPROW");n&&(this.arguments_.length?this.getField("WITH")||(n.appendField(Jt.Msg.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"),n.init()):this.getField("WITH")&&n.removeField("WITH"))},mutationToDom:function(){var t=Jt.utils.xml.createElement("mutation");t.setAttribute("name",this.getProcedureCall());for(var e=0;e<this.arguments_.length;e++){var n=Jt.utils.xml.createElement("arg");n.setAttribute("name",this.arguments_[e]),t.appendChild(n)}return t},domToMutation:function(t){var e=t.getAttribute("name");this.renameProcedure(this.getProcedureCall(),e);for(var n,i=[],s=[],r=0;n=t.childNodes[r];r++)"arg"==n.nodeName.toLowerCase()&&(i.push(n.getAttribute("name")),s.push(n.getAttribute("paramId")));this.setProcedureParameters_(i,s)},saveExtraState:function(){const t=Object.create(null);return t.name=this.getProcedureCall(),this.arguments_.length&&(t.params=this.arguments_),t},loadExtraState:function(t){this.renameProcedure(this.getProcedureCall(),t.name);const e=t.params;if(e){const t=[];t.length=e.length,t.fill(null),this.setProcedureParameters_(e,t)}},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},onchange:function(t){if(this.workspace&&!this.workspace.isFlyout&&t.recordUndo)if(t.type==Jt.Events.BLOCK_CREATE&&-1!=t.ids.indexOf(this.id)){var e=this.getProcedureCall();if((d=Jt.Procedures.getDefinition(e,this.workspace))&&d.type!=this.defType_&&(d=null),d){if(JSON.stringify(d.getVars())!=JSON.stringify(this.arguments_)){let t=d.arguments_,e=[];for(var n=0;n<this.arguments_.length;n++){var i=this.getInput("ARG"+n);if(i){var s=i.connection.targetConnection;s?e.push(s.sourceBlock_.id):e.push(null)}}this.setProcedureParameters_(t,e)}}else{Jt.Events.setGroup(t.group);var r=Jt.utils.xml.createElement("xml"),a=Jt.utils.xml.createElement("block");a.setAttribute("type",this.defType_);var o=this.getRelativeToSurfaceXY(),l=o.x+Jt.SNAP_RADIUS*(this.RTL?-1:1),u=o.y+2*Jt.SNAP_RADIUS;a.setAttribute("x",l),a.setAttribute("y",u);var h=this.mutationToDom();a.appendChild(h);var p=Jt.utils.xml.createElement("field");p.setAttribute("name","NAME");var c=this.getProcedureCall();c||(c=Jt.Procedures.findLegalName("",this),this.renameProcedure("",c)),p.appendChild(Jt.utils.xml.createTextNode(c)),a.appendChild(p),r.appendChild(a),Jt.Xml.domToWorkspace(r,this.workspace),Jt.Events.setGroup(!1)}}else if(t.type==Jt.Events.BLOCK_DELETE){e=this.getProcedureCall();(d=Jt.Procedures.getDefinition(e,this.workspace))||(Jt.Events.setGroup(t.group),this.dispose(!0),Jt.Events.setGroup(!1))}else if(t.type==Jt.Events.CHANGE&&"disabled"==t.element){var d;e=this.getProcedureCall();if((d=Jt.Procedures.getDefinition(e,this.workspace))&&d.id==t.blockId){var f=Jt.Events.getGroup();f&&console.log("Saw an existing group while responding to a definition change"),Jt.Events.setGroup(t.group),t.newValue?(this.previousEnabledState_=this.isEnabled(),this.setEnabled(!1)):this.setEnabled(this.previousEnabledState_),Jt.Events.setGroup(f)}}},customContextMenu:function(t){if(this.workspace.isMovable()){var e={enabled:!0};e.text=Jt.Msg.PROCEDURES_HIGHLIGHT_DEF;var n=this.getProcedureCall(),i=this.workspace;e.callback=function(){var t=Jt.Procedures.getDefinition(n,i);t&&(i.centerOnBlock(t.id),t.select())},t.push(e)}},defType_:"procedures_defnoreturn"},Gs={init:function(){this.appendDummyInput("TOPROW").appendField("","NAME"),this.setOutput(!0),this.setStyle("procedure_blocks"),this.setHelpUrl(Jt.Msg.PROCEDURES_CALLRETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.quarkConnections_={},this.quarkIds_=null,this.previousEnabledState_=!0},getProcedureCall:Ys.getProcedureCall,renameProcedure:Ys.renameProcedure,setProcedureParameters_:Ys.setProcedureParameters_,updateShape_:Ys.updateShape_,mutationToDom:Ys.mutationToDom,domToMutation:Ys.domToMutation,getVars:Ys.getVars,getVarModels:Ys.getVarModels,onchange:Ys.onchange,customContextMenu:Ys.customContextMenu,defType_:"procedures_defreturn"},Hs={init:function(){this.appendValueInput("CONDITION").setCheck("Boolean").appendField(Jt.Msg.CONTROLS_IF_MSG_IF),this.appendValueInput("VALUE").appendField(Jt.Msg.PROCEDURES_DEFRETURN_RETURN),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setTooltip(Jt.Msg.PROCEDURES_IFRETURN_TOOLTIP),this.setHelpUrl(Jt.Msg.PROCEDURES_IFRETURN_HELPURL),this.hasReturnValue_=!0},mutationToDom:function(){var t=Jt.utils.xml.createElement("mutation");return t.setAttribute("value",Number(this.hasReturnValue_)),t},domToMutation:function(t){var e=t.getAttribute("value");this.hasReturnValue_=1==e,this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Jt.Msg.PROCEDURES_DEFRETURN_RETURN))},onchange:function(){if(this.workspace.isDragging&&!this.workspace.isDragging()){var t=!1,e=this;do{if(-1!=this.FUNCTION_TYPES.indexOf(e.type)){t=!0;break}e=e.getSurroundParent()}while(e);t?("procedures_defnoreturn"==e.type&&this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Jt.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):"procedures_defreturn"!=e.type||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendField(Jt.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),this.setWarningText(null),this.isInFlyout||this.setEnabled(!0)):(this.setWarningText(Jt.Msg.PROCEDURES_IFRETURN_WARNING),this.isInFlyout||this.getInheritedDisabled()||this.setEnabled(!1))}},FUNCTION_TYPES:["procedures_defnoreturn","procedures_defreturn"]},Ws={init:function(){this.setStyle("procedure_blocks"),this.appendValueInput("VALUE").appendField(Jt.Msg.PROCEDURES_DEFRETURN_RETURN),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.PROCEDURES_IFRETURN_TOOLTIP),this.hasReturnValue_=!0},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("value",Number(this.hasReturnValue_)),t},domToMutation:function(t){var e=t.getAttribute("value");this.hasReturnValue_=1==e,this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Jt.Msg.PROCEDURES_DEFRETURN_RETURN))},onchange:function(){var t=!1,e=this;do{if(-1!=this.FUNCTION_TYPES.indexOf(e.type)){t=!0;break}e=e.getSurroundParent()}while(e);t?("procedures_defnoreturn"==e.type&&this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Jt.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):"procedures_defreturn"!=e.type||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendField(Jt.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),this.setWarningText(null)):this.setWarningText(Jt.Msg.PROCEDURES_IFRETURN_WARNING)},FUNCTION_TYPES:["procedures_defnoreturn","procedures_defreturn","method_procedures_defnoreturn","method_procedures_defreturn"]},zs=195,Xs={init:function(){this.setColour(zs),this.appendDummyInput("").appendField(new Jt.FieldTextInput("mytup"),"VAR"),this.itemCount_=3,this.updateShape_(),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["tuple_create_with_item"],this)),this.setTooltip(Jt.Msg.TUPLE_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("tuple_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("tuple_create_with_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("ADD"+t);)this.removeInput("ADD"+t),t++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(Jt.Msg.TUPLE_CREATE_EMPTY_TITLE);else for(t=0;t<this.itemCount_;t++){var e=this.appendValueInput("ADD"+t);0==t&&e.appendField(Jt.Msg.TUPLE_CREATE_WITH_INPUT_WITH)}},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},js={init:function(){this.setColour(zs),this.appendDummyInput().appendField(Jt.Msg.TUPLE_CREATE_WITH_CONTAINER_TITLE_ADD),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.TUPLE_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},qs={init:function(){this.setColour(zs),this.appendDummyInput().appendField(Jt.Msg.blockpy_SET_VARIABLES_NAME),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.TUPLE_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},Ks={init:function(){this.setColour(zs),this.appendDummyInput("").appendField(new Jt.FieldTextInput("mytup"),"VAR").appendField(" = (").appendField(new Jt.FieldTextInput("0,0,0"),"TEXT").appendField(")"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXPY_TOOLTIP_TUPLE_CREATE_WITH_TEXT)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Qs={init:function(){this.setColour(zs),this.appendDummyInput("").appendField("(").appendField(new Jt.FieldTextInput("0,0,0"),"TEXT").appendField(")"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXPY_TOOLTIP_TUPLE_CREATE_WITH_TEXT)}},Js={init:function(){this.setColour(zs),this.setOutput(!0),this.appendValueInput("TUP").setCheck("Tuple"),this.appendValueInput("AT").setCheck(Number).appendField(Jt.Msg.LANG_LISTS_GET_INDEX1),this.appendDummyInput("").appendField(Jt.Msg.LANG_LISTS_GET_INDEX2),this.setInputsInline(!0),this.setTooltip(Jt.Msg.TUPLE_GET_INDEX_TOOLTIP)}},Zs={init:function(){this.setColour(zs),this.appendValueInput("TUP"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_LENGTH),this.setTooltip(Jt.Msg.TUPLE_LENGTH_TOOLTIP),this.setOutput(!0,Number)}},tr={init:function(){this.setColour(zs),this.appendValueInput("TUP").setCheck("Tuple"),this.appendDummyInput("").appendField(Jt.Msg.TUPLE_DEL),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.TUPLE_DEL_TOOLTIP)}},er={init:function(){this.setColour(zs),this.appendValueInput("TUP1").setCheck("Tuple"),this.appendDummyInput("").appendField(Jt.Msg.TUPLE_JOIN),this.appendValueInput("TUP2").setCheck("Tuple"),this.setInputsInline(!0),this.setTooltip(Jt.Msg.TUPLE_JOIN_TOOLTIP),this.setOutput(!0,"Tuple")}},nr={init:function(){this.appendValueInput("TUP").setCheck("Tuple");var t=[[Jt.Msg.blockpy_TUPLE_MAX,"max"],[Jt.Msg.blockpy_TUPLE_MIN,"min"],[Jt.Msg.MATH_ONLIST_OPERATOR_SUM,"sum"]];this.setColour(zs),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROBIT_JS_GET).appendField(new Jt.FieldDropdown(t),"DIR"),this.setInputsInline(!0),this.setOutput(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{max:Jt.Msg.MIXLY_TOOLTIP_TUPLE_MAX,min:Jt.Msg.MIXLY_TOOLTIP_TUPLE_MIN,sum:Jt.Msg.MIXLY_TOOLTIP_TUPLE_SUM}[t]}))}},ir={init:function(){var t=[[Jt.Msg.MIXLY_MICROBIT_TYPE_LIST,"list"],[Jt.Msg.blockpy_SET_CREATE_WITH_CONTAINER_TITLE_ADD,"set"]];this.setColour(zs),this.appendValueInput("VAR").setCheck("Tuple"),this.appendDummyInput("").appendField(Jt.Msg.A_TO_B).appendField(new Jt.FieldDropdown(t),"OP"),this.setInputsInline(!0),this.setOutput(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{list:Jt.Msg.TUPLE_TO_LISTS,set:Jt.Msg.TUPLE_TO_SET}[t]}))}},sr={init:function(){var t=[[Jt.Msg.MIXLY_LIST_INDEX,"INDEX"],[Jt.Msg.MIXLY_LIST_COUNT,"COUNT"]];this.setColour(zs),this.appendValueInput("VAR").setCheck("List"),this.appendValueInput("data").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET).appendField(Jt.Msg.HTML_VALUE),this.appendDummyInput().appendField(Jt.Msg.MIXLY_DE).appendField(new Jt.FieldDropdown(t),"OP"),this.setInputsInline(!0),this.setOutput(!0,Number);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{INDEX:Jt.Msg.MIXLY_TOOLTIP_TUPLE_FIND_INDEX,COUNT:Jt.Msg.MIXLY_TOOLTIP_TUPLE_FIND_COUNT}[t]}))}},rr={init:function(){var t=[[Jt.Msg.MIXLY_LIST_LEN,"LEN"],[Jt.Msg.MATH_ONLIST_OPERATOR_SUM,"SUM"],[Jt.Msg.MATH_ONLIST_OPERATOR_MAX,"MAX"],[Jt.Msg.MATH_ONLIST_OPERATOR_MIN,"MIN"],[Jt.Msg.MATH_ONLIST_OPERATOR_AVERAGE,"AVERAGE"],[Jt.Msg.MATH_ONLIST_OPERATOR_MEDIAN,"MEDIAN"],[Jt.Msg.MATH_ONLIST_OPERATOR_MODE,"MODE"],[Jt.Msg.MATH_ONLIST_OPERATOR_STD_DEV,"STD_DEV"]];this.setColour(zs),this.setOutput(!0,Number),this.appendValueInput("data").setCheck("List"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET).appendField(new Jt.FieldDropdown(t),"OP"),this.setInputsInline(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OP");return{LEN:Jt.Msg.TUPLE_LENGTH_TOOLTIP,SUM:Jt.Msg.MATH_ONLIST_TOOLTIP_TUPLE_SUM,MAX:Jt.Msg.MATH_ONLIST_TOOLTIP_TUPLE_MAX,MIN:Jt.Msg.MATH_ONLIST_TOOLTIP_TUPLE_MIN,AVERAGE:Jt.Msg.MATH_ONLIST_TOOLTIP_TUPLE_AVERAGE,MEDIAN:Jt.Msg.MATH_ONLIST_TOOLTIP_TUPLE_MEDIAN,MODE:Jt.Msg.MATH_ONLIST_TOOLTIP_TUPLE_MODE,STD_DEV:Jt.Msg.MATH_ONLIST_TOOLTIP_TUPLE_STD_DEV}[t]}))}},ar={init:function(){this.WHERE_OPTIONS_1=[[Jt.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Jt.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Jt.Msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[Jt.Msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[Jt.Msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[Jt.Msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]],this.setHelpUrl(Jt.Msg.LISTS_GET_SUBLIST_HELPURL),this.setColour(zs),this.appendValueInput("LIST").setCheck("List"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),this.setInputsInline(!0),this.setOutput(!0,"List"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(Jt.Msg.PYTHON_TUPLE_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation"),e=this.getInput("AT1").type==Jt.INPUT_VALUE;t.setAttribute("at1",e);var n=this.getInput("AT2").type==Jt.INPUT_VALUE;return t.setAttribute("at2",n),t},domToMutation:function(t){var e="true"==t.getAttribute("at1"),n="true"==t.getAttribute("at2");this.updateAt_(1,e),this.updateAt_(2,n)},updateAt_:function(t,e){this.removeInput("AT"+t),this.removeInput("ORDINAL"+t,!0),e?(this.appendValueInput("AT"+t).setCheck(Number),Jt.Msg.TEXT_CHARAT_TAIL&&this.appendDummyInput("ORDINAL"+t).appendField(Jt.Msg.TEXT_CHARAT_TAIL)):this.appendDummyInput("AT"+t);var n=new Jt.FieldDropdown(this["WHERE_OPTIONS_"+t],(function(n){var i="FROM_START"==n||"FROM_END"==n;if(i!=e){var s=this.sourceBlock_;return s.updateAt_(t,i),s.setFieldValue(n,"WHERE"+t),null}}));this.getInput("AT"+t).appendField(n,"WHERE"+t),1==t&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2"))}},or={init:function(){this.setColour(zs),this.itemCount_=3,this.updateShape_(),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0,"Tuple"),this.setMutator(new Jt.icons.MutatorIcon(["tuple_create_with_item"],this)),this.setTooltip(Jt.Msg.TUPLE_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("tuple_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("tuple_create_with_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("ADD"+t);)this.removeInput("ADD"+t),t++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(Jt.Msg.TUPLE_CREATE_EMPTY_TITLE);else for(t=0;t<this.itemCount_;t++){var e=this.appendValueInput("ADD"+t);0==t&&e.appendField(Jt.Msg.TUPLE_CREATE_WITH_INPUT_WITH)}},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},lr={init:function(){this.setHelpUrl(Jt.Msg.LISTS_GET_SUBLIST_HELPURL),this.setColour(zs),this.appendValueInput("LIST"),this.appendDummyInput(""),this.appendValueInput("AT1").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET+" "+Jt.Msg.LISTS_GET_INDEX_FROM_START),this.appendValueInput("AT2").appendField(Jt.Msg.TEXT_CHARAT_TAIL+" "+Jt.Msg.LISTS_GET_SUBLIST_END_FROM_START),this.appendDummyInput().appendField(Jt.Msg.TEXT_CHARAT_TAIL),this.setInputsInline(!0),this.setOutput(!0,"Tuple"),this.setTooltip(Jt.Msg.PYTHON_TUPLE_GET_SUBLIST_TOOLTIP)}},ur={init:function(){this.setColour(zs),this.appendValueInput("TUP"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET+" "+Jt.Msg.LISTS_GET_INDEX_RANDOM),this.setTooltip(Jt.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM),this.setOutput(!0)}},hr={init:function(){this.setColour(zs),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TOTUPLE),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOTUPLE)}};const pr={init:function(){var t;this.setColour(zs),this.appendDummyInput("").appendField("(").appendField(new Jt.FieldTextInput((t=new Date,t.getFullYear()+","+(t.getMonth()+1)+","+t.getDate()+","+t.getHours()+","+t.getMinutes()+","+t.getSeconds())),"CONTENT").appendField(")"),this.setOutput(!0)}},cr=100,dr={init:function(){this.setColour(cr),this.appendDummyInput("").appendField(new Jt.FieldTextInput("s1"),"VAR"),this.itemCount_=3,this.updateShape_(),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["set_create_with_item"],this)),this.setTooltip(Jt.Msg.blockpy_SET_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("set_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("set_create_with_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("ADD"+t);)this.removeInput("ADD"+t),t++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(Jt.Msg.blockpy_SET_CREATE_EMPTY_TITLE);else for(t=0;t<this.itemCount_;t++){var e=this.appendValueInput("ADD"+t);0==t&&e.appendField(Jt.Msg.blockpy_SET_CREATE_WITH_INPUT_WITH)}},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},fr={init:function(){this.setColour(cr),this.appendDummyInput().appendField(Jt.Msg.blockpy_SET_CREATE_WITH_CONTAINER_TITLE_ADD),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.blockpy_SET_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},mr={init:function(){this.setColour(cr),this.appendDummyInput().appendField(Jt.Msg.blockpy_SET_VARIABLES_NAME),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.blockpy_SET_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},gr={init:function(){this.setColour(cr),this.appendValueInput("SET"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_LENGTH),this.setInputsInline(!0),this.setTooltip(Jt.Msg.SET_LENGTH_TOOLTIP),this.setOutput(!0,Number)}},_r={init:function(){this.setColour(cr),this.appendValueInput("SET").setCheck("Set"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_SET_GET_AND_REMOVE_LAST),this.setTooltip(Jt.Msg.SET_POP_TOOLTIP),this.setInputsInline(!0),this.setOutput(!0)}},Tr={init:function(){this.setColour(cr),this.appendValueInput("SET").setCheck("Set"),this.appendDummyInput("").appendField(Jt.Msg.SET_CLEAR),this.setPreviousStatement(!0),this.setNextStatement(!0)}},yr={init:function(){this.appendValueInput("SET1").setCheck("Set");var t=[[Jt.Msg.blockpy_set_union,"union"],[Jt.Msg.blockpy_set_intersection,"intersection"],[Jt.Msg.blockpy_set_difference,"difference"]];this.setColour(cr),this.appendDummyInput("").appendField(Jt.Msg.blockpy_and_set),this.appendValueInput("SET2").setCheck("Set"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_set_get_operate).appendField(new Jt.FieldDropdown(t),"OPERATE"),this.setInputsInline(!0),this.setOutput(!0,"set");var e=this;this.setTooltip((function(){var t=e.getFieldValue("OPERATE");return{union:Jt.Msg.MIXLY_TOOLTIP_SET_UNION,intersection:Jt.Msg.MIXLY_TOOLTIP_SET_INTERSECTION,difference:Jt.Msg.MIXLY_TOOLTIP_SET_DIFFERENCE}[t]}))}},Ir={init:function(){this.appendValueInput("SET1").setCheck("Set");var t=[[Jt.Msg.blockpy_set_union,"update"],[Jt.Msg.blockpy_set_intersection,"intersection_update"],[Jt.Msg.blockpy_set_difference,"difference_update"]];this.setColour(cr),this.appendDummyInput("").appendField(Jt.Msg.blockpy_and_set),this.appendValueInput("SET2").setCheck("Set"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_set_get_operate).appendField(new Jt.FieldDropdown(t),"OPERATE"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_set_update),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OPERATE");return{update:Jt.Msg.MIXLY_TOOLTIP_SET_UPDATE,intersection_update:Jt.Msg.MIXLY_TOOLTIP_SET_INTERSECTION_UPDATE,difference_update:Jt.Msg.MIXLY_TOOLTIP_SET_DIFFERENCE_UPDATE}[t]}))}},Er={init:function(){this.appendValueInput("SET").setCheck("Set");var t=[[Jt.Msg.MIXLY_blockpy_set_add,"add"],[Jt.Msg.MIXLY_blockpy_set_discard,"discard"]];this.setColour(cr),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"OPERATE"),this.appendValueInput("data").appendField(Jt.Msg.blockpy_SET_VARIABLES_NAME),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OPERATE");return{add:Jt.Msg.SET_ADD_TOOLTIP,discard:Jt.Msg.SET_DISCARD_TOOLTIP}[t]}))}},br={init:function(){this.appendValueInput("SET1").setCheck("Set");var t=[[Jt.Msg.blockpy_set_sub,"issubset"],[Jt.Msg.blockpy_set_super,"issuperset"]];this.setColour(cr),this.appendDummyInput("").appendField(Jt.Msg.blockpy_is_set),this.appendValueInput("SET2").setCheck("Set"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_set_of).appendField(new Jt.FieldDropdown(t),"OPERATE"),this.setInputsInline(!0),this.setOutput(!0,Boolean);var e=this;this.setTooltip((function(){var t=e.getFieldValue("OPERATE");return{issubset:Jt.Msg.MIXLY_TOOLTIP_SET_SUB,issuperset:Jt.Msg.MIXLY_TOOLTIP_SET_SUPER}[t]}))}},vr={init:function(){this.appendValueInput("SET").setCheck("Set"),this.setColour(cr),this.appendValueInput("VAR").setCheck([String,"List"]).appendField(Jt.Msg.blockpy_set_add_update),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.SET_UPDATE_TOOLTIP)}},wr={init:function(){this.setColour(cr),this.appendDummyInput("").appendField("{").appendField(new Jt.FieldTextInput("0,0,0"),"TEXT").appendField("}"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXPY_TOOLTIP_SET_CREATE_WITH_TEXT)}},Sr={init:function(){this.setColour(cr),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TOSET),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOSET)}},xr="#1ec1e4",Rr={init:function(){this.setColour(xr),this.appendDummyInput().appendField(Jt.Msg.HTML_DOCUMENT),this.appendStatementInput("HEAD").appendField(Jt.Msg.HTML_HEAD),this.appendStatementInput("BODY").appendField(Jt.Msg.HTML_BODY),this.setOutput(!0)}},Or={init:function(){this.setColour(xr),this.appendDummyInput().appendField(Jt.Msg.HTML_LEVEL).appendField(new Jt.FieldDropdown([["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"]]),"LEVEL"),this.appendStatementInput("DO").appendField(""),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ar={init:function(){this.setColour(xr),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.HTML_HEAD,"head"],[Jt.Msg.HTML_BODY,"body"]]),"LEVEL"),this.appendStatementInput("DO").appendField(""),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Mr={init:function(){this.setColour(xr),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.HTML_P,"p"],[Jt.Msg.HTML_SPAN,"span"],[Jt.Msg.HTML_FORM,"form"],[Jt.Msg.HTML_TABLE,"table"],[Jt.Msg.HTML_LINE,"tr"],[Jt.Msg.HTML_CELL,"td"],[Jt.Msg.HTML_OL,"ol"],[Jt.Msg.HTML_UL,"ul"],[Jt.Msg.HTML_LI,"li"]]),"LEVEL"),this.appendStatementInput("DO").appendField(""),this.setInputsInline(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Cr={init:function(){this.setColour(xr),this.appendDummyInput().appendField("<").appendField(new Jt.FieldTextInput("tag"),"LEVEL").appendField(">"),this.appendValueInput("style").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.appendStatementInput("DO").appendField(""),this.setInputsInline(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Nr={init:function(){this.setColour(xr),this.appendDummyInput().appendField(Jt.Msg.HTML_STYLE),this.appendStatementInput("STYLE"),this.setOutput(!0)}},kr={init:function(){this.setColour(xr),this.appendDummyInput().appendField(Jt.Msg.HTML_FORM_CONTENT).appendField(new Jt.FieldDropdown([[Jt.Msg.HTML_TEXT,"text"],[Jt.Msg.HTML_EMAIL,"email"],[Jt.Msg.HTML_NUMBER,"number"],[Jt.Msg.HTML_PASSWORD,"password"],[Jt.Msg.HTML_CHECKBOX,"checkbox"],[Jt.Msg.HTML_RADIOBUTTON,"radiobutton"],[Jt.Msg.HTML_BUTTON,"button"],[Jt.Msg.HTML_COLOUR,"colour"],[Jt.Msg.HTML_DATE,"date"],[Jt.Msg.HTML_LOCALTIME,"local time"],[Jt.Msg.HTML_FILE,"file"],[Jt.Msg.HTML_HIDDEN,"hidden"],[Jt.Msg.HTML_IMAGE,"image"],[Jt.Msg.HTML_MONTH,"month"],[Jt.Msg.HTML_RANGE,"range"],[Jt.Msg.HTML_RESET,"reset"],[Jt.Msg.HTML_SEARCH,"search"],[Jt.Msg.HTML_SUBMIT,"submit"],[Jt.Msg.HTML_TELEPHONENUMBER,"telephone number"],[Jt.Msg.HTML_TIME,"time"],[Jt.Msg.HTML_URL,"url"],[Jt.Msg.HTML_WEEK,"week"]]),"LEVEL"),this.appendDummyInput().appendField(Jt.Msg.HTML_NAME).appendField(new Jt.FieldTextInput("car"),"NAME"),this.appendDummyInput().appendField(Jt.Msg.HTML_VALUE).appendField(new Jt.FieldTextInput("go"),"VALUE"),this.appendValueInput("style").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Dr={init:function(){this.setColour(xr),this.appendDummyInput().appendField(new Jt.FieldTextInput("property"),"KEY").appendField(":").appendField(new Jt.FieldTextInput("value"),"VALUE"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Lr={init:function(){this.setColour(xr),this.appendDummyInput().appendField(new Jt.FieldTextInput("property"),"KEY").appendField(":").appendField(new Jt.FieldColour("#ff0000"),"RGB_LED_COLOR"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Fr={init:function(){this.setColour(xr),this.appendDummyInput().appendField(Jt.Msg.HTML_TEXT).appendField(new Jt.FieldTextInput("text"),"TEXT"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Pr=160,$r={init:function(){this.setColour(Pr),this.setPreviousStatement(!0),this.setNextStatement(!0),this.appendDummyInput().appendField("Tabular Abstraction:"),this.appendDummyInput().appendField(new Jt.FieldTable(""),"TEXT")}},Br={init:function(){this.setColour(Pr),this.setPreviousStatement(!0),this.setNextStatement(!0),this.appendDummyInput().appendField("Code Block:"),this.appendDummyInput().appendField(new Jt.FieldMultilineInput(""),"TEXT")}},Vr={init:function(){this.setColour(Pr),this.appendDummyInput().appendField("Code Expression:"),this.appendDummyInput().appendField(new Jt.FieldMultilineInput(""),"TEXT"),this.setOutput(!0)}},Ur={init:function(){this.setColour(Pr),this.setPreviousStatement(!0),this.setNextStatement(!0),this.appendValueInput("VALUE").appendField(""),this.setInputsInline(!1)}},Yr={init:function(){this.setColour(Pr),this.appendDummyInput().appendTitle("Comment:").appendTitle(new Jt.FieldTextInput(""),"TEXT"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("This comment will be ignored by Python")}},Gr={init:function(){this.setColour(Pr),this.appendValueInput("VALUE").appendField(Jt.Msg.TYPE_CHECK),this.setInputsInline(!1),this.setOutput(!0,"Type")}},Hr={init:function(){this.setColour(Pr),this.itemCount_=1,this.updateShape_(),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["text_print_multiple_item"],this)),this.setTooltip(Jt.Msg.TEXT_PRINT_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=Jt.Block.obtain(t,"text_print_multiple_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("text_print_multiple_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("PRINT"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("PRINT"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("PRINT"+t);)this.removeInput("PRINT"+t),t++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField("print");else for(t=0;t<this.itemCount_;t++){var e=this.appendValueInput("PRINT"+t);0==t&&e.appendField("print")}}},Wr={init:function(){this.setColour(Pr),this.appendDummyInput().appendField("print"),this.appendStatementInput("STACK"),this.setTooltip(""),this.contextMenu=!1}},zr={init:function(){this.setColour(Pr),this.appendDummyInput().appendField("item"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(""),this.contextMenu=!1}},Xr={init:function(){this.setColour(Pr),this.itemCount_=1,this.hasReturn_=!1,this.appendDummyInput().appendField(new Jt.FieldTextInput("str"),"NAME"),this.updateShape_(),this.setMutator(new Jt.icons.MutatorIcon(["function_call_item"],this)),this.setTooltip("Can be used to call any function")},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t.setAttribute("hasReturn",this.hasReturn_?"TRUE":"FALSE"),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.hasReturn_="TRUE"===t.getAttribute("hasReturn"),this.updateShape_()},decompose:function(t){var e=Jt.Block.obtain(t,"function_call_container");e.initSvg(),e.setFieldValue(this.hasStatements_?"TRUE":"FALSE","RETURN");for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("function_call_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},setReturn:function(t){this.unplug(!0,!0),this.setOutput(t),this.setPreviousStatement(!t),this.setNextStatement(!t),this.rendered&&this.render()},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.hasReturn_="TRUE"===t.getFieldValue("RETURN"),this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ARGUMENT"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ARGUMENT"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("ARGUMENT"+t);)this.removeInput("ARGUMENT"+t),t++;for(t=0;t<this.itemCount_;t++)this.appendValueInput("ARGUMENT"+t);this.setReturn(this.hasReturn_)}},jr={init:function(){this.setColour(Pr),this.appendDummyInput().appendField("Arguments"),this.appendStatementInput("STACK"),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField("has return").appendField(new Jt.FieldCheckbox("TRUE"),"RETURN"),this.setTooltip(""),this.contextMenu=!1}},qr={init:function(){this.setColour(Pr),this.appendDummyInput().appendField("argument"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(""),this.contextMenu=!1}},Kr={init:function(){this.appendValueInput("MODULE").setCheck(null),this.appendValueInput("NAME").setCheck(null).appendField("."),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(230),this.setTooltip(""),this.setHelpUrl("")}},Qr=function(t,e){return[e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE),e.ORDER_ATOMIC]},Jr=function(t,e){if(""==this.getFieldValue("VAR"))return" = None\n";var n=e.valueToCode(this,"VALUE",e.ORDER_ASSIGNMENT)||"None";return e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+" = "+n+"\n"},Zr=function(t,e){var n=this.getFieldValue("OP"),i=e.valueToCode(this,"MYVALUE",e.ORDER_ATOMIC)||"None";if("bytes"==n)var s=n+"("+i+',"UTF-8")';else s=n+"("+i+")";return[s,e.ORDER_ATOMIC]},ta=function(t,e){return"global "+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"None")+"\n"},ea=function(t,e){return["type("+(e.valueToCode(this,"DATA",e.ORDER_ATOMIC)||"None")+")",e.ORDER_ATOMIC]},na=function(t,e){return[this.getFieldValue("type"),e.ORDER_ATOMIC]},ia=function(t,e){for(var n=new Array(this.itemCount_),i=0;i<this.itemCount_;i++)n[i]=e.valueToCode(this,"ADD"+i,e.ORDER_NONE)||"[]";return[n="zip("+n.join(", ")+")",e.ORDER_ATOMIC]},sa=function(t,e){const n=e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"[]";return[`${this.getFieldValue("TYPE")}(${n})`,e.ORDER_ATOMIC]},ra=function(t,e){var n=e.statementToCode(t,"DO");return"if __name__ == '__main__':\n"+(n=e.addLoopTrap(n,t.id)||e.PASS)},aa=function(t,e){var n=e.statementToCode(this,"DO");return(n=n.replace(/(^\s*)|(\s*$)/g,"").replace(/\n {4}/g,"\n")).endsWith("\n")?e.setups_.setup_setup=n:e.setups_.setup_setup=n+"\n",""},oa=function(t,e){var n=0,i="";do{i+=(0==n?"if ":"elif ")+(e.valueToCode(t,"IF"+n,e.ORDER_NONE)||"False")+":\n"+(e.statementToCode(t,"DO"+n)||e.PASS),++n}while(t.getInput("IF"+n));return t.getInput("ELSE")&&(i+="else:\n"+(e.statementToCode(t,"ELSE")||e.PASS)),i},la=function(t,e){var n=1,i=e.valueToCode(this,"IF"+n,e.ORDER_NONE)||"null",s="try:\n"+(e.statementToCode(this,"try")||" pass\n");for(n=1;n<=this.elseifCount_;n++)""!==(i=e.valueToCode(this,"IF"+n,e.ORDER_NONE)||"")&&(i=" "+i),s+="except"+i+": \n"+(e.statementToCode(this,"DO"+n)||" pass\n");return this.elseCount_&&(s+="finally:\n"+(e.statementToCode(this,"ELSE")||" pass\n")),s},ua=function(t,e){var n=e.variableDB_.getName(t.getFieldValue("VAR"),Jt.Variables.NAME_TYPE),i=e.valueToCode(t,"FROM",e.ORDER_NONE)||"0",s=e.valueToCode(t,"TO",e.ORDER_NONE)||"0",r=e.valueToCode(t,"STEP",e.ORDER_NONE)||"1",a=e.statementToCode(t,"DO"),o=(a=e.addLoopTrap(a,t.id)||e.PASS,""),l=function(t,e){return e.provideFunction_("upRange",["def "+e.FUNCTION_NAME_PLACEHOLDER_+"(start, stop, step):"," while start <= stop:"," yield start"," start += abs(step)"])},u=function(t,e){return e.provideFunction_("downRange",["def "+e.FUNCTION_NAME_PLACEHOLDER_+"(start, stop, step):"," while start >= stop:"," yield start"," start -= abs(step)"])};if(t=function(t,e,n){return"("+t+" <= "+e+") and "+l()+"("+t+", "+e+", "+n+") or "+u()+"("+t+", "+e+", "+n+")"},Jt.isNumber(i)&&Jt.isNumber(s)&&Jt.isNumber(r))i=parseFloat(i),s=parseFloat(s),r=Math.abs(parseFloat(r)),0==i%1&&0==s%1&&0==r%1?(i<=s?(s++,t=0==i&&1==r?s:i+", "+s,1!=r&&(t+=", "+r)):t=i+", "+--s+", -"+r,t="range("+t+")"):(t=i<s?l():u(),t+="("+i+", "+s+", "+r+")");else{var h=function(t,i){if(Jt.isNumber(t))t=parseFloat(t);else{var s=e.variableDB_.getDistinctName(n+i,Jt.Variables.NAME_TYPE);o+=s+" = "+t+"\n",t=s}return t};i=h(i,"_start"),s=h(s,"_end");h(r,"_inc"),t="number"==typeof i&&"number"==typeof s?i<s?l(0,s):u(0,s):t(i,s,r)}return o+="for "+n+" in "+t+":\n"+a},ha=function(t,e){var n=e.variableDB_.getName(t.getFieldValue("VAR"),Jt.Variables.NAME_TYPE),i=e.valueToCode(t,"FROM",e.ORDER_NONE)||"0",s=e.valueToCode(t,"TO",e.ORDER_NONE)||"0",r=e.valueToCode(t,"STEP",e.ORDER_NONE)||"1",a=e.statementToCode(t,"DO"),o=e.addLoopTrap(a,t.id)||e.PASS;return e.setups_.mixly_range="def mixly_range(start, stop, step):\n for i in range(start, stop + 1, step):\n yield i\n\n","for "+n+" in mixly_range("+i+", "+s+", "+r+"):\n"+o},pa=function(t,e){var n="UNTIL"==t.getFieldValue("MODE"),i=e.valueToCode(t,"BOOL",e.ORDER_NONE)||"False",s=e.statementToCode(t,"DO");return n&&(i="not "+i),"while "+i+":\n"+(s=e.addLoopTrap(s,t.id)||e.PASS)},ca=function(t){switch(t.getFieldValue("FLOW")){case"BREAK":return"break\n";case"CONTINUE":return"continue\n"}throw"Unknown flow statement."},da=function(t,e){return"sleep("+(e.valueToCode(this,"DELAY_TIME",e.ORDER_ATOMIC)||"1000")+")\n"},fa=function(t,e){return"panic("+(e.valueToCode(this,"STATUS_CODE",e.ORDER_ATOMIC)||"1000")+")\n"},ma=function(t,e){e.definitions_.import_time="import time";return["time.time()",e.ORDER_ATOMIC]},ga=function(t,e){return e.definitions_.import_microbit="from microbit import *","reset()\n"},_a=function(){return"interrupts();\n"},Ta=function(){return"noInterrupts();\n"},ya=function(t,e){var n=e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"''",i=e.valueToCode(t,"LIST",e.ORDER_RELATIONAL)||"[]",s=e.statementToCode(t,"DO");return"for "+n+" in "+i+":\n"+(s=e.addLoopTrap(s,t.id)||e.PASS)},Ia=function(t,e){return["range("+(e.valueToCode(this,"FROM",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"TO",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"STEP",e.ORDER_NONE)||"1")+")",e.ORDER_ATOMIC]},Ea=function(t,e){var n="lambda "+(e.valueToCode(t,"BOOL",e.ORDER_NONE)||"None")+": "+(e.statementToCode(t,"DO")||"pass");return[n=n.replace("\n","").replace(" ",""),e.ORDER_ATOMIC]},ba=function(t,e){return e.definitions_.import_time="import time","time.sleep("+(e.valueToCode(this,"DELAY_TIME",e.ORDER_ATOMIC)||"1000")+")\n"},va=function(){return"pass\n"},wa=function(t,e){e.definitions_.import__thread="import _thread";var n=e.valueToCode(this,"VAR",e.ORDER_NONE)||"None";return"_thread.start_new_thread("+e.variableDB_.getName(e.valueToCode(this,"callback",e.ORDER_NONE)||"None",Jt.Procedures.NAME_TYPE)+", "+n+")\n"},Sa=function(t,e){var n=e.valueToCode(this,"select_data",e.ORDER_NONE)||"False",i=e.statementToCode(this,"input_data");return i="true"==this.getFieldValue("type")?i+" if ("+n+"):\n break\n":i+" if not ("+n+"):\n break\n","while True:\n"+(i=e.addLoopTrap(i,this.id)||e.PASS)},xa=function(t,e){var n=e.valueToCode(this,"TIMES",e.ORDER_ATOMIC),i=e.statementToCode(t,"DO");return"for _my_variable in range("+n+"):\n"+(i=e.addLoopTrap(i,t.id)||e.PASS)},Ra=function(t,e){e.definitions_.import_gc="import gc";return"gc.collect()\n"},Oa=function(t,e){e.definitions_.import_gc="import gc";return["gc.mem_alloc()",e.ORDER_ATOMIC]},Aa=function(t,e){e.definitions_.import_gc="import gc";return["gc.mem_free()",e.ORDER_ATOMIC]},Ma=function(t,e){e.definitions_.import_machine="import machine";return["machine.unique_id()",e.ORDER_ATOMIC]},Ca=xa,Na=function(t,e){return e.definitions_.import_datetime="import datetime",["datetime.datetime.fromtimestamp("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},ka=function(t,e){var n=Zt.Boards.getSelectedBoardKey().split(":")[2];e.definitions_["import_"+n+"uuid"]="from "+n+" import uuid";return["uuid()",e.ORDER_ATOMIC]},Da=function(t,e){var n=this.getFieldValue("NUM");return[n,n<0?e.ORDER_UNARY_PREFIX:e.ORDER_ATOMIC]},La=function(t,e){return e.definitions_.import_math="import math",["math."+this.getFieldValue("CONSTANT"),e.ORDER_ATOMIC]},Fa=function(t,e){return e.definitions_.import_math="import math",["math."+this.getFieldValue("CONSTANT"),e.ORDER_ATOMIC]},Pa=function(t,e){var n=this.getFieldValue("OP"),i=e.ORDER_ATOMIC;return["("+(e.valueToCode(this,"A",i)||"0")+n+(e.valueToCode(this,"B",i)||"0")+")",i]},$a=function(t,e){var n=(i={ADD:[" + ",e.ORDER_ADDITIVE],MINUS:[" - ",e.ORDER_ADDITIVE],MULTIPLY:[" * ",e.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",e.ORDER_MULTIPLICATIVE],QUYU:[" % ",e.ORDER_MULTIPLICATIVE],ZHENGCHU:[" // ",e.ORDER_MULTIPLICATIVE],POWER:[" ** ",e.ORDER_EXPONENTIATION]}[t.getFieldValue("OP")])[0],i=i[1];return[(e.valueToCode(t,"A",i)||"0")+n+(t=e.valueToCode(t,"B",i)||"0"),i]},Ba=function(t,e){var n=e.valueToCode(this,"A",e.ORDER_RELATIONAL)||"0",i=e.valueToCode(this,"B",e.ORDER_RELATIONAL)||"0";switch(this.getFieldValue("OP")){case"ADD":var s="+=";break;case"MINUS":s="-=";break;case"MULTIPLY":s="*=";break;case"DIVIDE":s="/=";break;case"QUYU":s="%=";break;case"ZHENGCHU":s="//=";break;case"POWER":s="**="}return n+" "+s+" "+i+"\n"},Va=function(t,e){var n,i=t.getFieldValue("OP");if("NEG"==i)return["-"+(n=e.valueToCode(t,"NUM",e.ORDER_UNARY_SIGN)||"0"),e.ORDER_UNARY_SIGN];switch(e.definitions_.import_math="import math",t="SIN"==i||"COS"==i||"TAN"==i?e.valueToCode(t,"NUM",e.ORDER_MULTIPLICATIVE)||"0":e.valueToCode(t,"NUM",e.ORDER_NONE)||"0",i){case"ABS":n="math.fabs("+t+")";break;case"ROOT":n="math.sqrt("+t+")";break;case"LN":n="math.log("+t+")";break;case"LOG10":n="math.log10("+t+")";break;case"EXP":n="math.exp("+t+")";break;case"POW10":n="math.pow(10,"+t+")";break;case"ROUND":n="round("+t+")";break;case"ROUNDUP":n="math.ceil("+t+")";break;case"ROUNDDOWN":n="math.floor("+t+")";break;case"SIN":n="math.sin("+t+")";break;case"COS":n="math.cos("+t+")";break;case"TAN":n="math.tan("+t+")";break;case"++":n="++("+t+")";break;case"--":n="--("+t+")";break;case"-":n="-("+t+")"}if(n)return[n,e.ORDER_EXPONENTIATION];switch(i){case"ASIN":n="math.degrees(math.asin("+t+"))";break;case"ACOS":n="math.degrees(math.acos("+t+"))";break;case"ATAN":n="math.degrees(math.atan("+t+"))"}return[n,e.ORDER_MULTIPLICATIVE]},Ua=Va,Ya=function(t,e){var n=e.valueToCode(this,"NUM",e.ORDER_NONE)||"0";return[this.getFieldValue("OP")+"("+n+")",e.ORDER_ATOMIC]},Ga=function(t,e){var n=e.valueToCode(this,"A",e.ORDER_NONE)||"0",i=this.getFieldValue("OP"),s="";return"round"===i?s=i+"("+n+")":(s="math."+i+"("+n+")",e.definitions_.import_math="import math"),[s,e.ORDER_ATOMIC]},Ha=function(t,e){var n=e.valueToCode(this,"A",e.ORDER_NONE)||"0",i=e.valueToCode(this,"B",e.ORDER_NONE)||"0";return[this.getFieldValue("OP")+"("+n+", "+i+")",e.ORDER_ATOMIC]},Wa=function(t,e){e.definitions_.import_random="import random";var n=this.getFieldValue("TYPE"),i=e.valueToCode(this,"FROM",e.ORDER_NONE)||"0",s=e.valueToCode(this,"TO",e.ORDER_NONE)||"0";if("int"==n)var r="random.randint("+i+", "+s+")";else if("float"==n)r="random.uniform("+i+", "+s+")";return[r,e.ORDER_UNARY_POSTFIX]},za=function(t,e){var n=e.valueToCode(this,"NUM",e.ORDER_NONE),i=e.valueToCode(this,"fromLow",e.ORDER_ATOMIC),s=e.valueToCode(this,"fromHigh",e.ORDER_ATOMIC),r=e.valueToCode(this,"toLow",e.ORDER_ATOMIC),a=e.valueToCode(this,"toHigh",e.ORDER_ATOMIC);return e.definitions_.import_mixpy_math_map="from mixpy import math_map",["math_map("+n+", "+i+", "+s+", "+r+", "+a+")",e.ORDER_NONE]},Xa=function(t,e){return["min(max("+(e.valueToCode(this,"VALUE",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"LOW",e.ORDER_NONE)||"0")+"), "+(e.valueToCode(this,"HIGH",e.ORDER_NONE)||"0")+")",e.ORDER_UNARY_POSTFIX]},ja=function(t,e){var n=t.getFieldValue("OP"),i=e.valueToCode(this,"NUM",e.ORDER_NONE)||"0",s=t.getFieldValue("OP2");e.definitions_.import_math="import math";var r="",a="10";if("two"==n?a="2":"eight"==n?a="8":"ten"==n?a="10":"sixteen"==n&&(a="16"),"two"==s?r="bin":"eight"==s?r="oct":"ten"==s?r="":"sixteen"==s&&(r="hex"),""==r)var o="int(str("+i+"), "+a+")";else o=r+"(int(str("+i+"), "+a+"))";return[o,e.ORDER_ATOMIC]},qa=function(t,e){return e.definitions_.import_random="import random","random.seed("+(e.valueToCode(this,"NUM",e.ORDER_NONE)||"0")+");\n"},Ka=function(t,e){var n=this.getFieldValue("NUM");return[n,n<0?e.ORDER_UNARY_PREFIX:e.ORDER_ATOMIC]},Qa=function(t,e){return["round("+(e.valueToCode(this,"VALUE",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"VAR",e.ORDER_NONE)||"0")+")",e.ORDER_ATOMIC]},Ja=function(t,e){var n=this.getFieldValue("TOWHAT"),i=e.valueToCode(this,"VAR",e.ORDER_ATOMIC);return"b"==n?[i+'.encode("utf-8")',e.ORDER_ATOMIC]:"bti"==n?["int.from_bytes("+i+',"big")',e.ORDER_ATOMIC]:[n+"("+i+")",e.ORDER_ATOMIC]},Za=function(t,e){var n=this.getFieldValue("TOWHAT"),i=e.valueToCode(this,"VAR",e.ORDER_ATOMIC);return"b"==n?[i+'.encode("utf-8")',e.ORDER_ATOMIC]:[n+"("+i+")",e.ORDER_ATOMIC]},to=za,eo=function(t,e){return e.definitions_.import_hexlify="from ubinascii import hexlify",["hexlify("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+").decode()",e.ORDER_ATOMIC]},no=function(t,e){e.definitions_.import_itertools="import itertools";let n=e.valueToCode(this,"REPEAT",e.ORDER_ATOMIC),i=new Array(this.itemCount_);for(let t=0;t<this.itemCount_;t++)i[t]=e.valueToCode(this,`ADD${t}`,e.ORDER_NONE)||"0";let s="";return this.itemCount_&&(s=`itertools.product(${i.join(", ")}, repeat=${n})`),[s,e.ORDER_ATOMIC]},io=function(t,e){return e.definitions_.import_math="import math",["math.degrees("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},so=function(t,e){return e.definitions_.import_math="import math",["math.radians("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},ro=function(t,e){return[e.quote_(this.getFieldValue("TEXT")),e.ORDER_ATOMIC]},ao=function(t,e){return['"""'+this.getFieldValue("VALUE")+'"""',e.ORDER_ATOMIC]},oo=function(t,e){return["'"+this.getFieldValue("TEXT")+"'",e.ORDER_ATOMIC]},lo=function(t,e){return[e.valueToCode(this,"A",e.ORDER_ATOMIC)+" + "+e.valueToCode(this,"B",e.ORDER_ATOMIC),e.ORDER_ADDITIVE]},uo=function(t,e){return["chr("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0")+")",e.ORDER_ATOMIC]},ho=function(t,e){return["ord("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"a")+")",e.ORDER_ATOMIC]},po=function(t,e){return["str("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0")+")",e.ORDER_ATOMIC]},co=function(t,e){return["len("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+")",e.ORDER_ATOMIC]},fo=function(t,e){var n=t.getFieldValue("WHERE")||"FROM_START",i=e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""';switch(n){case"FROM_START":return[i+"["+(t=e.getAdjustedInt(t,"AT"))+"]",e.ORDER_ATOMIC];case"FROM_END":return[i+"["+(t=e.getAdjustedInt(t,"AT",1,!0))+"]",e.ORDER_ATOMIC];case"RANDOM":return e.definitions_.import_random="import random",["random.choice("+i+")",e.ORDER_FUNCTION_CALL]}throw"Unhandled combination (lists_getIndex)."},mo=function(t,e){return[(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+"["+(e.valueToCode(this,"AT",e.ORDER_ATOMIC)||0)+"]",e.ORDER_ATOMIC]},go=function(t,e){var n=e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""';return e.definitions_.import_random="import random",["random.choice("+n+")",e.ORDER_FUNCTION_CALL]},_o=function(t,e){var n=e.valueToCode(this,"STR1",e.ORDER_ATOMIC)||'""',i=e.valueToCode(this,"STR2",e.ORDER_ATOMIC)||'""',s=this.getFieldValue("DOWHAT");return"==="===s?[n+" == "+i,e.ORDER_ATOMIC]:[n+"."+s+"("+i+")",e.ORDER_ATOMIC]},To=function(t,e){return["cmp("+(e.valueToCode(this,"STR1",e.ORDER_ATOMIC)||'""')+","+(e.valueToCode(this,"STR2",e.ORDER_ATOMIC)||'""')+")",e.ORDER_ATOMIC]},yo=function(t,e){var n=e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""',i=t.getFieldValue("WHERE1"),s=t.getFieldValue("WHERE2");switch(i){case"FROM_START":"0"==(r=e.getAdjustedInt(t,"AT1"))&&(r="");break;case"FROM_END":var r=e.getAdjustedInt(t,"AT1",0,!0);break;case"FIRST":r="0";break;default:throw"Unhandled option (lists_getSublist)"}switch(s){case"FROM_START":var a=e.getAdjustedInt(t,"AT2");break;case"FROM_END":a=e.getAdjustedInt(t,"AT2",0,!0);Jt.isNumber(String(a))?"0"==a&&(a=""):(e.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case"LAST":a="-1";break;default:throw"Unhandled option (lists_getSublist)"}return[n+"["+r+" : "+a+"]",e.ORDER_ATOMIC]},Io=function(t,e){return[(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+"["+e.valueToCode(this,"AT1",e.ORDER_ATOMIC)+" : "+e.valueToCode(this,"AT2",e.ORDER_ATOMIC)+"]",e.ORDER_ATOMIC]},Eo=function(t,e){var n=this.getFieldValue("CAPITAL");return[e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+"."+n+"()",e.ORDER_ATOMIC]},bo=function(t,e){var n=this.getFieldValue("CENTER");return[e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+"."+n+"("+e.valueToCode(this,"WID",e.ORDER_ATOMIC)+","+e.valueToCode(this,"Symbol",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},vo=function(t,e){return[e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+".find("+e.valueToCode(this,"STR",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},wo=function(t,e){return[e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+".join("+(e.valueToCode(this,"LIST",e.ORDER_ASSIGNMENT)||"0")+")",e.ORDER_ATOMIC]},So=function(t,e){return[e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+".replace("+e.valueToCode(this,"STR1",e.ORDER_ATOMIC)+","+e.valueToCode(this,"STR2",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},xo=function(t,e){return[(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+".split("+(e.valueToCode(this,"VAL",e.ORDER_ATOMIC)||'""')+")",e.ORDER_ATOMIC]},Ro=function(t,e){var n=this.getFieldValue("TOWHAT");return[e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+"."+n+"()",e.ORDER_ATOMIC]},Oo=function(t,e){for(var n=this.getFieldValue("VAR"),i=new Array(this.itemCount_),s=0;s<this.itemCount_;s++)i[s]=e.valueToCode(this,"ADD"+s,e.ORDER_NONE)||"0";return[i=n+".format("+i.join(", ")+")",e.ORDER_ATOMIC]},Ao=function(t,e){for(var n=e.valueToCode(this,"VAR",e.ORDER_ATOMIC),i=new Array(this.itemCount_),s=0;s<this.itemCount_;s++)i[s]=e.valueToCode(this,"ADD"+s,e.ORDER_NONE)||"0";return[i=n+".format("+i.join(", ")+")",e.ORDER_ATOMIC]},Mo=Io,Co=To,No=mo,ko=function(t,e){var n=this.getFieldValue("DIR"),i=this.getFieldValue("CODE");return[(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+"."+n+'("'+i+'")',e.ORDER_ATOMIC]},Do=function(t,e){return["eval("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},Lo=function(t,e){return e.definitions_.import_os="import os","os.system("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},Fo=function(t,e){return[(e.valueToCode(this,"LIST",e.ORDER_ADDITIVE)||"mylist")+"["+e.valueToCode(this,"AT1",e.ORDER_ADDITIVE)+" : "+e.valueToCode(this,"AT2",e.ORDER_ADDITIVE)+"]",e.ORDER_ATOMIC]},Po=function(t,e){return[(e.valueToCode(this,"LIST",e.ORDER_ATOMIC)||"mylist")+"["+(e.valueToCode(this,"row",e.ORDER_ATOMIC)||0)+","+(e.valueToCode(this,"col",e.ORDER_ATOMIC)||0)+"]",e.ORDER_ATOMIC]},$o=function(t,e){return[(e.valueToCode(this,"LIST",e.ORDER_ATOMIC)||"mylist")+"["+(e.valueToCode(this,"row_start",e.ORDER_ATOMIC)||0)+" : "+(e.valueToCode(this,"row_end",e.ORDER_ATOMIC)||1)+","+(e.valueToCode(this,"col_start",e.ORDER_ATOMIC)||0)+" : "+(e.valueToCode(this,"col_end",e.ORDER_ATOMIC)||1)+"]",e.ORDER_ATOMIC]},Bo=function(t,e){for(var n=e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE),i=new Array(this.itemCount_),s=0;s<this.itemCount_;s++)i[s]=e.valueToCode(this,"ADD"+s,e.ORDER_NONE)||"0";return i=n+" = ["+i.join(", ")+"]\n"},Vo=function(t,e){return e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+" = ["+this.getFieldValue("TEXT")+"]\n"},Uo=function(t,e){return[(e.valueToCode(this,"LIST",e.ORDER_ADDITIVE)||"mylist")+"["+(e.valueToCode(this,"AT",e.ORDER_ADDITIVE)||0)+"]",e.ORDER_ATOMIC]},Yo=function(t,e){return(e.valueToCode(this,"LIST",e.ORDER_ADDITIVE)||"mylist")+"["+(e.valueToCode(this,"AT",e.ORDER_ADDITIVE)||"0")+"] = "+(e.valueToCode(this,"TO",e.ORDER_ASSIGNMENT)||"0")+"\n"},Go=function(t,e){var n=e.valueToCode(this,"LIST",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"DATA",e.ORDER_ASSIGNMENT)||"0";return n+"."+this.getFieldValue("OP")+"("+i+")\n"},Ho=function(t,e){return e.definitions_.import_random="import random",["random.choice("+(e.valueToCode(this,"LIST",e.ORDER_ADDITIVE)||"mylist")+")",e.ORDER_ATOMIC]},Wo=function(t,e){return e.definitions_.import_random="import random",["random.sample("+(e.valueToCode(this,"LIST",e.ORDER_ADDITIVE)||"mylist")+","+(e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0")+")",e.ORDER_ATOMIC]},zo=function(t,e){return(e.valueToCode(this,"LIST",e.ORDER_ASSIGNMENT)||"0")+".insert("+(e.valueToCode(this,"AT",e.ORDER_ADDITIVE)||"0")+", "+(e.valueToCode(this,"VALUE",e.ORDER_ASSIGNMENT)||"0")+")\n"},Xo=function(t,e){return(e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0")+".reverse()\n"},jo=function(t,e){return(e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0")+".clear()\n"},qo=function(t,e){var n=this.getFieldValue("OP"),i=e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0",s=e.valueToCode(this,"data",e.ORDER_ASSIGNMENT)||"0";if("INDEX"==n)var r=i+".index("+s+")";else if("COUNT"==n)r=i+".count("+s+")";return[r,e.ORDER_ATOMIC]},Ko=function(t,e){var n=e.valueToCode(this,"LIST",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"DATA",e.ORDER_ASSIGNMENT)||"0";return"del"==this.getFieldValue("OP")?"del "+n+"["+i+"]\n":n+".remove("+i+")\n"},Qo=function(t,e){return[(e.valueToCode(this,"LIST",e.ORDER_ADDITIVE)||"mylist")+".pop("+(e.valueToCode(this,"VALUE",e.ORDER_ASSIGNMENT)||"0")+")",e.ORDER_ATOMIC]},Jo=function(t,e){var n,i=t.getFieldValue("OP");switch(e.definitions_.import_math="import math",t=e.valueToCode(t,"data",e.ORDER_NONE),i){case"LEN":n="len("+t+")";break;case"SUM":n="sum("+t+")";break;case"MIN":n="min("+t+")";break;case"MAX":n="max("+t+")";break;case"AVERAGE":e.definitions_.import_mixpy_math_mean="from mixpy import math_mean",n="math_mean("+t+")";break;case"MEDIAN":e.definitions_.import_mixpy_math_median="from mixpy import math_median",n="math_median("+t+")";break;case"MODE":e.definitions_.import_mixpy_math_modes="from mixpy import math_modes",n="math_modes("+t+")";break;case"STD_DEV":e.definitions_.import_mixpy_math_standard_deviation="from mixpy import math_standard_deviation",n="math_standard_deviation("+t+")";break;default:throw"Unknown operator: "+i}if(n)return[n,e.ORDER_ATOMIC]},Zo=function(t,e){return e.definitions_.import_mixpy_lists_sort="from mixpy import lists_sort",["lists_sort("+(e.valueToCode(t,"LIST",e.ORDER_NONE)||"[]")+', "'+t.getFieldValue("TYPE")+'", '+("1"===t.getFieldValue("DIRECTION")?"False":"True")+")",e.ORDER_ATOMIC]},tl=function(t,e){var n=this.getFieldValue("OP"),i=e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0",s="";return"array"==n?(e.definitions_.import_numpy="import numpy",s="numpy.array("+i+")"):s=n+"("+i+")",[s,e.ORDER_ATOMIC]},el=function(t,e){return["["+this.getFieldValue("CONTENT")+"]",e.ORDER_ATOMIC]},nl=function(t,e){for(var n=new Array(this.itemCount_),i=0;i<this.itemCount_;i++)n[i]=e.valueToCode(this,"ADD"+i,e.ORDER_NONE)||"0";return[n="["+n.join(", ")+"]",e.ORDER_ATOMIC]},il=tl,sl=function(t,e){return"del "+(e.valueToCode(this,"TUP",e.ORDER_ASSIGNMENT)||"0")+"\n"},rl=Bo,al=Vo,ol=Uo,ll=Fo,ul=Yo,hl=zo,pl=Ko,cl=function(t,e){return["list("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0")+")",e.ORDER_ATOMIC]},dl=function(t,e){return[(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0")+".tolist()",e.ORDER_ATOMIC]},fl=function(t,e){return["enumerate("+(e.valueToCode(this,"LIST",e.ORDER_ADDITIVE)||"mylist")+",start="+(e.valueToCode(this,"VALUE",e.ORDER_ASSIGNMENT)||"0")+")",e.ORDER_ATOMIC]},ml=function(t,e){var n=e.valueToCode(this,"LIST",e.ORDER_ADDITIVE)||"mylist";return[(e.valueToCode(this,"CON",e.ORDER_ASSIGNMENT)||"0")+" in "+n,e.ORDER_ATOMIC]},gl=function(t,e){for(var n=e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE),i=new Array(this.itemCount_),s=0;s<this.itemCount_;s++){var r=this.getFieldValue("KEY"+s);i[s]=r+":"+(e.valueToCode(this,"ADD"+s,e.ORDER_NONE)||"0")}return i=n+"= {"+i.join(", ")+"}\n"},_l=function(t,e){return[(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+".keys()",e.ORDER_ATOMIC]},Tl=function(t,e){var n=Zt.Boards.getSelectedBoardKey().split(":")[2],i=e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0",s=e.valueToCode(this,"KEY",e.ORDER_ASSIGNMENT);if("educore"==n)var r=i+".get("+s+")";else r=i+"["+s+"]";return[r,e.ORDER_ATOMIC]},yl=function(t,e){return[(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+".get("+e.valueToCode(this,"KEY",e.ORDER_ASSIGNMENT)+","+(e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0")+")",e.ORDER_ATOMIC]},Il=function(t,e){return(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"mydict")+"["+e.valueToCode(this,"KEY",e.ORDER_ASSIGNMENT)+"] = "+(e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0")+"\n"},El=function(t,e){return"del "+(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"mydict")+"["+e.valueToCode(this,"KEY",e.ORDER_ASSIGNMENT)+"]\n"},bl=function(t,e){var n=e.valueToCode(this,"DICT2",e.ORDER_ASSIGNMENT)||"0";return(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+".update("+n+")\n"},vl=function(t,e){return(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+".clear()\n"},wl=function(t,e){return[(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+".items()",e.ORDER_ATOMIC]},Sl=function(t,e){return[(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+".values()",e.ORDER_ATOMIC]},xl=function(t,e){return["len("+(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+")",e.ORDER_ATOMIC]},Rl=function(t,e){return"del "+(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+"\n"},Ol=function(t,e){var n=e.valueToCode(t,"DICT",e.ORDER_MEMBER)||"[]",i=t.getFieldValue("WHERE"),s=e.valueToCode(this,"KEY",e.ORDER_ASSIGNMENT);switch(i){case"INSERT":var r=n+"["+s+"] = "+(e.valueToCode(this,"AT2",e.ORDER_ASSIGNMENT)||"0")+"\n";break;case"DELETE":r="del "+n+"["+s+"]\n";break;default:throw"Unhandled option (lists_setIndex2)"}return r},Al=function(t,e){return[(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+".pop("+e.valueToCode(this,"KEY",e.ORDER_ASSIGNMENT)+")",e.ORDER_ATOMIC]},Ml=function(t,e){return(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"mydict")+".setdefault("+e.valueToCode(this,"KEY",e.ORDER_ASSIGNMENT)+","+(e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0")+")\n"},Cl=function(t,e){for(var n=new Array(this.itemCount_),i=0;i<this.itemCount_;i++){var s=this.getFieldValue("KEY"+i);n[i]=s+": "+(e.valueToCode(this,"ADD"+i,e.ORDER_NONE)||"0")}return[n="{"+n.join(", ")+"}",e.ORDER_ATOMIC]},Nl=function(t,e){return["dict("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0")+")",e.ORDER_ATOMIC]},kl=function(t,e){return e.definitions_.import_json="import json",["json.dumps("+(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+")",e.ORDER_ATOMIC]},Dl=function(t,e){return e.definitions_.import_json="import json",["json.loads("+(e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"null")+")",e.ORDER_ATOMIC]},Ll=function(t,e){return[(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+"["+(e.valueToCode(this,"VAR1",e.ORDER_ASSIGNMENT)||"null")+"]["+(e.valueToCode(this,"VAR2",e.ORDER_ASSIGNMENT)||"null")+"]["+(e.valueToCode(this,"VAR3",e.ORDER_ASSIGNMENT)||"null")+"]["+(e.valueToCode(this,"VAR4",e.ORDER_ASSIGNMENT)||"null")+"]",e.ORDER_ATOMIC]},Fl=function(t,e){return e.definitions_.import_json="import json",e.definitions_.import_ujson="import ujson",["ujson.loads("+(e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0")+")",e.ORDER_ATOMIC]},Pl=function(t,e){var n=this.getFieldValue("OP"),i=Pl.OPERATORS[n],s="=="==i||"!="==i?e.ORDER_EQUALITY:e.ORDER_RELATIONAL;return[(e.valueToCode(this,"A",s)||"0")+" "+i+" "+(e.valueToCode(this,"B",s)||"0"),s]},$l=function(t,e){var n=this.getFieldValue("OP1"),i=Pl.OPERATORS[n],s=this.getFieldValue("OP2"),r=Pl.OPERATORS[s];return[(e.valueToCode(this,"A",e.ORDER_RELATIONAL)||"0")+" "+i+" "+(e.valueToCode(this,"B",e.ORDER_RELATIONAL)||"0")+" "+r+" "+(e.valueToCode(this,"C",e.ORDER_RELATIONAL)||"0"),e.ORDER_RELATIONAL]};Pl.OPERATORS={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="};const Bl=function(t,e){var n=this.getFieldValue("OP"),i="&&"==n?e.ORDER_LOGICAL_AND:e.ORDER_LOGICAL_OR,s=e.valueToCode(this,"A",i)||"False",r=e.valueToCode(this,"B",i)||"False";if("AND"==n)var a=s+" and "+r;else if("OR"==n)a=s+" or "+r;else if("NOR"==n)a="not("+s+"^"+r+")";else a=s+"^"+r;return[a,i]},Vl=function(t,e){var n=e.ORDER_UNARY_PREFIX;return["not "+(e.valueToCode(this,"BOOL",n)||"False"),n]},Ul=function(t,e){return["TRUE"==this.getFieldValue("BOOL")?"True":"False",e.ORDER_ATOMIC]},Yl=function(t,e){return["None",e.ORDER_ATOMIC]},Gl=function(t,e){var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"False";return["("+(e.valueToCode(this,"B",e.ORDER_ATOMIC)||"False")+" if "+n+" else "+(e.valueToCode(this,"C",e.ORDER_ATOMIC)||"False")+")",e.ORDER_ATOMIC]},Hl=function(t,e){var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''",i=e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''";return[n+" "+this.getFieldValue("BOOL")+" "+i,e.ORDER_ATOMIC]},Wl=function(t,e){var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''",i=e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''";return[n+" "+this.getFieldValue("BOOL")+" "+i,e.ORDER_ATOMIC]},zl=function(t,e){return["bool("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0")+")",e.ORDER_ATOMIC]},Xl=function(t,e){return e.definitions_.import_os="import os","os.startfile("+e.valueToCode(this,"fn",e.ORDER_ATOMIC)+")\n"},jl=function(t,e){return e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+" = open("+e.valueToCode(this,"FILENAME",e.ORDER_ATOMIC)+", '"+this.getFieldValue("MODE")+"')\n"},ql=function(t,e){return["open("+e.valueToCode(this,"FILENAME",e.ORDER_ATOMIC)+", '"+this.getFieldValue("MODE")+"')",e.ORDER_ATOMIC]},Kl=function(t,e){return["open("+e.valueToCode(this,"FILENAME",e.ORDER_ATOMIC)+", '"+this.getFieldValue("MODE")+"', encoding=\""+this.getFieldValue("CODE")+'")',e.ORDER_ATOMIC]},Ql=function(t,e){var n=e.valueToCode(this,"data",e.ORDER_ATOMIC);return e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".write("+n+")\n"},Jl=function(t,e){var n=this.getFieldValue("MODE");return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+"."+n+"()",e.ORDER_ATOMIC]},Zl=function(t,e){var n=this.getFieldValue("MODE");return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+"."+n+"("+e.valueToCode(this,"SIZE",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},tu=function(t,e){return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".readline("+e.valueToCode(this,"SIZE",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},eu=function(t,e){return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".writable()",e.ORDER_ATOMIC]},nu=function(t,e){return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".name()",e.ORDER_ATOMIC]},iu=function(t,e){return e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".close()\n"},su=function(t,e){e.definitions_.import_os="import os";return["os.listdir()",e.ORDER_ATOMIC]},ru=function(t,e){return e.definitions_.import_os="import os","os."+this.getFieldValue("MODE")+"("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")\n"},au=function(t,e){return e.definitions_.import_os="import os",["os.path.getsize("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},ou=function(t,e){return[e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".tell()",e.ORDER_ATOMIC]},lu=function(t,e){var n=this.getFieldValue("MODE"),i=0;return i="start"==n?0:"current"==n?1:2,e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+".seek("+e.valueToCode(this,"SIZE",e.ORDER_ATOMIC)+","+i+")\n"},uu=function(t,e){return e.definitions_.import_os="import os","os.chdir("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")\n"},hu=function(t,e){e.definitions_.import_os="import os";return["os.getcwd()",e.ORDER_ATOMIC]},pu=function(t,e){return e.definitions_.import_os="import os","os."+this.getFieldValue("MODE")+"("+e.valueToCode(this,"PATH",e.ORDER_ATOMIC)+")\n"},cu=function(t,e){return e.definitions_.import_os="import os","os.rename("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+","+e.valueToCode(this,"NEWFILE",e.ORDER_ATOMIC)+")\n"},du=function(t,e){e.definitions_.import_os="import os";var n=e.valueToCode(this,"FILE",e.ORDER_ATOMIC);return["os."+this.getFieldValue("MODE")+"("+n+")",e.ORDER_ATOMIC]},fu=function(t,e){return e.definitions_.import_os="import os",e.definitions_.import_sdcard="import sdcard",e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+" = sdcard.SDCard("+e.valueToCode(this,"SPISUB",e.ORDER_ATOMIC)+","+e.valueToCode(this,"PINSUB",e.ORDER_ATOMIC)+")\n"},mu=function(t,e){return e.definitions_.import_os="import os",e.definitions_.import_sdcard="import sdcard","os.mount("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+","+e.valueToCode(this,"DIR",e.ORDER_ATOMIC)+")\n"},gu=function(t,e){var n=e.variableDB_.getName(this.getFieldValue("NAME"),Jt.Procedures.NAME_TYPE),i=(this.getInput("STACK")&&e.statementToCode(this,"STACK"))??" pass\n";e.INFINITE_LOOP_TRAP&&(i=e.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+this.id+"'")+i);var s=e.valueToCode(this,"RETURN",e.ORDER_NONE)||"";s&&(s=" return "+s+"\n");for(var r=[],a=0;a<this.arguments_.length;a++){var o=e.variableDB_.getName(this.arguments_[a],Jt.Variables.NAME_TYPE);r[a]=o}var l="def "+n+"("+r.join(", ")+"):\n"+i+s+"\n";return l=e.scrub_(this,l),e.setups_[n]=l,null},_u=function(t,e){var n=e.variableDB_.getName(this.getFieldValue("NAME"),Jt.Procedures.NAME_TYPE),i=(this.getInput("STACK")&&e.statementToCode(this,"STACK"))??" pass\n";e.INFINITE_LOOP_TRAP&&(i=e.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+this.id+"'")+i);for(var s=[],r=0;r<this.arguments_.length;r++){var a=e.variableDB_.getName(this.arguments_[r],Jt.Variables.NAME_TYPE);s[r]=a}var o="def "+n+"("+s.join(", ")+"):\n"+i+"\n";return o=e.scrub_(this,o),e.setups_[n]=o,null},Tu=function(t,e){for(var n=e.variableDB_.getName(this.getFieldValue("NAME"),Jt.Procedures.NAME_TYPE),i=[],s=0;s<this.arguments_.length;s++)i[s]=e.valueToCode(this,"ARG"+s,e.ORDER_NONE)||"null";return[n+"("+i.join(", ")+")",e.ORDER_UNARY_POSTFIX]},yu=function(t,e){for(var n=e.variableDB_.getName(this.getFieldValue("NAME"),Jt.Procedures.NAME_TYPE),i=[],s=0;s<this.arguments_.length;s++)i[s]=e.valueToCode(this,"ARG"+s,e.ORDER_NONE)||"null";return n+"("+i.join(", ")+")\n"},Iu=function(t,e){var n="if ("+(e.valueToCode(this,"CONDITION",e.ORDER_NONE)||"False")+") :\n";this.hasReturnValue_?n+=" return "+(e.valueToCode(this,"VALUE",e.ORDER_NONE)||"None"):n+=" return None";return n+="\n"},Eu=function(t,e){var n="";this.hasReturnValue_?n+="return "+(e.valueToCode(this,"VALUE",e.ORDER_NONE)||"None"):n+="return None";return n+="\n"},bu=function(t,e){for(var n=e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE),i=new Array(this.itemCount_),s=0;s<this.itemCount_;s++)i[s]=e.valueToCode(this,"ADD"+s,e.ORDER_NONE)||"0";if(1!=this.itemCount_)i=n+"= ("+i.join(", ")+")\n";else i=n+"= ("+i.join(", ")+",)\n";return i},vu=function(t,e){return e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+"= ("+this.getFieldValue("TEXT")+")\n"},wu=function(t,e){return["("+this.getFieldValue("TEXT")+")",e.ORDER_ATOMIC]},Su=function(t,e){var n=e.valueToCode(this,"TUP",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"AT",e.ORDER_ADDITIVE)||"1";return i.match(/^\d+$/)&&(i=parseInt(i,10)),[n+"["+i+"]",e.ORDER_ATOMIC]},xu=function(t,e){return["len("+(e.valueToCode(this,"TUP",e.ORDER_ASSIGNMENT)||"0")+")",e.ORDER_ATOMIC]},Ru=function(t,e){return"del "+(e.valueToCode(this,"TUP",e.ORDER_ASSIGNMENT)||"0")+"\n"},Ou=function(t,e){return[(e.valueToCode(this,"TUP1",e.ORDER_ASSIGNMENT)||"0")+" + "+(e.valueToCode(this,"TUP2",e.ORDER_ASSIGNMENT)||"0"),e.ORDER_ATOMIC]},Au=function(t,e){var n=e.valueToCode(this,"TUP",e.ORDER_ASSIGNMENT)||"0";return[this.getFieldValue("DIR")+"("+n+")",e.ORDER_ATOMIC]},Mu=function(t,e){return[this.getFieldValue("OP")+"("+(e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0")+")\n",e.ORDER_ATOMIC]},Cu=function(t,e){var n=this.getFieldValue("OP"),i=e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0",s=e.valueToCode(this,"data",e.ORDER_ASSIGNMENT)||"0";if("INDEX"==n)var r=i+".index("+s+")";else if("COUNT"==n)r=i+".count("+s+")";return[r,e.ORDER_ATOMIC]},Nu=function(t,e){var n,i=t.getFieldValue("OP");switch(e.definitions_.import_math="import math",t=e.valueToCode(t,"data",e.ORDER_NONE),i){case"LEN":n="len("+t+")";break;case"SUM":n="sum("+t+")";break;case"MIN":n="min("+t+")";break;case"MAX":n="max("+t+")";break;case"AVERAGE":n=e.provideFunction_("math_mean",["def "+e.FUNCTION_NAME_PLACEHOLDER_+"(myList):"," localList = [e for e in myList if type(e) == int or type(e) == float]"," if not localList: return"," return float(sum(localList)) / len(localList)"])+"("+t+")";break;case"MEDIAN":n=e.provideFunction_("math_median",["def "+e.FUNCTION_NAME_PLACEHOLDER_+"(myList):"," localList = sorted([e for e in myList if type(e) == int or type(e) == float])"," if not localList: return"," if len(localList) % 2 == 0:"," return (localList[len(localList) // 2 - 1] + localList[len(localList) // 2]) / 2.0"," else:"," return localList[(len(localList) - 1) // 2]"])+"("+t+")";break;case"MODE":n=e.provideFunction_("math_modes",["def "+e.FUNCTION_NAME_PLACEHOLDER_+"(some_list):"," modes = []"," # Using a lists of [item, count] to keep count rather than dict",' # to avoid "unhashable" errors when the counted item is itself a list or dict.'," counts = []"," maxCount = 1"," for item in some_list:"," found = False"," for count in counts:"," if count[0] == item:"," count[1] += 1"," maxCount = max(maxCount, count[1])"," found = True"," if not found:"," counts.append([item, 1])"," for counted_item, item_count in counts:"," if item_count == maxCount:"," modes.append(counted_item)"," return modes"])+"("+t+")";break;case"STD_DEV":e.definitions_.import_math="import math",n=e.provideFunction_("math_standard_deviation",["def "+e.FUNCTION_NAME_PLACEHOLDER_+"(numbers):"," n = len(numbers)"," if n == 0: return"," mean = float(sum(numbers)) / n"," variance = sum((x - mean) ** 2 for x in numbers) / n"," return math.sqrt(variance)"])+"("+t+")";break;default:throw"Unknown operator: "+i}if(n)return[n,e.ORDER_FUNCTION_CALL]},ku=function(t,e){var n=e.valueToCode(t,"LIST",e.ORDER_MEMBER)||"[]",i=t.getFieldValue("WHERE1"),s=t.getFieldValue("WHERE2");switch(i){case"FROM_START":"0"==(r=e.getAdjustedInt(t,"AT1"))&&(r="");break;case"FROM_END":var r=e.getAdjustedInt(t,"AT1",1,!0);break;case"FIRST":r="0";break;default:throw"Unhandled option (lists_getSublist)"}switch(s){case"FROM_START":var a=e.getAdjustedInt(t,"AT2",1);a-=1;break;case"FROM_END":a=e.getAdjustedInt(t,"AT2",1,!0);Jt.isNumber(String(a))?"0"==a&&(a=""):(e.definitions_.import_sys="import sys",a+=" or sys.maxsize");break;case"LAST":a="-1";break;default:throw"Unhandled option (lists_getSublist)"}return[n+"["+r+" : "+a+"]",e.ORDER_MEMBER]},Du=function(t,e){for(var n=new Array(this.itemCount_),i=0;i<this.itemCount_;i++)n[i]=e.valueToCode(this,"ADD"+i,e.ORDER_NONE)||"0";if(1!=this.itemCount_)n="("+n.join(", ")+")";else n="("+n.join(", ")+",)";return[n,e.ORDER_ATOMIC]},Lu=function(t,e){return[(e.valueToCode(this,"LIST",e.ORDER_ADDITIVE)||"0")+"["+(e.valueToCode(this,"AT1",e.ORDER_ADDITIVE)||"0")+" : "+(e.valueToCode(this,"AT2",e.ORDER_ADDITIVE)||"0")+"]",e.ORDER_ATOMIC]},Fu=function(t,e){return e.definitions_.import_random="import random",["random.choice("+(e.valueToCode(this,"TUP",e.ORDER_ADDITIVE)||"mytup")+")",e.ORDER_ATOMIC]},Pu=function(t,e){return["tuple("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0")+")",e.ORDER_ATOMIC]},$u=function(t,e){return["("+this.getFieldValue("CONTENT")+")",e.ORDER_ATOMIC]},Bu=function(t,e){for(var n=e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE),i=new Array(this.itemCount_),s=0;s<this.itemCount_;s++)i[s]=e.valueToCode(this,"ADD"+s,e.ORDER_NONE)||"0";return i=n+"= {"+i.join(", ")+"}\n",0==this.itemCount_&&(i=n+" = set()\n"),i},Vu=function(t,e){return["len("+(e.valueToCode(this,"SET",e.ORDER_ASSIGNMENT)||"0")+")",e.ORDER_ATOMIC]},Uu=function(t,e){return[(e.valueToCode(this,"SET",e.ORDER_ASSIGNMENT)||"0")+".pop()",e.ORDER_ATOMIC]},Yu=function(t,e){return(e.valueToCode(this,"SET",e.ORDER_ASSIGNMENT)||"0")+".clear()\n"},Gu=function(t,e){var n=e.valueToCode(this,"SET1",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"SET2",e.ORDER_ASSIGNMENT)||"0";return[n+"."+this.getFieldValue("OPERATE")+"("+i+")",e.ORDER_ATOMIC]},Hu=function(t,e){var n=e.valueToCode(this,"SET1",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"SET2",e.ORDER_ASSIGNMENT)||"0";return n+"."+this.getFieldValue("OPERATE")+"("+i+")\n"},Wu=function(t,e){return(e.valueToCode(this,"SET",e.ORDER_ASSIGNMENT)||"0")+"."+this.getFieldValue("OPERATE")+"("+(e.valueToCode(this,"data",e.ORDER_ASSIGNMENT)||"0")+")\n"},zu=function(t,e){var n=e.valueToCode(this,"SET1",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"SET2",e.ORDER_ASSIGNMENT)||"0";return[n+"."+this.getFieldValue("OPERATE")+"("+i+")",e.ORDER_ATOMIC]},Xu=function(t,e){return(e.valueToCode(this,"SET",e.ORDER_ASSIGNMENT)||"0")+".update("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},ju=function(t,e){return["{"+this.getFieldValue("TEXT")+"}",e.ORDER_ATOMIC]},qu=function(t,e){return["set("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0")+")",e.ORDER_ATOMIC]},Ku=function(t,e){return["'''<!DOCTYPE HTML>\n<html>\n<head>\n\t<meta charset=\"utf-8\">\n"+e.statementToCode(this,"HEAD")+"</head>\n<body>\n"+e.statementToCode(this,"BODY")+"</body>\n</html>\n'''",e.ORDER_ATOMIC]},Qu=function(t,e){var n=e.statementToCode(this,"DO"),i=this.getFieldValue("LEVEL");return"<h"+i+">\n"+n+"</h"+i+">\n"},Ju=function(t,e){var n=e.statementToCode(this,"DO"),i=this.getFieldValue("LEVEL");if("head"==i)var s="<"+i+'>\n\t<meta charset="utf-8">\n'+n+"</"+i+">\n";else s="<"+i+">\n"+n+"</"+i+">\n";return s},Zu=function(t,e){var n=e.statementToCode(this,"DO"),i=this.getFieldValue("LEVEL");return"<"+i+">\n"+n+"</"+i+">\n"},th=function(t,e){var n=e.statementToCode(this,"DO"),i=e.valueToCode(this,"style"),s=this.getFieldValue("LEVEL");return"<"+s+" "+i+" >\n"+n+"</"+s+">\n"},eh=function(t,e){return['style="'+e.statementToCode(this,"STYLE")+'"',e.ORDER_ATOMIC]},nh=function(t,e){return'<input type="'+this.getFieldValue("LEVEL")+'" name="'+this.getFieldValue("NAME")+'" value="'+this.getFieldValue("VALUE")+'" '+(e.valueToCode(this,"style")||"")+" />"},ih=function(){return this.getFieldValue("KEY")+":"+this.getFieldValue("VALUE")+";"},sh=function(){return this.getFieldValue("TEXT")+"\n"},rh=function(t){return t.getFieldValue("TEXT")+"\n"},ah=function(t,e){return[t.getFieldValue("TEXT"),e.ORDER_ATOMIC]},oh=function(t,e){return(e.valueToCode(t,"VALUE",e.ORDER_ATOMIC)||"")+"\n"},lh=function(){return""},uh=function(t,e){return["type("+(e.valueToCode(t,"VALUE",e.ORDER_MEMBER)||"___")+")",e.ORDER_ATOMIC]},hh=function(t,e){for(var n=t.getFieldValue("NAME"),i=t.hasReturn_,s=new Array(t.itemCount_),r=0;r<t.itemCount_;r++)s[r]=e.valueToCode(t,"ARGUMENT"+r,e.ORDER_NONE)||"___";var a=n+"("+s.join(", ")+")";return i?[a,e.ORDER_ATOMIC]:a+"\n"},ph=function(t,e){var n=e.valueToCode(t,"MODULE",e.ORDER_ATOMIC),i=e.valueToCode(t,"NAME",e.ORDER_ATOMIC);return[n+"."+(i=i.substring(1,i.length-1)),e.ORDER_NONE]},ch={};ch.NAME_TYPE=Jt.PROCEDURE_CATEGORY_NAME,ch.allProcedures=function(t){for(var e=t.getAllBlocks(!1),n=[],i=[],s=0;s<e.length;s++)if(e[s].getProcedureDef){var r=e[s].getProcedureDef();r&&(r[2]?n.push(r):i.push(r))}return i.sort(ch.procTupleComparator_),n.sort(ch.procTupleComparator_),[i,n]},ch.procTupleComparator_=function(t,e){return t[0].toLowerCase().localeCompare(e[0].toLowerCase())},ch.findLegalName=function(t,e){if(e.isInFlyout)return t;for(t=t||Jt.Msg.UNNAMED_KEY||"unnamed";!ch.isLegalName_(t,e.workspace,e);){var n=t.match(/^(.*?)(\d+)$/);n?t=n[1]+(parseInt(n[2],10)+1):t+="2"}return t},ch.isLegalName_=function(t,e,n){return!ch.isNameUsed(t,e,n)},ch.isNameUsed=function(t,e,n){for(var i=e.getAllBlocks(!1),s=0;s<i.length;s++)if(i[s]!=n&&i[s].getProcedureDef){var r=i[s].getProcedureDef();if(Jt.Names.equals(r[0],t))return!0}return!1},ch.rename=function(t){t=t.trim();var e=ch.findLegalName(t,this.getSourceBlock()),n=this.getValue();if(n!=t&&n!=e)for(var i=this.getSourceBlock().workspace.getAllBlocks(!1),s=0;s<i.length;s++)i[s].renameProcedure&&i[s].renameProcedure(n,e);return e},ch.flyoutCategory=function(t){var e,n,i=[];Jt.Blocks.procedures_defnoreturn&&((n=Jt.utils.xml.createElement("block")).setAttribute("type","procedures_defnoreturn"),n.setAttribute("gap",16),(e=Jt.utils.xml.createElement("field")).setAttribute("name","NAME"),e.appendChild(Jt.utils.xml.createTextNode(Jt.Msg.PROCEDURES_DEFNORETURN_PROCEDURE)),n.appendChild(e),i.push(n));Jt.Blocks.procedures_defreturn&&((n=Jt.utils.xml.createElement("block")).setAttribute("type","procedures_defreturn"),n.setAttribute("gap",16),(e=Jt.utils.xml.createElement("field")).setAttribute("name","NAME"),e.appendChild(Jt.utils.xml.createTextNode(Jt.Msg.PROCEDURES_DEFRETURN_PROCEDURE)),n.appendChild(e),i.push(n));Jt.Blocks.procedures_return&&((n=Jt.utils.xml.createElement("block")).setAttribute("type","procedures_return"),n.setAttribute("gap",16),i.push(n));Jt.Blocks.procedures_ifreturn&&((n=Jt.utils.xml.createElement("block")).setAttribute("type","procedures_ifreturn"),n.setAttribute("gap",16),i.push(n));function s(t,e){for(var n=0;n<t.length;n++){var s=t[n][0],r=t[n][1],a=Jt.utils.xml.createElement("block");a.setAttribute("type",e),a.setAttribute("gap",16);var o=Jt.utils.xml.createElement("mutation");o.setAttribute("name",s),a.appendChild(o);for(var l=0;l<r.length;l++){var u=Jt.utils.xml.createElement("arg");u.setAttribute("name",r[l]),o.appendChild(u)}i.push(a)}}i.length&&i[i.length-1].setAttribute("gap",24);var r=ch.allProcedures(t);return s(r[0],"procedures_callnoreturn"),s(r[1],"procedures_callreturn"),i},ch.getCallers=function(t,e){for(var n=[],i=e.getAllBlocks(!1),s=0;s<i.length;s++)if(i[s].getProcedureCall){var r=i[s].getProcedureCall();r&&Jt.Names.equals(r,t)&&n.push(i[s])}return n},ch.mutateCallers=function(t){const e=Jt.Events.getRecordUndo(),n=t.getProcedureDef()[0],i=t.mutationToDom(!0),s=Jt.Procedures.getCallers(n,t.workspace);for(let t,n=0;t=s[n];n++){const n=t.mutationToDom(),s=n&&Jt.utils.xml.domToText(n);t.domToMutation&&t.domToMutation(i);const r=t.mutationToDom(),a=r&&Jt.utils.xml.domToText(r);s!==a&&(Jt.Events.setRecordUndo(!1),Jt.Events.fire(new(Jt.Events.get(Jt.Events.BLOCK_CHANGE))(t,"mutation",null,s,a)),Jt.Events.setRecordUndo(e))}},ch.getDefinition=function(t,e){for(var n=e.getTopBlocks(!1),i=0;i<n.length;i++)if(n[i].getProcedureDef){var s=n[i].getProcedureDef();if(s&&Jt.Names.equals(s[0],t))return n[i]}return null};const dh=ch,fh=new Jt.Generator("Python");fh.INDENT=" ",fh.addReservedWords("False,None,True,and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,nonlocal,not,or,pass,print,raise,return,try,while,with,yield,NotImplemented,Ellipsis,__debug__,quit,exit,copyright,license,credits,ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EnvironmentError,Exception,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StandardError,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,ZeroDivisionError,_,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,all,any,apply,ascii,basestring,bin,bool,buffer,bytearray,bytes,callable,chr,classmethod,cmp,coerce,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,execfile,exit,file,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,intern,isinstance,issubclass,iter,len,license,list,locals,long,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,raw_input,reduce,reload,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,unichr,unicode,vars,xrange,zip"),fh.ORDER_ATOMIC=0,fh.ORDER_COLLECTION=1,fh.ORDER_STRING_CONVERSION=1,fh.ORDER_UNARY_POSTFIX=1,fh.ORDER_UNARY_PREFIX=2,fh.ORDER_MEMBER=2.1,fh.ORDER_FUNCTION_CALL=2.2,fh.ORDER_EXPONENTIATION=3,fh.ORDER_UNARY_SIGN=4,fh.ORDER_BITWISE_NOT=4,fh.ORDER_MULTIPLICATIVE=5,fh.ORDER_ADDITIVE=6,fh.ORDER_BITWISE_SHIFT=7,fh.ORDER_BITWISE_AND=8,fh.ORDER_BITWISE_XOR=9,fh.ORDER_BITWISE_OR=10,fh.ORDER_RELATIONAL=11,fh.ORDER_EQUALITY=11,fh.ORDER_LOGICAL_NOT=12,fh.ORDER_LOGICAL_AND=13,fh.ORDER_LOGICAL_OR=14,fh.ORDER_ASSIGNMENT=14,fh.ORDER_CONDITIONAL=15,fh.ORDER_LAMBDA=16,fh.ORDER_NONE=99,fh.ORDER_OVERRIDES=[[fh.ORDER_FUNCTION_CALL,fh.ORDER_MEMBER],[fh.ORDER_FUNCTION_CALL,fh.ORDER_FUNCTION_CALL],[fh.ORDER_MEMBER,fh.ORDER_MEMBER],[fh.ORDER_MEMBER,fh.ORDER_FUNCTION_CALL]],fh.init=function(){fh.PASS=this.INDENT+"pass\n",fh.definitions_=Object.create(null),fh.functionNames_=Object.create(null),fh.setups_=Object.create(null),fh.loops_=Object.create(null),fh.codeEnd_=Object.create(null),fh.variableDB_?fh.variableDB_.reset():fh.variableDB_=new ie(fh.RESERVED_WORDS_)},fh.finish=function(t){""!==t&&(t=(t=t.replace(/\n/g,"\n")).replace(/\n\s+$/,"\n"));var e=[],n=[],i=[];for(var s in this.definitions_){var r=this.definitions_[s];0===s.indexOf("import")?e.push(r):0===s.indexOf("var_declare")?n.push(r):i.push(r)}e.length&&e.push("\n\n"),n.length&&n.push("\n\n"),i.length&&i.push("\n\n");var a=[];for(var s in fh.functions_)a.push(fh.functions_[s]);a.length&&a.push("\n\n");var o=[];for(var s in fh.setups_)o.push(fh.setups_[s]);o.length&&o.push("\n\n");var l=[];for(var s in fh.loops_)l.push(fh.loops_[s]);var u=[];for(var s in fh.codeEnd_)u.push(fh.codeEnd_[s]);return 0!==u.length&&u.push("\n"),l.length>0?e.join("\n")+n.join("\n")+i.join("\n")+a.join("\n")+o.join("")+t+"while True:\n"+l.join("")+u.join("\n"):e.join("\n")+n.join("\n")+i.join("\n")+a.join("\n")+o.join("")+t+u.join("\n")},fh.scrubNakedValue=function(t){return t+"\n"},fh.quote_=function(t){var e="'";return-1!==t.indexOf("'")&&(-1===t.indexOf('"')?e='"':t=t.replace(/'/g,"\\'")),e+t+e},fh.multiline_quote_=function(t){return"'''"+(t=t.replace(/'''/g,"\\'\\'\\'"))+"'''"},fh.scrub_=function(t,e,n){var i="";if(!t.outputConnection||!t.outputConnection.targetConnection){(r=t.getCommentText())&&(r=Jt.utils.string.wrap(r,fh.COMMENT_WRAP-3),i+=fh.prefixLines(r+"\n","# "));for(var s=0;s<t.inputList.length;s++)if(t.inputList[s].type==Jt.INPUT_VALUE){var r,a=t.inputList[s].connection.targetBlock();if(a)(r=fh.allNestedComments(a))&&(i+=fh.prefixLines(r,"# "))}}var o=t.nextConnection&&t.nextConnection.targetBlock();return i+e+(n?"":fh.blockToCode(o))},fh.getAdjustedInt=function(t,e,n,i){var s=n||0;t.workspace.options.oneBasedIndex&&s--;var r=t.workspace.options.oneBasedIndex?"1":"0",a=s?fh.ORDER_ADDITIVE:fh.ORDER_NONE,o=fh.valueToCode(t,e,a)||r;return Jt.isNumber(o)?(o=parseInt(o,10)+s,i&&(o=-o)):(o=s>0?"int("+o+" + "+s+")":s<0?"int("+o+" - "+-s+")":"int("+o+")",i&&(o="-"+o)),o};const mh=205,gh={init:function(){this.setColour(mh),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_CHOOSE_AND_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_CHOOSE_AND_GET_ONE_FILE_NAME,"getOneFile"],[Jt.Msg.MIXLY_CHOOSE_AND_GET_MANY_FILE_NAMES,"getManyFiles"],[Jt.Msg.MIXLY_CHOOSE_AND_GET_DIR,"getDirectory"]]),"TYPE"),this.setInputsInline(!0),this.setOutput(!0)}},_h={init:function(){this.setColour(mh),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_SETUP).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipImageClassify,"AipImageClassify"],[Jt.Msg.MIXLY_AipSpeech,"AipSpeech"],[Jt.Msg.MIXLY_AipImageCensor,"AipImageCensor"],[Jt.Msg.MIXLY_AipFace,"AipFace"],[Jt.Msg.MIXLY_AipOcr,"AipOcr"],[Jt.Msg.MIXLY_AipNlp,"AipNlp"]]),"CTYPE"),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("API_KEY").appendField("API_KEY").setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("SECRET_KEY").appendField("SECRET_KEY").setAlign(Jt.inputs.Align.RIGHT),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Th={init:function(){this.setColour(mh),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipSpeech_synthesis).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR").appendField(Jt.Msg.OLED_STRING).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipSpeech_synthesis_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},yh={init:function(){this.setColour(mh),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipSpeech_asr).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_AipSpeech_File).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipSpeech_ASR_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},Ih={init:function(){this.setColour(mh),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipImageClassify).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("FUNC").appendField(Jt.Msg.MIXLY_AIP_FUNC).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ADDR").appendField(Jt.Msg.MIXLY_AipImageClassify_Image).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipImageClassify_advancedGeneral_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},Eh={init:function(){this.setColour(mh),this.appendDummyInput("").appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipImageClassify_advancedGeneral,"advancedGeneral"],[Jt.Msg.MIXLY_AipImageClassify_dishDetect,"dishDetect"],[Jt.Msg.MIXLY_AipImageClassify_carDetect,"carDetect"],[Jt.Msg.MIXLY_AipImageClassify_animalDetect,"animalDetect"],[Jt.Msg.MIXLY_AipImageClassify_plantDetect,"plantDetect"],[Jt.Msg.MIXLY_AipImageClassify_logoSearch,"logoSearch"]]),"TYPE"),this.setOutput(!0)}},bh={init:function(){this.setColour(mh),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipFace_match).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_AipImageClassify_Image+"1"+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("VAR2").appendField(Jt.Msg.MIXLY_AipImageClassify_Image+"2"+Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipFace_match_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},vh={init:function(){this.setColour(mh),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipOcr).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("FUNC").appendField(Jt.Msg.MIXLY_AIP_FUNC).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ADDR").appendField(Jt.Msg.MIXLY_AipImageClassify_Image).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipOcr_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},wh={init:function(){this.setColour(mh),this.appendDummyInput("").appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipOcr_basicGeneral,"basicGeneral"],[Jt.Msg.MIXLY_AipOcr_webImage,"webImage"],[Jt.Msg.MIXLY_AipOcr_idcard,"idcard"],[Jt.Msg.MIXLY_AipOcr_bankcard,"bankcard"],[Jt.Msg.MIXLY_AipOcr_drivingLicense,"drivingLicense"],[Jt.Msg.MIXLY_AipOcr_vehicleLicense,"vehicleLicense"],[Jt.Msg.MIXLY_AipOcr_licensePlate,"licensePlate"],[Jt.Msg.MIXLY_AipOcr_businessLicense,"businessLicense"],[Jt.Msg.MIXLY_AipOcr_receipt,"receipt"],[Jt.Msg.MIXLY_AipOcr_trainTicket,"trainTicket"],[Jt.Msg.MIXLY_AipOcr_taxiReceipt,"taxiReceipt"],[Jt.Msg.MIXLY_AipOcr_form,"tableRecognition"],[Jt.Msg.MIXLY_AipOcr_vatInvoice,"vatInvoice"],[Jt.Msg.MIXLY_AipOcr_passport,"passport"],[Jt.Msg.MIXLY_AipOcr_handwriting,"handwriting"]]),"TYPE"),this.setOutput(!0)}},Sh={init:function(){this.setColour(mh),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipNlp).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("FUNC").appendField(Jt.Msg.MIXLY_AIP_FUNC).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR").appendField(Jt.Msg.OLED_STRING).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipNlp_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},xh={init:function(){this.setColour(mh),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipNlp_Sim).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("FUNC").appendField(Jt.Msg.MIXLY_AIP_FUNC).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR1").appendField(Jt.Msg.OLED_STRING+"1").setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR2").appendField(Jt.Msg.OLED_STRING+"2").setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipNlp_Sim_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},Rh={init:function(){this.setColour(mh),this.appendDummyInput("").appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipNlp_lexer,"lexer"],[Jt.Msg.MIXLY_AipNlp_depParser,"depParser"],[Jt.Msg.MIXLY_AipNlp_wordEmbedding,"wordEmbedding"],[Jt.Msg.MIXLY_AipNlp_dnnlm,"dnnlm"],[Jt.Msg.MIXLY_AipNlp_commentTag,"commentTag"],[Jt.Msg.MIXLY_AipNlp_sentimentClassify,"sentimentClassify"],[Jt.Msg.MIXLY_AipNlp_keyword,"keyword"],[Jt.Msg.MIXLY_AipNlp_topic,"topic"],[Jt.Msg.MIXLY_AipNlp_ecnet,"ecnet"],[Jt.Msg.MIXLY_AipNlp_emotion,"emotion"]]),"TYPE"),this.setOutput(!0)}},Oh={init:function(){this.setColour(mh),this.appendDummyInput("").appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipNlp_wordSimEmbedding,"wordSimEmbedding"],[Jt.Msg.MIXLY_AipNlp_simnet,"simnet"]]),"TYPE"),this.setOutput(!0)}},Ah={init:function(){this.setColour(mh),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipNlp_topic).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR1").appendField(Jt.Msg.MIXLY_AipNlp_Topic_Title).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR2").appendField(Jt.Msg.MIXLY_AipNlp_Topic_Content).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipNlp_Topic_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},Mh={init:function(){this.setColour(mh),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_AipNlp_summary).appendField(Jt.Msg.MIXLY_Client).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("STR").appendField(Jt.Msg.MIXLY_AipNlp_Topic_Content).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("LEN").appendField(Jt.Msg.MIXLY_LIST_LEN).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("ATTR").appendField(Jt.Msg.MIXLY_AIP_ATTR).setAlign(Jt.inputs.Align.RIGHT),this.setTooltip(Jt.Msg.MIXLY_AipNlp_Summary_TOOLTIP),this.setInputsInline(!1),this.setOutput(!0)}},Ch={init:function(){this.setColour(mh),this.appendValueInput("VAR").appendField(Jt.Msg.MIXPY_AI_AUDIO),this.appendValueInput("TIME").appendField(Jt.Msg.MIXPY_AI_AUDIO_TIME),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXPY_AI_AUDIO_TOOLTIP)}},Nh={init:function(){this.setColour(mh),this.appendValueInput("VAR").appendField(Jt.Msg.MIXPY_AI_PHOTO),this.appendValueInput("BUT").appendField(Jt.Msg.MIXPY_AI_PHOTO_BUTTON),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXPY_AI_PHOTO_TOOLTIP)}},kh={init:function(){this.setColour(mh),this.appendValueInput("AI").appendField(Jt.Msg.MIXPY_AI_RESULT).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_AipImageClassify,"Image"],[Jt.Msg.MIXLY_AipSpeech_asr,"Speech"],[Jt.Msg.MIXLY_AipFace_match,"Face"],[Jt.Msg.MIXLY_AipOcr,"Ocr"],[Jt.Msg.MIXLY_AipNlp_simnet,"OcrSimilarity"],[Jt.Msg.MIXLY_AipNlp_sentimentClassify,"Emotion"]]),"CTYPE"),this.setOutput(!0),this.setTooltip(Jt.Msg.LOGIC_NEGATE_TOOLTIP)}},Dh="#526FC3",Lh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PREPARE),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Fh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_ADD_SCHOOL),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Ph={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_FIND_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},$h={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NEW_PATH),this.setOutput(!0)}},Bh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_SET_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Vh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_ADD_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Uh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_DEL_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Yh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_RETURN_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Gh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NO_LEFT),this.setOutput(!0)}},Hh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Wh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PREPARE2),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},zh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_CURRENT_SCHOOL),this.setOutput(!0)}},Xh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NO_PATH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},jh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PREPARE_2_1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},qh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PREPARE_2_2),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Kh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_MOVE_RECENT),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Qh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NOT_HOME),this.setOutput(!0)}},Jh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NOT_SCHOOL),this.setOutput(!0)}},Zh={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_PATH2),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},tp={init:function(){this.appendDummyInput().appendField("准备").appendField(new Jt.FieldNumber(3,0,100,1),"NUM").appendField("层汉诺塔"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},ep={init:function(){this.appendDummyInput().appendField("移动圆盘从"),this.appendValueInput("FROM_NUM").setCheck(null).appendField("柱"),this.appendDummyInput().appendField("到"),this.appendValueInput("TO_NUM").setCheck(null).appendField("柱"),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},np={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_ALL_BOOKS),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},ip={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_ALL_BOOKS2),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},sp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_FIRST_BOOK),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},rp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NO_RING),this.setOutput(!0)}},ap={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_YES_RING),this.setOutput(!0)}},op={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NEXT_BOOK),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},lp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_TWO_LEFT),this.setOutput(!0)}},up={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_DIVIDE_BOOKS),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},hp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_GET_HALF_BOOKS),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},pp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_DELETE_BOOK),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},cp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_DELETE_BOOKS),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},dp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_DELETE_BOOKS2),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},fp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_BOOK),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},mp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("设置待查书总数 N=").appendField(new Jt.FieldDropdown([["5","5"],["10","10"],["20","20"],["50","50"]]),"NUM"),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},gp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NUMBER_ZERO),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},_p={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_NUMBER_ADD),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Tp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_NUMBER),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},yp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField("n"+Jt.Msg.MIXLY_VALUE2).appendField(new Jt.FieldTextInput("50"),"NUM"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Ip={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_SEQUENCE),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Ep={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_PRINT_DIVIDE),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},bp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("初始化鸡兔同笼问题:"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("有若干只鸡、兔在同一个笼子里。"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("从上面数鸡兔有10个头"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("从下面数鸡兔有32只脚。"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("问笼中有多少只鸡和多少只兔?"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},vp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("假设兔子的数量为0只"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},wp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("兔子的数量在范围之内"),this.setOutput(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Sp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("根据(头数-兔子数)计算出鸡的数量"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},xp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("计算得到脚的数量正确"),this.setOutput(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Rp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("输出鸡、兔的数量"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Op={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("假设兔子数量要更多一只"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Ap={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("加载路线图"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Mp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("计算").appendField(new Jt.FieldDropdown([["S1","1"],["S2","2"],["S3","3"],["S4","4"]]),"PATHNAME").appendField("长度"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Cp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("设置S1为Smin"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Np={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField(new Jt.FieldDropdown([["S1","1"],["S2","2"],["S3","3"],["S4","4"]]),"PATHNAME").appendField("的长度比").appendField(new Jt.FieldDropdown([["S1","1"],["S2","2"],["S3","3"],["S4","4"]]),"PATHNAME2").appendField("短"),this.setOutput(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},kp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("设置").appendField(new Jt.FieldDropdown([["S1","1"],["S2","2"],["S3","3"],["S4","4"]]),"PATHNAME").appendField("为Smin"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Dp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("按照Smin移动"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Lp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("初始化韩信点兵问题:"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("有未知数量的若干士兵。"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("若3人一排列队多1人"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("若5人一排列队多2人"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("若7人一排列队多2人"),this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("问士兵的数量最少是多少人?"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Fp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("初始化士兵为").appendField(new Jt.FieldTextInput("7"),"NUM").appendField("个"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Pp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("使士兵").appendField(new Jt.FieldDropdown([["3","3"],["5","5"],["7","7"]]),"NUM").appendField("人一排列队"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},$p={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("剩余").appendField(new Jt.FieldTextInput("1"),"NUM").appendField("个士兵"),this.setOutput(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Bp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("增加1个士兵"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Vp={init:function(){this.appendDummyInput().setAlign(Jt.inputs.Align.LEFT).appendField("输出士兵数量"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setTooltip(""),this.setHelpUrl("")}},Up={init:function(){this.appendDummyInput().appendField("准备").appendField(new Jt.FieldNumber(3,0,100,1),"NUM").appendField("层汉诺塔"),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.HTML_COLOUR),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(Dh),this.setInputsInline(!0),this.setTooltip(""),this.setHelpUrl("")}},Yp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_GET_CURRENT_LOCATION),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},Gp={init:function(){this.setColour(Dh),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MIXPY_ALGORITHM_VOID_PATH),this.setOutput(!0)}},Hp={init:function(){this.setColour(Dh),this.appendDummyInput("").setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldColour("ff0000"),"COLOR"),this.setInputsInline(!0),this.setOutput(!0,String)}},Wp="#3288dd",zp={init:function(){this.setColour(Wp),this.appendValueInput("DOMAIN").appendField(Jt.Msg.DISPLAY_IMAGE_LET2).setCheck(String),this.appendDummyInput("").appendField(Jt.Msg.blockpy_REQUESTS_GET).appendField(new Jt.FieldTextInput("response"),"VAR"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.blockpy_REQUESTS_GET_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Xp={init:function(){this.setColour(Wp),this.appendValueInput("URL").appendField(Jt.Msg.DISPLAY_IMAGE_LET2).setCheck(String),this.appendDummyInput("").appendField(Jt.Msg.blockpy_CONDUCT).appendField(new Jt.FieldDropdown([["get","get"],["head","head"],["delete","delete"]]),"TYPE").appendField(Jt.Msg.blockpy_REQUESTS).appendField(Jt.Msg.MIXPY_REQUESTS_GET_RESULT),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip("")}},jp={init:function(){this.setColour(Wp),this.appendValueInput("URL").appendField(Jt.Msg.DISPLAY_IMAGE_LET2).setCheck(String),this.appendDummyInput("").appendField(Jt.Msg.blockpy_CONDUCT).appendField(new Jt.FieldDropdown([["post","post"],["put","put"],["patch","patch"]]),"TYPE").appendField(Jt.Msg.blockpy_REQUESTS),this.appendValueInput("data").appendField(Jt.Msg.blockpy_REQUESTS+Jt.Msg.OLED_STRING),this.appendDummyInput("").appendField(Jt.Msg.MIXPY_REQUESTS_GET_RESULT),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip("")}},qp={init:function(){this.appendValueInput("VAL");var t=[[Jt.Msg.blockpy_REQUESTS_GET_ATTR_STATUS_CODE,"status_code"],[Jt.Msg.blockpy_REQUESTS_GET_ATTR_TEXT,"text"],[Jt.Msg.blockpy_REQUESTS_GET_ATTR_COOKIES,"cookies"],[Jt.Msg.blockpy_REQUESTS_GET_ATTR_CONTENT,"content"],[Jt.Msg.MIXPY_TEXT_ENCODE,"encoding"]];this.setColour(Wp),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROBIT_JS_GET).appendField(new Jt.FieldDropdown(t),"ATTR"),this.setInputsInline(!0),this.setOutput(!0,String)}},Kp={init:function(){this.appendValueInput("VAR").appendField(Jt.Msg.DISPLAY_IMAGE_LET2).setCheck(String);this.setColour(Wp),this.appendDummyInput("").appendField(Jt.Msg.blockpy_CONDUCT).appendField(new Jt.FieldDropdown([["post","post"],["put","put"],["delete","delete"],["head","head"],["option","option"]]),"DIR"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_REQUESTS),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip((function(){var e=t.getFieldValue("DIR");return{forward:Jt.Msg.MIXLY_TOOLTIP_TURTEL_FORWARD,backward:Jt.Msg.MIXLY_TOOLTIP_TURTEL_BACKWARD}[e]}))}},Qp="f0a559",Jp={init:function(){this.setColour(Qp),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_CV_IMREAD),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)}},Zp={init:function(){this.setColour(Qp),this.appendValueInput("FILE").appendField(Jt.Msg.OLED_BITMAP),this.appendValueInput("data").setCheck(String).appendField(Jt.Msg.MIXLY_AipNlp_Topic_Title),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0)}},tc={init:function(){this.setColour(Qp),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_CV_IMWRITE),this.appendValueInput("data").setCheck(String).appendField(Jt.Msg.HTML_NAME),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0)}},ec={init:function(){this.setColour(Qp),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.MIXLY_DELAY),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MILLIS+Jt.Msg.MIXLY_CV_OR_PRESS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_CV_WAITKEY_TOOLTIP)}},nc={init:function(){this.setColour(Qp),this.appendDummyInput().appendField(Jt.Msg.MIXLY_CV_DESTROY_ALL),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0)}},ic={init:function(){this.setColour(Qp),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_IMAGE);var t=[[Jt.Msg.MIXLY_CV_RECT,"rectangle"],[Jt.Msg.MIXLY_CV_LINE,"line"]];this.appendValueInput("x1").setCheck(Number).appendField(Jt.Msg.MIXLY_DISPLAY_DRAW).appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.MIXLY_CV_DRAWLINE_BEGIN+"(x1"),this.appendValueInput("y1").setCheck(Number).appendField(",y1"),this.appendValueInput("x2").setCheck(Number).appendField(") "+Jt.Msg.MIXLY_CV_DRAWLINE_END+"(x2"),this.appendValueInput("y2").setCheck(Number).appendField(",y2"),this.appendDummyInput().appendField(") "+Jt.Msg.MIXLY_CV_DRAWLINE_COLOR).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.appendValueInput("thick").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_DRAWLINE_THICKNESS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_CV_DRAWLINE_RECT_TOOLTIP)}},sc={init:function(){this.setColour(Qp),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_IMAGE);this.appendValueInput("data").setCheck(String).appendField(Jt.Msg.MIXLY_CV_DRAWTEXT),this.appendValueInput("x1").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_DRAWLINE_BEGIN+"(x1"),this.appendValueInput("y1").setCheck(Number).appendField(",y1"),this.appendDummyInput().appendField(") "+Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NAME).appendField(new Jt.FieldDropdown([["SIMPLEX","SIMPLEX"],["PLAIN","PLAIN"],["DUPLEX","DUPLEX"],["COMPLEX","COMPLEX"],["COMPLEX_SMALL","COMPLEX_SMALL"],["TRIPLEX","TRIPLEX"],["SCRIPT_SIMPLEX","SCRIPT_SIMPLEX"],["SCRIPT_COMPLEX","SCRIPT_COMPLEX"]]),"font"),this.appendValueInput("size").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NUM),this.appendDummyInput().appendField(") "+Jt.Msg.MIXLY_CV_DRAWLINE_COLOR).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.appendValueInput("thick").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_DRAWLINE_THICKNESS),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_CV_DRAWLINE_RECT_TOOLTIP)}},rc={init:function(){this.setColour(Qp),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.MIXLY_CV_FACE_CLASSIFIER),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)}},ac={init:function(){this.setColour(Qp),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_IMAGE),this.appendValueInput("FACE").appendField(Jt.Msg.MIXLY_CV_FACE_DETECT),this.appendValueInput("SCALE").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_FACE_DETECT_SCALE),this.appendValueInput("NEIGHBOR").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_FACE_DETECT_NEIGHBOR),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)}},oc={init:function(){this.setColour(Qp),this.appendValueInput("FILE").appendField(Jt.Msg.MIXLY_MICROBIT_IMAGE),this.appendValueInput("FACE").appendField(Jt.Msg.MIXLY_CV_FACE_DETECT),this.appendValueInput("SCALE").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_FACE_DETECT_SCALE),this.appendValueInput("NEIGHBOR").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_FACE_DETECT_NEIGHBOR),this.appendValueInput("x1").setCheck(Number).appendField(Jt.Msg.MIXLY_CV_FACE_DETECT_RANGE).appendField(Jt.Msg.blockpy_TUPLE_MIN),this.appendValueInput("y1").setCheck(Number).appendField("×"),this.appendValueInput("x2").setCheck(Number).appendField(Jt.Msg.blockpy_TUPLE_MAX),this.appendValueInput("y2").setCheck(Number).appendField("×"),this.setInputsInline(!0),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)}},lc=170,uc={init:function(){this.setColour(lc),this.appendDummyInput("").appendField(Jt.Msg.blockpy_series_create).appendField(new Jt.FieldTextInput("ser1"),"VAR"),this.appendValueInput("SER").appendField(Jt.Msg.blockpy_series_via),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.blockpy_series_create_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},hc={init:function(){this.setColour(lc),this.appendDummyInput("").appendField(Jt.Msg.blockpy_series_create).appendField(new Jt.FieldTextInput("ser1"),"VAR"),this.appendValueInput("SER").appendField(Jt.Msg.blockpy_series_via),this.appendValueInput("INDEX").setCheck([String,"List"]).appendField(Jt.Msg.blockpy_series_set_index),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.blockpy_series_create_index_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},pc={init:function(){this.setColour(lc),this.appendDummyInput("").appendField(Jt.Msg.blockpy_dataframe_create).appendField(new Jt.FieldTextInput("df1"),"VAR"),this.appendValueInput("SER").appendField(Jt.Msg.blockpy_series_via),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.blockpy_dataframe_create_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},cc={init:function(){this.setColour(lc);var t=[[Jt.Msg.DATAFRAME_RAW,"index"],[Jt.Msg.DATAFRAME_COLUMN,"columns"]];this.appendDummyInput("").appendField(Jt.Msg.blockpy_dataframe_create).appendField(new Jt.FieldTextInput("df1"),"VAR"),this.appendValueInput("SER").appendField(Jt.Msg.blockpy_series_via),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"COLUMN_RAW"),this.appendValueInput("INDEX").setCheck([String,"List"]).appendField(Jt.Msg.blockpy_series_set_index),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.blockpy_dataframe_create_index_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},dc={init:function(){this.setColour(lc),this.appendDummyInput("").appendField(Jt.Msg.blockpy_dataframe_create).appendField(new Jt.FieldTextInput("df1"),"VAR"),this.appendValueInput("SER").appendField(Jt.Msg.blockpy_series_via),this.appendValueInput("INDEX_COLUMN").setCheck([String,"List"]).appendField(Jt.Msg.blockpy_dataframe_set_index_column),this.appendValueInput("INDEX_RAW").setCheck([String,"List"]).appendField(Jt.Msg.blockpy_dataframe_set_index_raw),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.blockpy_dataframe_create_index_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},fc={init:function(){this.setColour(lc),this.appendDummyInput("").appendField(new Jt.FieldTextInput("ser1"),"VAR").appendField(" = [").appendField(new Jt.FieldTextInput("1,2,3"),"TEXT").appendField("]"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_SERIES_CREATE_FROM_TEXT)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},mc={init:function(){this.setColour(lc);var t=[[Jt.Msg.SERIES_INDEX,"index"],[Jt.Msg.HTML_VALUE,"value"]];this.appendValueInput("SERIES").setCheck("Series"),this.appendDummyInput("").appendField(Jt.Msg.SERIES_INDEX_VALUE).appendField(new Jt.FieldDropdown(t),"INDEX_VALUE"),this.setOutput(!0,"List");var e=this;this.setTooltip((function(){var t=e.getFieldValue("INDEX_VALUE");return{index:Jt.Msg.SERIES_INDEX_TOOLTIP,value:Jt.Msg.HTML_VALUE_TOOLTIP}[t]}))}},gc={init:function(){this.setColour(lc),this.setOutput(!0),this.appendValueInput("SER").setCheck("Series"),this.appendValueInput("AT").setCheck(Number).appendField(Jt.Msg.LANG_LISTS_GET_INDEX1),this.appendDummyInput("").appendField(Jt.Msg.LANG_LISTS_GET_INDEX2),this.setInputsInline(!0),this.setTooltip(Jt.Msg.TUPLE_GET_INDEX_TOOLTIP)}},_c={init:function(){this.setColour(lc),this.appendValueInput("SER").setCheck("Series").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_PLOT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Tc={init:function(){this.setColour(lc);var t=[[Jt.Msg.blockpy_PYLAB_PLOT_LINE_SOLID,"-"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_DOTTED,"--"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_CHAIN,"-."],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_POINT_DOTTED,":"],[Jt.Msg.MIXLY_MICROBIT_JS_INOUT_PULL_NONE,""]],e=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],n=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("SER").setCheck("Series").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_PLOT),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(n),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_LINE).appendField(new Jt.FieldDropdown(t),"LINE"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(e),"COLOR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},yc={init:function(){this.setColour(lc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_SHOW),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ic={init:function(){this.setColour(lc),this.appendDummyInput().appendField(Jt.Msg.mixpy_PL_AXES),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ec={init:function(){this.setColour(lc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_LEGEND),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},bc={init:function(){this.setColour(lc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_TITLE),this.appendValueInput("TITLE").setCheck(String),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},vc={init:function(){this.setColour(lc);var t=[[Jt.Msg.PYLAB_LABEL_X,"x"],[Jt.Msg.PYLAB_LABEL_Y,"y"]];this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_SET_LABEL).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("LABEL").appendField(Jt.Msg.blockpy_PYLAB_LABEL).setCheck(String),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},wc={init:function(){this.setColour(lc),this.appendValueInput("FROM").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_SPLITBYDOU).appendField(Jt.Msg.MIXPY_DATA_ARRAY_CREATE_FROM),this.appendValueInput("TO").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXPY_DATA_ARRAY_CREATE_TO),this.appendValueInput("STEP").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_STEP),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_RANGE_TOOLTIP)}},Sc={init:function(){this.setColour(lc);var t=[[Jt.Msg.mixpy_PYLAB_PLOT_BAR_PLOT,"plot"],[Jt.Msg.mixpy_PYLAB_PLOT_BAR_BAR,"bar"]];this.appendDummyInput().appendField(Jt.Msg.MIXLY_DISPLAY_DRAW).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{plot:Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP,bar:Jt.Msg.mixpy_PYLAB_PLOT_BAR_EASY_TOOLTIP}[t]}))}},xc={init:function(){this.setColour(lc);var t=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],e=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_SCATTER).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendValueInput("S").appendField(Jt.Msg.MIXLY_MICROBIT_JS_NUMBER),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(e),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(t),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Rc={init:function(){this.setColour(lc);var t=[[Jt.Msg.blockpy_PYLAB_PLOT_LINE_SOLID,"-"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_DOTTED,"--"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_CHAIN,"-."],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_POINT_DOTTED,":"],[Jt.Msg.MIXLY_MICROBIT_JS_INOUT_PULL_NONE,""]],e=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],n=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PLOT_XY).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(n),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_LINE).appendField(new Jt.FieldDropdown(t),"LINE"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(e),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},Oc={init:function(){this.setColour(lc);var t=[[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_CENTER,"center"],[Jt.Msg.AILGN_EDGE,"edge"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_BAR).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendValueInput("WIDTH").setCheck(Number).appendField(Jt.Msg.MIXLY_WIDTH),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_BAR_ALIGN).appendField(new Jt.FieldDropdown(t),"ALIGN"),this.appendDummyInput().appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldColour("#0000ff"),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},Ac={init:function(){this.setColour(lc);var t=[[Jt.Msg.mixpy_PL_PIE_SHADOW_N,"False"],[Jt.Msg.mixpy_PL_PIE_SHADOW_Y,"True"]],e=[[Jt.Msg.mixpy_PL_PIE_SHADOW_N,"None"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_Z,"%.0f%%"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_O,"%.1f%%"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_T,"%.2f%%"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PIE).appendField(Jt.Msg.COLOUR_BLEND_RATIO),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.appendValueInput("EXPLODE").appendField(Jt.Msg.mixpy_PYLAB_PIE_EXPLODE),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT).appendField(new Jt.FieldDropdown(e),"autopct"),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_PIE_SHADOW).appendField(new Jt.FieldDropdown(t),"SHADOW"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},Mc={init:function(){this.setColour(lc),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_HIST).appendField(Jt.Msg.MIXLY_SD_DATA),this.appendValueInput("B").appendField(Jt.Msg.MIXLY_MICROBIT_JS_MONITOR_SCROLL_INTERVAL),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Cc={init:function(){this.setColour(lc);var t=[[Jt.Msg.PYLAB_LABEL_X,"x"],[Jt.Msg.PYLAB_LABEL_Y,"y"]];this.appendDummyInput().appendField(Jt.Msg.MIXLY_SETTING).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_TICKS).appendField(Jt.Msg.MIXLY_MICROBIT_JS_I2C_VALUE),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_TICKS_TOOLTIP)}},Nc={init:function(){var t=[["sin","sin"],["cos","cos"],["tan","tan"],["arcsin","arcsin"],["arccos","arccos"],["arctan","arctan"],[Jt.Msg.LANG_MATH_TO_ROUND,"round"],[Jt.Msg.LANG_MATH_TO_CEIL,"ceil"],[Jt.Msg.LANG_MATH_TO_FLOOR,"floor"]];this.setColour(lc),this.setOutput(!0),this.setInputsInline(!0),this.appendDummyInput().appendField(Jt.Msg.mixpy_NUMPY_TRIG),this.appendValueInput("NUM").setCheck(Number).appendField(new Jt.FieldDropdown(t),"OP"),this.setTooltip(Jt.Msg.mixpy_NUMPY_TRIG_TOOLTIP)}},kc={init:function(){this.setColour(lc),this.appendValueInput("VET").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT).appendField(Jt.Msg.mixpy_SUBPLOT_VERTICLE),this.appendValueInput("HOR").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT_HORIZEN),this.appendValueInput("NUM").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT_NUM),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_RANGE_TOOLTIP)}},Dc={init:function(){this.setColour(lc),this.appendValueInput("FILENAME").appendField(Jt.Msg.MIXPY_PANDAS_READ_CSV),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.mixpy_PANDAS_READCSV_HEADER_Y,"0"],[Jt.Msg.mixpy_PANDAS_READCSV_HEADER_N,"None"]]),"MODE"),this.appendDummyInput().appendField(Jt.Msg.mixpy_PANDAS_READCSV_TITLE),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.mixpy_PANDAS_READCSV_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Lc={init:function(){this.setColour(lc),this.appendValueInput("DICT").setCheck("Dict"),this.appendValueInput("KEY").appendField(Jt.Msg.mixpy_DATAFRAME_GET),this.appendDummyInput("").appendField(Jt.Msg.mixpy_DATAFRAME_GET_INDEX).appendField(new Jt.FieldDropdown([[Jt.Msg.DATAFRAME_COLUMN,"column"],[Jt.Msg.DATAFRAME_RAW,"raw"]]),"MODE"),this.setOutput(!0),this.setTooltip(Jt.Msg.mixpy_DATAFRAME_GET_TOOLTIP)}},Fc={init:function(){this.setColour(lc),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.mixpy_PL_SAVEFIG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.mixpy_PL_SAVEFIG_TOOLTIP)}},Pc={init:function(){this.setColour(lc);var t=[[Jt.Msg.TEXT_TRIM_LEFT,"right"],[Jt.Msg.mixpy_PL_TEXT_CENTER,"center"],[Jt.Msg.TEXT_TRIM_RIGHT,"left"]],e=[[Jt.Msg.mixpy_PL_TEXT_TOP,"bottom"],[Jt.Msg.mixpy_PL_TEXT_CENTER,"center"],[Jt.Msg.mixpy_PL_TEXT_BOTTOM,"top"]];this.appendValueInput("VET").setCheck(Number).appendField(Jt.Msg.MIXLY_SETTING).appendField(Jt.Msg.mixpy_PL_TEXT_X),this.appendValueInput("HOR").setCheck(Number).appendField(Jt.Msg.mixpy_PL_TEXT_Y),this.appendValueInput("NUM").setCheck(Number).appendField(Jt.Msg.mixpy_PL_TEXT_TAG),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PL_TEXT_HOR).appendField(new Jt.FieldDropdown(t),"HALIGN"),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PL_TEXT_VER).appendField(new Jt.FieldDropdown(e),"VALIGN"),this.appendValueInput("FONTNUM").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NUM),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PL_TEXT_TOOLTIP)}},$c={init:function(){this.setColour(lc),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TOARRAY),this.setOutput(!0,"List"),this.setTooltip(Jt.Msg.MIXLY_PYTHON_TOOLTIP_TOARRAY)}},Bc={init:function(){this.setColour(lc),this.appendValueInput("SER").setCheck("Series").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_PLOT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Vc={init:function(){this.setColour(lc);var t=[[Jt.Msg.blockpy_PYLAB_PLOT_LINE_SOLID,"-"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_DOTTED,"--"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_CHAIN,"-."],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_POINT_DOTTED,":"],[Jt.Msg.MIXLY_MICROBIT_JS_INOUT_PULL_NONE,""]],e=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],n=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("SER").setCheck("Series").appendField(Jt.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_PLOT),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(n),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_LINE).appendField(new Jt.FieldDropdown(t),"LINE"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(e),"COLOR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Uc={init:function(){this.setColour(lc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_SHOW),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Yc={init:function(){this.setColour(lc),this.appendDummyInput().appendField(Jt.Msg.mixpy_PL_AXES),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Gc={init:function(){this.setColour(lc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_LEGEND),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Hc={init:function(){this.setColour(lc),this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_TITLE),this.appendValueInput("TITLE").setCheck(String),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Wc={init:function(){this.setColour(lc);var t=[[Jt.Msg.PYLAB_LABEL_X,"x"],[Jt.Msg.PYLAB_LABEL_Y,"y"]];this.appendDummyInput().appendField(Jt.Msg.blockpy_PYLAB_SET_LABEL).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("LABEL").appendField(Jt.Msg.blockpy_PYLAB_LABEL).setCheck(String),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},zc={init:function(){this.setColour(lc);var t=[[Jt.Msg.mixpy_PYLAB_PLOT_BAR_PLOT,"plot"],[Jt.Msg.mixpy_PYLAB_PLOT_BAR_BAR,"bar"]];this.appendDummyInput().appendField(Jt.Msg.MIXLY_DISPLAY_DRAW).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{plot:Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP,bar:Jt.Msg.mixpy_PYLAB_PLOT_BAR_EASY_TOOLTIP}[t]}))}},Xc={init:function(){this.setColour(lc);var t=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],e=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_SCATTER).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendValueInput("S").appendField(Jt.Msg.MIXLY_MICROBIT_JS_NUMBER),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(e),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(t),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},jc={init:function(){this.setColour(lc);var t=[[Jt.Msg.blockpy_PYLAB_PLOT_LINE_SOLID,"-"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_DOTTED,"--"],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_CHAIN,"-."],[Jt.Msg.blockpy_PYLAB_PLOT_LINE_POINT_DOTTED,":"],[Jt.Msg.MIXLY_MICROBIT_JS_INOUT_PULL_NONE,""]],e=[[Jt.Msg.COLOUR_RGB_BLUE,"b"],[Jt.Msg.COLOUR_RGB_GREEN,"g"],[Jt.Msg.COLOUR_RGB_RED,"r"],[Jt.Msg.COLOUR_CYAN,"c"],[Jt.Msg.COLOUR_MAGENTA,"m"],[Jt.Msg.COLOUR_YELLOW,"y"],[Jt.Msg.COLOUR_BLACK,"k"],[Jt.Msg.COLOUR_WHITE,"w"]],n=[[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CIRCULAR,"."],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PIXEL,","],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_LARGE_DOT,"o"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_DOWN,"v"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_UP,"^"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_LEFT,"<"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIANGLE_RIGHT,">"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_UP,"1"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_DOWN,"2"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_LEFT,"3"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_TRIMARKER_RIGHT,"4"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_SQUARE,"s"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PENTAGON,"p"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_STAR,"*"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_VERTICAL,"h"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HEXAGON_HORIZONTAL,"H"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_PLUS,"+"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_CROSS,"x"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND,"D"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_DIAMOND_SMALL,"d"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_VERTICAL,"|"],[Jt.Msg.blockpy_PYLAB_PLOT_DOT_HORIZONTAL,"_"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PLOT_XY).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_DOT).appendField(new Jt.FieldDropdown(n),"DOT"),this.appendDummyInput("").appendField(Jt.Msg.blockpy_PYLAB_PLOT_LINE).appendField(new Jt.FieldDropdown(t),"LINE"),this.appendDummyInput("").appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldDropdown(e),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},qc={init:function(){this.setColour(lc);var t=[[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_CENTER,"center"],[Jt.Msg.AILGN_EDGE,"edge"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_BAR).appendField(Jt.Msg.mixpy_PYLAB_PLOT_X),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_PLOT_Y),this.appendValueInput("WIDTH").setCheck(Number).appendField(Jt.Msg.MIXLY_WIDTH),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_BAR_ALIGN).appendField(new Jt.FieldDropdown(t),"ALIGN"),this.appendDummyInput().appendField(Jt.Msg.HTML_COLOUR).appendField(new Jt.FieldColour("#0000ff"),"COLOR"),this.appendValueInput("TAG").setCheck(String).appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},Kc={init:function(){this.setColour(lc);var t=[[Jt.Msg.mixpy_PL_PIE_SHADOW_N,"False"],[Jt.Msg.mixpy_PL_PIE_SHADOW_Y,"True"]],e=[[Jt.Msg.mixpy_PL_PIE_SHADOW_N,"None"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_Z,"%.0f%%"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_O,"%.1f%%"],[Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT_T,"%.2f%%"]];this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_PIE).appendField(Jt.Msg.COLOUR_BLEND_RATIO),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.appendValueInput("EXPLODE").appendField(Jt.Msg.mixpy_PYLAB_PIE_EXPLODE),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_PIE_AUTOPCT).appendField(new Jt.FieldDropdown(e),"autopct"),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PYLAB_PIE_SHADOW).appendField(new Jt.FieldDropdown(t),"SHADOW"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_PLOT_XY_TOOLTIP)}},Qc={init:function(){this.setColour(lc),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_HIST).appendField(Jt.Msg.MIXLY_SD_DATA),this.appendValueInput("B").appendField(Jt.Msg.MIXLY_MICROBIT_JS_MONITOR_SCROLL_INTERVAL),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Jc={init:function(){this.setColour(lc);var t=[[Jt.Msg.PYLAB_LABEL_X,"x"],[Jt.Msg.PYLAB_LABEL_Y,"y"]];this.appendDummyInput().appendField(Jt.Msg.MIXLY_SETTING).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("A").appendField(Jt.Msg.mixpy_PYLAB_TICKS).appendField(Jt.Msg.MIXLY_MICROBIT_JS_I2C_VALUE),this.appendValueInput("B").appendField(Jt.Msg.mixpy_PYLAB_TICKS_TAG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PYLAB_TICKS_TOOLTIP)}},Zc={init:function(){this.setColour(lc),this.appendValueInput("VET").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT).appendField(Jt.Msg.mixpy_SUBPLOT_VERTICLE),this.appendValueInput("HOR").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT_HORIZEN),this.appendValueInput("NUM").setCheck(Number).appendField(Jt.Msg.mixpy_SUBPLOT_NUM),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_CONTROLS_RANGE_TOOLTIP)}},td={init:function(){this.setColour(lc),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PL_SAVEFIG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.mixpy_PL_SAVEFIG_TOOLTIP)}},ed={init:function(){this.setColour(lc);var t=[[Jt.Msg.TEXT_TRIM_LEFT,"right"],[Jt.Msg.mixpy_PL_TEXT_CENTER,"center"],[Jt.Msg.TEXT_TRIM_RIGHT,"left"]],e=[[Jt.Msg.mixpy_PL_TEXT_TOP,"bottom"],[Jt.Msg.mixpy_PL_TEXT_CENTER,"center"],[Jt.Msg.mixpy_PL_TEXT_BOTTOM,"top"]];this.appendValueInput("VET").setCheck(Number).appendField(Jt.Msg.MIXLY_SETTING).appendField(Jt.Msg.mixpy_PL_TEXT_X),this.appendValueInput("HOR").setCheck(Number).appendField(Jt.Msg.mixpy_PL_TEXT_Y),this.appendValueInput("NUM").setCheck(Number).appendField(Jt.Msg.mixpy_PL_TEXT_TAG),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PL_TEXT_HOR).appendField(new Jt.FieldDropdown(t),"HALIGN"),this.appendDummyInput("").appendField(Jt.Msg.mixpy_PL_TEXT_VER).appendField(new Jt.FieldDropdown(e),"VALIGN"),this.appendValueInput("FONTNUM").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NUM),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.mixpy_PL_TEXT_TOOLTIP)}},nd={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("获取维度"),this.setOutput(!0),this.setTooltip("Returns the shape of the array.")}},id={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("变形"),this.appendValueInput("DIMENSIONS").appendField("后维度为"),this.setOutput(!0),this.setTooltip("Reshapes the array to the specified dimensions.")}},sd={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("把"),this.appendDummyInput().appendField("转换为").appendField(new Jt.FieldDropdown([["uint8","numpy.uint8"],["int32","numpy.int32"],["float32","numpy.float32"],["float64","numpy.float64"]]),"TYPE"),this.setOutput(!0),this.setTooltip("Converts array to specified type.")}},rd={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("创建二维图"),this.appendDummyInput().appendField("颜色").appendField(new Jt.FieldDropdown([["gray","gray"],["viridis","viridis"],["plasma","plasma"],["inferno","inferno"],["magma","magma"],["cividis","cividis"],["hot","hot"],["cool","cool"],["spring","spring"],["summer","summer"],["autumn","autumn"],["winter","winter"],["jet","jet"]]),"COLORMAP"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip("Displays an image with the specified colormap.")}},ad={init:function(){this.setColour(lc),this.appendValueInput("X").appendField("从数据集"),this.appendValueInput("Y").appendField("获取平均图像,标签"),this.appendValueInput("DIGIT").appendField("为"),this.setOutput(!0),this.setTooltip("Computes the mean of X where y equals the specified digit.")}},od={init:function(){this.setColour(lc),this.appendValueInput("IMAGE").appendField("获取模板匹配结果,图片:"),this.appendValueInput("TEMPLATES").appendField("模板:"),this.setOutput(!0),this.setTooltip("Finds the index of the template that minimizes the sum of absolute differences with the image.")}},ld={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("获取平均值"),this.appendDummyInput().appendField("沿着axis").appendField(new Jt.FieldDropdown([["None","NONE"],["0","0"],["1","1"]]),"AXIS"),this.setOutput(!0),this.setTooltip("Computes the mean of the array along the specified axis.")}},ud={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("获取标准差"),this.appendDummyInput().appendField("沿着axis").appendField(new Jt.FieldDropdown([["None","NONE"],["0","0"],["1","1"]]),"AXIS"),this.setOutput(!0),this.setTooltip("Computes the standard deviation of the array along the specified axis.")}},hd={init:function(){this.setColour(lc),this.appendValueInput("DF").appendField("丢弃缺省值"),this.setOutput(!0),this.setTooltip("Drops rows with NaN values from the dataframe.")}},pd={init:function(){this.setColour(lc),this.appendValueInput("DATAFRAME").appendField("从数据集"),this.appendValueInput("COLUMNS").appendField("中删除列").setCheck(String),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip("从数据框中删除指定的列。用逗号分隔多个列名。")}},cd={init:function(){this.setColour(lc),this.appendValueInput("NUM").appendField("生成单位行向量"),this.setOutput(!0),this.setTooltip("Creates an array of ones with the specified length.")}},dd={init:function(){this.setColour(lc),this.appendValueInput("ARRAY1").appendField("列拼接数组1"),this.appendValueInput("ARRAY2").appendField("数组2"),this.setOutput(!0),this.setTooltip("Concatenates two arrays along the second axis using numpy.c_.")}},fd={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("获取行列式"),this.setOutput(!0),this.setTooltip("Computes the determinant of an array using numpy.linalg.det.")}},md={init:function(){this.setColour(lc),this.appendValueInput("MATRIX").appendField("获取转置"),this.setOutput(!0),this.setTooltip("Computes the transpose of the given matrix.")}},gd={init:function(){this.setColour(lc),this.appendValueInput("MATRIX1"),this.appendValueInput("MATRIX2").appendField("@"),this.setOutput(!0),this.setTooltip("Multiplies two matrices.")}},_d={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("获取逆矩阵"),this.setOutput(!0),this.setTooltip("Computes the inverse of the given matrix using numpy.linalg.inv.")}},Td={init:function(){this.setColour(lc),this.appendValueInput("DATAFRAME").appendField("获取中位数"),this.setOutput(!0),this.setTooltip("Computes the median of the given dataframe.")}},yd={init:function(){this.setColour(lc),this.appendValueInput("DATAFRAME").appendField("填充缺失值"),this.appendValueInput("VALUE").appendField("填充值"),this.appendDummyInput().appendField("是否修改原数据").appendField(new Jt.FieldDropdown([["True","True"],["False","False"]]),"INPLACE"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip("Fills NaN values in the dataframe with the specified value.")}},Id={init:function(){this.setColour(lc),this.appendValueInput("DATAFRAME").appendField("获取DataFrame信息"),this.setOutput(!0),this.setTooltip("Displays information about the DataFrame.")}},Ed={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("获取最小值"),this.appendDummyInput().appendField("沿着axis").appendField(new Jt.FieldDropdown([["None","None"],["行","0"],["列","1"]]),"AXIS"),this.setOutput(!0),this.setTooltip("Returns the minimum value along the specified axis.")}},bd={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("获取最大值"),this.appendDummyInput().appendField("沿着axis").appendField(new Jt.FieldDropdown([["None","None"],["行","0"],["列","1"]]),"AXIS"),this.setOutput(!0),this.setTooltip("Returns the maximum value along the specified axis.")}},vd={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("获取数组大小"),this.setOutput(!0),this.setTooltip("Returns the size of the array.")}},wd={init:function(){this.setColour(lc),this.appendValueInput("ARRAY1").appendField("点乘数组1"),this.appendValueInput("ARRAY2").appendField("点乘数组2"),this.setOutput(!0),this.setTooltip("Returns the dot product of two arrays.")}},Sd={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("获取平方数组"),this.setOutput(!0),this.setTooltip("Returns the element-wise square of the array.")}},xd={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("获取数组元素和"),this.setOutput(!0),this.setTooltip("Returns the sum of the array.")}},Rd={init:function(){this.setColour(lc),this.appendValueInput("SIZE").appendField("生成随机数组"),this.setOutput(!0),this.setTooltip("Returns a random array of the specified size.")}},Od={init:function(){this.setColour(lc),this.appendValueInput("ARRAY").appendField("Python求和"),this.setOutput(!0),this.setTooltip("Returns the sum of the iterable.")}},Ad={init:function(){this.setColour(lc),this.appendValueInput("DICT").setAlign(Jt.inputs.Align.RIGHT).setCheck("Dict"),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField("值排序"),this.appendValueInput("KEY").setAlign(Jt.inputs.Align.RIGHT).appendField("标签"),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField("排序方式").appendField(new Jt.FieldDropdown([["升序","True"],["降序","False"]]),"AS_CENDING"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip("")}},Md={init:function(){this.setColour(lc),this.appendValueInput("DICT").setAlign(Jt.inputs.Align.RIGHT).setCheck("Dict"),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField("获取").appendField(new Jt.FieldDropdown([["前几行","head"],["最后几行","tail"]]),"TYPE"),this.appendValueInput("LINES").setAlign(Jt.inputs.Align.RIGHT).appendField("行数"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip("")}},Cd={init:function(){this.setColour(lc),this.appendValueInput("DICT").setAlign(Jt.inputs.Align.RIGHT).setCheck("Dict"),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField("筛选数据"),this.appendValueInput("KEY").setAlign(Jt.inputs.Align.RIGHT).appendField("满足条件"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip("")}},Nd={init:function(){this.setColour(lc),this.appendValueInput("DICT").setAlign(Jt.inputs.Align.RIGHT).setCheck("Dict"),this.appendValueInput("KEY").setAlign(Jt.inputs.Align.RIGHT).appendField("通过标签"),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField("分组"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip("")}},kd={init:function(){this.setColour(lc),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldDropdown([["求最小值","min"],["求最大值","max"],["求和","sum"],["求平均值","mean"],["求中位数","median"],["求标准差","std"]]),"TYPE"),this.appendValueInput("DICT").setAlign(Jt.inputs.Align.RIGHT).setCheck("Dict"),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip("")}},Dd={init:function(){this.setColour(lc),this.appendDummyInput().appendField("清除已有图像"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ld=80,Fd={init:function(){this.setColour(Ld),this.appendDummyInput("").appendField(new Jt.FieldLabel(Jt.Msg.DS_CREATE_LINKEDLIST_NEW)),this.appendDummyInput("").appendField(new Jt.FieldLabel(Jt.Msg.DS_CREATE_LINKEDLIST_HEAD)).appendField(new Jt.FieldTextInput("head"),"VAR"),this.appendDummyInput("").appendField(new Jt.FieldLabel(Jt.Msg.DS_CREATE_LINKEDLIST_TYPE)).appendField(new Jt.FieldTextInput("tag"),"TYPE"),this.appendDummyInput().appendField(Jt.Msg.DS_CREATE_LINKEDLIST_ATTRIBUTE),this.itemCount_=1,this.updateShape_(),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["ds_create_linkedlist_item"],this)),this.setTooltip(Jt.Msg.DS_CREATE_LINKEDLIST_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("ds_create_linkedlist_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("ds_create_linkedlist_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){this.getInput("EMPTY")&&this.removeInput("EMPTY");for(var t=[],e=0;this.getInput("ADD"+e);e++)t.push(this.getFieldValue("KEY"+e)),this.removeInput("ADD"+e);for(e=0;e<this.itemCount_;e++)this.appendValueInput("ADD"+e).setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldTextInput(t.length>e?t[e]:"name"),"KEY"+e).appendField("=")},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Pd={init:function(){this.setColour(Ld),this.appendDummyInput().appendField(Jt.Msg.DS_CREATE_LINKEDLIST_CONTAINER_TITLE),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.DS_CREATE_LINKEDLIST_CONTAINER_TOOLTIP),this.contextMenu=!1}},$d={init:function(){this.setColour(Ld),this.appendDummyInput().appendField(Jt.Msg.DS_CREATE_LINKEDLIST_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DS_CREATE_LINKEDLIST_ITEM_TOOLTIP),this.contextMenu=!1}},Bd={init:function(){this.setColour(Ld),this.appendDummyInput("").appendField(Jt.Msg.DS_CREATE_NODE_USE).appendField(new Jt.FieldTextInput("tag"),"TYPE"),this.appendDummyInput("").appendField(Jt.Msg.DS_CREATE_NODE_NEW),this.appendValueInput("NODE"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_CREATE_NODE_TOOLTIP)}},Vd={init:function(){this.setColour(Ld),this.appendDummyInput("").appendField(Jt.Msg.DS_GET_NODE_ATTR_NODE),this.appendValueInput("NODE"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_AIP_ATTR).appendField(new Jt.FieldTextInput("name"),"TYPE"),this.appendDummyInput("").appendField(Jt.Msg.DICTS_ADD_VALUE),this.setOutput(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_GET_NODE_ATTR_TOOLTIP)}},Ud={init:function(){this.setColour(Ld),this.appendDummyInput("").appendField(Jt.Msg.DS_SET_NODE_ATTR_NODE),this.appendValueInput("NODE"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_AIP_ATTR).appendField(new Jt.FieldTextInput("name"),"TYPE"),this.appendValueInput("VAR").appendField(Jt.Msg.DS_SET_NODE_ATTR_SET),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_SET_NODE_ATTR_TOOLTIP)}},Yd={init:function(){this.setColour(Ld),this.appendValueInput("NODE").appendField(Jt.Msg.DS_ADD_NODE_HEAD_NODE);var t=[[Jt.Msg.DS_ADD_NODE_BEFORE,"before"],[Jt.Msg.DS_ADD_NODE_AFTER,"after"]];this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_LINKEDLIST),this.appendValueInput("NODE2").appendField(Jt.Msg.DS_SET_NODE_ATTR_NODE),this.appendValueInput("NODE3").appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.DS_ADD_NODE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_ADD_NODE_TOOLTIP)}},Gd={init:function(){this.setColour(Ld),this.appendValueInput("NODE").appendField(Jt.Msg.DS_ADD_NODE_HEAD_NODE);var t=[[Jt.Msg.DS_ADD_NODE_BEFORE,"before"],[Jt.Msg.DS_ADD_NODE_AFTER,"after"]];this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_LINKEDLIST),this.appendDummyInput("").appendField(Jt.Msg.DS_CREATE_LINKEDLIST_ITEM_TITLE).appendField(new Jt.FieldTextInput("name"),"TYPE"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_AS),this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_ATTR),this.appendValueInput("NODE3").appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.DS_ADD_NODE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_ADD_NODE_TOOLTIP)}},Hd={init:function(){this.setColour(Ld),this.appendValueInput("NODE").appendField(Jt.Msg.DS_ADD_NODE_HEAD_NODE),this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_LINKEDLIST),this.appendValueInput("NODE2").appendField(Jt.Msg.DS_DEL_NODE_NAME),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_DEL_NODE_TOOLTIP)}},Wd={init:function(){this.setColour(Ld),this.appendValueInput("NODE").appendField(Jt.Msg.DS_ADD_NODE_HEAD_NODE),this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_LINKEDLIST),this.appendDummyInput("").appendField(Jt.Msg.DS_DEL_NODE_ATTR).appendField(new Jt.FieldTextInput("name"),"TYPE"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_AS),this.appendDummyInput("").appendField(Jt.Msg.DS_ADD_NODE_ATTR),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_DEL_NODE_TOOLTIP)}},zd={init:function(){this.setColour(Ld),this.appendValueInput("NODE").appendField(Jt.Msg.DS_ADD_NODE_HEAD_NODE),this.appendDummyInput("").appendField(Jt.Msg.DS_REVERSE_LINKEDLIST),this.appendValueInput("NODE2").appendField(Jt.Msg.DS_REVERSE_LINKEDLIST_NEW_HEAD),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.DS_DEL_NODE_TOOLTIP)}},Xd="#777777",jd={init:function(){this.setColour(Xd),this.appendDummyInput("").appendField("from ").appendField(new Jt.FieldTextInput("ESP32"),"path").appendField(" import ").appendField(new Jt.FieldTextInput("*"),"module"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},qd={init:function(){this.setColour(Xd),this.appendDummyInput("").appendField("import ").appendField(new Jt.FieldTextInput("module"),"module"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Kd={init:function(){this.setColour(Xd),this.appendDummyInput("").appendField(new Jt.FieldTextInput("my_function"),"NAME"),this.itemCount_=1,this.arguments_=["x"],this.updateShape_(),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["factory_create_with_item"],this))},mutationToDom:function(){var t=document.createElement("mutation");t.setAttribute("items",this.itemCount_);for(var e=0;e<this.arguments_.length;e++){var n=document.createElement("arg");n.setAttribute("name",this.arguments_[e]),t.appendChild(n)}return t},domToMutation:function(t){this.arguments_=[];for(var e=0;t.childNodes[e];e++){let n=t.childNodes[e];"arg"==n.nodeName.toLowerCase()&&this.arguments_.push(n.getAttribute("name"))}this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("factory_create_with_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("factory_create_with_item");s.initSvg(),s.setFieldValue(this.arguments_[i],"NAME"),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){this.arguments_=[];for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)this.arguments_.push(e.getFieldValue("NAME")),n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("ADD"+t);)this.removeInput("ADD"+t),t++;for(t=0;t<this.itemCount_;t++)this.appendValueInput("ADD"+t).setAlign(Jt.inputs.Align.RIGHT).appendField(this.arguments_[t])}},Qd={init:function(){this.setColour(Xd),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PARAMS),this.appendStatementInput("STACK"),this.contextMenu=!1}},Jd={init:function(){this.setColour(Xd),this.appendDummyInput().appendField(Jt.Msg.LISTS_CREATE_WITH_ITEM_TITLE+":").appendField(new Jt.FieldTextInput("x"),"NAME"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.contextMenu=!1}},Zd={init:function(){this.setColour(Xd),this.appendDummyInput("").appendField(new Jt.FieldTextInput("my_function"),"NAME"),this.itemCount_=1,this.arguments_=["x"],this.updateShape_(),this.setOutput(!0),this.setMutator(new Jt.icons.MutatorIcon(["factory_create_with_item"],this))},mutationToDom:Kd.mutationToDom,domToMutation:Kd.domToMutation,decompose:Kd.decompose,compose:Kd.compose,saveConnections:Kd.saveConnections,updateShape_:Kd.updateShape_},tf={init:function(){this.setColour(Xd),this.appendDummyInput("").appendField(new Jt.FieldTextInput("test"),"NAME").appendField("=").appendField(new Jt.FieldTextInput("Test"),"TYPE").appendField("()"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},ef={init:function(){this.setColour(Xd),this.appendDummyInput("").appendField(new Jt.FieldTextInput("test"),"NAME").appendField(".").appendField(new Jt.FieldTextInput("callMethod"),"METHOD"),this.itemCount_=1,this.arguments_=["x"],this.updateShape_(),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.icons.MutatorIcon(["factory_create_with_item"],this))},mutationToDom:Kd.mutationToDom,domToMutation:Kd.domToMutation,decompose:Kd.decompose,compose:Kd.compose,saveConnections:Kd.saveConnections,updateShape_:Kd.updateShape_},nf={init:function(){this.setColour(Xd),this.appendDummyInput("").appendField(new Jt.FieldTextInput("test"),"NAME").appendField(".").appendField(new Jt.FieldTextInput("callMethod"),"METHOD"),this.itemCount_=1,this.arguments_=["x"],this.updateShape_(),this.setOutput(!0),this.setMutator(new Jt.icons.MutatorIcon(["factory_create_with_item"],this))},mutationToDom:Kd.mutationToDom,domToMutation:Kd.domToMutation,decompose:Kd.decompose,compose:Kd.compose,saveConnections:Kd.saveConnections,updateShape_:Kd.updateShape_},sf={init:function(){this.setColour(Xd),this.appendDummyInput("").appendField(new Jt.FieldTextInput('display.scroll("Hello World!")'),"VALUE"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},rf={init:function(){this.setColour(Xd),this.appendDummyInput("").appendField(new Jt.FieldTextInput("test"),"VALUE"),this.setOutput(!0)}},af={init:function(){this.setColour(Xd),this.appendDummyInput("").appendField(new Jt.FieldMultilineInput('display.scroll("Hello World!")\ndisplay.scroll("Hello Mixly!")'),"VALUE"),this.setPreviousStatement(!0),this.setNextStatement(!0)}},of={init:function(){this.setColour(Xd),this.appendDummyInput("").appendField(new Jt.FieldMultilineInput("Hello\nMixly"),"VALUE"),this.setOutput(!0)}},lf=40,uf={init:function(){this.setColour(lf),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_HARDWARE),this.appendValueInput("SUB").setCheck("var"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_HARDWARE_START),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null)}},hf={init:function(){this.setColour(lf),this.appendDummyInput("").appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_HIGH,"HIGH"],[Jt.Msg.MIXLY_LOW,"LOW"]]),"BOOL"),this.setOutput(!0,Boolean),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_INOUT_HIGHLOW)}},pf={init:function(){this.setColour(lf),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_HARDWARE).setCheck("var"),this.appendValueInput("PIN",Number).appendField(Jt.Msg.MIXLY_Digital_PINMODEOUT).appendField(Jt.Msg.MIXLY_PIN).setCheck(Number),this.appendValueInput("STAT").appendField(Jt.Msg.MIXLY_STAT).setCheck([Number,Boolean]),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.LANG_INOUT_DIGITAL_WRITE_TOOLTIP)}},cf={init:function(){this.setColour(lf),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_HARDWARE).setCheck("var"),this.appendValueInput("PIN",Number).appendField(Jt.Msg.MIXLY_Digital_PINMODEIN).appendField(Jt.Msg.MIXLY_PIN).setCheck(Number),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_MACHINE_VALUE),this.setInputsInline(!0),this.setOutput(!0,[Boolean,Number]),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_INOUT_DIGITAL_READ)}},df={init:function(){this.setColour(lf),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_HARDWARE).setCheck("var"),this.appendValueInput("PIN",Number).appendField(Jt.Msg.MIXLY_Analog_PINMODEOUT).appendField(Jt.Msg.MIXLY_PIN).setCheck(Number),this.appendValueInput("NUM",Number).appendField(Jt.Msg.MIXLY_VALUE2).setCheck(Number),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_INOUT_ANALOG_WRITE)}},ff={init:function(){this.setColour(lf),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_HARDWARE).setCheck("var"),this.appendValueInput("PIN",Number).appendField(Jt.Msg.MIXLY_Analog_PINMODEIN).appendField(Jt.Msg.MIXLY_PIN).setCheck(Number),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_MACHINE_VALUE),this.setInputsInline(!0),this.setOutput(!0,[Boolean,Number]),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_INOUT_ANALOG_READ)}},mf={init:function(){this.setColour(20),this.appendValueInput("VAR").appendField(Jt.Msg.blockpy_inout_raw_input).setCheck(String),this.setOutput(!0),this.setTooltip(Jt.Msg.INOUT_input_TOOLTIP)}},gf={init:function(){this.setColour(20),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_SERIAL_PRINTLN),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip(Jt.Msg.BLOCKPY_PRINT_TOOLTIP)}},_f={init:function(){this.setColour(20),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_SERIAL_PRINT),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip(Jt.Msg.TEXT_PRINT_TOOLTIP)}},Tf={init:function(){this.setColour(20),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_SERIAL_PRINT),this.appendValueInput("END").appendField(Jt.Msg.MIXLY_ENDSWITH),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_PYTHON_INOUT_PRINT_END_TOOLTIP)}},yf={init:function(){var t=[[Jt.Msg.LANG_MATH_STRING,"str"],[Jt.Msg.LANG_MATH_INT,"int"],[Jt.Msg.LANG_MATH_FLOAT,"float"]];this.setColour(20),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("VAR").appendField(Jt.Msg.PROCEDURES_MUTATORCONTAINER_TITLE).setCheck(String),this.setInputsInline(!0),this.setOutput(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{str:Jt.Msg.MIXLY_MIXPY_INOUT_STR_INPUT_TOOLTIP,int:Jt.Msg.MIXLY_MIXPY_INOUT_INT_INPUT_TOOLTIP,float:Jt.Msg.MIXLY_MIXPY_INOUT_FLOAT_INPUT_TOOLTIP}[t]}))}},If={init:function(){var t=[[Jt.Msg.LANG_MATH_STRING,"str"],[Jt.Msg.LANG_MATH_INT,"int"],[Jt.Msg.LANG_MATH_FLOAT,"float"]];this.setColour(20),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_GET).appendField(new Jt.FieldDropdown(t),"DIR"),this.appendValueInput("VAR").appendField(Jt.Msg.PROCEDURES_MUTATORCONTAINER_TITLE).setCheck(String),this.setInputsInline(!0),this.setOutput(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{str:Jt.Msg.MIXLY_MIXPY_INOUT_STR_INPUT_TOOLTIP,int:Jt.Msg.MIXLY_MIXPY_INOUT_INT_INPUT_TOOLTIP,float:Jt.Msg.MIXLY_MIXPY_INOUT_FLOAT_INPUT_TOOLTIP}[t]}))}},Ef={init:function(){this.setColour(20),this.itemCount_=2,this.updateShape_(),this.setPreviousStatement(!1),this.setNextStatement(!1),this.setInputsInline(!0),this.setMutator(new Jt.icons.MutatorIcon(["inout_print_item"],this)),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_MIXPY_INOUT_PRINT_MANY_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("inout_print_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("inout_print_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var t=0;this.getInput("ADD"+t);)this.removeInput("ADD"+t),t++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(Jt.Msg.MIXLY_MIXPY_INOUT_PRINT_EMPTY);else for(t=0;t<this.itemCount_;t++){var e=this.appendValueInput("ADD"+t);0==t&&e.appendField(Jt.Msg.MIXLY_SERIAL_PRINTLN)}}},bf={init:function(){this.setColour(20),this.appendDummyInput().appendField(Jt.Msg.MIXLY_SERIAL_PRINTLN),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.MIXLY_MIXPY_INOUT_PRINT_MANY_CONTAINER_TOOLTIP),this.contextMenu=!1}},vf={init:function(){this.setColour(20),this.appendDummyInput().appendField(Jt.Msg.LISTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_MIXPY_INOUT_PRINT_MANY_ITEM_TOOLTIP),this.contextMenu=!1}},wf="#526FC3",Sf={init:function(){this.setColour("#78AAE0"),this.appendValueInput("VAR").setCheck("var").appendField("OneNET"+Jt.Msg.TUPLE_JOIN),this.appendValueInput("CLIENT").setCheck(String).appendField(Jt.Msg.MIXLY_ESP32_ONENET_CLIENT),this.appendValueInput("SERVER").setCheck(String).appendField(Jt.Msg.MIXLY_ESP32_ONENET_SERVER),this.appendValueInput("USERNAME").setCheck(String).appendField(Jt.Msg.MIXLY_ESP32_ONENET_USERNAME),this.appendValueInput("PASSWORD").setCheck(String).appendField(Jt.Msg.MIXLY_ESP32_ONENET_PASSWORD),this.appendValueInput("TOPIC").setCheck(String).appendField(Jt.Msg.MIXLY_ESP32_ONENET_TOPIC),this.appendValueInput("SUB").appendField(Jt.Msg.MIXLY_ESP32_ONENET_SUB),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_ONENET_CONNECT_TOOLTIP)}},xf={init:function(){this.setColour("#78AAE0"),this.appendValueInput("VAR").setCheck("var").appendField("OneNET"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_DISCONNECT_ONENET),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_ONENET_DISCONNECT_TOOLTIP)}},Rf={init:function(){this.setColour("#78AAE0"),this.appendValueInput("VAR").setCheck("var").appendField("OneNET"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_CHECK_ONENET),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_ONENET_CHECK_TOOLTIP)}},Of={init:function(){this.setColour("#78AAE0"),this.appendValueInput("VAR").setCheck("var").appendField("OneNET"),this.appendValueInput("DICT").appendField(Jt.Msg.MIXLY_ESP32_PUBLISH_ONENET),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_IOT_ONENET_PRINT_DATA).appendField(new Jt.FieldCheckbox("TRUE"),"is_print"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_ONENET_PUBLISH_DICT_TOOLTIP)}},Af={init:function(){this.setColour("#78AAE0"),this.appendValueInput("VAR").setCheck("var").appendField("OneNET").setAlign(Jt.inputs.Align.RIGHT),this.appendDummyInput().appendField(new Jt.FieldLabel(Jt.Msg.MIXLY_ESP32_PUBLISH_ONENET),"TIP").setAlign(Jt.inputs.Align.RIGHT),this.itemCount_=2,this.updateShape_(),this.setInputsInline(!1),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Jt.Mutator(["iot_publish_item"])),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_ONENET_PUBLISH_TOOLTIP)},mutationToDom:function(){var t=document.createElement("mutation");return t.setAttribute("items",this.itemCount_),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},decompose:function(t){var e=t.newBlock("iot_publish_container");e.initSvg();for(var n=e.getInput("STACK").connection,i=0;i<this.itemCount_;i++){var s=t.newBlock("iot_create_with_item");s.initSvg(),n.connect(s.previousConnection),n=s.nextConnection}return e},compose:function(t){for(var e=t.getInputTargetBlock("STACK"),n=[],i=0;e;)n[i]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),i++;this.itemCount_=i,this.updateShape_();for(i=0;i<this.itemCount_;i++)n[i]&&this.getInput("ADD"+i).connection.connect(n[i])},saveConnections:function(t){for(var e=t.getInputTargetBlock("STACK"),n=0;e;){var i=this.getInput("ADD"+n);e.valueConnection_=i&&i.connection.targetConnection,n++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){this.getInput("EMPTY")&&this.removeInput("EMPTY");for(var t=[],e=0;this.getInput("ADD"+e);e++)t.push(this.getFieldValue("KEY"+e)),this.removeInput("ADD"+e);if(0==this.itemCount_)this.setFieldValue(Jt.Msg.MIXLY_ESP32_PUBLISH_ONENET_EMPTY,"TIP");else{this.setFieldValue(Jt.Msg.MIXLY_ESP32_PUBLISH_ONENET,"TIP");for(e=0;e<this.itemCount_;e++)this.appendValueInput("ADD"+e).setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldTextInput(t.length>e?t[e]:'"key'+(e+1)+'"'),"KEY"+e).appendField(":")}},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Mf={init:function(){this.setColour(wf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_TYPE_DICT),this.appendStatementInput("STACK"),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},Cf={init:function(){this.setColour(wf),this.appendDummyInput().appendField(Jt.Msg.DICTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},Nf={init:function(){this.setColour(wf),this.appendDummyInput().appendField(Jt.Msg.DICTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.DICTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},kf={init:function(){this.setColour(wf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_CREATE_MQTT_CLIENT_AND_CONNECT),this.appendValueInput("SERVER").setCheck(String).appendField(Jt.Msg.MIXLY_EMQX_SERVER).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("USERNAME").setCheck(String).appendField(Jt.Msg.MIXLY_WIFI_USERNAME).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("PASSWORD").setCheck(String).appendField(Jt.Msg.MIXLY_IOT_PASSWORD).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("PROJECT").setCheck(String).appendField(Jt.Msg.MIXLY_EMQX_PROJECT).setAlign(Jt.inputs.Align.RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Df={init:function(){this.setColour(wf),this.appendDummyInput().appendField("MixIO"),this.appendValueInput("TOPIC").appendField(Jt.Msg.MIXLY_EMQX_PUBLISH_NEW).appendField(Jt.Msg.MIXLY_EMQX_PUBLISH_TOPIC),this.appendValueInput("MSG").appendField(Jt.Msg.HTML_BODY),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_EMQX_PUBLISH_TOOLTIP)}},Lf={init:function(){this.setColour(wf),this.appendDummyInput().appendField("MixIO"),this.appendValueInput("TOPIC").appendField(Jt.Msg.MIXLY_EMQX_SUBSCRIBE+Jt.Msg.MIXLY_MICROBIT_MSG).appendField(Jt.Msg.MIXLY_EMQX_PUBLISH_TOPIC),this.appendValueInput("METHOD").appendField(Jt.Msg.MIXLY_EMQX_SET_METHOD),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_EMQX_SUBSCRIBE_TOOLTIP)}},Ff={init:function(){this.setColour(wf),this.appendDummyInput().appendField("MixIO"),this.appendValueInput("TOPIC").appendField(Jt.Msg.MSG.stop+Jt.Msg.MIXLY_EMQX_SUBSCRIBE).appendField(Jt.Msg.MIXLY_EMQX_PUBLISH_TOPIC),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_EMQX_SUBSCRIBE_TOOLTIP)}},Pf={init:function(){this.setColour(wf),this.appendDummyInput().appendField("MixIO"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_DISCONNECT_ONENET),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},$f={init:function(){this.setColour(wf),this.appendDummyInput().appendField("MixIO"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_EMQX_CONNECT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Bf={init:function(){this.setColour(wf),this.appendDummyInput().appendField("MixIO"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_ESP32_CHECK_ONENET),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Vf={init:function(){this.setColour(wf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROPYTHON_FORMAT).appendField(Jt.MQTT_Topic),this.setInputsInline(!0),this.setOutput(!0)}},Uf={init:function(){this.setColour(wf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROPYTHON_FORMAT).appendField(Jt.Msg.MIXLY_EMQX_PUBLISH_MSG),this.setInputsInline(!0),this.setOutput(!0)}},Yf={init:function(){this.setColour(wf),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_ESP32_IOT_MAP_FORMATING),this.setOutput(!0)}},Gf={init:function(){this.setColour(wf),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_MICROPYTHON_FORMAT+"(Json)"),this.setOutput(!0)}},Hf={init:function(){this.setColour(wf),this.appendDummyInput().appendField("MixIO"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_EMQX_PING),this.setInputsInline(!0),this.setOutput(!0),this.setTooltip(Jt.Msg.MIXLY_ESP32_IOT_EMQX_PING_TOOLTIP)}},Wf={init:function(){this.setColour(wf),this.appendDummyInput().appendField("MixIO").appendField(Jt.Msg.MIXLY_GET_NTP),this.appendValueInput("addr").appendField(Jt.blynk_SERVER_ADD),this.setInputsInline(!0),this.setOutput(!0)}},zf={init:function(){this.setColour(wf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_CREATE_MQTT_CLIENT_AND_CONNECT),this.appendValueInput("SERVER").appendField(Jt.Msg.MIXLY_EMQX_SERVER).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("KEY").appendField(Jt.Msg.CONTROLS_FOR_INPUT_WITH+Jt.Msg.MIXLY_MIXIO_SHARE_KEY).setAlign(Jt.inputs.Align.RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Xf={init:function(){this.setColour(wf),this.appendDummyInput().appendField(Jt.Msg.MIXLY_CREATE_MQTT_CLIENT_AND_CONNECT),this.appendValueInput("SERVER").appendField(Jt.Msg.MIXLY_EMQX_SERVER).setAlign(Jt.inputs.Align.RIGHT),this.appendValueInput("KEY").appendField(Jt.Msg.CONTROLS_FOR_INPUT_WITH+"Mixly Key").setAlign(Jt.inputs.Align.RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},jf={init:function(){this.VISITOR_ID=Zt.Config.BOARD.visitorId.str32.substring(0,8).toUpperCase(),this.setColour(wf),this.appendDummyInput("").appendField(this.newQuote_(!0)).appendField(new Jt.FieldTextInput(this.visitorId),"VISITOR_ID").appendField(this.newQuote_(!1)),this.setOutput(!0,null)},onchange:function(){const t=this.getFieldValue("VISITOR_ID");this.VISITOR_ID!==t&&this.setFieldValue(this.VISITOR_ID,"VISITOR_ID")},newQuote_:function(t){if(t==this.RTL)var e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==";else e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC";return new Jt.FieldImage(e,12,12,'"')}},qf={init:function(){this.VISITOR_ID=Zt.Config.BOARD.visitorId.str32.substring(0,8).toUpperCase(),this.setColour(wf),this.appendDummyInput("").appendField(new Jt.FieldTextInput(this.visitorId),"VISITOR_ID"),this.setOutput(!0,null)},onchange:function(){const t=this.getFieldValue("VISITOR_ID");this.VISITOR_ID!==t&&this.setFieldValue(this.VISITOR_ID,"VISITOR_ID")}},Kf={init:function(){this.setColour(wf),this.appendDummyInput().appendField("MixIO").appendField(Jt.Msg.MSG.catEthernet_clinet),this.setOutput(!0),this.setInputsInline(!0)}},Qf={init:function(){this.setColour(wf),this.appendDummyInput().appendField("HTTP"+Jt.Msg.MIXLY_Client),this.appendValueInput("addr").appendField(Jt.Msg.DISPLAY_IMAGE_LET2),this.appendDummyInput().appendField(Jt.Msg.MIXLY_REQUESTS_GET).appendField(Jt.Msg.MIXLY_GET_CURRENT_TIME).appendField(Jt.Msg.MIXLY_OPEN_DEBUG).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE,"True"],[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE,"False"]]),"key"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Jf={init:function(){this.setColour(wf),this.appendDummyInput().appendField("HTTP"+Jt.Msg.MIXLY_Client).appendField(Jt.Msg.MIXLY_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_REQUESTS_LEN,"client_len"],[Jt.Msg.MIXLY_REQUESTS_GET_LEN,"server_len"],[Jt.Msg.MIXLY_REQUESTS_MESSAGE,"text"]]),"key"),this.setOutput(!0),this.setInputsInline(!0)}},Zf={init:function(){this.setColour(wf),this.appendDummyInput().appendField("MQTT"+Jt.Msg.MIXLY_Client),this.appendValueInput("addr").appendField(Jt.Msg.MIXLY_CONNECTTO),this.appendDummyInput().appendField(Jt.Msg.MIXLY_INIT_SUBSCRIBE).appendField(Jt.MQTT_Topic).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_GET_CURRENT_TIME,""]]),"key").appendField(Jt.Msg.MIXLY_OPEN_DEBUG).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE,"True"],[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE,"False"]]),"key2"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},tm={init:function(){this.setColour(wf),this.appendDummyInput().appendField("MQTT"+Jt.Msg.MIXLY_Client).appendField(Jt.Msg.MIXLY_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_REQUESTS_LEN,"client_len"],[Jt.Msg.MIXLY_REQUESTS_GET_LEN,"server_len"],[Jt.Msg.MIXLY_REQUESTS_MESSAGE,"time_msg()"]]),"key"),this.setOutput(!0),this.setInputsInline(!0)}},em=Sf,nm=xf,im=Rf,sm=Af,rm=230,am={init:function(){this.setColour(rm),this.appendDummyInput("").appendField(new Jt.FieldDropdown(Zt.Profile.default.digital_write),"PIN"),this.setOutput(!0)}},om={init:function(){this.setColour(rm),this.appendDummyInput("").appendField(new Jt.FieldDropdown(Zt.Profile.default.digital_read),"PIN"),this.setOutput(!0)}},lm={init:function(){this.setColour(rm),this.appendDummyInput("").appendField(new Jt.FieldDropdown(Zt.Profile.default.analog_write),"PIN"),this.setOutput(!0)}},um={init:function(){this.setColour(rm),this.appendDummyInput("").appendField(new Jt.FieldDropdown(Zt.Profile.default.analog_read),"PIN"),this.setOutput(!0)}},hm={init:function(){this.setColour(40),this.appendDummyInput("").appendField(new Jt.FieldLabel(Jt.Msg.MIXPY_SERIAL_OPEN)).appendField(new Jt.FieldTextInput("ser"),"SER"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_SERIAL_BEGIN).appendField(new Jt.FieldDropdown([["115200","115200"],["256000","256000"],["128000","128000"],["57600","57600"],["56000","56000"],["43000","43000"],["38400","38400"],["28800","28800"],["19200","19200"],["9600","9600"],["4800","4800"],["2400","2400"],["1200","1200"],["600","600"],["300","300"],["110","110"]]),"BPS"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXPY_SERIAL_OPEN_TIMEOUT),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip(Jt.Msg.MIXPY_SERIAL_OPEN_TOOLTIP)}},pm={init:function(){this.setColour(40),this.appendValueInput("SER"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXPY_SERIAL_WRITE),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip(Jt.Msg.MIXPY_SERIAL_WRITE_TOOLTIP)}},cm={init:function(){this.setColour(40),this.appendValueInput("SER"),this.appendValueInput("VAR").setCheck(Number).appendField(Jt.Msg.MIXPY_SERIAL_READ),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.MIXPY_SERIAL_READ_TOOLTIP)}},dm={init:function(){this.setColour(40),this.appendValueInput("SER"),this.appendDummyInput().appendField(Jt.Msg.MIXPY_SERIAL_CLOSE),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setTooltip(Jt.Msg.MIXPY_SERIAL_CLOSE_TOOLTIP)}},fm=80,mm={init:function(){this.appendDummyInput().appendField(Jt.Msg.SKLEARN_CLASSIFICATION_GENERATION),this.appendValueInput("n_samples").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_SAMPLES),this.appendValueInput("n_features").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_FEATURES),this.appendValueInput("n_informative").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_EFFECTIVE_FEATURES),this.appendValueInput("n_redundant").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_REDUNDANT_FEATURES),this.appendValueInput("n_repeated").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_REPEATED_FEATURES),this.appendValueInput("n_classes").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_CLASSES),this.appendValueInput("n_clusters_per_class").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_CLUSTERS_PER_CLASSES),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},gm={init:function(){this.appendDummyInput().appendField(Jt.Msg.SKLEARN_REGRESSION_GENERATION),this.appendValueInput("n_samples").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_SAMPLES),this.appendValueInput("n_features").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_FEATURES),this.appendValueInput("n_informative").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_EFFECTIVE_FEATURES),this.appendValueInput("n_targets").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_LABELS),this.appendValueInput("bias").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.DEVIATION),this.appendValueInput("noise").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NOISE),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},_m={init:function(){this.appendDummyInput().appendField(Jt.Msg.SKLEARN_CLUSTERING_GENERATION),this.appendValueInput("n_samples").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_SAMPLES),this.appendValueInput("n_features").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_FEATURES),this.appendValueInput("centers").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_CLUSTERS),this.appendValueInput("cluster_std").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.STANDARD_DEVIATION_OF_CLUSTER),this.appendValueInput("center_box").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.CLUSTER_BOUNDING_BOX),this.appendValueInput("shuffle").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SHUFFLE_SAMPLES),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Tm={init:function(){var t=[[Jt.Msg.SKLEARN_LOAD_IRIS,"load_iris"],[Jt.Msg.SKLEARN_LOAD_BOSTON,"load_boston"],[Jt.Msg.SKLEARN_LOAD_DIABETES,"load_diabetes"],[Jt.Msg.SKLEARN_LOAD_BREAST_CANCER,"load_breast_cancer"],[Jt.Msg.SKLEARN_LOAD_LINNERUD,"load_linnerud"],[Jt.Msg.SKLEARN_LOAD_DIGITS,"load_digits"]];this.appendDummyInput().appendField("sklearn "+Jt.Msg.LOAD).appendField(new Jt.FieldDropdown(t),"type").appendField(new Jt.FieldTextInput("iris"),"name"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")},getVars:function(){return[this.getFieldValue("name")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("name"))&&this.setTitleValue(e,"name")}},ym={init:function(){this.appendValueInput("name").setCheck(null).appendField("sklearn "+Jt.Msg.DATA_SET),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.EIGENVALUES,"data"],[Jt.Msg.LABEL_VALUE,"target"],[Jt.Msg.FEATURE,"feature_names"],[Jt.Msg.mixpy_PYLAB_TICKS_TAG,"target_names"]]),"type"),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Im={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.DATA_SEGMENTATION),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.appendValueInput("train_target").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LABEL_VALUE),this.appendValueInput("test_size").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.TEST_SET_PROPORTION),this.appendValueInput("rondom_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Em={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.DATA_SEGMENTATION),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.appendValueInput("test_size").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.TEST_SET_PROPORTION),this.appendValueInput("rondom_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},bm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_LINEARREGRESSION_INIT),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("fit_intercept").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_CALCULATE_MODEL_INTERRUPT),this.appendValueInput("normalize").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_REGRESSION_NORMIALIZATION),this.appendValueInput("n_jobs").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_THREADS),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},vm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_RIDGE_INIT),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("alpha").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_REGULA_INTENSITY),this.appendValueInput("fit_intercept").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_CALCULATE_MODEL_INTERRUPT),this.appendValueInput("normalize").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_REGRESSION_NORMIALIZATION),this.appendValueInput("max_iter").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_MAX_ITER),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},wm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_DECISIONTREE_INIT).appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_CLASSIFICATION_ALGORITHM,"DecisionTreeClassifier"],[Jt.Msg.SKLEARN_REGRESSION_ALGORITHM,"DecisionTreeRegressor"]]),"type"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("max_depth").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_MAXIMUM_TREE_DEPTH),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Sm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_RANDOMFOREST_INIT).appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_CLASSIFICATION_ALGORITHM,"RandomForestClassifier"],[Jt.Msg.SKLEARN_REGRESSION_ALGORITHM,"RandomForestRegressor"]]),"type"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("n_estimators").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_TREES),this.appendValueInput("max_depth").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_MAXIMUM_TREE_DEPTH),this.appendValueInput("n_jobs").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_THREADS),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},xm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_KNN_INIT).appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_CLASSIFICATION_ALGORITHM,"KNeighborsClassifier"],[Jt.Msg.SKLEARN_REGRESSION_ALGORITHM,"KNeighborsRegressor"]]),"type"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("K").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField("K"),this.appendValueInput("n_jobs").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_THREADS),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Rm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_GAUSSINNB_INIT),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Om={init:function(){this.appendDummyInput().appendField("sklearn 初始化 PCA 算法"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("n_components").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_PCA_N_COMPONENTS),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Am={init:function(){this.appendDummyInput().appendField("sklearn PCA 降维"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Mm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_KMEANS_INIT),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("n_clusters").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.NUMBER_OF_CLUSTERS_JUST),this.appendValueInput("max_iter").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.SKLEARN_MAX_ITER),this.appendValueInput("random_state").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.RANDOM_SEED),this.setInputsInline(!1),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Cm={init:function(){this.appendDummyInput().appendField("sklearn K-均值聚类"),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Nm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.TRAINING_MODEL),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.appendValueInput("train_target").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LABEL_VALUE),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},km={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.TRAINING_MODEL),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Dm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.MODEL_PRODICTION),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Lm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.CALCULATE_THE_SCORE),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.appendValueInput("train_target").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.LABEL_VALUE),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Fm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.CALCULATE_THE_SCORE),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendValueInput("train_data").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.EIGENVALUES),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Pm={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_GENERALIZED_LINEAR_REGRESSION),this.appendValueInput("model_name").setAlign(Jt.inputs.Align.RIGHT).setCheck(null).appendField(Jt.Msg.MODEL_NAME),this.appendDummyInput().setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_COEF,"coef_"],[Jt.Msg.SKLEARN_INTERCEPT,"intercept_"]]),"type"),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},$m={init:function(){this.appendDummyInput().appendField("sklearn "+Jt.Msg.SKLEARN_CLUSTERING),this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MODEL_NAME),this.appendDummyInput().appendField(Jt.Msg.MIXLY_GET).appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_CLUSTER_CENTER,"cluster_centers_"],[Jt.Msg.SKLEARN_LABELS_AFTER_CLUSTERING,"labels_"],[Jt.Msg.SKLEARN_CLUSTERING_SUM_OF_SQUARED_DISTANCES,"inertia_"]]),"type"),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Bm={init:function(){this.appendValueInput("model_name").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField("sklearn").appendField(new Jt.FieldDropdown([[Jt.Msg.SKLEARN_SAVE_MODEL,"dump"],[Jt.Msg.SKLEARN_LOAD_MODEL,"load"]]),"type").appendField(" "+Jt.Msg.MODEL_NAME),this.appendValueInput("address").setCheck(null).setAlign(Jt.inputs.Align.RIGHT).appendField(Jt.Msg.MIXLY_MICROBIT_PY_STORAGE_THE_PATH),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(fm),this.setTooltip(""),this.setHelpUrl("")}},Vm=120,Um={init:function(){this.setColour(Vm),this.appendValueInput("DELAY_TIME",Number).appendField(Jt.Msg.MIXLY_DELAY+"("+Jt.Msg.MIXLY_MILLIS+")").setCheck(Number),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_CONTROL_DELAY)}},Ym={init:function(){this.setColour(Vm),this.appendDummyInput().appendField(Jt.Msg.blockpy_time_time),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_CONTROL_MILLIS)}},Gm={init:function(){this.setColour(Vm),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME),this.appendDummyInput().appendField(new Jt.FieldDropdown([[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_ALL,"all"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_YEAR,"0"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_MONTH,"1"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_DATE,"2"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_HOUR,"3"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_MINUTE,"4"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_SECOND,"5"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_INWEEK,"6"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_INYEAR,"7"],[Jt.Msg.MIXLY_SYSTEM_TIME_LOCALTIME_DST,"8"]]),"op"),this.setOutput(!0),this.setInputsInline(!0)}},Hm={init:function(){this.setColour(Vm),this.appendValueInput("STATUS_CODE",Number).appendField(Jt.Msg.MIXLY_MICROBIT_Panic_with_status_code).setCheck(Number),this.setPreviousStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_CONTROL_DELAY)}},Wm={init:function(){this.setColour(Vm),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MICROBIT_Reset_micro),this.setPreviousStatement(!0)}},zm={init:function(){this.setColour(Vm),this.appendValueInput("TIME").setCheck(Number).setAlign(Jt.inputs.Align.RIGHT).appendField("MsTimer2").appendField(Jt.Msg.MIXLY_MSTIMER2_EVERY),this.appendDummyInput().appendField("ms"),this.appendStatementInput("DO").appendField(Jt.Msg.MIXLY_MSTIMER2_DO),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Xm={init:function(){this.setColour(Vm),this.appendDummyInput().appendField("MsTimer2").appendField(Jt.Msg.MIXLY_MSTIMER2_START),this.setPreviousStatement(!0),this.setNextStatement(!0)}},jm={init:function(){this.setColour(Vm),this.appendDummyInput().appendField("MsTimer2").appendField(Jt.Msg.MIXLY_STOP),this.setPreviousStatement(!0),this.setNextStatement(!0)}},qm={init:function(){this.setColour(Vm),this.appendValueInput("DELAY_TIME",Number).appendField(Jt.Msg.MIXLY_DELAY).setCheck(Number),this.appendDummyInput().appendField(Jt.Msg.MIXLY_SECOND),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_CONTROL_DELAY)}},Km=180,Qm={init:function(){this.setColour(Km),this.appendDummyInput("").appendField(Jt.Msg.blockpy_turtle_create).appendField(new Jt.FieldTextInput("tina"),"VAR"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.blockpy_turtle_create_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Jm={init:function(){this.setColour(Km),this.appendDummyInput().appendField(Jt.Msg.blockpy_TURTLE_DONE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Zm={init:function(){this.setColour(Km),this.appendDummyInput().appendField(Jt.Msg.MIXLY_PYTHON_TURTLE_EXITONCLICK),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},tg={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_forward,"forward"],[Jt.Msg.blockpy_backward,"backward"]];this.setColour(Km),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_MICROBIT_JS_MOVE_BY).appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.MIXLY_MICROBIT_JS_MOVE_BY_num),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{forward:Jt.Msg.MIXLY_TOOLTIP_TURTEL_FORWARD,backward:Jt.Msg.MIXLY_TOOLTIP_TURTEL_BACKWARD}[t]}))}},eg={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_left,"left"],[Jt.Msg.blockpy_right,"right"]];this.setColour(Km),this.appendValueInput("VAR").appendField(Jt.Msg.blockpy_turtle_rotate).appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.MIXLY_MICROBIT_JS_BY_ANGLE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{left:Jt.Msg.MIXLY_TOOLTIP_TURTEL_LEFT,right:Jt.Msg.MIXLY_TOOLTIP_TURTEL_RIGHT}[t]}))}},ng={init:function(){this.setColour(Km),this.appendValueInput("TUR").setCheck("Turtle"),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.blockpy_setheading),this.appendDummyInput().appendField(Jt.Msg.blockpy_setheading_degree),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},ig={init:function(){this.setColour(Km),this.appendValueInput("TUR").setCheck("Turtle"),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_SCREEN_DELAY),this.appendDummyInput().appendField(Jt.Msg.MIXLY_MILLIS),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TURTEL_SCREEN_DELAY),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},sg={init:function(){this.setColour(Km),this.appendValueInput("TUR").setCheck("Turtle"),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.blockpy_turtle_goto),this.appendValueInput("val").setCheck(Number).appendField(Jt.Msg.blockpy_turtle_goto_y),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_goto_position),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},rg={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.PYLAB_LABEL_X,"x"],[Jt.Msg.PYLAB_LABEL_Y,"y"]];this.setColour(Km),this.appendValueInput("VAR").appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_SETXY),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_MIXPY_TURTLE_SETXY_TOOLTIP)}},ag={init:function(){this.setColour(Km);var t=[[Jt.Msg.TURTLE_POS,"pos"],[Jt.Msg.TURTLE_SHAPE,"shape"],[Jt.Msg.TURTLE_HEADING,"heading"],[Jt.Msg.MIXLY_MIXPY_TURTLE_WIDTH,"width"],[Jt.Msg.MIXLY_TURTEL_GET_SHAPESIZE,"shapesize"],[Jt.Msg.MIXLY_SPEED,"speed"]];this.appendValueInput("TUR").setCheck("Turtle"),this.appendDummyInput("").appendField(Jt.Msg.TURTLE_POS_SHAPE).appendField(new Jt.FieldDropdown(t),"DIR");var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{pos:Jt.Msg.MIXLY_TOOLTIP_TURTEL_POS,shape:Jt.Msg.MIXLY_TOOLTIP_TURTEL_SHAPE,heading:Jt.Msg.MIXLY_TOOLTIP_TURTEL_HEADING,width:Jt.Msg.MIXLY_TOOLTIP_TURTEL_WIDTH,speed:Jt.Msg.MIXLY_TOOLTIP_TURTEL_GET_SPEED,shapesize:Jt.Msg.MIXLY_TURTEL_GET_SHAPESIZE_TOOLTIP}[t]})),this.setOutput(!0),this.setInputsInline(!0)}},og={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.MIXLY_LCD_STAT_CLEAR,"clear"],[Jt.Msg.blockpy_turtle_reset,"reset"],[Jt.Msg.blockpy_turtle_home,"home"]];this.setColour(Km),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"DIR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{clear:Jt.Msg.MIXLY_TOOLTIP_TURTEL_CLEAR,reset:Jt.Msg.MIXLY_TOOLTIP_TURTEL_RESET,home:Jt.Msg.MIXLY_TOOLTIP_TURTEL_HOME}[t]}))}},lg={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_turtle_penup,"penup"],[Jt.Msg.blockpy_turtle_pendown,"pendown"]];this.setColour(Km),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"DIR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{penup:Jt.Msg.MIXLY_TOOLTIP_TURTEL_PENUP,pendown:Jt.Msg.MIXLY_TOOLTIP_TURTEL_PENDOWN}[t]}))}},ug={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_turtle_beginfill,"begin"],[Jt.Msg.blockpy_turtle_endfill,"end"]];this.setColour(Km),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"DIR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{begin:Jt.Msg.MIXLY_TOOLTIP_TURTEL_BEGINFILL,end:Jt.Msg.MIXLY_TOOLTIP_TURTEL_ENDFILL}[t]}))}},hg={init:function(){this.appendDummyInput("").appendField(new Jt.FieldTextInput("tina"),"TUR");var t=[[Jt.Msg.blockpy_turtle_size,"pensize"],[Jt.Msg.MIXLY_SPEED,"speed"]];this.setColour(Km),this.appendValueInput("VAR").appendField(Jt.Msg.blockpy_turtle_set).appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.blockpy_turtle_set_num),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{pensize:Jt.Msg.MIXLY_TOOLTIP_TURTEL_SIZE,speed:Jt.Msg.MIXLY_TOOLTIP_TURTEL_SPEED}[t]}))}},pg={init:function(){this.setColour(Km),this.appendValueInput("TUR").setCheck("Turtle"),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.blockpy_turtle_set_size),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TURTEL_SIZE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},cg={init:function(){this.setColour(Km),this.appendValueInput("TUR").setCheck("Turtle"),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.blockpy_turtle_set_speed),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TURTEL_SPEED),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},dg={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_turtle_circle,"circle"],[Jt.Msg.blockpy_turtle_dot,"dot"]];this.setColour(Km),this.appendValueInput("VAR").appendField(Jt.Msg.blockpy_turtle_draw).appendField(new Jt.FieldDropdown(t),"DIR").appendField(Jt.Msg.blockpy_turtle_radius),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{circle:Jt.Msg.MIXLY_TOOLTIP_TURTEL_CIRCLE,dot:Jt.Msg.MIXLY_TOOLTIP_TURTEL_DOT}[t]}))}},fg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_DRAW_CIRCLE).appendField(Jt.Msg.blockpy_turtle_radius),this.appendValueInput("data").setCheck(Number).appendField(Jt.Msg.blockpy_turtle_angle),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_TURTEL_CIRCLE)}},mg={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_turtle_hide,"hideturtle"],[Jt.Msg.blockpy_turtle_show,"showturtle"]];this.setColour(Km),this.appendDummyInput("").appendField(new Jt.FieldDropdown(t),"DIR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip((function(){var t=e.getFieldValue("DIR");return{hideturtle:Jt.Msg.MIXLY_TOOLTIP_TURTEL_HIDE,showturtle:Jt.Msg.MIXLY_TOOLTIP_TURTEL_SHOW}[t]}))}},gg={init:function(){this.setColour(Km),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_bgcolor).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},_g={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_pencolor).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Tg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_fillcolor).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},yg={init:function(){this.setColour(Km),this.appendValueInput("TUR").setCheck("Turtle"),this.appendDummyInput("").appendField(Jt.Msg.TURTLE_CLONE),this.setTooltip(Jt.Msg.TURTLE_CLONE_TOOLTIP),this.setOutput(!0)}},Ig={init:function(){this.setColour(Km),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_bgcolor),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Eg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_pencolor),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},bg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_fillcolor),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},vg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_pencolor).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME"),this.appendDummyInput().appendField(Jt.Msg.blockpy_turtle_fillcolor).appendField(new Jt.FieldColour("#ff0000"),"FIELDNAME2"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},wg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendValueInput("VAR1").setCheck(String).appendField(Jt.Msg.blockpy_turtle_pencolor),this.appendValueInput("VAR2").setCheck(String).appendField(Jt.Msg.blockpy_turtle_fillcolor),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Sg={init:function(){this.setColour(Km),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_bgcolor_hex),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},xg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_pencolor_hex),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Rg={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_fillcolor_hex),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Og={init:function(){this.appendValueInput("TUR").setCheck("Turtle");var t=[[Jt.Msg.blockpy_turtle_shape_arrow,"arrow"],[Jt.Msg.blockpy_turtle_shape_turtle,"turtle"],[Jt.Msg.blockpy_turtle_shape_circle,"circle"],[Jt.Msg.blockpy_turtle_shape_square,"square"],[Jt.Msg.blockpy_turtle_shape_triangle,"triangle"],[Jt.Msg.blockpy_turtle_shape_classic,"classic"]];this.setColour(Km),this.appendDummyInput("").appendField(Jt.Msg.blockpy_turtle_shape).appendField(new Jt.FieldDropdown(t),"DIR"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.TURTLE_SHAPE_TOOLTIP)}},Ag={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTEL_SHAPESIZE),this.appendValueInput("WID").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTEL_SHAPESIZE_WID),this.appendValueInput("LEN").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTEL_SHAPESIZE_LEN),this.appendValueInput("OUTLINE").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTEL_SHAPESIZE_OUTLINE),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_TOOLTIP_SHAPESIZE)}},Mg={init:function(){this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_NUMINPUT),this.setColour(Km),this.appendValueInput("TITLE").setCheck(String).appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_TEXTINPUT_TITLE),this.appendValueInput("PROMPT").setCheck(String).appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_TEXTINPUT_PROMPT),this.appendValueInput("DEFAULT").setCheck(Number).appendField(Jt.Msg.DICTS_DEFAULT_VALUE),this.appendValueInput("MIN").setCheck(Number).appendField(Jt.Msg.MATH_ONLIST_OPERATOR_MIN),this.appendValueInput("MAX").setCheck(Number).appendField(Jt.Msg.MATH_ONLIST_OPERATOR_MAX),this.setInputsInline(!0),this.setOutput(!0,Number),this.setTooltip(Jt.Msg.TURTLE_NUMINPUT_TOOLTIP)}},Cg={init:function(){this.appendDummyInput("").appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_TEXTINPUT),this.setColour(Km),this.appendValueInput("TITLE").setCheck(String).appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_TEXTINPUT_TITLE),this.appendValueInput("PROMPT").setCheck(String).appendField(Jt.Msg.MIXLY_MIXPY_TURTLE_TEXTINPUT_PROMPT),this.setInputsInline(!0),this.setOutput(!0,String),this.setTooltip(Jt.Msg.TURTLE_TEXTINPUT_TOOLTIP)}},Ng={init:function(){this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_write),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.TURTLE_WRITE_TOOLTIP)}},kg={init:function(){var t=[[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE,"False"],[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE,"True"]],e=[[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_LEFT,"left"],[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_CENTER,"center"],[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_RIGHT,"right"]],n=[[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_NORMAL,"normal"],[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_BOLD,"bold"],[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_ITALIC,"italic"],[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_BOLD_ITALIC,'bold","italic']];this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_write),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_MOVE).appendField(new Jt.FieldDropdown(t),"MOVE"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN).appendField(new Jt.FieldDropdown(e),"ALIGN"),this.appendValueInput("FONTNAME").setCheck(String).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NAME),this.appendValueInput("FONTNUM").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NUM),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE).appendField(new Jt.FieldDropdown(n),"FONTTYPE"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.TURTLE_WRITE_TOOLTIP)}},Dg={init:function(){var t=[[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_FALSE,"False"],[Jt.Msg.MIXLY_TURTLE_WRITE_MOVE_TRUE,"True"]],e=[[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_LEFT,"left"],[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_CENTER,"center"],[Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN_RIGHT,"right"]],n=[[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_NORMAL,"normal"],[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_BOLD,"bold"],[Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE_ITALIC,"italic"]];this.appendValueInput("TUR").setCheck("Turtle"),this.setColour(Km),this.appendValueInput("VAR").setCheck(String).appendField(Jt.Msg.blockpy_turtle_write),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_MOVE).appendField(new Jt.FieldDropdown(t),"MOVE"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_ALIGN).appendField(new Jt.FieldDropdown(e),"ALIGN"),this.appendValueInput("FONTNAME").setCheck(String).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NAME),this.appendValueInput("FONTNUM").setCheck(Number).appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_NUM),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTLE_WRITE_FONT_TYPE).appendField(new Jt.FieldDropdown(n),"FONTTYPE"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.TURTLE_WRITE_TOOLTIP)}},Lg={init:function(){this.setColour(Km),this.appendDummyInput("").setAlign(Jt.inputs.Align.RIGHT).appendField(new Jt.FieldColour("ff0000"),"COLOR"),this.setInputsInline(!0),this.setOutput(!0,String)}},Fg={init:function(){this.setColour(Km),this.appendValueInput("TUR").setCheck("Turtle"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTEL_GETSCREEN).appendField(new Jt.FieldTextInput("screen"),"VAR"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Jt.Msg.MIXLY_TURTEL_GETSCREEN_TOOLTIP)},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(t,e){Jt.Names.equals(t,this.getFieldValue("VAR"))&&this.setTitleValue(e,"VAR")}},Pg={init:function(){this.setColour(Km),this.appendValueInput("TUR"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TURTEL_EVENT_ONKEY),this.appendValueInput("callback").appendField(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_USE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TURTEL_EVENT_ONKEY_TOOLTIP)}},$g={init:function(){this.setColour(Km),this.appendValueInput("TUR"),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_TURTEL_EVENT_ONCLICK),this.appendValueInput("callback").appendField(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_USE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TURTEL_EVENT_ONCLICK_TOOLTIP)}},Bg={init:function(){this.setColour(Km),this.appendValueInput("TUR"),this.appendValueInput("VAR").appendField(Jt.Msg.MIXLY_TURTEL_EVENT_ONTIMER),this.appendDummyInput("").appendField(Jt.Msg.MIXLY_mSecond),this.appendValueInput("callback").appendField(Jt.Msg.MIXLY_PYTHON_CONTROLS_THREAD_USE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Jt.Msg.MIXLY_TURTEL_EVENT_ONTIMER_TOOLTIP)}},Vg={init:function(){this.setColour(Km),this.appendValueInput("TUR"),this.appendDummyInput().appendField(Jt.Msg.MIXLY_TURTEL_SCREEN_LISTEN),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0)}},Ug={init:function(){this.setColour(Km),this.appendValueInput("TUR"),this.appendValueInput("FILE").setCheck(String).appendField(Jt.Msg.mixpy_PL_SAVEFIG),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setOutput(!1),this.setTooltip(Jt.Msg.mixpy_TURTLE_SAVEFIG_TOOLTIP)}},Yg=function(t,e){var n=this.getFieldValue("TYPE");return e.definitions_.import_FileDialog="import FileDialog",["FileDialog."+n+"()",e.ORDER_ATOMIC]},Gg=function(t,e){var n=this.getFieldValue("CTYPE");return e.definitions_.import_aip="import aip",e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+" = aip."+n+"("+e.valueToCode(this,"API_KEY",e.ORDER_ATOMIC)+", "+e.valueToCode(this,"SECRET_KEY",e.ORDER_ATOMIC)+")\n"},Hg=function(t,e){return e.definitions_.import_aip="import aip",[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".synthesis("+e.valueToCode(this,"STR",e.ORDER_ATOMIC)+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},Wg=function(t,e){return e.definitions_.import_aip="import aip",[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".asr("+(e.valueToCode(this,"FILE",e.ORDER_ATOMIC)||'""')+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},zg=function(t,e){e.definitions_.import_aip="import aip";var n=e.valueToCode(this,"SUB",e.ORDER_ATOMIC),i=e.valueToCode(this,"ADDR",e.ORDER_ATOMIC);return[n+"."+e.valueToCode(this,"FUNC",e.ORDER_ATOMIC)+"("+i+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},Xg=function(t,e){return e.definitions_.import_aip="import aip",[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".match("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+","+e.valueToCode(this,"VAR2",e.ORDER_ATOMIC)+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},jg=function(t,e){e.definitions_.import_aip="import aip";var n=e.valueToCode(this,"SUB",e.ORDER_ATOMIC),i=e.valueToCode(this,"ADDR",e.ORDER_ATOMIC);return[n+"."+e.valueToCode(this,"FUNC",e.ORDER_ATOMIC)+"("+i+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},qg=function(t,e){e.definitions_.import_aip="import aip";var n=e.valueToCode(this,"SUB",e.ORDER_ATOMIC),i=e.valueToCode(this,"STR",e.ORDER_ATOMIC);return[n+"."+e.valueToCode(this,"FUNC",e.ORDER_ATOMIC)+"("+i+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},Kg=function(t,e){e.definitions_.import_aip="import aip";var n=e.valueToCode(this,"SUB",e.ORDER_ATOMIC),i=e.valueToCode(this,"STR1",e.ORDER_ATOMIC),s=e.valueToCode(this,"STR2",e.ORDER_ATOMIC);return[n+"."+e.valueToCode(this,"FUNC",e.ORDER_ATOMIC)+"("+i+","+s+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},Qg=function(t,e){return e.definitions_.import_aip="import aip",[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".topic("+e.valueToCode(this,"STR1",e.ORDER_ATOMIC)+","+e.valueToCode(this,"STR2",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},Jg=function(t,e){return e.definitions_.import_aip="import aip",[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".newsSummary("+e.valueToCode(this,"STR",e.ORDER_ATOMIC)+","+e.valueToCode(this,"LEN",e.ORDER_ATOMIC)+", options="+(e.valueToCode(this,"ATTR",e.ORDER_ATOMIC)||"{}")+")",e.ORDER_ATOMIC]},Zg=function(t,e){return[this.getFieldValue("TYPE"),e.ORDER_ATOMIC]},t_=function(t,e){return[this.getFieldValue("TYPE"),e.ORDER_ATOMIC]},e_=function(t,e){return[this.getFieldValue("TYPE"),e.ORDER_ATOMIC]},n_=function(t,e){return[this.getFieldValue("TYPE"),e.ORDER_ATOMIC]},i_=function(t,e){return e.definitions_.import_audio="import audio","audio.audio_record("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+","+(e.valueToCode(this,"TIME",e.ORDER_ATOMIC)||"0")+")\n"},s_=function(t,e){return e.definitions_.import_audio="import cam","cam.photo_capture("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+","+(e.valueToCode(this,"BUT",e.ORDER_ATOMIC)||'""')+")\n"},r_=function(t,e){var n=e.valueToCode(this,"AI",e.ORDER_ASSIGNMENT)||"0",i=this.getFieldValue("CTYPE");if("Image"==i)var s=n+'["result"][0]["keyword"]';if("Speech"==i)s=n+'["result"][0]';if("Face"==i||"OcrSimilarity"==i)s=n+'["score"]';if("Ocr"==i)s=n+'["words_result"]';return[s,e.ORDER_ATOMIC]},a_=function(t,e){e.definitions_.import_sprite="import sprite";return"g = [[0,0,0,0,0,0,0,0,0,0], [0,0,0,1,0,0,0,0,0,0], [0,0,0,1,0,0,1,0,0,0], [0,1,1,0,1,1,0,0,0,0], [0,0,0,1,0,0,0,1,0,0], [0,0,0,1,0,0,1,1,0,0], [0,0,1,0,0,1,0,1,0,0], [0,0,0,0,1,1,1,0,0,0]]\nmark = [[0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0]]\nvis = [0,1,0,0,0,0,0,0,0]\nposition = [[0, 0], [200, 200], [250, 60], [320, 200], [280, 380], [470, 250], [670, 90], [650, 340]]\nsprite.clearAllSprites()\nsprite.createBackground('ditu')\nmask = sprite.Sprite('white', 96, 354)\nmask.hide()\nhouse = [\n sprite.Sprite('mark', 150, 380),\n sprite.Sprite('xtxn', 96, 170),\n sprite.Sprite('xnvijx', 270, 45),\n sprite.Sprite('xnxbjx', 310, 182),\n sprite.Sprite('xnsijx', 300, 370),\n sprite.Sprite('xnkejx', 495, 220),\n sprite.Sprite('bwbwjx', 716, 85),\n sprite.Sprite('lelejx', 686, 314)\n]\nfor i in house:\n i.filterBrighter()\n i.hide()\n"},o_=function(){return"path = [1]\nmask.show()\ncar = sprite.Sprite('xnie', position[1][0], position[1][1])\nhouse[1].show()\ncar.nowPos = 1\ndef drive(n):\n if g[car.nowPos][n]==1:\n car.slideTo(position[n][0], position[n][1], 1)\n car.nowPos = n\n else:\n print('移动失败!程序有误!')\n exit()\n"},l_=function(t,e){e.definitions_.import_random="import random";return"f = path[(len(path) - 1)]\nflag = 0\nfor _my_variable in [6,5,4,3,2,1,0]:\n if vis[_my_variable+1] == 0 and g[f][_my_variable+1] == 1:\n if mark[f][_my_variable+1] == 0:\n flag = 1\n break\n"},u_=function(t,e){return["flag == 1",e.ORDER_ATOMIC]},h_=function(){return"mark[f][_my_variable+1] = 1\nvis[_my_variable+1] = 1\n"},p_=function(){return"path.append(_my_variable+1)\ndrive(path[len(path) - 1])\nhouse[_my_variable+1].show()\n"},c_=function(t,e){e.definitions_.import_time="import time";return"del path[len(path) - 1]\nhouse[0].show()\ntime.sleep(0.5)\nhouse[0].hide()\n"},d_=function(){var t="for i in range(7):\n mark[f][i+1] = 0\n vis[f] = 0\n";return t="house[f].hide()\ndrive(path[len(path) - 1])\n"+t},f_=function(t,e){return["len(path) == 7",e.ORDER_ATOMIC]},m_=function(){return'name = ["","学校","小智家","小欣家","小思家","小科家","贝贝家","乐乐家"]\nres = ""\nfor i in path:\n res = res + name[i] + "-"\nprint(res[:-1])\n'},g_=function(t,e){e.definitions_.import_sprite="import sprite";return"g = [[0,0,0,0,0,0,0,0,0,0], [0,0,0,1,0,0,0,0,0,0], [0,0,0,1,0,0,1,0,0,0], [0,1,1,0,1,0,0,0,0,0], [0,0,0,1,0,0,0,1,0,0], [0,0,0,1,0,0,0,1,0,0], [0,0,1,0,0,0,0,1,0,0], [0,0,0,0,1,1,1,0,0,0]]\nmark = [[0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0]]\nvis = [0,1,0,0,0,0,0,0,0]\nposition = [[0, 0], [200, 200], [250, 60], [320, 200], [280, 380], [470, 250], [670, 90], [650, 340]]\nsprite.clearAllSprites()\nsprite.createBackground('ditu')\nmask = sprite.Sprite('white', 96, 354)\nmask.hide()\nhouse = [\n sprite.Sprite('mark', 150, 380),\n sprite.Sprite('xtxn', 96, 170),\n sprite.Sprite('xnvijx', 270, 45),\n sprite.Sprite('xnxbjx', 310, 182),\n sprite.Sprite('xnsijx', 300, 370),\n sprite.Sprite('xnkejx', 495, 220),\n sprite.Sprite('bwbwjx', 716, 85),\n sprite.Sprite('lelejx', 686, 314)\n]\nbarricade = sprite.Sprite('barricade', 610, 170)\nbarricade.enlargeTo(100)\nfor i in house:\n i.filterBrighter()\n i.hide()\n"},__=function(t,e){return["f == 1",e.ORDER_ATOMIC]},T_=function(){return"print('没有符合条件的路线')\n"},y_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return'g = [[10000,10000,10000,10000,10000,10000,10000,10000,10000,10000,10000],[10000,10000,500,300,10000,10000,10000,10000,10000,10000,10000],[10000,500,10000,10000,100,10000,10000,10000,10000,10000,10000],[10000,300,10000,10000,400,300,10000,10000,10000,10000,10000],[10000,10000,100,400,10000,10000,200,10000,10000,10000,10000],[10000,10000,10000,300,10000,10000,100,200,10000,10000,10000],[10000,10000,10000,10000,200,100,10000,10000,100,10000,10000],[10000,10000,10000,10000,10000,200,10000,10000,100,10000,10000],[10000,10000,10000,10000,10000,10000,100,100,10000,10000,10000]]\nnow=1\nlast=1\npath=[]\npath.append(1)\nname = ["","小思家","银行","邮局","餐厅","书店","医院","超市","小科家"]\nposition = [[0, 0], [60, 320], [510, 390], [240, 200], [750, 330], [410, 90], [540, 190], [550, 30], [720, 120]]\nsprite.clearAllSprites()\nsprite.createBackground(\'map_si_ke\')\nstu = sprite.Sprite(\'girl\', 60, 320)\nstu.enlargeTo(100)\ntime.sleep(1)\n\n'},I_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return'g =[[10000,10000,10000,10000,10000,10000,10000],[10000,10000,300,500,10000,10000,10000],[10000,300,10000,10000,300,700,10000],[10000,500,10000,10000,10000,100,10000],[10000,10000,300,10000,10000,10000,200],[10000,10000,700,100,10000,10000,100],[10000,10000,10000,10000,200,100,10000]]\nnow=1\nlast=1\npath=[]\npath.append(1)\nname = ["","小智家","邮局","银行","书店","餐厅","学校"]\nposition = [[0, 0], [70, 340], [70, 90], [550, 310], [420, 70], [730, 250], [650, 130]]\nsprite.clearAllSprites()\nsprite.createBackground(\'map_zhi_xue\')\nstu = sprite.Sprite(\'boy\', 70, 340)\nstu.enlargeTo(100)\ntime.sleep(1)\n\n'},E_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return'tmp=10000\nfor i in range(0, len(g), 1):\n if g[now][i]<tmp and i!=last:\n next=i\n tmp=g[now][i]\nstu.slideTo(position[next][0], position[next][1], 1)\ntime.sleep(0.5)\npath.append(next)\nlast=now\nnow=next\nif len(path)>6:\n print("路线错乱!程序有误!")\n exit()\n'},b_=function(t,e){return["name[now] != '小科家'",e.ORDER_ATOMIC]},v_=function(t,e){return["name[now] != '学校'",e.ORDER_ATOMIC]},w_=function(){return'res = ""\nfor i in path:\n res = res + name[i] + "→"\nprint(res[:-1])\n'},S_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n=this.getFieldValue("NUM");if(n>=7)var i="print('层数过高不得高于6层')\nexit()\n";else i="sprite.clearAllSprites()\n_Hanoicolor = ['blue', 'red', 'yellow', 'green', 'purple', 'black']\n_Hanoi = [[], [], []]\nA = 0\nB = 1\nC = 2\n_n = "+n+"\n_HanoiColumn = [\n sprite.Sprite('HanoiColumn', 200, 320),\n sprite.Sprite('HanoiColumn', 400, 320),\n sprite.Sprite('HanoiColumn', 600, 320)\n]\n_HanoiColumnNumber = [\n sprite.Text('A', 190, 120),\n sprite.Text('B', 390, 120),\n sprite.Text('C', 590, 120)\n]\n_HanoiBlock = []\nfor i in range(0, _n, 1):\n _HanoiBlock.append(sprite.Sprite(_Hanoicolor[i], 200, 400-(_n-i-1)*27))\n _HanoiBlock[i].setScale(25, 30*i+30)\n _Hanoi[0].insert(0, _HanoiBlock[i])\n_steptext = sprite.Text('步数0', 30, 30)\n_steps = {'steps' : 0}\ntime.sleep(1)\n";return i},x_=function(t,e){var n=e.valueToCode(this,"FROM_NUM",e.ORDER_ATOMIC)||"0",i=e.valueToCode(this,"TO_NUM",e.ORDER_ATOMIC)||"0";return`if len(_Hanoi[${n}])>0 :\n _HanoiBlockMoved = _Hanoi[${n}].pop()\n if len(_Hanoi[${i}]) > 0 :\n _HanoiBlockSuppressed = _Hanoi[${i}].pop()\n if _HanoiBlock.index(_HanoiBlockMoved) > _HanoiBlock.index(_HanoiBlockSuppressed):\n print('非法移动!程序有误!')\n exit()\n else:\n _Hanoi[${i}].append(_HanoiBlockSuppressed)\n _HanoiBlockMoved.slideTo(${n}*200+200, 180, 0.2)\n _HanoiBlockMoved.slideTo(${i}*200+200, 180, 0.5)\n _HanoiBlockMoved.slideTo(${i}*200+200, 400-len(_Hanoi[${i}])*27, 0.2)\n _Hanoi[${i}].append(_HanoiBlockMoved)\n _steps['steps'] += 1\n _steptext.changeText('步数:'+str(_steps['steps']))\nelse :\n print('非法移动!程序有误!')\n exit()\n`},R_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"if 'mode' not in globals() or mode == 0:\n sprite.clearAllSprites()\n ring=[0,0,0,0,0,0,0,0,0,0]\n mode=1\n n=5\n ring[5]=1\n name=['小王子','海底两万里','荷花镇的早市','孔子的故事','夏洛的网','草房子','月下看猫头鹰','会唱歌的咖啡磨','父与子','城南旧事']\n Books = []\n for i in range(1, 11, 1):\n Books.append(sprite.Sprite('books/book'+str(i), (130*i-650) if i>5 else 130*i, 320 if i>5 else 120))\nelse:\n mode=2\n n=len(ring)-1\nring[n]=1\ntime.sleep(1)\n"},O_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"if 'mode' not in globals() or mode == 0:\n sprite.clearAllSprites()\n ring=[0,0,0,0,0,0,0,0,0,0]\n mode=2\n n=5\n name=['小王子','海底两万里','荷花镇的早市','孔子的故事','夏洛的网','草房子','月下看猫头鹰','会唱歌的咖啡磨','父与子','城南旧事']\n Books = []\n for i in range(1, 11, 1):\n Books.append(sprite.Sprite('books/book'+str(i), (130*i-650) if i>5 else 130*i, 320 if i>5 else 120))\nelse:\n mode=1\n n=len(ring)-1\nring[n]=n\nlist=ring\ntemp=Books\ntime.sleep(1)\n"},A_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"res=0\nflag=ring[res]\nBooks[res].filterBrighter()\ntime.sleep(0.1)\nBooks[res].filterOrigin()\n"},M_=function(t,e){return["(('mode' not in globals())or(mode==1 and flag==0)or(mode==2 and not any(value > 0 for value in qian))or(mode==0))",e.ORDER_ATOMIC]},C_=function(t,e){return["(('mode' in globals())and((mode==1 and flag!=0)or(mode==2 and any(value > 0 for value in qian))))",e.ORDER_ATOMIC]},N_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n="res+=1\nflag=ring[res]\n";return n="Books[res].filterGray()\ntime.sleep(0.3)\n"+(n+="Books[res].filterBrighter()\ntime.sleep(0.1)\nBooks[res].filterOrigin()\n")},k_=function(t,e){return["len(list)>=2",e.ORDER_ATOMIC]},D_=function(){return"mid = int(len(list)/2)\nqian = list[0:mid]\nhou = list[mid:]\nqiantemp = temp[0:mid]\nhoutemp = temp[mid:]\n"},L_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"quchu = qian\nlist = hou\nquchutemp = qiantemp\ntemp = houtemp\nfor i in qiantemp:\n i.filterBrighter()\ntime.sleep(0.5)\nfor i in qiantemp:\n i.filterGray()\ntime.sleep(0.5)\n"},F_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"list = quchu\ntemp = quchutemp\nfor i in qiantemp:\n i.filterBrighter()\ntime.sleep(0.5)\nfor i in qiantemp:\n i.filterOrigin()\nfor i in houtemp:\n\ti.filterBrighter()\ntime.sleep(0.5)\nfor i in houtemp:\n i.filterGray()\ntime.sleep(0.5)\n"},P_=function(){return"if 'list' in globals():\n res = list[0]\nBooks[res].filterBrighter()\nprint('未消磁的书籍是第'+str(res+1)+'本《'+name[res%10]+'》。')\nif res!=n:\n print('答案错误!请检查程序!')\nmode=0\n"},$_=function(t,e){var n=this.getFieldValue("NUM");return e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite",`sprite.clearAllSprites()\nring = []\nname = ['小王子','海底两万里','荷花镇的早市','孔子的故事','夏洛的网','草房子','月下看猫头鹰','会唱歌的咖啡磨','父与子','城南旧事']\nBooks = []\nfor i in range(${n}):\n ring.append(0)\nfor i in range(1, ${n}+1, 1):\n Books.append(sprite.Sprite('books/book'+str(i%10 if i%10!=0 else 10), ${{5:"130*i, 120",10:"(130*i-650) if i>5 else 130*i, 320 if i>5 else 120",20:"(65*i-650)+30 if i>10 else 65*i+30, 320 if i>10 else 120",50:"(26*i-650)+50 if i>25 else 26*i+50, 320 if i>25 else 120"}[n]}))\ntime.sleep(1)\nmode=3\n`},B_=function(t,e){e.definitions_.import_sprite="import sprite";return"cnt=0\ncntText = sprite.Text('计数器0', 30, 200)\n"},V_=function(t,e){e.definitions_.import_sprite="import sprite";return"cnt+=1\ncntText.changeText('计数器:'+str(cnt))\n"},U_=function(t,e){e.definitions_.import_sprite="import sprite";return"print('计数器大小:'+str(cnt))\n"},Y_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"sprite.clearAllSprites()\n_head = 10\n_foot = 32\n_footText = sprite.Text('脚的数量:', 20, 10)\n_sprite = []\n"},G_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"_rabbit = 0\ntime.sleep(1)\n"},H_=function(t,e){return["_rabbit < _head",e.ORDER_ATOMIC]},W_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"_chick = _head - _rabbit\nfor i in range(0, _chick, 1):\n _sprite.append(sprite.Sprite('jttl/chick', len(_sprite)*130+130 if len(_sprite)<5 else len(_sprite)*130+130-650, 120 if len(_sprite)<5 else 320))\n\ntime.sleep(0.5)\n_footText.changeText('脚的数量:'+str(_rabbit*4 + _chick*2))\ntime.sleep(1)\n"},z_=function(t,e){return["_rabbit*4 + _chick*2 == _foot",e.ORDER_ATOMIC]},X_=function(t,e){e.definitions_.import_sprite="import sprite";return"print('鸡的数量:'+str(_chick)+'只;\\n兔的数量'+str(_rabbit)+'只。')\n"},j_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"_rabbit += 1\nsprite.clearAllSprites()\n_sprite = []\n_footText = sprite.Text('脚的数量:', 20, 10)\nfor i in range(0, _rabbit, 1):\n _sprite.append(sprite.Sprite('jttl/rabbit', len(_sprite)*130+130 if len(_sprite)<5 else len(_sprite)*130+130-650, 120 if len(_sprite)<5 else 320))\ntime.sleep(0.5)\n"},q_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"sprite.clearAllSprites()\nsprite.createBackground('/fzsf/map_ck_xxjsjs')\n_S1 = sprite.Sprite('/fzsf/S1',400,225,'S1')\n_S2 = sprite.Sprite('/fzsf/S2',400,225,'S2')\n_S3 = sprite.Sprite('/fzsf/S3',400,225,'S3')\n_S4 = sprite.Sprite('/fzsf/S4',400,225,'S4')\n_S1.hide()\n_S2.hide()\n_S3.hide()\n_S4.hide()\n_text_1 = sprite.Text('S1',0,0,'text')\n_text_2 = sprite.Text('S2',0,30,'text2')\n_text_3 = sprite.Text('S3',0,60,'text3')\n_text_4 = sprite.Text('S4',0,90,'text4')\n_position = [[60, 270], [240, 50], [260, 380], [440, 190], [730, 60], [700, 400]]\n_Llen = [0, 170, 230, 100, 150, 10, 30, 50]\n_Slen = [0, 0, 0, 0, 0]\n_tag = [0, [0, 1, 3], [0, 2, 3], [3, 4, 5], [3, 5]]\nbear = sprite.Sprite('mixbear',60,270,'bear')\nbear.enlargeTo(80)\n_pos = 0\ntime.sleep(1)\n"},K_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n=this.getFieldValue("PATHNAME");const i=[0,[1,3],[2,4],[5,7],[6]];var s="";return s+=`_S${n}.show()\ntime.sleep(1)\n`,s+=4!=n?`_Slen[${n}] = _Llen[${i[n][0]}] + _Llen[${i[n][1]}]\n_text_${n}.changeText('S${n}'+str(_Slen[${n}])+'m')\ntime.sleep(1)\n_S${n}.hide()\ntime.sleep(1)\n`:"_Slen[4] = _Llen[6]\n_text_4.changeText('S4'+str(_Slen[4])+'m')\ntime.sleep(1)\n_S4.hide()\ntime.sleep(1)\n"},Q_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n="";return[n+=`_Slen[${this.getFieldValue("PATHNAME")}] < _Slen[${this.getFieldValue("PATHNAME2")}]`,e.ORDER_ATOMIC]},J_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n=this.getFieldValue("PATHNAME"),i="";return i+=`\n_S1.hide()\n_S2.hide()\n_S3.hide()\n_S4.hide()\n_Smin = ${n}\n_S${n}.show()\ntime.sleep(0.5)\n_S${n}.hide()\ntime.sleep(0.5)\n_S${n}.show()\ntime.sleep(1)\n`},Z_=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"if(_pos == _tag[_Smin][0]):\n for i in range(1, len(_tag[_Smin]), 1):\n bear.slideTo(_position[_tag[_Smin][i]][0], _position[_tag[_Smin][i]][1], 1)\n _pos = _tag[_Smin][len(_tag[_Smin])-1]\nelse:\n print('移动错误!程序有误!')\n exit()\n_S1.hide()\n_S2.hide()\n_S3.hide()\n_S4.hide()\nif(_pos == 5):\n print('成功抵达信息科技教室!')\n"},tT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"sprite.clearAllSprites()\nsprite.createBackground('/hxdb/hxdbbg')\n_soldier = []\n_num = sprite.Text('目前士兵数量0',0,0,'num')\n_last = sprite.Text('剩余0',500,0,'last')\n_line = 3\n"},eT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n="";return n+=`for i in range(0, ${this.getFieldValue("NUM")}, 1):\n _soldier.append(sprite.Sprite('/hxdb/soldier', 30 + (len(_soldier)%_line)*50 + (len(_soldier)//(4*_line))*(_line+1)*50 +(len(_soldier)%3-2), 80+(len(_soldier)//_line)*100-(len(_soldier)//(4*_line))*4*100+(len(_soldier)%2)))\n_num.changeText('目前士兵数量:'+str(len(_soldier)))\n`},nT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";var n=this.getFieldValue("NUM");return`for i in range(0, len(_soldier), 1):\n _soldier[i].slideTo(30 + (i%${n})*50 + (i//(4*${n}))*(${n}+1)*50 +(i%3-2), 80+(i//${n})*100-(i//(4*${n}))*4*100+(i%2), 0.05)\n_line = ${n}\n_last.changeText('剩余:'+str(len(_soldier)%_line))\ntime.sleep(2)\n`},iT=function(t,e){return e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite",[`len(_soldier)%_line == ${this.getFieldValue("NUM")}`,e.ORDER_ATOMIC]},sT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"_num.changeText('目前士兵数量:'+str(len(_soldier)+1))\n_last.changeText('剩余:')\ntime.sleep(0.5)\n_soldier.append(sprite.Sprite('/hxdb/soldier', 30 + (len(_soldier)%_line)*50 + (len(_soldier)//(4*_line))*(_line+1)*50 +(len(_soldier)%3-2), 80+(len(_soldier)//_line)*100-(len(_soldier)//(4*_line))*4*100+(len(_soldier)%2)))\ntime.sleep(1)\n"},rT=function(t,e){e.definitions_.import_time="import time",e.definitions_.import_sprite="import sprite";return"print('符合要求的士兵数量为:'+str(len(_soldier)))\n"},aT=function(t,e){e.definitions_.import_turtle="import turtle",e.definitions_.import_time="import time",e.definitions_.import_math="import math";var n=e.valueToCode(this,"VAR",e.ORDER_ATOMIC),i=this.getFieldValue("NUM");return e.setups_.init_Hanoi="\ndef init_Hanoi():\n pen = turtle.Turtle()\n pen.hideturtle()\n pen.speed(0)\n for i in range(0, 3, 1):\n pen.penup()\n pen.setheading(0)\n pen.goto(150 * i - 200,-100)\n pen.pendown()\n pen.pensize(5)\n pen.forward(100)\n pen.goto(150 * i - 150,-100)\n pen.setheading(90)\n pen.forward(200)",e.setups_.begin="\ndef begin(): \n s = turtle.Turtle()\n s.hideturtle()\n s.penup()\n s.speed(0)\n s.goto(0,-150)\n s.write('3')\n time.sleep(1)\n s.clear()\n s.write('2')\n time.sleep(1)\n s.clear()\n s.write('1')\n time.sleep(1)\n s.clear()\n s.write('Start!')\n time.sleep(1)\n s.clear()\n",e.setups_.move="\ndef move(x, y):\n try:\n t = tower[x].pop(-1)\n a = tower_num[x].pop(-1)\n if tower_num[y]!=[]:\n b = tower_num[y][-1]\n if a<b:\n print('非法移动,不能将大盘放置在小盘上')\n exit() \n t.goto(150 * y - 150,20 * len(tower[y]) - 90)\n tower[y].append(t)\n tower_num[y].append(a)\n except IndexError:\n print('非法移动,未找到可移动的圆盘')\n exit()\n",`num = ${i}\ntower = [[], [], []]\ntower_num = [[], [], []]\nA,B,C=0,1,2\ntotal_num=[0]\ncolor= (${n})\ninit_Hanoi()\nfor i in range(0, num, 1):\n tina = turtle.Turtle()\n tina.penup()\n tina.shape('square')\n if num == 1:\n tina.shapesize(1,7,1)\n else:\n tina.shapesize(1,7 - (6 / (num - 1)) * i,1)\n tina.color("#000000",color)\n tina.speed(3)\n tina.goto(-150,20 * i - 90)\n tower[0].append(tina)\n tower_num[0].append(i)\ncount_turtle=turtle.Turtle()\ncount_turtle.hideturtle()\ncount_turtle.penup()\ncount_turtle.goto(0,150)\ncount_turtle.write('总步数0') \nbegin()\n`},oT=function(){return"f = path[(len(path) - 1)]\n"},lT=function(t,e){return["len(path)==0",e.ORDER_ATOMIC]},uT=function(t,e){return['"'+this.getFieldValue("COLOR")+'"',e.ORDER_ATOMIC]},hT=function(t,e){return e.definitions_.import_requests="import requests",e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+"= requests.get("+e.valueToCode(this,"DOMAIN",e.ORDER_ATOMIC)+")\n"},pT=function(t,e){return e.definitions_.import_requests="import requests",["requests."+this.getFieldValue("TYPE")+"("+e.valueToCode(this,"URL",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},cT=function(t,e){return e.definitions_.import_requests="import requests",["requests."+this.getFieldValue("TYPE")+"("+e.valueToCode(this,"URL",e.ORDER_ATOMIC)+",data="+e.valueToCode(this,"data",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},dT=function(t,e){return e.definitions_.import_requests="import requests",[(e.valueToCode(this,"VAL",e.ORDER_ASSIGNMENT)||"0")+"."+this.getFieldValue("ATTR"),e.ORDER_ATOMIC]},fT=function(t,e){return e.definitions_.import_requests="import requests","requests."+this.getFieldValue("DIR")+"("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"};var mT=__webpack_require__(936);const gT=function(t,e){e.definitions_.import_pandas="import pandas";var n=e.valueToCode(this,"SER",e.ORDER_ASSIGNMENT)||"0";return e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+" = pandas.Series("+n+")\n"},_T=function(t,e){e.definitions_.import_pandas="import pandas";var n=e.valueToCode(this,"SER",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"INDEX",e.ORDER_ATOMIC)||"''";return e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+" = pandas.Series("+n+",index="+i+")\n"},TT=function(t,e){e.definitions_.import_pandas="import pandas";var n=e.valueToCode(this,"SER",e.ORDER_ASSIGNMENT)||"0";return e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+" = pandas.DataFrame("+n+")\n"},yT=function(t,e){e.definitions_.import_pandas="import pandas";var n=e.valueToCode(this,"SER",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"INDEX_COLUMN",e.ORDER_ATOMIC)||"''",s=e.valueToCode(this,"INDEX_RAW",e.ORDER_ATOMIC)||"''";return e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+" = pandas.DataFrame("+n+",columns="+i+",index="+s+")\n"},IT=function(t,e){e.definitions_.import_pandas="import pandas";var n=this.getFieldValue("COLUMN_RAW"),i=e.valueToCode(this,"SER",e.ORDER_ASSIGNMENT)||"0",s=e.valueToCode(this,"INDEX",e.ORDER_ATOMIC)||"''";return e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+" = pandas.DataFrame("+i+","+n+"="+s+")\n"},ET=function(t,e){return e.definitions_.import_pandas="import pandas",e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+" = pandas.Series(["+this.getFieldValue("TEXT")+"])\n"},bT=function(t,e){return e.definitions_.import_pandas="import pandas",[(e.valueToCode(this,"SERIES",e.ORDER_ASSIGNMENT)||"0")+"."+this.getFieldValue("INDEX_VALUE"),e.ORDER_ATOMIC]},vT=function(t,e){return[(e.valueToCode(this,"SER",e.ORDER_ASSIGNMENT)||"0")+"["+(e.valueToCode(this,"AT",e.ORDER_ADDITIVE)||"1")+"]",e.ORDER_ATOMIC]},wT=function(t,e){e.definitions_.import_pylab="import pylab";return"pylab.show()\n"},ST=function(t,e){e.definitions_.import_pylab="import pylab";return"pylab.axes(aspect=1)\n"},xT=function(t,e){return e.definitions_.import_pylab="import pylab","pylab.plot("+(e.valueToCode(this,"SER",e.ORDER_ASSIGNMENT)||"0")+")\n"},RT=function(t,e){e.definitions_.import_pylab="import pylab";var n=this.getFieldValue("LINE"),i=this.getFieldValue("COLOR"),s=this.getFieldValue("DOT");return"pylab.plot("+(e.valueToCode(this,"SER",e.ORDER_ASSIGNMENT)||"0")+",'"+s+n+i+"')\n"},OT=function(t,e){e.definitions_.import_pylab="import pylab",e.definitions_.import_matplotlib_font_manager="import matplotlib.font_manager";return'pylab.legend(prop=matplotlib.font_manager.FontProperties("STSong"))\n'},AT=function(t,e){return e.definitions_.import_pylab="import pylab","pylab.title("+e.valueToCode(this,"TITLE",e.ORDER_ATOMIC)+', fontproperties = "STSong")\n'},MT=function(t,e){return e.definitions_.import_pylab="import pylab","pylab."+this.getFieldValue("DIR")+"label("+e.valueToCode(this,"LABEL",e.ORDER_ATOMIC)+', fontproperties = "STSong")\n'},CT=function(t,e){return e.definitions_.import_numpy="import numpy",["numpy.arange("+(e.valueToCode(this,"FROM",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"TO",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"STEP",e.ORDER_NONE)||"1")+")",e.ORDER_ATOMIC]},NT=function(t,e){return e.definitions_.import_pylab="import pylab","pylab."+this.getFieldValue("DIR")+"("+(e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''")+","+(e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''")+")\n"},kT=function(t,e){return e.definitions_.import_pylab="import pylab","pylab.scatter("+(e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''")+","+(e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''")+",s="+(e.valueToCode(this,"S",e.ORDER_ATOMIC)||"''")+",c='"+this.getFieldValue("COLOR")+"',marker='"+this.getFieldValue("DOT")+"',label="+(e.valueToCode(this,"TAG",e.ORDER_ATOMIC)||"''")+")\n"},DT=function(t,e){e.definitions_.import_pylab="import pylab";var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''",i=e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''",s=this.getFieldValue("LINE"),r=this.getFieldValue("COLOR");return"pylab.plot("+n+","+i+",'"+this.getFieldValue("DOT")+s+r+"',label="+(e.valueToCode(this,"TAG",e.ORDER_ATOMIC)||"''")+")\n"},LT=function(t,e){e.definitions_.import_pylab="import pylab";var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''",i=e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''",s=e.valueToCode(this,"TAG",e.ORDER_ATOMIC)||"''",r=e.valueToCode(this,"WIDTH",e.ORDER_RELATIONAL)||"0",a=this.getFieldValue("COLOR");return"pylab.bar("+n+","+i+',align="'+this.getFieldValue("ALIGN")+'",color="'+a+'",width='+r+",label="+s+")\n"},FT=function(t,e){e.definitions_.import_pylab="import pylab";var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''",i=e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''",s=e.valueToCode(this,"EXPLODE",e.ORDER_ATOMIC)||"''",r=this.getFieldValue("SHADOW"),a=this.getFieldValue("autopct");return"None"!=a&&(a="'"+a+"'"),"pylab.pie("+n+",explode="+s+",labels="+i+",autopct="+a+",shadow="+r+")\n"},PT=function(t,e){return e.definitions_.import_pylab="import pylab","pylab.hist("+(e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''")+","+(e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''")+")\n"},$T=function(t,e){return e.definitions_.import_pylab="import pylab","pylab."+this.getFieldValue("DIR")+"ticks("+(e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''")+","+(e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''")+",fontproperties = 'STSong')\n"},BT=function(t,e){e.definitions_.import_numpy="import numpy";var n=e.valueToCode(this,"NUM",e.ORDER_NONE)||"0";return["numpy."+this.getFieldValue("OP")+"("+n+")",e.ORDER_ATOMIC]},VT=function(t,e){return e.definitions_.import_numpy="import numpy","pylab.subplot("+(e.valueToCode(this,"VET",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"HOR",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"NUM",e.ORDER_NONE)||"0")+")\n"},UT=function(t,e){return e.definitions_.import_pandas="import pandas",["pandas.read_csv("+e.valueToCode(this,"FILENAME",e.ORDER_ATOMIC)+", header="+this.getFieldValue("MODE")+")",e.ORDER_ATOMIC]},YT=function(t,e){var n=this.getFieldValue("MODE"),i=e.valueToCode(this,"DICT",e.ORDER_ASSIGNMENT)||"0",s=e.valueToCode(this,"KEY",e.ORDER_ASSIGNMENT);if("column"==n)var r=i+"["+s+"]";else if("raw"==n)r=i+".loc["+s+"]";return[r,e.ORDER_ATOMIC]},GT=function(t,e){return e.definitions_.import_pylab="import pylab","pylab.savefig("+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")\n"},HT=function(t,e){return e.definitions_.import_numpy="import numpy","pylab.text("+(e.valueToCode(this,"VET",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"HOR",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"NUM",e.ORDER_NONE)||"0")+", ha='"+this.getFieldValue("HALIGN")+"', va='"+this.getFieldValue("VALIGN")+"', fontsize="+(e.valueToCode(this,"FONTNUM",e.ORDER_ASSIGNMENT)||"0")+")\n"},WT=function(t,e){var n=e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0";return e.definitions_.import_numpy="import numpy",["numpy.array("+n+")",e.ORDER_ATOMIC]},zT=function(t,e){e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt";return"plt.show()\n"},XT=function(t,e){e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt";return"plt.axes(aspect=1)\n"},jT=function(t,e){return e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt","plt.plot("+(e.valueToCode(this,"SER",e.ORDER_ASSIGNMENT)||"0")+")\n"},qT=function(t,e){e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt";var n=this.getFieldValue("LINE"),i=this.getFieldValue("COLOR"),s=this.getFieldValue("DOT");return"plt.plot("+(e.valueToCode(this,"SER",e.ORDER_ASSIGNMENT)||"0")+", '"+s+n+i+"')\n"},KT=function(t,e){e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt",e.definitions_.import_matplotlib_font_manager="import matplotlib.font_manager";return'plt.legend(prop=matplotlib.font_manager.FontProperties("STSong"))\n'},QT=function(t,e){return e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt","plt.title("+e.valueToCode(this,"TITLE",e.ORDER_ATOMIC)+', fontproperties="STSong")\n'},JT=function(t,e){return e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt","plt."+this.getFieldValue("DIR")+"label("+e.valueToCode(this,"LABEL",e.ORDER_ATOMIC)+', fontproperties="STSong")\n'},ZT=function(t,e){return e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt","plt."+this.getFieldValue("DIR")+"("+(e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''")+", "+(e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''")+")\n"},ty=function(t,e){return e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt","plt.scatter("+(e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''")+", "+(e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''")+", s="+(e.valueToCode(this,"S",e.ORDER_ATOMIC)||"''")+", c='"+this.getFieldValue("COLOR")+"', marker='"+this.getFieldValue("DOT")+"', label="+(e.valueToCode(this,"TAG",e.ORDER_ATOMIC)||"''")+")\n"},ey=function(t,e){e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt";var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''",i=e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''",s=this.getFieldValue("LINE"),r=this.getFieldValue("COLOR");return"plt.plot("+n+", "+i+", '"+this.getFieldValue("DOT")+s+r+"', label="+(e.valueToCode(this,"TAG",e.ORDER_ATOMIC)||"''")+")\n"},ny=function(t,e){e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt";var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''",i=e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''",s=e.valueToCode(this,"TAG",e.ORDER_ATOMIC)||"''",r=e.valueToCode(this,"WIDTH",e.ORDER_RELATIONAL)||"0",a=this.getFieldValue("COLOR");return"plt.bar("+n+", "+i+', align="'+this.getFieldValue("ALIGN")+'", color="'+a+'", width='+r+", label="+s+")\n"},iy=function(t,e){e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt";var n=e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''",i=e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''",s=e.valueToCode(this,"EXPLODE",e.ORDER_ATOMIC)||"''",r=this.getFieldValue("SHADOW"),a=this.getFieldValue("autopct");return"None"!=a&&(a="'"+a+"'"),"plt.pie("+n+", explode="+s+", labels="+i+", autopct="+a+", shadow="+r+")\n"},sy=function(t,e){return e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt","plt.hist("+(e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''")+", "+(e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''")+")\n"},ry=function(t,e){return e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt","plt."+this.getFieldValue("DIR")+"ticks("+(e.valueToCode(this,"A",e.ORDER_ATOMIC)||"''")+", "+(e.valueToCode(this,"B",e.ORDER_ATOMIC)||"''")+", fontproperties = 'STSong')\n"},ay=function(t,e){return e.definitions_.import_numpy="import numpy",e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt","plt.subplot("+(e.valueToCode(this,"VET",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"HOR",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"NUM",e.ORDER_NONE)||"0")+")\n"},oy=function(t,e){e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt";return"plt.savefig('1.png')\n"},ly=function(t,e){return e.definitions_.import_numpy="import numpy",e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt","plt.text("+(e.valueToCode(this,"VET",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"HOR",e.ORDER_NONE)||"0")+", "+(e.valueToCode(this,"NUM",e.ORDER_NONE)||"0")+", ha='"+this.getFieldValue("HALIGN")+"', va='"+this.getFieldValue("VALIGN")+"', fontsize="+(e.valueToCode(this,"FONTNUM",e.ORDER_ASSIGNMENT)||"0")+")\n"},uy=function(t,e){return e.definitions_.import_numpy="import numpy",["numpy.shape("+(e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]")+")",e.ORDER_ATOMIC]},hy=function(t,e){return e.definitions_.import_numpy="import numpy",["numpy.reshape("+(e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]")+", "+(e.valueToCode(t,"DIMENSIONS",e.ORDER_ATOMIC)||"(1, -1)")+")",e.ORDER_ATOMIC]},py=function(t,e){return e.definitions_.import_numpy="import numpy",[(e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]")+".astype("+t.getFieldValue("TYPE")+")",e.ORDER_ATOMIC]},cy=function(t,e){return e.definitions_.import_pylab="import pylab","pylab.imshow("+(e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]")+', cmap="'+(t.getFieldValue("COLORMAP")||"gray")+'")\n'},dy=function(t,e){return e.definitions_.import_numpy="import numpy",["numpy.mean("+(e.valueToCode(t,"X",e.ORDER_ATOMIC)||"[]")+"["+(e.valueToCode(t,"Y",e.ORDER_ATOMIC)||"[]")+" == "+(e.valueToCode(t,"DIGIT",e.ORDER_ATOMIC)||"0")+"], axis=0)",e.ORDER_ATOMIC]},fy=function(t,e){return e.definitions_.import_numpy="import numpy",e.definitions_.import_cv2="import cv2",["numpy.argmin([numpy.sum(cv2.absdiff("+(e.valueToCode(t,"IMAGE",e.ORDER_ATOMIC)||"[]")+", template)) for template in "+(e.valueToCode(t,"TEMPLATES",e.ORDER_ATOMIC)||"[]")+"])",e.ORDER_ATOMIC]},my=function(t,e){e.definitions_.import_numpy="import numpy";var n=e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]",i=t.getFieldValue("AXIS");if("NONE"===i)var s="numpy.mean("+n+")";else s="numpy.mean("+n+", axis="+i+")";return[s,e.ORDER_ATOMIC]},gy=function(t,e){e.definitions_.import_numpy="import numpy";var n=e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]",i=t.getFieldValue("AXIS");if("NONE"===i)var s="numpy.std("+n+")";else s="numpy.std("+n+", axis="+i+")";return[s,e.ORDER_ATOMIC]},_y=function(t,e){return e.definitions_.import_pandas="import pandas",[(e.valueToCode(t,"DF",e.ORDER_ATOMIC)||"df")+".dropna()",e.ORDER_MEMBER]},Ty=function(t,e){return e.definitions_.import_pandas="import pandas",[(e.valueToCode(t,"DATAFRAME",e.ORDER_ATOMIC)||"df")+".drop(columns="+(e.valueToCode(t,"COLUMNS",e.ORDER_ATOMIC)||"[]")+", axis=1)",e.ORDER_ATOMIC]},yy=function(t,e){return e.definitions_.import_numpy="import numpy",["numpy.ones("+(e.valueToCode(t,"NUM",e.ORDER_ATOMIC)||"1")+")",e.ORDER_ATOMIC]},Iy=function(t,e){return e.definitions_.import_numpy="import numpy",["numpy.c_["+(e.valueToCode(t,"ARRAY1",e.ORDER_ATOMIC)||"[]")+", "+(e.valueToCode(t,"ARRAY2",e.ORDER_ATOMIC)||"[]")+"]",e.ORDER_ATOMIC]},Ey=function(t,e){return e.definitions_.import_numpy="import numpy",e.definitions_.import_linalg="import numpy.linalg",["numpy.linalg.det("+(e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]")+")",e.ORDER_ATOMIC]},by=function(t,e){return[(e.valueToCode(t,"MATRIX",e.ORDER_ATOMIC)||"[]")+".T",e.ORDER_ATOMIC]},vy=function(t,e){return[(e.valueToCode(t,"MATRIX1",e.ORDER_ATOMIC)||"[]")+" @ "+(e.valueToCode(t,"MATRIX2",e.ORDER_ATOMIC)||"[]"),e.ORDER_ATOMIC]},wy=function(t,e){return e.definitions_.import_numpy="import numpy",e.definitions_.import_linalg="import numpy.linalg",["numpy.linalg.inv("+(e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]")+")",e.ORDER_ATOMIC]},Sy=function(t,e){return[(e.valueToCode(t,"DATAFRAME",e.ORDER_ATOMIC)||"df")+".median()",e.ORDER_ATOMIC]},xy=function(t,e){return(e.valueToCode(t,"DATAFRAME",e.ORDER_ATOMIC)||"df")+".fillna(value="+(e.valueToCode(t,"VALUE",e.ORDER_ATOMIC)||"0")+", inplace="+(t.getFieldValue("INPLACE")||"False")+")\n"},Ry=function(t,e){return[(e.valueToCode(t,"DATAFRAME",e.ORDER_ATOMIC)||"df")+".info()",e.ORDER_ATOMIC]},Oy=function(t,e){e.definitions_.import_numpy="import numpy";var n=e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]",i=t.getFieldValue("AXIS");return["None"===i?"numpy.min("+n+")":"numpy.min("+n+", axis="+i+")",e.ORDER_ATOMIC]},Ay=function(t,e){e.definitions_.import_numpy="import numpy";var n=e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]",i=t.getFieldValue("AXIS");return["None"===i?"numpy.max("+n+")":"numpy.max("+n+", axis="+i+")",e.ORDER_ATOMIC]},My=function(t,e){return e.definitions_.import_numpy="import numpy",[(e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]")+".size",e.ORDER_ATOMIC]},Cy=function(t,e){return e.definitions_.import_numpy="import numpy",["numpy.dot("+(e.valueToCode(t,"ARRAY1",e.ORDER_ATOMIC)||"[]")+", "+(e.valueToCode(t,"ARRAY2",e.ORDER_ATOMIC)||"[]")+")",e.ORDER_ATOMIC]},Ny=function(t,e){return e.definitions_.import_numpy="import numpy",["numpy.square("+(e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]")+")",e.ORDER_ATOMIC]},ky=function(t,e){return e.definitions_.import_numpy="import numpy",["numpy.sum("+(e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]")+")",e.ORDER_ATOMIC]},Dy=function(t,e){return e.definitions_.import_numpy="import numpy",["numpy.random.random("+(e.valueToCode(t,"SIZE",e.ORDER_ATOMIC)||"1")+")",e.ORDER_ATOMIC]},Ly=function(t,e){return["sum("+(e.valueToCode(t,"ARRAY",e.ORDER_ATOMIC)||"[]")+")",e.ORDER_ATOMIC]},Fy=function(t,e){return[`${e.valueToCode(t,"DICT",e.ORDER_ATOMIC)||"df"}.sort_values(by=${e.valueToCode(t,"KEY",e.ORDER_ATOMIC)||"'tag'"}, ascending=${t.getFieldValue("AS_CENDING")})`,e.ORDER_ATOMIC]},Py=function(t,e){const n=e.valueToCode(t,"DICT",e.ORDER_ATOMIC)||"df",i=e.valueToCode(t,"LINES",e.ORDER_ATOMIC)||"1";return[`${n}.${t.getFieldValue("TYPE")}(${i})`,e.ORDER_ATOMIC]},$y=function(t,e){return[`${e.valueToCode(t,"DICT",e.ORDER_ATOMIC)||"df"}[${e.valueToCode(t,"KEY",e.ORDER_ATOMIC)||"df['tag'] > 1"}]`,e.ORDER_ATOMIC]},By=function(t,e){return[`${e.valueToCode(t,"DICT",e.ORDER_ATOMIC)||"df"}.groupby(by=${e.valueToCode(t,"KEY",e.ORDER_ATOMIC)||"'tag'"})`,e.ORDER_ATOMIC]},Vy=function(t,e){return[`${e.valueToCode(t,"DICT",e.ORDER_ATOMIC)||"df"}.${t.getFieldValue("TYPE")}()`,e.ORDER_ATOMIC]},Uy=function(t,e){e.definitions_.import_matplotlib_pyplot="import matplotlib.pyplot as plt";return"plt.cla()\n"},Yy=function(t,e){var n=e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE),i=e.variableDB_.getName(this.getFieldValue("TYPE"),Jt.Variables.NAME_TYPE),s="class "+i+":\n";s+=" def __init__(self):\n";for(var r=new Array(this.itemCount_),a=0;a<this.itemCount_;a++){var o=this.getFieldValue("KEY"+a);r[a]=" self."+o+" = "+(e.valueToCode(this,"ADD"+a,e.ORDER_NONE)||"0")}return s+=r.join("\n")+"\n",s+=" self.next = None\n",s+=n+" = "+i+"()\n"},Gy=function(t,e){return(e.valueToCode(this,"NODE",e.ORDER_ASSIGNMENT)||"0")+" = "+e.variableDB_.getName(this.getFieldValue("TYPE"),Jt.Variables.NAME_TYPE)+"()\n"},Hy=function(t,e){return[(e.valueToCode(this,"NODE",e.ORDER_ASSIGNMENT)||"0")+"."+e.variableDB_.getName(this.getFieldValue("TYPE"),Jt.Variables.NAME_TYPE),e.ORDER_ATOMIC]},Wy=function(t,e){return(e.valueToCode(this,"NODE",e.ORDER_ASSIGNMENT)||"0")+"."+e.variableDB_.getName(this.getFieldValue("TYPE"),Jt.Variables.NAME_TYPE)+" = "+(e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0")+"\n"},zy=function(t,e){var n=e.valueToCode(this,"NODE",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"NODE2",e.ORDER_ASSIGNMENT)||"0",s=e.valueToCode(this,"NODE3",e.ORDER_ASSIGNMENT)||"0",r=this.getFieldValue("DIR");if("after"==r){var a="now = "+n+"\n";a+="while now != "+i+" and now != None:\n",a+=" now = now.next\n",a+="if now != None:\n",a+=" "+s+".next = now.next\n",a+=" now.next = "+s+"\n",a+=' print("插入节点成功")\n',a+="else:\n",a+=' print("插入节点失败,未找到指定名称的节点")\n'}if("before"==r){a="if "+n+" == "+i+":\n";a+=" "+s+".next = "+n+"\n",a+="else:\n",a+=" now = "+n+"\n",a+=" while now.next != "+i+" and now.next != None:\n",a+=" now = now.next\n",a+=" if now != None:\n",a+=" "+s+".next = now.next\n",a+=" now.next = "+s+"\n",a+=' print("插入节点成功")\n',a+=" else:\n",a+=' print("插入节点失败,未找到指定名称的节点")\n'}return a},Xy=function(t,e){var n=e.valueToCode(this,"NODE",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0",s=e.valueToCode(this,"NODE3",e.ORDER_ASSIGNMENT)||"0",r=e.variableDB_.getName(this.getFieldValue("TYPE"),Jt.Variables.NAME_TYPE),a=this.getFieldValue("DIR");if("after"==a){var o="now = "+n+"\n";o+="while now."+r+" != "+i+" and now != None:\n",o+=" now = now.next\n",o+="if now != None:\n",o+=" "+s+".next = now.next\n",o+=" now.next = "+s+"\n",o+=' print("插入节点成功")\n',o+="else:\n",o+=' print("插入节点失败,未找到指定的节点")\n'}if("before"==a){o="if "+n+"."+r+" == "+i+":\n";o+=" "+s+".next = "+n+"\n",o+="else:\n",o+=" now = "+n+"\n",o+=" while now.next."+r+" != "+i+"and now.next != None:\n",o+=" now = now.next\n",o+=" if now != None:\n",o+=" "+s+".next = now.next\n",o+=" now.next = "+s+"\n",o+=' print("插入节点成功")\n',o+=" else:\n",o+=' print("插入节点失败,未找到指定的节点")\n'}return o},jy=function(t,e){var n=e.valueToCode(this,"NODE",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"NODE2",e.ORDER_ASSIGNMENT)||"0",s="if "+n+" == "+i+":\n";return s+=" "+n+".next = None\n",s+="else:\n",s+=" now = "+n+"\n",s+=" while now.next != "+i+" and now.next != None:\n",s+=" now = now.next\n",s+=" if now != None:\n",s+=" now.next = now.next.next\n",s+=' print("删除节点成功")\n',s+=" else:\n",s+=' print("删除节点失败,未找到指定名称的节点")\n'},qy=function(t,e){var n=e.valueToCode(this,"NODE",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"VAR",e.ORDER_ASSIGNMENT)||"0",s=e.variableDB_.getName(this.getFieldValue("TYPE"),Jt.Variables.NAME_TYPE),r="if "+n+"."+s+" == "+i+":\n";return r+=" "+n+".next = None\n",r+="else:\n",r+=" now = "+n+"\n",r+=" while now.next."+s+" != "+i+" and now.next != None:\n",r+=" now = now.next\n",r+=" if now != None:\n",r+=" now.next = now.next.next\n",r+=' print("删除节点成功")\n',r+=" else:\n",r+=' print("删除节点失败,未找到指定的节点")\n'},Ky=function(t,e){var n="ptr = "+(e.valueToCode(this,"NODE",e.ORDER_ASSIGNMENT)||"0")+"\n";return n+="before = None\n",n+="while ptr != None:\n",n+=" last = before\n",n+=" before = ptr\n",n+=" ptr = ptr.next\n",n+=" before.next = last\n",n+=(e.valueToCode(this,"NODE2",e.ORDER_ASSIGNMENT)||"0")+" = before\n"},Qy=function(t,e){var n=this.getFieldValue("path"),i=this.getFieldValue("module");return e.definitions_["import_"+n+"_"+i]="from "+n+" import "+i,""},Jy=function(t,e){var n=this.getFieldValue("module");return e.definitions_["import_"+n]="import "+n,""},Zy=function(t,e){for(var n=this.getFieldValue("NAME"),i=new Array(this.itemCount_),s=0;s<this.itemCount_;s++)i[s]=e.valueToCode(this,"ADD"+s,e.ORDER_NONE)||"";return n+"("+i.join(", ")+")\n"},tI=function(t,e){for(var n=this.getFieldValue("NAME"),i=new Array(this.itemCount_),s=0;s<this.itemCount_;s++)i[s]=e.valueToCode(this,"ADD"+s,e.ORDER_NONE)||"";return[n+"("+i.join(", ")+")",e.ORDER_ATOMIC]},eI=function(){var t=this.getFieldValue("TYPE");return this.getFieldValue("NAME")+" = "+t+"()\n"},nI=function(t,e){for(var n=this.getFieldValue("NAME"),i=this.getFieldValue("METHOD"),s=new Array(this.itemCount_),r=0;r<this.itemCount_;r++)s[r]=e.valueToCode(this,"ADD"+r,e.ORDER_NONE)||"";return n+"."+i+"("+s.join(", ")+")\n"},iI=function(t,e){for(var n=this.getFieldValue("NAME"),i=this.getFieldValue("METHOD"),s=new Array(this.itemCount_),r=0;r<this.itemCount_;r++)s[r]=e.valueToCode(this,"ADD"+r,e.ORDER_NONE)||"";return[n+"."+i+"("+s.join(", ")+")",e.ORDER_ATOMIC]},sI=function(){return this.getFieldValue("VALUE")+"\n"},rI=function(t,e){return[this.getFieldValue("VALUE"),e.ORDER_ATOMIC]},aI=function(){return this.getFieldValue("VALUE")+"\n"},oI=function(t,e){return[this.getFieldValue("VALUE"),e.ORDER_ATOMIC]},lI=function(t,e){return e.definitions_.import_s4alib="import s4alib",e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+' = s4alib.s4a_start("'+Zt.JSFuncs.getCom()+'")\n'},uI=function(t,e){return["HIGH"==this.getFieldValue("BOOL")?"1":"0",e.ORDER_ATOMIC]},hI=function(t,e){e.definitions_.import_s4alib="import s4alib";var n="";return n+=e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".digital_write("+e.valueToCode(this,"PIN",e.ORDER_ATOMIC)+","+e.valueToCode(this,"STAT",e.ORDER_ATOMIC)+")\n"},pI=function(t,e){e.definitions_.import_s4alib="import s4alib";return[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".digital_read("+e.valueToCode(this,"PIN",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},cI=function(t,e){e.definitions_.import_s4alib="import s4alib";return[e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".analog_read("+e.valueToCode(this,"PIN",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},dI=function(t,e){e.definitions_.import_s4alib="import s4alib";var n="";return n+=e.valueToCode(this,"SUB",e.ORDER_ATOMIC)+".analog_write("+e.valueToCode(this,"PIN",e.ORDER_ATOMIC)+","+e.valueToCode(this,"NUM",e.ORDER_ATOMIC)+")\n"},fI=function(t,e){return["input("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+")",e.ORDER_ATOMIC]},mI=function(t,e){return"print("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+")\n"},gI=function(t,e){return"print("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+',end ="")\n'},_I=function(t,e){return"print("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+",end ="+(e.valueToCode(this,"END",e.ORDER_ATOMIC)||'""')+")\n"},TI=function(t,e){var n=e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""',i=this.getFieldValue("DIR");if("str"==i)var s="input("+n+")";else if("int"==i)s="int(input("+n+"))";else if("float"==i)s="float(input("+n+"))";return[s,e.ORDER_ATOMIC]},yI=function(t,e){var n=e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""',i=this.getFieldValue("DIR");if(e.definitions_.import_pyinput="import pyinput","str"==i)var s="pyinput.input("+n+")";else if("int"==i)s="int(pyinput.input("+n+"))";else if("float"==i)s="float(pyinput.input("+n+"))";return[s,e.ORDER_ATOMIC]},II=function(t,e){for(var n=new Array(this.itemCount_),i=0;i<this.itemCount_;i++)n[i]=e.valueToCode(this,"ADD"+i,e.ORDER_NONE)||"0";return n="print("+n.join(", ")+")\n"},EI=function(t,e){e.definitions_.import_mixiot="import mixiot";var n=e.valueToCode(this,"SERVER",e.ORDER_ATOMIC),i=e.valueToCode(this,"USERNAME",e.ORDER_ATOMIC),s=e.valueToCode(this,"PASSWORD",e.ORDER_ATOMIC),r=e.valueToCode(this,"PROJECT",e.ORDER_ATOMIC),a=Math.round(new Date).toString(),o="f'python-mqtt-"+i.replace("'","").replace("'","")+a.replace("'","").replace("'","")+"'";return"mqtt_client = mixiot.MixIO("+n+", 1883 ,"+i+", "+s+", "+r+", "+o+")\n"},bI=function(t,e){var n=e.valueToCode(this,"TOPIC",e.ORDER_ATOMIC),i=e.valueToCode(this,"MSG",e.ORDER_ATOMIC);return e.definitions_.import_mixiot="import mixiot","mqtt_client.publish("+n+", "+i+")\n"},vI=function(t,e){var n=e.valueToCode(this,"TOPIC",e.ORDER_ATOMIC),i=e.valueToCode(this,"METHOD",e.ORDER_ATOMIC);return e.definitions_.import_mixiot="import mixiot","mqtt_client.subscribe_and_set_callback("+n+","+i+")\n"},wI=function(t,e){var n=e.valueToCode(this,"TOPIC",e.ORDER_ATOMIC);return e.definitions_.import_mixiot="import mixiot","mqtt_client.unsubscribe("+n+")\n"},SI=function(t,e){e.definitions_.import_mixiot="import mixiot";return"mqtt_client.disconnect()\n"},xI=function(t,e){e.definitions_.import_mixiot="import mixiot";return"mqtt_client.connect()\n"},RI=function(t,e){e.definitions_.import_mixiot="import mixiot";return"mqtt_client.check_msg()\n"},OI=function(t,e){return['mqtt_client.decode("utf-8").split("/")[-1]',e.ORDER_ATOMIC]},AI=function(t,e){return['mqtt_client.decode("utf-8")',e.ORDER_ATOMIC]},MI=function(t,e){return e.definitions_.import_mixpy="import mixpy",["mixpy.format_content("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+", mqtt_client.client_id)",e.ORDER_ATOMIC]},CI=function(t,e){return e.definitions_.import_mixpy="import mixpy",["mixpy.format_str("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},NI=function(t,e){e.definitions_.import_mixiot="import mixiot";var n=e.valueToCode(this,"SERVER",e.ORDER_ATOMIC),i=e.valueToCode(this,"KEY",e.ORDER_ATOMIC),s=Math.round(new Date).toString(),r="f'python-mqtt-"+i.replace("'","").replace("'","")+s.replace("'","").replace("'","")+"'";return"mqtt_client = mixiot.MixIO.from_mixly_key("+n+", 1883 ,"+i+", "+r+")\n"},kI=function(t,e){return[this.getFieldValue("VISITOR_ID"),e.ORDER_ATOMIC]},DI=function(t,e){return["'"+this.getFieldValue("VISITOR_ID")+"'",e.ORDER_ATOMIC]},LI=function(t,e){e.definitions_.import_mixiot="import mixiot";var n=e.valueToCode(this,"SERVER",e.ORDER_ATOMIC),i=e.valueToCode(this,"KEY",e.ORDER_ATOMIC),s=Math.round(new Date).toString(),r="f'python-mqtt-"+i.replace("'","").replace("'","")+s.replace("'","").replace("'","")+"'";return"mqtt_client = mixiot.MixIO.from_share_key("+n+", 1883 ,"+i+", "+r+")\n"},FI=function(t,e){e.definitions_.import_mixiot="import mixiot";return["mqtt_client.pingSync()",e.ORDER_ATOMIC]},PI=function(t,e){return e.definitions_.import_mixiot="import mixiot",["mixiot.ntp("+e.valueToCode(this,"addr",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},$I=function(t,e){return[this.getFieldValue("PIN"),e.ORDER_ATOMIC]},BI=$I,VI=$I,UI=$I,YI=$I,GI=function(t,e){e.definitions_.import_serial="import serial";var n=e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0",i=e.variableDB_.getName(this.getFieldValue("SER"),Jt.Variables.NAME_TYPE),s=this.getFieldValue("BPS");return i+' = serial.Serial("'+Zt.JSFuncs.getCom()+'", '+s+", timeout="+n+")\n"},HI=function(t,e){return e.definitions_.import_serial="import serial",(e.valueToCode(this,"SER",e.ORDER_ADDITIVE)||"ser")+".write("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||'""')+")\n"},WI=function(t,e){return e.definitions_.import_serial="import serial",[(e.valueToCode(this,"SER",e.ORDER_ADDITIVE)||"ser")+".read("+(e.valueToCode(this,"VAR",e.ORDER_ATOMIC)||"0")+")",e.ORDER_ATOMIC]},zI=function(t,e){return e.definitions_.import_serial="import serial",(e.valueToCode(this,"SER",e.ORDER_ADDITIVE)||"ser")+".close()\n"},XI=function(t,e){var n=e.valueToCode(this,"n_samples",e.ORDER_ATOMIC)||"100",i=e.valueToCode(this,"n_features",e.ORDER_ATOMIC)||"20",s=e.valueToCode(this,"n_informative",e.ORDER_ATOMIC)||"2",r=e.valueToCode(this,"n_redundant",e.ORDER_ATOMIC)||"2",a=e.valueToCode(this,"n_repeated",e.ORDER_ATOMIC)||"0",o=e.valueToCode(this,"n_classes",e.ORDER_ATOMIC)||"2",l=e.valueToCode(this,"n_clusters_per_class",e.ORDER_ATOMIC)||"2",u=e.valueToCode(this,"random_state",e.ORDER_ATOMIC)||"None";return e.definitions_.import_sklearn_make_classification="from sklearn.datasets import make_classification",["make_classification(n_samples="+n+",n_features="+i+",n_informative="+s+",n_redundant="+r+",n_repeated="+a+",n_classes="+o+",n_clusters_per_class="+l+",random_state="+u+")",e.ORDER_ATOMIC]},jI=function(t,e){var n=e.valueToCode(this,"n_samples",e.ORDER_ATOMIC)||"100",i=e.valueToCode(this,"n_features",e.ORDER_ATOMIC)||"100",s=e.valueToCode(this,"n_informative",e.ORDER_ATOMIC)||"10",r=e.valueToCode(this,"n_targets",e.ORDER_ATOMIC)||"1",a=e.valueToCode(this,"bias",e.ORDER_ATOMIC)||"0.0",o=e.valueToCode(this,"noise",e.ORDER_ATOMIC)||"0.0",l=e.valueToCode(this,"random_state",e.ORDER_ATOMIC)||"None";return e.definitions_.import_sklearn_make_regression="from sklearn.datasets import make_regression",["make_regression(n_samples="+n+",n_features="+i+",n_informative="+s+",n_targets="+r+",bias="+a+",noise="+o+",random_state="+l+")",e.ORDER_ATOMIC]},qI=function(t,e){var n=e.valueToCode(this,"n_samples",e.ORDER_ATOMIC)||"100",i=e.valueToCode(this,"n_features",e.ORDER_ATOMIC)||"2",s=e.valueToCode(this,"centers",e.ORDER_ATOMIC)||"None",r=e.valueToCode(this,"cluster_std",e.ORDER_ATOMIC)||"1.0",a=e.valueToCode(this,"center_box",e.ORDER_ATOMIC)||"(-10.0,10.0)",o=e.valueToCode(this,"shuffle",e.ORDER_ATOMIC)||"True",l=e.valueToCode(this,"random_state",e.ORDER_ATOMIC)||"None";return e.definitions_.import_sklearn_make_blobs="from sklearn.datasets import make_blobs",["make_blobs(n_samples="+n+",n_features="+i+",centers="+s+",cluster_std="+r+",center_box="+a+",shuffle="+o+",random_state="+l+")",e.ORDER_ATOMIC]},KI=function(t,e){var n=this.getFieldValue("type"),i=this.getFieldValue("name");return e.definitions_.import_sklearn_datasets="from sklearn import datasets",i+" = datasets."+n+"()\n"},QI=function(t,e){return[(e.valueToCode(this,"name",e.ORDER_ATOMIC)||"iris")+"."+this.getFieldValue("type"),e.ORDER_ATOMIC]},JI=function(t,e){var n=e.valueToCode(this,"train_data",e.ORDER_ATOMIC)||"iris_X",i=e.valueToCode(this,"train_target",e.ORDER_ATOMIC)||"iris_y",s=e.valueToCode(this,"test_size",e.ORDER_ATOMIC)||"0.3",r=e.valueToCode(this,"rondom_state",e.ORDER_ATOMIC)||"None";if(e.definitions_.import_sklearn_train_test_split="from sklearn.model_selection import train_test_split","None"==i)var a="train_test_split("+n+",test_size = "+s+",random_state = "+r+")";else a="train_test_split("+n+","+i+",test_size = "+s+",random_state = "+r+")";return[a,e.ORDER_ATOMIC]},ZI=function(t,e){var n=e.valueToCode(this,"train_data",e.ORDER_ATOMIC)||"iris_X",i=e.valueToCode(this,"test_size",e.ORDER_ATOMIC)||"0.3",s=e.valueToCode(this,"rondom_state",e.ORDER_ATOMIC)||"None";return e.definitions_.import_sklearn_train_test_split="from sklearn.model_selection import train_test_split",["train_test_split("+n+",test_size = "+i+",random_state = "+s+")",e.ORDER_ATOMIC]},tE=function(t,e){var n=e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model",i=e.valueToCode(this,"fit_intercept",e.ORDER_ATOMIC)||"True",s=e.valueToCode(this,"normalize",e.ORDER_ATOMIC)||"False",r=e.valueToCode(this,"n_jobs",e.ORDER_ATOMIC)||"None";return e.definitions_.import_sklearn_linear_model="from sklearn.linear_model import LinearRegression",n+" = LinearRegression(fit_intercept = "+i+",normalize = "+s+",n_jobs = "+r+")\n"},eE=function(t,e){var n=e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model",i=e.valueToCode(this,"alpha",e.ORDER_ATOMIC)||"1.0",s=e.valueToCode(this,"fit_intercept",e.ORDER_ATOMIC)||"True",r=e.valueToCode(this,"normalize",e.ORDER_ATOMIC)||"False",a=e.valueToCode(this,"max_iter",e.ORDER_ATOMIC)||"300",o=e.valueToCode(this,"random_state",e.ORDER_ATOMIC)||"None";return e.definitions_.import_sklearn_linear_model="from sklearn.linear_model import Ridge",n+" = Ridge(alpha = "+i+",fit_intercept = "+s+",normalize = "+r+",max_iter = "+a+",random_state = "+o+")\n"},nE=function(t,e){var n=e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model",i=this.getFieldValue("type"),s=e.valueToCode(this,"max_depth",e.ORDER_ATOMIC)||"None",r=e.valueToCode(this,"random_state",e.ORDER_ATOMIC)||"None";return e.definitions_["import_sklearn_"+i]="from sklearn.tree import "+i,n+" = "+i+"(max_depth = "+s+",random_state = "+r+")\n"},iE=function(t,e){var n=this.getFieldValue("type"),i=e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"Model",s=e.valueToCode(this,"n_estimators",e.ORDER_ATOMIC)||"100",r=e.valueToCode(this,"max_depth",e.ORDER_ATOMIC)||"None",a=e.valueToCode(this,"n_jobs",e.ORDER_ATOMIC)||"None",o=e.valueToCode(this,"random_state",e.ORDER_ATOMIC)||"None";return e.definitions_["import_sklearn_"+n]="from sklearn.ensemble import "+n,i+" = "+n+"(n_estimators = "+s+",max_depth = "+r+",n_jobs = "+a+",random_state = "+o+")\n"},sE=function(t,e){var n=this.getFieldValue("type"),i=e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model",s=e.valueToCode(this,"K",e.ORDER_ATOMIC)||"5",r=e.valueToCode(this,"n_jobs",e.ORDER_ATOMIC)||"None";return e.definitions_["import_sklearn_"+n]="from sklearn.neighbors import "+n,i+" = "+n+"(n_neighbors = "+s+",n_jobs = "+r+")\n"},rE=function(t,e){var n=e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model";return e.definitions_.import_sklearn_GaussianNB="from sklearn.naive_bayes import GaussianNB",n+" = GaussianNB()\n"},aE=function(t,e){var n=e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"pca",i=e.valueToCode(this,"n_components",e.ORDER_ATOMIC)||"2";return e.definitions_.import_sklearn_pca="from sklearn.decomposition import PCA",n+" = PCA(n_components="+i+")\n"},oE=function(t,e){return[e.valueToCode(t,"model_name",e.ORDER_ATOMIC)+".fit_transform("+e.valueToCode(t,"train_data",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},lE=function(t,e){var n=e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model",i=e.valueToCode(this,"n_clusters",e.ORDER_ATOMIC)||"8",s=e.valueToCode(this,"max_iter",e.ORDER_ATOMIC)||"300",r=e.valueToCode(this,"random_state",e.ORDER_ATOMIC)||"None";return e.definitions_.import_sklearn_KMeans="from sklearn.cluster import KMeans",n+" = KMeans(n_clusters = "+i+",max_iter = "+s+",random_state = "+r+")\n"},uE=function(t,e){return e.valueToCode(t,"model_name",e.ORDER_ATOMIC)+".fit("+e.valueToCode(t,"train_data",e.ORDER_ATOMIC)+")\n"},hE=function(t,e){var n=e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model",i=e.valueToCode(this,"train_data",e.ORDER_ATOMIC)||"X_train",s=e.valueToCode(this,"train_target",e.ORDER_ATOMIC)||"y_train";if("None"==s)var r=n+".fit("+i+")\n";else r=n+".fit("+i+","+s+")\n";return r},pE=function(t,e){return(e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model")+".fit("+(e.valueToCode(this,"train_data",e.ORDER_ATOMIC)||"X_train")+")\n"},cE=function(t,e){return[(e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model")+".predict("+(e.valueToCode(this,"train_data",e.ORDER_ATOMIC)||"X_test")+")",e.ORDER_ATOMIC]},dE=function(t,e){var n=e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model",i=e.valueToCode(this,"train_data",e.ORDER_ATOMIC)||"X_train",s=e.valueToCode(this,"train_target",e.ORDER_ATOMIC)||"y_train";if("None"==s)var r=n+".score("+i+")";else r=n+".score("+i+","+s+")";return[r,e.ORDER_ATOMIC]},fE=function(t,e){return[(e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model")+".score("+(e.valueToCode(this,"train_data",e.ORDER_ATOMIC)||"X_train")+")",e.ORDER_ATOMIC]},mE=function(t,e){return[(e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model")+"."+this.getFieldValue("type"),e.ORDER_ATOMIC]},gE=function(t,e){return[(e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model")+"."+this.getFieldValue("type"),e.ORDER_ATOMIC]},_E=function(t,e){var n=e.valueToCode(this,"model_name",e.ORDER_ATOMIC)||"model",i=this.getFieldValue("type"),s=e.valueToCode(this,"address",e.ORDER_ATOMIC)||"D:/mixly/test.pkl";e.definitions_.import_sklearn_joblib="import joblib";return"dump"==i?"joblib.dump("+n+","+s+")\n":n+" = joblib.load("+s+")\n"},TE=function(t,e){e.definitions_.import_time="import time";return["time.time()",e.ORDER_ATOMIC]},yE=function(){return"exit()\n"},IE=function(t,e){e.definitions_.import_time="import time";var n=this.getFieldValue("op"),i="time.localtime()["+n+"]";if("all"===n){return["time.localtime()",e.ORDER_ASSIGNMENT]}return[i,e.ORDER_ASSIGNMENT]},EE=function(t,e){return e.definitions_.import_turtle="import turtle",e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+" = turtle.Turtle()\n"},bE=function(t,e){e.definitions_.import_turtle="import turtle";return"turtle.done()\n"},vE=function(t,e){e.definitions_.import_turtle="import turtle";return"turtle.exitonclick()\n"},wE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+"."+this.getFieldValue("DIR")+"("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},SE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+"."+this.getFieldValue("DIR")+"("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},xE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".setheading("+(e.valueToCode(this,"data",e.ORDER_ASSIGNMENT)||"0")+")\n"},RE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".screen.delay("+(e.valueToCode(this,"data",e.ORDER_ASSIGNMENT)||"0")+")\n"},OE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".goto("+(e.valueToCode(this,"data",e.ORDER_ASSIGNMENT)||"0")+","+(e.valueToCode(this,"val",e.ORDER_ASSIGNMENT)||"0")+")\n"},AE=function(t,e){return e.definitions_.import_turtle="import turtle",[(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+"."+this.getFieldValue("DIR")+"()",e.ORDER_ATOMIC]},ME=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+"."+this.getFieldValue("DIR")+"()\n"},CE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+"."+this.getFieldValue("DIR")+"()\n"},NE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+"."+this.getFieldValue("DIR")+"_fill()\n"},kE=function(t,e){return e.definitions_.import_turtle="import turtle",this.getFieldValue("TUR")+"."+this.getFieldValue("DIR")+"("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},DE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".pensize("+(e.valueToCode(this,"data",e.ORDER_ASSIGNMENT)||"0")+")\n"},LE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".speed("+(e.valueToCode(this,"data",e.ORDER_ASSIGNMENT)||"0")+")\n"},FE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+"."+this.getFieldValue("DIR")+"("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},PE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".set"+this.getFieldValue("DIR")+"("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},$E=function(t,e){e.definitions_.import_turtle="import turtle";var n=e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"data",e.ORDER_ASSIGNMENT)||"0";return n+".circle ("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+","+i+")\n"},BE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+"."+this.getFieldValue("DIR")+"()\n"},VE=function(t,e){return e.definitions_.import_turtle="import turtle",'turtle.bgcolor("'+this.getFieldValue("FIELDNAME")+'")\n'},UE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+'.pencolor("'+this.getFieldValue("FIELDNAME")+'")\n'},YE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+'.fillcolor("'+this.getFieldValue("FIELDNAME")+'")\n'},GE=function(t,e){return e.definitions_.import_turtle="import turtle",[(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".clone()",e.ORDER_ATOMIC]},HE=function(t,e){return e.definitions_.import_turtle="import turtle","turtle.bgcolor("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},WE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".pencolor("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},zE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".fillcolor("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},XE=function(t,e){return e.definitions_.import_turtle="import turtle","turtle.bgcolor("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},jE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".pencolor("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},qE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".fillcolor("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},KE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".color("+e.valueToCode(this,"VAR1",e.ORDER_ATOMIC)+","+e.valueToCode(this,"VAR2",e.ORDER_ATOMIC)+")\n"},QE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+'.color("'+this.getFieldValue("FIELDNAME")+'","'+this.getFieldValue("FIELDNAME2")+'")\n'},JE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".shape('"+this.getFieldValue("DIR")+"')\n"},ZE=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".shapesize("+(e.valueToCode(this,"WID",e.ORDER_ASSIGNMENT)||"0")+","+(e.valueToCode(this,"LEN",e.ORDER_ASSIGNMENT)||"0")+","+(e.valueToCode(this,"OUTLINE",e.ORDER_ASSIGNMENT)||"0")+")\n"},tb=function(t,e){return e.definitions_.import_turtle="import turtle",["turtle.textinput("+e.valueToCode(this,"TITLE",e.ORDER_ATOMIC)+","+e.valueToCode(this,"PROMPT",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},eb=function(t,e){return e.definitions_.import_turtle="import turtle",["turtle.numinput("+e.valueToCode(this,"TITLE",e.ORDER_ATOMIC)+","+e.valueToCode(this,"PROMPT",e.ORDER_ATOMIC)+","+e.valueToCode(this,"DEFAULT",e.ORDER_ATOMIC)+",minval = "+e.valueToCode(this,"MIN",e.ORDER_ATOMIC)+",maxval = "+e.valueToCode(this,"MAX",e.ORDER_ATOMIC)+")",e.ORDER_ATOMIC]},nb=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".write("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+")\n"},ib=function(t,e){e.definitions_.import_turtle="import turtle";var n=this.getFieldValue("MOVE"),i=this.getFieldValue("ALIGN"),s=e.valueToCode(this,"FONTNAME",e.ORDER_ATOMIC),r=e.valueToCode(this,"FONTNUM",e.ORDER_ASSIGNMENT)||"0",a=this.getFieldValue("FONTTYPE");return(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".write("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+","+n+',align="'+i+'",font=('+s+","+r+',"'+a+'"))\n'},sb=function(t,e){e.definitions_.import_turtle="import turtle";var n=this.getFieldValue("MOVE"),i=this.getFieldValue("ALIGN"),s=e.valueToCode(this,"FONTNAME",e.ORDER_ATOMIC),r=e.valueToCode(this,"FONTNUM",e.ORDER_ASSIGNMENT)||"0",a=this.getFieldValue("FONTTYPE");return(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".write("+e.valueToCode(this,"VAR",e.ORDER_ATOMIC)+","+n+',align="'+i+'",font=('+s+","+r+',"'+a+'"))\n'},rb=function(t,e){return['"'+this.getFieldValue("COLOR")+'"',e.ORDER_ATOMIC]},ab=function(t,e){e.definitions_.import_turtle="import turtle";var n=e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0";return e.variableDB_.getName(this.getFieldValue("VAR"),Jt.Variables.NAME_TYPE)+" = "+n+".getscreen()\n"},ob=function(t,e){e.definitions_.import_turtle="import turtle";var n=e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"VAR",e.ORDER_NONE)||"None";return n+".onkey("+(e.valueToCode(this,"callback",e.ORDER_NONE)||"None")+", "+i+")\n"},lb=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".onclick("+(e.valueToCode(this,"callback",e.ORDER_NONE)||"None")+")\n"},ub=function(t,e){e.definitions_.import_turtle="import turtle";var n=e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0",i=e.valueToCode(this,"VAR",e.ORDER_NONE)||"None";return n+".ontimer("+(e.valueToCode(this,"callback",e.ORDER_NONE)||"None")+", "+i+")\n"},hb=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".listen()\n"},pb=function(t,e){return e.definitions_.import_turtle="import turtle",(e.valueToCode(this,"TUR",e.ORDER_ASSIGNMENT)||"0")+".getcanvas().postscript(file="+e.valueToCode(this,"FILE",e.ORDER_ATOMIC)+")\n"};var cb=__webpack_require__(6944);const db=$;var fb=__webpack_require__.n(db),mb=__webpack_require__(6619),gb=__webpack_require__.n(mb);const _b={stage:new(gb().Container),pointer:{x:0,y:0},backgroundSprite:null,sprites:{},texts:{},counter:0,keys:{},state:!1,running:!1,repeatPlay:()=>{},displayTag:!1,processingDisplayEvent:null,successDisplayEvents:[],successProcessingDisplayEvents:[],startTime:performance.now(),timer:0,lastFrameTime:null,lastSecond:null,targetFPS:60,frameCount:0,currentFPS:60,canvasHeight:450,canvasWidth:800,gameLoop:()=>{1==_b.state&&(_b.repeatPlay(),_b.gameLoopDisplay()),_b.timer=performance.now()-_b.startTime},animate:t=>{t-_b.lastFrameTime>=1e3/_b.targetFPS&&(_b.frameCount++,_b.gameLoop(),_b.renderer.render(_b.stage),_b.lastFrameTime=t),t-_b.lastSecond>=1e3&&(_b.currentFPS=_b.frameCount,_b.frameCount=0,_b.lastSecond=t),requestAnimationFrame(_b.animate)}};_b.createBackground=(t,e=0)=>{var n;return 0==e&&(n=new(gb().Sprite.fromImage)(`../common/media/spriteimg/${t}.png`)),n.name="background",n.anchor.set(.5),n.x=_b.canvasWidth/2,n.y=_b.canvasHeight/2,n.width=_b.canvasWidth,n.height=_b.canvasHeight,n.interactive=!0,n.buttonMode=!0,n.isDown=!1,n.isUp=!0,n.on("mousedown",(function(){this.isDown=!0,this.isUp=!1,_b.state&&this.runningMouseDown()})).on("mouseup",(function(){this.isDown=!1,this.isUp=!0})).on("mouseupoutside",(function(){this.isDown=!1,this.isUp=!0})),n.runningMouseDown=new Function(""),_b.backgroundSprite&&_b.backgroundSprite.parent&&_b.stage.removeChild(_b.backgroundSprite),_b.backgroundSprite=n,_b.stage.addChildAt(_b.backgroundSprite,0),0},_b.createASprite=(t,e=_b.canvasWidth/2,n=_b.canvasHeight/2,i="",s=0)=>{var r;return""==i&&(i="sprite"+ ++_b.counter),0==s&&(r=new(gb().Sprite.fromImage)(`../common/media/spriteimg/${t}.png`)),_b.sprites[i]||_b.texts[i]||(r.name=i,r.anchor.set(.5),r.x=e,r.y=n,r.interactive=!0,r.buttonMode=!0,r.isDown=!1,r.isUp=!0,r.on("mousedown",(function(t){this.isDown=!0,this.isUp=!1,_b.state?this.runningMouseDown():(this.data=t.data,this.alpha=.5,this.dragging=!0)})).on("mouseup",(function(){this.isDown=!1,this.isUp=!0,_b.state||(this.alpha=1,this.dragging=!1,this.data=null)})).on("mouseupoutside",(function(){this.isDown=!1,this.isUp=!0,_b.state||(this.alpha=1,this.dragging=!1,this.data=null)})).on("mousemove",(function(){if(!_b.state&&this.dragging){var t=this.data.getLocalPosition(this.parent);this.position.x=t.x,this.position.y=t.y}})),r.runningMouseDown=new Function(""),r.show=function(){this.visible=!0},r.hide=function(){this.visible=!1},r.enlarge=function(t){const e=this.height/this.width;var n=Math.sqrt(this.height*this.width);n+=t,this.width=Math.sqrt(n*n/e),this.height=this.width*e},r.enlargeTo=function(t){var e=this.height/this.width;this.width=Math.sqrt(t*t/e),this.height=this.width*e},r.expandTo=async function(t,e=1){if(_b.running){_b.displayTag=!0,_b.processingDisplayEvent={sprite:this,targetS:t,totalTime:1e3*e,startTime:performance.now(),displayType:"expand"};var n=new Promise((t=>{if(!1===_b.displayTag)t();else{const e=setInterval((()=>{!1===_b.displayTag&&(clearInterval(e),t())}),10)}}));return await n}return _b.successProcessingDisplayEvents.push({sprite:this,targetS:t,totalTime:1e3*e,startTime:performance.now(),displayType:"expand"}),0},r.move=function(t){this.x+=t*Math.cos(this.rotation),this.y+=t*Math.sin(this.rotation)},r.moveTo=function(t,e){this.x=t,this.y=e},r.slideTo=async function(t,e,n=1){if(_b.running){_b.displayTag=!0,_b.processingDisplayEvent={sprite:this,targetX:t,targetY:e,totalTime:1e3*n,startTime:performance.now(),displayType:"slide"};var i=new Promise((t=>{const e=setInterval((()=>{!1===_b.displayTag&&(clearInterval(e),t())}),10)}));return await i}return _b.successProcessingDisplayEvents.push({sprite:this,targetX:t,targetY:e,totalTime:1e3*n,startTime:performance.now(),displayType:"slide"}),0},r.addX=function(t){this.x+=t},r.addY=function(t){this.y+=t},r.rotate=function(t){this.rotation+=Math.PI/180*t},r.rotateTo=function(t){this.rotation=Math.PI/180*t},r.circleTo=async function(t,e=1){if(_b.running){_b.displayTag=!0,_b.processingDisplayEvent={sprite:this,targetDegree:t,totalTime:1e3*e,startTime:performance.now(),displayType:"circle"};var n=new Promise((t=>{if(!1===_b.displayTag)t();else{const e=setInterval((()=>{!1===_b.displayTag&&(clearInterval(e),t())}),10)}}));return await n}return _b.successProcessingDisplayEvents.push({sprite:this,targetDegree:t,totalTime:1e3*e,startTime:performance.now(),displayType:"circle"}),0},r.hit=function(t){return _b.hitTestRectangle(this,t)},r.outOfScreen=function(){return this.y>=_b.renderer.height||this.y<=0||this.x<=0||this.x>=_b.renderer.width},r.mouseAction=function(t){this.runningMouseDown=t},r.setScale=function(t=0,e=0){0==t&&(t=this.height),0==e&&(e=this.width),this.height=t,this.width=e},r.filterGray=function(){const t=new(gb().filters.ColorMatrixFilter);t.blackAndWhite(),this.filters=[t]},r.filterBrighter=function(){const t=new(gb().filters.ColorMatrixFilter);t.brightness(1.25),this.filters=[t]},r.filterOrigin=function(){this.filters=null},_b.stage.addChild(r),_b.sprites[i]=r),i},_b.clearAllSprites=()=>{_b.backgroundSprite&&_b.backgroundSprite.parent&&_b.backgroundSprite.parent.removeChild(_b.backgroundSprite);for(const t in _b.sprites)_b.sprites[t].parent.removeChild(_b.sprites[t]),delete _b.sprites[t];for(const t in _b.texts)_b.texts[t].parent.removeChild(_b.texts[t]),delete _b.texts[t];return _b.counter=0,_b.clearTimer(),0},_b.createText=(t,e=_b.canvasWidth/2,n=_b.canvasHeight/2,i="")=>{if(""==i&&(i="text"+ ++_b.counter),!_b.sprites[i]&&!_b.texts[i]){var s=new(gb().Text)(t);s.name=i,s.x=e,s.y=n,s.interactive=!0,s.buttonMode=!0,s.on("mousedown",(function(t){this.isDown=!0,this.isUp=!1,_b.state?this.runningMouseDown():(this.data=t.data,this.alpha=.5,this.dragging=!0)})).on("mouseup",(function(){this.isDown=!1,this.isUp=!0,_b.state||(this.alpha=1,this.dragging=!1,this.data=null)})).on("mouseupoutside",(function(){this.isDown=!1,this.isUp=!0,_b.state||(this.alpha=1,this.dragging=!1,this.data=null)})).on("mousemove",(function(){if(!_b.state&&this.dragging){var t=this.data.getLocalPosition(this.parent);this.position.x=t.x,this.position.y=t.y}})),s.runningMouseDown=new Function(""),s.changeText=function(t){this.text=t},s.show=function(){this.visible=!0},s.hide=function(){this.visible=!1},_b.stage.addChild(s),_b.texts[i]=s}return i},_b.hitTestRectangle=(t,e)=>{let n,i,s,r,a;return n=!1,t.centerX=t.x+t.width/2,t.centerY=t.y+t.height/2,e.centerX=e.x+e.width/2,e.centerY=e.y+e.height/2,t.halfWidth=t.width/2,t.halfHeight=t.height/2,e.halfWidth=e.width/2,e.halfHeight=e.height/2,r=t.centerX-e.centerX,a=t.centerY-e.centerY,i=t.halfWidth+e.halfWidth,s=t.halfHeight+e.halfHeight,n=Math.abs(r)<i&&Math.abs(a)<s,n},_b.repeat=t=>{_b.repeatPlay=t},_b.isKeyboardHit=t=>{if(!_b.keys[t]){let e=_b.keyboard(t);_b.keys[t]=e}return _b.keys[t].isDown},_b.keyboardListener=(t,e)=>{if(_b.keys[t])_b.keys[t].press=function(){_b.state&&e()};else{let n=_b.keyboard(t);n.press=function(){_b.state&&e()},_b.keys[t]=n}},_b.keyboard=t=>{let e={};e.value=t,e.isDown=!1,e.isUp=!0,e.press=void 0,e.release=void 0,e.downHandler=t=>{t.key===e.value&&(e.isUp&&e.press&&e.press(),e.isDown=!0,e.isUp=!1,t.preventDefault())},e.upHandler=t=>{t.key===e.value&&(e.isDown&&e.release&&e.release(),e.isDown=!1,e.isUp=!0,t.preventDefault())};const n=e.downHandler.bind(e),i=e.upHandler.bind(e);return window.addEventListener("keydown",n,!1),window.addEventListener("keyup",i,!1),e.unsubscribe=()=>{window.removeEventListener("keydown",n),window.removeEventListener("keyup",i)},e},_b.clearTimer=()=>{_b.startTime=performance.now()},_b.gameLoopDisplay=()=>{if(_b.processingDisplayEvent){const t=_b.processingDisplayEvent;switch(t.displayType){case"slide":if(performance.now()>=t.totalTime+t.startTime)t.sprite.moveTo(t.targetX,t.targetY),_b.displayTag=!1,_b.processingDisplayEvent=null;else(e=_b.currentFPS*(t.totalTime+t.startTime-performance.now())/1e3)>=1&&(t.sprite.addX((t.targetX-t.sprite.x)/e),t.sprite.addY((t.targetY-t.sprite.y)/e));break;case"expand":if(performance.now()>=t.totalTime+t.startTime)t.sprite.enlargeTo(t.targetS),_b.displayTag=!1,_b.processingDisplayEvent=null;else(e=_b.currentFPS*(t.totalTime+t.startTime-performance.now())/1e3)>=1&&t.sprite.enlarge((t.targetS-Math.sqrt(t.sprite.height*t.sprite.width))/e);break;case"circle":if(performance.now()>=t.totalTime+t.startTime)t.sprite.rotateTo(t.targetDegree),_b.displayTag=!1,_b.processingDisplayEvent=null;else(e=_b.currentFPS*(t.totalTime+t.startTime-performance.now())/1e3)>=1&&t.sprite.rotate((t.targetDegree-180*t.sprite.rotation/Math.PI)/e)}}if(!_b.running&&_b.successProcessingDisplayEvents.length)for(var t=_b.successProcessingDisplayEvents.length-1;t>=0;t--){const n=_b.successProcessingDisplayEvents[t];switch(n.displayType){case"slide":if(performance.now()>=n.totalTime+n.startTime)n.sprite.moveTo(n.targetX,n.targetY),_b.successProcessingDisplayEvents.splice(t,1);else(e=_b.currentFPS*(n.totalTime+n.startTime-performance.now())/1e3)>=1&&(n.sprite.addX((n.targetX-n.sprite.x)/e),n.sprite.addY((n.targetY-n.sprite.y)/e));break;case"expand":if(performance.now()>=n.totalTime+n.startTime)n.sprite.enlargeTo(n.targetS),_b.successProcessingDisplayEvents.splice(t,1);else(e=_b.currentFPS*(n.totalTime+n.startTime-performance.now())/1e3)>=1&&n.sprite.enlarge((n.targetS-Math.sqrt(n.sprite.height*n.sprite.width))/e);break;case"circle":var e;if(performance.now()>=n.totalTime+n.startTime)n.sprite.rotateTo(n.targetDegree),_b.successProcessingDisplayEvents.splice(t,1);else(e=_b.currentFPS*(n.totalTime+n.startTime-performance.now())/1e3)>=1&&n.sprite.rotate((n.targetDegree-180*n.sprite.rotation/Math.PI)/e)}}},_b.changeWidth=t=>{const e=fb()(_b.renderer.view),n=e.width(),i=e.height();e.width(t),e.height(t/n*i)},_b.kill=()=>{_b.state=!1,_b.repeatPlay=new Function;for(let t in _b.keys)_b.keys[t].unsubscribe(),delete _b.keys[t];_b.processingDisplayEvent=null,_b.displayTag=!1,_b.running=!1,_b.clearTimer()},_b.runit=t=>{const e=fb()(t);e.empty(),gb().SCALE_MODES.DEFAULT=gb().SCALE_MODES.NEAREST,_b.renderer=gb().autoDetectRenderer(_b.canvasWidth,_b.canvasHeight,{backgroundColor:16777215}),e.append(_b.renderer.view),_b.pointer={x:0,y:0},_b.stage.sortableChildren=!0,_b.stage.interactive=!0,_b.stage.on("mousemove",((t=gb().InteractionEvent)=>{_b.pointer.x=t.data.global.x,_b.pointer.y=t.data.global.y})),_b.lastFrameTime=0,_b.running=!0,_b.lastFrameTime||(_b.lastFrameTime=performance.now(),_b.lastSecond=performance.now()),_b.animate(performance.now()),_b.repeatPlay=new Function;for(let t in _b.keys)_b.keys[t].unsubscribe(),delete _b.keys[t];_b.backgroundSprite&&(_b.backgroundSprite.runningMouseDown=new Function);for(let t in _b.sprites)_b.sprites[t].runningMouseDown=new Function;for(let t in _b.texts)_b.texts[t].runningMouseDown=new Function;_b.processingDisplayEvent=null,_b.displayTag=!1,_b.clearTimer(),_b.changeWidth(fb()("body").width()/2),_b.state=!0},window.mixlySprite=_b;const Tb=_b;var yb=__webpack_require__(9610);class Ib{constructor(t,e){this._pageLoad=new yb.D,this._kernelAvailable=new yb.D,this._loaderId="basthon-loader",this._doNotHideLoader=!0;const n=t.language;if(null!=e&&(this._loaderId=e),"loading"===document.readyState){const t=()=>{document.removeEventListener("DOMContentLoaded",t),this._pageLoad.resolve()};document.addEventListener("DOMContentLoaded",t)}else this._pageLoad.resolve();(async()=>{switch(n){case"python":case"python3":case"python3.11":const{KernelPython3:e}=await __webpack_require__.e(211).then(__webpack_require__.bind(__webpack_require__,211));this._kernel=new e(t);break;case"python3-old":case"python3.8":const{KernelPython3Old:i}=await __webpack_require__.e(195).then(__webpack_require__.bind(__webpack_require__,5195));this._kernel=new i(t);break;case"js":case"javascript":const{KernelJavaScript:s}=await __webpack_require__.e(97).then(__webpack_require__.bind(__webpack_require__,4097));this._kernel=new s(t);break;case"sql":const{KernelSQL:r}=await Promise.all([__webpack_require__.e(960),__webpack_require__.e(837)]).then(__webpack_require__.bind(__webpack_require__,592));this._kernel=new r(t);break;case"ocaml":const{KernelOCaml:a}=await __webpack_require__.e(38).then(__webpack_require__.bind(__webpack_require__,38));this._kernel=new a(t);break;default:return window.console.error(`Kernel '${n}' not supported.`),void this._kernelAvailable.reject()}window.Basthon=this._kernel,this._kernelAvailable.resolve(this._kernel)})()}async pageLoad(){await this._pageLoad.promise}async kernelAvailable(){return await this._kernelAvailable.promise}async kernelLoaded(){const t=await this.kernelAvailable();return await t.loaded(),t}get kernel(){return this._kernel}get kernelSafe(){var t;return(null===(t=this.kernel)||void 0===t?void 0:t.ready)?this.kernel:null}async showLoader(t,e=!1,n=!0){this.kernelAvailable().then((()=>{var t;return null===(t=this.kernel)||void 0===t?void 0:t.init()})),__webpack_require__.e(317).then(__webpack_require__.bind(__webpack_require__,1317));const i="basthon-loader-"+(e?"full":"foot"),s=document.createElement("div");s.id=this._loaderId,s.classList.add("darklighted"),s.classList.add("basthon-loader-root"),s.classList.add(i);const r=document.createElement("div");r.classList.add("basthon-loader-container"),r.classList.add(i),s.appendChild(r);const a=document.createElement("div");a.classList.add("basthon-loader-spinner"),a.classList.add(i),a.innerHTML="<span><span></span><span></span></span>",r.appendChild(a);const o=document.createElement("div");o.classList.add("basthon-loader-break"),o.classList.add(i),r.appendChild(o);const l=document.createElement("div");l.classList.add("basthon-loader-text"),l.classList.add(i),l.innerHTML=t,r.appendChild(l),this._loaderTextElem=l;const u=document.createElement("div");u.classList.add("basthon-loader-text"),u.classList.add(i),u.style.display="none",r.appendChild(u),this._loaderTextError=u,await this.pageLoad(),document.body.appendChild(s),this._rootLoader=s;try{await this.kernelLoaded()}catch(t){const e=this.browser();this.setErrorText(`Erreur de chargement de Basthon !!!<br>Vérifiez que votre navigateur est à jour.<br>Version détectée : ${e.name} ${e.version}.`);for(const t of document.body.querySelectorAll(".basthon-loader-foot"))t.classList.remove("basthon-loader-foot"),t.classList.add("basthon-loader-full");return a.classList.remove("basthon-loader-spinner"),a.classList.add("basthon-loader-error"),void(this._doNotHideLoader=!0)}this._doNotHideLoader=!1,n&&this.hideLoader()}setLoaderText(t){null!=this._loaderTextElem&&(this._loaderTextElem.innerHTML=t)}setErrorText(t){null!=this._loaderTextElem&&(this._loaderTextElem.style.display="none"),null!=this._loaderTextError&&(this._loaderTextError.style.display="",this._loaderTextError.innerHTML=t)}hideLoader(){if(this._doNotHideLoader)return;const t=this._rootLoader;null!=t&&(t.classList.add("basthon-loader-hide"),window.setTimeout((()=>{this._rootLoader=void 0,t.remove()}),1100))}browser(){var t,e=navigator.userAgent,n=e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];return/trident/i.test(n[1])?{name:"IE",version:(t=/\brv[ :]+(\d+)/g.exec(e)||[])[1]||""}:"Chrome"===n[1]&&null!=(t=e.match(/\bOPR|Edge\/(\d+)/))?{name:"Opera",version:t[1]}:(n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(t=e.match(/version\/(\d+)/i))&&n.splice(1,1,t[1]),{name:n[0],version:n[1]})}}class Eb extends Zt.PageBase{static{Zt.HTMLTemplate.add("html/statusbar/statusbar-image.html",new Zt.HTMLTemplate('<style>\r\n div[m-id="{{d.mId}}"] {\r\n display: flex;\r\n flex-direction: row;\r\n justify-content: center;\r\n align-items: center;\r\n flex-wrap: wrap;\r\n align-content: flex-start;\r\n overflow: auto;\r\n }\r\n\r\n html[data-bs-theme=light] div[m-id="{{d.mId}}"] {\r\n background-color: #ffffff;\r\n }\r\n\r\n html[data-bs-theme=dark] div[m-id="{{d.mId}}"] {\r\n background-color: #1e1e1e;\r\n }\r\n</style>\r\n<div m-id="{{d.mId}}" class="page-item"></div>')),this.init=function(){Zt.StatusBarsManager.typesRegistry.register(["images"],Eb);const t=Zt.Workspace.getMain().getStatusBarsManager();return t.add({type:"images",id:"images",name:Jt.Msg.PYTHON_PYODIDE_IMAGE,title:Jt.Msg.PYTHON_PYODIDE_IMAGE}),t.changeTo("output"),t.get("images")}}constructor(){super();const t=fb()(Zt.HTMLTemplate.get("html/statusbar/statusbar-image.html").render());this.setContent(t)}init(){super.init(),this.hideCloseBtn()}clean(){this.getContent().empty()}display(t){const e=this.getContent(),n=function(t){t.style.width="auto",t.style.height="auto",t.style.maxWidth="100%",t.style.maxHeight="100%"};this.clean();let i=t.content,s=null,r=null;switch(t.display_type){case"p5":i.style.width="100%",i.style.height="100%",i.style.display="flex",i.style.justifyContent="center",i.style.alignItems="center",new MutationObserver((function(t){t.forEach((t=>t.addedNodes.forEach((t=>{const e=t;null!=e.tagName&&["canvas","video"].includes(e.tagName.toLowerCase())&&n(e)}))))})).observe(i,{childList:!0}),i.querySelectorAll("canvas,video").forEach(n),e.append(i);break;case"matplotlib":s=i.querySelector("canvas"),s&&(i=s),i.style.width="",i.style.height="",i.style.maxWidth="100%",i.style.maxHeight="100%",e.append(i);break;case"ocaml-canvas":i.style.width="",i.style.height="",i.style.maxWidth="100%",i.style.maxHeight="100%",e.append(i);break;case"turtle":i.setAttribute("width","100%"),i.setAttribute("height","100%"),e.append(i.outerHTML);break;case"sympy":e.append(t.content),void 0===window.MathJax?(console.log("Loading MathJax (Sympy expression needs it)."),function(){let t=document.createElement("script");t.type="text/javascript",t.src="https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-mml-chtml.js",document.getElementsByTagName("head")[0].appendChild(t)}()):window.MathJax.typeset();break;case"multiple":for(let n of["image/svg+xml","image/png","text/html","text/plain"])if(n in t.content){let i=t.content[n];"image/png"===n&&(i='<img src="data:image/png;base64,'+i+'" style="max-width: 100%; max-height: 100%;">'),e.append(i);break}break;case"tutor":if(e.append(fb()(t.content.replace("overflow-y%3A%20hidden%3B",""))),r=this.getContent()[0].getElementsByTagName("iframe")[0],null==r)return;r.style.maxHeight=r.style.minHeight="100%",new IntersectionObserver(((t,e)=>{const n=t[0];n&&!n.isIntersecting||(r.contentWindow?.postMessage({type:"redraw"},"*"),e.disconnect())})).observe(r);break;default:console.error(`Not supported node type '${t.display_type}' in eval.display result processing.`)}}}const bb=layui;var vb;!function(t){t[t.EPERM=1]="EPERM",t[t.ENOENT=2]="ENOENT",t[t.EINTR=4]="EINTR",t[t.EIO=5]="EIO",t[t.ENXIO=6]="ENXIO",t[t.EBADF=9]="EBADF",t[t.EAGAIN=11]="EAGAIN",t[t.ENOMEM=12]="ENOMEM",t[t.EACCES=13]="EACCES",t[t.EFAULT=14]="EFAULT",t[t.ENOTBLK=15]="ENOTBLK",t[t.EBUSY=16]="EBUSY",t[t.EEXIST=17]="EEXIST",t[t.EXDEV=18]="EXDEV",t[t.ENODEV=19]="ENODEV",t[t.ENOTDIR=20]="ENOTDIR",t[t.EISDIR=21]="EISDIR",t[t.EINVAL=22]="EINVAL",t[t.ENFILE=23]="ENFILE",t[t.EMFILE=24]="EMFILE",t[t.ETXTBSY=26]="ETXTBSY",t[t.EFBIG=27]="EFBIG",t[t.ENOSPC=28]="ENOSPC",t[t.ESPIPE=29]="ESPIPE",t[t.EROFS=30]="EROFS",t[t.EMLINK=31]="EMLINK",t[t.EPIPE=32]="EPIPE",t[t.EDOM=33]="EDOM",t[t.ERANGE=34]="ERANGE",t[t.EDEADLK=35]="EDEADLK",t[t.ENAMETOOLONG=36]="ENAMETOOLONG",t[t.ENOLCK=37]="ENOLCK",t[t.ENOSYS=38]="ENOSYS",t[t.ENOTEMPTY=39]="ENOTEMPTY",t[t.ELOOP=40]="ELOOP",t[t.ENOMSG=42]="ENOMSG",t[t.EBADE=52]="EBADE",t[t.EBADR=53]="EBADR",t[t.EXFULL=54]="EXFULL",t[t.ENOANO=55]="ENOANO",t[t.EBADRQC=56]="EBADRQC",t[t.ENOSTR=60]="ENOSTR",t[t.ENODATA=61]="ENODATA",t[t.ETIME=62]="ETIME",t[t.ENOSR=63]="ENOSR",t[t.ENONET=64]="ENONET",t[t.EREMOTE=66]="EREMOTE",t[t.ENOLINK=67]="ENOLINK",t[t.ECOMM=70]="ECOMM",t[t.EPROTO=71]="EPROTO",t[t.EBADMSG=74]="EBADMSG",t[t.EOVERFLOW=75]="EOVERFLOW",t[t.EBADFD=77]="EBADFD",t[t.ESTRPIPE=86]="ESTRPIPE",t[t.ENOTSOCK=88]="ENOTSOCK",t[t.EDESTADDRREQ=89]="EDESTADDRREQ",t[t.EMSGSIZE=90]="EMSGSIZE",t[t.EPROTOTYPE=91]="EPROTOTYPE",t[t.ENOPROTOOPT=92]="ENOPROTOOPT",t[t.EPROTONOSUPPORT=93]="EPROTONOSUPPORT",t[t.ESOCKTNOSUPPORT=94]="ESOCKTNOSUPPORT",t[t.ENOTSUP=95]="ENOTSUP",t[t.ENETDOWN=100]="ENETDOWN",t[t.ENETUNREACH=101]="ENETUNREACH",t[t.ENETRESET=102]="ENETRESET",t[t.ETIMEDOUT=110]="ETIMEDOUT",t[t.ECONNREFUSED=111]="ECONNREFUSED",t[t.EHOSTDOWN=112]="EHOSTDOWN",t[t.EHOSTUNREACH=113]="EHOSTUNREACH",t[t.EALREADY=114]="EALREADY",t[t.EINPROGRESS=115]="EINPROGRESS",t[t.ESTALE=116]="ESTALE",t[t.EREMOTEIO=121]="EREMOTEIO",t[t.EDQUOT=122]="EDQUOT"}(vb||(vb={}));const wb={[vb.EPERM]:"Operation not permitted",[vb.ENOENT]:"No such file or directory",[vb.EINTR]:"Interrupted system call",[vb.EIO]:"Input/output error",[vb.ENXIO]:"No such device or address",[vb.EBADF]:"Bad file descriptor",[vb.EAGAIN]:"Resource temporarily unavailable",[vb.ENOMEM]:"Cannot allocate memory",[vb.EACCES]:"Permission denied",[vb.EFAULT]:"Bad address",[vb.ENOTBLK]:"Block device required",[vb.EBUSY]:"Resource busy or locked",[vb.EEXIST]:"File exists",[vb.EXDEV]:"Invalid cross-device link",[vb.ENODEV]:"No such device",[vb.ENOTDIR]:"File is not a directory",[vb.EISDIR]:"File is a directory",[vb.EINVAL]:"Invalid argument",[vb.ENFILE]:"Too many open files in system",[vb.EMFILE]:"Too many open files",[vb.ETXTBSY]:"Text file busy",[vb.EFBIG]:"File is too big",[vb.ENOSPC]:"No space left on disk",[vb.ESPIPE]:"Illegal seek",[vb.EROFS]:"Cannot modify a read-only file system",[vb.EMLINK]:"Too many links",[vb.EPIPE]:"Broken pipe",[vb.EDOM]:"Numerical argument out of domain",[vb.ERANGE]:"Numerical result out of range",[vb.EDEADLK]:"Resource deadlock would occur",[vb.ENAMETOOLONG]:"File name too long",[vb.ENOLCK]:"No locks available",[vb.ENOSYS]:"Function not implemented",[vb.ENOTEMPTY]:"Directory is not empty",[vb.ELOOP]:"Too many levels of symbolic links",[vb.ENOMSG]:"No message of desired type",[vb.EBADE]:"Invalid exchange",[vb.EBADR]:"Invalid request descriptor",[vb.EXFULL]:"Exchange full",[vb.ENOANO]:"No anode",[vb.EBADRQC]:"Invalid request code",[vb.ENOSTR]:"Device not a stream",[vb.ENODATA]:"No data available",[vb.ETIME]:"Timer expired",[vb.ENOSR]:"Out of streams resources",[vb.ENONET]:"Machine is not on the network",[vb.EREMOTE]:"Object is remote",[vb.ENOLINK]:"Link has been severed",[vb.ECOMM]:"Communication error on send",[vb.EPROTO]:"Protocol error",[vb.EBADMSG]:"Bad message",[vb.EOVERFLOW]:"Value too large for defined data type",[vb.EBADFD]:"File descriptor in bad state",[vb.ESTRPIPE]:"Streams pipe error",[vb.ENOTSOCK]:"Socket operation on non-socket",[vb.EDESTADDRREQ]:"Destination address required",[vb.EMSGSIZE]:"Message too long",[vb.EPROTOTYPE]:"Protocol wrong type for socket",[vb.ENOPROTOOPT]:"Protocol not available",[vb.EPROTONOSUPPORT]:"Protocol not supported",[vb.ESOCKTNOSUPPORT]:"Socket type not supported",[vb.ENOTSUP]:"Operation is not supported",[vb.ENETDOWN]:"Network is down",[vb.ENETUNREACH]:"Network is unreachable",[vb.ENETRESET]:"Network dropped connection on reset",[vb.ETIMEDOUT]:"Connection timed out",[vb.ECONNREFUSED]:"Connection refused",[vb.EHOSTDOWN]:"Host is down",[vb.EHOSTUNREACH]:"No route to host",[vb.EALREADY]:"Operation already in progress",[vb.EINPROGRESS]:"Operation now in progress",[vb.ESTALE]:"Stale file handle",[vb.EREMOTEIO]:"Remote I/O error",[vb.EDQUOT]:"Disk quota exceeded"};class Sb extends Error{static fromJSON(t){const e=new Sb(t.errno,t.message,t.path,t.syscall);return e.code=t.code,e.stack=t.stack,e}static With(t,e,n){return new Sb(vb[t],wb[vb[t]],e,n)}constructor(t,e=wb[t],n,i=""){super(e),this.errno=t,this.path=n,this.syscall=i,this.code=vb[t],this.message=this.code+": "+e+(this.path?`, '${this.path}'`:"")}toString(){return this.message}toJSON(){return{errno:this.errno,code:this.code,path:this.path,stack:this.stack,message:this.message,syscall:this.syscall}}bufferSize(){return 4+JSON.stringify(this.toJSON()).length}}let xb="/";function Rb(t,e){let n="",i=0,s=-1,r=0,a="\0";for(let o=0;o<=t.length;++o){if(o<t.length)a=t[o];else{if("/"==a)break;a="/"}if("/"==a){if(s===o-1||1===r);else if(2===r){if(n.length<2||2!==i||"."!==n.at(-1)||"."!==n.at(-2)){if(n.length>2){const t=n.lastIndexOf("/");-1===t?(n="",i=0):(n=n.slice(0,t),i=n.length-1-n.lastIndexOf("/")),s=o,r=0;continue}if(0!==n.length){n="",i=0,s=o,r=0;continue}}e&&(n+=n.length>0?"/..":"..",i=2)}else n.length>0?n+="/"+t.slice(s+1,o):n=t.slice(s+1,o),i=o-s-1;s=o,r=0}else"."===a&&-1!==r?++r:r=-1}return n}function Ob(...t){let e="";for(const n of[...t.reverse(),xb])if(n.length&&(e=`${n}/${e}`,n.startsWith("/")))break;const n=e.startsWith("/");return e=Rb(e,!n),n?`/${e}`:e.length?e:"/"}function Ab(...t){if(!t.length)return".";const e=t.join("/");return e?.length?function(t){if(!t.length)return".";const e=t.startsWith("/"),n=t.endsWith("/");return(t=Rb(t,!e)).length?(n&&(t+="/"),e?`/${t}`:t):e?"/":n?"./":"."}(e):"."}function Mb(t){if(0===t.length)return".";const e="/"===t[0];let n=-1,i=!0;for(let e=t.length-1;e>=1;--e)if("/"===t[e]){if(!i){n=e;break}}else i=!1;return-1===n?e?"/":".":e&&1===n?"//":t.slice(0,n)}function Cb(t,e){let n=0,i=-1,s=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e===t)return"";let r=e.length-1,a=-1;for(let o=t.length-1;o>=0;--o)if("/"===t[o]){if(!s){n=o+1;break}}else-1===a&&(s=!1,a=o+1),r>=0&&(t[o]===e[r]?-1==--r&&(i=o):(r=-1,i=a));return n===i?i=a:-1===i&&(i=t.length),t.slice(n,i)}for(let e=t.length-1;e>=0;--e)if("/"===t[e]){if(!s){n=e+1;break}}else-1===i&&(s=!1,i=e+1);return-1===i?"":t.slice(n,i)}function Nb(t){const e=t.startsWith("/"),n={root:e?"/":"",dir:"",base:"",ext:"",name:""};if(0===t.length)return n;const i=e?1:0;let s=-1,r=0,a=-1,o=!0,l=t.length-1,u=0;for(;l>=i;--l)if("/"!==t[l])-1===a&&(o=!1,a=l+1),"."===t[l]?-1===s?s=l:1!==u&&(u=1):-1!==s&&(u=-1);else if(!o){r=l+1;break}if(-1!==a){const i=0===r&&e?1:r;-1===s||0===u||1===u&&s===a-1&&s===r+1?n.base=n.name=t.slice(i,a):(n.name=t.slice(i,s),n.base=t.slice(i,a),n.ext=t.slice(s,a))}return r>0?n.dir=t.slice(0,r-1):e&&(n.dir="/"),n}const kb=new TextEncoder;function Db(t){if("string"!=typeof t)throw new Sb(vb.EINVAL,"Can not encode a non-string");return kb.encode(t)}const Lb=new TextDecoder;function Fb(t){if(!(t instanceof Uint8Array))throw new Sb(vb.EINVAL,"Can not decode a non-Uint8Array");return Lb.decode(t)}function Pb(t){return JSON.parse(Fb(t),((t,e)=>""==t?e:BigInt(e)))}function $b(t){return Db(JSON.stringify(t,((t,e)=>""==t?e:e.toString())))}function Bb(t,e){if("number"==typeof t)return t;if("string"==typeof t){const e=parseInt(t,8);if(!isNaN(e))return e}if("number"==typeof e)return e;throw new Sb(vb.EINVAL,"Invalid mode: "+t?.toString())}function Vb(t){if(t instanceof Date)return t;try{return new Date(t)}catch{throw new Sb(vb.EINVAL,"Invalid time.")}}function Ub(t){if((t=t.toString()).includes("\0"))throw new Sb(vb.EINVAL,"Path can not contain null character");if(0==t.length)throw new Sb(vb.EINVAL,"Path can not be empty");return Ob(t.replaceAll(/[/\\]+/g,"/"))}function Yb(t,e="utf8",n,i=0){return"object"!=typeof t||null===t?{encoding:"string"==typeof t?t:e??null,flag:n,mode:i}:{encoding:"string"==typeof t?.encoding?t.encoding:e??null,flag:"string"==typeof t?.flag?t.flag:n,mode:Bb("mode"in t?t?.mode:null,i)}}function Gb(){return crypto.getRandomValues(new BigUint64Array(1))[0]}const Hb={uid:0,gid:0,suid:0,sgid:0,euid:0,egid:0,groups:[]};function Wb(t){return{suid:t.uid,sgid:t.gid,euid:t.uid,egid:t.gid,groups:[],...t}}const zb=0,Xb=4,jb=2,qb=1,Kb=1,Qb=2,Jb=4,Zb=0,tv=1,ev=2,nv=64,iv=128,sv=256,rv=512,av=1024,ov=65536,lv=262144,uv=131072,hv=1052672,pv=4096,cv=32768,dv=16384,fv=2048,mv=61440,gv=49152,_v=40960,Tv=32768,yv=24576,Iv=16384,Ev=8192,bv=4096,vv=2048,wv=1024,Sv=512,xv=448,Rv=256,Ov=128,Av=64,Mv=56,Cv=32,Nv=16,kv=8,Dv=7,Lv=4,Fv=2,Pv=1,$v=0,Bv=2**32-1,Vv={checkAccess:!0,updateOnRead:!0,syncImmediately:!0,unsafeBufferReplace:!1};Promise.withResolvers??(Promise.withResolvers=function(){let t,e;const n=new Promise(((n,i)=>{t=n,e=i}));return{promise:n,resolve:t,reject:e}}),Symbol.dispose??(Symbol.dispose=Symbol("Symbol.dispose")),Symbol.asyncDispose??(Symbol.asyncDispose=Symbol("Symbol.asyncDispose"));class Uv{_convert(t){return this._isBigint?BigInt(t):Number(t)}get blocks(){return this._convert(Math.ceil(Number(this.size)/512))}get atime(){return new Date(Number(this.atimeMs))}set atime(t){this.atimeMs=this._convert(t.getTime())}get mtime(){return new Date(Number(this.mtimeMs))}set mtime(t){this.mtimeMs=this._convert(t.getTime())}get ctime(){return new Date(Number(this.ctimeMs))}set ctime(t){this.ctimeMs=this._convert(t.getTime())}get birthtime(){return new Date(Number(this.birthtimeMs))}set birthtime(t){this.birthtimeMs=this._convert(t.getTime())}constructor({atimeMs:t,mtimeMs:e,ctimeMs:n,birthtimeMs:i,uid:s,gid:r,size:a,mode:o,ino:l}={}){this.dev=this._convert(0),this.ino=this._convert(0),this.rdev=this._convert(0),this.nlink=this._convert(1),this.blksize=this._convert(4096),this.uid=this._convert(0),this.gid=this._convert(0);const u=Date.now();this.atimeMs=this._convert(t??u),this.mtimeMs=this._convert(e??u),this.ctimeMs=this._convert(n??u),this.birthtimeMs=this._convert(i??u),this.uid=this._convert(s??0),this.gid=this._convert(r??0),this.size=this._convert(a??0),this.ino=this._convert(l??0),this.mode=this._convert(o??420&Tv),this.mode&mv||(this.mode=this.mode|this._convert(Tv))}isFile(){return(this.mode&mv)===Tv}isDirectory(){return(this.mode&mv)===Iv}isSymbolicLink(){return(this.mode&mv)===_v}isSocket(){return(this.mode&mv)===gv}isBlockDevice(){return(this.mode&mv)===yv}isCharacterDevice(){return(this.mode&mv)===Ev}isFIFO(){return(this.mode&mv)===bv}hasAccess(t,e){const n=e?.credentials||Hb;if(this.isSymbolicLink()||0===n.euid||0===n.egid)return!0;let i=0;return n.uid===this.uid&&(this.mode&Rv&&(i|=Xb),this.mode&Ov&&(i|=jb),this.mode&Av&&(i|=qb)),(n.gid===this.gid||n.groups.includes(Number(this.gid)))&&(this.mode&Cv&&(i|=Xb),this.mode&Nv&&(i|=jb),this.mode&kv&&(i|=qb)),this.mode&Lv&&(i|=Xb),this.mode&Fv&&(i|=jb),this.mode&Pv&&(i|=qb),(i&t)===t}chmod(t){this.mode=this._convert(this.mode&mv|t)}chown(t,e){t=Number(t),e=Number(e),!isNaN(t)&&0<=t&&t<2**32&&(this.uid=this._convert(t)),!isNaN(e)&&0<=e&&e<2**32&&(this.gid=this._convert(e))}get atimeNs(){return 1000n*BigInt(this.atimeMs)}get mtimeNs(){return 1000n*BigInt(this.mtimeMs)}get ctimeNs(){return 1000n*BigInt(this.ctimeMs)}get birthtimeNs(){return 1000n*BigInt(this.birthtimeMs)}}function Yv(t,e,n){!isNaN(e)&&0<=e&&e<2**32&&(t.uid=e),!isNaN(n)&&0<=n&&n<2**32&&(t.gid=n)}class Gv extends Uv{constructor(){super(...arguments),this._isBigint=!1}}class Hv extends Uv{constructor(){super(...arguments),this._isBigint=!0}}class Wv{constructor(){this.type=525687744115,this.bsize=4096,this.blocks=0,this.bfree=0,this.bavail=0,this.files=Bv,this.ffree=Bv}}class zv{constructor(){this.type=0x7a656e6673n,this.bsize=4096n,this.blocks=0n,this.bfree=0n,this.bavail=0n,this.files=BigInt(Bv),this.ffree=BigInt(Bv)}}const Xv=["r","r+","rs","rs+","w","wx","w+","wx+","a","ax","a+","ax+"];function jv(t){if("number"==typeof t)return function(t){switch(t){case Zb:return"r";case Zb|hv:return"rs";case ev:return"r+";case ev|hv:return"rs+";case rv|nv|tv:return"w";case rv|nv|tv|iv:return"wx";case rv|nv|ev:return"w+";case rv|nv|ev|iv:return"wx+";case av|nv|tv:return"a";case av|nv|tv|iv:return"ax";case av|nv|ev:return"a+";case av|nv|ev|iv:return"ax+";default:throw new Error("Invalid flag number: "+t)}}(t);if(!Xv.includes(t))throw new Error("Invalid flag string: "+t);return t}function qv(t){let e=0;return e<<=1,e+=+Kv(t),e<<=1,e+=+Qv(t),e<<=1,e}function Kv(t){return-1!==t.indexOf("r")||-1!==t.indexOf("+")}function Qv(t){return-1!==t.indexOf("w")||-1!==t.indexOf("a")||-1!==t.indexOf("+")}function Jv(t){return-1!==t.indexOf("w")}function Zv(t){return-1!==t.indexOf("a")}function tw(t){return-1!==t.indexOf("x")}class ew{constructor(t,e){this.fs=t,this.path=e}async[Symbol.asyncDispose](){await this.close()}[Symbol.dispose](){this.closeSync()}datasync(){return this.sync()}datasyncSync(){return this.syncSync()}}class nw extends ew{constructor(t,e,n,i,s=new Uint8Array(new ArrayBuffer(0,t.metadata().noResizableBuffers?{}:{maxByteLength:Bv}))){if(super(t,e),this.flag=n,this.stats=i,this._buffer=s,this._position=0,this.dirty=!1,this.closed=!1,this.stats.size!=s.byteLength){if(Kv(this.flag))throw new Error(`Size mismatch: buffer length ${s.byteLength}, stats size ${this.stats.size}`);this.dirty=!0}}get buffer(){return this._buffer}get position(){return Zv(this.flag)?this.stats.size:this._position}set position(t){this._position=t}async sync(){if(this.closed)throw Sb.With("EBADF",this.path,"File.sync");this.dirty&&(await this.fs.sync(this.path,this._buffer,this.stats),this.dirty=!1)}syncSync(){if(this.closed)throw Sb.With("EBADF",this.path,"File.sync");this.dirty&&(this.fs.syncSync(this.path,this._buffer,this.stats),this.dirty=!1)}async close(){if(this.closed)throw Sb.With("EBADF",this.path,"File.close");await this.sync(),this.dispose()}closeSync(){if(this.closed)throw Sb.With("EBADF",this.path,"File.close");this.syncSync(),this.dispose()}dispose(t){if(this.closed)throw Sb.With("EBADF",this.path,"File.dispose");if(this.dirty&&!t)throw Sb.With("EBUSY",this.path,"File.dispose");delete this._buffer,delete this.stats,this.closed=!0}stat(){if(this.closed)throw Sb.With("EBADF",this.path,"File.stat");return Promise.resolve(new Gv(this.stats))}statSync(){if(this.closed)throw Sb.With("EBADF",this.path,"File.stat");return new Gv(this.stats)}_truncate(t){if(this.closed)throw Sb.With("EBADF",this.path,"File.truncate");if(this.dirty=!0,!Qv(this.flag))throw new Sb(vb.EPERM,"File not opened with a writeable mode.");if(this.stats.mtimeMs=Date.now(),t>this._buffer.length){const e=new Uint8Array(t-this._buffer.length);this._write(e,0,e.length,this._buffer.length)}else this.stats.size=t,this._buffer=t?this._buffer.slice(0,t):new Uint8Array}async truncate(t){this._truncate(t),Vv.syncImmediately&&await this.sync()}truncateSync(t){this._truncate(t),Vv.syncImmediately&&this.syncSync()}_write(t,e=0,n=this.stats.size,i=this.position){if(this.closed)throw Sb.With("EBADF",this.path,"File.write");if(!Qv(this.flag))throw new Sb(vb.EPERM,"File not opened with a writeable mode.");this.dirty=!0;const s=i+n,r=t.slice(e,e+n);if(s>this.stats.size&&(this.stats.size=s,s>this._buffer.byteLength))if(this._buffer.buffer.resizable&&this._buffer.buffer.maxByteLength<=s)this._buffer.buffer.resize(s);else if(Vv.unsafeBufferReplace)this._buffer=r;else{const t=new Uint8Array(new ArrayBuffer(s,this.fs.metadata().noResizableBuffers?{}:{maxByteLength:Bv}));t.set(this._buffer),this._buffer=t}return this._buffer.set(r,i),this.stats.mtimeMs=Date.now(),this.position=i+r.byteLength,r.byteLength}async write(t,e,n,i){const s=this._write(t,e,n,i);return Vv.syncImmediately&&await this.sync(),s}writeSync(t,e=0,n=this.stats.size,i=this.position){const s=this._write(t,e,n,i);return Vv.syncImmediately&&this.syncSync(),s}_read(t,e=0,n=this.stats.size,i){if(this.closed)throw Sb.With("EBADF",this.path,"File.read");if(!Kv(this.flag))throw new Sb(vb.EPERM,"File not opened with a readable mode.");Vv.updateOnRead&&(this.dirty=!0),this.stats.atimeMs=Date.now(),i??(i=this.position);let s=i+n;s>this.stats.size&&(s=i+Math.max(this.stats.size-i,0)),this._position=s;const r=s-i;return 0==r||new Uint8Array(t.buffer,e,n).set(this._buffer.slice(i,s)),r}async read(t,e,n,i){const s=this._read(t,e,n,i);return Vv.syncImmediately&&await this.sync(),{bytesRead:s,buffer:t}}readSync(t,e,n,i){const s=this._read(t,e,n,i);return Vv.syncImmediately&&this.syncSync(),s}async chmod(t){if(this.closed)throw Sb.With("EBADF",this.path,"File.chmod");this.dirty=!0,this.stats.mode=this.stats.mode&(t>mv?~mv:mv)|t,(Vv.syncImmediately||t>mv)&&await this.sync()}chmodSync(t){if(this.closed)throw Sb.With("EBADF",this.path,"File.chmod");this.dirty=!0,this.stats.mode=this.stats.mode&(t>mv?~mv:mv)|t,(Vv.syncImmediately||t>mv)&&this.syncSync()}async chown(t,e){if(this.closed)throw Sb.With("EBADF",this.path,"File.chown");this.dirty=!0,Yv(this.stats,t,e),Vv.syncImmediately&&await this.sync()}chownSync(t,e){if(this.closed)throw Sb.With("EBADF",this.path,"File.chown");this.dirty=!0,Yv(this.stats,t,e),Vv.syncImmediately&&this.syncSync()}async utimes(t,e){if(this.closed)throw Sb.With("EBADF",this.path,"File.utimes");this.dirty=!0,this.stats.atime=t,this.stats.mtime=e,Vv.syncImmediately&&await this.sync()}utimesSync(t,e){if(this.closed)throw Sb.With("EBADF",this.path,"File.utimes");this.dirty=!0,this.stats.atime=t,this.stats.mtime=e,Vv.syncImmediately&&this.syncSync()}}class iw{metadata(){return{name:this.constructor.name.toLowerCase(),readonly:!1,totalSpace:0,freeSpace:0,noResizableBuffers:!1,noAsyncCache:this._disableSync??!1,type:525687744115}}constructor(...t){}async ready(){}async exists(t){try{return await this.stat(t),!0}catch(t){return"ENOENT"!=t.code}}existsSync(t){try{return this.statSync(t),!0}catch(t){return"ENOENT"!=t.code}}}var sw=__webpack_require__(228);Symbol.toStringTag,Symbol.iterator;const rw=Intl.NumberFormat("en",{notation:"compact"});rw.format.bind(rw);function aw(t){return t.at(0).toUpperCase()+t.slice(1)}const ow=["int8","uint8","int16","uint16","int32","uint32","int64","uint64","float32","float64"],lw=[...ow,...ow.map((t=>aw(t))),"char"],uw=/^(u?int|float)(8|16|32|64)$/i;function hw(t){return"char"==t?"uint8":t.toLowerCase()}function pw(t){return uw.test(t.toString())}function cw(t){return"char"==t||uw.test(t.toString().toLowerCase())}Symbol.struct_init||=Symbol("struct_init"),Symbol.struct_metadata||=Symbol("struct_metadata");Symbol.struct_init,Symbol.struct_metadata;function dw(t){const e=Symbol.metadata||Object.getOwnPropertySymbols(t).find((t=>"Symbol.metadata"==t.description));var n;if(n=t,Symbol?.metadata&&(Symbol.metadata in n||Object.defineProperty(n,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:Object.create(null)})),!e)throw new ReferenceError("Could not get a reference to Symbol.metadata");return e}function fw(t){return"function"==typeof t&&dw(t)in t&&function(t){return null!=t&&"object"==typeof t&&Symbol.struct_metadata in t}(t[dw(t)])}function mw(t){return null!=t&&"object"==typeof t&&fw(t.constructor)}function gw(t){if(!mw(t))throw new TypeError(("function"==typeof t?t.name:"object"==typeof t&&t?t.constructor.name:t)+" is not a struct instance")}function _w(t){if(!function(t){return mw(t)||fw(t)}(t))throw new TypeError(("function"==typeof t?t.name:"object"==typeof t&&t?t.constructor.name:t)+" is not a struct")}function Tw(t){if("string"==typeof t)return function(t){if(!cw(t))throw new TypeError("Not a valid primitive type: "+t)}(t),+hw(t).match(uw)[2]/8;_w(t);const e=fw(t)?t:t.constructor;return e[dw(e)][Symbol.struct_metadata].size}function yw(t={}){return function(e,n){n.metadata??={},n.metadata[Symbol.struct_init]||=[];let i=0;const s=new Map;for(const e of n.metadata[Symbol.struct_init]){const{name:n,type:o,length:l}=e;if(!cw(o)&&!fw(o))throw new TypeError("Not a valid type: "+o);s.set(n,{offset:i,type:cw(o)?hw(o):o,length:l}),i+=Tw(o)*(l||1),r=i,a=t.align||1,i=Math.ceil(r/a)*a}var r,a;return n.metadata[Symbol.struct_metadata]={options:t,members:s,size:i},e}}function Iw(t,e){return function(n,i){let s=i.name;if("symbol"==typeof s&&(console.warn("Symbol used for struct member name will be coerced to string: "+s.toString()),s=s.toString()),!s)throw new ReferenceError("Invalid name for struct member");return i.metadata??={},i.metadata[Symbol.struct_init]||=[],i.metadata[Symbol.struct_init].push({name:s,type:t,length:e}),n}}function Ew(t){gw(t);const{options:e,members:n}=t.constructor[dw(t.constructor)][Symbol.struct_metadata],i=new Uint8Array(Tw(t)),s=new DataView(i.buffer);for(const[r,{type:a,length:o,offset:l}]of n)for(let n=0;n<(o||1);n++){const u=l+Tw(a)*n;let h=o>0?t[r][n]:t[r];if("string"==typeof h&&(h=h.charCodeAt(0)),!pw(a)){i.set(h?Ew(h):new Uint8Array(Tw(a)),u);continue}const p="set"+aw(a);"setInt64"!=p?"setUint64"!=p?s[p](u,Number(h),!e.bigEndian):s.setBigUint64(u,BigInt(h),!e.bigEndian):s.setBigInt64(u,BigInt(h),!e.bigEndian)}return i}function bw(t,e){gw(t);const{options:n,members:i}=t.constructor[dw(t.constructor)][Symbol.struct_metadata],s=e instanceof Uint8Array?e:new Uint8Array("buffer"in e?e.buffer:e),r=new DataView(s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength));for(const[e,{type:a,offset:o,length:l}]of i)for(let i=0;i<(l||1);i++){let u=l>0?t[e]:t;const h=l>0?i:e,p=o+Tw(a)*i;if("string"==typeof t[e]){t[e]=t[e].slice(0,i)+String.fromCharCode(r.getUint8(p))+t[e].slice(i+1);continue}if(!pw(a)){if(null===u[h]||void 0===u[h])continue;bw(u[h],new Uint8Array(s.slice(p,p+Tw(a))));continue}l>0&&(u||=[]);const c="get"+aw(a);"getInt64"!=c?u[h]="getUint64"!=c?r[c](p,!n.bigEndian):r.getBigUint64(p,!n.bigEndian):u[h]=r.getBigInt64(p,!n.bigEndian)}}Symbol.metadata??=Symbol.for("Symbol.metadata");const vw=Object.fromEntries(lw.map((t=>{return[t,(e=t,function(t,n){return"number"==typeof t?Iw(e,t):Iw(e)(t,n)})];var e})));var ww=function(t,e,n,i,s,r){function a(t){if(void 0!==t&&"function"!=typeof t)throw new TypeError("Function expected");return t}for(var o,l=i.kind,u="getter"===l?"get":"setter"===l?"set":"value",h=!e&&t?i.static?t:t.prototype:null,p=e||(h?Object.getOwnPropertyDescriptor(h,i.name):{}),c=!1,d=n.length-1;d>=0;d--){var f={};for(var m in i)f[m]="access"===m?{}:i[m];for(var m in i.access)f.access[m]=i.access[m];f.addInitializer=function(t){if(c)throw new TypeError("Cannot add initializers after decoration has completed");r.push(a(t||null))};var g=(0,n[d])("accessor"===l?{get:p.get,set:p.set}:p[u],f);if("accessor"===l){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(o=a(g.get))&&(p.get=o),(o=a(g.set))&&(p.set=o),(o=a(g.init))&&s.unshift(o)}else(o=a(g))&&("field"===l?s.unshift(o):p[u]=o)}h&&Object.defineProperty(h,i.name,p),c=!0},Sw=function(t,e,n){for(var i=arguments.length>2,s=0;s<e.length;s++)n=i?e[s].call(t,n):e[s].call(t);return i?n:void 0},xw=function(t,e,n){return"symbol"==typeof e&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:n?"".concat(n," ",e):e})};let Rw=(()=>{var t,e,n,i,s,r,a,o,l,u,h;let p,c,d,f,m,g,_,T,y,I,E,b,v,w=[yw()],S=[],x=[],R=[],O=[],A=[],M=[],C=[],N=[],k=[],D=[],L=[],F=[],P=[],$=[],B=[],V=[],U=[],Y=[],G=[],H=[],W=[],z=[],X=[];var j=c=class{constructor(t){if(this.data=Sw(this,x,void 0),this.size=(Sw(this,R),Sw(this,O,void 0)),this.mode=(Sw(this,A),Sw(this,M,void 0)),this.nlink=(Sw(this,C),Sw(this,N,void 0)),this.uid=(Sw(this,k),Sw(this,D,void 0)),this.gid=(Sw(this,L),Sw(this,F,void 0)),this.atimeMs=(Sw(this,P),Sw(this,$,void 0)),this.birthtimeMs=(Sw(this,B),Sw(this,V,void 0)),this.mtimeMs=(Sw(this,U),Sw(this,Y,void 0)),this.ctimeMs=(Sw(this,G),Sw(this,H,void 0)),this.ino=(Sw(this,W),Sw(this,z,void 0)),Sw(this,X),t){const e=Tw(j),n=e-Tw("uint64");if(t.byteLength<n)throw new RangeError(`Can not create an inode from a buffer less than ${n} bytes`);if(t.byteLength<e){const n=new Uint8Array(e);n.set(new Uint8Array(ArrayBuffer.isView(t)?t.buffer:t));const i=crypto.getRandomValues(new Uint32Array(2));n.set(i,e-2),t=n}return void bw(this,t)}this.ino=Gb(),this.data=Gb(),this.nlink=1,this.size=4096;const e=Date.now();this.atimeMs=e,this.mtimeMs=e,this.ctimeMs=e,this.birthtimeMs=e}toStats(){return new Gv(this)}update(t){let e=!1;return this.size!==t.size&&(this.size=t.size,e=!0),this.mode!==t.mode&&(this.mode=t.mode,e=!0),this.nlink!==t.nlink&&(this.nlink=t.nlink,e=!0),this.uid!==t.uid&&(this.uid=t.uid,e=!0),this.gid!==t.gid&&(this.gid=t.gid,e=!0),this.atimeMs!==t.atimeMs&&(this.atimeMs=t.atimeMs,e=!0),this.mtimeMs!==t.mtimeMs&&(this.mtimeMs=t.mtimeMs,e=!0),this.ctimeMs!==t.ctimeMs&&(this.ctimeMs=t.ctimeMs,e=!0),e}};return xw(c,"Inode"),(()=>{const q="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;d=[(t=vw).uint64.bind(t)],f=[(e=vw).uint32.bind(e)],m=[(n=vw).uint16.bind(n)],g=[(i=vw).uint32.bind(i)],_=[(s=vw).uint32.bind(s)],T=[(r=vw).uint32.bind(r)],y=[(a=vw).float64.bind(a)],I=[(o=vw).float64.bind(o)],E=[(l=vw).float64.bind(l)],b=[(u=vw).float64.bind(u)],v=[(h=vw).uint64.bind(h)],ww(null,null,d,{kind:"field",name:"data",static:!1,private:!1,access:{has:t=>"data"in t,get:t=>t.data,set:(t,e)=>{t.data=e}},metadata:q},x,R),ww(null,null,f,{kind:"field",name:"size",static:!1,private:!1,access:{has:t=>"size"in t,get:t=>t.size,set:(t,e)=>{t.size=e}},metadata:q},O,A),ww(null,null,m,{kind:"field",name:"mode",static:!1,private:!1,access:{has:t=>"mode"in t,get:t=>t.mode,set:(t,e)=>{t.mode=e}},metadata:q},M,C),ww(null,null,g,{kind:"field",name:"nlink",static:!1,private:!1,access:{has:t=>"nlink"in t,get:t=>t.nlink,set:(t,e)=>{t.nlink=e}},metadata:q},N,k),ww(null,null,_,{kind:"field",name:"uid",static:!1,private:!1,access:{has:t=>"uid"in t,get:t=>t.uid,set:(t,e)=>{t.uid=e}},metadata:q},D,L),ww(null,null,T,{kind:"field",name:"gid",static:!1,private:!1,access:{has:t=>"gid"in t,get:t=>t.gid,set:(t,e)=>{t.gid=e}},metadata:q},F,P),ww(null,null,y,{kind:"field",name:"atimeMs",static:!1,private:!1,access:{has:t=>"atimeMs"in t,get:t=>t.atimeMs,set:(t,e)=>{t.atimeMs=e}},metadata:q},$,B),ww(null,null,I,{kind:"field",name:"birthtimeMs",static:!1,private:!1,access:{has:t=>"birthtimeMs"in t,get:t=>t.birthtimeMs,set:(t,e)=>{t.birthtimeMs=e}},metadata:q},V,U),ww(null,null,E,{kind:"field",name:"mtimeMs",static:!1,private:!1,access:{has:t=>"mtimeMs"in t,get:t=>t.mtimeMs,set:(t,e)=>{t.mtimeMs=e}},metadata:q},Y,G),ww(null,null,b,{kind:"field",name:"ctimeMs",static:!1,private:!1,access:{has:t=>"ctimeMs"in t,get:t=>t.ctimeMs,set:(t,e)=>{t.ctimeMs=e}},metadata:q},H,W),ww(null,null,v,{kind:"field",name:"ino",static:!1,private:!1,access:{has:t=>"ino"in t,get:t=>t.ino,set:(t,e)=>{t.ino=e}},metadata:q},z,X),ww(null,p={value:c},w,{kind:"class",name:c.name,metadata:q},null,S),j=c=p.value,q&&Object.defineProperty(c,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:q}),Sw(c,S)})(),j=c})();var Ow=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},Aw=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});class Mw extends iw{async ready(){this._initialized||(await this.checkRoot(),this._initialized=!0)}constructor(t){super(),this.store=t,this._initialized=!1}metadata(){return{...super.metadata(),name:this.store.name}}async empty(){await this.store.clear(),await this.checkRoot()}emptySync(){this.store.clearSync(),this.checkRootSync()}async rename(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Ow(n,this.store.transaction(),!0),s=Nb(t),r=Nb(e),a=await this.findInode(i,s.dir,"rename"),o=Pb(await this.get(i,a.data,s.dir,"rename"));if(!o[s.base])throw Sb.With("ENOENT",t,"rename");const l=o[s.base];if(delete o[s.base],0===(r.dir+"/").indexOf(t+"/"))throw new Sb(vb.EBUSY,s.dir);const u=r.dir==s.dir,h=u?a:await this.findInode(i,r.dir,"rename"),p=u?o:Pb(await this.get(i,h.data,r.dir,"rename"));if(p[r.base]){const t=new Rw(await this.get(i,p[r.base],e,"rename"));if(!t.toStats().isFile())throw Sb.With("EPERM",e,"rename");await i.remove(t.data),await i.remove(p[r.base])}p[r.base]=l,await i.set(a.data,$b(o)),await i.set(h.data,$b(p)),await i.commit()}catch(t){n.error=t,n.hasError=!0}finally{const t=Aw(n);t&&await t}}renameSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Ow(n,this.store.transaction(),!1),s=Nb(t),r=Nb(e),a=this.findInodeSync(i,s.dir,"rename"),o=Pb(this.getSync(i,a.data,s.dir,"rename"));if(!o[s.base])throw Sb.With("ENOENT",t,"rename");const l=o[s.base];if(delete o[s.base],0==(r.dir+"/").indexOf(t+"/"))throw new Sb(vb.EBUSY,s.dir);const u=r.dir===s.dir,h=u?a:this.findInodeSync(i,r.dir,"rename"),p=u?o:Pb(this.getSync(i,h.data,r.dir,"rename"));if(p[r.base]){const t=new Rw(this.getSync(i,p[r.base],e,"rename"));if(!t.toStats().isFile())throw Sb.With("EPERM",e,"rename");i.removeSync(t.data),i.removeSync(p[r.base])}p[r.base]=l,i.setSync(a.data,$b(o)),i.setSync(h.data,$b(p)),i.commitSync()}catch(t){n.error=t,n.hasError=!0}finally{Aw(n)}}async stat(t){const e={stack:[],error:void 0,hasError:!1};try{const n=Ow(e,this.store.transaction(),!0);return(await this.findInode(n,t,"stat")).toStats()}catch(t){e.error=t,e.hasError=!0}finally{const t=Aw(e);t&&await t}}statSync(t){const e={stack:[],error:void 0,hasError:!1};try{const n=Ow(e,this.store.transaction(),!1);return this.findInodeSync(n,t,"stat").toStats()}catch(t){e.error=t,e.hasError=!0}finally{Aw(e)}}async createFile(t,e,n){const i=await this.commitNew(t,Tv,n,new Uint8Array,"createFile");return new nw(this,t,e,i.toStats(),new Uint8Array)}createFileSync(t,e,n){const i=this.commitNewSync(t,Tv,n,new Uint8Array,"createFile");return new nw(this,t,e,i.toStats(),new Uint8Array)}async openFile(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Ow(n,this.store.transaction(),!0),s=await this.findInode(i,t,"openFile"),r=await this.get(i,s.data,t,"openFile");return new nw(this,t,e,s.toStats(),r)}catch(t){n.error=t,n.hasError=!0}finally{const t=Aw(n);t&&await t}}openFileSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Ow(n,this.store.transaction(),!1),s=this.findInodeSync(i,t,"openFile"),r=this.getSync(i,s.data,t,"openFile");return new nw(this,t,e,s.toStats(),r)}catch(t){n.error=t,n.hasError=!0}finally{Aw(n)}}async unlink(t){return this.remove(t,!1,"unlink")}unlinkSync(t){this.removeSync(t,!1,"unlink")}async rmdir(t){if((await this.readdir(t)).length)throw Sb.With("ENOTEMPTY",t,"rmdir");await this.remove(t,!0,"rmdir")}rmdirSync(t){if(this.readdirSync(t).length)throw Sb.With("ENOTEMPTY",t,"rmdir");this.removeSync(t,!0,"rmdir")}async mkdir(t,e){await this.commitNew(t,Iv,e,Db("{}"),"mkdir")}mkdirSync(t,e){this.commitNewSync(t,Iv,e,Db("{}"),"mkdir")}async readdir(t){const e={stack:[],error:void 0,hasError:!1};try{const n=Ow(e,this.store.transaction(),!0),i=await this.findInode(n,t,"readdir");return Object.keys(Pb(await this.get(n,i.data,t,"readdir")))}catch(t){e.error=t,e.hasError=!0}finally{const t=Aw(e);t&&await t}}readdirSync(t){const e={stack:[],error:void 0,hasError:!1};try{const n=Ow(e,this.store.transaction(),!1),i=this.findInodeSync(n,t,"readdir");return Object.keys(Pb(this.getSync(n,i.data,t,"readdir")))}catch(t){e.error=t,e.hasError=!0}finally{Aw(e)}}async sync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Ow(i,this.store.transaction(),!0),r=await this._findInode(s,t,"sync"),a=new Rw(await this.get(s,r,t,"sync")),o=a.update(n);await s.set(a.data,e),o&&await s.set(r,Ew(a)),await s.commit()}catch(t){i.error=t,i.hasError=!0}finally{const t=Aw(i);t&&await t}}syncSync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Ow(i,this.store.transaction(),!1),r=this._findInodeSync(s,t,"sync"),a=new Rw(this.getSync(s,r,t,"sync")),o=a.update(n);s.setSync(a.data,e),o&&s.setSync(r,Ew(a)),s.commitSync()}catch(t){i.error=t,i.hasError=!0}finally{Aw(i)}}async link(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Ow(n,this.store.transaction(),!0),s=Mb(e),r=await this.findInode(i,s,"link"),a=Pb(await this.get(i,r.data,s,"link")),o=await this._findInode(i,t,"link"),l=new Rw(await this.get(i,o,t,"link"));l.nlink++,a[Cb(e)]=o,i.setSync(o,Ew(l)),i.setSync(r.data,$b(a)),i.commitSync()}catch(t){n.error=t,n.hasError=!0}finally{const t=Aw(n);t&&await t}}linkSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Ow(n,this.store.transaction(),!1),s=Mb(e),r=this.findInodeSync(i,s,"link"),a=Pb(this.getSync(i,r.data,s,"link")),o=this._findInodeSync(i,t,"link"),l=new Rw(this.getSync(i,o,t,"link"));l.nlink++,a[Cb(e)]=o,i.setSync(o,Ew(l)),i.setSync(r.data,$b(a)),i.commitSync()}catch(t){n.error=t,n.hasError=!0}finally{Aw(n)}}async checkRoot(){const t={stack:[],error:void 0,hasError:!1};try{const e=Ow(t,this.store.transaction(),!0);if(await e.get(0n))return;const n=new Rw;n.ino=0n,n.mode=511|Iv,await e.set(n.data,Db("{}")),await e.set(0n,Ew(n)),await e.commit()}catch(e){t.error=e,t.hasError=!0}finally{const e=Aw(t);e&&await e}}checkRootSync(){const t={stack:[],error:void 0,hasError:!1};try{const e=Ow(t,this.store.transaction(),!1);if(e.getSync(0n))return;const n=new Rw;n.ino=0n,n.mode=511|Iv,e.setSync(n.data,Db("{}")),e.setSync(0n,Ew(n)),e.commitSync()}catch(e){t.error=e,t.hasError=!0}finally{Aw(t)}}async _findInode(t,e,n,i=new Set){if(i.has(e))throw new Sb(vb.EIO,"Infinite loop detected while finding inode",e);if(i.add(e),"/"==e)return 0n;const{dir:s,base:r}=Nb(e),a="/"==s?new Rw(await this.get(t,0n,s,n)):await this.findInode(t,s,n,i),o=Pb(await this.get(t,a.data,s,n));if(!(r in o))throw Sb.With("ENOENT",Ob(s,r),n);return o[r]}_findInodeSync(t,e,n,i=new Set){if(i.has(e))throw new Sb(vb.EIO,"Infinite loop detected while finding inode",e);if(i.add(e),"/"==e)return 0n;const{dir:s,base:r}=Nb(e),a="/"==s?new Rw(this.getSync(t,0n,s,n)):this.findInodeSync(t,s,n,i),o=Pb(this.getSync(t,a.data,s,n));if(!(r in o))throw Sb.With("ENOENT",Ob(s,r),n);return o[r]}async findInode(t,e,n,i=new Set){const s=await this._findInode(t,e,n,i);return new Rw(await this.get(t,s,e,n))}findInodeSync(t,e,n,i=new Set){const s=this._findInodeSync(t,e,n,i);return new Rw(this.getSync(t,s,e,n))}async get(t,e,n,i){const s=await t.get(e);if(!s)throw Sb.With("ENOENT",n,i);return s}getSync(t,e,n,i){const s=t.getSync(e);if(!s)throw Sb.With("ENOENT",n,i);return s}async allocNew(t,e,n){for(let e=0;e<5;e++){const e=Gb();if(!await t.get(e))return e}throw new Sb(vb.ENOSPC,"No IDs available",e,n)}allocNewSync(t,e,n){for(let e=0;e<5;e++){const e=Gb();if(!t.getSync(e))return e}throw new Sb(vb.ENOSPC,"No IDs available",e,n)}async commitNew(t,e,n,i,s){const r={stack:[],error:void 0,hasError:!1};try{if("/"==t)throw Sb.With("EEXIST",t,s);const a=Ow(r,this.store.transaction(),!0),{dir:o,base:l}=Nb(t),u=await this.findInode(a,o,s),h=Pb(await this.get(a,u.data,o,s));if(h[l])throw Sb.With("EEXIST",t,s);const p=new Rw;return p.ino=await this.allocNew(a,t,s),p.data=await this.allocNew(a,t,s),p.mode=n|e,p.uid=u.mode&vv?u.uid:Hb.uid,p.gid=u.mode&wv?u.gid:Hb.gid,p.size=i.length,await a.set(p.ino,Ew(p)),await a.set(p.data,i),h[l]=p.ino,await a.set(u.data,$b(h)),await a.commit(),p}catch(t){r.error=t,r.hasError=!0}finally{const t=Aw(r);t&&await t}}commitNewSync(t,e,n,i,s){const r={stack:[],error:void 0,hasError:!1};try{if("/"==t)throw Sb.With("EEXIST",t,s);const a=Ow(r,this.store.transaction(),!1),{dir:o,base:l}=Nb(t),u=this.findInodeSync(a,o,s),h=Pb(this.getSync(a,u.data,o,s));if(h[l])throw Sb.With("EEXIST",t,s);const p=new Rw;return p.ino=this.allocNewSync(a,t,s),p.data=this.allocNewSync(a,t,s),p.size=i.length,p.mode=n|e,p.uid=u.mode&vv?u.uid:Hb.uid,p.gid=u.mode&wv?u.gid:Hb.gid,a.setSync(p.ino,Ew(p)),a.setSync(p.data,i),h[l]=p.ino,a.setSync(u.data,$b(h)),a.commitSync(),p}catch(t){r.error=t,r.hasError=!0}finally{Aw(r)}}async remove(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Ow(i,this.store.transaction(),!0),{dir:r,base:a}=Nb(t),o=await this.findInode(s,r,n),l=Pb(await this.get(s,o.data,r,n));if(!l[a])throw Sb.With("ENOENT",t,"remove");const u=l[a],h=new Rw(await this.get(s,u,t,n));if(delete l[a],!e&&h.toStats().isDirectory())throw Sb.With("EISDIR",t,"remove");await s.set(o.data,$b(l)),--h.nlink<1&&(await s.remove(h.data),await s.remove(u)),await s.commit()}catch(t){i.error=t,i.hasError=!0}finally{const t=Aw(i);t&&await t}}removeSync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Ow(i,this.store.transaction(),!1),{dir:r,base:a}=Nb(t),o=this.findInodeSync(s,r,n),l=Pb(this.getSync(s,o.data,r,n)),u=l[a];if(!u)throw Sb.With("ENOENT",t,"remove");const h=new Rw(this.getSync(s,u,t,n));if(delete l[a],!e&&h.toStats().isDirectory())throw Sb.With("EISDIR",t,"remove");s.setSync(o.data,$b(l)),--h.nlink<1&&(s.removeSync(h.data),s.removeSync(u)),s.commitSync()}catch(t){i.error=t,i.hasError=!0}finally{Aw(i)}}}class Cw{constructor(t){this.store=t,this.done=!1}async[Symbol.asyncDispose](){this.done||await this.abort()}[Symbol.dispose](){this.done||this.abortSync()}}class Nw extends Cw{async keys(){return this.keysSync()}async get(t){return this.getSync(t)}async set(t,e){return this.setSync(t,e)}async remove(t){return this.removeSync(t)}async commit(){return this.commitSync()}async abort(){return this.abortSync()}}class kw extends Nw{constructor(){super(...arguments),this.originalData=new Map,this.modifiedKeys=new Set}keysSync(){return this.store.keys()}getSync(t){const e=this.store.get(t);return this.stashOldValue(t,e),e}setSync(t,e){return this.markModified(t),this.store.set(t,e)}removeSync(t){this.markModified(t),this.store.delete(t)}commitSync(){this.done=!0}abortSync(){if(this.done){for(const t of this.modifiedKeys){const e=this.originalData.get(t);e?this.store.set(t,e):this.store.delete(t)}this.done=!0}}stashOldValue(t,e){this.originalData.has(t)||this.originalData.set(t,e)}markModified(t){this.modifiedKeys.add(t),this.originalData.has(t)||this.originalData.set(t,this.store.get(t))}}class Dw extends Map{constructor(t="tmp"){super(),this.name=t}async sync(){}clearSync(){this.clear()}transaction(){return new kw(this)}}const Lw={name:"InMemory",isAvailable:()=>!0,options:{name:{type:"string",required:!1}},create({name:t}){const e=new Mw(new Dw(t));return e.checkRootSync(),e}};"function"==typeof SuppressedError&&SuppressedError;class Fw{constructor(){this.isEnabled=!1,this.sync=new Map,this.async=new Map}has(t){return this.isEnabled&&this.sync.has(t)}get(t){if(this.isEnabled)return this.sync.get(t)}set(t,e){this.isEnabled&&(this.sync.set(t,e),this.async.set(t,Promise.resolve(e)))}hasAsync(t){return this.isEnabled&&this.async.has(t)}getAsync(t){if(this.isEnabled)return this.async.get(t)}setAsync(t,e){this.isEnabled&&(this.async.set(t,e),e.then((e=>this.sync.set(t,e))))}clear(){this.isEnabled&&(this.sync.clear(),this.async.clear())}}const Pw=new Fw,$w=new Fw;var Bw=__webpack_require__(8287);function Vw(t,e){return Object.fromEntries(Object.entries(t).map((([t,n])=>[t,"function"==typeof n?n.bind(e):n])))}const Uw=new Map;let Yw=100;function Gw(t){const e=Yw++;return Uw.set(e,t),e}function Hw(t){if(!Uw.has(t))throw new Sb(vb.EBADF);return Uw.get(t)}const Ww=new Map;function zw(t,e){if("/"!==t[0]&&(t="/"+t),t=Ob(t),Ww.has(t))throw new Sb(vb.EINVAL,"Mount point "+t+" is already in use.");Ww.set(t,e),$w.clear()}function Xw(t){if("/"!==t[0]&&(t="/"+t),t=Ob(t),!Ww.has(t))throw new Sb(vb.EINVAL,"Mount point "+t+" is already unmounted.");Ww.delete(t),$w.clear()}function jw(t,e){const n=e?.root||"/";t=Ub(Ab(n,t));const i=[...Ww].sort(((t,e)=>t[0].length>e[0].length?-1:1));for(const[e,s]of i)if(e.length<=t.length&&t.startsWith(e))return""===(t=t.slice(e.length>1?e.length:0))&&(t=n),{fs:s,path:t,mountPoint:e,root:n};throw new Sb(vb.EIO,"No file system")}async function qw(){await Promise.all([...Ww.values()].map((t=>t.ready())))}function Kw(t,e){for(const[n,i]of Object.entries(e))t=t?.replaceAll(n,i);return t}function Qw(t,e){"string"==typeof t.stack&&(t.stack=Kw(t.stack,e));try{t.message=Kw(t.message,e)}catch{}return t.path&&(t.path=Kw(t.path,e)),t}function Jw(t){"/"in t&&Xw("/");for(const[e,n]of Object.entries(t))zw(e,n)}function Zw(t,e){const n=t.metadata(),i=n.blockSize||4096;return{type:(e?BigInt:Number)(n.type),bsize:(e?BigInt:Number)(i),ffree:(e?BigInt:Number)(n.freeNodes||Bv),files:(e?BigInt:Number)(n.totalNodes||Bv),bavail:(e?BigInt:Number)(n.freeSpace/i),bfree:(e?BigInt:Number)(n.freeSpace/i),blocks:(e?BigInt:Number)(n.totalSpace/i)}}function tS(t,e){const n=this?.credentials;if(n?.uid&&n?.gid&&n?.euid&&n?.egid)throw new Sb(vb.EPERM,"Can not chroot() as non-root user");return e&&this?(this.root+=t,this):function(t,e=structuredClone(Hb)){const n={root:t,credentials:Wb(e)},i=Vw(st,n),s=Vw(it,n);return{...n,...i,promises:s}}(Ab(this?.root||"/",t),n)}zw("/",Lw.create({name:"root"}));class eS extends sw{off(t,e,n,i){return super.off(t,e,n,i)}removeListener(t,e,n,i){return super.removeListener(t,e,n,i)}constructor(t){super(),this.path=t}setMaxListeners(){throw Sb.With("ENOSYS",this.path,"Watcher.setMaxListeners")}getMaxListeners(){throw Sb.With("ENOSYS",this.path,"Watcher.getMaxListeners")}prependListener(){throw Sb.With("ENOSYS",this.path,"Watcher.prependListener")}prependOnceListener(){throw Sb.With("ENOSYS",this.path,"Watcher.prependOnceListener")}rawListeners(){throw Sb.With("ENOSYS",this.path,"Watcher.rawListeners")}ref(){return this}unref(){return this}}class nS extends eS{constructor(t,e){super(t),this.options=e,function(t,e){const n=Ub(t);sS.has(n)||sS.set(n,new Set);sS.get(n).add(e)}(t.toString(),this)}close(){super.emit("close"),function(t,e){const n=Ub(t);sS.has(n)&&(sS.get(n).delete(e),0===sS.get(n).size&&sS.delete(n))}(this.path.toString(),this)}[Symbol.dispose](){this.close()}}class iS extends eS{constructor(t,e){super(t),this.options=e,this.start()}onInterval(){try{const n=hS(this.path);t=this.previous,e=n,(t.size!=e.size||+t.atime!=+e.atime||+t.mtime!=+e.mtime||+t.ctime!=+e.ctime||t.mode!=e.mode)&&(this.emit("change",n,this.previous),this.previous=n)}catch(t){this.emit("error",t)}var t,e}start(){const t=this.options.interval||5e3;try{this.previous=hS(this.path)}catch(t){return void this.emit("error",t)}this.intervalId=setInterval(this.onInterval.bind(this),t),this.options.persistent||"object"!=typeof this.intervalId||this.intervalId.unref()}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0),this.removeAllListeners()}}const sS=new Map;function rS(t,e){if(e=Ub(e),sS.has(e))for(const n of sS.get(e))n.emit("change",t,Cb(e));let n,i=e;for(;i!==n;)if(n=i,i=Mb(i),sS.has(i))for(const n of sS.get(i))n.emit("change",t,e.slice(i.length+("/"==i?0:1)))}var aS=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},oS=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});function lS(t,e){t=Ub(t),e=Ub(e);const n=jw(t,this),i=jw(e,this);if(Vv.checkAccess&&!hS.call(this,Mb(t)).hasAccess(jb,this))throw Sb.With("EACCES",t,"rename");try{if(n===i)return n.fs.renameSync(n.path,i.path),rS("rename",t.toString()),void rS("change",e.toString());yS.call(this,e,TS(t)),dS.call(this,t),rS("rename",t.toString())}catch(s){throw Qw(s,{[n.path]:t,[i.path]:e})}}function uS(t){t=Ub(t);try{const{fs:e,path:n}=jw(GS.call(this,t),this);return e.existsSync(n)}catch(t){if(t.errno==vb.ENOENT)return!1;throw t}}function hS(t,e){t=Ub(t);const{fs:n,path:i}=jw(GS.call(this,t),this);try{const t=n.statSync(i);if(Vv.checkAccess&&!t.hasAccess(Xb,this))throw Sb.With("EACCES",i,"stat");return e?.bigint?new Hv(t):t}catch(e){throw Qw(e,{[i]:t})}}function pS(t,e){t=Ub(t);const{fs:n,path:i}=jw(t,this);try{const t=n.statSync(i);return e?.bigint?new Hv(t):t}catch(e){throw Qw(e,{[i]:t})}}function cS(t,e=0){const n={stack:[],error:void 0,hasError:!1};try{const i=aS(n,fS.call(this,t,"r+"),!1);if(e||(e=0),e<0)throw new Sb(vb.EINVAL);i.truncateSync(e)}catch(t){n.error=t,n.hasError=!0}finally{oS(n)}}function dS(t){t=Ub(t);const{fs:e,path:n}=jw(t,this);try{if(Vv.checkAccess&&!(Pw.get(t)||e.statSync(n)).hasAccess(jb,this))throw Sb.With("EACCES",n,"unlink");e.unlinkSync(n),rS("rename",t.toString())}catch(e){throw Qw(e,{[n]:t})}}function fS(t,e,n,i=!0){t=Ub(t);const s=Bb(n,420),r=jv(e);t=i?GS.call(this,t):t;const{fs:a,path:o}=jw(t,this);let l;try{l=a.statSync(o)}catch{}if(!l){if(!Qv(r)&&!Zv(r)||"r+"==r)throw Sb.With("ENOENT",t,"_open");const e=a.statSync(Mb(o));if(Vv.checkAccess&&!e.hasAccess(jb,this))throw Sb.With("EACCES",Mb(t),"_open");if(!e.isDirectory())throw Sb.With("ENOTDIR",Mb(t),"_open");return a.createFileSync(o,r,s)}if(Vv.checkAccess&&(!l.hasAccess(s,this)||!l.hasAccess(qv(r),this)))throw Sb.With("EACCES",t,"_open");if(tw(r))throw Sb.With("EEXIST",t,"_open");const u=a.openFileSync(o,r);return Jv(r)&&u.truncateSync(0),u}function mS(t,e,n=zb){return Gw(fS.call(this,t,e,n,!0))}function gS(t,e,n){return Gw(fS.call(this,t,e,n,!1))}function _S(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=aS(i,fS.call(this,t,e,420,n),!1),r=s.statSync(),a=new Uint8Array(r.size);return s.readSync(a,0,r.size,0),a}catch(t){i.error=t,i.hasError=!0}finally{oS(i)}}function TS(t,e={}){const n=Yb(e,null,"r",420);if(!Kv(jv(n.flag)))throw new Sb(vb.EINVAL,"Flag passed to readFile must allow for reading.");const i=Bw.Buffer.from(_S.call(this,"number"==typeof t?Hw(t).path:t.toString(),n.flag,!0));return n.encoding?i.toString(n.encoding):i}function yS(t,e,n={}){const i={stack:[],error:void 0,hasError:!1};try{const s=Yb(n,"utf8","w+",420),r=jv(s.flag);if(!Qv(r))throw new Sb(vb.EINVAL,"Flag passed to writeFile must allow for writing.");if("string"!=typeof e&&!s.encoding)throw new Sb(vb.EINVAL,"Encoding not specified");const a="string"==typeof e?Bw.Buffer.from(e,s.encoding):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(!a)throw new Sb(vb.EINVAL,"Data not specified");aS(i,fS.call(this,"number"==typeof t?Hw(t).path:t.toString(),r,s.mode,!0),!1).writeSync(a,0,a.byteLength,0),rS("change",t.toString())}catch(t){i.error=t,i.hasError=!0}finally{oS(i)}}function IS(t,e,n={}){const i={stack:[],error:void 0,hasError:!1};try{const s=Yb(n,"utf8","a+",420),r=jv(s.flag);if(!Zv(r))throw new Sb(vb.EINVAL,"Flag passed to appendFile must allow for appending.");if("string"!=typeof e&&!s.encoding)throw new Sb(vb.EINVAL,"Encoding not specified");const a="string"==typeof e?Bw.Buffer.from(e,s.encoding):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);aS(i,fS.call(this,"number"==typeof t?Hw(t).path:t.toString(),r,s.mode,!0),!1).writeSync(a,0,a.byteLength)}catch(t){i.error=t,i.hasError=!0}finally{oS(i)}}function ES(t,e){const n=Hw(t).statSync();return e?.bigint?new Hv(n):n}function bS(t){Hw(t).closeSync(),Uw.delete(t)}function vS(t,e=0){if(e||(e=0),e<0)throw new Sb(vb.EINVAL);Hw(t).truncateSync(e)}function wS(t){Hw(t).syncSync()}function SS(t){Hw(t).datasyncSync()}function xS(t,e,n,i,s){let r,a,o,l;if("string"==typeof e){l="number"==typeof n?n:null;const t="string"==typeof i?i:"utf8";a=0,r=Bw.Buffer.from(e,t),o=r.byteLength}else r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=n,o=i,l="number"==typeof s?s:null;const u=Hw(t);l??(l=u.position);const h=u.writeSync(r,a,o,l);return rS("change",u.path),h}function RS(t,e,n,i,s){const r=Hw(t),a="object"==typeof n?n.offset:n;return"object"==typeof n&&(i=n.length,s=n.position),s=Number(s),isNaN(s)&&(s=r.position),r.readSync(e,a,i,s)}function OS(t,e,n){Hw(t).chownSync(e,n)}function AS(t,e){const n=Bb(e,-1);if(n<0)throw new Sb(vb.EINVAL,"Invalid mode.");Hw(t).chmodSync(n)}function MS(t,e,n){Hw(t).utimesSync(Vb(e),Vb(n))}function CS(t){t=Ub(t);const{fs:e,path:n}=jw(GS.call(this,t),this);try{const i=Pw.get(t)||e.statSync(n);if(!i.isDirectory())throw Sb.With("ENOTDIR",n,"rmdir");if(Vv.checkAccess&&!i.hasAccess(jb,this))throw Sb.With("EACCES",n,"rmdir");e.rmdirSync(n),rS("rename",t.toString())}catch(e){throw Qw(e,{[n]:t})}}function NS(t,e){e="object"==typeof e?e:{mode:e};const n=Bb(e?.mode,511);t=GS.call(this,t);const{fs:i,path:s,root:r}=jw(t,this),a={[s]:t};try{if(!e?.recursive){if(Vv.checkAccess&&!i.statSync(Mb(s)).hasAccess(jb,this))throw Sb.With("EACCES",Mb(s),"mkdir");return i.mkdirSync(s,n)}const o=[];for(let e=s,n=t;!i.existsSync(e);e=Mb(e),n=Mb(n))o.unshift(e),a[e]=n;for(const t of o){if(Vv.checkAccess&&!i.statSync(Mb(t)).hasAccess(jb,this))throw Sb.With("EACCES",Mb(t),"mkdir");i.mkdirSync(t,n),rS("rename",t)}return 1==r.length?o[0]:o[0]?.slice(r.length)}catch(t){throw Qw(t,a)}}function kS(t,e){e="object"==typeof e?e:{encoding:e},t=Ub(t);const{fs:n,path:i}=jw(GS.call(this,t),this);let s;try{const e=Pw.get(t)||n.statSync(i);if(Pw.set(t,e),Vv.checkAccess&&!e.hasAccess(Xb,this))throw Sb.With("EACCES",i,"readdir");if(!e.isDirectory())throw Sb.With("ENOTDIR",i,"readdir");s=n.readdirSync(i)}catch(e){throw Qw(e,{[i]:t})}const r=[];for(const a of s){const s=Pw.get(Ab(t,a))||n.statSync(Ab(i,a));if(Pw.set(Ab(t,a),s),e?.withFileTypes?r.push(new ZS(a,s)):"buffer"==e?.encoding?r.push(Bw.Buffer.from(a)):r.push(a),s.isDirectory()&&e?.recursive)for(const n of kS.call(this,Ab(t,a),{...e,_isIndirect:!0}))n instanceof ZS?(n.path=Ab(a,n.path),r.push(n)):Bw.Buffer.isBuffer(n)?r.push(Bw.Buffer.from(Ab(a,Fb(n)))):r.push(Ab(a,n))}return e?._isIndirect||Pw.clear(),r}function DS(t,e){if(t=Ub(t),Vv.checkAccess&&!hS(Mb(t)).hasAccess(Xb,this))throw Sb.With("EACCES",Mb(t),"link");if(e=Ub(e),Vv.checkAccess&&!hS(Mb(e)).hasAccess(jb,this))throw Sb.With("EACCES",Mb(e),"link");const{fs:n,path:i}=jw(t,this),s=jw(e,this);if(n!=s.fs)throw Sb.With("EXDEV",e,"link");try{if(Vv.checkAccess&&!n.statSync(i).hasAccess(Xb,this))throw Sb.With("EACCES",i,"link");return n.linkSync(i,e)}catch(n){throw Qw(n,{[i]:t,[s.path]:e})}}function LS(t,e,n="file"){if(!["file","dir","junction"].includes(n))throw new Sb(vb.EINVAL,"Invalid type: "+n);if(uS.call(this,e))throw Sb.With("EEXIST",e.toString(),"symlink");yS.call(this,e,t.toString());fS.call(this,e,"r+",420,!1).chmodSync(_v)}function FS(t,e){const n=Bw.Buffer.from(_S.call(this,t.toString(),"r",!1)),i="object"==typeof e?e?.encoding:e;return"buffer"==i?n:n.toString(i)}function PS(t,e,n){const i=mS.call(this,t,"r+");OS(i,e,n),bS(i)}function $S(t,e,n){const i=gS.call(this,t,"r+");OS(i,e,n),bS(i)}function BS(t,e){const n=mS.call(this,t,"r+");AS(n,e),bS(n)}function VS(t,e){const n=gS.call(this,t,"r+");AS(n,e),bS(n)}function US(t,e,n){const i=mS.call(this,t,"r+");MS(i,e,n),bS(i)}function YS(t,e,n){const i=gS.call(this,t,"r+");MS(i,e,n),bS(i)}function GS(t,e){t=Ub(t);const n=(this?.root||"")+t;if($w.has(n))return $w.get(n);const{base:i,dir:s}=Nb(t),r="/"==s?"/":$w.get((this?.root||"")+s)||GS.call(this,s),a=Ab(r,i),{fs:o,path:l}=jw(a,this);try{const i=Pw.get(a)||o.statSync(l);if(Pw.set(a,i),!i.isSymbolicLink())return $w.set(t,a),a;const s=Ob(r,FS.call(this,a,e).toString()),u=$w.get((this?.root||"")+s)||GS.call(this,s);return $w.set(n,u),u}catch(e){if("ENOENT"==e.code)return t;throw Qw(e,{[l]:a})}}function HS(t,e=384){if(Vv.checkAccess&&!hS.call(this,t).hasAccess(e,this))throw new Sb(vb.EACCES)}function WS(t,e){let n;t=Ub(t);try{n=Pw.get(t)||pS.bind(this)(t)}catch(t){if("ENOENT"!=t.code||!e?.force)throw t}if(n){switch(Pw.set(t,n),n.mode&mv){case Iv:if(e?.recursive)for(const n of kS.call(this,t,{_isIndirect:!0}))WS.call(this,Ab(t,n),{...e,_isIndirect:!0});CS.call(this,t);break;case Tv:case _v:case yv:case Ev:dS.call(this,t);break;default:throw Pw.clear(),new Sb(vb.EPERM,"File type not supported",t,"rm")}e?._isIndirect||Pw.clear()}}function zS(t,e){const n="object"==typeof e?e?.encoding:e||"utf8",i="/tmp/"+`${t}${Date.now()}-${Math.random().toString(36).slice(2)}`;return NS.call(this,i),"buffer"==n?Bw.Buffer.from(i):i}function XS(t,e,n){if(t=Ub(t),e=Ub(e),n&&n&Kb&&uS(e))throw new Sb(vb.EEXIST,"Destination file already exists.",e,"copyFile");yS.call(this,e,TS(t)),rS("rename",e.toString())}function jS(t,e,n){const i=Hw(t);let s=0;for(const t of e)s+=i.readSync(t,0,t.byteLength,n+s);return s}function qS(t,e,n){const i=Hw(t);let s=0;for(const t of e)s+=i.writeSync(new Uint8Array(t.buffer),0,t.byteLength,n+s);return s}function KS(t,e){return t=Ub(t),new tx(t,this)}function QS(t,e,n){t=Ub(t),e=Ub(e);const i=pS.call(this,t);if(n?.errorOnExist&&uS.call(this,e))throw new Sb(vb.EEXIST,"Destination file or directory already exists.",e,"cp");switch(i.mode&mv){case Iv:if(!n?.recursive)throw new Sb(vb.EISDIR,t+" is a directory (not copied)",t,"cp");NS.call(this,e,{recursive:!0});for(const i of kS.call(this,t,{withFileTypes:!0}))n.filter&&!n.filter(Ab(t,i.name),Ab(e,i.name))||QS.call(this,Ab(t,i.name),Ab(e,i.name),n);break;case Tv:case _v:XS.call(this,t,e);break;default:throw new Sb(vb.EPERM,"File type not supported",t,"rm")}n?.preserveTimestamps&&US.call(this,e,i.atime,i.mtime)}function JS(t,e){t=Ub(t);const{fs:n}=jw(t,this);return Zw(n,e?.bigint)}class ZS{get name(){return Cb(this.path)}constructor(t,e){this.path=t,this.stats=e}get parentPath(){return this.path}isFile(){return this.stats.isFile()}isDirectory(){return this.stats.isDirectory()}isBlockDevice(){return this.stats.isBlockDevice()}isCharacterDevice(){return this.stats.isCharacterDevice()}isSymbolicLink(){return this.stats.isSymbolicLink()}isFIFO(){return this.stats.isFIFO()}isSocket(){return this.stats.isSocket()}}class tx{checkClosed(){if(this.closed)throw new Sb(vb.EBADF,"Can not use closed Dir")}constructor(t,e){this.path=t,this.context=e,this.closed=!1}close(t){if(this.closed=!0,!t)return Promise.resolve();t()}closeSync(){this.closed=!0}async _read(){return this.checkClosed(),this._entries??(this._entries=await Ix.call(this.context,this.path,{withFileTypes:!0})),this._entries.length?this._entries.shift()??null:null}read(t){if(!t)return this._read();this._read().then((e=>t(void 0,e)))}readSync(){return this.checkClosed(),this._entries??(this._entries=kS.call(this.context,this.path,{withFileTypes:!0})),this._entries.length?this._entries.shift()??null:null}async next(){const t=await this._read();return t?{done:!1,value:t}:(await this.close(),{done:!0,value:void 0})}[Symbol.asyncIterator](){return this}}var ex=__webpack_require__(6248);class nx extends ex.Readable{close(t=()=>null){try{super.destroy(),super.emit("close"),t()}catch(e){t(new Sb(vb.EIO,e.toString()))}}}class ix extends ex.Writable{close(t=()=>null){try{super.destroy(),super.emit("close"),t()}catch(e){t(new Sb(vb.EIO,e.toString()))}}}var sx=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},rx=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});class ax{constructor(t,e){this.context=e;const n="number"!=typeof t;this.fd=n?Gw(t):t,this.file=n?t:Hw(t)}async chown(t,e){await this.file.chown(t,e),rS("change",this.file.path)}async chmod(t){const e=Bb(t,-1);if(e<0)throw new Sb(vb.EINVAL,"Invalid mode.");await this.file.chmod(e),rS("change",this.file.path)}datasync(){return this.file.datasync()}sync(){return this.file.sync()}async truncate(t){if(t||(t=0),t<0)throw new Sb(vb.EINVAL);await this.file.truncate(t),rS("change",this.file.path)}async utimes(t,e){await this.file.utimes(Vb(t),Vb(e)),rS("change",this.file.path)}async appendFile(t,e={}){const n=Yb(e,"utf8","a",420);if(!Zv(jv(n.flag)))throw new Sb(vb.EINVAL,"Flag passed to appendFile must allow for appending.");if("string"!=typeof t&&!n.encoding)throw new Sb(vb.EINVAL,"Encoding not specified");const i="string"==typeof t?Bw.Buffer.from(t,n.encoding):t;await this.file.write(i,0,i.length),rS("change",this.file.path)}read(t,e,n,i){return isNaN(+i)&&(i=this.file.position),this.file.read(t,e,n,i)}async readFile(t){const e=Yb(t,null,"r",292);if(!Kv(jv(e.flag)))throw new Sb(vb.EINVAL,"Flag passed must allow for reading.");const{size:n}=await this.stat(),{buffer:i}=await this.file.read(new Uint8Array(n),0,n,0),s=Bw.Buffer.from(i);return e.encoding?s.toString(e.encoding):s}readableWebStream(t={}){const e=globalThis;if(!("ReadableStream"in e))throw new Sb(vb.ENOSYS,"ReadableStream is missing on globalThis");return new e.ReadableStream({start:async t=>{try{const e=65536,n=1e7;let i=0,s=0,r=NaN;for(;r>0;){const a=await this.read(new Uint8Array(e),0,e,s);if(!a.bytesRead)return void t.close();if(t.enqueue(a.buffer.slice(0,a.bytesRead)),s+=a.bytesRead,++i>=n)throw new Sb(vb.EFBIG,"Too many iterations on readable stream",this.file.path,"FileHandle.readableWebStream");r=a.bytesRead}}catch(e){t.error(e)}},type:t.type})}readLines(t){throw Sb.With("ENOSYS",this.file.path,"FileHandle.readLines")}[Symbol.asyncDispose](){return this.close()}async stat(t){const e=await this.file.stat();if(Vv.checkAccess&&!e.hasAccess(Xb,this.context))throw Sb.With("EACCES",this.file.path,"stat");return t?.bigint?new Hv(e):e}async write(t,e,n,i){let s,r,a;if("string"==typeof t){i="number"==typeof e?e:null;const o="string"==typeof n?n:"utf8";r=0,s=Bw.Buffer.from(t,o),a=s.length}else s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r=e,a=n,i="number"==typeof i?i:null;i??(i=this.file.position);const o=await this.file.write(s,r,a,i);return rS("change",this.file.path),{buffer:s,bytesWritten:o}}async writeFile(t,e={}){const n=Yb(e,"utf8","w",420);if(!Qv(jv(n.flag)))throw new Sb(vb.EINVAL,"Flag passed must allow for writing.");if("string"!=typeof t&&!n.encoding)throw new Sb(vb.EINVAL,"Encoding not specified");const i="string"==typeof t?Bw.Buffer.from(t,n.encoding):t;await this.file.write(i,0,i.length,0),rS("change",this.file.path)}async close(){await this.file.close(),Uw.delete(this.fd)}async writev(t,e){let n=0;for(const i of t)n+=(await this.write(i,0,i.length,e+n)).bytesWritten;return{bytesWritten:n,buffers:t}}async readv(t,e){let n=0;for(const i of t)n+=(await this.read(i,0,i.byteLength,e+n)).bytesRead;return{bytesRead:n,buffers:t}}createReadStream(t){const e=new nx({highWaterMark:t?.highWaterMark||65536,encoding:t.encoding,read:async t=>{try{const n=await this.read(new Uint8Array(t),0,t,this.file.position);e.push(n.bytesRead?n.buffer.slice(0,n.bytesRead):null),this.file.position+=n.bytesRead}catch(t){e.destroy(t)}}});return e.path=this.file.path,e}createWriteStream(t){const e=new ix({highWaterMark:t?.highWaterMark,encoding:t?.encoding,write:async(t,e,n)=>{try{const{bytesWritten:i}=await this.write(t,null,e);n(i==t.length?null:new Error("Failed to write full chunk"))}catch(t){n(t)}}});return e.path=this.file.path,e}}async function ox(t,e){t=Ub(t),e=Ub(e);const n=jw(t,this),i=jw(e,this);if(Vv.checkAccess&&!(await ux.call(this,Mb(t))).hasAccess(jb,this))throw Sb.With("EACCES",t,"rename");try{if(n.mountPoint==i.mountPoint)return await n.fs.rename(n.path,i.path),rS("rename",t.toString()),void rS("change",e.toString());await gx.call(this,e,await mx(t)),await cx.call(this,t),rS("rename",t.toString())}catch(s){throw Qw(s,{[n.path]:t,[i.path]:e})}}async function lx(t){try{const{fs:e,path:n}=jw(await Mx.call(this,t),this);return await e.exists(n)}catch(t){if(t instanceof Sb&&"ENOENT"==t.code)return!1;throw t}}async function ux(t,e){t=Ub(t);const{fs:n,path:i}=jw(await Mx.call(this,t),this);try{const t=await n.stat(i);if(Vv.checkAccess&&!t.hasAccess(Xb,this))throw Sb.With("EACCES",i,"stat");return e?.bigint?new Hv(t):t}catch(e){throw Qw(e,{[i]:t})}}async function hx(t,e){t=Ub(t);const{fs:n,path:i}=jw(t,this);try{const t=await n.stat(i);return e?.bigint?new Hv(t):t}catch(e){throw Qw(e,{[i]:t})}}async function px(t,e=0){const n={stack:[],error:void 0,hasError:!1};try{const i=sx(n,await fx.call(this,t,"r+"),!0);await i.truncate(e)}catch(t){n.error=t,n.hasError=!0}finally{const t=rx(n);t&&await t}}async function cx(t){t=Ub(t);const{fs:e,path:n}=jw(t,this);try{if(Vv.checkAccess&&!(await(Pw.getAsync(t)||e.stat(n))).hasAccess(jb,this))throw Sb.With("EACCES",n,"unlink");await e.unlink(n),rS("rename",t.toString())}catch(e){throw Qw(e,{[n]:t})}}async function dx(t,e,n=420,i){t=Ub(t);const s=Bb(n,420),r=jv(e);t=i?await Mx.call(this,t):t;const{fs:a,path:o}=jw(t,this),l=await a.stat(o).catch((()=>null));if(!l){if(!Qv(r)&&!Zv(r)||"r+"==r)throw Sb.With("ENOENT",t,"_open");const e=await a.stat(Mb(o));if(Vv.checkAccess&&!e.hasAccess(jb,this))throw Sb.With("EACCES",Mb(t),"_open");if(!e.isDirectory())throw Sb.With("ENOTDIR",Mb(t),"_open");return new ax(await a.createFile(o,r,s),this)}if(Vv.checkAccess&&!l.hasAccess(qv(r),this))throw Sb.With("EACCES",t,"_open");if(tw(r))throw Sb.With("EEXIST",t,"_open");const u=new ax(await a.openFile(o,r),this);return Jv(r)&&await u.truncate(0),u}async function fx(t,e="r",n=420){return await dx.call(this,t,e,n,!0)}async function mx(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=Yb(e,null,"r",420),s=sx(n,"object"==typeof t&&"fd"in t?t:await fx.call(this,t,i.flag,i.mode),!0);return await s.readFile(i)}catch(t){n.error=t,n.hasError=!0}finally{const t=rx(n);t&&await t}}async function gx(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Yb(n,"utf8","w+",420),r=sx(i,t instanceof ax?t:await fx.call(this,t.toString(),s.flag,s.mode),!0),a=e;if("string"!=typeof a&&!(a instanceof Uint8Array))throw new Sb(vb.EINVAL,"Iterables and streams not supported",r.file.path,"writeFile");await r.writeFile(a,s)}catch(t){i.error=t,i.hasError=!0}finally{const t=rx(i);t&&await t}}async function _x(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=Yb(n,"utf8","a",420);if(!Zv(jv(s.flag)))throw new Sb(vb.EINVAL,"Flag passed to appendFile must allow for appending.");if("string"!=typeof e&&!s.encoding)throw new Sb(vb.EINVAL,"Encoding not specified");const r="string"==typeof e?Bw.Buffer.from(e,s.encoding):new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=sx(i,"object"==typeof t&&"fd"in t?t:await fx.call(this,t,s.flag,s.mode),!0);await a.appendFile(r,s)}catch(t){i.error=t,i.hasError=!0}finally{const t=rx(i);t&&await t}}async function Tx(t){t=await Mx.call(this,t);const{fs:e,path:n}=jw(t,this);try{const i=await(Pw.getAsync(t)||e.stat(n));if(!i)throw Sb.With("ENOENT",t,"rmdir");if(!i.isDirectory())throw Sb.With("ENOTDIR",n,"rmdir");if(Vv.checkAccess&&!i.hasAccess(jb,this))throw Sb.With("EACCES",n,"rmdir");await e.rmdir(n),rS("rename",t.toString())}catch(e){throw Qw(e,{[n]:t})}}async function yx(t,e){e="object"==typeof e?e:{mode:e};const n=Bb(e?.mode,511);t=await Mx.call(this,t);const{fs:i,path:s,root:r}=jw(t,this),a={[s]:t};try{if(!e?.recursive){if(Vv.checkAccess&&!(await i.stat(Mb(s))).hasAccess(jb,this))throw Sb.With("EACCES",Mb(s),"mkdir");return await i.mkdir(s,n),void rS("rename",t.toString())}const o=[];for(let e=s,n=t;!await i.exists(e);e=Mb(e),n=Mb(n))o.unshift(e),a[e]=n;for(const t of o){if(Vv.checkAccess&&!(await i.stat(Mb(t))).hasAccess(jb,this))throw Sb.With("EACCES",Mb(t),"mkdir");await i.mkdir(t,n),rS("rename",t)}return 1==r.length?o[0]:o[0]?.slice(r.length)}catch(t){throw Qw(t,a)}}async function Ix(t,e){e="object"==typeof e?e:{encoding:e},t=await Mx.call(this,t);const n=e=>{throw Qw(e,{[s]:t})},{fs:i,path:s}=jw(t,this),r=Pw.getAsync(t)||i.stat(s).catch(n);Pw.setAsync(t,r);const a=await r;if(!a)throw Sb.With("ENOENT",t,"readdir");if(Vv.checkAccess&&!a.hasAccess(Xb,this))throw Sb.With("EACCES",t,"readdir");if(!a.isDirectory())throw Sb.With("ENOTDIR",t,"readdir");const o=await i.readdir(s).catch(n),l=[];return await Promise.all(o.map((async r=>{let a;if(e?.recursive||e?.withFileTypes){const e=Pw.getAsync(Ab(t,r))||i.stat(Ab(s,r)).catch(n);Pw.setAsync(Ab(t,r),e),a=await e}if(e?.withFileTypes?l.push(new ZS(r,a)):"buffer"==e?.encoding?l.push(Bw.Buffer.from(r)):l.push(r),e?.recursive&&a?.isDirectory())for(const n of await Ix.call(this,Ab(t,r),{...e,_isIndirect:!0}))n instanceof ZS?(n.path=Ab(r,n.path),l.push(n)):Bw.Buffer.isBuffer(n)?l.push(Bw.Buffer.from(Ab(r,Fb(n)))):l.push(Ab(r,n))}))),e?._isIndirect||Pw.clear(),l}async function Ex(t,e){t=Ub(t),e=Ub(e);const{fs:n,path:i}=jw(t,this),s=jw(e,this);if(n!=s.fs)throw Sb.With("EXDEV",e,"link");try{if(Vv.checkAccess&&!(await n.stat(Mb(t))).hasAccess(Xb,this))throw Sb.With("EACCES",Mb(i),"link");if(Vv.checkAccess&&!(await ux.call(this,Mb(e))).hasAccess(jb,this))throw Sb.With("EACCES",Mb(e),"link");if(Vv.checkAccess&&!(await n.stat(i)).hasAccess(Xb,this))throw Sb.With("EACCES",i,"link");return await n.link(i,s.path)}catch(n){throw Qw(n,{[s.path]:e,[i]:t})}}async function bx(t,e,n="file"){const i={stack:[],error:void 0,hasError:!1};try{if(!["file","dir","junction"].includes(n))throw new Sb(vb.EINVAL,"Invalid symlink type: "+n);if(await lx.call(this,e))throw Sb.With("EEXIST",e.toString(),"symlink");const s=sx(i,await dx.call(this,e,"w+",420,!1),!0);await s.writeFile(t.toString()),await s.file.chmod(_v)}catch(t){i.error=t,i.hasError=!0}finally{const t=rx(i);t&&await t}}async function vx(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=sx(n,await dx.call(this,Ub(t),"r",420,!1),!0),s=await i.readFile(),r="object"==typeof e?e?.encoding:e;return"buffer"==r?s:s.toString(r)}catch(t){n.error=t,n.hasError=!0}finally{const t=rx(n);t&&await t}}async function wx(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=sx(i,await fx.call(this,t,"r+"),!0);await s.chown(e,n)}catch(t){i.error=t,i.hasError=!0}finally{const t=rx(i);t&&await t}}async function Sx(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=sx(i,await dx.call(this,t,"r+",420,!1),!0);await s.chown(e,n)}catch(t){i.error=t,i.hasError=!0}finally{const t=rx(i);t&&await t}}async function xx(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=sx(n,await fx.call(this,t,"r+"),!0);await i.chmod(e)}catch(t){n.error=t,n.hasError=!0}finally{const t=rx(n);t&&await t}}async function Rx(t,e){const n={stack:[],error:void 0,hasError:!1};try{const i=sx(n,await dx.call(this,t,"r+",420,!1),!0);await i.chmod(e)}catch(t){n.error=t,n.hasError=!0}finally{const t=rx(n);t&&await t}}async function Ox(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=sx(i,await fx.call(this,t,"r+"),!0);await s.utimes(e,n)}catch(t){i.error=t,i.hasError=!0}finally{const t=rx(i);t&&await t}}async function Ax(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{const s=sx(i,await dx.call(this,t,"r+",420,!1),!0);await s.utimes(new Date(e),new Date(n))}catch(t){i.error=t,i.hasError=!0}finally{const t=rx(i);t&&await t}}async function Mx(t,e){t=Ub(t);const n=(this?.root||"")+t;if($w.hasAsync(n))return $w.getAsync(n);const{base:i,dir:s}=Nb(t),r="/"==s?"/":await($w.getAsync((this?.root||"")+s)||Mx.call(this,s)),a=Ab(r,i),{fs:o,path:l}=jw(a,this);try{const e=Pw.getAsync(a)||o.stat(l);if(Pw.setAsync(a,e),!(await e).isSymbolicLink())return $w.set(t,a),a;const i=Ob(r,(await vx.call(this,a)).toString()),s=$w.getAsync((this?.root||"")+i)||Mx.call(this,i);return $w.setAsync(n,s),await s}catch(e){if("ENOENT"==e.code)return t;throw Qw(e,{[l]:a})}}function Cx(t,e={}){return{[Symbol.asyncIterator](){const n=new nS(t.toString(),"string"!=typeof e?e:{encoding:e}),i=[];function s(){n.close();for(const t of i)t({value:null,done:!0});return i.length=0,Promise.resolve({value:null,done:!0})}return n.on("change",((t,e)=>{i.shift()?.({value:{eventType:t,filename:e},done:!1})})),{async next(){const{promise:t,resolve:e}=Promise.withResolvers();return i.push(e),t},return:s,throw:s}}}}async function Nx(t,e=zb){if(!Vv.checkAccess)return;if(!(await ux.call(this,t)).hasAccess(e,this))throw new Sb(vb.EACCES)}async function kx(t,e){t=Ub(t);const n=await(Pw.getAsync(t)||hx.call(this,t).catch((t=>{if("ENOENT"!=t.code||!e?.force)throw t})));if(n){switch(Pw.set(t,n),n.mode&mv){case Iv:if(e?.recursive)for(const n of await Ix.call(this,t,{_isIndirect:!0}))await kx.call(this,Ab(t,n),{...e,_isIndirect:!0});await Tx.call(this,t);break;case Tv:case _v:case yv:case Ev:await cx.call(this,t);break;default:throw Pw.clear(),new Sb(vb.EPERM,"File type not supported",t,"rm")}e?._isIndirect||Pw.clear()}}async function Dx(t,e){const n="object"==typeof e?e?.encoding:e||"utf8",i="/tmp/"+`${t}${Date.now()}-${Math.random().toString(36).slice(2)}`;return await yx.call(this,i),"buffer"==n?Bw.Buffer.from(i):i}async function Lx(t,e,n){if(t=Ub(t),e=Ub(e),n&&n&Kb&&await lx.call(this,e))throw new Sb(vb.EEXIST,"Destination file already exists.",e,"copyFile");await gx.call(this,e,await mx.call(this,t)),rS("rename",e.toString())}function Fx(t,e){return t=Ub(t),Promise.resolve(new tx(t,this))}async function Px(t,e,n){t=Ub(t),e=Ub(e);const i=await hx.call(this,t);if(n?.errorOnExist&&await lx.call(this,e))throw new Sb(vb.EEXIST,"Destination file or directory already exists.",e,"cp");switch(i.mode&mv){case Iv:{if(!n?.recursive)throw new Sb(vb.EISDIR,t+" is a directory (not copied)",t,"cp");const[i]=await Promise.all([Ix.call(this,t,{withFileTypes:!0}),yx.call(this,e,{recursive:!0})]),s=async i=>{n.filter&&!n.filter(Ab(t,i.name),Ab(e,i.name))||await Px.call(this,Ab(t,i.name),Ab(e,i.name),n)};await Promise.all(i.map(s));break}case Tv:case _v:await Lx.call(this,t,e);break;default:throw new Sb(vb.EPERM,"File type not supported",t,"rm")}n?.preserveTimestamps&&await Ox.call(this,e,i.atime,i.mtime)}async function $x(t,e){t=Ub(t);const{fs:n}=jw(t,this);return Promise.resolve(Zw(n,e?.bigint))}const Bx=()=>{};function Vx(t,e,n=Bx){ox.call(this,t,e).then((()=>n())).catch(n)}function Ux(t,e=Bx){lx.call(this,t).then(e).catch((()=>e(!1)))}function Yx(t,e,n=Bx){n="function"==typeof e?e:n,ux.call(this,t,"function"!=typeof e?e:{}).then((t=>n(void 0,t))).catch(n)}function Gx(t,e,n=Bx){n="function"==typeof e?e:n,hx.call(this,t,"function"!=typeof e?e:{}).then((t=>n(void 0,t))).catch(n)}function Hx(t,e=0,n=Bx){n="function"==typeof e?e:n;const i="number"==typeof e?e:0;px.call(this,t,i).then((()=>n())).catch(n)}function Wx(t,e=Bx){cx.call(this,t).then((()=>e())).catch(e)}function zx(t,e,n,i=Bx){const s=Bb(n,420);i="function"==typeof n?n:i,fx.call(this,t,e,s).then((t=>i(void 0,t.fd))).catch(i)}function Xx(t,e,n=Bx){n="function"==typeof e?e:n,mx.call(this,t,"function"==typeof e?null:e).then((t=>n(void 0,t))).catch(n)}function jx(t,e,n,i=Bx){i="function"==typeof n?n:i,gx.call(this,t,e,"function"!=typeof n?n:null).then((()=>i(void 0))).catch(i)}function qx(t,e,n,i=Bx){const s="function"!=typeof n?n:void 0;i="function"==typeof n?n:i,_x.call(this,t,e,s).then((()=>i())).catch(i)}function Kx(t,e,n=Bx){n="function"==typeof e?e:n,Hw(t).stat().then((t=>n(void 0,"object"==typeof e&&e?.bigint?new Hv(t):t))).catch(n)}function Qx(t,e=Bx){const n=Hw(t).close();Uw.delete(t),n.then((()=>e())).catch(e)}function Jx(t,e,n=Bx){const i="number"==typeof e?e:0;n="function"==typeof e?e:n;const s=Hw(t);if(i<0)throw new Sb(vb.EINVAL);s.truncate(i).then((()=>n())).catch(n)}function Zx(t,e=Bx){Hw(t).sync().then((()=>e())).catch(e)}function tR(t,e=Bx){Hw(t).datasync().then((()=>e())).catch(e)}function eR(t,e,n,i,s,r=Bx){let a,o,l,u,h;const p=new ax(t,this);if("string"==typeof e){switch(h="utf8",typeof n){case"function":r=n;break;case"number":u=n,h="string"==typeof i?i:"utf8",r="function"==typeof s?s:r;break;default:return void(r="function"==typeof i?i:"function"==typeof s?s:r)(new Sb(vb.EINVAL,"Invalid arguments."))}a=Bw.Buffer.from(e),o=0,l=a.length;const t=r;p.write(a,o,l,u).then((({bytesWritten:e})=>t(void 0,e,a.toString(h)))).catch(t)}else{a=Bw.Buffer.from(e.buffer),o=n,l=i,u="number"==typeof s?s:null;const t="function"==typeof s?s:r;p.write(a,o,l,u).then((({bytesWritten:e})=>t(void 0,e,a))).catch(t)}}function nR(t,e,n,i,s,r=Bx){new ax(t,this).read(e,n,i,s).then((({bytesRead:t,buffer:e})=>r(void 0,t,e))).catch(r)}function iR(t,e,n,i=Bx){new ax(t,this).chown(e,n).then((()=>i())).catch(i)}function sR(t,e,n){new ax(t,this).chmod(e).then((()=>n())).catch(n)}function rR(t,e,n,i=Bx){new ax(t,this).utimes(e,n).then((()=>i())).catch(i)}function aR(t,e=Bx){Tx.call(this,t).then((()=>e())).catch(e)}function oR(t,e,n=Bx){yx.call(this,t,e).then((()=>n())).catch(n)}function lR(t,e,n=Bx){n="function"==typeof e?e:n;const i="function"!=typeof e?e:{};Ix.call(this,t,i).then((t=>n(void 0,t))).catch(n)}function uR(t,e,n=Bx){Ex.call(this,t,e).then((()=>n())).catch(n)}function hR(t,e,n,i=Bx){const s="string"==typeof n?n:"file";i="function"==typeof n?n:i,bx.call(this,t,e,s).then((()=>i())).catch(i)}function pR(t,e,n=Bx){n="function"==typeof e?e:n,vx.call(this,t).then((t=>n(void 0,t))).catch(n)}function cR(t,e,n,i=Bx){wx.call(this,t,e,n).then((()=>i())).catch(i)}function dR(t,e,n,i=Bx){Sx.call(this,t,e,n).then((()=>i())).catch(i)}function fR(t,e,n=Bx){xx.call(this,t,e).then((()=>n())).catch(n)}function mR(t,e,n=Bx){Rx.call(this,t,e).then((()=>n())).catch(n)}function gR(t,e,n,i=Bx){Ox.call(this,t,e,n).then((()=>i())).catch(i)}function _R(t,e,n,i=Bx){Ax.call(this,t,e,n).then((()=>i())).catch(i)}function TR(t,e,n=Bx){n="function"==typeof e?e:n,Mx.call(this,t,"function"==typeof e?null:e).then((t=>n(void 0,t))).catch(n)}function yR(t,e,n=Bx){const i="number"==typeof e?e:Xb;n="function"==typeof e?e:n,Nx.call(this,t,i).then((()=>n())).catch(n)}const IR=new Map;function ER(t,e,n){const i=Ub(t.toString()),s="function"!=typeof e?e:{};if("function"==typeof e&&(n=e),!n)throw new Sb(vb.EINVAL,"No listener specified",t.toString(),"watchFile");if(IR.has(i)){const t=IR.get(i);return void(t&&t.listeners.add(n))}const r=new iS(i,s);r.on("change",((t,e)=>{const n=IR.get(i);if(n)for(const i of n.listeners)i(t,e)})),IR.set(i,{watcher:r,listeners:new Set})}function bR(t,e=Bx){const n=Ub(t.toString()),i=IR.get(n);i&&(e&&e!==Bx?i.listeners.delete(e):i.listeners.clear(),0===i.listeners.size&&(i.watcher.stop(),IR.delete(n)))}function vR(t,e,n){const i=new nS(Ub(t),"object"==typeof e?e:{});return n="function"==typeof e?e:n,i.on("change",n||Bx),i}function wR(t,e){const n=this;let i;const s=new nx({highWaterMark:(e="object"==typeof e?e:{encoding:e}).highWaterMark||65536,encoding:e.encoding||"utf8",async read(r){try{i||(i=await fx.call(n,t,"r",e?.mode));const a=await i.read(new Uint8Array(r),0,r,i.file.position);s.push(a.bytesRead?a.buffer.slice(0,a.bytesRead):null),i.file.position+=a.bytesRead,a.bytesRead||await i.close()}catch(t){await(i?.close()),s.destroy(t)}},destroy(t,e){i?.close().then((()=>e(t))).catch(Bx)}});return s.path=t.toString(),s}function SR(t,e){const n=this;let i;e="object"==typeof e?e:{encoding:e};const s=new ix({highWaterMark:e?.highWaterMark,async write(s,r,a){try{i||(i=await fx.call(n,t,"w",e?.mode||438)),await i.write(s,0,r),a(void 0)}catch(t){await(i?.close()),a(t)}},destroy(t,e){e(t),i?.close().then((()=>e(t))).catch(e)},final(t){i?.close().then((()=>t())).catch(t)}});return s.path=t.toString(),s}function xR(t,e,n=Bx){n="function"==typeof e?e:n,kx.call(this,t,"function"==typeof e?void 0:e).then((()=>n(void 0))).catch(n)}function RR(t,e,n=Bx){n="function"==typeof e?e:n,Dx.call(this,t,"function"!=typeof e?e:null).then((t=>n(void 0,t))).catch(n)}function OR(t,e,n,i=Bx){i="function"==typeof n?n:i,Lx.call(this,t,e,"function"==typeof n?void 0:n).then((()=>i(void 0))).catch(i)}function AR(t,e,n,i=Bx){i="function"==typeof n?n:i,new ax(t,this).readv(e,"function"==typeof n?void 0:n).then((({buffers:t,bytesRead:e})=>i(void 0,e,t))).catch(i)}function MR(t,e,n,i=Bx){i="function"==typeof n?n:i,new ax(t,this).writev(e,"function"==typeof n?void 0:n).then((({buffers:t,bytesWritten:e})=>i(void 0,e,t))).catch(i)}function CR(t,e,n=Bx){n="function"==typeof e?e:n,Fx.call(this,t,"function"==typeof e?void 0:e).then((t=>n(void 0,t))).catch(n)}function NR(t,e,n,i=Bx){i="function"==typeof n?n:i,Px.call(this,t,e,"function"==typeof n?void 0:n).then((()=>i(void 0))).catch(i)}function kR(t,e,n=Bx){n="function"==typeof e?e:n,$x.call(this,t,"function"==typeof e?void 0:e).then((t=>n(void 0,t))).catch(n)}async function DR(t,e){const n=await fx.call(this,t.toString(),"r"),i=await n.readFile();return await n.close(),new Blob([i],e)}var LR=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},FR=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});function PR(t){return class extends t{constructor(){super(...arguments),this._queue=[],this._isInitialized=!1}get _queueRunning(){return!!this._queue.length}queueDone(){return new Promise((t=>{const e=()=>this._queueRunning?setTimeout(e):t();e()}))}async ready(){if(await super.ready(),await this.queueDone(),!this._isInitialized&&!this._disableSync){if(this.checkSync(),await this._sync.ready(),this._sync instanceof Mw&&this instanceof Mw){const t=this._sync.store.transaction(),e=this.store.transaction(),n=[];for(const i of await e.keys())n.push(e.get(i).then((e=>t.setSync(i,e))));return await Promise.all(n),void(this._isInitialized=!0)}try{await this.crossCopy("/"),this._isInitialized=!0}catch(t){throw this._isInitialized=!1,t}}}checkSync(t,e){if(this._disableSync)throw new Sb(vb.ENOTSUP,"Sync caching has been disabled for this async file system",t,e);if(!this._sync)throw new Sb(vb.ENOTSUP,"No sync cache is attached to this async file system",t,e)}renameSync(t,e){this.checkSync(t,"rename"),this._sync.renameSync(t,e),this.queue("rename",t,e)}statSync(t){return this.checkSync(t,"stat"),this._sync.statSync(t)}createFileSync(t,e,n){return this.checkSync(t,"createFile"),this._sync.createFileSync(t,e,n),this.queue("createFile",t,e,n),this.openFileSync(t,e)}openFileSync(t,e){this.checkSync(t,"openFile");const n=this._sync.openFileSync(t,e+"+"),i=n.statSync(),s=new Uint8Array(i.size);return n.readSync(s),new nw(this,t,e,i,s)}unlinkSync(t){this.checkSync(t,"unlinkSync"),this._sync.unlinkSync(t),this.queue("unlink",t)}rmdirSync(t){this.checkSync(t,"rmdir"),this._sync.rmdirSync(t),this.queue("rmdir",t)}mkdirSync(t,e){this.checkSync(t,"mkdir"),this._sync.mkdirSync(t,e),this.queue("mkdir",t,e)}readdirSync(t){return this.checkSync(t,"readdir"),this._sync.readdirSync(t)}linkSync(t,e){this.checkSync(t,"link"),this._sync.linkSync(t,e),this.queue("link",t,e)}syncSync(t,e,n){this.checkSync(t,"sync"),this._sync.syncSync(t,e,n),this.queue("sync",t,e,n)}existsSync(t){return this.checkSync(t,"exists"),this._sync.existsSync(t)}async crossCopy(t){this.checkSync(t,"crossCopy");const e=await this.stat(t);if(!e.isDirectory()){const n={stack:[],error:void 0,hasError:!1};try{const i=LR(n,await this.openFile(t,jv("r")),!0),s=LR(n,this._sync.createFileSync(t,jv("w"),e.mode),!1),r=new Uint8Array(e.size);return await i.read(r),void s.writeSync(r,0,e.size)}catch(t){n.error=t,n.hasError=!0}finally{const t=FR(n);t&&await t}}if("/"!==t){const e=await this.stat(t);this._sync.mkdirSync(t,e.mode)}const n=[];for(const e of await this.readdir(t))n.push(this.crossCopy(Ab(t,e)));await Promise.all(n)}async _next(){if(!this._queueRunning)return;const[t,...e]=this._queue.shift();await this[t](...e),await this._next()}queue(...t){this._queue.push(t),this._next()}}}new Map;PR(iw);new Map;Map;$R=iw;var $R;var BR=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},VR=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});class UR{get isLocked(){return this._isLocked}constructor(t){this.previous=t,this.current=Promise.withResolvers(),this._isLocked=!0}async done(){await(this.previous?.done()),await this.current.promise}unlock(){this.current.resolve(),this._isLocked=!1}[Symbol.dispose](){this.unlock()}}class YR{async ready(){return await this._fs.ready()}metadata(){return this._fs.metadata()}addLock(){const t=new UR(this.currentLock);return this.currentLock=t,t}async lock(t,e){const n=this.currentLock,i=this.addLock(),s=(new Error).stack;return setTimeout((()=>{if(i.isLocked){const n=Sb.With("EDEADLK",t,e);throw n.stack+=s?.slice(5),n}}),5e3),await(n?.done()),i}lockSync(t,e){if(this.currentLock?.isLocked)throw Sb.With("EBUSY",t,e);return this.addLock()}get isLocked(){return!!this.currentLock?.isLocked}async rename(t,e){const n={stack:[],error:void 0,hasError:!1};try{BR(n,await this.lock(t,"rename"),!1);await this._fs.rename(t,e)}catch(t){n.error=t,n.hasError=!0}finally{VR(n)}}renameSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{BR(n,this.lockSync(t,"rename"),!1);return this._fs.renameSync(t,e)}catch(t){n.error=t,n.hasError=!0}finally{VR(n)}}async stat(t){const e={stack:[],error:void 0,hasError:!1};try{BR(e,await this.lock(t,"stat"),!1);return await this._fs.stat(t)}catch(t){e.error=t,e.hasError=!0}finally{VR(e)}}statSync(t){const e={stack:[],error:void 0,hasError:!1};try{BR(e,this.lockSync(t,"stat"),!1);return this._fs.statSync(t)}catch(t){e.error=t,e.hasError=!0}finally{VR(e)}}async openFile(t,e){const n={stack:[],error:void 0,hasError:!1};try{BR(n,await this.lock(t,"openFile"),!1);const i=await this._fs.openFile(t,e);return i.fs=this,i}catch(t){n.error=t,n.hasError=!0}finally{VR(n)}}openFileSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{BR(n,this.lockSync(t,"openFile"),!1);const i=this._fs.openFileSync(t,e);return i.fs=this,i}catch(t){n.error=t,n.hasError=!0}finally{VR(n)}}async createFile(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{BR(i,await this.lock(t,"createFile"),!1);const s=await this._fs.createFile(t,e,n);return s.fs=this,s}catch(t){i.error=t,i.hasError=!0}finally{VR(i)}}createFileSync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{BR(i,this.lockSync(t,"createFile"),!1);const s=this._fs.createFileSync(t,e,n);return s.fs=this,s}catch(t){i.error=t,i.hasError=!0}finally{VR(i)}}async unlink(t){const e={stack:[],error:void 0,hasError:!1};try{BR(e,await this.lock(t,"unlink"),!1);await this._fs.unlink(t)}catch(t){e.error=t,e.hasError=!0}finally{VR(e)}}unlinkSync(t){const e={stack:[],error:void 0,hasError:!1};try{BR(e,this.lockSync(t,"unlink"),!1);return this._fs.unlinkSync(t)}catch(t){e.error=t,e.hasError=!0}finally{VR(e)}}async rmdir(t){const e={stack:[],error:void 0,hasError:!1};try{BR(e,await this.lock(t,"rmdir"),!1);await this._fs.rmdir(t)}catch(t){e.error=t,e.hasError=!0}finally{VR(e)}}rmdirSync(t){const e={stack:[],error:void 0,hasError:!1};try{BR(e,this.lockSync(t,"rmdir"),!1);return this._fs.rmdirSync(t)}catch(t){e.error=t,e.hasError=!0}finally{VR(e)}}async mkdir(t,e){const n={stack:[],error:void 0,hasError:!1};try{BR(n,await this.lock(t,"mkdir"),!1);await this._fs.mkdir(t,e)}catch(t){n.error=t,n.hasError=!0}finally{VR(n)}}mkdirSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{BR(n,this.lockSync(t,"mkdir"),!1);return this._fs.mkdirSync(t,e)}catch(t){n.error=t,n.hasError=!0}finally{VR(n)}}async readdir(t){const e={stack:[],error:void 0,hasError:!1};try{BR(e,await this.lock(t,"readdir"),!1);return await this._fs.readdir(t)}catch(t){e.error=t,e.hasError=!0}finally{VR(e)}}readdirSync(t){const e={stack:[],error:void 0,hasError:!1};try{BR(e,this.lockSync(t,"readdir"),!1);return this._fs.readdirSync(t)}catch(t){e.error=t,e.hasError=!0}finally{VR(e)}}async exists(t){const e={stack:[],error:void 0,hasError:!1};try{BR(e,await this.lock(t,"exists"),!1);return await this._fs.exists(t)}catch(t){e.error=t,e.hasError=!0}finally{VR(e)}}existsSync(t){const e={stack:[],error:void 0,hasError:!1};try{BR(e,this.lockSync(t,"exists"),!1);return this._fs.existsSync(t)}catch(t){e.error=t,e.hasError=!0}finally{VR(e)}}async link(t,e){const n={stack:[],error:void 0,hasError:!1};try{BR(n,await this.lock(t,"link"),!1);await this._fs.link(t,e)}catch(t){n.error=t,n.hasError=!0}finally{VR(n)}}linkSync(t,e){const n={stack:[],error:void 0,hasError:!1};try{BR(n,this.lockSync(t,"link"),!1);return this._fs.linkSync(t,e)}catch(t){n.error=t,n.hasError=!0}finally{VR(n)}}async sync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{BR(i,await this.lock(t,"sync"),!1);await this._fs.sync(t,e,n)}catch(t){i.error=t,i.hasError=!0}finally{VR(i)}}syncSync(t,e,n){const i={stack:[],error:void 0,hasError:!1};try{BR(i,this.lockSync(t,"sync"),!1);return this._fs.syncSync(t,e,n)}catch(t){i.error=t,i.hasError=!0}finally{VR(i)}}}var GR=function(t,e,n){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var i,s;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");i=e[Symbol.asyncDispose]}if(void 0===i){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");i=e[Symbol.dispose],n&&(s=i)}if("function"!=typeof i)throw new TypeError("Object not disposable.");s&&(i=function(){try{s.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:i,async:n})}else n&&t.stack.push({async:!0});return e},HR=function(t){return function(e){function n(n){e.error=e.hasError?new t(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}return function t(){for(;e.stack.length;){var i=e.stack.pop();try{var s=i.dispose&&i.dispose.call(i.value);if(i.async)return Promise.resolve(s).then(t,(function(e){return n(e),t()}))}catch(t){n(t)}}if(e.hasError)throw e.error}()}}("function"==typeof SuppressedError?SuppressedError:function(t,e,n){var i=new Error(n);return i.name="SuppressedError",i.error=t,i.suppressed=e,i});const WR="/.deleted";class zR extends iw{async ready(){await this.readable.ready(),await this.writable.ready(),await this._ready}constructor({writable:t,readable:e}){if(super(),this._isInitialized=!1,this._deletedFiles=new Set,this._deleteLog="",this._deleteLogUpdatePending=!1,this._deleteLogUpdateNeeded=!1,this.writable=t,this.readable=e,this.writable.metadata().readonly)throw new Sb(vb.EINVAL,"Writable file system must be writable.");this._ready=this._initialize()}metadata(){return{...super.metadata(),name:XR.name}}async sync(t,e,n){await this.copyForWrite(t),await this.writable.exists(t)||await this.writable.createFile(t,"w",420),await this.writable.sync(t,e,n)}syncSync(t,e,n){this.copyForWriteSync(t),this.writable.syncSync(t,e,n)}async _initialize(){if(!this._isInitialized){try{const t=await this.writable.openFile(WR,jv("r")),{size:e}=await t.stat(),{buffer:n}=await t.read(new Uint8Array(e));this._deleteLog=Fb(n)}catch(t){if(t.errno!==vb.ENOENT)throw t}this._isInitialized=!0,this._reparseDeletionLog()}}getDeletionLog(){return this._deleteLog}async restoreDeletionLog(t){this._deleteLog=t,this._reparseDeletionLog(),await this.updateLog("")}async rename(t,e){this.checkInitialized(),this.checkPath(t),this.checkPath(e),await this.copyForWrite(t);try{await this.writable.rename(t,e)}catch{if(this._deletedFiles.has(t))throw Sb.With("ENOENT",t,"rename")}}renameSync(t,e){this.checkInitialized(),this.checkPath(t),this.checkPath(e),this.copyForWriteSync(t);try{this.writable.renameSync(t,e)}catch{if(this._deletedFiles.has(t))throw Sb.With("ENOENT",t,"rename")}}async stat(t){this.checkInitialized();try{return await this.writable.stat(t)}catch{if(this._deletedFiles.has(t))throw Sb.With("ENOENT",t,"stat");const e=await this.readable.stat(t);return e.mode|=146,e}}statSync(t){this.checkInitialized();try{return this.writable.statSync(t)}catch{if(this._deletedFiles.has(t))throw Sb.With("ENOENT",t,"stat");const e=this.readable.statSync(t);return e.mode|=146,e}}async openFile(t,e){if(await this.writable.exists(t))return this.writable.openFile(t,e);const n=await this.readable.openFile(t,jv("r")),i=await n.stat(),{buffer:s}=await n.read(new Uint8Array(i.size));return new nw(this,t,e,i,s)}openFileSync(t,e){if(this.writable.existsSync(t))return this.writable.openFileSync(t,e);const n=this.readable.openFileSync(t,jv("r")),i=n.statSync(),s=new Uint8Array(i.size);return n.readSync(s),new nw(this,t,e,i,s)}async createFile(t,e,n){return this.checkInitialized(),await this.writable.createFile(t,e,n),this.openFile(t,e)}createFileSync(t,e,n){return this.checkInitialized(),this.writable.createFileSync(t,e,n),this.openFileSync(t,e)}async link(t,e){this.checkInitialized(),await this.copyForWrite(t),await this.writable.link(t,e)}linkSync(t,e){this.checkInitialized(),this.copyForWriteSync(t),this.writable.linkSync(t,e)}async unlink(t){if(this.checkInitialized(),this.checkPath(t),!await this.exists(t))throw Sb.With("ENOENT",t,"unlink");await this.writable.exists(t)&&await this.writable.unlink(t),await this.exists(t)&&await this.deletePath(t)}unlinkSync(t){if(this.checkInitialized(),this.checkPath(t),!this.existsSync(t))throw Sb.With("ENOENT",t,"unlink");this.writable.existsSync(t)&&this.writable.unlinkSync(t),this.existsSync(t)&&this.deletePath(t)}async rmdir(t){if(this.checkInitialized(),!await this.exists(t))throw Sb.With("ENOENT",t,"rmdir");if(await this.writable.exists(t)&&await this.writable.rmdir(t),await this.exists(t)){if((await this.readdir(t)).length)throw Sb.With("ENOTEMPTY",t,"rmdir");await this.deletePath(t)}}rmdirSync(t){if(this.checkInitialized(),!this.existsSync(t))throw Sb.With("ENOENT",t,"rmdir");if(this.writable.existsSync(t)&&this.writable.rmdirSync(t),this.existsSync(t)){if(this.readdirSync(t).length)throw Sb.With("ENOTEMPTY",t,"rmdir");this.deletePath(t)}}async mkdir(t,e){if(this.checkInitialized(),await this.exists(t))throw Sb.With("EEXIST",t,"mkdir");await this.createParentDirectories(t),await this.writable.mkdir(t,e)}mkdirSync(t,e){if(this.checkInitialized(),this.existsSync(t))throw Sb.With("EEXIST",t,"mkdir");this.createParentDirectoriesSync(t),this.writable.mkdirSync(t,e)}async readdir(t){this.checkInitialized();const e=[];try{e.push(...await this.writable.readdir(t))}catch{}try{e.push(...(await this.readable.readdir(t)).filter((e=>!this._deletedFiles.has(`${t}/${e}`))))}catch{}const n={};return e.filter((t=>{const e=!n[t];return n[t]=!0,e}))}readdirSync(t){this.checkInitialized();let e=[];try{e=e.concat(this.writable.readdirSync(t))}catch{}try{e=e.concat(this.readable.readdirSync(t).filter((e=>!this._deletedFiles.has(`${t}/${e}`))))}catch{}const n={};return e.filter((t=>{const e=!n[t];return n[t]=!0,e}))}async deletePath(t){this._deletedFiles.add(t),await this.updateLog(`d${t}\n`)}async updateLog(t){if(this._deleteLog+=t,this._deleteLogUpdatePending)return void(this._deleteLogUpdateNeeded=!0);this._deleteLogUpdatePending=!0;const e=await this.writable.openFile(WR,jv("w"));try{await e.write(Db(this._deleteLog)),this._deleteLogUpdateNeeded&&(this._deleteLogUpdateNeeded=!1,await this.updateLog(""))}catch(t){this._deleteLogError=t}finally{this._deleteLogUpdatePending=!1}}_reparseDeletionLog(){this._deletedFiles.clear();for(const t of this._deleteLog.split("\n"))t.startsWith("d")&&this._deletedFiles.add(t.slice(1))}checkInitialized(){if(!this._isInitialized)throw new Sb(vb.EPERM,"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.");if(!this._deleteLogError)return;const t=this._deleteLogError;throw delete this._deleteLogError,t}checkPath(t){if(t==WR)throw Sb.With("EPERM",t,"checkPath")}createParentDirectoriesSync(t){let e=Mb(t);const n=[];for(;!this.writable.existsSync(e);)n.push(e),e=Mb(e);for(const t of n.reverse())this.writable.mkdirSync(t,this.statSync(t).mode)}async createParentDirectories(t){let e=Mb(t);const n=[];for(;!await this.writable.exists(e);)n.push(e),e=Mb(e);for(const t of n.reverse()){const e=await this.stat(t);await this.writable.mkdir(t,e.mode)}}copyForWriteSync(t){if(!this.existsSync(t))throw Sb.With("ENOENT",t,"copyForWrite");this.writable.existsSync(Mb(t))||this.createParentDirectoriesSync(t),this.writable.existsSync(t)||this.copyToWritableSync(t)}async copyForWrite(t){if(!await this.exists(t))throw Sb.With("ENOENT",t,"copyForWrite");if(await this.writable.exists(Mb(t))||await this.createParentDirectories(t),!await this.writable.exists(t))return this.copyToWritable(t)}copyToWritableSync(t){const e={stack:[],error:void 0,hasError:!1};try{const n=this.statSync(t);if(n.isDirectory())return void this.writable.mkdirSync(t,n.mode);const i=new Uint8Array(n.size);GR(e,this.readable.openFileSync(t,"r"),!1).readSync(i);GR(e,this.writable.createFileSync(t,"w",146|n.mode),!1).writeSync(i)}catch(t){e.error=t,e.hasError=!0}finally{HR(e)}}async copyToWritable(t){const e={stack:[],error:void 0,hasError:!1};try{const n=await this.stat(t);if(n.isDirectory())return void await this.writable.mkdir(t,n.mode);const i=new Uint8Array(n.size),s=GR(e,await this.readable.openFile(t,"r"),!0);await s.read(i);const r=GR(e,await this.writable.createFile(t,"w",146|n.mode),!0);await r.write(i)}catch(t){e.error=t,e.hasError=!0}finally{const t=HR(e);t&&await t}}}class XR extends(function(t){return class extends YR{constructor(...e){super(),this._fs=new t(...e)}}}(zR)){}function jR(t,e,n){if(t instanceof Sb)return t;const i=t instanceof DOMException?vb[function(t){switch(t.name){case"IndexSizeError":case"HierarchyRequestError":case"InvalidCharacterError":case"InvalidStateError":case"SyntaxError":case"NamespaceError":case"TypeMismatchError":case"ConstraintError":case"VersionError":case"URLMismatchError":case"InvalidNodeTypeError":return"EINVAL";case"WrongDocumentError":return"EXDEV";case"NoModificationAllowedError":case"InvalidModificationError":case"InvalidAccessError":case"SecurityError":case"NotAllowedError":return"EACCES";case"NotFoundError":return"ENOENT";case"NotSupportedError":return"ENOTSUP";case"InUseAttributeError":return"EBUSY";case"NetworkError":return"ENETDOWN";case"AbortError":return"EINTR";case"QuotaExceededError":return"ENOSPC";case"TimeoutError":return"ETIMEDOUT";case"ReadOnlyError":return"EROFS";default:return"EIO"}}(t)]:vb.EIO,s=new Sb(i,t.message,e,n);return s.stack=t.stack,s.cause=t.cause,s}globalThis.__zenfs__=st;class qR extends(PR(iw)){constructor(t){super(),this._handles=new Map,this._sync=Lw.create({name:"accessfs-cache"}),this._handles.set("/",t)}metadata(){return{...super.metadata(),name:"WebAccess",noResizableBuffers:!0}}async sync(t,e){await this.writeFile(t,e)}async rename(t,e){const n=await this.getHandle(t);if(n instanceof FileSystemDirectoryHandle){const n=await this.readdir(t);if(await this.mkdir(e),!n.length)return void await this.unlink(t);for(const i of n)await this.rename(Ab(t,i),Ab(e,i)),await this.unlink(t);return}if(!(n instanceof FileSystemFileHandle))throw new Sb(vb.ENOTSUP,"Not a file or directory handle",t,"rename");const i=await n.getFile().catch((e=>{throw jR(e,t,"rename")})),s=await this.getHandle(Mb(e));if(!(s instanceof FileSystemDirectoryHandle))return;const r=await s.getFileHandle(Cb(e),{create:!0}).catch((t=>{throw jR(t,e,"rename")})),a=await r.createWritable();await a.write(await i.arrayBuffer()),await a.close(),await this.unlink(t)}async writeFile(t,e){if(e.buffer.resizable)throw new Sb(vb.EINVAL,"Resizable buffers can not be written",t,"write");const n=await this.getHandle(Mb(t));if(!(n instanceof FileSystemDirectoryHandle))return;const i=await n.getFileHandle(Cb(t),{create:!0}),s=await i.createWritable();await s.write(e),await s.close()}async createFile(t,e){return await this.writeFile(t,new Uint8Array),this.openFile(t,e)}async stat(t){const e=await this.getHandle(t);if(!e)throw Sb.With("ENOENT",t,"stat");if(e instanceof FileSystemDirectoryHandle)return new Gv({mode:511|Iv,size:4096});if(e instanceof FileSystemFileHandle){const{lastModified:t,size:n}=await e.getFile();return new Gv({mode:511|Tv,size:n,mtimeMs:t})}throw new Sb(vb.EBADE,"Handle is not a directory or file",t,"stat")}async openFile(t,e){const n=await this.getHandle(t);if(!(n instanceof FileSystemFileHandle))throw Sb.With("EISDIR",t,"openFile");const i=await n.getFile().catch((e=>{throw jR(e,t,"openFile")})),s=new Uint8Array(await i.arrayBuffer()),r=new Gv({mode:511|Tv,size:i.size,mtimeMs:i.lastModified});return new nw(this,t,e,r,s)}async unlink(t){const e=await this.getHandle(Mb(t));if(!(e instanceof FileSystemDirectoryHandle))throw Sb.With("ENOTDIR",Mb(t),"unlink");await e.removeEntry(Cb(t),{recursive:!0}).catch((e=>{throw jR(e,t,"unlink")}))}async link(t){}async rmdir(t){return this.unlink(t)}async mkdir(t){if(await this.getHandle(t).catch((t=>{if("ENOENT"!=t.code)throw t})))throw Sb.With("EEXIST",t,"mkdir");const e=await this.getHandle(Mb(t));if(!(e instanceof FileSystemDirectoryHandle))throw Sb.With("ENOTDIR",t,"mkdir");await e.getDirectoryHandle(Cb(t),{create:!0})}async readdir(t){const e=await this.getHandle(t);if(!(e instanceof FileSystemDirectoryHandle))throw Sb.With("ENOTDIR",t,"readdir");const n=[];for await(const t of e.keys())n.push(t);return n}async getHandle(t){if(this._handles.has(t))return this._handles.get(t);let e="/";for(const n of t.split("/").slice(1)){const t=this._handles.get(e);if(!(t instanceof FileSystemDirectoryHandle))throw Sb.With("ENOTDIR",e,"getHandle");e=Ab(e,n);const i=await t.getDirectoryHandle(n).catch((i=>{switch(i.name){case"TypeMismatchError":return t.getFileHandle(n).catch((t=>{}));case"TypeError":throw new Sb(vb.ENOENT,i.message,e,"getHandle");default:throw jR(i,e,"getHandle")}}));i&&this._handles.set(e,i)}return this._handles.get(t)}}function KR(t){return new Promise(((e,n)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>n(t.error)}))}let QR;function JR(){return QR||(QR=function(t,e){const n=indexedDB.open(t);n.onupgradeneeded=()=>n.result.createObjectStore(e);const i=KR(n);return(t,n)=>i.then((i=>n(i.transaction(e,t).objectStore(e))))}("keyval-store","keyval")),QR}class ZR extends qR{constructor(t){super(t)}async readFile(t){const e=await this.getHandle(t);if(e instanceof window.FileSystemFileHandle){const t=await e.getFile();return await t.text()}return""}}class tO extends Zt.FS{#t=null;#e=new TextEncoder;constructor(){super()}async showDirectoryPicker(){const t=await window.showDirectoryPicker({mode:"readwrite"});if("granted"!==await t.requestPermission({mode:"readwrite"}))throw new Error("readwrite access to directory not granted");return await this.setFSCache(t),this.#t=new ZR(t),t}async loadFS(){let t=await this.getFSCache();if(!t)return null;if("granted"!==await t.requestPermission({mode:"readwrite"}))throw new Error("readwrite access to directory not granted");return this.#t=new ZR(t),t}async getFSCache(){return function(t,e=JR()){return e("readonly",(e=>KR(e.get(t))))}("mixly-pyodide-fs")}async setFSCache(t){await function(t,e,n=JR()){return n("readwrite",(n=>(n.put(e,t),KR(n.transaction))))}("mixly-pyodide-fs",t)}async createFile(t){return this.#t.createFile(t,"")}async readFile(t){return this.#t.readFile(t)}async writeFile(t,e){const n=this.#e.encode(e);return this.#t.writeFile(t,n)}async isFile(t){const e=await this.#t.stat(t);return!(!e||33279!==e.mode)}async renameFile(t,e){return await this.#t.rename(t,e)}async moveFile(t,e){return this.renameFile(t,e)}async deleteFile(t){return this.#t.unlink(t)}async createDirectory(t){return this.#t.mkdir(t,511)}async readDirectory(t){return await this.#t.readdir(t)}async isDirectory(t){const e=await this.#t.stat(t);return!(!e||16895!==e.mode)}async isDirectoryEmpty(t){const e=await this.readDirectory(t);return!e?.length}async renameDirectory(t,e){return this.#t.rename(t,e)}async moveDirectory(t,e){return this.#t.rename(t,e)}async deleteDirectory(t){return this.#t.rmdir(t)}}class eO extends Zt.FileTree{constructor(){super(new tO)}async readFolder(t){let e=[];try{const n=this.getFS();if(!await n.isDirectory(t))return e;const i=await n.readDirectory(t);for(let s of i){const i=cb.join(t,s);if(await n.isDirectory(i)){const t=await n.isDirectoryEmpty(i);e.push({type:"folder",id:i,children:!t,title:`/${this.getRootFolderName()}${i}`})}else e.push({type:"file",id:i,children:!1,title:`/${this.getRootFolderName()}${i}`})}}catch(t){Zt.Debug.error(t)}return e}}class nO extends Zt.PageBase{static{Zt.HTMLTemplate.add("html/statusbar/statusbar-filesystem.html",new Zt.HTMLTemplate('<style>\r\n div[m-id="{{d.mId}}"] {\r\n display: flex;\r\n flex-direction: row;\r\n align-items: center;\r\n }\r\n\r\n div[m-id="{{d.mId}}"] > .file-tree {\r\n width: 15%;\r\n height: 100%;\r\n border-right-width: 1px;\r\n border-right-style: solid;\r\n }\r\n\r\n html[data-bs-theme=light] div[m-id="{{d.mId}}"] > .file-tree {\r\n border-right-color: #c9c9c9;\r\n }\r\n\r\n html[data-bs-theme=dark] div[m-id="{{d.mId}}"] > .file-tree {\r\n border-right-color: rgba(128, 128, 128, 0.35);\r\n }\r\n\r\n div[m-id="{{d.mId}}"] > .editor {\r\n width: 85%;\r\n height: 100%;\r\n }\r\n</style>\r\n<div m-id="{{d.mId}}" class="page-item">\r\n <div class="file-tree"></div>\r\n <div class="editor"></div>\r\n</div>')),Zt.HTMLTemplate.add("html/statusbar/statusbar-filesystem-open-fs.html",new Zt.HTMLTemplate('<style>\r\n div[m-id="{{d.mId}}"] {\r\n width: 100%;\r\n height: 100%;\r\n position: relative;\r\n display: flex;\r\n flex-direction: row;\r\n justify-content: center;\r\n }\r\n\r\n div[m-id="{{d.mId}}"] > button {\r\n margin: 15px;\r\n max-width: 200px;\r\n width: 100%;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n color: #fff !important;\r\n height: 25px;\r\n border-radius: 3px;\r\n }\r\n</style>\r\n<div m-id="{{d.mId}}">\r\n <button class="layui-btn layui-btn-xs m-btn self-adaption-btn">{{ d.msg.loadFS }}</button>\r\n</div>')),Zt.HTMLTemplate.add("html/statusbar/statusbar-filesystem-editor-empty.html",new Zt.HTMLTemplate('<style>\r\n div[m-id="{{d.mId}}"] {\r\n display: flex;\r\n flex-direction: row;\r\n align-items: center;\r\n justify-content: center;\r\n }\r\n\r\n div[m-id="{{d.mId}}"] > div {\r\n width: 150px;\r\n height: 150px;\r\n }\r\n\r\n html[data-bs-theme=light] div[m-id="{{d.mId}}"] > div {\r\n background: url(\'../common/css/svg/empty/empty-light.svg\');\r\n background-size: 100% auto;\r\n }\r\n\r\n html[data-bs-theme=dark] div[m-id="{{d.mId}}"] > div {\r\n background: url(\'../common/css/svg/empty/empty-dark.svg\');\r\n background-size: 100% auto;\r\n }\r\n</style>\r\n<div m-id="{{d.mId}}" class="page-item">\r\n <div></div>\r\n</div>')),this.init=function(){Zt.StatusBarsManager.typesRegistry.register(["file-system"],nO);const t=Zt.Workspace.getMain().getStatusBarsManager();return t.add({type:"file-system",id:"file-system",name:Jt.Msg.PYTHON_PYODIDE_FILE_SYSTEM,title:Jt.Msg.PYTHON_PYODIDE_FILE_SYSTEM}),t.changeTo("output"),t.get("file-system")}}#n=null;#i=null;#s=null;#r=null;#a=null;#o=null;#l=null;#u=null;#h=!1;#p=!1;#c=!1;#d=null;constructor(){super();const t=fb()(Zt.HTMLTemplate.get("html/statusbar/statusbar-filesystem.html").render());this.setContent(t),this.#l=new eO,this.#i=t.children(".file-tree"),this.#r=fb()(Zt.HTMLTemplate.get("html/statusbar/statusbar-filesystem-open-fs.html").render({msg:{loadFS:Jt.Msg.PYTHON_PYODIDE_LOAD_FILE_SYSTEM}})),this.#i.append(this.#r),this.#o=new Zt.StatusBar,this.#s=t.children(".editor"),this.#a=fb()(Zt.HTMLTemplate.get("html/statusbar/statusbar-filesystem-editor-empty.html").render()),this.#s.append(this.#a)}#f(){this.#u=new Zt.DragV(this.getContent()[0],{min:"150px",startSize:"15%",full:[!1,!1]}),this.#u.bind("sizeChanged",(()=>{this.resize()})),this.#r.children("button").click((()=>{this.selectFS().catch(Zt.Debug.error)})),this.#l.bind("beforeSelectLeaf",(t=>{const e=t[0].id,n=this.#o.getFileMode(cb.extname(e));return n?(this.#o.setMode(n),!0):(bb.layer.msg(Zt.Msg.Lang["statusbar.ampy.cannotEdit"],{time:1e3}),!1)})),this.#l.bind("afterSelectLeaf",(async t=>{const e=t[0].id;this.#l.showProgress();const n=this.#l.getFS();try{const t=await n.readFile(e);this.showEditor(),this.#o.setValue(t),this.#o.scrollToTop(),this.#o.focus(),this.setStatus(!1)}catch(t){Zt.Debug.error(t),this.hideEditor(),this.#l.deselectAll()}this.#l.hideProgress()})),this.#l.bind("afterCreateNode",(t=>{this.#l.refreshFolder(t)})),this.#l.bind("afterDeleteNode",(t=>{this.#l.refreshFolder(t)})),this.#l.bind("afterRenameNode",(t=>{this.#l.refreshFolder(t)})),this.#l.bind("afterRefreshNode",(()=>{this.#l.getSelectedNodeId()||this.hideEditor()}));const t=this.#l.getContextMenu().getItem("menu");t.add({weight:7,id:"copy_path",data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["fileTree.copyPath"]),callback:(t,{$trigger:e})=>{let n=null;n="root"===e.attr("type")?this.#l.getRootFolderTitle():e.attr("title"),navigator.clipboard.writeText(n).catch(Zt.Debug.error)}}}),t.add({weight:14,id:"sep5",preconditionFn:t=>{const e=this.#l.getSelectedNodeId();let n=t.attr("type"),i=t.attr("id");return"file"!==n||e===i},data:"---------"}),t.add({weight:15,id:"refresh",preconditionFn:t=>{const e=this.#l.getSelectedNodeId();let n=t.attr("type"),i=t.attr("id");return"file"!==n||e===i},data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["statusbar.ampy.refresh"]),callback:(t,{$trigger:e})=>{let n=e.attr("type");if("root"===n)this.#l.openRootFolder(),this.#l.refreshFolder("/");else if("folder"===n){let t=e.attr("id");this.#l.openNode(t),this.#l.refreshFolder(t)}else{const t=this.#l.getSelectedNodes();this.#l.runEvent("afterSelectLeaf",t)}}}}),t.add({weight:16,id:"sep6",preconditionFn:t=>{let e=t.attr("type");return["root"].includes(e)},data:"---------"}),t.add({weight:17,id:"exit",preconditionFn:t=>{let e=t.attr("type");return["root"].includes(e)},data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["statusbar.ampy.exit"]),callback:()=>{this.closeFS()}}}),t.remove("copy"),t.remove("cut"),t.remove("paste"),t.remove("sep2");const e=this.#o.getContextMenu().getItem("code");e.empty(),e.add({weight:0,id:"cut",data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["editor.contextMenu.cut"],"Ctrl+X"),callback:()=>this.#o.cut()}}),e.add({weight:1,id:"copy",data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["editor.contextMenu.copy"],"Ctrl+C"),callback:()=>this.#o.copy()}}),e.add({weight:2,id:"paste",data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["editor.contextMenu.paste"],"Ctrl+V"),callback:()=>this.#o.paste()}}),e.add({weight:3,id:"sep1",data:"---------"}),e.add({weight:4,id:"togglecomment",data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["editor.contextMenu.togglecomment"],"Ctrl+/"),callback:()=>this.#o.commentLine()}}),e.add({weight:6,id:"sep2",preconditionFn:()=>this.#c,data:"---------"}),e.add({weight:7,id:"save",preconditionFn:()=>this.#c,data:{isHtmlName:!0,name:Zt.Menu.getItem(Zt.Msg.Lang["file.save"],"Ctrl+S"),callback:async()=>{await this.put()}}});const{commands:n}=this.#o.getEditor();n.addCommand({name:"save",bindKey:"Ctrl-S",exec:async()=>{this.#c&&await this.put()}})}async put(){this.#l.showProgress();const t=this.#l.getSelectedNodeId(),e=this.#l.getFS();try{await e.writeFile(t,this.#o.getValue()),this.setStatus(!1)}catch(t){Zt.Debug.error(t)}finally{this.#l.hideProgress()}}showFileTree(){this.#h||(this.#r.detach(),this.#i.empty(),this.#i.append(this.#l.getContent()),this.#h=!0)}hideFileTree(){this.#h&&(this.#l.getContent().detach(),this.#i.empty(),this.#i.append(this.#r),this.#h=!1)}showEditor(){this.#p||(this.#a.detach(),this.#s.empty(),this.#s.append(this.#o.getContent()),this.#p=!0)}hideEditor(){this.#p&&(this.#o.getContent().detach(),this.#s.empty(),this.#s.append(this.#a),this.#p=!1,this.setStatus(!1))}getDrag(){return this.#u}init(){super.init(),this.hideCloseBtn(),this.#o.init(),this.#f();const t=this.#o.getEditor();t.setReadOnly(!1),t.renderer.setShowGutter(!0),t.setOptions({enableBasicAutocompletion:!0,enableSnippets:!0,enableLiveAutocompletion:!0,newLineMode:"unix"}),t.on("change",(()=>{this.setStatus(!0)})),this.loadFS().catch(Zt.Debug.error)}async loadFS(){const t=this.#l.getFS(),e=await t.loadFS();await this.openFS(e)}async selectFS(){const t=this.#l.getFS(),e=await t.showDirectoryPicker();await this.openFS(e)}async openFS(t){if(!t?.name)return;const e="/"+t.name;this.#l.setFolderPath("/"),this.#l.setRootFolderTitle(e),this.#l.setRootFolderName(t.name),this.#l.openRootFolder(),this.showFileTree(),this.#d=await window.pyodide.mountNativeFS(e,t)}closeFS(){const t=this.#l.getRootFolderTitle();if(Object.keys(window.pyodide.FS.root.contents).includes(cb.basename(t))){const e=window.pyodide.FS.lookupPath(t,{follow_mount:!1});window.pyodide.FS.isMountpoint(e.node)&&window.pyodide.FS.unmount(t)}this.#l.getFS().setFSCache(null),this.#l.deselectAll(),this.hideFileTree(),this.hideEditor(),this.setStatus(!1)}onMounted(){super.onMounted(),this.#o.onMounted(),this.#l.onMounted()}onUnmounted(){super.onUnmounted(),this.#o.onUnmounted(),this.#l.onUnmounted()}resize(){super.resize(),this.#o.resize(),this.#l.resize()}setStatus(t){this.#c!==t&&(this.#c=t)}getNativeFS(){return this.#d}dispose(){this.#o.dispose(),this.#o=null,this.#l.dispose(),this.#l=null,super.dispose()}}class iO{static{Zt.HTMLTemplate.add("html/statusbar/loader.html",new Zt.HTMLTemplate('<style>\r\n div[m-id="{{d.mId}}"] {\r\n display: flex;\r\n flex-direction: row;\r\n justify-content: center;\r\n align-items: center;\r\n position: absolute;\r\n background-color: transparent !important;\r\n font-size: 12px;\r\n line-height: 12px;\r\n color: #fff;\r\n bottom: 0;\r\n height: var(--footer-height);\r\n width: 100%;\r\n }\r\n\r\n div[m-id="{{d.mId}}"] > p {\r\n margin-left: 5px;\r\n }\r\n</style>\r\n<div m-id="{{d.mId}}">\r\n <div class="ui mini active inline slow loader"></div>\r\n <p>{{d.msg.loading}}</p>\r\n</div>')),this.pythonShell=null,this.kernelLoaded=!1,this.$loader=fb()(Zt.HTMLTemplate.get("html/statusbar/loader.html").render({msg:{loading:Jt.Msg.PYTHON_PYODIDE_LOADING}})),this.statusBarImage=null,this.statusBarFileSystem=null,this.init=async function(){Zt.app.getFooterBar().getContent().after(this.$loader);const t=cb.relative(Zt.Env.indexDirPath,Zt.Env.boardDirPath),e=new Ib({rootPath:cb.join(t,"deps"),language:"python3"}),n=await e.kernelAvailable();n&&(await n.init(),await n.loaded(),this.loader=e,this.kernel=n,this.statusBarImage=Eb.init(),this.statusBarFileSystem=nO.init(),this.pythonShell=new iO,this.pyodide=window.pyodide,this.interruptBuffer=new Uint8Array(new ArrayBuffer(1)),this.pyodide.setInterruptBuffer(this.interruptBuffer),this.kernelLoaded=!0,this.$loader.remove(),this.$loader=null)},this.run=async function(){if(!this.kernelLoaded)return;const t=Zt.Workspace.getMain().getEditorsManager().getActive().getCode();return this.pythonShell.run(t)},this.stop=async function(){if(this.kernelLoaded)return this.pythonShell.stop()}}#m=null;#g=null;#_=null;#T={row:0,column:0};#y="";#I=null;#E=null;#b=!1;#v=!1;#w=null;#S=()=>this.#x();#R=[{name:"REPL-Enter",bindKey:"Enter",exec:t=>{if(t.getSession().selection.getCursor().row===this.#T.row){const t=this.#m.getEndPos();let e=this.#m.getValueRange(this.#T,t);e=e.replace(this.#y,""),this.#I?.(e),this.#I=null,this.#E=null,this.#m.addValue("\n"),this.#O()}return!1}},{name:"REPL-ChangeEditor",bindKey:"Delete|Ctrl-X|Backspace",exec:t=>{const e=t.getSession().selection.getCursor();return e.row<this.#T.row||e.column<=this.#T.column}}];constructor(){const t=Zt.Workspace.getMain();this.#_=t.getStatusBarsManager(),this.#m=this.#_.getStatusBarById("output"),this.#g=this.#_.getStatusBarById("images"),this.#w=iO.kernel,this.#f()}#f(){this.#w.addEventListener("eval.finished",(()=>{this.#v=!1,this.#m.addValue(`\n==${Zt.Msg.Lang["shell.finish"]}==`),this.syncfs(!1).catch(Zt.Debug.error)})),this.#w.addEventListener("eval.output",(t=>{this.#m.addValue(t.content)})),this.#w.addEventListener("eval.error",(()=>{this.#v=!1,this.#m.addValue(`\n==${Zt.Msg.Lang["shell.finish"]}==`)})),this.#w.addEventListener("eval.input",(t=>{const e=String(t?.content?.prompt);this.#m.addValue(e),this.#y=e,this.#I=t.resolve,this.#E=t.reject,this.#A()})),this.#w.addEventListener("eval.display",(t=>{this.#_.changeTo("images"),this.#g.display(t)}))}#x(){const t=this.#m.getEditor(),e=t.getSession().selection.getCursor();t.setReadOnly(e.row<this.#T.row||e.column<this.#T.column)}#A(){if(!this.#v)return;this.#b=!0,this.#T=this.#m.getEndPos();const t=this.#m.getEditor();t.setReadOnly(!1),t.focus();t.getSession().selection.on("changeCursor",this.#S),t.commands.addCommands(this.#R)}#O(){this.#b=!1;const t=this.#m.getEditor();t.getSession().selection.off("changeCursor",this.#S),t.commands.removeCommands(this.#R),this.#y="",this.#I?.(""),this.cursor_={row:0,column:0},t.setReadOnly(!0)}async run(t){await this.stop(),await this.syncfs(!0),-1!==t.indexOf("import turtle")&&(t+="\nturtle.done()\n"),-1!==t.indexOf("import matplotlib.pyplot")&&(t+="\nplt.clf()\n"),Tb.runit(this.#g.getContent()[0]),-1!==t.indexOf("import sprite")||-1!==t.indexOf("from sprite import")?this.#_.changeTo("images"):this.#_.changeTo("output"),this.#_.show(),this.#m.setValue(`${Zt.Msg.Lang["shell.running"]}...\n`),this.#v=!0,this.#w.dispatchEvent("eval.request",{code:t,interactive:!1})}async stop(){if(this.#b&&this.#O(),this.#v){const t=5;iO.interruptBuffer[0]=2;const e=Number(new Date);for(;Number(new Date)-e<1e3*t&&this.#v;)iO.interruptBuffer[0]=2,await this.sleep(100);this.#v=!1}}async syncfs(t=!1){return new Promise((e=>{window.pyodide.FS.syncfs(t,e)}))}sleep(t){return new Promise((e=>setTimeout(e,t)))}}const sO={init:async function(){const t=Zt.app.getNav();t.register({icon:"icon-play-circled",title:"",id:"python-run-btn",displayText:Jt.Msg.MSG.run,preconditionFn:()=>!0,callback:()=>{iO.run().catch(Zt.Debug.error)},scopeType:Zt.Nav.Scope.LEFT,weight:4}),t.register({icon:"icon-cancel",title:"",id:"python-stop-btn",displayText:Jt.Msg.MSG.stop,preconditionFn:()=>!0,callback:()=>{iO.stop().catch(Zt.Debug.error)},scopeType:Zt.Nav.Scope.LEFT,weight:5}),await iO.init()}},rO=sO;class aO{constructor(t,e){this.backend=t,this.dataMover=e,this.data=new WeakMap,this.dataIdsCount=0}get(t){return this.data.has(t)||this.dataMover.moveData(this.backend,t),this.data.get(t)}set(t,e){this.dataIdsCount++,this.data.set(t,e)}has(t){return this.data.has(t)}delete(t){return this.dataIdsCount--,this.data.delete(t)}numDataIds(){return this.dataIdsCount}}class oO{refCount(t){return lO("refCount")}incRef(t){return lO("incRef")}timerAvailable(){return!0}time(t){return lO("time")}read(t){return lO("read")}readSync(t){return lO("readSync")}readToGPU(t,e){return lO("readToGPU")}numDataIds(){return lO("numDataIds")}disposeData(t,e){return lO("disposeData")}write(t,e,n){return lO("write")}move(t,e,n,i,s){return lO("move")}createTensorFromGPUData(t,e,n){return lO("createTensorFromGPUData")}memory(){return lO("memory")}floatPrecision(){return lO("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return lO("dispose")}}function lO(t){throw new Error(`'${t}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function uO(t){let e=t.length,n=0;for(;e>0;)n=Math.random()*e|0,e--,dO(t,e,n)}function hO(t,e){if(t.length!==e.length)throw new Error(`Array sizes must match to be shuffled together First array length was ${t.length}Second array length was ${e.length}`);let n=t.length,i=0;for(;n>0;)i=Math.random()*n|0,n--,dO(t,n,i),dO(e,n,i)}function pO(t,e,n){return Math.max(t,Math.min(e,n))}function cO(t){return t%2==0?t:t+1}function dO(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function fO(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n];return e}function mO(t,e){const n=Math.random();return e*n+(1-n)*t}function gO(t,e){let n=0;for(let i=0;i<t.length;i++){const s=Number(t[i])-Number(e[i]);n+=s*s}return n}function _O(t,e){if(!t)throw new Error("string"==typeof e?e:e())}function TO(t,e,n=""){_O(vO(t,e),(()=>n+` Shapes ${t} and ${e} must match`))}function yO(t){_O(null!=t,(()=>"The input to the tensor constructor must be a non-null value."))}function IO(t){if(0===t.length)return 1;let e=t[0];for(let n=1;n<t.length;n++)e*=t[n];return e}function EO(t){return 0===t.length}function bO(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(null!==t[n]&&null!==e[n]&&t[n]!==e[n])return!1;return!0}function vO(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function wO(t){return t%1==0}function SO(t){if(null!=Math.tanh)return Math.tanh(t);if(t===1/0)return 1;if(t===-1/0)return-1;{const e=Math.exp(2*t);return(e-1)/(e+1)}}function xO(t){const e=Math.ceil(Math.sqrt(t));return[e,Math.ceil(t/e)]}function RO(t){const e=new Uint32Array(t);for(let n=0;n<t;++n)e[n]=n;return uO(e),e}function OO(t,e){return e<=t.length?t:t+" ".repeat(e-t.length)}function AO(t,e=t=>0,n,i){return new Promise(((s,r)=>{let a=0;const o=()=>{if(t())return void s();a++;const l=e(a);null!=n&&a>=n?r():null!=i?i(o,l):setTimeout(o,l)};o()}))}function MO(t,e){let n=1,i=-1;for(let e=0;e<t.length;++e)if(t[e]>=0)n*=t[e];else if(-1===t[e]){if(-1!==i)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${i} and dim ${e}`);i=e}else if(t[e]<0)throw Error(`Shapes can not be < 0. Found ${t[e]} at dim ${e}`);if(-1===i){if(e>0&&e!==n)throw Error(`Size(${e}) must match the product of shape ${t}`);return t}if(0===n)throw Error(`Cannot infer the missing size in [${t}] when there are 0 elements`);if(e%n!=0)throw Error(`The implicit shape can't be a fractional number. Got ${e} / ${n}`);const s=t.slice();return s[i]=e/n,s}function CO(t,e){const n=e.length;return _O((t=null==t?e.map(((t,e)=>e)):[].concat(t)).every((t=>t>=-n&&t<n)),(()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${t}`)),_O(t.every((t=>wO(t))),(()=>`All values in axis param must be integers but got axis ${t}`)),t.map((t=>t<0?n+t:t))}function NO(t,e){const n=[],i=[],s=null!=e&&Array.isArray(e)&&0===e.length,r=null==e||s?null:CO(e,t).sort();let a=0;for(let e=0;e<t.length;++e){if(null!=r){if(r[a]===e&&1!==t[e])throw new Error(`Can't squeeze axis ${e} since its dim '${t[e]}' is not 1`);(null==r[a]||r[a]>e)&&1===t[e]&&(n.push(t[e]),i.push(e)),r[a]<=e&&a++}1!==t[e]&&(n.push(t[e]),i.push(e))}return{newShape:n,keptDims:i}}function kO(t,e){return DO(t,e)}function DO(t,e){let n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else if("bool"===t)n=new Uint8Array(e);else{if("string"!==t)throw new Error(`Unknown data type ${t}`);n=new Array(e)}return n}function LO(t,e){for(let n=0;n<t.length;n++){const i=t[n];if(isNaN(i)||!isFinite(i))throw Error(`A tensor of type ${e} being uploaded contains ${i}.`)}}function FO(t){return"bool"===t||"complex64"===t||"float32"===t||"int32"===t||"string"===t}function PO(t,e){return"complex64"!==e&&(("float32"!==e||"complex64"===t)&&(("int32"!==e||"float32"===t||"complex64"===t)&&("bool"!==e||"bool"!==t)))}function $O(t){if("float32"===t||"int32"===t)return 4;if("complex64"===t)return 8;if("bool"===t)return 1;throw new Error(`Unknown dtype ${t}`)}function BO(t){if(null==t)return 0;let e=0;return t.forEach((t=>e+=t.length)),e}function VO(t){return"string"==typeof t||t instanceof String}function UO(t){return"boolean"==typeof t}function YO(t){return"number"==typeof t}function GO(t){return Array.isArray(t)?GO(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray?"int32":YO(t)?"float32":VO(t)?"string":UO(t)?"bool":"float32"}function HO(t){return!!(t&&t.constructor&&t.call&&t.apply)}function WO(t,e){for(let n=e;n<t;++n)if(t%n==0)return n;return t}function zO(t){const e=t.length;if(e<2)return[];const n=new Array(e-1);n[e-2]=t[e-1];for(let i=e-3;i>=0;--i)n[i]=n[i+1]*t[i+1];return n}function XO(t,e,n,i=!1){const s=new Array;if(1===e.length){const r=e[0]*(i?2:1);for(let e=0;e<r;e++)s[e]=n[t+e]}else{const r=e[0],a=e.slice(1),o=a.reduce(((t,e)=>t*e))*(i?2:1);for(let e=0;e<r;e++)s[e]=XO(t+e*o,a,n,i)}return s}function jO(t,e,n=!1){if(0===t.length)return e[0];const i=t.reduce(((t,e)=>t*e))*(n?2:1);if(0===i)return[];if(i!==e.length)throw new Error(`[${t}] does not match the input size ${e.length}${n?" for a complex tensor":""}.`);return XO(0,t,e,n)}function qO(t,e){if(Array.isArray(t))return t;if("float32"===e)return t instanceof Float32Array?t:new Float32Array(t);if("int32"===e)return t instanceof Int32Array?t:new Int32Array(t);if("bool"===e||"string"===e)return Uint8Array.from(new Int32Array(t));throw new Error(`Unknown dtype ${e}`)}function KO(t,e){const n=QO(t,e);for(let t=0;t<n.length;t++)n[t]=1;return n}function QO(t,e){if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e)return new Uint8Array(t);throw new Error(`Unknown data type ${e}`)}function JO(t,e){const n=t.reduce(((t,e)=>t*e),1);if(null==e||"float32"===e)return jO(t,new Float32Array(n));if("int32"===e)return jO(t,new Int32Array(n));if("bool"===e)return jO(t,new Uint8Array(n));throw new Error(`Unknown data type ${e}`)}function ZO(t){t.forEach((e=>{_O(Number.isInteger(e)&&e>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${t}].`))}))}function tA(t,e,n){if(0===e)return 0;if(1===e)return t[0];let i=t[t.length-1];for(let e=0;e<t.length-1;++e)i+=n[e]*t[e];return i}function eA(t,e,n){if(0===e)return[];if(1===e)return[t];const i=new Array(e);for(let e=0;e<i.length-1;++e)i[e]=Math.floor(t/n[e]),t-=i[e]*n[e];return i[i.length-1]=t,i}function nA(t){return t&&t.then&&"function"==typeof t.then}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const iA="tfjsflags";class sA{constructor(t){this.global=t,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=rA,this.populateURLFlags()}setPlatform(t,e){null!=this.platform&&(aA().getBool("IS_TEST")||aA().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${t}.`)),this.platformName=t,this.platform=e}registerFlag(t,e,n){if(this.flagRegistry[t]={evaluationFn:e,setHook:n},null!=this.urlFlags[t]){const e=this.urlFlags[t];aA().getBool("IS_TEST")||aA().getBool("PROD")||console.warn(`Setting feature override from URL ${t}: ${e}.`),this.set(t,e)}}async getAsync(t){return t in this.flags||(this.flags[t]=await this.evaluateFlag(t)),this.flags[t]}get(t){if(t in this.flags)return this.flags[t];const e=this.evaluateFlag(t);if(nA(e))throw new Error(`Flag ${t} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[t]=e,this.flags[t]}getNumber(t){return this.get(t)}getBool(t){return this.get(t)}getString(t){return this.get(t)}getFlags(){return this.flags}get features(){return this.flags}set(t,e){if(null==this.flagRegistry[t])throw new Error(`Cannot set flag ${t} as it has not been registered.`);this.flags[t]=e,null!=this.flagRegistry[t].setHook&&this.flagRegistry[t].setHook(e)}evaluateFlag(t){if(null==this.flagRegistry[t])throw new Error(`Cannot evaluate flag '${t}': no evaluation function found.`);return this.flagRegistry[t].evaluationFn()}setFlags(t){this.flags=Object.assign({},t)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;const t=this.getQueryParams(this.global.location.search);if(iA in t){t[iA].split(",").forEach((t=>{const[e,n]=t.split(":");this.urlFlags[e]=function(t,e){const n=e.toLowerCase();return"true"===n||"false"===n?"true"===n:""+ +n===n?+n:e}(0,n)}))}}}function rA(t){const e={};return t.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((t,...n)=>(function(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"")}(e,n[0],n[1]),n.join("=")))),e}function aA(){return lA}let oA,lA=null;function uA(){if(null==oA){let t;if("undefined"!=typeof window)t=window;else if(void 0!==__webpack_require__.g)t=__webpack_require__.g;else if("undefined"!=typeof process)t=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");t=self}oA=t}return oA}function hA(t,e){const n=function(){const t=uA();return null==t._tfGlobals&&(t._tfGlobals=new Map),t._tfGlobals}();if(n.has(t))return n.get(t);{const i=e();return n.set(t,i),n.get(t)}}const pA="Abs",cA="Acos",dA="Acosh",fA="Add",mA="AddN",gA="All",_A="Any",TA="ArgMax",yA="ArgMin",IA="Asin",EA="Asinh",bA="Atan",vA="Atanh",wA="Atan2",SA="AvgPool",xA="AvgPoolGrad",RA="AvgPool3D",OA="AvgPool3DGrad",AA="BatchMatMul",MA="BatchToSpaceND",CA="Bincount",NA="BitwiseAnd",kA="BroadcastTo",DA="BroadcastArgs",LA="Cast",FA="Ceil",PA="ClipByValue",$A="Complex",BA="ComplexAbs",VA="Concat",UA="Conv2D",YA="Conv2DBackpropFilter",GA="Conv2DBackpropInput",HA="Conv3D",WA="Conv3DBackpropFilterV2",zA="Conv3DBackpropInputV2",XA="Cos",jA="Cosh",qA="Cumprod",KA="Cumsum",QA="CropAndResize",JA="DenseBincount",ZA="DepthToSpace",tM="DepthwiseConv2dNative",eM="DepthwiseConv2dNativeBackpropFilter",nM="DepthwiseConv2dNativeBackpropInput",iM="Diag",sM="Dilation2D",rM="Dilation2DBackpropInput",aM="Dilation2DBackpropFilter",oM="Draw",lM="RealDiv",uM="Einsum",hM="Elu",pM="EluGrad",cM="Erf",dM="Equal",fM="Exp",mM="ExpandDims",gM="Expm1",_M="FFT",TM="Fill",yM="FlipLeftRight",IM="Floor",EM="FloorDiv",bM="FusedBatchNorm",vM="GatherV2",wM="GatherNd",SM="Greater",xM="GreaterEqual",RM="Identity",OM="IFFT",AM="Imag",MM="IsFinite",CM="IsInf",NM="IsNan",kM="LeakyRelu",DM="Less",LM="LessEqual",FM="LinSpace",PM="Log",$M="Log1p",BM="LogicalAnd",VM="LogicalNot",UM="LogicalOr",YM="LogicalXor",GM="LogSoftmax",HM="LowerBound",WM="LRN",zM="LRNGrad",XM="MatrixBandPart",jM="Max",qM="Maximum",KM="MaxPool",QM="MaxPoolGrad",JM="MaxPool3D",ZM="MaxPool3DGrad",tC="MaxPoolWithArgmax",eC="Mean",nC="Min",iC="Minimum",sC="MirrorPad",rC="Mod",aC="Multinomial",oC="Multiply",lC="Neg",uC="NotEqual",hC="NonMaxSuppressionV3",pC="NonMaxSuppressionV4",cC="NonMaxSuppressionV5",dC="OnesLike",fC="OneHot",mC="Pack",gC="PadV2",_C="Pool",TC="Pow",yC="Prelu",IC="Prod",EC="RaggedGather",bC="RaggedRange",vC="RaggedTensorToTensor",wC="Range",SC="Real",xC="Reciprocal",RC="Relu",OC="Reshape",AC="ResizeNearestNeighbor",MC="ResizeNearestNeighborGrad",CC="ResizeBilinear",NC="ResizeBilinearGrad",kC="Relu6",DC="Reverse",LC="Round",FC="Rsqrt",PC="ScatterNd",$C="TensorScatterUpdate",BC="SearchSorted",VC="Select",UC="Selu",YC="Slice",GC="Sin",HC="Sinh",WC="Sign",zC="Sigmoid",XC="Softplus",jC="Sqrt",qC="Sum",KC="SpaceToBatchND",QC="SplitV",JC="Softmax",ZC="SparseFillEmptyRows",tN="SparseReshape",eN="SparseSegmentMean",nN="SparseSegmentSum",iN="SparseToDense",sN="SquaredDifference",rN="Square",aN="StaticRegexReplace",oN="StridedSlice",lN="StringNGrams",uN="StringSplit",hN="StringToHashBucketFast",pN="Sub",cN="Tan",dN="Tanh",fN="Tile",mN="TopK",gN="Transform",_N="Transpose",TN="Unique",yN="Unpack",IN="UnsortedSegmentSum",EN="UpperBound",bN="ZerosLike",vN="Step",wN="FromPixels",SN="RotateWithOffset",xN="_FusedMatMul",RN="FusedConv2D",ON="FusedDepthwiseConv2D";
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function AN(...t){aA().getBool("IS_TEST")||aA().getBool("PROD")||console.warn(...t)}function MN(...t){aA().getBool("IS_TEST")||aA().getBool("PROD")||console.log(...t)}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const CN=hA("kernelRegistry",(()=>new Map)),NN=hA("gradRegistry",(()=>new Map));function kN(t,e){const n=UN(t,e);return CN.get(n)}function DN(t){return NN.get(t)}function LN(t){const e=CN.entries(),n=[];for(;;){const{done:i,value:s}=e.next();if(i)break;const[r,a]=s,[o]=r.split("_");o===t&&n.push(a)}return n}function FN(t){const{kernelName:e,backendName:n}=t,i=UN(e,n);CN.has(i)&&AN(`The kernel '${e}' for backend '${n}' is already registered`),CN.set(i,t)}function PN(t){const{kernelName:e}=t;NN.has(e)&&aA().getBool("DEBUG")&&AN(`Overriding the gradient for '${e}'`),NN.set(e,t)}function $N(t,e){const n=UN(t,e);if(!CN.has(n))throw new Error(`The kernel '${t}' for backend '${e}' is not registered`);CN.delete(n)}function BN(t){if(!NN.has(t))throw new Error(`The gradient '${t}' for backend is not registered`);NN.delete(t)}function VN(t,e){LN(t).forEach((t=>{FN(Object.assign({},t,{backendName:e}))}))}function UN(t,e){return`${e}_${t}`}
/**
* @license
* Copyright 2023 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function YN(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray}var GN=__webpack_require__(8570);
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const HN=__webpack_require__.n(GN)()||GN;function WN(t){return HN.fromString(t,!0,16)}const zN=WN("c3a5c85c97cb3127"),XN=WN("b492b66fbe98f273"),jN=WN("9ae16a3b2f90404f");function qN(t){return t.xor(t.shru(47))}function KN(t,e,n){const i=t.slice(e,e+n);return HN.fromBytes(Array.from(i),!0,!0)}function QN(t,e){return KN(t,e,8)}function JN(t,e){return KN(t,e,4)}function ZN(t,e){return 0===e?t:t.shru(e).or(t.shl(64-e))}function tk(t,e,n=WN("9ddfea08eb382d69")){let i=t.xor(e).mul(n);i=i.xor(i.shru(47));let s=e.xor(i).mul(n);return s=s.xor(s.shru(47)),s=s.mul(n),s}function ek(t,e,n,i){return function(t,e,n,i,s,r){s=s.add(t),r=ZN(r.add(s).add(i),21);const a=s;return s=(s=s.add(e)).add(n),r=r.add(ZN(s,44)),[s.add(i),r.add(a)]}(QN(t,e),QN(t,e+8),QN(t,e+16),QN(t,e+24),n,i)}function nk(t,e=t.length){const n=HN.fromNumber(81,!0);if(e<=32)return e<=16?function(t,e=t.length){if(e>=8){const n=jN.add(2*e),i=QN(t,0).add(jN),s=QN(t,e-8);return tk(ZN(s,37).mul(n).add(i),ZN(i,25).add(s).mul(n),n)}if(e>=4){const n=jN.add(2*e);return tk(JN(t,0).shl(3).add(e),JN(t,e-4),n)}if(e>0){const n=t[0]+(t[e>>1]<<8),i=e+(t[e-1]<<2);return qN(jN.mul(n).xor(zN.mul(i))).mul(jN)}return jN}(t,e):function(t,e=t.length){const n=jN.add(2*e),i=QN(t,0).mul(XN),s=QN(t,8),r=QN(t,e-8).mul(n),a=QN(t,e-16).mul(jN);return tk(ZN(i.add(s),43).add(ZN(r,30)).add(a),i.add(ZN(s.add(jN),18)).add(r),n)}(t,e);if(e<=64)return function(t,e=t.length){const n=jN.add(2*e),i=QN(t,0).mul(jN),s=QN(t,8),r=QN(t,e-8).mul(n),a=QN(t,e-16).mul(jN),o=ZN(i.add(s),43).add(ZN(r,30)).add(a),l=tk(o,i.add(ZN(s.add(jN),18)).add(r),n),u=QN(t,16).mul(n),h=QN(t,24),p=o.add(QN(t,e-32)).mul(n),c=l.add(QN(t,e-24)).mul(n);return tk(ZN(u.add(h),43).add(ZN(p,30)).add(c),u.add(ZN(h.add(i),18)).add(p),n)}(t,e);let i=n,s=n.mul(XN).add(113),r=qN(s.mul(jN).add(113)).mul(jN),a=[HN.UZERO,HN.UZERO],o=[HN.UZERO,HN.UZERO];i=i.mul(jN).add(QN(t,0));let l=0;const u=64*(e-1>>6),h=u+(e-1&63)-63;do{i=ZN(i.add(s).add(a[0]).add(QN(t,l+8)),37).mul(XN),s=ZN(s.add(a[1]).add(QN(t,l+48)),42).mul(XN),i=i.xor(o[1]),s=s.add(a[0]).add(QN(t,l+40)),r=ZN(r.add(o[0]),33).mul(XN),a=ek(t,l,a[1].mul(XN),i.add(o[0])),o=ek(t,l+32,r.add(o[1]),s.add(QN(t,l+16))),[r,i]=[i,r],l+=64}while(l!==u);const p=XN.add(r.and(255).shl(1));return l=h,o[0]=o[0].add(e-1&63),a[0]=a[0].add(o[0]),o[0]=o[0].add(a[0]),i=ZN(i.add(s).add(a[0]).add(QN(t,l+8)),37).mul(p),s=ZN(s.add(a[1]).add(QN(t,l+48)),42).mul(p),i=i.xor(o[1].mul(9)),s=s.add(a[0].mul(9).add(QN(t,l+40))),r=ZN(r.add(o[0]),33).mul(p),a=ek(t,l,a[1].mul(p),i.add(o[0])),o=ek(t,l+32,r.add(o[1]),s.add(QN(t,l+16))),[r,i]=[i,r],tk(tk(a[0],o[0],p).add(qN(s).mul(zN)).add(r),tk(a[1],o[1],p).add(i),p)}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function ik(t,e){return"string"===e?ok(t):sk([t],e)}function sk(t,e){if("string"===e)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=hk(t)),aA().getBool("DEBUG")&&LO(t,e),function(t,e){return t instanceof Float32Array&&"float32"===e||t instanceof Int32Array&&"int32"===e||t instanceof Uint8Array&&"bool"===e}(t,e))return t;if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e){const e=new Uint8Array(t.length);for(let n=0;n<e.length;++n)0!==Math.round(t[n])&&(e[n]=1);return e}throw new Error(`Unknown data type ${e}`)}function rk(){return aA().platform.now()}function ak(t,e){return aA().platform.fetch(t,e)}function ok(t,e="utf-8"){return e=e||"utf-8",aA().platform.encode(t,e)}function lk(t,e="utf-8"){return e=e||"utf-8",aA().platform.decode(t,e)}function uk(t){return null!=aA().platform.isTypedArray?aA().platform.isTypedArray(t):YN(t)}function hk(t,e=[],n=!1){if(null==e&&(e=[]),"boolean"==typeof t||"number"==typeof t||"string"==typeof t||nA(t)||null==t||uk(t)&&n)e.push(t);else if(Array.isArray(t)||uk(t))for(let i=0;i<t.length;++i)hk(t[i],e,n);else{let i=-1;for(const e of Object.keys(t))/^([1-9]+[0-9]*|0)$/.test(e)&&(i=Math.max(i,Number(e)));for(let s=0;s<=i;s++)hk(t[s],e,n)}return e}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class pk{constructor(t,e){this.backendTimer=t,this.logger=e,null==e&&(this.logger=new dk)}profileKernel(t,e,n){let i;const s=()=>{i=n()};let r;const a=rk();if(this.backendTimer.timerAvailable())r=this.backendTimer.time(s);else{s();for(const t of i)t.dataSync();r=Promise.resolve({kernelMs:rk()-a})}if(aA().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let e=0;e<i.length;e++){const n=i[e];n.data().then((e=>{ck(e,n.dtype,t)}))}return{kernelName:t,outputs:i,inputs:e,timeMs:r.then((t=>t.kernelMs)),extraInfo:r.then((t=>null!=t.getExtraProfileInfo?t.getExtraProfileInfo():""))}}logKernelProfile(t){const{kernelName:e,outputs:n,timeMs:i,inputs:s,extraInfo:r}=t;n.forEach((t=>{Promise.all([t.data(),i,r]).then((n=>{this.logger.logKernelProfile(e,t,n[0],n[1],s,n[2])}))}))}}function ck(t,e,n){if("float32"!==e)return!1;for(let e=0;e<t.length;e++){const i=t[e];if(isNaN(i)||!isFinite(i))return console.warn(`Found ${i} in the result of '${n}'`),!0}return!1}class dk{logKernelProfile(t,e,n,i,s,r){const a="number"==typeof i?OO(`${i}ms`,9):i.error,o=OO(t,25),l=e.rank,u=e.size,h=OO(e.shape.toString(),14);let p="";for(const t in s){const n=s[t];if(null!=n){const i=n.shape||e.shape,s=i.length;p+=`${t}: ${s}D ${s>0?i:""} `}}console.log(`%c${o}\t%c${a}\t%c${l}D ${h}\t%c${u}\t%c${p}\t%c${r}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const fk=20,mk=3,gk=7;function _k(t,e,n,i){const s=zO(e),r=function(t,e,n,i){const s=IO(e),r=i[i.length-1],a=new Array(r).fill(0),o=e.length,l="complex64"===n?Ek(t):t;if(o>1)for(let t=0;t<s/r;t++){const e=t*r;for(let t=0;t<r;t++)a[t]=Math.max(a[t],Tk(l[e+t],0,n).length)}return a}(t,e,n,s),a=e.length,o=Ik(t,e,n,s,r),l=["Tensor"];return i&&(l.push(` dtype: ${n}`),l.push(` rank: ${a}`),l.push(` shape: [${e}]`),l.push(" values:")),l.push(o.map((t=>" "+t)).join("\n")),l.join("\n")}function Tk(t,e,n){let i;return i=Array.isArray(t)?`${parseFloat(t[0].toFixed(gk))} + ${parseFloat(t[1].toFixed(gk))}j`:VO(t)?`'${t}'`:"bool"===n?yk(t):parseFloat(t.toFixed(gk)).toString(),OO(i,e)}function yk(t){return 0===t?"false":"true"}function Ik(t,e,n,i,s,r=!0){const a="complex64"===n?2:1,o=e[0],l=e.length;if(0===l){if("complex64"===n){return[Tk(Ek(t)[0],0,n)]}return"bool"===n?[yk(t[0])]:[t[0].toString()]}if(1===l){if(o>fk){const e=mk*a;let i=Array.from(t.slice(0,e)),r=Array.from(t.slice((o-mk)*a,o*a));return"complex64"===n&&(i=Ek(i),r=Ek(r)),["["+i.map(((t,e)=>Tk(t,s[e],n))).join(", ")+", ..., "+r.map(((t,e)=>Tk(t,s[o-mk+e],n))).join(", ")+"]"]}return["["+("complex64"===n?Ek(t):Array.from(t)).map(((t,e)=>Tk(t,s[e],n))).join(", ")+"]"]}const u=e.slice(1),h=i.slice(1),p=i[0]*a,c=[];if(o>fk){for(let e=0;e<mk;e++){const i=e*p,r=i+p;c.push(...Ik(t.slice(i,r),u,n,h,s,!1))}c.push("...");for(let e=o-mk;e<o;e++){const i=e*p,r=i+p;c.push(...Ik(t.slice(i,r),u,n,h,s,e===o-1))}}else for(let e=0;e<o;e++){const i=e*p,r=i+p;c.push(...Ik(t.slice(i,r),u,n,h,s,e===o-1))}const d=2===l?",":"";c[0]="["+(o>0?c[0]+d:"");for(let t=1;t<c.length-1;t++)c[t]=" "+c[t]+d;let f=",\n";for(let t=2;t<l;t++)f+="\n";return c[c.length-1]=" "+c[c.length-1]+"]"+(r?"":f),c}function Ek(t){const e=[];for(let n=0;n<t.length;n+=2)e.push([t[n],t[n+1]]);return e}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class bk{constructor(t,e,n){if(this.dtype=e,this.shape=t.slice(),this.size=IO(t),null!=n){const t=n.length;_O(t===this.size,(()=>`Length of values '${t}' does not match the size inferred by the shape '${this.size}'.`))}if("complex64"===e)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||DO(e,this.size),this.strides=zO(t)}set(t,...e){0===e.length&&(e=[0]),_O(e.length===this.rank,(()=>`The number of provided coordinates (${e.length}) must match the rank (${this.rank})`));const n=this.locToIndex(e);this.values[n]=t}get(...t){0===t.length&&(t=[0]);let e=0;for(const n of t){if(n<0||n>=this.shape[e]){const e=`Requested out of range element at ${t}. Buffer shape=${this.shape}`;throw new Error(e)}e++}let n=t[t.length-1];for(let e=0;e<t.length-1;++e)n+=this.strides[e]*t[e];return this.values[n]}locToIndex(t){if(0===this.rank)return 0;if(1===this.rank)return t[0];let e=t[t.length-1];for(let n=0;n<t.length-1;++n)e+=this.strides[n]*t[n];return e}indexToLoc(t){if(0===this.rank)return[];if(1===this.rank)return[t];const e=new Array(this.shape.length);for(let n=0;n<e.length-1;++n)e[n]=Math.floor(t/this.strides[n]),t-=e[n]*this.strides[n];return e[e.length-1]=t,e}get rank(){return this.shape.length}toTensor(){return vk().makeTensor(this.values,this.shape,this.dtype)}}let vk=null,wk=null,Sk=null;class xk{constructor(t,e,n,i){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=IO(t),this.strides=zO(t),this.dataId=n,this.id=i,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const t=await this.data();return wk.buffer(this.shape,this.dtype,t)}bufferSync(){return wk.buffer(this.shape,this.dtype,this.dataSync())}async array(){const t=await this.data();return jO(this.shape,t,"complex64"===this.dtype)}arraySync(){return jO(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const t=vk().read(this.dataId);if("string"===this.dtype){const e=await t;try{return e.map((t=>lk(t)))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return t}dataToGPU(t){return this.throwIfDisposed(),vk().readToGPU(this.dataId,t)}dataSync(){this.throwIfDisposed();const t=vk().readSync(this.dataId);if("string"===this.dtype)try{return t.map((t=>lk(t)))}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return t}async bytes(){this.throwIfDisposed();const t=await vk().read(this.dataId);return"string"===this.dtype?t:new Uint8Array(t.buffer)}dispose(){this.isDisposed||(this.kerasMask&&this.kerasMask.dispose(),vk().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(t=!1){return wk.print(this,t)}clone(){return this.throwIfDisposed(),wk.clone(this)}toString(t=!1){return _k(this.dataSync(),this.shape,this.dtype,t)}cast(t){return this.throwIfDisposed(),wk.cast(this,t)}variable(t=!0,e,n){return this.throwIfDisposed(),vk().makeVariable(this,t,e,n)}}function Rk(){return hA("Tensor",(()=>xk))}Object.defineProperty(xk,Symbol.hasInstance,{value:t=>!!t&&null!=t.data&&null!=t.dataSync&&null!=t.throwIfDisposed}),Rk();class Ok extends xk{constructor(t,e,n,i){super(t.shape,t.dtype,t.dataId,i),this.trainable=e,this.name=n}assign(t){if(t.dtype!==this.dtype)throw new Error(`dtype of the new value (${t.dtype}) and previous value (${this.dtype}) must match`);if(!vO(t.shape,this.shape))throw new Error(`shape of the new value (${t.shape}) and previous value (${this.shape}) must match`);vk().disposeTensor(this),this.dataId=t.dataId,vk().incRef(this,null)}dispose(){vk().disposeVariable(this),this.isDisposedInternal=!0}}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
var Ak,Mk,Ck,Nk,kk;Object.defineProperty(Ok,Symbol.hasInstance,{value:t=>t instanceof xk&&null!=t.assign&&t.assign instanceof Function}),function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6"}(Ak||(Ak={})),function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64"}(Mk||(Mk={})),function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64"}(Ck||(Ck={})),function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64"}(Nk||(Nk={})),function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64"}(kk||(kk={}));const Dk={float32:Nk,int32:Mk,bool:Ck,complex64:kk};function Lk(t,e){if("string"===t||"string"===e){if("string"===t&&"string"===e)return"string";throw new Error(`Can not upcast ${t} with ${e}`)}return Dk[t][e]}function Fk(t){return Lk(t,"int32")}function Pk(t){return null!=t&&"object"==typeof t&&"texture"in t&&t.texture instanceof WebGLTexture}function $k(t){return"undefined"!=typeof GPUBuffer&&null!=t&&"object"==typeof t&&"buffer"in t&&t.buffer instanceof GPUBuffer}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Bk(t,e){if(t.dtype===e.dtype)return[t,e];const n=Lk(t.dtype,e.dtype);return[t.cast(n),e.cast(n)]}function Vk(t,e){_O(t.dtype===e.dtype,(()=>`The dtypes of the first(${t.dtype}) and second(${e.dtype}) input must match`))}function Uk(t,e){return e.some((e=>e.id===t.id))}function Yk(t){const e=[];return Gk(t,e,new Set),e}function Gk(t,e,n){if(null==t)return;if(t instanceof xk)return void e.push(t);if(i=t,!Array.isArray(i)&&"object"!=typeof i)return;var i;const s=t;for(const t in s){const i=s[t];n.has(i)||(n.add(i),Gk(i,e,n))}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Hk(t){return null!=t.kernelName}class Wk{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((t=>t.name))))}}}dispose(){for(const t in this.registeredVariables)this.registeredVariables[t].dispose()}}class zk{constructor(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Wk}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const t=this.getSortedBackends();for(let e=0;e<t.length;e++){const n=t[e];if(await this.initializeBackend(n).success)return void await this.setBackend(n)}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(null!=this.pendingBackendInit)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){const{name:t,asyncInit:e}=this.initializeBackendsAndReturnBest();if(e)throw new Error(`The highest priority backend '${t}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(t)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(t){if(!(t in this.registry)){if(!(t in this.registryFactory))return null;{const{asyncInit:e}=this.initializeBackend(t);if(e)return null}}return this.registry[t]}findBackendFactory(t){return t in this.registryFactory?this.registryFactory[t].factory:null}registerBackend(t,e,n=1){return t in this.registryFactory?(AN(`${t} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[t]={factory:e,priority:n},!0)}async setBackend(t){if(null==this.registryFactory[t])throw new Error(`Backend name '${t}' not found in registry`);if(this.backendName=t,null==this.registry[t]){this.backendInstance=null;const{success:e,asyncInit:n}=this.initializeBackend(t);if(!(n?await e:e))return!1}return this.backendInstance=this.registry[t],this.setupRegisteredKernels(),this.profiler=new pk(this.backendInstance),!0}setupRegisteredKernels(){LN(this.backendName).forEach((t=>{null!=t.setupFunc&&t.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(t){LN(t).forEach((e=>{null!=e.disposeFunc&&e.disposeFunc(this.registry[t])}))}initializeBackend(t){const e=this.registryFactory[t];if(null==e)throw new Error(`Cannot initialize backend ${t}, no registration found.`);try{const n=e.factory();if(!n||n instanceof oO||"function"!=typeof n.then)return this.registry[t]=n,{success:!0,asyncInit:!1};{const e=++this.pendingBackendInitId,i=n.then((n=>!(e<this.pendingBackendInitId)&&(this.registry[t]=n,this.pendingBackendInit=null,!0))).catch((n=>(e<this.pendingBackendInitId||(this.pendingBackendInit=null,AN(`Initialization of backend ${t} failed`),AN(n.stack||n.message)),!1)));return this.pendingBackendInit=i,{success:i,asyncInit:!0}}}catch(e){return AN(`Initialization of backend ${t} failed`),AN(e.stack||e.message),{success:!1,asyncInit:!1}}}removeBackend(t){if(!(t in this.registryFactory))throw new Error(`${t} backend not found in registry`);this.backendName===t&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,t in this.registry&&(this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t]),delete this.registryFactory[t],this.backendName===t&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(((t,e)=>this.registryFactory[e].priority-this.registryFactory[t].priority))}initializeBackendsAndReturnBest(){const t=this.getSortedBackends();for(let e=0;e<t.length;e++){const n=t[e],{success:i,asyncInit:s}=this.initializeBackend(n);if(s||i)return{name:n,asyncInit:s}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(t,e){const n=this.state.tensorInfo.get(e),i=n.backend,s=this.readSync(e),r=i.refCount(e);i.disposeData(e,!0),n.backend=t,t.move(e,s,n.shape,n.dtype,r),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(t,e){let n,i=null;if(null==e){if("function"!=typeof t)throw new Error("Please provide a function to tidy()");e=t}else{if("string"!=typeof t&&!(t instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof e)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");i=t}return this.scopedRun((()=>this.startScope(i)),(()=>this.endScope(n)),(()=>(n=e(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(t,e,n){t();try{const t=n();return e(),t}catch(t){throw e(),t}}nextTensorId(){return zk.nextTensorId++}nextVariableId(){return zk.nextVariableId++}clone(t){const e=jk.runKernel(RM,{x:t}),n={x:t};return this.addTapeNode(this.state.activeScope.name,n,[e],(t=>({x:()=>{const e={x:t},n={dtype:"float32"};return jk.runKernel(LA,e,n)}})),[],{}),e}runKernel(t,e,n){null==this.backendName&&this.backend;if(!(null!=kN(t,this.backendName)))throw new Error(`Kernel '${t}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:t,inputs:e,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(t,e,n){const i=this.backend.numDataIds();let s=0;n.forEach((t=>{s+="complex64"===t.dtype?3:1}));const r=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=i-e-s-r;if(a>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${a} data ids) after running '${t}'`)}runKernelFunc(t){let e,n=[];const i=this.isTapeOn(),s=this.state.numBytes,r=this.state.numTensors;let a,o;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const l=Hk(t)?t.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(Hk(t)){const{kernelName:e,inputs:s,attrs:r}=t;null==this.backendName&&this.backend;const l=kN(e,this.backendName);_O(null!=l,(()=>`Cannot find registered kernel '${e}' for backend '${this.backendName}'`)),a=()=>{const t=this.backend.numDataIds();o=l.kernelFunc({inputs:s,attrs:r,backend:this.backend});const a=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(e,t,a);const u=a.map((t=>null!=t.rank?t:this.makeTensorFromTensorInfo(t)));if(i){const t=this.getTensorsForGradient(e,s,u);n=this.saveTensorsForBackwardMode(t)}return u}}else{const{forwardFunc:e}=t,s=t=>{i&&(n=t.map((t=>this.keep(this.clone(t)))))};a=()=>{const t=this.backend.numDataIds();o=this.tidy((()=>e(this.backend,s)));const n=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(l,t,n),n}}const{inputs:u,attrs:h}=t,p=Hk(t)?null:t.backwardsFunc;let c;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(c=this.profiler.profileKernel(l,u,(()=>a())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(c),e=c.outputs):e=a()})),i&&this.addTapeNode(l,u,e,p,n,h),this.state.profiling&&this.state.activeProfile.kernels.push({name:l,bytesAdded:this.state.numBytes-s,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-r,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(u).map((t=>null!=u[t]?u[t].shape:null)),outputShapes:e.map((t=>t.shape)),kernelTimeMs:c.timeMs,extraInfo:c.extraInfo}),Array.isArray(o)?e:e[0]}saveTensorsForBackwardMode(t){const e=t.map((t=>this.keep(this.clone(t))));return e}getTensorsForGradient(t,e,n){const i=DN(t);if(null!=i){const t=i.inputsToSave||[],s=i.outputsToSave||[];let r;i.saveAllInputs?(_O(Array.isArray(e),(()=>"saveAllInputs is true, expected inputs to be an array.")),r=Object.keys(e).map((t=>e[t]))):r=t.map((t=>e[t]));const a=n.filter(((t,e)=>s[e]));return r.concat(a)}return[]}makeTensor(t,e,n,i){if(null==t)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",i=i||this.backend;let s=t;"string"===n&&VO(t[0])&&(s=t.map((t=>ok(t))));const r=i.write(s,e,n),a=new xk(e,n,r,this.nextTensorId());if(this.trackTensor(a,i),"string"===n){const t=this.state.tensorInfo.get(r),e=BO(s);this.state.numBytes+=e-t.bytes,t.bytes=e}return a}makeTensorFromDataId(t,e,n,i){const s={dataId:t,shape:e,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(s,i)}makeTensorFromTensorInfo(t,e){const{dataId:n,shape:i,dtype:s}=t,r=new xk(i,s,n,this.nextTensorId());return this.trackTensor(r,e),r}makeVariable(t,e=!0,n,i){n=n||this.nextVariableId().toString(),null!=i&&i!==t.dtype&&(t=t.cast(i));const s=new Ok(t,e,n,this.nextTensorId());if(null!=this.state.registeredVariables[s.name])throw new Error(`Variable with name ${s.name} was already registered`);return this.state.registeredVariables[s.name]=s,this.incRef(s,this.backend),s}trackTensor(t,e){this.state.numTensors++,"string"===t.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==t.dtype&&"string"!==t.dtype&&(n=t.size*$O(t.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(t.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(t.dataId,{backend:e||this.backend,dtype:t.dtype,shape:t.shape,bytes:n})),t instanceof Ok||this.track(t)}incRef(t,e){this.trackTensor(t,e),this.backend.incRef(t.dataId)}removeDataId(t,e){this.state.tensorInfo.has(t)&&this.state.tensorInfo.get(t).backend===e&&(this.state.tensorInfo.delete(t),this.state.numDataBuffers--)}disposeTensor(t){if(!this.state.tensorInfo.has(t.dataId))return;const e=this.state.tensorInfo.get(t.dataId);if(this.state.numTensors--,"string"===t.dtype&&(this.state.numStringTensors--,this.state.numBytes-=e.bytes),"complex64"!==t.dtype&&"string"!==t.dtype){const e=t.size*$O(t.dtype);this.state.numBytes-=e}e.backend.disposeData(t.dataId)&&this.removeDataId(t.dataId,e.backend)}disposeVariables(){for(const t in this.state.registeredVariables){const e=this.state.registeredVariables[t];this.disposeVariable(e)}}disposeVariable(t){this.disposeTensor(t),null!=this.state.registeredVariables[t.name]&&delete this.state.registeredVariables[t.name]}memory(){const t=this.backend.memory();return t.numTensors=this.state.numTensors,t.numDataBuffers=this.state.numDataBuffers,t.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(t.unreliable=!0,null==t.reasons&&(t.reasons=[]),t.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),t}async profile(t){this.state.profiling=!0;const e=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await t(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((t=>t.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-e,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const t of this.state.activeProfile.kernels)t.kernelTimeMs=await t.kernelTimeMs,t.extraInfo=await t.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(t,e,n,i,s,r){const a={id:this.state.nextTapeNodeId++,kernelName:t,inputs:e,outputs:n,saved:s},o=DN(t);null!=o&&(i=o.gradFunc),null!=i&&(a.gradient=t=>(t=t.map(((t,e)=>{if(null==t){const t=n[e],i=QO(t.size,t.dtype);return this.makeTensor(i,t.shape,t.dtype)}return t})),i(t.length>1?t:t[0],s,r))),this.state.activeTape.push(a)}keep(t){return t.kept=!0,t}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(t){const e={track:[],name:"unnamed scope",id:this.state.nextScopeId++};t&&(e.name=t),this.state.scopeStack.push(e),this.state.activeScope=e}endScope(t){const e=Yk(t),n=new Set(e.map((t=>t.id)));for(let t=0;t<this.state.activeScope.track.length;t++){const e=this.state.activeScope.track[t];e.kept||n.has(e.id)||e.dispose()}const i=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],e.forEach((t=>{t.kept||t.scopeId!==i.id||this.track(t)}))}gradients(t,e,n,i=!1){if(_O(e.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const s=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",t)));_O(s instanceof xk,(()=>"The result y returned by f() must be a tensor."));const r=
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i={},s={};for(let t=0;t<e.length;t++)i[e[t].id]=!0;for(let n=0;n<t.length;n++){const r=t[n],a=r.inputs;for(const t in a){const n=a[t];let o=!1;for(let t=0;t<e.length;t++)if(i[n.id]){r.outputs.forEach((t=>i[t.id]=!0)),o=!0,s[r.id]=!0;break}if(o)break}}const r={};r[n.id]=!0;const a={};for(let e=t.length-1;e>=0;e--){const n=t[e],i=n.inputs;for(let t=0;t<n.outputs.length;t++)if(r[n.outputs[t].id]){for(const t in i)r[i[t].id]=!0,a[n.id]=!0;break}}const o=[];for(let e=0;e<t.length;e++){const n=t[e];if(s[n.id]&&a[n.id]){const t={};for(const e in n.inputs){const s=n.inputs[e];i[s.id]&&(t[e]=s)}const e=Object.assign({},n);e.inputs=t,e.outputs=n.outputs,o.push(e)}}return o}(this.state.activeTape,e,s);if(!i&&0===r.length&&e.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(()=>{const t={};t[s.id]=null==n?function(t){const e=KO(IO(t),"float32");return jk.makeTensor(e,t,"float32")}(s.shape):n,function(t,e,n,i){for(let s=e.length-1;s>=0;s--){const r=e[s],a=[];if(r.outputs.forEach((e=>{const n=t[e.id];null!=n?a.push(n):a.push(null)})),null==r.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${r.kernelName}.`);const o=r.gradient(a);for(const e in r.inputs){if(!(e in o))throw new Error(`Cannot backprop through input ${e}. Available gradients found: ${Object.keys(o)}.`);const s=n((()=>o[e]()));if("float32"!==s.dtype)throw new Error(`Error in gradient for op ${r.kernelName}. The gradient of input ${e} must have 'float32' dtype, but has '${s.dtype}'`);const a=r.inputs[e];if(!vO(s.shape,a.shape))throw new Error(`Error in gradient for op ${r.kernelName}. The gradient of input '${e}' has shape '${s.shape}', which does not match the shape of the input '${a.shape}'`);if(null==t[a.id])t[a.id]=s;else{const e=t[a.id];t[a.id]=i(e,s),e.dispose()}}}}(t,r,(t=>this.tidy(t)),qk);const i=e.map((e=>t[e.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((t=>{for(const e of t.saved)e.dispose()})),this.state.activeTape=null),{value:s,grads:i}}))}customGrad(t){return _O(HO(t),(()=>"The f passed in customGrad(f) must be a function.")),(...e)=>{let n;_O(e.every((t=>t instanceof xk)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const i={};e.forEach(((t,e)=>{i[e]=t}));return this.runKernelFunc({forwardFunc:(i,s)=>(n=t(...e,s),_O(n.value instanceof xk,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),_O(HO(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(t,i)=>{const s=n.gradFunc(t,i),r=Array.isArray(s)?s:[s];_O(r.length===e.length,(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).")),_O(r.every((t=>t instanceof xk)),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."));const a={};return r.forEach(((t,e)=>{a[e]=()=>t})),a},inputs:i})}}readSync(t){return this.state.tensorInfo.get(t).backend.readSync(t)}read(t){return this.state.tensorInfo.get(t).backend.read(t)}readToGPU(t,e){return this.state.tensorInfo.get(t).backend.readToGPU(t,e)}async time(t){const e=rk(),n=await this.backend.time(t);return n.wallMs=rk()-e,n}track(t){return null!=this.state.activeScope&&(t.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(t)),t}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new Wk;for(const t in this.registry)this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function Xk(){const t=uA();if(null==t._tfengine){const e=new sA(t);t._tfengine=new zk(e)}var e;return e=t._tfengine.ENV,lA=e,vk=()=>t._tfengine,t._tfengine}zk.nextTensorId=0,zk.nextVariableId=0;const jk=Xk();function qk(t,e){const n={a:t,b:e};return jk.runKernel(fA,n)}let Kk;function Qk(t){Kk=t}function Jk(t){if(void 0!==Kk)return Kk;if(t||"undefined"!=typeof navigator&&null!=navigator){if(t||(t=navigator),"ReactNative"===t.product)return!0;const e=t.userAgent||t.vendor||("undefined"!=typeof window?window.opera:"");if(!e){const e=t;return e.userAgentData&&e.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}return!1}function Zk(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const tD=aA();
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function eD(t,e){let n=t;if(uk(t))return"string"===e?[]:[t.length];if(Pk(t)){const e=t.channels||"RGBA";return[t.height,t.width*e.length]}if($k(t))return[t.buffer.size/(null==e?4:$O(e))];if(!Array.isArray(t))return[];const i=[];for(;Array.isArray(n)||uk(n)&&"string"!==e;)i.push(n.length),n=n[0];return Array.isArray(t)&&aA().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&nD(t,i,[]),i}function nD(t,e,n){if(n=n||[],!Array.isArray(t)&&!uk(t))return void _O(0===e.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${e[0]} elements`));_O(e.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${t.length} elements`)),_O(t.length===e[0],(()=>`Element arr[${n.join("][")}] should have ${e[0]} elements, but has ${t.length} elements`));const i=e.slice(1);for(let e=0;e<t.length;++e)nD(t[e],i,n.concat(e))}function iD(t,e,n,i){if("string_or_numeric"!==t){if(null==t)throw new Error("Expected dtype cannot be null.");if("numeric"!==t&&t!==e||"numeric"===t&&"string"===e)throw new Error(`Argument '${n}' passed to '${i}' must be ${t} tensor, but got ${e} tensor`)}}function sD(t,e,n,i="numeric"){if(t instanceof Rk())return iD(i,t.dtype,e,n),t;let s=GO(t);if("string"!==s&&["bool","int32","float32"].indexOf(i)>=0&&(s=i),iD(i,s,e,n),null==t||!uk(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t){const i=null==t?"null":t.constructor.name;throw new Error(`Argument '${e}' passed to '${n}' must be a Tensor or TensorLike, but got '${i}'`)}const r=eD(t,s);uk(t)||Array.isArray(t)||(t=[t]);const a="string"!==s?sk(t,s):hk(t,[],!0);return jk.makeTensor(a,r,s)}function rD(t,e,n,i="numeric"){if(!Array.isArray(t))throw new Error(`Argument ${e} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return t.map(((t,s)=>sD(t,`${e}[${s}]`,n,i)))}tD.registerFlag("DEBUG",(()=>!1),(t=>{t&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),tD.registerFlag("IS_BROWSER",(()=>Zk())),tD.registerFlag("IS_NODE",(()=>"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node)),tD.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),tD.registerFlag("IS_SAFARI",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor))),tD.registerFlag("PROD",(()=>!1)),tD.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>tD.getBool("DEBUG"))),tD.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),tD.registerFlag("IS_TEST",(()=>!1)),tD.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>tD.getBool("DEBUG"))),tD.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),tD.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",(()=>!1)),tD.registerFlag("USE_SETTIMEOUTCUSTOM",(()=>!1));
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const aD="__op";function oD(t){const e=Object.keys(t);if(1!==e.length)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${e.length} keys.`);let n=e[0];const i=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=aD;const s=(...t)=>{jk.startScope(n);try{const e=i(...t);return nA(e)&&console.error("Cannot return a Promise inside of tidy."),jk.endScope(e),e}catch(t){throw jk.endScope(null),t}};return Object.defineProperty(s,"name",{value:n,configurable:!0}),s}const lD=oD({complex_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"real","complex"),i=sD(e,"imag","complex");TO(n.shape,i.shape,`real and imag shapes, ${n.shape} and ${i.shape}, must match in call to tf.complex().`);const s={real:n,imag:i};return jk.runKernel($A,s)}});
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function uD(t,e,n,i){if(null==i)i=GO(t);else if("complex64"===i)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if($k(t)||Pk(t)){if("float32"!==i&&"int32"!==i)throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${i}.`);return jk.backend.createTensorFromGPUData(t,e||n,i)}if(!uk(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=e){ZO(e);const t=IO(e),i=IO(n);_O(t===i,(()=>`Based on the provided shape, [${e}], the tensor should have ${t} values but has ${i}`));for(let t=0;t<n.length;++t){const i=n[t],s=t!==n.length-1||i!==IO(e.slice(t));_O(n[t]===e[t]||!s,(()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${e}). `))}}return uk(t)||Array.isArray(t)||(t=[t]),e=e||n,t="string"!==i?sk(t,i):hk(t,[],!0),jk.makeTensor(t,e,i)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function hD(t,e,n){return uD(t,e,eD(t,n),n)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const pD={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};class cD{static join(t){return new cD(t).slice()}constructor(t){if(this.shards=[],this.previousShardIndex=0,null==t)return;if(t instanceof Array||(t=[t]),0===(t=t.map((t=>uk(t)?t.buffer:t))).length)return;this.bufferUniformSize=t[0].byteLength;let e=0;for(let n=0;n<t.length;n++){const i=t[n];n!==t.length-1&&i.byteLength!==this.bufferUniformSize&&(this.bufferUniformSize=void 0);const s=e+i.byteLength;this.shards.push({buffer:i,start:e,end:s}),e=s}0===this.shards.length&&(this.byteLength=0),this.byteLength=this.shards[this.shards.length-1].end}slice(t=0,e=this.byteLength){if(0===this.shards.length)return new ArrayBuffer(0);if(t=isNaN(Number(t))?0:t,e=isNaN(Number(e))?0:e,t=Math.max(0,t),(e=Math.min(this.byteLength,e))<=t)return new ArrayBuffer(0);const n=this.findShardForByte(t);if(-1===n)throw new Error(`Could not find start shard for byte ${t}`);const i=new ArrayBuffer(e-t),s=new Uint8Array(i);let r=0;for(let i=n;i<this.shards.length;i++){const n=this.shards[i],a=t+r-n.start,o=r,l=Math.min(e,n.end)-n.start,u=new Uint8Array(n.buffer,a,l-a);if(s.set(u,o),r+=u.length,e<n.end)break}return i}findShardForByte(t){if(0===this.shards.length||t<0||t>=this.byteLength)return-1;if(null!=this.bufferUniformSize)return this.previousShardIndex=Math.floor(t/this.bufferUniformSize),this.previousShardIndex;function e(e){return t<e.start?-1:t>=e.end?1:0}if(0===e(this.shards[this.previousShardIndex]))return this.previousShardIndex;const n=function(t,e){let n=0,i=t.length;for(;n<=i;){const s=Math.floor((i-n)/2)+n,r=e(t[s]);if(0===r)return s;r<0?i=s:n=s+1}return-1}(this.shards,e);return-1===n?-1:(this.previousShardIndex=n,this.previousShardIndex)}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function dD(){aA().set("PROD",!0)}function fD(){aA().set("DEBUG",!0)}function mD(){aA().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")}function gD(t){aA().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(t+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function _D(){jk.disposeVariables()}function TD(){return jk}function yD(){return jk.memory()}function ID(t){return jk.profile(t)}function ED(t,e){return jk.tidy(t,e)}function bD(t){Yk(t).forEach((t=>t.dispose()))}function vD(t){return jk.keep(t)}function wD(t){return jk.time(t)}function SD(t){return jk.setBackend(t)}function xD(){return jk.ready()}function RD(){return jk.backendName}function OD(t){jk.removeBackend(t)}function AD(t){return jk.findBackend(t)}function MD(t){return jk.findBackendFactory(t)}function CD(t,e,n=1){return jk.registerBackend(t,e,n)}function ND(){return jk.backend}function kD(t,e){aA().setPlatform(t,e)}Sk=gD;
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const DD=4;async function LD(t,e){const n=[],i=[],s=Array.isArray(t)?t.map((t=>t.name)):Object.keys(t);for(let r=0;r<s.length;++r){const a=s[r],o=Array.isArray(t)?t[r].tensor:t[a];if("float32"!==o.dtype&&"int32"!==o.dtype&&"bool"!==o.dtype&&"string"!==o.dtype&&"complex64"!==o.dtype)throw new Error(`Unsupported dtype in weight '${a}': ${o.dtype}`);const l={name:a,shape:o.shape,dtype:o.dtype};if("string"===o.dtype){const t=new Promise((async t=>{const e=await o.bytes(),n=e.reduce(((t,e)=>t+e.length),0)+DD*e.length,i=new Uint8Array(n);let s=0;for(let t=0;t<e.length;t++){const n=e[t],r=new Uint8Array(new Uint32Array([n.length]).buffer);i.set(r,s),s+=DD,i.set(n,s),s+=n.length}t(i)}));i.push(t)}else i.push(o.data());null!=e&&(l.group=e),n.push(l)}return{data:YD(await Promise.all(i)),specs:n}}function FD(t,e){const n=new cD(t),i={};let s=0;for(const t of e){const e=PD(t,((t,e)=>n.slice(s+t,s+e)));i[t.name]=BD(t,n.slice(s,s+e)),s+=e}return i}function PD(t,e){const n=IO(t.shape);let i;if("quantization"in t){const e=t.quantization;i=pD[e.dtype]}else{if("string"===t.dtype){let t=0;for(let i=0;i<n;i++)t+=DD+new Uint32Array(e(t,t+DD))[0];return t}i=pD[t.dtype]}return n*i}async function $D(t,e){const n=IO(t.shape);let i;if("quantization"in t){const e=t.quantization;i=pD[e.dtype]}else{if("string"===t.dtype){let t=0;for(let i=0;i<n;i++)t+=DD+new Uint32Array(await e(t,t+DD))[0];return t}i=pD[t.dtype]}return n*i}function BD(t,e){const n=t.name,i=t.dtype,s=t.shape,r=IO(s);let a,o=0;if("quantization"in t){const s=t.quantization;if("uint8"===s.dtype||"uint16"===s.dtype){if(!("min"in s)||!("scale"in s))throw new Error(`Weight ${t.name} with quantization ${s.dtype} doesn't have corresponding metadata min and scale.`)}else{if("float16"!==s.dtype)throw new Error(`Weight ${t.name} has unknown quantization dtype ${s.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);if("float32"!==i)throw new Error(`Weight ${t.name} is quantized with ${s.dtype} which only supports weights of type float32 not ${i}.`)}const l=pD[s.dtype],u="uint8"===s.dtype?new Uint8Array(e):new Uint16Array(e);if("float32"===i)if("uint8"===s.dtype||"uint16"===s.dtype){a=new Float32Array(u.length);for(let t=0;t<u.length;t++){const e=u[t];a[t]=e*s.scale+s.min}}else{if("float16"!==s.dtype)throw new Error(`Unsupported quantization type ${s.dtype} for weight type float32.`);{const t=function(){const t=function(){const t=t=>{let e=t<<13,n=0;for(;!(8388608&e);)n-=8388608,e<<=1;return e&=-8388609,n+=947912704,e|n},e=new Uint32Array(2048);e[0]=0;for(let n=1;n<1024;n++)e[n]=t(n);for(let t=1024;t<2048;t++)e[t]=939524096+(t-1024<<13);return e}(),e=function(){const t=new Uint32Array(64);t[0]=0,t[31]=1199570944,t[32]=2147483648,t[63]=3347054592;for(let e=1;e<31;e++)t[e]=e<<23;for(let e=33;e<63;e++)t[e]=2147483648+(e-32<<23);return t}(),n=function(){const t=new Uint32Array(64);for(let e=0;e<64;e++)t[e]=1024;return t[0]=t[32]=0,t}();return i=>{const s=new ArrayBuffer(4*i.length),r=new Uint32Array(s);for(let s=0;s<i.length;s++){const a=i[s],o=t[n[a>>10]+(1023&a)]+e[a>>10];r[s]=o}return new Float32Array(s)}}();a=t(u)}}else{if("int32"!==i)throw new Error(`Unsupported dtype in weight '${n}': ${i}`);if("uint8"!==s.dtype&&"uint16"!==s.dtype)throw new Error(`Unsupported quantization type ${s.dtype} for weight type int32.`);a=new Int32Array(u.length);for(let t=0;t<u.length;t++){const e=u[t];a[t]=Math.round(e*s.scale+s.min)}}o+=r*l}else if("string"===i){const n=IO(t.shape);a=[];for(let t=0;t<n;t++){const t=new Uint32Array(e.slice(o,o+DD))[0];o+=DD;const n=new Uint8Array(e.slice(o,o+t));a.push(n),o+=t}}else{const t=pD[i];if("float32"===i)a=new Float32Array(e);else if("int32"===i)a=new Int32Array(e);else{if("bool"!==i){if("complex64"===i){a=new Float32Array(e);const t=new Float32Array(a.length/2),n=new Float32Array(a.length/2);for(let e=0;e<t.length;e++)t[e]=a[2*e],n[e]=a[2*e+1];const i=hD(t,s,"float32"),r=hD(n,s,"float32"),o=lD(i,r);return i.dispose(),r.dispose(),o}throw new Error(`Unsupported dtype in weight '${n}': ${i}`)}a=new Uint8Array(e)}o+=r*t}return hD(a,s,i)}async function VD(t,e,n){let i=new Uint8Array(e);for(;i.byteLength<n;){const{done:e,value:s}=await t.read();if(e&&null==s){const t=n-i.byteLength;throw new Error(`Reader is done but ${t} bytes are still expected`)}const r=new Uint8Array(i.length+s.byteLength);r.set(i,0),r.set(new Uint8Array(s),i.length),i=r}return i.buffer}async function UD(t,e){const n={},i=t.getReader();let s=new ArrayBuffer(0);for(const t of e){const e=await $D(t,(async(t,e)=>(s=await VD(i,s,e),s.slice(t,e))));s=await VD(i,s,e);const r=s.slice(0,e);s=s.slice(e);const a=BD(t,r);if(n[t.name]=a,"webgpu"===RD()){const t=ND();"uploadToGPU"in t&&IO(a.shape)>=aA().get("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD")&&t.uploadToGPU(a.dataId)}}return n}function YD(t){if(null===t)throw new Error(`Invalid input value: ${JSON.stringify(t)}`);let e=0;const n=[];t.forEach((t=>{if(e+=t.byteLength,n.push(t.byteLength===t.buffer.byteLength?t:new t.constructor(t)),!(t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${t.constructor.name}`)}));const i=new Uint8Array(e);let s=0;return n.forEach((t=>{i.set(new Uint8Array(t.buffer),s),s+=t.byteLength})),i.buffer}const GD="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function HD(t){return GD?Buffer.byteLength(t,"utf8"):new Blob([t]).size}function WD(t){return cD.join(t)}function zD(t){for(t=t.trim();t.endsWith("/");)t=t.slice(0,t.length-1);const e=t.split("/");return e[e.length-1]}function XD(t,e){const n={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,weightsManifest:e};return null!=t.signature&&(n.signature=t.signature),null!=t.userDefinedMetadata&&(n.userDefinedMetadata=t.userDefinedMetadata),null!=t.modelInitializer&&(n.modelInitializer=t.modelInitializer),null!=t.initializerSignature&&(n.initializerSignature=t.initializerSignature),null!=t.trainingConfig&&(n.trainingConfig=t.trainingConfig),n}function jD(t,e,n){const i={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy};if(null!=t.trainingConfig&&(i.trainingConfig=t.trainingConfig),null!=t.weightsManifest){if(!e)throw new Error("modelJSON has weightsManifest but weightSpecs is null");if(!n)throw new Error("modelJSON has weightsManifest but weightData is null");i.weightSpecs=e,i.weightData=n}return null!=t.signature&&(i.signature=t.signature),null!=t.userDefinedMetadata&&(i.userDefinedMetadata=t.userDefinedMetadata),null!=t.modelInitializer&&(i.modelInitializer=t.modelInitializer),null!=t.initializerSignature&&(i.initializerSignature=t.initializerSignature),i}async function qD(t,e){let n,i;return null!=t.weightsManifest&&([n,i]=await e(t.weightsManifest)),jD(t,n,i)}function KD(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==t.modelTopology?0:HD(JSON.stringify(t.modelTopology)),weightSpecsBytes:null==t.weightSpecs?0:HD(JSON.stringify(t.weightSpecs)),weightDataBytes:null==t.weightData?0:new cD(t.weightData).byteLength}}function QD(t){const e=[];for(const n of t)e.push(...n.weights);return e}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class JD{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==JD.instance&&(JD.instance=new JD),JD.instance}static registerSaveRouter(t){JD.getInstance().saveRouters.push(t)}static registerLoadRouter(t){JD.getInstance().loadRouters.push(t)}static getSaveHandlers(t){return JD.getHandlers(t,"save")}static getLoadHandlers(t,e){return JD.getHandlers(t,"load",e)}static getHandlers(t,e,n){const i=[];return("load"===e?JD.getInstance().loadRouters:JD.getInstance().saveRouters).forEach((e=>{const s=e(t,n);null!==s&&i.push(s)})),i}}const ZD=t=>JD.registerSaveRouter(t),tL=t=>JD.registerLoadRouter(t),eL=t=>JD.getSaveHandlers(t),nL=(t,e)=>JD.getLoadHandlers(t,e),iL="tensorflowjs",sL="models_store",rL="model_info_store";function aL(){if(!aA().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const t="undefined"==typeof window?self:window,e=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB||t.shimIndexedDB;if(null==e)throw new Error("The current browser does not appear to support IndexedDB.");return e}function oL(t){const e=t.result;e.createObjectStore(sL,{keyPath:"modelPath"}),e.createObjectStore(rL,{keyPath:"modelPath"})}class lL{constructor(t){if(this.indexedDB=aL(),null==t||!t)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=t}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,t)}async load(){return this.databaseAction(this.modelPath)}databaseAction(t,e){return new Promise(((t,n)=>{const i=this.indexedDB.open(iL,1);i.onupgradeneeded=()=>oL(i),i.onsuccess=()=>{const s=i.result;if(null==e){const e=s.transaction(sL,"readonly"),i=e.objectStore(sL).get(this.modelPath);i.onsuccess=()=>{if(null==i.result)return s.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));t(i.result.modelArtifacts)},i.onerror=t=>(s.close(),n(i.error)),e.oncomplete=()=>s.close()}else{e.weightData=cD.join(e.weightData);const i=KD(e),r=s.transaction(rL,"readwrite");let a,o,l=r.objectStore(rL);try{a=l.put({modelPath:this.modelPath,modelArtifactsInfo:i})}catch(t){return n(t)}a.onsuccess=()=>{o=s.transaction(sL,"readwrite");const a=o.objectStore(sL);let u;try{u=a.put({modelPath:this.modelPath,modelArtifacts:e,modelArtifactsInfo:i})}catch(t){return n(t)}u.onsuccess=()=>t({modelArtifactsInfo:i}),u.onerror=t=>{l=r.objectStore(rL);const e=l.delete(this.modelPath);e.onsuccess=()=>(s.close(),n(u.error)),e.onerror=t=>(s.close(),n(u.error))}},a.onerror=t=>(s.close(),n(a.error)),r.oncomplete=()=>{null==o?s.close():o.oncomplete=()=>s.close()}}},i.onerror=t=>n(i.error)}))}}lL.URL_SCHEME="indexeddb://";const uL=t=>{return aA().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(lL.URL_SCHEME)?(e=t.slice(lL.URL_SCHEME.length),new lL(e)):null;var e};JD.registerSaveRouter(uL),JD.registerLoadRouter(uL);class hL{constructor(){this.indexedDB=aL()}async listModels(){return new Promise(((t,e)=>{const n=this.indexedDB.open(iL,1);n.onupgradeneeded=()=>oL(n),n.onsuccess=()=>{const i=n.result,s=i.transaction(rL,"readonly"),r=s.objectStore(rL).getAll();r.onsuccess=()=>{const e={};for(const t of r.result)e[t.modelPath]=t.modelArtifactsInfo;t(e)},r.onerror=t=>(i.close(),e(r.error)),s.oncomplete=()=>i.close()},n.onerror=t=>e(n.error)}))}async removeModel(t){var e;return t=(e=t).startsWith(lL.URL_SCHEME)?e.slice(lL.URL_SCHEME.length):e,new Promise(((e,n)=>{const i=this.indexedDB.open(iL,1);i.onupgradeneeded=()=>oL(i),i.onsuccess=()=>{const s=i.result,r=s.transaction(rL,"readwrite"),a=r.objectStore(rL),o=a.get(t);let l;o.onsuccess=()=>{if(null==o.result)return s.close(),n(new Error(`Cannot find model with path '${t}' in IndexedDB.`));{const i=a.delete(t),r=()=>{l=s.transaction(sL,"readwrite");const i=l.objectStore(sL).delete(t);i.onsuccess=()=>e(o.result.modelArtifactsInfo),i.onerror=t=>n(o.error)};i.onsuccess=r,i.onerror=t=>(r(),s.close(),n(o.error))}},o.onerror=t=>(s.close(),n(o.error)),r.oncomplete=()=>{null==l?s.close():l.oncomplete=()=>s.close()}},i.onerror=t=>n(i.error)}))}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const pL="/",cL="tensorflowjs_models",dL="info",fL="model_topology",mL="weight_specs",gL="weight_data",_L="model_metadata";function TL(t){return{info:[cL,t,dL].join(pL),topology:[cL,t,fL].join(pL),weightSpecs:[cL,t,mL].join(pL),weightData:[cL,t,gL].join(pL),modelMetadata:[cL,t,_L].join(pL)}}function yL(t){for(const e of Object.values(t))window.localStorage.removeItem(e)}function IL(t){const e=t.split(pL);if(e.length<3)throw new Error(`Invalid key format: ${t}`);return e.slice(1,e.length-1).join(pL)}class EL{constructor(t){if(!aA().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==t||!t)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=t,this.keys=TL(this.modelPath)}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const e=JSON.stringify(t.modelTopology),n=JSON.stringify(t.weightSpecs),i=KD(t),s=cD.join(t.weightData);try{this.LS.setItem(this.keys.info,JSON.stringify(i)),this.LS.setItem(this.keys.topology,e),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(t){if(GD)return Buffer.from(t).toString("base64");const e=new Uint8Array(t);let n="";for(let t=0,i=e.length;t<i;t++)n+=String.fromCharCode(e[t]);return btoa(n)}(s));const r={format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,signature:null!=t.signature?t.signature:void 0,userDefinedMetadata:null!=t.userDefinedMetadata?t.userDefinedMetadata:void 0,modelInitializer:null!=t.modelInitializer?t.modelInitializer:void 0,initializerSignature:null!=t.initializerSignature?t.initializerSignature:void 0,trainingConfig:null!=t.trainingConfig?t.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(r)),{modelArtifactsInfo:i}}catch(t){throw yL(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${i.modelTopologyBytes}, weightSpecsBytes=${i.weightSpecsBytes}, weightDataBytes=${i.weightDataBytes}.`)}}}async load(){const t=JSON.parse(this.LS.getItem(this.keys.info));if(null==t)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==t.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const e={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(null==n)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);e.modelTopology=n;const i=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==i)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);e.weightSpecs=i;const s=this.LS.getItem(this.keys.modelMetadata);if(null!=s){const t=JSON.parse(s);e.format=t.format,e.generatedBy=t.generatedBy,e.convertedBy=t.convertedBy,null!=t.signature&&(e.signature=t.signature),null!=t.userDefinedMetadata&&(e.userDefinedMetadata=t.userDefinedMetadata),null!=t.modelInitializer&&(e.modelInitializer=t.modelInitializer),null!=t.initializerSignature&&(e.initializerSignature=t.initializerSignature),null!=t.trainingConfig&&(e.trainingConfig=t.trainingConfig)}const r=this.LS.getItem(this.keys.weightData);if(null==r)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return e.weightData=function(t){if(GD){const e=Buffer.from(t,"base64");return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;++t)n.set([e.charCodeAt(t)],t);return n.buffer}(r),e}}EL.URL_SCHEME="localstorage://";const bL=t=>{return aA().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(EL.URL_SCHEME)?(e=t.slice(EL.URL_SCHEME.length),new EL(e)):null;var e};JD.registerSaveRouter(bL),JD.registerLoadRouter(bL);class vL{constructor(){_O(aA().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),_O("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const t={},e=cL+pL,n=pL+dL;for(let i=0;i<this.LS.length;++i){const s=this.LS.key(i);if(s.startsWith(e)&&s.endsWith(n)){t[IL(s)]=JSON.parse(this.LS.getItem(s))}}return t}async removeModel(t){var e;const n=TL(t=(e=t).startsWith(EL.URL_SCHEME)?e.slice(EL.URL_SCHEME.length):e);if(null==this.LS.getItem(n.info))throw new Error(`Cannot find model at path '${t}'`);const i=JSON.parse(this.LS.getItem(n.info));return yL(n),i}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const wL="://";class SL{constructor(){this.managers={}}static getInstance(){return null==SL.instance&&(SL.instance=new SL),SL.instance}static registerManager(t,e){_O(null!=t,(()=>"scheme must not be undefined or null.")),t.endsWith(wL)&&(t=t.slice(0,t.indexOf(wL))),_O(t.length>0,(()=>"scheme must not be an empty string."));const n=SL.getInstance();_O(null==n.managers[t],(()=>`A model store manager is already registered for scheme '${t}'.`)),n.managers[t]=e}static getManager(t){const e=SL.getInstance().managers[t];if(null==e)throw new Error(`Cannot find model manager for scheme '${t}'`);return e}static getSchemes(){return Object.keys(SL.getInstance().managers)}}function xL(t){if(-1===t.indexOf(wL))throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${SL.getSchemes().join(",")}`);return{scheme:t.split(wL)[0],path:t.split(wL)[1]}}async function RL(t,e,n=!1){_O(t!==e,(()=>`Old path and new path are the same: '${t}'`));const i=JD.getLoadHandlers(t);_O(i.length>0,(()=>`Copying failed because no load handler is found for source URL ${t}.`)),_O(i.length<2,(()=>`Copying failed because more than one (${i.length}) load handlers for source URL ${t}.`));const s=i[0],r=JD.getSaveHandlers(e);_O(r.length>0,(()=>`Copying failed because no save handler is found for destination URL ${e}.`)),_O(r.length<2,(()=>`Copying failed because more than one (${i.length}) save handlers for destination URL ${e}.`));const a=r[0],o=xL(t).scheme,l=xL(t).path,u=o===xL(t).scheme,h=await s.load();n&&u&&await SL.getManager(o).removeModel(l);const p=await a.save(h);return n&&!u&&await SL.getManager(o).removeModel(l),p.modelArtifactsInfo}async function OL(){const t=SL.getSchemes(),e={};for(const n of t){const t=await SL.getManager(n).listModels();for(const i in t){e[n+wL+i]=t[i]}}return e}async function AL(t){const e=xL(t);return SL.getManager(e.scheme).removeModel(e.path)}async function ML(t,e){return RL(t,e,!1)}async function CL(t,e){return RL(t,e,!0)}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class NL{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(t,e){return fetch(t,e)}now(){return performance.now()}encode(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error(`Browser's encoder only supports utf-8, but got ${e}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(t)}decode(t,e){return new TextDecoder(e).decode(t)}setTimeoutCustom(t,e){"undefined"!=typeof window&&aA().getBool("USE_SETTIMEOUTCUSTOM")?(this.functionRefs.push(t),setTimeout((()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")}),e),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",(t=>{if(t.source===window&&t.data.name===this.messageName){t.stopPropagation();(0,this.functionRefs[t.data.index])(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0)}}),!0))):setTimeout(t,e)}isTypedArray(t){return YN(t)}}if(aA().get("IS_BROWSER")){aA().setPlatform("browser",new NL);try{SL.registerManager(EL.URL_SCHEME,new vL)}catch(t){}try{SL.registerManager(lL.URL_SCHEME,new hL)}catch(t){}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const kL=()=>__webpack_require__(5817);let DL;class LL{constructor(){this.util=__webpack_require__(8590),this.textEncoder=new this.util.TextEncoder}fetch(t,e){return null!=aA().global.fetch?aA().global.fetch(t,e):(null==DL&&(DL=kL()),DL(t,e))}now(){const t=process.hrtime();return 1e3*t[0]+t[1]/1e6}encode(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error(`Node built-in encoder only supports utf-8, but got ${e}`);return this.textEncoder.encode(t)}decode(t,e){return 0===t.length?"":new this.util.TextDecoder(e).decode(t)}isTypedArray(t){return this.util.types.isFloat32Array(t)||this.util.types.isInt32Array(t)||this.util.types.isUint8Array(t)||this.util.types.isUint8ClampedArray(t)}}
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function FL(t,e="float32",n){return e=e||"float32",ZO(t),new bk(t,e,n)}aA().get("IS_NODE")&&!aA().get("IS_BROWSER")&&aA().setPlatform("node",new LL);const PL=oD({cast_:
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"x","cast");if(!FO(e))throw new Error(`Failed to cast to unknown dtype ${e}`);if("string"===e&&"string"!==n.dtype||"string"!==e&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");const i={x:n},s={dtype:e};return jk.runKernel(LA,i,s)}});const $L=oD({clone_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","clone","string_or_numeric")};return jk.runKernel(RM,e)}});
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function BL(t,e=!1){console.log(t.toString(e))}
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Xk();wk={buffer:FL,cast:PL,clone:$L,print:BL};const VL=oD({add_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","add"),i=sD(e,"b","add");[n,i]=Bk(n,i);const s={a:n,b:i};return jk.runKernel(fA,s)}});const UL=oD({floorDiv_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","floorDiv"),i=sD(e,"b","floorDiv");[n,i]=Bk(n,i);const s={a:n,b:i};return jk.runKernel(EM,s)}});const YL=oD({div_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","div"),i=sD(e,"b","div");if([n,i]=Bk(n,i),"int32"===n.dtype&&"int32"===i.dtype)return UL(n,i);const s={a:n,b:i};return jk.runKernel(lM,s,{})}});const GL=oD({mul_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","mul"),i=sD(e,"b","mul");[n,i]=Bk(n,i);const s={a:n,b:i};return jk.runKernel(oC,s)}});const HL=oD({sqrt_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","sqrt","float32")};return jk.runKernel(jC,e)}});const WL=oD({square_:
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e=sD(t,"x","square");return jk.runKernel("Square",{x:e},{})}});const zL=oD({zerosLike_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","zerosLike")};return jk.runKernel(bN,e)}});
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function XL(t){return _O(HO(t),(()=>"The f passed in grad(f) must be a function")),(e,n)=>{const i=sD(e,"x","tf.grad","string_or_numeric"),s=null!=n?sD(n,"dy","tf.grad"):null;return jk.tidy((()=>{const{value:e,grads:n}=jk.gradients((()=>t(i)),[i],s);return null!=s&&TO(e.shape,s.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),ZL(n),n[0]}))}}function jL(t){return _O(HO(t),(()=>"The f passed in grads(f) must be a function")),(e,n)=>{_O(Array.isArray(e),(()=>"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"));const i=rD(e,"args","tf.grads","string_or_numeric"),s=null!=n?sD(n,"dy","tf.grads"):null;return jk.tidy((()=>{const{value:e,grads:n}=jk.gradients((()=>t(...i)),i,s);return null!=s&&TO(e.shape,s.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),ZL(n),n}))}}function qL(t){return _O(HO(t),(()=>"The f passed in valueAndGrad(f) must be a function")),(e,n)=>{_O(e instanceof xk,(()=>"The x passed in valueAndGrad(f)(x) must be a tensor")),_O(null==n||n instanceof xk,(()=>"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"));const{grads:i,value:s}=jk.gradients((()=>t(e)),[e],n);return ZL(i),{grad:i[0],value:s}}}function KL(t){return _O(HO(t),(()=>"The f passed in valueAndGrads(f) must be a function")),(e,n)=>{_O(Array.isArray(e)&&e.every((t=>t instanceof xk)),(()=>"The args passed in valueAndGrads(f)(args) must be array of tensors")),_O(null==n||n instanceof xk,(()=>"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"));const i=jk.gradients((()=>t(...e)),e,n);return null!=n&&TO(i.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),ZL(i.grads),i}}function QL(t,e){_O(HO(t),(()=>"The f passed in variableGrads(f) must be a function")),_O(null==e||Array.isArray(e)&&e.every((t=>t instanceof Ok)),(()=>"The varList passed in variableGrads(f, varList) must be an array of variables"));const n=null!=e;if(!n){e=[];for(const t in jk.registeredVariables)e.push(jk.registeredVariables[t])}const i=n?e.filter((t=>!t.trainable)):null,s=e.length;e=e.filter((t=>t.trainable)),_O(e.length>0,(()=>`variableGrads() expects at least one of the input variables to be trainable, but none of the ${s} variables is trainable.`));const{value:r,grads:a}=jk.gradients(t,e,null,!0);_O(a.some((t=>null!=t)),(()=>"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize().")),_O(0===r.rank,(()=>`The f passed in variableGrads(f) must return a scalar, but it returned a rank-${r.rank} tensor`));const o={};return e.forEach(((t,e)=>{null!=a[e]&&(o[t.name]=a[e])})),null!=i&&i.forEach((t=>o[t.name]=null)),{value:r,grads:o}}function JL(t){return jk.customGrad(t)}function ZL(t){if(t.filter((t=>null==t)).length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n the f you passed encloses all operations that lead from x to y.")}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function tF(t,e){if((uk(t)&&"string"!==e||Array.isArray(t))&&"complex64"!==e)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===e&&uk(t)&&!(t instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return uD(t,[],[],e)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const eF=new Map,nF=new Map;class iF{getClassName(){return this.constructor.className}static fromConfig(t,e){return new t(e)}}class sF{constructor(){this.classNameMap={}}static getMap(){return null==sF.instance&&(sF.instance=new sF),sF.instance}static register(t){sF.getMap().classNameMap[t.className]=[t,t.fromConfig]}}function rF(t,e,n){_O(null!=t.className,(()=>"Class being registered does not have the static className property defined.")),_O("string"==typeof t.className,(()=>"className is required to be a string, but got type "+typeof t.className)),_O(t.className.length>0,(()=>"Class being registered has an empty-string as its className, which is disallowed.")),void 0===e&&(e="Custom"),void 0===n&&(n=t.className);const i=e+">"+n;return sF.register(t),eF.set(i,t),nF.set(t,i),t}function aF(t){return nF.has(t)?nF.get(t):t.className}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class oF extends iF{minimize(t,e=!1,n){const{value:i,grads:s}=this.computeGradients(t,n);if(null!=n){const t=n.map((t=>({name:t.name,tensor:s[t.name]})));this.applyGradients(t)}else this.applyGradients(s);return bD(s),e?i:(i.dispose(),null)}get iterations(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}incrementIterations(){this.iterations_=this.iterations+1}computeGradients(t,e){return QL(t,e)}dispose(){null!=this.iterations_&&bD(this.iterations_)}async saveIterations(){return null==this.iterations_&&(this.iterations_=0),{name:"iter",tensor:tF(this.iterations_,"int32")}}async getWeights(){throw new Error("getWeights() is not implemented for this optimizer yet.")}async setWeights(t){throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`)}async extractIterations(t){return this.iterations_=(await t[0].tensor.data())[0],t.slice(1)}}Object.defineProperty(oF,Symbol.hasInstance,{value:t=>null!=t.minimize&&null!=t.computeGradients&&null!=t.applyGradients});
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class lF extends oF{static get className(){return"Adadelta"}constructor(t,e,n=null){super(),this.learningRate=t,this.rho=e,this.epsilon=n,this.accumulatedGrads=[],this.accumulatedUpdates=[],null==n&&(this.epsilon=jk.backend.epsilon())}applyGradients(t){(Array.isArray(t)?t.map((t=>t.name)):Object.keys(t)).forEach(((e,n)=>{const i=jk.registeredVariables[e],s=!1;null==this.accumulatedGrads[n]&&(this.accumulatedGrads[n]={originalName:`${e}/accum_grad`,variable:ED((()=>zL(i).variable(s)))}),null==this.accumulatedUpdates[n]&&(this.accumulatedUpdates[n]={originalName:`${e}/accum_var`,variable:ED((()=>zL(i).variable(s)))});const r=Array.isArray(t)?t[n].tensor:t[e];if(null==r)return;const a=this.accumulatedGrads[n].variable,o=this.accumulatedUpdates[n].variable;ED((()=>{const t=VL(GL(a,this.rho),GL(WL(r),1-this.rho)),e=GL(YL(HL(VL(o,this.epsilon)),HL(VL(a,this.epsilon))),r),n=VL(GL(o,this.rho),GL(WL(e),1-this.rho));a.assign(t),o.assign(n);const s=VL(GL(e,-this.learningRate),i);i.assign(s)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedUpdates&&(bD(this.accumulatedGrads.map((t=>t.variable))),bD(this.accumulatedUpdates.map((t=>t.variable))))}async getWeights(){const t=[...this.accumulatedGrads,...this.accumulatedUpdates];return[await this.saveIterations()].concat(t.map((t=>({name:t.originalName,tensor:t.variable}))))}async setWeights(t){const e=(t=await this.extractIterations(t)).length/2,n=!1;this.accumulatedGrads=t.slice(0,e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)}))),this.accumulatedUpdates=t.slice(e,2*e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)})))}getConfig(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}}static fromConfig(t,e){return new t(e.learningRate,e.rho,e.epsilon)}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function uF(t,e,n){ZO(t);const i={shape:t,value:e,dtype:n=n||GO(e)};return jk.runKernel(TM,{},i)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class hF extends oF{static get className(){return"Adagrad"}constructor(t,e=.1){super(),this.learningRate=t,this.initialAccumulatorValue=e,this.accumulatedGrads=[]}applyGradients(t){(Array.isArray(t)?t.map((t=>t.name)):Object.keys(t)).forEach(((e,n)=>{const i=jk.registeredVariables[e];if(null==this.accumulatedGrads[n]){const t=!1;this.accumulatedGrads[n]={originalName:`${e}/accumulator`,variable:ED((()=>uF(i.shape,this.initialAccumulatorValue).variable(t)))}}const s=Array.isArray(t)?t[n].tensor:t[e];if(null==s)return;const r=this.accumulatedGrads[n].variable;ED((()=>{const t=VL(r,WL(s));r.assign(t);const e=VL(GL(YL(s,HL(VL(t,jk.backend.epsilon()))),-this.learningRate),i);i.assign(e)}))})),this.incrementIterations()}dispose(){null!=this.accumulatedGrads&&bD(this.accumulatedGrads.map((t=>t.variable)))}async getWeights(){return[await this.saveIterations()].concat(this.accumulatedGrads.map((t=>({name:t.originalName,tensor:t.variable}))))}async setWeights(t){t=await this.extractIterations(t);this.accumulatedGrads=t.map((t=>({originalName:t.name,variable:t.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}}static fromConfig(t,e){return new t(e.learningRate,e.initialAccumulatorValue)}}const pF=oD({pow_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"base","pow"),i=sD(e,"exp","pow");[n,i]=Bk(n,i);const s={a:n,b:i};return jk.runKernel(TC,s)}});const cF=oD({sub_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","sub"),i=sD(e,"b","sub");[n,i]=Bk(n,i);const s={a:n,b:i};return jk.runKernel(pN,s)}});
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class dF extends oF{static get className(){return"Adam"}constructor(t,e,n,i=null){super(),this.learningRate=t,this.beta1=e,this.beta2=n,this.epsilon=i,this.accumulatedFirstMoment=[],this.accumulatedSecondMoment=[],ED((()=>{this.accBeta1=tF(e).variable(),this.accBeta2=tF(n).variable()})),null==i&&(this.epsilon=jk.backend.epsilon())}applyGradients(t){const e=Array.isArray(t)?t.map((t=>t.name)):Object.keys(t);ED((()=>{const n=cF(1,this.accBeta1),i=cF(1,this.accBeta2);e.forEach(((e,s)=>{const r=jk.registeredVariables[e],a=!1;null==this.accumulatedFirstMoment[s]&&(this.accumulatedFirstMoment[s]={originalName:`${e}/m`,variable:ED((()=>zL(r).variable(a)))}),null==this.accumulatedSecondMoment[s]&&(this.accumulatedSecondMoment[s]={originalName:`${e}/v`,variable:ED((()=>zL(r).variable(a)))});const o=Array.isArray(t)?t[s].tensor:t[e];if(null==o)return;const l=this.accumulatedFirstMoment[s].variable,u=this.accumulatedSecondMoment[s].variable,h=VL(GL(l,this.beta1),GL(o,1-this.beta1)),p=VL(GL(u,this.beta2),GL(WL(o),1-this.beta2)),c=YL(h,n),d=YL(p,i);l.assign(h),u.assign(p);const f=VL(GL(YL(c,VL(HL(d),this.epsilon)),-this.learningRate),r);r.assign(f)})),this.accBeta1.assign(GL(this.accBeta1,this.beta1)),this.accBeta2.assign(GL(this.accBeta2,this.beta2))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&bD(this.accumulatedFirstMoment.map((t=>t.variable))),null!=this.accumulatedSecondMoment&&bD(this.accumulatedSecondMoment.map((t=>t.variable)))}async getWeights(){const t=[...this.accumulatedFirstMoment,...this.accumulatedSecondMoment];return[await this.saveIterations()].concat(t.map((t=>({name:t.originalName,tensor:t.variable}))))}async setWeights(t){t=await this.extractIterations(t),ED((()=>{this.accBeta1.assign(pF(this.beta1,this.iterations_+1)),this.accBeta2.assign(pF(this.beta2,this.iterations_+1))}));const e=t.length/2,n=!1;this.accumulatedFirstMoment=t.slice(0,e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)}))),this.accumulatedSecondMoment=t.slice(e,2*e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)})))}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}}static fromConfig(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon)}}const fF=oD({abs_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e=sD(t,"x","abs");if("complex64"===e.dtype){const t={x:e};return jk.runKernel(BA,t)}{const t={x:e};return jk.runKernel(pA,t)}}});
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function mF(t,e){const n=t.length,i=[];for(let s=0;s<n;s++){const r=n-1-s,a=t[r]||1;(e[e.length-1-s]||1)>1&&1===a&&i.unshift(r)}return i}function gF(t,e){const n=[];for(let i=0;i<e.length;i++){const s=t[t.length-i-1],r=e.length-i-1,a=e[r];(null==s||1===s&&a>1)&&n.unshift(r)}return n}function _F(t,e){const n=Math.max(t.length,e.length),i=new Array(n);for(let s=0;s<n;s++){let r=t[t.length-s-1];null==r&&(r=1);let a=e[e.length-s-1];if(null==a&&(a=1),1===r)i[n-s-1]=a;else if(1===a)i[n-s-1]=r;else{if(r!==a){throw Error(`Operands could not be broadcast together with shapes ${t} and ${e}.`)}i[n-s-1]=r}}return i}const TF=oD({maximum_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","maximum"),i=sD(e,"b","maximum");[n,i]=Bk(n,i),"bool"===n.dtype&&(n=PL(n,"int32"),i=PL(i,"int32")),_F(n.shape,i.shape);const s={a:n,b:i};return jk.runKernel(qM,s)}});
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class yF extends oF{static get className(){return"Adamax"}constructor(t,e,n,i=null,s=0){super(),this.learningRate=t,this.beta1=e,this.beta2=n,this.epsilon=i,this.decay=s,this.accumulatedFirstMoment=[],this.accumulatedWeightedInfNorm=[],ED((()=>{this.iteration=tF(0).variable(),this.accBeta1=tF(e).variable()})),null==i&&(this.epsilon=jk.backend.epsilon())}applyGradients(t){const e=Array.isArray(t)?t.map((t=>t.name)):Object.keys(t);ED((()=>{const n=cF(1,this.accBeta1),i=YL(-this.learningRate,VL(GL(this.iteration,this.decay),1));e.forEach(((e,s)=>{const r=jk.registeredVariables[e],a=!1;null==this.accumulatedFirstMoment[s]&&(this.accumulatedFirstMoment[s]={originalName:`${e}/m`,variable:zL(r).variable(a)}),null==this.accumulatedWeightedInfNorm[s]&&(this.accumulatedWeightedInfNorm[s]={originalName:`${e}/v`,variable:zL(r).variable(a)});const o=Array.isArray(t)?t[s].tensor:t[e];if(null==o)return;const l=this.accumulatedFirstMoment[s].variable,u=this.accumulatedWeightedInfNorm[s].variable,h=VL(GL(l,this.beta1),GL(o,1-this.beta1)),p=GL(u,this.beta2),c=fF(o),d=TF(p,c);l.assign(h),u.assign(d);const f=VL(GL(YL(i,n),YL(h,VL(d,this.epsilon))),r);r.assign(f)})),this.iteration.assign(VL(this.iteration,1)),this.accBeta1.assign(GL(this.accBeta1,this.beta1))})),this.incrementIterations()}dispose(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&bD(this.accumulatedFirstMoment.map((t=>t.variable))),null!=this.accumulatedWeightedInfNorm&&bD(this.accumulatedWeightedInfNorm.map((t=>t.variable)))}async getWeights(){throw new Error("getWeights() is not implemented for Adamax yet.")}async setWeights(t){throw new Error("setWeights() is not implemented for Adamax yet.")}getConfig(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}}static fromConfig(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon,e.decay)}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class IF extends oF{static get className(){return"SGD"}constructor(t){super(),this.learningRate=t,this.setLearningRate(t)}applyGradients(t){(Array.isArray(t)?t.map((t=>t.name)):Object.keys(t)).forEach(((e,n)=>{const i=Array.isArray(t)?t[n].tensor:t[e];if(null==i)return;const s=jk.registeredVariables[e];ED((()=>{const t=VL(GL(this.c,i),s);s.assign(t)}))})),this.incrementIterations()}setLearningRate(t){this.learningRate=t,null!=this.c&&this.c.dispose(),this.c=vD(tF(-t))}dispose(){this.c.dispose()}async getWeights(){return[await this.saveIterations()]}async setWeights(t){if(0!==(t=await this.extractIterations(t)).length)throw new Error("SGD optimizer does not have settable weights.")}getConfig(){return{learningRate:this.learningRate}}static fromConfig(t,e){return new t(e.learningRate)}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class EF extends IF{static get className(){return"Momentum"}constructor(t,e,n=!1){super(t),this.learningRate=t,this.momentum=e,this.useNesterov=n,this.accumulations=[],this.m=tF(this.momentum)}applyGradients(t){(Array.isArray(t)?t.map((t=>t.name)):Object.keys(t)).forEach(((e,n)=>{const i=jk.registeredVariables[e];if(null==this.accumulations[n]){const t=!1;this.accumulations[n]={originalName:`${e}/momentum`,variable:ED((()=>zL(i).variable(t)))}}const s=this.accumulations[n].variable,r=Array.isArray(t)?t[n].tensor:t[e];null!=r&&ED((()=>{let t;const e=VL(GL(this.m,s),r);t=this.useNesterov?VL(GL(this.c,VL(r,GL(e,this.m))),i):VL(GL(this.c,e),i),s.assign(e),i.assign(t)}))})),this.incrementIterations()}dispose(){this.m.dispose(),null!=this.accumulations&&bD(this.accumulations.map((t=>t.variable)))}setMomentum(t){this.momentum=t}async getWeights(){return[await this.saveIterations()].concat(this.accumulations.map((t=>({name:t.originalName,tensor:t.variable}))))}async setWeights(t){t=await this.extractIterations(t);this.accumulations=t.map((t=>({originalName:t.name,variable:t.tensor.variable(false)})))}getConfig(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}}static fromConfig(t,e){return new t(e.learningRate,e.momentum,e.useNesterov)}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class bF extends oF{static get className(){return"RMSProp"}constructor(t,e=.9,n=0,i=null,s=!1){if(super(),this.learningRate=t,this.decay=e,this.momentum=n,this.epsilon=i,this.accumulatedMeanSquares=[],this.accumulatedMoments=[],this.accumulatedMeanGrads=[],this.centered=s,null==i&&(this.epsilon=jk.backend.epsilon()),null==t)throw new Error("learningRate for RMSPropOptimizer must be defined.")}applyGradients(t){(Array.isArray(t)?t.map((t=>t.name)):Object.keys(t)).forEach(((e,n)=>{const i=jk.registeredVariables[e],s=!1;null==this.accumulatedMeanSquares[n]&&(this.accumulatedMeanSquares[n]={originalName:`${e}/rms`,variable:ED((()=>zL(i).variable(s)))}),null==this.accumulatedMoments[n]&&(this.accumulatedMoments[n]={originalName:`${e}/momentum`,variable:ED((()=>zL(i).variable(s)))}),null==this.accumulatedMeanGrads[n]&&this.centered&&(this.accumulatedMeanGrads[n]={originalName:`${e}/mg`,variable:ED((()=>zL(i).variable(s)))});const r=Array.isArray(t)?t[n].tensor:t[e];if(null==r)return;const a=this.accumulatedMeanSquares[n].variable,o=this.accumulatedMoments[n].variable;ED((()=>{const t=VL(GL(a,this.decay),GL(WL(r),1-this.decay));if(this.centered){const e=this.accumulatedMeanGrads[n].variable,s=VL(GL(e,this.decay),GL(r,1-this.decay)),l=YL(GL(r,this.learningRate),HL(cF(t,VL(WL(s),this.epsilon)))),u=VL(GL(o,this.momentum),l);a.assign(t),e.assign(s),o.assign(u);const h=cF(i,u);i.assign(h)}else{const t=VL(GL(a,this.decay),GL(WL(r),1-this.decay)),e=VL(GL(o,this.momentum),YL(GL(r,this.learningRate),HL(VL(t,this.epsilon))));a.assign(t),o.assign(e);const n=cF(i,e);i.assign(n)}}))})),this.incrementIterations()}dispose(){null!=this.accumulatedMeanSquares&&bD(this.accumulatedMeanSquares.map((t=>t.variable))),null!=this.accumulatedMeanGrads&&this.centered&&bD(this.accumulatedMeanGrads.map((t=>t.variable))),null!=this.accumulatedMoments&&bD(this.accumulatedMoments.map((t=>t.variable)))}async getWeights(){const t=[...this.accumulatedMeanSquares,...this.accumulatedMoments];return this.centered&&t.push(...this.accumulatedMeanGrads),[await this.saveIterations()].concat(t.map((t=>({name:t.originalName,tensor:t.variable}))))}async setWeights(t){t=await this.extractIterations(t);const e=this.centered?t.length/3:t.length/2,n=!1;this.accumulatedMeanSquares=t.slice(0,e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)}))),this.accumulatedMoments=t.slice(e,2*e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)}))),this.centered&&(this.accumulatedMeanGrads=t.slice(2*e,3*e).map((t=>({originalName:t.name,variable:t.tensor.variable(n)}))))}getConfig(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}}static fromConfig(t,e){return new t(e.learningRate,e.decay,e.momentum,e.epsilon,e.centered)}}
/**
* @license
* Copyright 2022 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const vF=[lF,hF,dF,yF,EF,bF,IF];function wF(t){return new Promise((t=>setTimeout(t))).then(t)}class SF{constructor(t){if(!aA().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");t.startsWith(SF.URL_SCHEME)&&(t=t.slice(SF.URL_SCHEME.length)),null!=t&&0!==t.length||(t="model"),this.modelJsonFileName=t+".json",this.weightDataFileName=t+".weights.bin"}async save(t){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const e=cD.join(t.weightData),n=window.URL.createObjectURL(new Blob([e],{type:"application/octet-stream"}));if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const e=XD(t,[{paths:["./"+this.weightDataFileName],weights:t.weightSpecs}]),i=window.URL.createObjectURL(new Blob([JSON.stringify(e)],{type:"application/json"})),s=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(s.download=this.modelJsonFileName,s.href=i,await wF((()=>s.dispatchEvent(new MouseEvent("click")))),null!=t.weightData){const t=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;t.download=this.weightDataFileName,t.href=n,await wF((()=>t.dispatchEvent(new MouseEvent("click"))))}return{modelArtifactsInfo:KD(t)}}}}SF.URL_SCHEME="downloads://";class xF{constructor(t){if(null==t||t.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${t}`);this.jsonFile=t[0],this.weightsFiles=t.slice(1)}async load(){return new Promise(((t,e)=>{const n=new FileReader;n.onload=n=>{const i=JSON.parse(n.target.result),s=i.modelTopology;if(null==s)return void e(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));if(null==i.weightsManifest)return void e(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));if(0===this.weightsFiles.length)return void t({modelTopology:s});const r=qD(i,(t=>this.loadWeights(t)));t(r)},n.onerror=t=>e(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)}))}loadWeights(t){const e=[],n=[];for(const i of t)e.push(...i.weights),n.push(...i.paths);const i=this.checkManifestAndWeightFiles(t),s=n.map((t=>this.loadWeightsFile(t,i[t])));return Promise.all(s).then((t=>[e,t]))}loadWeightsFile(t,e){return new Promise(((n,i)=>{const s=new FileReader;s.onload=t=>{const e=t.target.result;n(e)},s.onerror=e=>i(`Failed to weights data from file of path '${t}'.`),s.readAsArrayBuffer(e)}))}checkManifestAndWeightFiles(t){const e=[],n=this.weightsFiles.map((t=>zD(t.name))),i={};for(const s of t)s.paths.forEach((t=>{const s=zD(t);if(-1!==e.indexOf(s))throw new Error(`Duplicate file basename found in weights manifest: '${s}'`);if(e.push(s),-1===n.indexOf(s))throw new Error(`Weight file with basename '${s}' is not provided.`);i[t]=this.weightsFiles[n.indexOf(s)]}));if(e.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${e.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return i}}function RF(t){return new xF(t)}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function OF(t,e,n,i){!function(t){_O(null!=t&&Array.isArray(t)&&t.length>0,(()=>"promises must be a none empty array"))}(t),function(t,e){_O(t>=0&&t<=1,(()=>`Progress fraction must be in range [0, 1], but got startFraction ${t}`)),_O(e>=0&&e<=1,(()=>`Progress fraction must be in range [0, 1], but got endFraction ${e}`)),_O(e>=t,(()=>`startFraction must be no more than endFraction, but got startFraction ${t} and endFraction ${e}`))}(n=null==n?0:n,i=null==i?1:i);let s=0;return Promise.all(t.map((r=>(r.then((r=>{const a=n+ ++s/t.length*(i-n);return e(a),r})),r))))}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
async function AF(t,e){null==e&&(e={});const n=null==e.fetchFunc?aA().platform.fetch:e.fetchFunc,i=t.map((t=>n(t,e.requestInit,{isBinary:!0}))),s=(null==e.onProgress?await Promise.all(i):await OF(i,e.onProgress,0,.5)).map((t=>t.arrayBuffer()));return null==e.onProgress?await Promise.all(s):await OF(s,e.onProgress,.5,1)}async function MF(t,e="",n,i){return CF((t=>AF(t,{requestInit:i})))(t,e,n)}function CF(t){return async(e,n="",i)=>{const s=e.map((()=>!1)),r={},a=null!=i?i.map((()=>!1)):[],o=[];if(e.forEach(((t,e)=>{let n=0;t.weights.forEach((t=>{const l="quantization"in t?t.quantization.dtype:t.dtype,u=pD[l]*IO(t.shape),h=()=>{s[e]=!0,null==r[e]&&(r[e]=[]),r[e].push({manifestEntry:t,groupOffset:n,sizeBytes:u})};null!=i?i.forEach(((e,n)=>{e===t.name&&(h(),a[n]=!0)})):h(),o.push(t.name),n+=u}))})),!a.every((t=>t))){const t=i.filter(((t,e)=>!a[e]));throw new Error(`Could not find weights in manifest with names: ${t.join(", ")}. \nManifest JSON has weights with names: ${o.join(", ")}.`)}const l=s.reduce(((t,e,n)=>(e&&t.push(n),t)),[]),u=[];l.forEach((t=>{e[t].paths.forEach((t=>{const e=n+(n.endsWith("/")?"":"/")+t;u.push(e)}))}));const h=await t(u),p={};let c=0;return l.forEach((t=>{const n=e[t].paths.length,i=new cD(h.slice(c,c+n));r[t].forEach((t=>{const e=FD(i.slice(t.groupOffset,t.groupOffset+t.sizeBytes),[t.manifestEntry]);for(const t in e)p[t]=e[t]})),c+=n})),p}}JD.registerSaveRouter((t=>aA().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(SF.URL_SCHEME)?function(t="model"){return new SF(t)}(t.slice(SF.URL_SCHEME.length)):null));class NF{constructor(t,e){if(this.DEFAULT_METHOD="POST",null==e&&(e={}),this.weightPathPrefix=e.weightPathPrefix,this.weightUrlConverter=e.weightUrlConverter,null!=e.fetchFunc?(_O("function"==typeof e.fetchFunc,(()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)")),this.fetch=e.fetchFunc):this.fetch=aA().platform.fetch,_O(null!=t&&t.length>0,(()=>"URL path for http must not be null, undefined or empty.")),Array.isArray(t)&&_O(2===t.length,(()=>`URL paths for http must have a length of 2, (actual length is ${t.length}).`)),this.path=t,null!=e.requestInit&&null!=e.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=e.requestInit||{},this.loadOptions=e}async save(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const e=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);e.body=new FormData;const n=XD(t,[{paths:["./model.weights.bin"],weights:t.weightSpecs}]);if(e.body.append("model.json",new Blob([JSON.stringify(n)],{type:"application/json"}),"model.json"),null!=t.weightData){const n=cD.join(t.weightData);e.body.append("model.weights.bin",new Blob([n],{type:"application/octet-stream"}),"model.weights.bin")}const i=await this.fetch(this.path,e);if(i.ok)return{modelArtifactsInfo:KD(t),responses:[i]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${i.status}.`)}async loadModelJSON(){const t=await this.fetch(this.path,this.requestInit);if(!t.ok)throw new Error(`Request to ${this.path} failed with status code ${t.status}. Please verify this URL points to the model JSON of the model to load.`);let e;try{e=await t.json()}catch(t){let e=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?e+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":e+=" Please make sure the server is serving valid JSON for this request.",new Error(e)}const n=e.modelTopology,i=e.weightsManifest;if(null==n&&null==i)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return e}async load(){if(this.loadOptions.streamWeights)return this.loadStream();return qD(await this.loadModelJSON(),(t=>this.loadWeights(t)))}async loadStream(){const t=await this.loadModelJSON(),e=await this.getWeightUrls(t.weightsManifest),n=QD(t.weightsManifest);return Object.assign(Object.assign({},t),{weightSpecs:n,getWeightStream:()=>function(t,e){var n;const i=null==e.fetchFunc?aA().platform.fetch:e.fetchFunc;let s,r=0;return null===(n=e.onProgress)||void 0===n||n.call(e,0),new ReadableStream({pull:async n=>{for(var a;r<t.length;){if(!s){const n=(await i(t[r],e.requestInit,{isBinary:!0})).body;s=n.getReader()}const{done:o,value:l}=await s.read();if(!o)return void n.enqueue(l);r++,s=void 0,null===(a=e.onProgress)||void 0===a||a.call(e,r/t.length)}n.close()}})}(e,this.loadOptions)})}async getWeightUrls(t){const e=Array.isArray(this.path)?this.path[1]:this.path,[n,i]=function(t){const e=t.lastIndexOf("/"),n=t.lastIndexOf("?"),i=t.substring(0,e),s=n>e?t.substring(n):"";return[i+"/",s]}(e),s=this.weightPathPrefix||n,r=[],a=[];for(const e of t)for(const t of e.paths)null!=this.weightUrlConverter?a.push(this.weightUrlConverter(t)):r.push(s+t+i);return this.weightUrlConverter&&r.push(...await Promise.all(a)),r}async loadWeights(t){const e=await this.getWeightUrls(t);return[QD(t),await AF(e,this.loadOptions)]}}function kF(t){return null!=t.match(NF.URL_SCHEME_REGEX)}NF.URL_SCHEME_REGEX=/^https?:\/\//;const DF=(t,e)=>{if("undefined"==typeof fetch&&(null==e||null==e.fetchFunc))return null;{let n=!0;if(n=Array.isArray(t)?t.every((t=>kF(t))):kF(t),n)return LF(t,e)}return null};function LF(t,e){return new NF(t,e)}function FF(t,e){return LF(t,e)}JD.registerSaveRouter(DF),JD.registerLoadRouter(DF);
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class PF{constructor(t){this.modelArtifacts=t}load(){return this.modelArtifacts}}class $F{constructor(t){this.saveHandler=t}save(t){return this.saveHandler(t)}}class BF{constructor(t){t.load&&(this.load=()=>Promise.resolve(t.load())),t.save&&(this.save=e=>Promise.resolve(t.save(e)))}}function VF(t,e,n,i){return new BF(UF(...arguments))}function UF(t,e,n,i){if(1===arguments.length){return null!=t.modelTopology||null!=t.weightSpecs?new PF(t):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new PF({modelTopology:t}))}return console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new PF({modelTopology:t,weightSpecs:e,weightData:n,trainingConfig:i})}function YF(t){return new $F(t)}function GF(t){return new $F(t)}const HF=oD({matMul_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n=!1,i=!1){let s=sD(t,"a","matMul"),r=sD(e,"b","matMul");[s,r]=Bk(s,r);const a={a:s,b:r},o={transposeA:n,transposeB:i};return jk.runKernel(AA,a,o)}});const WF=oD({oneHot_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n=1,i=0,s="int32"){if(e<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${e}`);const r={indices:sD(t,"indices","oneHot","int32")},a={dtype:s,depth:e,onValue:n,offValue:i};return jk.runKernel(fC,r,a)}});const zF=oD({imag_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={input:sD(t,"input","imag")};return jk.runKernel(AM,e)}});const XF=oD({neg_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","neg")};return jk.runKernel(lC,e)}});const jF=oD({real_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={input:sD(t,"input","real")};return jk.runKernel(SC,e)}});const qF=oD({transpose_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"x","transpose");if(null==e&&(e=i.shape.map(((t,e)=>e)).reverse()),_O(i.rank===e.length,(()=>`Error in transpose: rank of input ${i.rank} must match length of perm ${e}.`)),e.forEach((t=>{_O(t>=0&&t<i.rank,(()=>"All entries in 'perm' must be between 0 and "+(i.rank-1)+` but got ${e}`))})),i.rank<=1)return i.clone();const s={x:i},r={perm:e};return"complex64"===i.dtype?ED((()=>{let t=jF(i),e=zF(i);return t=jk.runKernel(_N,{x:t},r),e=jk.runKernel(_N,{x:e},r),n&&(e=XF(e)),lD(t,e)})):jk.runKernel(_N,s,r)}});const KF=oD({confusionMatrix_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"labels","confusionMatrix"),s=sD(e,"predictions","confusionMatrix");_O(null==n||n>0&&Number.isInteger(n),(()=>`If provided, numClasses must be a positive integer, but got ${n}`)),_O(1===i.rank,(()=>`Expected the rank of labels to be 1, but got ${i.rank}`)),_O(1===s.rank,(()=>`Expected the rank of predictions to be 1, but got ${s.rank}`)),_O(i.shape[0]===s.shape[0],(()=>`Mismatch in the number of examples: ${i.shape[0]} vs. ${s.shape[0]}. Labels and predictions should have the same number of elements.`)),_O(n>0&&Number.isInteger(n),(()=>`numClasses is required to be a positive integer, but got ${n}`));const r=WF(PL(i,"int32"),n),a=WF(PL(s,"int32"),n),o=qF(r),l=HF(o,a);return PL(l,"int32")}});
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function QF(t,e,n){if(yO(t),null!=e&&3!==e.length)throw new Error("tensor3d() requires shape to have three numbers");const i=eD(t,n);if(3!==i.length&&1!==i.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===i.length&&null==e)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return uD(t,e,i,n)}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
let JF,ZF=!1;function tP(t,e=3){if(e>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==t)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let n=!1,i=!1,s=!1,r=!1,a=!1,o=!1;if(t.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&t instanceof ImageData)i=!0;else if("undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement)s=!0;else if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement)r=!0;else if(null!=t.getContext)a=!0;else{if(!("undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap))throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${t.constructor.name}`);o=!0}if(null!=kN(wN,jk.backendName)){const n={pixels:t},i={numChannels:e};return jk.runKernel(wN,n,i)}const[l,u]=s?[t.videoWidth,t.videoHeight]:[t.width,t.height];let h,p;if(a)h=t.getContext("2d").getImageData(0,0,l,u).data;else if(i||n)h=t.data;else if(r||s||o){if(null==JF)if("undefined"==typeof document){if("undefined"==typeof OffscreenCanvas||"undefined"==typeof OffscreenCanvasRenderingContext2D)throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");JF=new OffscreenCanvas(1,1).getContext("2d")}else JF=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});JF.canvas.width=l,JF.canvas.height=u,JF.drawImage(t,0,0,l,u),h=JF.getImageData(0,0,l,u).data}if(4===e)p=new Int32Array(h);else{const t=l*u;p=new Int32Array(t*e);for(let n=0;n<t;n++)for(let t=0;t<e;++t)p[n*e+t]=h[4*n+t]}return QF(p,[u,l,e],"int32")}function eP(t){return"undefined"!=typeof window&&"undefined"!=typeof ImageBitmap&&window.hasOwnProperty("createImageBitmap")&&!(t instanceof ImageBitmap)&&function(t){return null!=t&&0!==t.width&&0!==t.height}(t)&&!function(t){return null!=t&&t.data instanceof Uint8Array}(t)}async function nP(t,e=3){let n=null;if(aA().getBool("WRAP_TO_IMAGEBITMAP")&&eP(t)){let e;try{e=await createImageBitmap(t,{premultiplyAlpha:"none"})}catch(t){e=null}n=null!=e&&e.width===t.width&&e.height===t.height?e:t}else n=t;return tP(n,e)}function iP(t){if(2!==t.rank&&3!==t.rank)throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${t.rank}.`);const e=2===t.rank?1:t.shape[2];if(e>4||2===e)throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${e}`);if("float32"!==t.dtype&&"int32"!==t.dtype)throw new Error(`Unsupported type for toPixels: ${t.dtype}. Please use float32 or int32 tensors.`)}async function sP(t,e){let n=sD(t,"img","toPixels");if(!(t instanceof xk)){const t=n;n=PL(t,"int32"),t.dispose()}iP(n);const[i,s]=n.shape.slice(0,2),r=2===n.rank?1:n.shape[2],a=await n.data(),o="float32"===n.dtype?255:1,l=new Uint8ClampedArray(s*i*4);for(let t=0;t<i*s;++t){const e=[0,0,0,255];for(let i=0;i<r;i++){const s=a[t*r+i];if("float32"===n.dtype){if(s<0||s>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${s}.`)}else if("int32"===n.dtype&&(s<0||s>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${s}.`);1===r?(e[0]=s*o,e[1]=s*o,e[2]=s*o):e[i]=s*o}const i=4*t;l[i+0]=Math.round(e[0]),l[i+1]=Math.round(e[1]),l[i+2]=Math.round(e[2]),l[i+3]=Math.round(e[3])}if(null!=e){if(!ZF){null!=kN(oM,jk.backendName)&&(console.warn("tf.browser.toPixels is not efficient to draw tensor on canvas. Please try tf.browser.draw instead."),ZF=!0)}e.width=s,e.height=i;const t=e.getContext("2d"),n=new ImageData(l,s,i);t.putImageData(n,0,0)}return n!==t&&n.dispose(),l}function rP(t,e,n){let i=sD(t,"img","draw");if(!(t instanceof xk)){const t=i;i=PL(t,"int32"),t.dispose()}iP(i),function(t){const e=(null==t?void 0:t.alpha)||1;if(e>1||e<0)throw new Error(`Alpha value ${e} is suppoed to be in range [0 - 1].`)}(null==n?void 0:n.imageOptions);const s={image:i},r={canvas:e,options:n};jk.runKernel(oM,s,r)}const aP=oD({fromPixels_:tP});function oP(t,e){const n=t.shape.length,i=e.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(i<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${i}.`);if("int32"!==e.dtype)throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.shape[i-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${e.shape[i-1]} vs. ${n}`);if(0===IO(t.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${t.shape}.`);const s=e.shape,r=s[s.length-1];let a=1;for(let t=0;t<s.length-1;++t)a*=s[t];const o=t.shape,l=s.slice();l.pop();let u=1;for(let t=r;t<n;++t)u*=o[t],l.push(o[t]);const h=[...zO(t.shape).map((t=>t/u)),1].slice(0,r);return[l,a,u,h]}function lP(t,e,n){const i=e.rank>1?e.shape[e.rank-1]:1,s=e.rank>1?e.rank-1:1,r=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${e.shape}, shape: ${t}, sliceDim: ${i}, and batchDim: ${s}.`;if(n.rank<s)throw new Error(r+` update.rank < ${s}. `);if(t.length<i+(n.rank-s))throw new Error(r+` Output shape length < ${i+(n.rank-s)}`);if(n.rank!==s+t.length-i)throw new Error(r+" update.rank != "+(s+t.length-i));for(let t=0;t<s;++t)if(n.shape[t]!==e.shape[t])throw new Error(r+` updates.shape[${t}] (${n.shape[t]}) != indices.shape[${t}] (${e.shape[t]}).`);for(let e=0;e<n.rank-s;++e)if(n.shape[e+s]!==t[e+i])throw new Error(r+` updates.shape[${e+s}] (${n.shape[e+s]}) != shape[${e+s}] (${t[e+s]})`)}function uP(t,e,n){if(e.rank<1)throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${e.rank}.`);if(t.rank<1)throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${t.rank}.`);if("int32"!==e.dtype)throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${e.dtype}`);if(n.length<1)throw new Error(`Output rank must be greater or equal to 1, but got shape: ${n}`);if(0===n.length){if(0===e.size)throw new Error(`Indices specified for empty output. indices shape: ${e.shape}`);if(0===t.size)throw new Error(`Updates specified for empty output. updates shape: ${t.shape}`)}lP(n,e,t)}function hP(t,e,n){const i=e.shape.length,s=i>1?e.shape[i-1]:1,r=n.length;let a=1;for(let t=s;t<r;++t)a*=n[t];const o=s<1?1:s;return{sliceRank:s,numUpdates:IO(e.shape)/o,sliceSize:a,strides:[...zO(n.slice(0,s)),1],outputSize:IO(n)}}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const pP=-2,cP=-1;function dP(t,e,n){const i=t.shape.length;_O(i===e.length,(()=>`Error in slice${i}D: Length of begin ${e} must match the rank of the array (${i}).`)),_O(i===n.length,(()=>`Error in slice${i}D: Length of size ${n} must match the rank of the array (${i}).`));for(let s=0;s<i;++s)_O(e[s]+n[s]<=t.shape[s],(()=>`Error in slice${i}D: begin[${s}] + size[${s}] (${e[s]+n[s]}) would overflow input.shape[${s}] (${t.shape[s]})`))}function fP(t){const e=[];let n=0;for(;t>0;)1&t&&e.push(n),t/=2,n++;return e}function mP(t,e,n){const i=[];for(let s=0;s<t.length;s++)i[s]=Math.ceil((e[s]-t[s])/n[s]);return i}function gP(t,e,n,i){const s=[...t];for(let t=s.length;t<i.length;t++)s.push(1);for(let t=0;t<n;t++)0===t?s[e]=1:(s.splice(e,0,1),s.pop());return s}function _P(t,e,n){return n<=t?n:n-(e-1)}function TP(t,e){const n=[];for(let i=0;i<t;i++)n.push(e+i);return n}function yP(t,e,n,i,s,r,a,o,l){const u=t.length;let h=new Array(u),p=new Array(u),c=new Array(u);if(e.length&&n>0){const l=e[0],u=n+1;h=IP(a,l,u,i,t),p=EP(o,l,u,s,t),c=gP(r,l,u,t)}else for(let e=0;e<u;e++)h[e]=vP(a,i,r,t,e,l),p[e]=wP(o,s,r,t,e,l),c[e]=bP(r,e,l);return{begin:h,end:p,strides:c}}function IP(t,e,n,i,s){const r=[...s],a=TP(n,e);for(let s=0;s<r.length;s++)if(a.indexOf(s)>-1)r[s]=0;else{const a=_P(e,n,s);let o=i[a];t&1<<a&&(o=0),r[s]=o}return r}function EP(t,e,n,i,s){const r=[...s],a=TP(n,e);for(let s=0;s<r.length;s++)if(a.indexOf(s)>-1)r[s]=Number.MAX_SAFE_INTEGER;else{const a=_P(e,n,s);let o=i[a];t&1<<a&&(o=Number.MAX_SAFE_INTEGER),r[s]=o}for(let t=0;t<r.length;t++){const e=s[t];r[t]<0&&(r[t]+=e),r[t]=pO(0,r[t],s[t])}return r}function bP(t,e,n){let i=t[e];return(n&1<<e||null==i)&&(i=1),i}function vP(t,e,n,i,s,r){let a=e[s];const o=n[s]||1;(t&1<<s||r&1<<s||null==a)&&(a=o>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const l=i[s];return a<0&&(a+=l),a=pO(0,a,l-1),a}function wP(t,e,n,i,s,r){let a=e[s];const o=n[s]||1;(t&1<<s||r&1<<s||null==a)&&(a=o>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const l=i[s];return a<0&&(a+=l),a=o>0?pO(0,a,l):pO(-1,a,l-1),a}function SP(t,e,n){let i=n.length;for(let t=0;t<n.length;t++)if(n[t]>1){i=t;break}for(let s=i+1;s<n.length;s++)if(e[s]>0||n[s]!==t[s])return!1;return!0}function xP(t,e){let n=t.length>0?t[t.length-1]:1;for(let i=0;i<t.length-1;i++)n+=t[i]*e[i];return n}function RP(t,e,n){let i;const s=t.shape.length;let r;return i="number"==typeof e?[e,...new Array(s-1).fill(0)]:e.length<s?e.concat(new Array(s-e.length).fill(0)):e.slice(),i.forEach((t=>{_O(-1!==t,(()=>"slice() does not support negative begin indexing."))})),r=null==n?new Array(s).fill(-1):"number"==typeof n?[n,...new Array(s-1).fill(-1)]:n.length<s?n.concat(new Array(s-n.length).fill(-1)):n,r=r.map(((e,n)=>e>=0?e:(_O(-1===e,(()=>`Negative size values should be exactly -1 but got ${e} for the slice() size at index ${n}.`)),t.shape[n]-i[n]))),[i,r]}function OP(t,e,n,i,s,r,a,o,l){let u;if(null==i?(u=new Array(e.length),u.fill(1)):u=i,null!=a&&a&a-1)throw new Error("Multiple ellipses in slice is not allowed.");let h=!1;const p={dims:u.length,numAddAxisAfterEllipsis:0,begin:e.slice(),end:n.slice(),strides:u.slice(),beginMask:s,endMask:r,ellipsisMask:a,newAxisMask:o,shrinkAxisMask:l};for(let t=0;t<p.dims;t++)h&&1<<t&o&&p.numAddAxisAfterEllipsis++,1<<t&a&&(h=!0);h||(p.ellipsisMask|=1<<p.dims,p.dims++);const c={dims:t.length,beginMask:0,endMask:0,beginValid:!1,endValid:!1};!function(t,e){e.beginMask=0,e.endMask=0,e.shrinkAxisMask=0;let n=0;e.beginValid=null!=t.begin,e.endValid=null!=t.end,e.begin=new Array(e.dims),e.end=new Array(e.dims),e.strides=new Array(e.dims),e.finalShapeGatherIndices=[],e.finalShapeGatherIndicesSparse=[],e.inputShapeGatherIndicesSparse=new Array(e.dims);for(let i=0;i<t.dims;i++)if(1<<i&t.ellipsisMask){const s=Math.min(e.dims-(t.dims-i)+1+t.numAddAxisAfterEllipsis,e.dims);for(;n<s;n++)e.begin[n]=0,e.end[n]=0,e.strides[n]=1,e.beginMask|=1<<n,e.endMask|=1<<n,e.finalShapeGatherIndices.push(n),e.finalShapeGatherIndicesSparse.push(-1),e.inputShapeGatherIndicesSparse[n]=i}else if(1<<i&t.newAxisMask)e.finalShapeGatherIndices.push(pP),e.finalShapeGatherIndicesSparse.push(-1);else{if(n===e.begin.length)throw Error(`Index out of range using input dim ${n}; input has only ${e.dims} dims, ${e.begin.length}.`);null!=t.begin&&(e.begin[n]=t.begin[i]),null!=t.end&&(e.end[n]=t.end[i]),e.strides[n]=t.strides[i],t.beginMask&1<<i&&(e.beginMask|=1<<n),t.endMask&1<<i&&(e.endMask|=1<<n),t.shrinkAxisMask&1<<i?(e.finalShapeGatherIndices.push(cP),e.finalShapeGatherIndicesSparse.push(-1),e.shrinkAxisMask|=1<<n):(e.finalShapeGatherIndices.push(n),e.finalShapeGatherIndicesSparse.push(i)),e.inputShapeGatherIndicesSparse[n]=i,n++}}(p,c);let d=!0,f=!0,m=!0;const g=[],_=[];for(let e=0;e<t.length;++e){if(0===c.strides[e])throw Error(`strides[${e}] must be non-zero`);const n=!!(c.shrinkAxisMask&1<<e),i=t[e];if(-1===i){g.push(n?1:-1);continue}const s=[c.beginMask&1<<e,c.endMask&1<<e],r=[c.strides[e]>0?0:-1,c.strides[e]>0?i:i-1];if(n&&c.strides[e]<=0)throw Error("only stride 1 allowed on non-range indexing.");m=m&&1===c.strides[e];const a=!!(c.beginMask&1<<e&&c.endMask&1<<e);if(c.beginValid&&c.endValid){if(n){const t=c.begin[e]<0?i+c.begin[e]:c.begin[e];if(c.begin[e]=t,c.end[e]=c.begin[e]+1,t<0||t>=i)throw Error(`slice index ${c.begin[e]} of dimension ${e} out of bounds.`)}else c.begin[e]=AP(c.begin[e],0,c.strides[e],i,s,r),c.end[e]=AP(c.end[e],1,c.strides[e],i,s,r);const t=1===c.strides[e]&&0===c.begin[e]&&c.end[e]===i;d=d&&t,f=f&&(0===e&&1===c.strides[e]||t)}else d=d&&1===c.strides[e]&&a,f=f&&(0===e&&1===c.strides[e]||a);let o,l=!1;if(c.beginValid&&c.endValid?(o=c.end[e]-c.begin[e],l=!0):n?(o=1,l=!0):a&&i>=0&&(o=c.strides[e]<0?-i:i,l=!0),l){let t;t=0===o||o<0!=c.strides[e]<0?0:Math.trunc(o/c.strides[e])+(o%c.strides[e]!=0?1:0),g.push(t)}else g.push(-1)}for(let t=0;t<c.finalShapeGatherIndices.length;++t){const e=c.finalShapeGatherIndices[t];e>=0?_.push(g[e]):e===pP&&_.push(1)}return{finalShapeSparse:_.filter(((t,e)=>c.finalShapeGatherIndices[e]!==pP)),finalShape:_,isIdentity:d,sliceDim0:f,isSimpleSlice:m,begin:c.begin,end:c.end,strides:c.strides}}function AP(t,e,n,i,s,r){if(s[e])return n>0?r[e]:r[e+1&1];{const e=t<0?i+t:t;return e<r[0]?r[0]:e>r[1]?r[1]:e}}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const MP=.001,CP=.1;function NP(t,e,n){return null==n&&(n=kP()),DP(t,e,((t,e)=>$P(t,e,n)))}function kP(){return 32===jk.backend.floatPrecision()?MP:CP}function DP(t,e,n){let i=!0;if((uk(t)||uk(e))&&(i=!1),uk(t)&&uk(e)&&(i=!0),i){const n=t.constructor.name,i=e.constructor.name;if(n!==i)throw new Error(`Arrays are of different type. Actual: ${n}. Expected: ${i}`)}if(Array.isArray(t)&&Array.isArray(e)){const n=eD(t),i=eD(e);if(!vO(n,i))throw new Error(`Arrays have different shapes. Actual: [${n}]. Expected: [${i}]`)}const s=uk(t)?t:hk(t),r=uk(e)?e:hk(e);if(s.length!==r.length)throw new Error(`Arrays have different lengths actual: ${s.length} vs expected: ${r.length}.\nActual: ${s}.\nExpected: ${r}.`);for(let t=0;t<r.length;++t){const e=s[t],i=r[t];if(!n(e,i))throw new Error(`Arrays differ: actual[${t}] = ${e}, expected[${t}] = ${i}.\nActual: ${s}.\nExpected: ${r}.`)}"undefined"!=typeof expect&&expect().nothing()}function LP(t,e){t().then((()=>e.fail()),(()=>e())),"undefined"!=typeof expect&&expect().nothing()}function FP(t,e){const n="string"==typeof e||"number"==typeof e||"boolean"==typeof e?[e]:e;return VO(t)||VO(t[0])||VO(e)||VO(e[0])?DP(t,n,((t,e)=>t==e)):DP(t,e,((t,e)=>$P(t,e,0)))}function PP(t,e,n){if(null==n&&(n=kP()),!$P(t,e,n))throw new Error(`Numbers differ: actual === ${t}, expected === ${e}`);"undefined"!=typeof expect&&expect().nothing()}function $P(t,e,n){return!isFinite(t)&&!isFinite(e)||!(isNaN(t)||isNaN(e)||Math.abs(t-e)>n)}function BP(t,e,n){for(let i=0;i<t.length;i++)if(t[i]<e||t[i]>n)throw new Error(`Value out of range:${t[i]} low: ${e}, high: ${n}`)}function VP(t,e){const n=new Float32Array(t),i=new Float32Array(e);if(n.length!==i.length)throw new Error(`Expected ArrayBuffer to be of length ${i.length}, but it was ${n.length}`);for(let t=0;t<i.length;t++)if(n[t]!==i[t])throw new Error(`Expected ArrayBuffer value at ${t} to be ${i[t]} but got ${n[t]} instead`)}function UP(t){for(let e=0;e<t.length;e++){const n=t[e];Array.isArray(n)?UP(n):t[e]=ok(n)}return t}function YP(t){const e=document.createElement("video");return"playsInline"in e&&(e.playsInline=!0),e.muted=!0,e.loop=!0,e.style.position="fixed",e.style.left="0px",e.style.top="0px",e.preload="auto",e.appendChild(t),new Promise((t=>{e.addEventListener("loadeddata",(n=>t(e))),e.load()}))}async function GP(t){await t.play(),"requestVideoFrameCallback"in t&&await new Promise((e=>{t.requestVideoFrameCallback(e)}))}
/** @license See the LICENSE file. */
const HP="4.22.0";
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class WP{static sgd(t){return new IF(t)}static momentum(t,e,n=!1){return new EF(t,e,n)}static rmsprop(t,e=.9,n=0,i=null,s=!1){return new bF(t,e,n,i,s)}static adam(t=.001,e=.9,n=.999,i=null){return new dF(t,e,n,i)}static adadelta(t=.001,e=.95,n=null){return new lF(t,e,n)}static adamax(t=.002,e=.9,n=.999,i=null,s=0){return new yF(t,e,n,i,s)}static adagrad(t,e=.1){return new hF(t,e)}}const zP=oD({acos_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","acos")};return jk.runKernel(cA,e)}});const XP=oD({acosh_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","acosh")};return jk.runKernel(dA,e)}});const jP=oD({addN_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){_O(Array.isArray(t),(()=>"The argument passed to tf.addN() must be a list of tensors")),_O(t.length>=1,(()=>`Must pass at least one tensor to tf.addN(), but got ${t.length}`));const e=t.map(((t,e)=>sD(t,`tensors${e}`,"addN"))),n=e[0];e.forEach((t=>{if(t.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),e.forEach((t=>{if(!vO(t.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));const i=e;return jk.runKernel(mA,i)}});const qP=oD({all_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=null,n=!1){const i={x:sD(t,"x","all","bool")},s={axis:e,keepDims:n};return jk.runKernel(gA,i,s)}});const KP=oD({any_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=null,n=!1){const i={x:sD(t,"x","any","bool")},s={axis:e,keepDims:n};return jk.runKernel(_A,i,s)}});const QP=oD({argMax_:
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0){const n={x:sD(t,"x","argMax")},i={axis:e};return jk.runKernel(TA,n,i)}});const JP=oD({argMin_:
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0){const n={x:sD(t,"x","argMin")},i={axis:e};return jk.runKernel(yA,n,i)}});const ZP=oD({asin_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","asin")};return jk.runKernel(IA,e)}});const t$=oD({asinh_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","asinh")};return jk.runKernel(EA,e)}});const e$=oD({atan_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","atan")};return jk.runKernel(bA,e)}});const n$=oD({atan2_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","atan2"),i=sD(e,"b","atan2");[n,i]=Bk(n,i);const s={a:n,b:i};return jk.runKernel(wA,s)}});const i$=oD({atanh_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","atanh")};return jk.runKernel(vA,e)}});
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function s$(t,e,n,i,s="NHWC",r){return o$(t,[...e,t[3]],n,r,i,null,null,_$(s))}function r$(t,e,n,i,s,r,a="channelsLast"){const[o,l]=h$(e);let u;if("channelsLast"===a)u=[o,l,t[3],t[3]];else{if("channelsFirst"!==a)throw new Error(`Unknown dataFormat ${a}`);u=[o,l,t[1],t[1]]}return o$(t,u,n,i,s,r,!1,a)}function a$(t,e,n,i,s,r,a="NDHWC"){const[o,l,u]=p$(e);let h,p;if("NDHWC"===a)p="channelsLast",h=[o,l,u,t[4],t[4]];else{if("NCDHW"!==a)throw new Error(`Unknown dataFormat ${a}`);p="channelsFirst",h=[o,l,u,t[1],t[1]]}return l$(t,h,n,i,s,!1,p,r)}function o$(t,e,n,i,s,r,a=!1,o="channelsLast"){let[l,u,h,p]=[-1,-1,-1,-1];if("channelsLast"===o)[l,u,h,p]=t;else{if("channelsFirst"!==o)throw new Error(`Unknown dataFormat ${o}`);[l,p,u,h]=t}const[c,d,,f]=e,[m,g]=h$(n),[_,T]=h$(i),y=c$(c,_),I=c$(d,T),{padInfo:E,outHeight:b,outWidth:v}=function(t,e,n,i,s,r,a,o,l){let u,h,p;if("number"==typeof t){u={top:t,bottom:t,left:t,right:t,type:0===t?"VALID":"NUMBER"};const s=function(t,e,n,i,s){null==i&&(i=u$(t,e,n));const r=t[0],a=t[1],o=d$((r-e+2*i)/n+1,s),l=d$((a-e+2*i)/n+1,s);return[o,l]}([e,n],r,i,t,o);h=s[0],p=s[1]}else if("same"===t){h=Math.ceil(e/i),p=Math.ceil(n/s);const t=Math.max(0,(h-1)*i+r-e),o=Math.max(0,(p-1)*s+a-n),l=Math.floor(t/2),c=t-l,d=Math.floor(o/2);u={top:l,bottom:c,left:d,right:o-d,type:"SAME"}}else if("valid"===t)u={top:0,bottom:0,left:0,right:0,type:"VALID"},h=Math.ceil((e-r+1)/i),p=Math.ceil((n-a+1)/s);else{if("object"!=typeof t)throw Error(`Unknown padding parameter: ${t}`);{const c="channelsLast"===l?t[1][0]:t[2][0],d="channelsLast"===l?t[1][1]:t[2][1],f="channelsLast"===l?t[2][0]:t[3][0],m="channelsLast"===l?t[2][1]:t[3][1];u={top:c,bottom:d,left:f,right:m,type:0===c&&0===d&&0===f&&0===m?"VALID":"EXPLICIT"},h=d$((e-r+c+d)/i+1,o),p=d$((n-a+f+m)/s+1,o)}}return{padInfo:u,outHeight:h,outWidth:p}}(s,u,h,m,g,y,I,r,o),w=a?f*p:f;let S;return"channelsFirst"===o?S=[l,w,b,v]:"channelsLast"===o&&(S=[l,b,v,w]),{batchSize:l,dataFormat:o,inHeight:u,inWidth:h,inChannels:p,outHeight:b,outWidth:v,outChannels:w,padInfo:E,strideHeight:m,strideWidth:g,filterHeight:c,filterWidth:d,effectiveFilterHeight:y,effectiveFilterWidth:I,dilationHeight:_,dilationWidth:T,inShape:t,outShape:S,filterShape:e}}function l$(t,e,n,i,s,r=!1,a="channelsLast",o){let[l,u,h,p,c]=[-1,-1,-1,-1,-1];if("channelsLast"===a)[l,u,h,p,c]=t;else{if("channelsFirst"!==a)throw new Error(`Unknown dataFormat ${a}`);[l,c,u,h,p]=t}const[d,f,m,,g]=e,[_,T,y]=p$(n),[I,E,b]=p$(i),v=c$(d,I),w=c$(f,E),S=c$(m,b),{padInfo:x,outDepth:R,outHeight:O,outWidth:A}=function(t,e,n,i,s,r,a,o,l,u,h){let p,c,d,f;"valid"===t&&(t=0);if("number"==typeof t){p={top:t,bottom:t,left:t,right:t,front:t,back:t,type:0===t?"VALID":"NUMBER"};const m=function(t,e,n,i,s,r){null==s&&(s=u$(t,e[0],i[0]));const a=[0,0,0,n];for(let n=0;n<3;n++)t[n]+2*s>=e[n]&&(a[n]=d$((t[n]-e[n]+2*s)/i[n]+1,r));return a}([e,n,i,1],[o,l,u],1,[s,r,a],t,h);c=m[0],d=m[1],f=m[2]}else{if("same"!==t)throw Error(`Unknown padding parameter: ${t}`);{c=Math.ceil(e/s),d=Math.ceil(n/r),f=Math.ceil(i/a);const t=(c-1)*s+o-e,h=(d-1)*r+l-n,m=(f-1)*a+u-i,g=Math.floor(t/2),_=t-g,T=Math.floor(h/2),y=h-T,I=Math.floor(m/2);p={top:T,bottom:y,left:I,right:m-I,front:g,back:_,type:"SAME"}}}return{padInfo:p,outDepth:c,outHeight:d,outWidth:f}}(s,u,h,p,_,T,y,v,w,S,o),M=r?g*c:g;let C;return"channelsFirst"===a?C=[l,M,R,O,A]:"channelsLast"===a&&(C=[l,R,O,A,M]),{batchSize:l,dataFormat:a,inDepth:u,inHeight:h,inWidth:p,inChannels:c,outDepth:R,outHeight:O,outWidth:A,outChannels:M,padInfo:x,strideDepth:_,strideHeight:T,strideWidth:y,filterDepth:d,filterHeight:f,filterWidth:m,effectiveFilterDepth:v,effectiveFilterHeight:w,effectiveFilterWidth:S,dilationDepth:I,dilationHeight:E,dilationWidth:b,inShape:t,outShape:C,filterShape:e}}function u$(t,e,n,i=1){const s=c$(e,i);return Math.floor((t[0]*(n-1)-n+s)/2)}function h$(t){return"number"==typeof t?[t,t,t]:2===t.length?[t[0],t[1],1]:t}function p$(t){return"number"==typeof t?[t,t,t]:t}function c$(t,e){return e<=1?t:t+(t-1)*(e-1)}function d$(t,e){if(!e)return Math.trunc(t);switch(e){case"round":return Math.round(t);case"ceil":return Math.ceil(t);case"floor":return Math.floor(t);default:throw new Error(`Unknown roundingMode ${e}`)}}function f$(t){const[e,n,i]=h$(t);return 1===e&&1===n&&1===i}function m$(t,e){return f$(t)||f$(e)}function g$(t){return h$(t).every((t=>t>0))}function _$(t){if("NHWC"===t)return"channelsLast";if("NCHW"===t)return"channelsFirst";throw new Error(`Unknown dataFormat ${t}`)}function T$(t,e,n){if(null!=n){if("string"==typeof e)throw Error(`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${e}.`);if("number"==typeof e)_O(wO(e),(()=>`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${e}.`));else{if("object"!=typeof e)throw Error(`Error in ${t}: Unknown padding parameter: ${e}`);e.forEach((e=>{e.forEach((e=>{_O(wO(e),(()=>`Error in ${t}: pad must be an integer when using dimRoundingMode ${n} but got pad ${e}.`))}))}))}}}const y$=oD({reshape_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n={x:sD(t,"x","reshape","string_or_numeric")},i={shape:e};return jk.runKernel(OC,n,i)}});const I$=oD({avgPool_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s){const r=sD(t,"x","avgPool","float32");_O(m$(n,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`));let a=r,o=!1;3===r.rank&&(o=!0,a=y$(r,[1,r.shape[0],r.shape[1],r.shape[2]])),_O(4===a.rank,(()=>`Error in avgPool: x must be rank 4 but got rank ${a.rank}.`)),T$("avgPool",i,s);const l={x:a},u={filterSize:e,strides:n,pad:i,dimRoundingMode:s};let h=jk.runKernel(SA,l,u);return h=PL(h,r.dtype),o?y$(h,[h.shape[1],h.shape[2],h.shape[3]]):h}});const E$=oD({avgPool3d_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r="NDHWC"){const a=sD(t,"x","avgPool3d","float32");let o=a,l=!1;4===a.rank&&(l=!0,o=y$(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]])),_O(5===o.rank,(()=>`Error in avgPool3d: x must be rank 5 but got rank ${o.rank}.`)),_O("NDHWC"===r,(()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${r}`)),_O("number"==typeof n&&n>0||Array.isArray(n)&&n[0]>0&&n[1]>0&&n[2]>0,(()=>`Error in avgPool3d: Stride must be > 0, but got '${n}'`)),T$("avgPool3d",i,s);const u={x:o},h={filterSize:e,strides:n,pad:i,dimRoundingMode:s,dataFormat:r};let p=jk.runKernel(RA,u,h);return p=PL(p,o.dtype),l?y$(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}});const b$=oD({concat_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0){_O(t.length>=1,(()=>"Pass at least one tensor to concat"));const n=rD(t,"tensors","concat","string_or_numeric");if("complex64"===n[0].dtype&&n.forEach((t=>{if("complex64"!==t.dtype)throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${t.dtype}. `)})),1===n.length)return $L(n[0]);const i=n,s={axis:e};return jk.runKernel(VA,i,s)}});const v$=oD({sigmoid_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","sigmoid","float32")};return jk.runKernel(zC,e)}});const w$=oD({slice_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"x","slice","string_or_numeric");if(0===i.rank)throw new Error("Slicing scalar is not possible");const s={x:i},r={begin:e,size:n};return jk.runKernel(YC,s,r)}});const S$=oD({tanh_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","tanh","float32")};return jk.runKernel(dN,e)}});const x$=oD({basicLSTMCell_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r){const a=sD(t,"forgetBias","basicLSTMCell"),o=sD(e,"lstmKernel","basicLSTMCell"),l=sD(n,"lstmBias","basicLSTMCell"),u=sD(i,"data","basicLSTMCell"),h=sD(s,"c","basicLSTMCell"),p=sD(r,"h","basicLSTMCell"),c=b$([u,p],1),d=HF(c,o),f=VL(d,l),m=f.shape[0],g=f.shape[1]/4,_=[m,g],T=w$(f,[0,0],_),y=w$(f,[0,g],_),I=w$(f,[0,2*g],_),E=w$(f,[0,3*g],_),b=VL(GL(v$(T),S$(y)),GL(h,v$(VL(a,I))));return[b,GL(S$(b),v$(E))]}});const R$=oD({batchToSpaceND_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"x","batchToSpaceND"),s=e.reduce(((t,e)=>t*e));_O(i.rank>=1+e.length,(()=>`input rank is ${i.rank} but should be > than blockShape.length ${e.length}`)),_O(n.length===e.length,(()=>`crops.length is ${n.length} but should be equal to blockShape.length ${e.length}`)),_O(i.shape[0]%s==0,(()=>`input tensor batch is ${i.shape[0]} but is not divisible by the product of the elements of blockShape ${e.join(" * ")} === ${s}`));const r={x:i},a={blockShape:e,crops:n};return jk.runKernel(MA,r,a)}});const O$=oD({batchNorm_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r){null==r&&(r=.001);const a=sD(t,"x","batchNorm"),o=sD(e,"mean","batchNorm"),l=sD(n,"variance","batchNorm");let u,h;null!=s&&(u=sD(s,"scale","batchNorm")),null!=i&&(h=sD(i,"offset","batchNorm")),_O(o.rank===l.rank,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),_O(null==h||o.rank===h.rank,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),_O(null==u||o.rank===u.rank,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));const p={x:function(t){let e;return e=0===t.rank||1===t.rank?y$(t,[1,1,1,t.size]):2===t.rank?y$(t,[1,1,t.shape[0],t.shape[1]]):3===t.rank?y$(t,[1,t.shape[0],t.shape[1],t.shape[2]]):t,e}(a),scale:u,offset:h,mean:o,variance:l},c={varianceEpsilon:r},d=jk.runKernel(bM,p,c);return y$(d,a.shape)}});const A$=oD({batchNorm2d_:function(t,e,n,i,s,r){const a=sD(t,"x","batchNorm"),o=sD(e,"mean","batchNorm"),l=sD(n,"variance","batchNorm");let u,h;return null!=s&&(u=sD(s,"scale","batchNorm")),null!=i&&(h=sD(i,"offset","batchNorm")),_O(2===a.rank,(()=>`Error in batchNorm2D: x must be rank 2 but got rank ${a.rank}.`)),_O(2===o.rank||1===o.rank,(()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`)),_O(2===l.rank||1===l.rank,(()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${l.rank}.`)),null!=u&&_O(2===u.rank||1===u.rank,(()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${u.rank}.`)),null!=h&&_O(2===h.rank||1===h.rank,(()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${h.rank}.`)),O$(a,o,l,h,u,r)}});const M$=oD({batchNorm3d_:function(t,e,n,i,s,r){const a=sD(t,"x","batchNorm"),o=sD(e,"mean","batchNorm"),l=sD(n,"variance","batchNorm");let u,h;return null!=s&&(u=sD(s,"scale","batchNorm")),null!=i&&(h=sD(i,"offset","batchNorm")),_O(3===a.rank,(()=>`Error in batchNorm3D: x must be rank 3 but got rank ${a.rank}.`)),_O(3===o.rank||1===o.rank,(()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`)),_O(3===l.rank||1===l.rank,(()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${l.rank}.`)),null!=u&&_O(3===u.rank||1===u.rank,(()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${u.rank}.`)),null!=h&&_O(3===h.rank||1===h.rank,(()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${h.rank}.`)),O$(a,o,l,h,u,r)}});const C$=oD({batchNorm4d_:function(t,e,n,i,s,r){const a=sD(t,"x","batchNorm"),o=sD(e,"mean","batchNorm"),l=sD(n,"variance","batchNorm");let u,h;return null!=s&&(u=sD(s,"scale","batchNorm")),null!=i&&(h=sD(i,"offset","batchNorm")),_O(4===a.rank,(()=>`Error in batchNorm4D: x must be rank 4 but got rank ${a.rank}.`)),_O(4===o.rank||1===o.rank,(()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${o.rank}.`)),_O(4===l.rank||1===l.rank,(()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${l.rank}.`)),null!=u&&_O(4===u.rank||1===u.rank,(()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${u.rank}.`)),null!=h&&_O(4===h.rank||1===h.rank,(()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${h.rank}.`)),O$(a,o,l,h,u,r)}});const N$=oD({bincount_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"x","bincount"),s=sD(e,"weights","bincount");_O("int32"===i.dtype,(()=>`Error in bincount: input dtype must be int32, but got ${i.dtype}`)),_O(n>=0,(()=>`size must be non-negative, but got ${n}.`)),_O(s.size===i.size||0===s.size,(()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${i.shape}, weights shape: ${s.shape}.`));const r={x:i,weights:s},a={size:n};return jk.runKernel(CA,r,a)}});const k$=oD({bitwiseAnd_:
/**
* @license
* Copyright 2023 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"x","bitwiseAnd"),i=sD(e,"y","bitwiseAnd");if(!vO(n.shape,i.shape))throw new Error(`BitwiseAnd: Tensors must have the same shape. x: ${n.shape}, y: ${i.shape}`);if("int32"!==n.dtype||"int32"!==i.dtype)throw new Error(`BitwiseAnd: Only supports 'int32' values in tensor, found type of x: ${n.dtype} and type of y: ${i.dtype}`);const s={a:n,b:i};return jk.runKernel(NA,s)}});const D$=oD({broadcastArgs_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"s0","broadcastArgs","int32"),i=sD(e,"s1","broadcastArgs","int32");if(1!==n.rank)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`);if(1!==i.rank)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${i.rank}`);const s={s0:n,s1:i};return jk.runKernel(DA,s)}});const L$=oD({broadcastTo_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"broadcastTo","x");const i=n.shape;if(ZO(e),e.length<n.rank)throw new Error(`broadcastTo(): shape.length=${e.length} < input.rank=${n.rank}.`);if(e.length>n.rank){const t=n.shape.slice();for(;t.length<e.length;)t.unshift(1);n=y$(n,t)}const s=n.shape,r=Array.from(e);for(let t=e.length-1;t>=0;t--)if(s[t]===e[t])r[t]=1;else if(1!==n.shape[t])throw new Error(`broadcastTo(): [${i}] cannot be broadcast to [${e}].`);if(0===r.map(((t,e)=>t>1?e:-1)).filter((t=>t>=0)).length)return $L(n);const a={x:n},o={reps:r};return jk.runKernel(fN,a,o)}});const F$=oD({ceil_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","ceil","float32")};return jk.runKernel(FA,e)}});const P$=oD({clipByValue_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"x","clipByValue");if(_O(e<=n,(()=>`Error in clip: min (${e}) must be less than or equal to max (${n}).`)),e===n)return uF(i.shape,e,i.dtype);const s={x:i},r={clipValueMin:e,clipValueMax:n};return jk.runKernel(PA,s,r)}});const $$=oD({concat1d_:function(t){return b$(t,0)}});const B$=oD({concat2d_:function(t,e){return b$(t,e)}});const V$=oD({concat3d_:function(t,e){return b$(t,e)}});const U$=oD({concat4d_:function(t,e){return b$(t,e)}});const Y$=oD({conv2d_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s="NHWC",r=[1,1],a){const o=sD(t,"x","conv2d","float32"),l=sD(e,"filter","conv2d","float32");let u=o,h=!1;3===o.rank&&(h=!0,u=y$(o,[1,o.shape[0],o.shape[1],o.shape[2]])),_O(4===u.rank,(()=>`Error in conv2d: input must be rank 4, but got rank ${u.rank}.`)),_O(4===l.rank,(()=>`Error in conv2d: filter must be rank 4, but got rank ${l.rank}.`)),T$("conv2d",i,a);const p="NHWC"===s?u.shape[3]:u.shape[1];_O(p===l.shape[2],(()=>`Error in conv2d: depth of input (${p}) must match input depth for filter ${l.shape[2]}.`)),_O(m$(n,r),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${r}'`)),_O(g$(r),(()=>"Error in conv2D: Dilated rates should be larger than 0.")),_O(g$(n),(()=>"Error in conv2D: Strides should be larger than 0."));const c={x:u,filter:l},d={strides:n,pad:i,dataFormat:s,dilations:r,dimRoundingMode:a},f=jk.runKernel(UA,c,d);return h?y$(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});const G$=oD({conv1d_:function(t,e,n,i,s="NWC",r=1,a){const o=sD(t,"x","conv1d"),l=sD(e,"filter","conv1d");let u=o,h=!1;2===o.rank&&(h=!0,u=y$(o,[1,o.shape[0],o.shape[1]])),_O(3===u.rank,(()=>`Error in conv1d: input must be rank 3, but got rank ${u.rank}.`)),_O(3===l.rank,(()=>`Error in conv1d: filter must be rank 3, but got rank ${l.rank}.`)),T$("conv1d",i,a),_O(u.shape[2]===l.shape[1],(()=>`Error in conv1d: depth of input (${u.shape[2]}) must match input depth for filter ${l.shape[1]}.`)),_O(m$(n,r),(()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${r}'`)),_O(g$(r),(()=>"Error in conv1D: Dilated rates should be larger than 0.")),_O(g$(n),(()=>"Error in conv1D: Stride should be larger than 0.")),_O("NWC"===s,(()=>`Error in conv1d: got dataFormat of ${s} but only NWC is currently supported.`));const p=y$(l,[1,l.shape[0],l.shape[1],l.shape[2]]),c=y$(u,[u.shape[0],1,u.shape[1],u.shape[2]]),d=Y$(c,p,[1,n],i,"NHWC",[1,r],a);return y$(d,h?[d.shape[2],d.shape[3]]:[d.shape[0],d.shape[2],d.shape[3]])}});const H$=oD({conv2DBackpropInput_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r="NHWC",a){_O(t.length===e.rank,(()=>`Length of inShape (${t.length}) and rank of dy (${e.rank}) must match`));let o=t,l=e,u=!1;3===e.rank&&(u=!0,l=y$(e,[1,e.shape[0],e.shape[1],e.shape[2]]),o=[1,t[0],t[1],t[2]]),_O(4===o.length,(()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${o.length}.`)),_O(4===l.rank,(()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${l.rank}`)),_O(4===n.rank,(()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`));const h="NHWC"===r?o[3]:o[1],p="NHWC"===r?l.shape[3]:l.shape[1];_O(h===n.shape[2],(()=>`Error in conv2dDerInput: depth of input (${h}) must match input depth for filter ${n.shape[2]}.`)),_O(p===n.shape[3],(()=>`Error in conv2dDerInput: depth of output (${p}) must match output depth for filter ${n.shape[3]}.`)),T$("conv2dDerInput",s,a);const c={dy:l,filter:n},d={strides:i,pad:s,dataFormat:r,dimRoundingMode:a,inputShape:o},f=jk.runKernel(GA,c,d);return u?y$(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});const W$=oD({conv2dTranspose_:function(t,e,n,i,s,r){const a=sD(t,"x","conv2dTranspose"),o=sD(e,"filter","conv2dTranspose");return H$(n,a,o,i,s,"NHWC",r)}});const z$=oD({conv3d_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s="NDHWC",r=[1,1,1]){const a=sD(t,"x","conv3d"),o=sD(e,"filter","conv3d");let l=a,u=!1;4===a.rank&&(u=!0,l=y$(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]])),_O(5===l.rank,(()=>`Error in conv3d: input must be rank 5, but got rank ${l.rank}.`)),_O(5===o.rank,(()=>`Error in conv3d: filter must be rank 5, but got rank ${o.rank}.`)),_O(l.shape[4]===o.shape[3],(()=>`Error in conv3d: depth of input (${l.shape[4]}) must match input depth for filter ${o.shape[3]}.`)),_O(m$(n,r),(()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${r}'`)),_O("NDHWC"===s,(()=>`Error in conv3d: got dataFormat of ${s} but only NDHWC is currently supported.`)),_O(g$(r),(()=>"Error in conv3D: Dilated rates should be larger than 0.")),_O(g$(n),(()=>"Error in conv3D: Strides should be larger than 0."));const h={x:l,filter:o},p={strides:n,pad:i,dataFormat:s,dilations:r},c=jk.runKernel(HA,h,p);return u?y$(c,[c.shape[1],c.shape[2],c.shape[3],c.shape[4]]):c}});const X$=oD({conv3DBackpropInput_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s){_O(t.length===e.rank,(()=>`Length of inShape (${t.length}) and rank of dy (${e.rank}) must match`));let r=t,a=e,o=!1;4===e.rank&&(o=!0,a=y$(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]),r=[1,t[0],t[1],t[2],t[3]]);const l=r[4],u=a.shape[4];_O(5===r.length,(()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${r.length}.`)),_O(5===a.rank,(()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${a.rank}`)),_O(5===n.rank,(()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)),_O(l===n.shape[3],(()=>`Error in conv3dDerInput: depth of input (${l}) must match input depth for filter ${n.shape[3]}.`)),_O(u===n.shape[4],(()=>`Error in conv3dDerInput: depth of output (${u}) must match output depth for filter ${n.shape[4]}.`));const h={dy:a,filter:n},p={pad:s,strides:i,inputShape:r},c=jk.runKernel(zA,h,p);return o?y$(c,[c.shape[1],c.shape[2],c.shape[3],c.shape[4]]):c}});const j$=oD({conv3dTranspose_:function(t,e,n,i,s){const r=sD(t,"x","conv3dTranspose"),a=sD(e,"filter","conv3dTranspose");return X$(n,r,a,i,s)}});const q$=oD({cos_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","cos","float32")};return jk.runKernel(XA,e)}});const K$=oD({cosh_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","cosh","float32")};return jk.runKernel(jA,e)}});const Q$=oD({cumprod_:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0,n=!1,i=!1){const s={x:sD(t,"x","cumprod")},r={axis:e,exclusive:n,reverse:i};return jk.runKernel(qA,s,r)}});const J$=oD({cumsum_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0,n=!1,i=!1){const s={x:sD(t,"x","cumsum")},r={axis:e,exclusive:n,reverse:i};return jk.runKernel(KA,s,r)}});const Z$=oD({denseBincount_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=!1){const s=sD(t,"x","denseBincount"),r=sD(e,"weights","denseBincount");_O("int32"===s.dtype,(()=>`Error in denseBincount: input dtype must be int32, but got ${s.dtype}`)),_O(s.rank<=2,(()=>`Error in denseBincount: input must be at most rank 2, but got rank ${s.rank}.`)),_O(n>=0,(()=>`size must be non-negative, but got ${n}.`)),_O(r.size===s.size||0===r.size,(()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${s.shape}, weights shape: ${r.shape}.`));const a={x:s,weights:r},o={size:n,binaryOutput:i};return jk.runKernel(JA,a,o)}});const tB=oD({depthToSpace_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n="NHWC"){const i=sD(t,"x","depthToSpace","float32"),s="NHWC"===n?i.shape[1]:i.shape[2],r="NHWC"===n?i.shape[2]:i.shape[3],a="NHWC"===n?i.shape[3]:i.shape[1];_O(e>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${e}`)),_O(s*e>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${s} and ${e} for depthToSpace with input shape\n ${i.shape}`)),_O(r*e>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${r} and ${e} for depthToSpace with input shape\n ${i.shape}`)),_O(a%(e*e)==0,(()=>`Dimension size must be evenly divisible by ${e*e} but is ${a} for depthToSpace with input shape ${i.shape}`));const o={x:i},l={blockSize:e,dataFormat:n};return jk.runKernel(ZA,o,l)}});const eB=oD({depthwiseConv2d_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s="NHWC",r=[1,1],a){const o=sD(t,"x","depthwiseConv2d","float32"),l=sD(e,"filter","depthwiseConv2d","float32");let u=o,h=!1;3===o.rank&&(h=!0,u=y$(o,[1,o.shape[0],o.shape[1],o.shape[2]])),_O(4===u.rank,(()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${u.rank}.`)),_O(4===l.rank,(()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${l.rank}.`));const p="NHWC"===s?u.shape[3]:u.shape[1];_O(p===l.shape[2],(()=>`Error in depthwiseConv2d: number of input channels (${p}) must match the inChannels dimension in filter ${l.shape[2]}.`)),T$("depthwiseConv2d",i,a);const c={x:u,filter:l},d={strides:n,pad:i,dataFormat:s,dilations:r,dimRoundingMode:a},f=jk.runKernel(tM,c,d);return h?y$(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});const nB=oD({diag_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","diag")};return jk.runKernel(iM,e)}});const iB=oD({dilation2d_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s=[1,1],r="NHWC"){const a=sD(t,"x","dilation2d"),o=sD(e,"filter","dilation2d");_O(3===a.rank||4===a.rank,(()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${a.rank}.`)),_O(3===o.rank,(()=>`Error in dilation2d: filter must be rank 3, but got rank ${o.rank}.`)),_O("NHWC"===r,(()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${r}`));let l=a,u=!1;3===a.rank&&(l=y$(a,[1,a.shape[0],a.shape[1],a.shape[2]]),u=!0),_O(l.shape[3]===o.shape[2],(()=>`Error in dilation2d: input and filter must have the same depth: ${l.shape[3]} vs ${o.shape[2]}`));const h={x:l,filter:o},p={strides:n,pad:i,dilations:s},c=jk.runKernel(sM,h,p);return u?y$(c,[c.shape[1],c.shape[2],c.shape[3]]):c}});const sB=oD({equal_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","equal","string_or_numeric"),i=sD(e,"b","equal","string_or_numeric");[n,i]=Bk(n,i),_F(n.shape,i.shape);const s={a:n,b:i};return jk.runKernel(dM,s)}});const rB=oD({where_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(e,"a","where"),s=sD(n,"b","where"),r=sD(t,"condition","where","bool"),a=_F(_F(r.shape,i.shape),s.shape),o={condition:L$(r,a),t:L$(i,a),e:L$(s,a)};return jk.runKernel(VC,o)}});const aB=oD({divNoNan_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","div"),i=sD(e,"b","div");[n,i]=Bk(n,i);const s=YL(n,i),r=zL(s),a=sB(i,r);return rB(a,r,s)}});const oB=oD({dot_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"t1","dot"),i=sD(e,"t2","dot");_O(!(1!==n.rank&&2!==n.rank||1!==i.rank&&2!==i.rank),(()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${i.rank}.`));const s=1===n.rank?n.size:n.shape[1],r=1===i.rank?i.size:i.shape[0];if(_O(s===r,(()=>`Error in dot: inner dimensions of inputs must match, but got ${s} and ${r}.`)),1===n.rank&&1===i.rank){const t=y$(n,[1,-1]),e=y$(i,[-1,1]),s=HF(t,e);return y$(s,[])}if(1===n.rank&&2===i.rank){const t=y$(n,[1,-1]),e=y$(i,[i.shape[0],i.shape[1]]),s=HF(t,e);return y$(s,[s.size])}if(2===n.rank&&1===i.rank){const t=y$(i,[-1,1]),e=HF(n,t);return y$(e,[e.size])}{const t=y$(i,[i.shape[0],i.shape[1]]);return HF(n,t)}}});const lB=oD({einsum_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,...e){const n=e.map(((t,e)=>sD(t,`tensors${e}`,"einsum"))),i={equation:t};return jk.runKernel(uM,n,i)}});const uB=oD({elu_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","elu","float32")};return jk.runKernel(hM,e)}});const hB=oD({ensureShape_:
/**
* @license
* Copyright 2023 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"x","ensureShape","string_or_numeric");if(!bO(n.shape,e))throw new Error(`EnsureShape: Shape of tensor ${n.shape} is not compatible with expected shape ${e}`);return t}});const pB=oD({erf_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){let e=sD(t,"x","erf");_O("int32"===e.dtype||"float32"===e.dtype,(()=>"Input dtype must be `int32` or `float32`.")),"int32"===e.dtype&&(e=PL(e,"float32"));const n={x:e};return jk.runKernel(cM,n)}});
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function cB(t,e){for(let n=0;n<t.length;++n)if(t[t.length-n-1]!==e-1-n)return!1;return!0}function dB(t,e,n){const i=t.length+e.length,s=[];let r=0,a=0;for(let o=0;o<i;o++)-1===n.indexOf(o)?s.push(t[r++]):s.push(e[a++]);return s}function fB(t,e){const n=[],i=t.length;for(let s=0;s<i;s++)-1===e.indexOf(s)&&n.push(t[s]);return[n,e.map((e=>t[e]))]}function mB(t,e){return dB(t,e.map((t=>1)),e)}function gB(t,e,n){_O(cB(e,n),(()=>`${t} supports only inner-most axes for now. Got axes ${e} and rank-${n} input.`))}function _B(t,e){if(cB(t,e))return null;const n=[];for(let i=0;i<e;++i)-1===t.indexOf(i)&&n.push(i);return t.forEach((t=>n.push(t))),n}function TB(t){return t.map(((t,e)=>[e,t])).sort(((t,e)=>t[1]-e[1])).map((t=>t[0]))}function yB(t,e){const n=[];for(let i=e-t;i<e;++i)n.push(i);return n}const IB=oD({max_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=null,n=!1){const i={x:sD(t,"x","max")},s={reductionIndices:e,keepDims:n};return jk.runKernel(jM,i,s)}});const EB=oD({min_:
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=null,n=!1){const i={x:sD(t,"x","min")},s={axis:e,keepDims:n};return jk.runKernel(nC,i,s)}});const bB=oD({sum_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=null,n=!1){let i=sD(t,"x","sum");"bool"===i.dtype&&(i=PL(i,"int32"));const s={x:i},r={axis:e,keepDims:n};return jk.runKernel(qC,s,r)}});function vB(t,e,n=null){if(0===t.rank)return fF(t);if(1!==t.rank&&null===n)return vB(y$(t,[-1]),e,n);if(1===t.rank||"number"==typeof n||Array.isArray(n)&&1===n.length){if(1===e)return bB(fF(t),n);if(e===1/0)return IB(fF(t),n);if(e===-1/0)return EB(fF(t),n);if("euclidean"===e||2===e)return HL(bB(pF(fF(t),tF(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${e}`)}if(Array.isArray(n)&&2===n.length){if(1===e)return IB(bB(fF(t),n[0]),n[1]-1);if(e===1/0)return IB(bB(fF(t),n[1]),n[0]);if(e===-1/0)return EB(bB(fF(t),n[1]),n[0]);if("fro"===e||"euclidean"===e)return HL(bB(WL(t),n));throw new Error(`Error in norm: invalid ord value: ${e}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}const wB=oD({norm_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e="euclidean",n=null,i=!1){const s=vB(t=sD(t,"x","norm"),e,n);let r=s.shape;if(i){const e=CO(n,t.shape);r=mB(s.shape,e)}return y$(s,r)}});const SB=oD({euclideanNorm_:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=null,n=!1){return wB(t,"euclidean",e,n)}});const xB=oD({exp_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","exp")};return jk.runKernel(fM,e)}});const RB=oD({expandDims_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0){const n=sD(t,"x","expandDims","string_or_numeric");_O(e<=n.rank,(()=>"Axis must be <= rank of the tensor"));const i={input:n},s={dim:e};return jk.runKernel(mM,i,s)}});const OB=oD({expm1_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","expm1")};return jk.runKernel(gM,e)}});const AB=oD({tile_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"x","tile","string_or_numeric");_O(n.rank===e.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${e}.`));const i={x:n},s={reps:e};return jk.runKernel(fN,i,s)}});const MB=oD({eye_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i="float32"){null==e&&(e=t);const s=FL([t,e],i),r=t<=e?t:e;for(let t=0;t<r;++t)s.set(1,t,t);const a=y$(s.toTensor(),[t,e]);if(null==n)return a;if(1===n.length)return AB(RB(a,0),[n[0],1,1]);if(2===n.length)return AB(RB(RB(a,0),0),[n[0],n[1],1,1]);if(3===n.length)return AB(RB(RB(RB(a,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`)}});const CB=oD({floor_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","floor","float32")};return jk.runKernel(IM,e)}});const NB=oD({gather_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n=0,i=0){const s={x:sD(t,"x","gather"),indices:sD(e,"indices","gather","int32")},r={axis:n,batchDims:i};return jk.runKernel(vM,s,r)}});const kB=oD({greater_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","greater","string_or_numeric"),i=sD(e,"b","greater","string_or_numeric");[n,i]=Bk(n,i),_F(n.shape,i.shape);const s={a:n,b:i};return jk.runKernel(SM,s)}});const DB=oD({greaterEqual_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","greaterEqual","string_or_numeric"),i=sD(e,"b","greaterEqual","string_or_numeric");[n,i]=Bk(n,i),_F(n.shape,i.shape);const s={a:n,b:i};return jk.runKernel(xM,s)}});const LB=oD({isFinite_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","isFinite")};return jk.runKernel(MM,e)}});const FB=oD({isInf_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","isInf")};return jk.runKernel(CM,e)}});const PB=oD({isNaN_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","isNaN")};return jk.runKernel(NM,e)}});const $B=oD({leakyRelu_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=.2){const n={x:sD(t,"x","leakyRelu")},i={alpha:e};return jk.runKernel(kM,n,i)}});const BB=oD({less_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","less","string_or_numeric"),i=sD(e,"b","less","string_or_numeric");[n,i]=Bk(n,i),_F(n.shape,i.shape);const s={a:n,b:i};return jk.runKernel(DM,s)}});const VB=oD({lessEqual_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","lessEqual","string_or_numeric"),i=sD(e,"b","lessEqual","string_or_numeric");[n,i]=Bk(n,i),_F(n.shape,i.shape);const s={a:n,b:i};return jk.runKernel(LM,s)}});
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function UB(t,e,n){if(n<=0)throw new Error("The number of values should be positive.");const i={start:t,stop:e,num:n};return jk.runKernel(FM,{},i)}const YB=oD({localResponseNormalization_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=5,n=1,i=1,s=.5){const r=sD(t,"x","localResponseNormalization");_O(4===r.rank||3===r.rank,(()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${r.rank}.`)),_O(wO(e),(()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${e}.`));let a=r,o=!1;3===r.rank&&(o=!0,a=y$(r,[1,r.shape[0],r.shape[1],r.shape[2]]));const l={x:a},u={depthRadius:e,bias:n,alpha:i,beta:s},h=jk.runKernel(WM,l,u);return o?y$(h,[h.shape[1],h.shape[2],h.shape[3]]):h}});const GB=oD({log_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","log","float32")};return jk.runKernel(PM,e)}});const HB=oD({log1p_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","log1p")};return jk.runKernel($M,e)}});const WB=oD({softplus_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","softplus")};return jk.runKernel(XC,e)}});const zB=oD({logSigmoid_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e=sD(t,"x","logSigmoid");return JL((t=>({value:XF(WB(XF(t))),gradFunc:e=>GL(e,v$(XF(t)))})))(e)}});const XB=oD({logSoftmax_:
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=-1){const n=sD(t,"logits","logSoftmax");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${e}`);const i=JL(((t,n)=>{const i=IB(t,e,!0),s=cF(t,i),r=cF(PL(s,"float32"),GB(bB(xB(s),e,!0)));n([r]);return{value:r,gradFunc:(t,n)=>{const[i]=n,s=xB(i);return cF(t,GL(bB(t,e,!0),s))}}}));return i(n)}});const jB=oD({logSumExp_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=null,n=!1){const i=sD(t,"x","logSumExp"),s=CO(e,i.shape),r=IB(i,s,!0),a=cF(i,r),o=xB(a),l=bB(o,s),u=GB(l),h=VL(y$(r,u.shape),u);if(n){const t=mB(h.shape,s);return y$(h,t)}return h}});const qB=oD({logicalAnd_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"a","logicalAnd","bool"),i=sD(e,"b","logicalAnd","bool");_F(n.shape,i.shape);const s={a:n,b:i};return jk.runKernel(BM,s)}});const KB=oD({logicalNot_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","logicalNot","bool")};return jk.runKernel(VM,e)}});const QB=oD({logicalOr_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"a","logicalOr","bool"),i=sD(e,"b","logicalOr","bool");_F(n.shape,i.shape);const s={a:n,b:i};return jk.runKernel(UM,s)}});const JB=oD({logicalXor_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"a","logicalXor","bool"),i=sD(e,"b","logicalXor","bool");return _F(n.shape,i.shape),qB(QB(t,e),KB(qB(t,e)))}}),ZB=2147483648;const tV=oD({searchSorted_:function(t,e,n="left"){const i=sD(t,"sortedSequence","searchSorted"),s=sD(e,"values","searchSorted"),r=i.shape[i.shape.length-1],a=s.shape[s.shape.length-1],o=y$(i,[-1,r]),l=y$(s,[-1,a]);if(o.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(o.shape[0]!==l.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(IO(l.shape)>=ZB)throw new Error("values tensor size must less than 2147483648");if(o.shape[1]>=ZB)throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${o.shape[1]}`);const u={sortedSequence:o,values:l},h={side:n};return jk.runKernel(BC,u,h)}});
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function eV(t,e){return tV(t,e,"left")}const nV=oD({maxPool_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s){const r=sD(t,"x","maxPool");let a=r,o=!1;3===r.rank&&(o=!0,a=y$(r,[1,r.shape[0],r.shape[1],r.shape[2]])),_O(4===a.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${a.rank}.`)),_O(m$(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),T$("maxPool",i,s);const l={x:a},u={filterSize:e,strides:n,pad:i,dimRoundingMode:s},h=jk.runKernel(KM,l,u);return o?y$(h,[h.shape[1],h.shape[2],h.shape[3]]):h}});const iV=oD({maxPool3d_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=[1,1,1],n,i,s,r="NDHWC"){const a=sD(t,"x","maxPool3d");let o=a,l=!1;4===a.rank&&(l=!0,o=y$(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]])),_O(5===o.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`)),_O("NDHWC"===r,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${r}`)),T$("maxPool3d",i,s);const u={x:o},h={filterSize:e,strides:n,pad:i,dimRoundingMode:s,dataFormat:r},p=jk.runKernel(JM,u,h);return l?y$(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}});const sV=oD({maxPoolWithArgmax_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s=!1){const r={x:sD(t,"x","maxPoolWithArgmax")},a={filterSize:e,strides:n,pad:i,includeBatchInIndex:s},o=jk.runKernel(tC,r,a);return{result:o[0],indexes:o[1]}}});const rV=oD({mean_:
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=null,n=!1){const i={x:sD(t,"x","mean")},s={axis:e,keepDims:n};return jk.runKernel(eC,i,s)}});
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function aV(t,e="float32"){if(ZO(t),"complex64"===e){const e=aV(t,"float32"),n=aV(t,"float32");return lD(e,n)}const n=QO(IO(t),e);return jk.makeTensor(n,t,e)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function oV(t,e="float32"){if(ZO(t),"complex64"===e){const e=oV(t,"float32"),n=aV(t,"float32");return lD(e,n)}const n=KO(IO(t),e);return jk.makeTensor(n,t,e)}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function lV(t,e,{indexing:n="xy"}={}){if("xy"!==n&&"ij"!==n)throw new TypeError(`${n} is not a valid third argument to meshgrid`);if(void 0===t)return[];let i=sD(t,"x","meshgrid",t instanceof xk?t.dtype:"float32");if(void 0===e)return[i];let s=sD(e,"y","meshgrid",e instanceof xk?e.dtype:"float32");const r=IO(i.shape),a=IO(s.shape);return"xy"===n?(i=y$(i,[1,-1]),s=y$(s,[-1,1]),[HF(oV([a,1],i.dtype),i),HF(s,oV([1,r],s.dtype))]):(i=y$(i,[-1,1]),s=y$(s,[1,-1]),[HF(i,oV([1,a],i.dtype)),HF(oV([r,1],s.dtype),s)])}const uV=oD({minimum_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","minimum"),i=sD(e,"b","minimum");[n,i]=Bk(n,i),"bool"===n.dtype&&(n=PL(n,"int32"),i=PL(i,"int32")),_F(n.shape,i.shape);const s={a:n,b:i};return jk.runKernel(iC,s)}});const hV=oD({mirrorPad_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){_O("reflect"===n||"symmetric"===n,(()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`));const i=sD(t,"x","mirrorPad");if(0===i.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");_O(e.length===i.rank,(()=>`Padding doesn't match input. Must be ${i.rank}. Got ${e.length}.`));const s="reflect"===n?1:0;for(let t=0;t<i.rank;t++)_O(2===e[t].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),_O(e[t][0]>=0&&e[t][0]<=i.shape[t]-s&&e[t][1]>=0&&e[t][1]<=i.shape[t]-s,(()=>`Padding in dimension ${t} cannot be greater than or equal to ${i.shape[t]-s} or less than 0 for input of shape ${i.shape}`));const r={paddings:e,mode:n},a={x:i};return jk.runKernel(sC,a,r)}});const pV=oD({mod_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","mod"),i=sD(e,"b","mod");[n,i]=Bk(n,i);const s={a:n,b:i};return jk.runKernel(rC,s)}});const cV=oD({moments_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=null,n=!1){const i=CO(e,(t=sD(t,"x","moments")).shape),s=rV(t,i,n);let r=s.shape;n||(r=mB(s.shape,i));const a=WL(cF(PL(t,"float32"),y$(s,r)));return{mean:s,variance:rV(a,i,n)}}});const dV=oD({multiRNNCell_:function(t,e,n,i){const s=sD(e,"data","multiRNNCell"),r=rD(n,"c","multiRNNCell"),a=rD(i,"h","multiRNNCell");let o=s;const l=[];for(let e=0;e<t.length;e++){const n=t[e](o,r[e],a[e]);l.push(n[0]),l.push(n[1]),o=n[1]}const u=[],h=[];for(let t=0;t<l.length;t+=2)u.push(l[t]),h.push(l[t+1]);return[u,h]}});const fV=oD({multinomial_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=!1){const s=sD(t,"logits","multinomial"),r=s.size,a=s.rank;if(r<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${r}.`);if(a>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${a}`);n=n||Math.random();const o={logits:1===a?y$(s,[1,-1]):s},l={numSamples:e,seed:n,normalized:i},u=jk.runKernel(aC,o,l);return 1===a?y$(u,[u.size]):u}});const mV=oD({notEqual_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","notEqual","string_or_numeric"),i=sD(e,"b","notEqual","string_or_numeric");[n,i]=Bk(n,i),_F(n.shape,i.shape);const s={a:n,b:i};return jk.runKernel(uC,s)}});const gV=oD({onesLike_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","onesLike")};return jk.runKernel(dC,e)}});const _V=oD({outerProduct_:function(t,e){const n=sD(t,"v1","outerProduct"),i=sD(e,"v2","outerProduct");_O(1===n.rank&&1===i.rank,(()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${i.rank}.`));const s=y$(n,[-1,1]),r=y$(i,[1,-1]);return HF(s,r)}});const TV=oD({pad_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n=0){const i=sD(t,"x","pad");if(0===i.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const s={paddings:e,constantValue:n},r={x:i};return jk.runKernel(gC,r,s)}});const yV=oD({pad1d_:function(t,e,n=0){return _O(2===e.length,(()=>"Invalid number of paddings. Must be length of 2.")),TV(t,[e],n)}});const IV=oD({pad2d_:function(t,e,n=0){return _O(2===e.length&&2===e[0].length&&2===e[1].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),TV(t,e,n)}});const EV=oD({pad3d_:function(t,e,n=0){return _O(3===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),TV(t,e,n)}});const bV=oD({pad4d_:function(t,e,n=0){return _O(4===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length&&2===e[3].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),TV(t,e,n)}});const vV=oD({spaceToBatchND_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"x","spaceToBatchND");_O(i.rank>=1+e.length,(()=>`input rank ${i.rank} should be > than [blockShape] ${e.length}`)),_O(n.length===e.length,(()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${e.length}`)),_O(i.shape.reduce(((t,i,s)=>s>0&&s<=e.length?t&&(i+n[s-1][0]+n[s-1][1])%e[s-1]==0:t),!0),(()=>`input spatial dimensions ${i.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${e.toString()}`));const s={x:i},r={blockShape:e,paddings:n};return jk.runKernel(KC,s,r)}});const wV=oD({pool_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r,a){null==s&&(s=[1,1]),null==r&&(r=1),0===i&&(i="valid");const o=sD(t,"x","maxPool");let l=o,u=!1;3===o.rank&&(u=!0,l=y$(o,[1,o.shape[0],o.shape[1],o.shape[2]])),_O(m$(r,s),(()=>`Error in pool: Either strides or dilations must be 1. Got strides ${r} and dilations '${s}'`));const h=r$(l.shape,e,r,s,i),p=[h.dilationHeight,h.dilationWidth];let c;c="same"===i?function(t,e){const n=t.map(((t,n)=>t+(t-1)*(e[n]-1))),i=n.map((t=>t-1)),s=i.map((t=>Math.floor(t/2))),r=i.map(((t,e)=>t-s[e]));return i.map(((t,e)=>[s[e],r[e]]))}([h.filterHeight,h.filterWidth],p):[[0,0],[0,0]];const d=1===p[0]&&1===p[1],[f,m]=function(t,e,n){const i=n.map((t=>t[0])),s=n.map((t=>t[1])),r=t.concat(i,s),a=e.map(((t,e)=>(t-r[e]%t)%t)),o=s.map(((t,e)=>t+a[e])),l=e.map(((t,e)=>[i[e],o[e]])),u=e.map(((t,e)=>[0,a[e]]));return[l,u]}([h.inHeight,h.inWidth],p,c),g=d?i:"valid",_=d?l:vV(l,p,f),T=("avg"===n?()=>I$(_,e,r,g,a):()=>nV(_,e,r,g,a))(),y=d?T:R$(T,p,m);return u?y$(y,[y.shape[1],y.shape[2],y.shape[3]]):y}});const SV=oD({prelu_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n={x:sD(t,"x","prelu"),alpha:sD(e,"alpha","prelu")};return jk.runKernel(yC,n)}});const xV=oD({prod_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=null,n=!1){let i=sD(t,"x","prod");"bool"===i.dtype&&(i=PL(i,"int32"));const s={x:i},r={axis:e,keepDims:n};return jk.runKernel(IC,s,r)}});const RV=oD({raggedGather_:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i){const s={paramsNestedSplits:t.map(((t,e)=>sD(t,`tensors${e}`,"raggedGather","int32"))),paramsDenseValues:sD(e,"paramsDenseValues","raggedGather"),indices:sD(n,"indices","raggedGather","int32")},r={outputRaggedRank:i},a=jk.runKernel(EC,s,r);return{outputNestedSplits:a.slice(0,a.length-1),outputDenseValues:a[a.length-1]}}});const OV=oD({raggedRange_:
/**
* @license
* Copyright 2022 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"starts","raggedRange"),s={starts:i,limits:sD(e,"limits","raggedRange",i.dtype),deltas:sD(n,"deltas","raggedRange",i.dtype)},r=jk.runKernel(bC,s);return{rtNestedSplits:r[0],rtDenseValues:r[1]}}});const AV=oD({raggedTensorToTensor_:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s){const r=sD(t,"shape","raggedTensorToTensor","int32"),a=sD(e,"values","raggedTensorToTensor"),o={shape:r,values:a,defaultValue:sD(n,"defaultValue","raggedTensorToTensor",a.dtype),rowPartitionTensors:i.map(((t,e)=>sD(t,`tensors${e}`,"raggedTensorToTensor","int32")))},l={rowPartitionTypes:s};return jk.runKernel(vC,o,l)}});const MV=oD({rand_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){ZO(t);const i=IO(t);let s=null;if(null==n||"float32"===n)s=new Float32Array(i);else if("int32"===n)s=new Int32Array(i);else{if("bool"!==n)throw new Error(`Unknown data type ${n}`);s=new Uint8Array(i)}for(let t=0;t<i;t++)s[t]=e();return jk.makeTensor(s,t,n)}});var CV=__webpack_require__(7391);
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class NV{constructor(t,e,n,i,s){this.mean=t,this.stdDev=e,this.dtype=n,this.nextVal=NaN,this.truncated=i,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);const r=s||Math.random();this.random=CV.alea(r.toString())}nextValue(){if(!isNaN(this.nextVal)){const t=this.nextVal;return this.nextVal=NaN,t}let t,e,n=!1;for(;!n;){let i,s,r;do{i=2*this.random()-1,s=2*this.random()-1,r=i*i+s*s}while(r>=1||0===r);const a=Math.sqrt(-2*Math.log(r)/r);t=this.mean+this.stdDev*i*a,e=this.mean+this.stdDev*s*a,this.truncated&&!this.isValidTruncated(t)||(n=!0)}return this.truncated&&!this.isValidTruncated(e)||(this.nextVal=this.convertValue(e)),this.convertValue(t)}convertValue(t){return null==this.dtype||"float32"===this.dtype?t:Math.round(t)}isValidTruncated(t){return t<=this.upper&&t>=this.lower}}class kV{constructor(t,e,n,i){this.alpha=t,this.beta=1/e,this.dtype=n;const s=i||Math.random();this.randu=CV.alea(s.toString()),this.randn=new NV(0,1,n,!1,this.randu()),this.d=t<1?t+2/3:t-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let t,e,n,i,s,r;for(;;){do{i=this.randn.nextValue(),r=1+this.c*i}while(r<=0);if(r*=r*r,t=i*i,e=1-.331*t*t,n=.5*t+this.d*(1-r+Math.log(r)),s=this.randu(),s<e||Math.log(s)<n)break}return r=1/this.beta*this.d*r,this.alpha<1&&(r*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(r)}convertValue(t){return"float32"===this.dtype?t:Math.round(t)}}class DV{constructor(t=0,e=1,n,i){if(this.canReturnFloat=()=>null==this.dtype||"float32"===this.dtype,this.min=t,this.range=e-t,this.dtype=n,null==i&&(i=Math.random()),"number"==typeof i&&(i=i.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${t} - ${e} <= 1 and dtype is not float`);this.random=CV.alea(i)}convertValue(t){return this.canReturnFloat()?t:Math.round(t)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}const LV=oD({randomGamma_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n=1,i="float32",s){if(ZO(t),null==n&&(n=1),null==i&&(i="float32"),"float32"!==i&&"int32"!==i)throw new Error(`Unsupported data type ${i}`);const r=new kV(e,n,i,s),a=FL(t,i);for(let t=0;t<a.values.length;t++)a.values[t]=r.nextValue();return a.toTensor()}});const FV=oD({randomNormal_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0,n=1,i,s){if(ZO(t),null!=i&&"bool"===i)throw new Error(`Unsupported data type ${i}`);const r=new NV(e,n,i,!1,s),a=FL(t,i);for(let t=0;t<a.values.length;t++)a.values[t]=r.nextValue();return a.toTensor()}});const PV=oD({randomStandardNormal_:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){if(null!=e&&"bool"===e)throw new Error(`Unsupported data type ${e}`);return FV(t,0,1,e,n)}});const $V=oD({randomUniform_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0,n=1,i="float32",s){ZO(t);const r=FL(t,i),a=new DV(e,n,null,s);for(let t=0;t<r.values.length;t++)r.values[t]=a.nextValue();return r.toTensor()}});const BV=oD({randomUniformInt_:
/**
* @license
* Copyright 2023 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i){return $V(t,e,n,"int32",i)}});
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function VV(t,e,n=1,i="float32"){if(0===n)throw new Error("Cannot have a step of zero");const s={start:t,stop:e,step:n,dtype:i};return jk.runKernel(wC,{},s)}const UV=oD({reciprocal_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","reciprocal")};return jk.runKernel(xC,e)}});const YV=oD({relu_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","relu")};return jk.runKernel(RC,e)}});const GV=oD({relu6_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","relu6")};return jk.runKernel(kC,e)}});const HV=oD({reverse_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n={x:sD(t,"x","reverse")},i={dims:e};return jk.runKernel(DC,n,i)}});const WV=oD({reverse1d_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e=sD(t,"x","reverse");return _O(1===e.rank,(()=>`Error in reverse1D: x must be rank 1 but got rank ${e.rank}.`)),HV(e,0)}});const zV=oD({reverse2d_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"x","reverse");return _O(2===n.rank,(()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)),HV(n,e)}});const XV=oD({reverse3d_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"x","reverse");return _O(3===n.rank,(()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)),HV(n,e)}});const jV=oD({reverse4d_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"x","reverse");return _O(4===n.rank,(()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)),HV(n,e)}});const qV=oD({round_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","round")};return jk.runKernel(LC,e)}});const KV=oD({rsqrt_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","rsqrt","float32")};return jk.runKernel(FC,e)}});const QV=oD({selu_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","selu")};return jk.runKernel(UC,e)}});const JV=oD({separableConv2d_:function(t,e,n,i,s,r=[1,1],a="NHWC"){const o=sD(t,"x","separableConv2d"),l=sD(e,"depthwiseFilter","separableConv2d"),u=sD(n,"pointwiseFilter","separableConv2d");let h=o,p=!1;if(3===o.rank&&(p=!0,h=y$(o,[1,o.shape[0],o.shape[1],o.shape[2]])),"NCHW"===a)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");_O(4===h.rank,(()=>`Error in separableConv2d: input must be rank 4, but got rank ${h.rank}.`)),_O(4===l.rank,(()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${l.rank}.`)),_O(4===u.rank,(()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${l.rank}.`)),_O(1===u.shape[0],(()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${u.shape[0]}.`)),_O(1===u.shape[1],(()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${u.shape[1]}.`));const c=l.shape[2],d=l.shape[3];_O(u.shape[2]===c*d,(()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${c*d}, but got ${u.shape[2]}.`));const f=eB(h,l,i,s,a,r),m=Y$(f,u,1,"valid",a);return p?y$(m,[m.shape[1],m.shape[2],m.shape[3]]):m}});const ZV=
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
async function(t,e){const n=sD(t,"x","setdiff1d"),i=sD(e,"y","setdiff1d");_O(n.dtype===i.dtype,(()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${i.dtype}).`)),_O(1===n.rank,(()=>`x should be 1D tensor, but got x (${n.shape}).`)),_O(1===i.rank,(()=>`y should be 1D tensor, but got y (${i.shape}).`));const s=await n.data(),r=await i.data(),a=new Set(r);let o=0;for(let t=0;t<s.length;t++)a.has(s[t])||o++;const l=new bk([o],n.dtype),u=new bk([o],"int32");for(let t=0,e=0;t<s.length;t++)a.has(s[t])||(l.values[e]=s[t],u.values[e]=t,e++);return[l.toTensor(),u.toTensor()]};const tU=oD({sign_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","sign")};return jk.runKernel(WC,e)}});const eU=oD({sin_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","sin","float32")};return jk.runKernel(GC,e)}});const nU=oD({sinh_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","sinh")};return jk.runKernel(HC,e)}});const iU=oD({slice1d_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"x","slice1d");return _O(1===i.rank,(()=>`slice1d expects a rank-1 tensor, but got a rank-${i.rank} tensor`)),w$(i,[e],[n])}});const sU=oD({slice2d_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"x","slice2d");return _O(2===i.rank,(()=>`slice2d expects a rank-2 tensor, but got a rank-${i.rank} tensor`)),w$(i,e,n)}});const rU=oD({slice3d_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"x","slice3d");return _O(3===i.rank,(()=>`slice3d expects a rank-3 tensor, but got a rank-${i.rank} tensor`)),w$(i,e,n)}});const aU=oD({slice4d_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"x","slice4d");return _O(4===i.rank,(()=>`slice4d expects a rank-4 tensor, but got a rank-${i.rank} tensor`)),w$(i,e,n)}});const oU=oD({softmax_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=-1){const n=sD(t,"logits","softmax","float32");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${e}`);const i={logits:n},s={dim:e};return jk.runKernel(JC,i,s)}});const lU=oD({fft_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){_O("complex64"===t.dtype,(()=>`The dtype for tf.spectral.fft() must be complex64 but got ${t.dtype}.`));const e={input:t};return jk.runKernel(_M,e)}});const uU=oD({ifft_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){_O("complex64"===t.dtype,(()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${t.dtype}.`));const e={input:t};return jk.runKernel(OM,e)}});const hU=oD({irfft_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e=t.shape[t.shape.length-1],n=t.size/e;let i;if(e<=2){const s=y$(t,[n,e]);i=uU(s)}else{const s=[n,2*(e-1)],r=y$(jF(t),[n,e]),a=y$(zF(t),[n,e]),o=HV(w$(r,[0,1],[n,e-2]),1),l=GL(HV(w$(a,[0,1],[n,e-2]),1),tF(-1)),u=b$([r,o],1),h=b$([a,l],1),p=y$(lD(u,h),[s[0],s[1]]);i=uU(p)}if(i=jF(i),3===t.rank&&0!==t.shape[0]){const e=i,n=t.shape[0];i=y$(i,[n,i.shape[0]/n,i.shape[1]]),e.dispose()}return i}});const pU=oD({split_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n=0){const i={x:sD(t,"x","split")},s={numOrSizeSplits:e,axis:n};return jk.runKernel(QC,i,s)}});const cU=oD({rfft_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){_O("float32"===t.dtype,(()=>`The dtype for rfft() must be real value but got ${t.dtype}`));let n=t.shape[t.shape.length-1];const i=t.size/n;let s;if(null!=e&&e<n){const i=t.shape.map((t=>0)),r=t.shape.map((t=>t));r[t.shape.length-1]=e,s=w$(t,i,r),n=e}else if(null!=e&&e>n){const i=t.shape.map((t=>t));i[t.shape.length-1]=e-n,s=b$([t,aV(i)],t.shape.length-1),n=e}else s=t;const r=zL(s),a=y$(lD(s,r),[i,n]),o=lU(a),l=Math.floor(n/2)+1,u=jF(o),h=zF(o),p=pU(u,[l,n-l],u.shape.length-1),c=pU(h,[l,n-l],h.shape.length-1),d=s.shape.slice();return d[s.shape.length-1]=l,y$(lD(p[0],c[0]),d)}});const dU=oD({squaredDifference_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){let n=sD(t,"a","squaredDifference"),i=sD(e,"b","squaredDifference");[n,i]=Bk(n,i),_F(n.shape,i.shape);const s={a:n,b:i};return jk.runKernel(sN,s,{})}});const fU=oD({squeeze_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"x","squeeze","string_or_numeric");return y$(n,NO(n.shape,e).newShape)}});const mU=oD({stack_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0){const n=rD(t,"tensors","stack","string_or_numeric");_O(n.length>=1,(()=>"Pass at least one tensor to tf.stack")),n.length>0&&_O(e<=n[0].rank,(()=>"Axis must be <= rank of the tensor"));const i=n,s={axis:e};return jk.runKernel(mC,i,s)}});const gU=oD({step_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0){const n={x:sD(t,"x","step")},i={alpha:e};return jk.runKernel(vN,n,i)}});const _U=oD({stridedSlice_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s=0,r=0,a=0,o=0,l=0){const u={x:sD(t,"x","stridedSlice","string_or_numeric")},h={begin:e,end:n,strides:i,beginMask:s,endMask:r,ellipsisMask:a,newAxisMask:o,shrinkAxisMask:l};return jk.runKernel(oN,u,h)}});const TU=oD({tan_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e={x:sD(t,"x","tan","float32")};return jk.runKernel(cN,e)}});
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function yU(t,e){yO(t);const n=eD(t,e);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return uD(t,null,n,e)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function IU(t,e,n){if(yO(t),null!=e&&2!==e.length)throw new Error("tensor2d() requires shape to have two numbers");const i=eD(t,n);if(2!==i.length&&1!==i.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===i.length&&null==e)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return uD(t,e,i,n)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function EU(t,e,n){if(yO(t),null!=e&&4!==e.length)throw new Error("tensor4d() requires shape to have four numbers");const i=eD(t,n);if(4!==i.length&&1!==i.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===i.length&&null==e)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return uD(t,e,i,n)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function bU(t,e,n){if(yO(t),null!=e&&5!==e.length)throw new Error("tensor5d() requires shape to have five numbers");const i=eD(t,n);if(5!==i.length&&1!==i.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===i.length&&null==e)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return uD(t,e,i,n)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function vU(t,e,n){if(yO(t),null!=e&&6!==e.length)throw new Error("tensor6d() requires shape to have six numbers");const i=eD(t,n);if(6!==i.length&&1!==i.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===i.length&&null==e)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return uD(t,e=e||i,i,n)}const wU=oD({tensorScatterUpdate_:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"tensor","tensorScatterupdate"),s=sD(e,"indices","tensorScatterupdate","int32"),r=sD(n,"updates","tensorScatterupdate");if(uP(r,s,i.shape),i.dtype!==r.dtype)throw new Error(`tensor and updates must have the same dtype, instead they are ${i.dtype} and ${r.dtype}.`);const a={tensor:i,indices:s,updates:r};return jk.runKernel($C,a,{})}});const SU=oD({topk_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=1,n=!0){const i=sD(t,"x","topk");if(0===i.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const s=i.shape[i.shape.length-1];if(e<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${e}`);if(e>s)throw new Error(`'k' passed to topk() must be <= the last dimension (${s}) but got ${e}`);const r={x:i},a={k:e,sorted:n},[o,l]=jk.runKernel(mN,r,a);return{values:o,indices:l}}});const xU=oD({truncatedNormal_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0,n=1,i,s){if(ZO(t),null!=i&&"bool"===i)throw new Error("Unsupported data type $ { dtype }");const r=new NV(e,n,i,!0,s),a=FL(t,i);for(let t=0;t<a.values.length;t++)a.values[t]=r.nextValue();return a.toTensor()}});const RU=oD({unique_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0){const n=sD(t,"x","unique","string_or_numeric");_O(n.rank>0,(()=>"The input tensor must be at least 1D"));const i={x:n},s={axis:e},[r,a]=jk.runKernel(TN,i,s);return{values:r,indices:a}}});const OU=oD({unsortedSegmentSum_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"x","unsortedSegmentSum"),s=sD(e,"segmentIds","unsortedSegmentSum","int32");_O(wO(n),(()=>"numSegments must be of dtype int"));const r={x:i,segmentIds:s},a={numSegments:n};return jk.runKernel(IN,r,a)}});const AU=oD({unstack_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=0){const n=sD(t,"x","unstack","string_or_numeric");_O(e>=-n.shape.length&&e<n.shape.length,(()=>`Axis = ${e} is not in [-${n.shape.length}, ${n.shape.length})`));const i={value:n},s={axis:e};return jk.runKernel(yN,i,s)}});
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function MU(t,e){return tV(t,e,"right")}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function CU(t,e=!0,n,i){return jk.makeVariable(t,e,n,i)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function NU(t,e){const n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(t);const i=FL(t,"int32"),s=FL([n.length,t.length],"int32");for(let e=0;e<n.length;e++){const r=i.indexToLoc(n[e]),a=e*t.length;s.values.set(r,a)}return s.toTensor()}const kU=
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
async function(t){const e=sD(t,"condition","whereAsync","bool"),n=await e.data(),i=NU(e.shape,n);return t!==e&&e.dispose(),i};const DU=
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
async function(t,e,n){const i=sD(t,"tensor","boolMask"),s=sD(e,"mask","boolMask","bool"),r=null==n?0:n,a=s.rank,o=i.shape;_O(a>0,(()=>"mask cannot be scalar")),TO(o.slice(r,r+a),s.shape,"mask's shape must match the first K dimensions of tensor's shape,");let l=1;for(let t=r;t<r+a;t++)l*=o[t];const u=o.slice(0,r).concat([l],o.slice(r+a)),h=y$(i,u),p=y$(s,[-1]),c=await kU(p),d=fU(c,[1]),f=NB(h,d,r);return t!==i&&i.dispose(),e!==s&&s.dispose(),d.dispose(),h.dispose(),p.dispose(),c.dispose(),f};const LU=oD({movingAverage_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s=!0){const r=sD(t,"v","movingAverage"),a=sD(e,"x","movingAverage"),o=sD(n,"decay","movingAverage");Vk(r,a),_O(vO(r.shape,a.shape),(()=>"Shape mismatch in v and x"));const l=tF(1),u=cF(l,o);let h=GL(cF(a,r),u);if(s){_O(null!=i,(()=>"When using zeroDebias: true, step is required."));const t=sD(i,"step","movingAverage");h=YL(h,cF(l,pF(o,t)))}return VL(r,h)}});const FU=oD({scatterND_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){ZO(n);const i=sD(t,"indices","scatterND","int32"),s=sD(e,"updates","scatterND");uP(s,i,n);const r={indices:i,updates:s},a={shape:n};return jk.runKernel(PC,r,a)}});const PU=oD({sparseToDense_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=0){ZO(n);const s=sD(t,"sparseIndices","sparseToDense","int32"),r=sD(e,"sparseValues","sparseToDense","string_or_numeric"),a=sD(i,"defaultValue","sparseToDense",r.dtype);!function(t,e,n,i){if("int32"!==t.dtype)throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.rank>2)throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${t.shape}.`);const s=t.rank>0?t.shape[0]:1,r=t.rank>1?t.shape[1]:1;if(n.length!==r)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${r}.`);const a=e.size;if(0!==e.rank&&(1!==e.rank||a!==s))throw new Error(`sparseValues has incorrect shape ${e.shape}, should be [] or [${s}]`);if(e.dtype!==i.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(s,r,n,a);const o={sparseIndices:s,sparseValues:r,defaultValue:a},l={outputShape:n};return jk.runKernel(iN,o,l)}});const $U=oD({gatherND_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(e,"indices","gatherND","int32"),i={params:sD(t,"x","gatherND","string_or_numeric"),indices:n};return jk.runKernel(wM,i)}});const BU=oD({dropout_:
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i){const s=sD(t,"x","dropout");if(_O("float32"===s.dtype,(()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${s.dtype} tensor instead.`)),_O(e>=0&&e<1,(()=>`rate must be a float in the range [0, 1), but got ${e}.`)),0===e)return t instanceof xk?s.clone():s;const r=
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){if(null==e)return t.shape.slice();if(vO(t.shape,e))return e;if(t.shape.length===e.length){const n=[];for(let i=0;i<t.shape.length;i++)null==e[i]&&null!=t.shape[i]?n.push(t.shape[i]):n.push(e[i]);return n}return e}(s,n),a=1-e,o=YL(CB(VL($V(r,0,1,"float32",i),a)),a);return GL(s,o)}});
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function VU(t){return Math.floor(Math.pow(2,Math.ceil(Math.log(t)/Math.log(2))))}function UU(t,e,n){const i=1-t%2,s=new Float32Array(t);for(let r=0;r<t;++r){const a=2*Math.PI*r/(t+i-1);s[r]=e-n*Math.cos(a)}return yU(s,"float32")}const YU=
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
async function(t,e,n=1){const i=sD(t,"predictions","inTopK"),s=sD(e,"targets","inTopK");_O(i.rank>1,(()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${i.rank}`)),_O(i.rank-1===s.rank,(()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${i.rank} and targets rank ${s.rank}`)),TO(i.shape.slice(0,i.shape.length-1),s.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const r=i.shape[i.shape.length-1];_O(n>0&&n<=r,(()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${r}), but got ${n}`));const a=await i.data(),o=await s.data(),[l,u]=[a.length/r,r],h=kO("bool",l);for(let t=0;t<l;t++){const e=t*u,i=a.subarray(e,e+u),s=[];for(let t=0;t<i.length;t++)s.push({value:i[t],index:t});s.sort(((t,e)=>e.value-t.value)),h[t]=0;for(let e=0;e<n;e++)if(s[e].index===o[t]){h[t]=1;break}}return t!==i&&i.dispose(),e!==s&&s.dispose(),hD(h,s.shape,"bool")};const GU=oD({conv2DBackpropFilter_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r="NHWC",a){let o=t;3===t.rank&&(o=y$(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let l=e;3===l.rank&&(l=y$(e,[1,e.shape[0],e.shape[1],e.shape[2]])),_O(4===o.rank,(()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${o.shape}.`)),_O(4===l.rank,(()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${l.shape}.`)),_O(4===n.length,(()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`));const u="NHWC"===r?o.shape[3]:o.shape[1],h="NHWC"===r?l.shape[3]:l.shape[1];_O(u===n[2],(()=>`Error in conv2dDerFilter: depth of input ${u}) must match input depth in filter (${n[2]}.`)),_O(h===n[3],(()=>`Error in conv2dDerFilter: depth of dy (${h}) must match output depth for filter (${n[3]}).`)),T$("conv2dDerFilter",s,a);const p={x:o,dy:l},c={strides:i,pad:s,dataFormat:r,dimRoundingMode:a,filterShape:n};return jk.runKernel(YA,p,c)}});
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function HU(t,e,n){if(null==n||"linear"===n)return t;if("relu"===n)return GL(t,gU(e));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function WU(t,e){let n=e;const i=gF(t.shape,e.shape);return i.length>0&&(n=bB(n,i)),y$(n,t.shape)}function zU(t,e,n,i){if("linear"===e)return t;if("relu"===e)return YV(t);if("elu"===e)return uB(t);if("relu6"===e)return GV(t);if("prelu"===e)return SV(t,n);if("leakyrelu"===e)return $B(t,i);if("sigmoid"===e)return v$(t);throw new Error(`Unknown fused activation ${e}.`)}const XU=(t,e)=>!(t>0)||"linear"===e;const jU=oD({fusedConv2d_:
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function({x:t,filter:e,strides:n,pad:i,dataFormat:s="NHWC",dilations:r=[1,1],dimRoundingMode:a,bias:o,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:h}){if(l=l||"linear",!1===XU(jk.state.gradientDepth,l)){_O("NHWC"===s,(()=>`Error in fused conv2d: got dataFormat of ${s} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`));let p=Y$(t,e,n,i,s,r,a);return null!=o&&(p=VL(p,o)),zU(p,l,u,h)}const p=sD(t,"x","conv2d","float32"),c=sD(e,"filter","conv2d","float32");let d=p,f=!1;3===p.rank&&(f=!0,d=y$(p,[1,p.shape[0],p.shape[1],p.shape[2]])),_O(4===d.rank,(()=>`Error in fused conv2d: input must be rank 4, but got rank ${d.rank}.`)),_O(4===c.rank,(()=>`Error in fused conv2d: filter must be rank 4, but got rank ${c.rank}.`)),T$("fused conv2d",i,a);const m="NHWC"===s?d.shape[3]:d.shape[1];_O(c.shape[2]===m,(()=>`Error in conv2d: depth of input (${m}) must match input depth for filter ${c.shape[2]}.`)),_O(m$(n,r),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${r}'`));const g=o$(d.shape,c.shape,n,r,i,a);let _,T;if(null!=o&&(_=sD(o,"bias","fused conv2d"),[_]=Bk(_,p),"NHWC"===s?_F(g.outShape,_.shape):(_O(_.shape.length<=1,(()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${_.shape.length}.`)),_O(0===_.shape.length||_.shape[0]===g.outChannels||1===_.shape[0],(()=>`Error in fused conv2d: bias shape (${_.shape}) is not compatible with the number of output channels (${g.outChannels})`)))),null!=u){const t=u.shape;if(_O(t.length<=1||3===t.length,(()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${t.length}.`)),1===t.length)_O(1===t[0]||t[0]===g.outChannels,(()=>`Error in fused conv2d: PReLU activation weights (${t}) is not compatible with the number of output channels (${g.outChannels}).`));else if(3===t.length)try{_F(t,g.outShape)}catch(e){const n=`Error in fused conv2d: PReLU activation weights (${t}) is not compatible with the output shape of the conv2d (${g.outShape}).`;throw Error(n)}T=sD(u,"prelu weights","fused conv2d")}const y=(t,e)=>{_O("NHWC"===s,(()=>`Error in gradient of fused conv2D: got dataFormat of ${s} but only NHWC is currently supported.`));const[a,o,u,h]=e,p=HU(t,u,l);_O(f$(r),(()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`));const c=[H$(o.shape,p,a,n,i),GU(o,p,a.shape,n,i)];if(null!=h){const t=WU(h,p);c.push(t)}return c},I={x:d,filter:c,bias:_,preluActivationWeights:T},E={strides:n,pad:i,dataFormat:s,dilations:r,dimRoundingMode:a,activation:l,leakyreluAlpha:h};if(null==o){const t=JL(((t,e,n)=>{let i=jk.runKernel(RN,I,E);return n([e,t,i]),f&&(i=y$(i,[i.shape[1],i.shape[2],i.shape[3]])),{value:i,gradFunc:y}}));return t(d,c)}{const t=JL(((t,e,n,i)=>{let s=jk.runKernel(RN,I,E);return i([e,t,s,n]),f&&(s=y$(s,[s.shape[1],s.shape[2],s.shape[3]])),{value:s,gradFunc:y}}));return t(d,c,_)}}});const qU=oD({depthwiseConv2dNativeBackpropFilter_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r=[1,1],a){let o=t;3===t.rank&&(o=y$(t,[1,t.shape[0],t.shape[1],t.shape[2]]));let l=e;3===l.rank&&(l=y$(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const u={x:o,dy:l},h={strides:i,pad:s,dimRoundingMode:a,dilations:r,filterShape:n};return jk.runKernel(eM,u,h)}});const KU=oD({depthwiseConv2dNativeBackpropInput_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r=[1,1],a){let o=e,l=!1;3===e.rank&&(l=!0,o=y$(e,[1,e.shape[0],e.shape[1],e.shape[2]]));const u={dy:o,filter:n},h={strides:i,pad:s,dimRoundingMode:a,dilations:r,inputShape:t},p=jk.runKernel(nM,u,h);return l?y$(p,[p.shape[1],p.shape[2],p.shape[3]]):p}});const QU=oD({fusedDepthwiseConv2d_:
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function({x:t,filter:e,strides:n,pad:i,dataFormat:s="NHWC",dilations:r=[1,1],dimRoundingMode:a,bias:o,activation:l="linear",preluActivationWeights:u,leakyreluAlpha:h}){if(!1===XU(jk.state.gradientDepth,l)){let p=eB(t,e,n,i,s,r,a);return null!=o&&(p=VL(p,o)),zU(p,l,u,h)}const p=sD(t,"x","depthwiseConv2d","float32"),c=sD(e,"filter","depthwiseConv2d","float32");let d=p,f=!1;3===p.rank&&(f=!0,d=y$(p,[1,p.shape[0],p.shape[1],p.shape[2]])),_O(4===d.rank,(()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${d.rank}.`)),_O(4===c.rank,(()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${c.rank}.`)),_O(d.shape[3]===c.shape[2],(()=>`Error in fused depthwiseConv2d: number of input channels (${d.shape[3]}) must match the inChannels dimension in filter ${c.shape[2]}.`)),null==r&&(r=[1,1]),_O(m$(n,r),(()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${r}'`)),T$("fused depthwiseConv2d",i,a);const m=o$(d.shape,c.shape,n,r,i,a,!0);let g,_;null!=o&&(g=sD(o,"bias","fused conv2d"),[g]=Bk(g,p),_F(m.outShape,g.shape)),null!=u&&(_=sD(u,"prelu weights","fused depthwiseConv2d"));const T=(t,e)=>{_O(f$(r),(()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${r}'`));const[s,o,u,h]=e,p=HU(t,u,l),c=KU(o.shape,p,s,n,i,r,a),d=qU(o,p,s.shape,n,i,r,a);if(null!=h){return[c,d,WU(g,p)]}return[c,d]},y={x:d,filter:c,bias:g,preluActivationWeights:_},I={strides:n,pad:i,dataFormat:s,dilations:r,dimRoundingMode:a,activation:l,leakyreluAlpha:h};if(null==o){const t=JL(((t,e,n)=>{let i=jk.runKernel(ON,y,I);return n([e,t,i]),f&&(i=y$(i,[i.shape[1],i.shape[2],i.shape[3]])),{value:i,gradFunc:T}}));return t(d,c)}{const t=JL(((t,e,n,i)=>{let s=jk.runKernel(ON,y,I);return i([e,t,s,n]),f&&(s=y$(s,[s.shape[1],s.shape[2],s.shape[3]])),{value:s,gradFunc:T}}));return t(d,c,g)}}});const JU=oD({fusedMatMul_:
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function({a:t,b:e,transposeA:n=!1,transposeB:i=!1,bias:s,activation:r="linear",preluActivationWeights:a,leakyreluAlpha:o=.2}){if(!1===XU(jk.state.gradientDepth,r)){let l=HF(t,e,n,i);return null!=s&&(l=VL(l,s)),zU(l,r,a,o)}let l=sD(t,"a","fused matMul"),u=sD(e,"b","fused matMul");[l,u]=Bk(l,u);const h=n?l.shape[l.rank-2]:l.shape[l.rank-1],p=i?u.shape[u.rank-1]:u.shape[u.rank-2],c=n?l.shape[l.rank-1]:l.shape[l.rank-2],d=i?u.shape[u.rank-2]:u.shape[u.rank-1],f=l.shape.slice(0,-2),m=u.shape.slice(0,-2),g=IO(f),_=IO(m);_O(h===p,(()=>`Error in fused matMul: inner shapes (${h}) and (${p}) of Tensors with shapes ${l.shape} and ${u.shape} and transposeA=${n} and transposeB=${i} must match.`));const T=_F(l.shape.slice(0,-2),u.shape.slice(0,-2)).concat([c,d]),y=y$(l,n?[g,h,c]:[g,c,h]),I=y$(u,i?[_,d,p]:[_,p,d]);let E,b;null!=s&&(E=sD(s,"bias","fused matMul"),[E]=Bk(E,l),_F(T,E.shape)),null!=a&&(b=sD(a,"prelu weights","fused matMul"));const v=(t,e)=>{const[a,o,l,u]=e,h=HU(y$(t,l.shape),l,r);let p,c;if(n||i?!n&&i?(p=HF(h,o,!1,!1),c=HF(h,a,!0,!1)):n&&!i?(p=HF(o,h,!1,!0),c=HF(a,h,!1,!1)):(p=HF(o,h,!0,!0),c=HF(h,a,!0,!0)):(p=HF(h,o,!1,!0),c=HF(a,h,!0,!1)),null!=s){return[p,c,WU(u,h)]}return[p,c]},w={a:y,b:I,bias:E,preluActivationWeights:b},S={transposeA:n,transposeB:i,activation:r,leakyreluAlpha:o};if(null==s){const t=JL(((t,e,n)=>{const i=jk.runKernel(xN,w,S);return n([t,e,i]),{value:y$(i,T),gradFunc:v}}));return t(y,I)}{const t=JL(((t,e,n,i)=>{const s=jk.runKernel(xN,w,S);return i([t,e,s,n]),{value:y$(s,T),gradFunc:v}}));return t(y,I,E)}}});const ZU=oD({hammingWindow_:
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){return UU(t,.54,.46)}});const tY=oD({hannWindow_:
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){return UU(t,.5,.5)}});const eY=oD({frame_:
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=!1,s=0){let r=0;const a=[];for(;r+e<=t.size;)a.push(w$(t,r,e)),r+=n;if(i)for(;r<t.size;){const i=r+e-t.size,o=b$([w$(t,r,e-i),uF([i],s)]);a.push(o),r+=n}return 0===a.length?IU([],[0,e]):y$(b$(a),[a.length,e])}});const nY=oD({stft_:
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s=tY){null==i&&(i=VU(e));const r=eY(t,e,n),a=GL(r,s(e));return cU(a,i)}});const iY=oD({cropAndResize_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s="bilinear",r=0){const a=sD(t,"image","cropAndResize"),o=sD(e,"boxes","cropAndResize","float32"),l=sD(n,"boxInd","cropAndResize","int32"),u=o.shape[0];_O(4===a.rank,(()=>`Error in cropAndResize: image must be rank 4,but got rank ${a.rank}.`)),_O(2===o.rank&&4===o.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${u},4] but had shape ${o.shape}.`)),_O(1===l.rank&&l.shape[0]===u,(()=>`Error in cropAndResize: boxInd must be have size [${u}] but had shape ${o.shape}.`)),_O(2===i.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${i.length}.`)),_O(i[0]>=1&&i[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${i}`)),_O("bilinear"===s||"nearest"===s,(()=>`method must be bilinear or nearest, but was ${s}`));const h={image:a,boxes:o,boxInd:l},p={method:s,extrapolationValue:r,cropSize:i};return jk.runKernel(QA,h,p)}});const sY=oD({flipLeftRight_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e=sD(t,"image","flipLeftRight","float32");_O(4===e.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`));const n={image:e};return jk.runKernel(yM,n,{})}});const rY=oD({grayscaleToRGB_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e=sD(t,"image","grayscaleToRGB"),n=e.rank-1,i=e.shape[n];_O(e.rank>=2,(()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`)),_O(1===i,(()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${i}.`));const s=new Array(e.rank);return s.fill(1,0,n),s[n]=3,AB(e,s)}});const aY=oD({rgbToGrayscale_:
/**
* @license
* Copyright 2023 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e=sD(t,"image","RGBToGrayscale"),n=e.rank-1,i=e.shape[n];_O(e.rank>=2,(()=>`Error in RGBToGrayscale: images must be at least rank 2, but got rank ${e.rank}.`)),_O(3===i,(()=>`Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${i}.`));const s=e.dtype,r=PL(e,"float32"),a=yU([.2989,.587,.114]);let o;switch(e.rank){case 2:o=lB("ij,j->i",r,a);break;case 3:o=lB("ijk,k->ij",r,a);break;case 4:o=lB("ijkl,l->ijk",r,a);break;case 5:o=lB("ijklm,m->ijkl",r,a);break;case 6:o=lB("ijklmn,n->ijklm",r,a);break;default:throw new Error("Not a valid tensor rank.")}return o=RB(o,-1),PL(o,s)}});const oY=oD({rotateWithOffset_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n=0,i=.5){const s=sD(t,"image","rotateWithOffset","float32");_O(4===s.rank,(()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${s.rank}.`));const r={image:s},a={radians:e,fillValue:n,center:i};return jk.runKernel(SN,r,a)}});
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function lY(t,e,n,i,s,r){null==i&&(i=.5),null==s&&(s=Number.NEGATIVE_INFINITY),null==r&&(r=0);const a=t.shape[0];return n=Math.min(n,a),_O(0<=i&&i<=1,(()=>`iouThreshold must be in [0, 1], but was '${i}'`)),_O(2===t.rank,(()=>`boxes must be a 2D tensor, but was of rank '${t.rank}'`)),_O(4===t.shape[1],(()=>`boxes must have 4 columns, but 2nd dimension was ${t.shape[1]}`)),_O(1===e.rank,(()=>"scores must be a 1D tensor")),_O(e.shape[0]===a,(()=>`scores has incompatible shape with boxes. Expected ${a}, but was ${e.shape[0]}`)),_O(0<=r&&r<=1,(()=>`softNmsSigma must be in [0, 1], but was '${r}'`)),{maxOutputSize:n,iouThreshold:i,scoreThreshold:s,softNmsSigma:r}}const uY=oD({nonMaxSuppression_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY){const r=sD(t,"boxes","nonMaxSuppression","float32"),a=sD(e,"scores","nonMaxSuppression","float32"),o=lY(r,a,n,i,s),l={maxOutputSize:n=o.maxOutputSize,iouThreshold:i=o.iouThreshold,scoreThreshold:s=o.scoreThreshold};return jk.runKernel(hC,{boxes:r,scores:a},l)}});
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function hY(t,e,n){const i=function(t,e,n){return function(t,e,n){let i=0,s=t.length,r=0,a=!1;for(;i<s;){r=i+(s-i>>>1);const o=n(e,t[r]);o>0?i=r+1:(s=r,a=!o)}return a?i:-i-1}(t,e,n||pY)}(t,e,n),s=i<0?-(i+1):i;t.splice(s,0,e)}function pY(t,e){return t>e?1:t<e?-1:0}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function cY(t,e,n,i,s){return mY(t,e,n,i,s,0)}function dY(t,e,n,i,s,r){return mY(t,e,n,i,s,0,!1,r,!0)}function fY(t,e,n,i,s,r){return mY(t,e,n,i,s,r,!0)}function mY(t,e,n,i,s,r,a=!1,o=!1,l=!1){const u=[];for(let t=0;t<e.length;t++)e[t]>s&&u.push({score:e[t],boxIndex:t,suppressBeginIndex:0});u.sort(TY);const h=r>0?-.5/r:0,p=[],c=[];for(;p.length<n&&u.length>0;){const e=u.pop(),{score:n,boxIndex:r,suppressBeginIndex:a}=e;if(n<s)break;let o=!1;for(let n=p.length-1;n>=a;--n){const a=gY(t,r,p[n]);if(a>=i){o=!0;break}if(e.score=e.score*_Y(i,h,a),e.score<=s)break}e.suppressBeginIndex=p.length,o||(e.score===n?(p.push(r),c.push(e.score)):e.score>s&&hY(u,e,TY))}const d=p.length,f=n-d;o&&f>0&&(p.push(...new Array(f).fill(0)),c.push(...new Array(f).fill(0)));const m={selectedIndices:p};return a&&(m.selectedScores=c),l&&(m.validOutputs=d),m}function gY(t,e,n){const i=t.subarray(4*e,4*e+4),s=t.subarray(4*n,4*n+4),r=Math.min(i[0],i[2]),a=Math.min(i[1],i[3]),o=Math.max(i[0],i[2]),l=Math.max(i[1],i[3]),u=Math.min(s[0],s[2]),h=Math.min(s[1],s[3]),p=Math.max(s[0],s[2]),c=Math.max(s[1],s[3]),d=(o-r)*(l-a),f=(p-u)*(c-h);if(d<=0||f<=0)return 0;const m=Math.max(r,u),g=Math.max(a,h),_=Math.min(o,p),T=Math.min(l,c),y=Math.max(_-m,0)*Math.max(T-g,0);return y/(d+f-y)}function _Y(t,e,n){const i=Math.exp(e*n*n);return n<=t?i:0}function TY(t,e){return t.score-e.score||t.score===e.score&&e.boxIndex-t.boxIndex}const yY=
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
async function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY){const r=sD(t,"boxes","nonMaxSuppressionAsync"),a=sD(e,"scores","nonMaxSuppressionAsync"),o=lY(r,a,n,i,s);n=o.maxOutputSize,i=o.iouThreshold,s=o.scoreThreshold;const l=await Promise.all([r.data(),a.data()]),u=l[0],h=l[1],{selectedIndices:p}=cY(u,h,n,i,s);return r!==t&&r.dispose(),a!==e&&a.dispose(),yU(p,"int32")};const IY=oD({nonMaxSuppressionWithScore_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY,r=0){const a=sD(t,"boxes","nonMaxSuppression"),o=sD(e,"scores","nonMaxSuppression"),l=lY(a,o,n,i,s,r),u={boxes:a,scores:o},h={maxOutputSize:n=l.maxOutputSize,iouThreshold:i=l.iouThreshold,scoreThreshold:s=l.scoreThreshold,softNmsSigma:r=l.softNmsSigma},p=jk.runKernel(cC,u,h);return{selectedIndices:p[0],selectedScores:p[1]}}});const EY=
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
async function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY,r=0){const a=sD(t,"boxes","nonMaxSuppressionAsync"),o=sD(e,"scores","nonMaxSuppressionAsync"),l=lY(a,o,n,i,s,r);n=l.maxOutputSize,i=l.iouThreshold,s=l.scoreThreshold,r=l.softNmsSigma;const u=await Promise.all([a.data(),o.data()]),h=u[0],p=u[1],{selectedIndices:c,selectedScores:d}=fY(h,p,n,i,s,r);return a!==t&&a.dispose(),o!==e&&o.dispose(),{selectedIndices:yU(c,"int32"),selectedScores:yU(d)}};const bY=oD({nonMaxSuppressionPadded_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY,r=!1){const a=sD(t,"boxes","nonMaxSuppression"),o=sD(e,"scores","nonMaxSuppression"),l=lY(a,o,n,i,s,null),u={boxes:a,scores:o},h={maxOutputSize:l.maxOutputSize,iouThreshold:l.iouThreshold,scoreThreshold:l.scoreThreshold,padToMaxOutputSize:r},p=jk.runKernel(pC,u,h);return{selectedIndices:p[0],validOutputs:p[1]}}});const vY=
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
async function(t,e,n,i=.5,s=Number.NEGATIVE_INFINITY,r=!1){const a=sD(t,"boxes","nonMaxSuppressionAsync"),o=sD(e,"scores","nonMaxSuppressionAsync"),l=lY(a,o,n,i,s,null),u=l.maxOutputSize,h=l.iouThreshold,p=l.scoreThreshold,[c,d]=await Promise.all([a.data(),o.data()]),{selectedIndices:f,validOutputs:m}=dY(c,d,u,h,p,r);return a!==t&&a.dispose(),o!==e&&o.dispose(),{selectedIndices:yU(f,"int32"),validOutputs:tF(m,"int32")}};const wY=oD({resizeBilinear_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n=!1,i=!1){const s=sD(t,"images","resizeBilinear");_O(3===s.rank||4===s.rank,(()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${s.rank}.`)),_O(2===e.length,(()=>`Error in resizeBilinear: new shape must 2D, but got shape ${e}.`)),_O(!1===i||!1===n,(()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."));let r=s,a=!1;3===s.rank&&(a=!0,r=y$(s,[1,s.shape[0],s.shape[1],s.shape[2]]));const[]=e,o={images:r},l={alignCorners:n,halfPixelCenters:i,size:e},u=jk.runKernel(CC,o,l);return a?y$(u,[u.shape[1],u.shape[2],u.shape[3]]):u}});const SY=oD({resizeNearestNeighbor_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n=!1,i=!1){const s=sD(t,"images","resizeNearestNeighbor");_O(3===s.rank||4===s.rank,(()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${s.rank}.`)),_O(2===e.length,(()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`)),_O("float32"===s.dtype||"int32"===s.dtype,(()=>"`images` must have `int32` or `float32` as dtype")),_O(!1===i||!1===n,(()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."));let r=s,a=!1;3===s.rank&&(a=!0,r=y$(s,[1,s.shape[0],s.shape[1],s.shape[2]]));const[]=e,o={images:r},l={alignCorners:n,halfPixelCenters:i,size:e},u=jk.runKernel(AC,o,l);return a?y$(u,[u.shape[1],u.shape[2],u.shape[3]]):u}});const xY=oD({threshold_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e="binary",n=!1,i=.5){const s=sD(t,"image","threshold"),r=s.shape[0]*s.shape[1];let a,o,l,u,h=GL(yU([i]),255);if(_O(3===s.rank,(()=>`Error in threshold: image must be rank 3,but got rank ${s.rank}.`)),_O(3===s.shape[2]||1===s.shape[2],(()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${s.shape[2]}.`)),_O("int32"===s.dtype||"float32"===s.dtype,(()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${s.dtype}.`)),_O("otsu"===e||"binary"===e,(()=>`Method must be binary or otsu, but was ${e}`)),3===s.shape[2]){[a,o,l]=pU(s,[1,1,1],-1);const t=GL(a,.2989),e=GL(o,.587),n=GL(l,.114);u=VL(VL(t,e),n)}else u=t;if("otsu"===e){h=function(t,e){let n,i,s,r,a,o,l=yU([-1]),u=yU([0]),h=yU([0]);for(let p=0;p<t.size-1;p++){n=w$(t,0,p+1),i=w$(t,p+1),a=YL(bB(n),e),o=YL(bB(i),e);const c=bB(GL(n,VV(0,n.size)));s=YL(c,bB(n));const d=uF(i.shape,n.size),f=VL(VV(0,i.size),d),m=GL(i,f);r=YL(bB(m),bB(i));const g=cF(s,r),_=cF(s,r),T=GL(a,o);h=GL(GL(T,g),_);const y=kB(h,u);u=rB(y,h,u),l=rB(y,yU([p]),l)}return l}(N$(PL(qV(u),"int32"),hD([]),256),r)}const p=n?VB(u,h):kB(u,h);return PL(GL(p,255),"int32")}});const RY=oD({transform_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n="nearest",i="constant",s=0,r){const a=sD(t,"image","transform","float32"),o=sD(e,"transforms","transform","float32");_O(4===a.rank,(()=>`Error in transform: image must be rank 4,but got rank ${a.rank}.`)),_O(2===o.rank&&(o.shape[0]===a.shape[0]||1===o.shape[0])&&8===o.shape[1],(()=>"Error in transform: Input transform should be batch x 8 or 1 x 8")),_O(null==r||2===r.length,(()=>`Error in transform: outputShape must be [height, width] or null, but got ${r}.`));const l={image:a,transforms:o},u={interpolation:n,fillMode:i,fillValue:s,outputShape:r};return jk.runKernel(gN,l,u)}});const OY=oD({bandPart_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"a","bandPart");_O(i.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${i.rank}.`));const s=i.shape,[r,a]=i.shape.slice(-2);let o,l;"number"==typeof e?(_O(e%1==0,(()=>`bandPart(): numLower must be an integer, got ${e}.`)),_O(e<=r,(()=>`bandPart(): numLower (${e}) must not be greater than the number of rows (${r}).`)),o=sD(e<0?r:e,"numLower","bandPart")):(_O("int32"===e.dtype,(()=>"bandPart(): numLower's dtype must be an int32.")),o=rB(BB(e,0),r,uV(e,r))),"number"==typeof n?(_O(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`)),_O(n<=a,(()=>`bandPart(): numUpper (${n}) must not be greater than the number of columns (${a}).`)),l=sD(n<0?a:n,"numUpper","bandPart")):(_O("int32"===n.dtype,(()=>"bandPart(): numUpper's dtype must be an int32.")),l=rB(BB(n,0),a,uV(n,a)));const u=y$(VV(0,r,1,"int32"),[-1,1]),h=VV(0,a,1,"int32"),p=cF(u,h),c=qB(VB(p,o),DB(p,XF(l))),d=aV([r,a],i.dtype);return y$(mU(AU(y$(i,[-1,r,a])).map((t=>rB(c,t,d)))),s)}});const AY=oD({gramSchmidt_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){let e;if(Array.isArray(t)){e=!1,_O(null!=t&&t.length>0,(()=>"Gram-Schmidt process: input must not be null, undefined, or empty"));const n=t[0].shape[0];for(let e=1;e<t.length;++e)_O(t[e].shape[0]===n,(()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${t[e].shape[0]} vs. ${n})`))}else e=!0,t=pU(t,t.shape[0],0).map((t=>fU(t,[0])));_O(t.length<=t[0].shape[0],(()=>`Gram-Schmidt: Number of vectors (${t.length}) exceeds number of dimensions (${t[0].shape[0]}).`));const n=[],i=t;for(let e=0;e<t.length;++e)n.push(jk.tidy((()=>{let t=i[e];if(e>0)for(let i=0;i<e;++i){const e=GL(bB(GL(n[i],t)),n[i]);t=cF(t,e)}return YL(t,wB(t,"euclidean"))})));return e?mU(n,0):n}});function MY(t,e=!1){return jk.tidy((()=>{_O(2===t.shape.length,(()=>`qr2d() requires a 2D Tensor, but got a ${t.shape.length}D Tensor.`));const n=t.shape[0],i=t.shape[1];let s=MB(n),r=$L(t);const a=IU([[1]],[1,1]);let o=$L(a);const l=n>=i?i:n;for(let t=0;t<l;++t){const e=r,l=o,u=s;[o,r,s]=jk.tidy((()=>{const e=w$(r,[t,t],[n-t,1]),l=wB(e),u=w$(r,[t,t],[1,1]),h=rB(kB(u,0),IU([[-1]]),IU([[1]])),p=cF(u,GL(h,l)),c=YL(e,p);o=1===c.shape[0]?$L(a):b$([a,w$(c,[1,0],[c.shape[0]-1,c.shape[1]])],0);const d=XF(YL(HF(h,p),l)),f=w$(r,[t,0],[n-t,i]),m=GL(d,o),g=qF(o);if(0===t)r=cF(f,HF(m,HF(g,f)));else{const e=cF(f,HF(m,HF(g,f)));r=b$([w$(r,[0,0],[t,i]),e],0)}const _=qF(m),T=w$(s,[0,t],[n,s.shape[1]-t]);if(0===t)s=cF(T,HF(HF(T,o),_));else{const e=cF(T,HF(HF(T,o),_));s=b$([w$(s,[0,0],[n,t]),e],1)}return[o,r,s]})),bD([e,l,u])}return!e&&n>i&&(s=w$(s,[0,0],[n,i]),r=w$(r,[0,0],[i,i])),[s,r]}))}const CY=oD({qr_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e=!1){if(_O(t.rank>=2,(()=>`qr() requires input tensor to have a rank >= 2, but got rank ${t.rank}`)),2===t.rank)return MY(t,e);{const n=t.shape.slice(0,t.shape.length-2).reduce(((t,e)=>t*e)),i=AU(y$(t,[n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0),s=[],r=[];i.forEach((t=>{const[n,i]=MY(t,e);s.push(n),r.push(i)}));return[y$(mU(s,0),t.shape),y$(mU(r,0),t.shape)]}}});
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
var NY;!function(t){t[t.NONE=0]="NONE",t[t.MEAN=1]="MEAN",t[t.SUM=2]="SUM",t[t.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(NY||(NY={}));const kY=oD({computeWeightedLoss_:function(t,e,n=NY.SUM_BY_NONZERO_WEIGHTS){const i=sD(t,"losses","computeWeightedLoss");let s=null;null!=e&&(s=sD(e,"weights","computeWeightedLoss"));const r=null==s?i:GL(i,s);if(n===NY.NONE)return r;if(n===NY.SUM)return bB(r);if(n===NY.MEAN){if(null==s)return rV(r);{const t=i.size/s.size,e=YL(bB(r),bB(s));return t>1?YL(e,tF(t)):e}}if(n===NY.SUM_BY_NONZERO_WEIGHTS){if(null==s)return YL(bB(r),tF(i.size));{const t=GL(s,oV(i.shape)),e=PL(bB(mV(t,tF(0))),"float32");return YL(bB(r),e)}}throw Error(`Unknown reduction: ${n}`)}});const DY=oD({absoluteDifference_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=NY.SUM_BY_NONZERO_WEIGHTS){const s=sD(t,"labels","absoluteDifference"),r=sD(e,"predictions","absoluteDifference");let a=null;null!=n&&(a=sD(n,"weights","absoluteDifference")),TO(s.shape,r.shape,"Error in absoluteDifference: ");const o=fF(cF(s,r));return kY(o,a,i)}});const LY=oD({cosineDistance_:function(t,e,n,i,s=NY.SUM_BY_NONZERO_WEIGHTS){const r=sD(t,"labels","cosineDistance"),a=sD(e,"predictions","cosineDistance");let o=null;null!=i&&(o=sD(i,"weights","cosineDistance")),TO(r.shape,a.shape,"Error in cosineDistance: ");const l=tF(1),u=cF(l,bB(GL(r,a),n,!0));return kY(u,o,s)}});const FY=oD({hingeLoss_:function(t,e,n,i=NY.SUM_BY_NONZERO_WEIGHTS){let s=sD(t,"labels","hingeLoss");const r=sD(e,"predictions","hingeLoss");let a=null;null!=n&&(a=sD(n,"weights","hingeLoss")),TO(s.shape,r.shape,"Error in hingeLoss: ");const o=tF(1);s=cF(GL(tF(2),s),o);const l=YV(cF(o,GL(s,r)));return kY(l,a,i)}});const PY=oD({huberLoss_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=1,s=NY.SUM_BY_NONZERO_WEIGHTS){const r=sD(t,"labels","huberLoss"),a=sD(e,"predictions","huberLoss");let o=null;null!=n&&(o=sD(n,"weights","huberLoss")),TO(r.shape,a.shape,"Error in huberLoss: ");const l=tF(i),u=fF(cF(a,r)),h=uV(u,l),p=cF(u,h),c=VL(GL(tF(.5),WL(h)),GL(l,p));return kY(c,o,s)}});const $Y=oD({logLoss_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=1e-7,s=NY.SUM_BY_NONZERO_WEIGHTS){const r=sD(t,"labels","logLoss"),a=sD(e,"predictions","logLoss");let o=null;null!=n&&(o=sD(n,"weights","logLoss")),TO(r.shape,a.shape,"Error in logLoss: ");const l=tF(1),u=tF(i),h=XF(GL(r,GB(VL(a,u)))),p=GL(cF(l,r),GB(VL(cF(l,a),u))),c=cF(h,p);return kY(c,o,s)}});const BY=oD({meanSquaredError_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=NY.SUM_BY_NONZERO_WEIGHTS){const s=sD(t,"labels","meanSquaredError"),r=sD(e,"predictions","meanSquaredError");let a=null;null!=n&&(a=sD(n,"weights","meanSquaredError")),TO(s.shape,r.shape,"Error in meanSquaredError: ");const o=dU(s,r);return kY(o,a,i)}});const VY=oD({sigmoidCrossEntropy_:function(t,e,n,i=0,s=NY.SUM_BY_NONZERO_WEIGHTS){let r=sD(t,"multiClassLabels","sigmoidCrossEntropy");const a=sD(e,"logits","sigmoidCrossEntropy");let o=null;if(null!=n&&(o=sD(n,"weights","sigmoidCrossEntropy")),TO(r.shape,a.shape,"Error in sigmoidCrossEntropy: "),i>0){const t=tF(i),e=tF(1),n=tF(.5);r=VL(GL(r,cF(e,t)),GL(n,t))}const l=
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"labels","sigmoidCrossEntropyWithLogits"),i=sD(e,"logits","sigmoidCrossEntropyWithLogits");TO(n.shape,i.shape,"Error in sigmoidCrossEntropyWithLogits: ");const s=YV(i),r=GL(i,n),a=HB(xB(XF(fF(i))));return VL(cF(s,r),a)}(r,a);return kY(l,o,s)}});const UY=oD({softmaxCrossEntropy_:function(t,e,n,i=0,s=NY.SUM_BY_NONZERO_WEIGHTS){let r=sD(t,"onehotLabels","softmaxCrossEntropy");const a=sD(e,"logits","softmaxCrossEntropy");let o=null;if(null!=n&&(o=sD(n,"weights","softmaxCrossEntropy")),TO(r.shape,a.shape,"Error in softmaxCrossEntropy: "),i>0){const t=tF(i),e=tF(1),n=tF(r.shape[1]);r=VL(GL(r,cF(e,t)),YL(t,n))}const l=
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n=-1){if(-1===n&&(n=e.rank-1),n!==e.rank-1)throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${e.rank} and dim was ${n}`);const i=JL(((t,e,i)=>{const s=jB(e,[n],!0),r=cF(PL(e,"float32"),s);i([t,r]);const a=XF(GL(r,t));return{value:bB(a,[n]),gradFunc:(t,e)=>{const[i,s]=e,r=mB(t.shape,[n]);return[GL(y$(t,r),cF(PL(i,"float32"),xB(s))),GL(y$(t,r),cF(xB(s),PL(i,"float32")))]}}}));return i(t,e)}(r,a);return kY(l,o,s)}});const YY=oD({sparseFillEmptyRows_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i){const s=sD(t,"indices","sparseFillEmptyRows","int32"),r=sD(e,"values","sparseFillEmptyRows"),a=sD(n,"denseShape","sparseFillEmptyRows","int32"),o=sD(i,"defaultValue","sparseFillEmptyRows",r.dtype);if(2!==s.rank)throw new Error(`Indices should be Tensor2D but received shape\n ${s.shape}`);if(1!==r.rank)throw new Error(`Values should be Tensor1D but received shape ${r.shape}`);if(1!==a.rank)throw new Error(`Dense shape should be Tensor1D but received shape ${a.shape}`);if(0!==o.rank)throw new Error(`Default value should be a scalar but received shape ${o.shape}`);const l={indices:s,values:r,denseShape:a,defaultValue:o},u=jk.runKernel(ZC,l);return{outputIndices:u[0],outputValues:u[1],emptyRowIndicator:u[2],reverseIndexMap:u[3]}}});const GY=oD({sparseReshape_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"inputIndices","sparseReshape","int32"),s=sD(e,"inputShape","sparseReshape","int32"),r=sD(n,"newShape","sparseReshape","int32");if(2!==i.rank)throw new Error(`Input indices should be Tensor2D but received shape\n ${i.shape}`);if(1!==s.rank)throw new Error(`Input shape should be Tensor1D but received shape ${s.shape}`);if(1!==r.rank)throw new Error(`New shape should be Tensor1D but received shape ${r.shape}`);const a={inputIndices:i,inputShape:s,newShape:r},o=jk.runKernel(tN,a);return{outputIndices:o[0],outputShape:o[1]}}});const HY=oD({sparseSegmentMean_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"data","sparseSegmentMean"),s=sD(e,"indices","sparseSegmentMean","int32"),r=sD(n,"segmentIds","sparseSegmentMean","int32");if(i.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${s.shape}`);if(1!==r.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${r.shape}`);const a={data:i,indices:s,segmentIds:r};return jk.runKernel(eN,a)}});const WY=oD({sparseSegmentSum_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=sD(t,"data","sparseSegmentSum"),s=sD(e,"indices","sparseSegmentSum","int32"),r=sD(n,"segmentIds","sparseSegmentSum","int32");if(i.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${s.shape}`);if(1!==r.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${r.shape}`);const a={data:i,indices:s,segmentIds:r};return jk.runKernel(nN,a)}});const zY=oD({stringNGrams_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r,a,o){const l=sD(t,"data","stringNGrams","string");if("string"!==l.dtype)throw new Error("Data must be of datatype string");if(1!==l.shape.length)throw new Error(`Data must be a vector, saw: ${l.shape}`);const u=sD(e,"dataSplits","stringNGrams");if("int32"!==u.dtype)throw new Error("Data splits must be of datatype int32");const h={separator:n,nGramWidths:i,leftPad:s,rightPad:r,padWidth:a,preserveShortSequences:o},p={data:l,dataSplits:u},c=jk.runKernel(lN,p,h);return{nGrams:c[0],nGramsSplits:c[1]}}});const XY=oD({stringSplit_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n=!0){const i=sD(t,"input","stringSplit","string"),s=sD(e,"delimiter","stringSplit","string");if(1!==i.rank)throw new Error(`Input should be Tensor1D but received shape ${i.shape}`);if(0!==s.rank)throw new Error(`Delimiter should be a scalar but received shape ${s.shape}`);const r={skipEmpty:n},a={input:i,delimiter:s},o=jk.runKernel(uN,a,r);return{indices:o[0],values:o[1],shape:o[2]}}});const jY=oD({stringToHashBucketFast_:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e){const n=sD(t,"input","stringToHashBucketFast","string"),i={numBuckets:e};if(e<=0)throw new Error("Number of buckets must be at least 1");const s={input:n};return jk.runKernel(hN,s,i)}});const qY=oD({staticRegexReplace_:
/**
* @license
* Copyright 2023 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=!0){const s=sD(t,"input","staticRegexReplace","string"),r={pattern:e,rewrite:n,replaceGlobal:i};return jk.runKernel(aN,{x:s},r)}}),KY={fft:lU,ifft:uU,rfft:cU,irfft:hU},QY={hammingWindow:ZU,hannWindow:tY,frame:eY,stft:nY},JY={flipLeftRight:sY,grayscaleToRGB:rY,resizeNearestNeighbor:SY,resizeBilinear:wY,rgbToGrayscale:aY,rotateWithOffset:oY,cropAndResize:iY,nonMaxSuppression:uY,nonMaxSuppressionAsync:yY,nonMaxSuppressionWithScore:IY,nonMaxSuppressionWithScoreAsync:EY,nonMaxSuppressionPadded:bY,nonMaxSuppressionPaddedAsync:vY,threshold:xY,transform:RY},ZY={bandPart:OY,gramSchmidt:AY,qr:CY},tG={absoluteDifference:DY,computeWeightedLoss:kY,cosineDistance:LY,hingeLoss:FY,huberLoss:PY,logLoss:$Y,meanSquaredError:BY,sigmoidCrossEntropy:VY,softmaxCrossEntropy:UY},eG={sparseFillEmptyRows:YY,sparseReshape:GY,sparseSegmentMean:HY,sparseSegmentSum:WY},nG={stringNGrams:zY,stringSplit:XY,stringToHashBucketFast:jY,staticRegexReplace:qY},iG=WP,sG="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:t=>t();function rG(){return new Promise((t=>sG((()=>t()))))}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function aG(t,e){const n=t[0].length;t.forEach(((t,e)=>{_O(t.length===n,(()=>`Error in concat${n}D: rank of tensors[${e}] must be the same as the rank of the rest (${n})`))})),_O(e>=0&&e<n,(()=>`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const i=t[0];t.forEach(((t,s)=>{for(let r=0;r<n;r++)_O(r===e||t[r]===i[r],(()=>`Error in concat${n}D: Shape of tensors[${s}] (${t}) does not match the shape of the rest (${i}) along the non-concatenated axis ${s}.`))}))}function oG(t,e){const n=t[0].slice();for(let i=1;i<t.length;i++)n[e]+=t[i][e];return n}
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
var lG;function uG(t,e,n){let i=new Array;if(null==n&&null==e)return i;if(null==e)for(;i.length<t+n.length;)i.push(-1);else i=e.slice();if(null==n)return i;if(t+n.length!==i.length)throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.rank = ${t+n.length}, but shape.rank = ${i.length}`);for(let s=1;s<n.length;++s){const r=n[s],a=i[i.length-n.length+s],o=i[a];if(r>=0)if(o>=0){if(o!==r)throw new Error(`rt input.shape and shape=${e} are incompatible: rt input.shape[${s+t}] = ${r} but shape[${s+t}] = ${o}`)}else i[a]=r}return i}function hG(t){const e={FIRST_DIM_SIZE:lG.FIRST_DIM_SIZE,VALUE_ROWIDS:lG.VALUE_ROWIDS,ROW_LENGTHS:lG.ROW_LENGTHS,ROW_SPLITS:lG.ROW_SPLITS,ROW_LIMITS:lG.ROW_LIMITS,ROW_STARTS:lG.ROW_STARTS},n=[];for(const i of t){if(!(i in e))break;n.push(e[i])}return n}function pG(t){return 0===t.length?0:t[0]===lG.FIRST_DIM_SIZE?t.length-1:t.length}function cG(t,e){if(null==t||null==e)return;const n=t.length,i=e.length;if(n>=i)throw new Error(`defaultValue.shape=${t} and ragged tensor flatValues.shape=${e}, are incompatible: defaultValue.rank = ${n} must be less than ragged tensor input flatValues.rank = ${i})`);for(let s=0;s<Math.min(n,i-1);++s){const n=t[s],i=e[s+1];if(n>=0&&i>=0&&1!==n&&n!==i)throw new Error(`defaultValue.shape=${t}, and ragged tensor input flatValues.shape=${e} are incompatible: defaultValue.shape[${s-t.length}] = ${n} but ragged tensor input.flatValues.shape[${s-t.length}] = ${i}`)}}!function(t){t[t.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",t[t.VALUE_ROWIDS=1]="VALUE_ROWIDS",t[t.ROW_LENGTHS=2]="ROW_LENGTHS",t[t.ROW_SPLITS=3]="ROW_SPLITS",t[t.ROW_LIMITS=4]="ROW_LIMITS",t[t.ROW_STARTS=5]="ROW_STARTS"}(lG||(lG={}));
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const dG=30;function fG(t){return t<=dG?t:WO(t,Math.floor(Math.sqrt(t)))}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function mG(t,e,n){return[n*("number"==typeof t?t:t[0]),e*("number"==typeof t?t:t[1])]}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function gG(t,e,n,i=!0){let s=[];if(i)s=s.concat(e.slice(0)),s.push(t[0]/n),s=s.concat(t.slice(1));else{s=s.concat(t[0]);const n=e.length;for(let i=0;i<n;++i)s=s.concat([t[i+1]/e[i],e[i]]);s=s.concat(t.slice(n+1))}return s}function _G(t,e,n=!0){const i=[];if(n){i.push(e);for(let n=e+1;n<t;++n)n<=2*e?(i.push(n),i.push(n-(e+1))):i.push(n)}else{const n=[],s=[];for(let i=1;i<t;++i)i>=2*e+1||i%2==1?s.push(i):n.push(i);i.push(...n),i.push(0),i.push(...s)}return i}function TG(t,e,n,i=!0){const s=[];i?s.push(t[0]/n):s.push(t[0]*n);for(let n=1;n<t.length;++n)n<=e.length?i?s.push(e[n-1]*t[n]):s.push(t[n]/e[n-1]):s.push(t[n]);return s}function yG(t,e){const n=[0];for(let i=0;i<e;++i)n.push(t[i][0]);return n}function IG(t,e,n){const i=t.slice(0,1);for(let s=0;s<n;++s)i.push(t[s+1]-e[s][0]-e[s][1]);return i}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const EG=1.7580993408473768,bG=1.0507009873554805,vG=.3275911,wG=.254829592,SG=-.284496736,xG=1.421413741,RG=-1.453152027,OG=1.061405429;
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function AG(t,e){if(t.length!==e.length)throw new Error(`Cannot merge real and imag arrays of different lengths. real:${t.length}, imag: ${e.length}.`);const n=new Float32Array(2*t.length);for(let i=0;i<n.length;i+=2)n[i]=t[i/2],n[i+1]=e[i/2];return n}function MG(t){const e=new Float32Array(t.length/2),n=new Float32Array(t.length/2);for(let i=0;i<t.length;i+=2)e[i/2]=t[i],n[i/2]=t[i+1];return{real:e,imag:n}}function CG(t){const e=Math.ceil(t.length/4),n=new Float32Array(e),i=new Float32Array(e);for(let e=0;e<t.length;e+=4)n[Math.floor(e/4)]=t[e],i[Math.floor(e/4)]=t[e+1];return{real:n,imag:i}}function NG(t){const e=Math.floor(t.length/4),n=new Float32Array(e),i=new Float32Array(e);for(let e=2;e<t.length;e+=4)n[Math.floor(e/4)]=t[e],i[Math.floor(e/4)]=t[e+1];return{real:n,imag:i}}function kG(t,e){return{real:t[2*e],imag:t[2*e+1]}}function DG(t,e,n,i){t[2*i]=e,t[2*i+1]=n}function LG(t,e){const n=new Float32Array(t/2),i=new Float32Array(t/2);for(let s=0;s<Math.ceil(t/2);s++){const r=(e?2:-2)*Math.PI*(s/t);n[s]=Math.cos(r),i[s]=Math.sin(r)}return{real:n,imag:i}}function FG(t,e,n){const i=(n?2:-2)*Math.PI*(t/e);return{real:Math.cos(i),imag:Math.sin(i)}}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const PG="->",$G=/->/g,BG=",",VG="...";function UG(t,e){const n=((t=t.replace(/\s/g,"")).length-t.replace($G,"").length)/PG.length;if(n<1)throw new Error("Equations without an arrow are not supported.");if(n>1)throw new Error(`Equation must contain exactly one arrow ("${PG}").`);const[i,s]=t.split(PG);_O(-1===i.indexOf(VG),(()=>`The ellipsis notation ("${VG}") is not supported yet.`));const r=i.split(BG),a=r.length;if(e!==a)throw new Error(`Expected ${a} input tensors, received ${e}`);if(a>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const o=[];for(let t=0;t<s.length;++t){const e=s[t];if(!r.some((t=>-1!==t.indexOf(e))))throw new Error(`Output subscripts contain the label ${e} not present in the input subscripts.`);-1===o.indexOf(e)&&o.push(e)}for(let t=0;t<i.length;++t){const e=i[t];-1===o.indexOf(e)&&e!==BG&&o.push(e)}const l=new Array(r.length);for(let t=0;t<a;++t){if(new Set(r[t].split("")).size!==r[t].length)throw new Error(`Found duplicate axes in input component ${r[t]}. Support for duplicate axes in input is not implemented yet.`);l[t]=[];for(let e=0;e<r[t].length;++e)l[t].push(o.indexOf(r[t][e]))}const u=o.length,h=[];for(let t=s.length;t<u;++t)h.push(t);return{allDims:o,summedDims:h,idDims:l}}function YG(t,e){let n=new Array(t);n.fill(-1);for(let t=0;t<e.length;++t)n[e[t]]=t;const i=[];for(let e=0;e<t;++e)-1===n[e]&&i.push(e);return n=n.filter((t=>-1!==t)),{permutationIndices:n,expandDims:i}}function GG(t,e,n){const i=new Array(t);for(let t=0;t<n.length;++t){const s=n[t].shape;for(let n=0;n<e[t].length;++n)void 0===i[e[t][n]]?i[e[t][n]]=s[n]:_O(i[e[t][n]]===s[n],(()=>`Expected dimension ${i[e[t][n]]} at axis ${n} of input shaped ${JSON.stringify(s)}, but got dimension ${s[n]}`))}}function HG(t,e){const n=t,i=[];let s=0;0===t.length&&n.push(-1),s=t.length+1;for(let t=0;t<s;++t)i.push([]);const r=[];for(let t=0;t<n.length;++t){const s=zG(e,n[t]);for(const e of s)-1===r.indexOf(e)&&(i[t].push(e),r.push(e))}return{path:n,steps:i}}function WG(t){return t.every(((t,e)=>t===e))}function zG(t,e){const n=[];for(let i=0;i<t.length;++i)0!==t[i].length&&-1===t[i].indexOf(e)&&-1!==e||n.push(i);return n}function XG(t,e,n=0){let i=[];if("number"==typeof e)_O(t.shape[n]%e==0,(()=>"Number of splits must evenly divide the axis.")),i=new Array(e).fill(t.shape[n]/e);else{const s=e.reduce(((t,e)=>(-1===e&&(t+=1),t)),0);_O(s<=1,(()=>"There should be only one negative value in split array."));const r=e.indexOf(-1);if(-1!==r){const i=e.reduce(((t,e)=>e>0?t+e:t));e[r]=t.shape[n]-i}_O(t.shape[n]===e.reduce(((t,e)=>t+e)),(()=>"The sum of sizes must match the size of the axis dimension.")),i=e}return i}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function jG(t){return`Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${t}`}function qG(t,e){return`indices(${t}, 0) is invalid: ${e} < 0`}function KG(t,e,n){return`indices(${t}, 0) is invalid: ${e} >= ${n}`}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function QG(t,e){return`only one output dimension may be -1, not both ${t} and ${e}`}function JG(t,e){return`size ${t} must be non-negative, not ${e}`}function ZG(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"}function tH(t,e){return`Input to reshape is a SparseTensor with ${IO(t)}\n dense values, but the requested shape requires a multiple of ${IO(e)}. inputShape=${t} outputShape= ${e}`}function eH(t,e){return`Input to reshape is a tensor with ${IO(t)} dense values, but the requested shape has ${IO(e)}. inputShape=${t} outputShape=${e}`}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function nH(){return"segment ids must be >= 0"}function iH(){return"segment ids are not increasing"}function sH(t,e){return`Segment id ${t} out of range [0, ${e}), possibly because segmentIds input is not sorted.`}function rH(t,e,n){return`Bad: indices[${t}] == ${e} out of range [0, ${n})`}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function aH(t,e){let n,i=!1;for(t<=dG?(n=t,i=!0):n=WO(t,Math.floor(Math.sqrt(t)));!i;)n>e||n===t?i=!0:n=WO(t,n+1);return n}function oH(t,e,n){const i=[],s=t.length;for(let r=0;r<s;r++)r!==e?i.push(t[r]):i.push(n);return i}function lH(t,e,n,i){const s=e.shape.length,r=t.shape.length;if(0!==i&&(i<-s||i>s))throw new Error(`Expect batchDims in the range of [-${s}, ${s}], but got ${i}`);if(i<0&&(i+=s),i>r)throw new Error(`batchDims (${i}) must be less than rank(x) (\n ${r}).`);if(n<i)throw new Error(`batchDims (${i}) must be less than or equal to axis (${n}).`);for(let n=0;n<i;++n)if(t.shape[n]!==e.shape[n])throw new Error(`x.shape[${n}]: ${t.shape[n]} should be equal to indices.shape[${n}]: ${e.shape[n]}.`);const a=t.shape[n],o=[];let l=1,u=1,h=1;for(let e=0;e<i;++e)o.push(t.shape[e]),l*=t.shape[e];for(let e=i;e<n;e++)o.push(t.shape[e]),u*=t.shape[e];for(let t=i;t<s;t++)o.push(e.shape[t]);for(let e=n+1;e<r;e++)o.push(t.shape[e]),h*=t.shape[e];return{batchSize:l,sliceSize:h,outerSize:u,dimSize:a,outputShape:o}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function uH(t){try{return t.map((t=>lk(t)))}catch(t){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${t}`)}}function hH(t){return t.map((t=>ok(t)))}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
!function(){for(const t of vF)rF(t)}();
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const pH={kernelName:pA,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(t,gU(PL(n,"float32"),-1))}}},cH={kernelName:cA,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=WL(PL(n,"float32")),i=HL(cF(tF(1),e));return XF(YL(t,i))}}}},dH={kernelName:dA,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=HL(cF(WL(PL(n,"float32")),1));return YL(t,e)}}}},fH={kernelName:fA,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=_F(n.shape,i.shape);return{a:()=>{let e=t;const i=gF(n.shape,s);return i.length>0&&(e=bB(e,i)),y$(e,n.shape)},b:()=>{let e=t;const n=gF(i.shape,s);return n.length>0&&(e=bB(e,n)),y$(e,i.shape)}}}},mH={kernelName:mA,saveAllInputs:!0,gradFunc:(t,e)=>{const n={};return e.forEach(((e,i)=>{n[i]=()=>t.clone()})),n}},gH={kernelName:TA,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>zL(n)}}},_H={kernelName:yA,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>zL(n)}}},TH={kernelName:IA,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>YL(t,HL(cF(tF(1),WL(PL(n,"float32")))))}}},yH={kernelName:EA,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=HL(VL(tF(1),WL(PL(n,"float32"))));return YL(t,e)}}}},IH={kernelName:wA,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=_F(n.shape,i.shape);return{a:()=>{const e=VL(WL(n),WL(i));let r=GL(t,YL(i,e));const a=gF(n.shape,s);return a.length>0&&(r=bB(r,a)),y$(r,n.shape)},b:()=>{const e=VL(WL(n),WL(i));let r=XF(GL(t,YL(n,e)));const a=gF(i.shape,s);return a.length>0&&(r=bB(r,a)),y$(r,i.shape)}}}},EH={kernelName:bA,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>YL(t,VL(WL(PL(n,"float32")),1))}}},bH={kernelName:vA,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>YL(t,cF(tF(1),WL(PL(n,"float32"))))}}};const vH=oD({avgPool3dGrad_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r){const a=sD(t,"dy","avgPool3dGrad"),o=sD(e,"input","avgPool3dGrad");let l=a,u=o,h=!1;4===o.rank&&(h=!0,l=y$(a,[1,a.shape[0],a.shape[1],a.shape[2],a.shape[3]]),u=y$(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),_O(5===l.rank,(()=>`Error in avgPool3dGrad: dy must be rank 5 but got rank ${l.rank}.`)),_O(5===u.rank,(()=>`Error in avgPool3dGrad: input must be rank 5 but got rank ${u.rank}.`)),T$("avgPool3dGrad",s,r);const p={dy:l,input:u},c={filterSize:n,strides:i,pad:s,dimRoundingMode:r},d=jk.runKernel(OA,p,c);return h?y$(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),wH={kernelName:RA,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{filterSize:s,strides:r,pad:a,dimRoundingMode:o}=n;return{x:()=>vH(t,i,s,r,a,o)}}};const SH=oD({avgPoolGrad_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s){const r=sD(t,"dy","avgPoolGrad"),a=sD(e,"input","avgPoolGrad");_O(a.rank===r.rank,(()=>`Rank of input (${a.rank}) does not match rank of dy (${r.rank})`));let o=a,l=r,u=!1;3===a.rank&&(u=!0,o=y$(a,[1,a.shape[0],a.shape[1],a.shape[2]]),l=y$(r,[1,r.shape[0],r.shape[1],r.shape[2]])),_O(4===l.rank,(()=>`Error in avgPoolGrad: dy must be rank 4 but got rank ${l.rank}.`)),_O(4===o.rank,(()=>`Error in avgPoolGrad: input must be rank 4 but got rank ${o.rank}.`));const h={dy:l,input:o},p={filterSize:n,strides:i,pad:s},c=jk.runKernel(xA,h,p);return u?y$(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),xH={kernelName:SA,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{filterSize:s,strides:r,pad:a}=n;return{x:()=>SH(t,i,s,r,a)}}},RH={kernelName:AA,inputsToSave:["a","b"],gradFunc:(t,e,n)=>{const[i,s]=e,{transposeA:r,transposeB:a}=n;return r||a?!r&&a?{a:()=>HF(t,s,!1,!1),b:()=>HF(t,i,!0,!1)}:r&&!a?{a:()=>HF(s,t,!1,!0),b:()=>HF(i,t,!1,!1)}:{a:()=>HF(s,t,!0,!0),b:()=>HF(t,i,!0,!0)}:{a:()=>HF(t,s,!1,!0),b:()=>HF(i,t,!0,!1)}}},OH={kernelName:MA,gradFunc:(t,e,n)=>{const{blockShape:i,crops:s}=n;return{x:()=>vV(t,i,s)}}},AH={kernelName:kA,gradFunc:(t,e,n)=>{const i=n,s=i.inputShape,r=i.shape,a=Array.from(r);for(let t=s.length-1;t>=0;t--)if(s[t]===r[t])a[t]=1;else if(1!==s[t])throw new Error(`broadcastTo(): [${s}] cannot be broadcast to [${r}].`);const o=[];for(let t=0;t<a.length;t++)a[t]>1&&o.push(t);return{x:()=>bB(t,o,!0)}}},MH={kernelName:LA,gradFunc:t=>({x:()=>t.clone()})},CH={kernelName:FA,gradFunc:t=>({x:()=>zL(t)})},NH={kernelName:PA,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{clipValueMin:s,clipValueMax:r}=n;return{x:()=>rB(qB(DB(i,s),VB(i,r)),t,zL(t))}}},kH={kernelName:BA,inputsToSave:["x"],gradFunc:pH.gradFunc},DH={kernelName:VA,saveAllInputs:!0,gradFunc:(t,e,n)=>{const i=e.map((t=>t.shape)),{axis:s}=n,r=CO(s,e[0].shape)[0],a=i.map((t=>t[r]));return pU(t,a,r).map((t=>()=>t))}},LH={kernelName:UA,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const[i,s]=e,{dilations:r,strides:a,pad:o,dataFormat:l}=n;return _O(f$(r),(()=>`Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`)),{x:()=>H$(i.shape,t,s,a,o,l),filter:()=>GU(i,t,s.shape,a,o,l)}}},FH={kernelName:GA,inputsToSave:["dy","filter"],gradFunc:(t,e,n)=>{const[i,s]=e,{strides:r,pad:a,dataFormat:o,dimRoundingMode:l}=n;return{dy:()=>Y$(t,s,r,a,o,1,l),filter:()=>GU(t,i,s.shape,r,a,o,l)}}};const PH=oD({conv3DBackpropFilter_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s){let r=t;4===t.rank&&(r=y$(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]));let a=e;4===a.rank&&(a=y$(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]])),_O(5===r.rank,(()=>`Error in conv3dDerFilter: input must be rank 5, but got shape ${r.shape}.`)),_O(5===a.rank,(()=>`Error in conv3dDerFilter: dy must be rank 5, but got shape ${a.shape}.`)),_O(5===n.length,(()=>`Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`)),_O(r.shape[4]===n[3],(()=>`Error in conv3dDerFilter: depth of input ${r.shape[4]}) must match input depth in filter (${n[3]}.`)),_O(a.shape[4]===n[4],(()=>`Error in conv3dDerFilter: depth of dy (${a.shape[4]}) must match output depth for filter (${n[4]}).`));const o={x:r,dy:a},l={strides:i,pad:s,filterShape:n};return jk.runKernel(WA,o,l)}}),$H={kernelName:HA,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const{dilations:i,strides:s,pad:r}=n;_O(f$(i),(()=>`Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${i}'`));const[a,o]=e;return{x:()=>X$(a.shape,t,o,s,r),filter:()=>PH(a,t,o.shape,s,r)}}},BH={kernelName:XA,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(XF(eU(PL(n,"float32"))),t)}}},VH={kernelName:jA,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(nU(PL(n,"float32")),t)}}},UH={kernelName:KA,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{axis:s,exclusive:r,reverse:a}=n;return{x:()=>{const e=_B([s],i.rank);let n=J$(t,s,r,!a);return null!=e&&(n=qF(n,e)),n}}}},YH={kernelName:tM,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const{dilations:i,strides:s,pad:r,dimRoundingMode:a}=n,o=null==i?[1,1]:i;_O(f$(o),(()=>`Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${o}'`));const[l,u]=e;return _O(4===l.rank,(()=>`Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${l.rank}.`)),_O(4===u.rank,(()=>`Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${u.rank}.`)),_O(l.shape[3]===u.shape[2],(()=>`Error in gradient of depthwiseConv2d: number of input channels (${l.shape[3]}) must match the inChannels dimension in filter ${u.shape[2]}.`)),_O(m$(s,o),(()=>`Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${o}'.`)),T$("depthwiseConv2d",r,a),{x:()=>KU(l.shape,t,u,s,r,o,a),filter:()=>qU(l,t,u.shape,s,r,o,a)}}},GH={kernelName:sM,inputsToSave:["x","filter"],gradFunc:(t,e,n)=>{const[i,s]=e,r={x:i,filter:s,dy:t},a={x:i,filter:s,dy:t};return{x:()=>jk.runKernel(rM,r,n),filter:()=>jk.runKernel(aM,a,n)}}},HH={kernelName:hM,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e,i={dy:t,y:n};return{x:()=>jk.runKernel(pM,i)}}},WH={kernelName:cM,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e,i=GL(xB(XF(WL(n))),2/Math.sqrt(Math.PI));return{x:()=>GL(t,i)}}},zH={kernelName:fM,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(t,n)}}},XH={kernelName:mM,inputsToSave:["input"],gradFunc:(t,e)=>{const[n]=e;return{input:()=>y$(t,n.shape)}}},jH={kernelName:gM,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(t,xB(n))}}},qH={kernelName:IM,gradFunc:t=>({x:()=>zL(t)})},KH={kernelName:EM,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=_F(n.shape,i.shape);return{a:()=>{const e=YL(t,PL(i,"float32")),r=gF(n.shape,s);return r.length>0?y$(bB(e,r),n.shape):e},b:()=>{let e=GL(t,PL(n,"float32"));const r=gF(i.shape,s);r.length>0&&(e=y$(bB(e,r),i.shape));const a=WL(i);return XF(YL(e,PL(a,"float32")))}}}},QH={kernelName:bM,inputsToSave:["x","mean","variance","scale"],gradFunc:(t,e,n)=>{const{varianceEpsilon:i}=n,[s,r,a,o]=e,l=null==o?tF(1):o,u=gF(r.shape,s.shape),h=[];if(1===r.rank){for(let t=0;t<s.shape.length-1;++t)h.push(s.shape[t]);h.push(1)}const p=cF(s,r),c=GL(t,l),d=KV(VL(a,tF(i))),f=GL(GL(GL(d,d),d),tF(-.5));return{x:()=>1===r.rank?y$(GL(GL(t,AB(y$(d,[1,1,1,r.shape[0]]),h)),l),s.shape):y$(GL(GL(t,d),l),s.shape),mean:()=>{let t=GL(GL(d,tF(-1)),c);return 1===r.rank&&(t=bB(t,u)),y$(t,r.shape)},variance:()=>{let t=GL(GL(f,p),c);return 1===r.rank&&(t=bB(t,u)),y$(t,r.shape)},scale:()=>{const e=GL(p,d);let n=GL(t,e);return 1===r.rank&&(n=bB(n,u)),y$(n,r.shape)},offset:()=>{let e=t;return 1===r.rank&&(e=bB(e,u)),y$(e,r.shape)}}}},JH={kernelName:vM,inputsToSave:["x","indices"],gradFunc:(t,e,n)=>{const[i,s]=e,{axis:r,batchDims:a}=n,o=CO(r,i.shape)[0],l=(t,e,n)=>()=>{const i=t.shape,s=e.size,a=i.slice(0,o),l=a.length,u=i.slice(r,i.length).slice(1),h=u.length,p=ZH(0,l),c=ZH(l+1,l+1+h),d=tW([a,[s],u]),f=y$(n,d),m=y$(e,[s]),g=tW([[l],p,c]),_=qF(f,g);let T=OU(_,m,t.shape[o]);const y=TB(g);return T=qF(T,y),T};if(1===a){const e=i.shape[0],n=i.split(e,0);return{x:()=>{const e=mU(n.map(((e,n)=>l(e,s.slice(n,1),t.slice(n,1))())));return e.reshape(i.shape)},indices:()=>s}}return{x:l(i,s,t),indices:()=>s}}};function ZH(t,e){const n=[];for(let i=t;i<e;++i)n.push(i);return n}function tW(t){const e=[];for(let n=0;n<t.length;++n)for(let i=0;i<t[n].length;++i)e.push(t[n][i]);return e}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const eW={kernelName:xM,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e;return{a:()=>zL(n),b:()=>zL(i)}}},nW={kernelName:RM,gradFunc:t=>({x:()=>PL(t,"float32")})},iW={kernelName:MM,gradFunc:t=>({x:()=>zL(t)})},sW={kernelName:CM,gradFunc:t=>({x:()=>zL(t)})},rW={kernelName:NM,gradFunc:t=>({x:()=>zL(t)})},aW={kernelName:kM,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{alpha:s}=n,r=kB(i,0);return{x:()=>rB(r,t,GL(t,s))}}},oW={kernelName:$M,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>YL(t,VL(n,1))}}},lW={kernelName:PM,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>YL(t,PL(n,"float32"))}}},uW={kernelName:GM,inputsToSave:[],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[i]=e,{axis:s}=n;return{logits:()=>{const e=xB(i);return cF(t,GL(bB(t,s,!0),e))}}}};const hW=oD({localResponseNormalizationBackprop_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i=5,s=1,r=1,a=.5){const o={x:t,y:e,dy:n},l={depthRadius:i,bias:s,alpha:r,beta:a};return jk.runKernel(zM,o,l)}}),pW={kernelName:WM,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[i,s]=e,{depthRadius:r,bias:a,alpha:o,beta:l}=n;return{x:()=>hW(i,s,t,r,a,o,l)}}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function cW(t,e,n,i){return e.rank<n.rank&&(e=y$(e,mB(e.shape,i))),t.rank<n.rank&&(t=y$(t,mB(t.shape,i))),{x:()=>GL(t,PL(sB(n,e),t.dtype))}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const dW={kernelName:jM,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const i=n,{reductionIndices:s}=i,r=e[0],a=cW(t,e[1],r,CO(s,r.shape));return{x:()=>a.x()}}},fW={kernelName:qM,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e;return{a:()=>GL(t,PL(DB(n,i),"float32")),b:()=>GL(t,PL(BB(n,i),"float32"))}}};const mW=oD({maxPool3dGrad_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r,a){const o=sD(t,"dy","maxPool3dGrad"),l=sD(e,"input","maxPool3dGrad"),u=sD(n,"output","maxPool3dGrad");let h=o,p=l,c=u,d=!1;4===l.rank&&(d=!0,h=y$(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]]),p=y$(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),c=y$(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]])),_O(5===h.rank,(()=>`Error in maxPool3dGrad: dy must be rank 5 but got rank ${h.rank}.`)),_O(5===p.rank,(()=>`Error in maxPool3dGrad: input must be rank 5 but got rank ${p.rank}.`)),_O(5===c.rank,(()=>`Error in maxPool3dGrad: output must be rank 5 but got rank ${c.rank}.`)),T$("maxPool3dGrad",r,a);const f={dy:h,input:p,output:c},m={filterSize:i,strides:s,pad:r,dimRoundingMode:a},g=jk.runKernel(ZM,f,m);return d?y$(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}}),gW={kernelName:JM,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[i,s]=e,{filterSize:r,strides:a,pad:o,dimRoundingMode:l}=n;return{x:()=>mW(t,i,s,r,a,o,l)}}};const _W=oD({maxPoolGrad_:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s,r,a){const o=sD(t,"dy","maxPoolGrad"),l=sD(e,"input","maxPoolGrad"),u=sD(n,"output","maxPoolGrad");_O(l.rank===o.rank,(()=>`Rank of input (${l.rank}) does not match rank of dy (${o.rank})`)),_O(4===o.rank,(()=>`Error in maxPoolGrad: dy must be rank 4 but got rank ${o.rank}.`)),_O(4===l.rank,(()=>`Error in maxPoolGrad: input must be rank 4 but got rank ${l.rank}.`)),T$("maxPoolGrad",r,a);const h={dy:o,input:l,output:u},p={filterSize:i,strides:s,pad:r,dimRoundingMode:a};return jk.runKernel(QM,h,p)}}),TW={kernelName:KM,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const[i,s]=e,{filterSize:r,strides:a,pad:o}=n;return{x:()=>_W(t,i,s,r,a,o)}}},yW={kernelName:sC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const i=e[0],{paddings:s}=n,r=s.map((t=>t[0]));return{x:()=>w$(t,r,i.shape)}}},IW={kernelName:gC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const i=e[0],{paddings:s}=n,r=s.map((t=>t[0]));return{x:()=>w$(t,r,i.shape)}}},EW={kernelName:TC,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:(t,e)=>{const[n,i,s]=e,r=n,a=i,o=_F(r.shape,a.shape);return{a:()=>{const e=PL(a,"float32");let n=GL(t,GL(e,pF(r,cF(e,tF(1)))));const i=gF(r.shape,o);return i.length>0&&(n=bB(n,i)),y$(n,r.shape)},b:()=>{const e=kB(r,0),n=rB(e,GB(r),zL(r));let i=GL(t,GL(s,n));const l=gF(a.shape,o);return l.length>0&&(i=bB(i,l)),y$(i,a.shape)}}}};function bW(t,e,n){const i=t.shape.length,s=i-n.length,r=_B(n,i);let a=t;null!=r&&(a=qF(t,r));const o=a.shape.slice(),l=o.splice(i-n.length,n.length).reduce(((t,e)=>t*e),1);o.push(l);let u=
/**
* @license
* Copyright 2022 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=t.shape.slice();i[n]=1;const s=y$(e,i),r=Q$(t,n,!0,!1),a=Q$(t,n,!0,!0),o=GL(r,a);return GL(s,o)}(a.reshape(o),e,s);if(u=u.reshape(a.shape),null!=r){const t=TB(r);u=qF(u,t)}return u}const vW={kernelName:UC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>{const e=kB(n,tF(0)),i=tF(EG),s=tF(bG),r=GL(t,s),a=GL(GL(t,i),xB(PL(n,"float32")));return rB(e,r,a)}}}},wW={kernelName:KC,gradFunc:(t,e,n)=>{const{blockShape:i,paddings:s}=n;return{x:()=>R$(t,i,s)}}},SW={kernelName:QC,gradFunc:(t,e,n)=>{const{axis:i}=n;return{x:()=>b$(t,i)}}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const xW=[pH,cH,dH,fH,mH,gH,_H,TH,yH,IH,EH,bH,wH,xH,RH,OH,AH,MH,CH,NH,kH,DH,FH,LH,$H,BH,VH,UH,YH,GH,{kernelName:lM,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=_F(n.shape,i.shape);return{a:()=>{const e=YL(t,PL(i,"float32")),r=gF(n.shape,s);return r.length>0?y$(bB(e,r),n.shape):e},b:()=>{let e=GL(t,PL(n,"float32"));const r=gF(i.shape,s);r.length>0&&(e=y$(bB(e,r),i.shape));const a=WL(i);return XF(YL(e,PL(a,"float32")))}}}},HH,WH,zH,XH,jH,KH,qH,QH,JH,eW,nW,iW,sW,rW,aW,oW,lW,uW,pW,dW,dW,fW,gW,TW,{kernelName:eC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{axis:s}=n,r=CO(s,i.shape),a=IO(fB(i.shape,r)[1]);return{x:()=>{const e=i.shape.slice();r.forEach((t=>{e[t]=1}));const n=y$(t,e);return YL(GL(n,oV(i.shape,"float32")),a)}}}},{kernelName:nC,inputsToSave:["x"],outputsToSave:[!0],gradFunc:(t,e,n)=>{const i=n,{axis:s}=i,[r,a]=e,o=cW(t,a,r,CO(s,r.shape));return{x:()=>o.x()}}},{kernelName:iC,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e;return{a:()=>GL(t,PL(VB(n,i),"float32")),b:()=>GL(t,PL(kB(n,i),"float32"))}}},yW,{kernelName:rC,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=_F(n.shape,i.shape);return{a:()=>{const e=gF(n.shape,s);return e.length>0?y$(bB(t,e),n.shape):t},b:()=>{const e=GL(t,XF(CB(YL(n,i)))),r=gF(i.shape,s);return r.length>0?y$(bB(e,r),i.shape):e}}}},{kernelName:oC,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=_F(n.shape,i.shape);return{a:()=>{const e=GL(t,PL(i,"float32")),r=gF(n.shape,s);return r.length>0?y$(bB(e,r),n.shape):e},b:()=>{const e=GL(t,PL(n,"float32")),r=gF(i.shape,s);return r.length>0?y$(bB(e,r),i.shape):e}}}},{kernelName:lC,gradFunc:t=>({x:()=>XF(t)})},{kernelName:fC,inputsToSave:["indices"],gradFunc:(t,e)=>{const n=e[0];return{indices:()=>aV(n.shape,"float32")}}},{kernelName:dC,gradFunc:t=>({x:()=>zL(t)})},{kernelName:mC,saveAllInputs:!0,gradFunc:(t,e,n)=>{const{axis:i}=n;return AU(t,i).map((t=>()=>t))}},IW,IW,EW,{kernelName:yC,inputsToSave:["x","alpha"],gradFunc:(t,e)=>{const[n,i]=e,s=kB(n,0);return{x:()=>rB(s,t,GL(t,i)),alpha:()=>{let e=rB(s,zL(t),GL(t,n));const r=gF(i.shape,t.shape);return r.length>0&&(e=bB(e,r)),y$(e,i.shape)}}}},{kernelName:IC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{axis:s}=n;let r=[];return r=null==s?i.shape.map(((t,e)=>e)):"number"==typeof s?[s]:s,{x:()=>bW(i,t,r)}}},{kernelName:xC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>YL(t,XF(WL(n)))}}},{kernelName:kC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e,i=GL(VB(n,6),gU(n));return{x:()=>GL(t,PL(i,"float32"))}}},{kernelName:RC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(t,PL(gU(n),"float32"))}}},{kernelName:OC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>y$(t,n.shape)}}},{kernelName:CC,inputsToSave:["images"],gradFunc:(t,e,n)=>{const[i]=e,s={dy:t,images:i};return{images:()=>jk.runKernel(NC,s,n)}}},{kernelName:AC,inputsToSave:["images"],gradFunc:(t,e,n)=>{const[i]=e,s={dy:t,images:i};return{images:()=>jk.runKernel(MC,s,n)}}},{kernelName:DC,gradFunc:(t,e,n)=>{const{dims:i}=n,s=CO(i,t.shape);return{x:()=>HV(t,s)}}},{kernelName:LC,gradFunc:t=>({x:()=>zL(t)})},{kernelName:FC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>XF(YL(t,GL(pF(n,1.5),2)))}}},{kernelName:VC,inputsToSave:["condition"],gradFunc:(t,e)=>{const[n]=e;return{condition:()=>PL(zL(n),"float32"),t:()=>GL(t,PL(n,t.dtype)),e:()=>GL(t,PL(KB(n),t.dtype))}}},vW,{kernelName:zC,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(t,GL(n,cF(tF(1),n)))}}},{kernelName:WC,gradFunc:t=>({x:()=>zL(t)})},{kernelName:GC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(q$(PL(n,"float32")),t)}}},{kernelName:HC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(K$(PL(n,"float32")),t)}}},{kernelName:YC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{begin:s,size:r}=n,a=i.shape,[o,l]=RP(i,s,r),u=[];for(let e=0;e<t.rank;e++)u.push([o[e],a[e]-o[e]-l[e]]);return{x:()=>TV(t,u)}}},{kernelName:JC,outputsToSave:[!0],gradFunc:(t,e,n)=>{const[i]=e,{dim:s}=n,r=GL(t,i);return{logits:()=>cF(r,GL(bB(r,[s],true),i))}}},{kernelName:XC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(t,v$(n))}}},wW,wW,SW,SW,{kernelName:jC,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>YL(t,GL(HL(PL(n,"float32")),2))}}},{kernelName:sN,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=tF(2);return{a:()=>GL(t,GL(s,cF(n,i))),b:()=>GL(t,GL(s,cF(i,n)))}}},{kernelName:rN,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(t,GL(PL(n,"float32"),2))}}},{kernelName:vN,gradFunc:t=>({x:()=>zL(t)})},{kernelName:pN,inputsToSave:["a","b"],gradFunc:(t,e)=>{const[n,i]=e,s=_F(n.shape,i.shape);return{a:()=>{let e=t;const i=gF(n.shape,s);return i.length>0&&(e=bB(e,i)),y$(e,n.shape)},b:()=>{let e=t;const n=gF(i.shape,s);return n.length>0&&(e=bB(e,n)),y$(XF(e),i.shape)}}}},{kernelName:qC,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,s=i.shape.slice(),{axis:r}=n;CO(r,i.shape).forEach((t=>{s[t]=1}));const a=y$(t,s),o=GL(a,oV(i.shape,"float32"));return{x:()=>o}}},{kernelName:cN,inputsToSave:["x"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>YL(t,WL(q$(n)))}}},{kernelName:dN,outputsToSave:[!0],gradFunc:(t,e)=>{const[n]=e;return{x:()=>GL(cF(tF(1),WL(n)),t)}}},{kernelName:fN,inputsToSave:["x"],gradFunc:(t,e,n)=>{const[i]=e,{reps:s}=n;return{x:()=>{let e=zL(i);if(1===i.rank)for(let n=0;n<s[0];++n)e=VL(e,w$(t,[n*i.shape[0]],[i.shape[0]]));else if(2===i.rank)for(let n=0;n<s[0];++n)for(let r=0;r<s[1];++r)e=VL(e,w$(t,[n*i.shape[0],r*i.shape[1]],[i.shape[0],i.shape[1]]));else if(3===i.rank)for(let n=0;n<s[0];++n)for(let r=0;r<s[1];++r)for(let a=0;a<s[2];++a)e=VL(e,w$(t,[n*i.shape[0],r*i.shape[1],a*i.shape[2]],[i.shape[0],i.shape[1],i.shape[2]]));else{if(4!==i.rank)throw new Error(`Gradient for tile operation is not implemented for rank-${i.rank} tensors yet.`);for(let n=0;n<s[0];++n)for(let r=0;r<s[1];++r)for(let a=0;a<s[2];++a)for(let o=0;o<s[3];++o)e=VL(e,w$(t,[n*i.shape[0],r*i.shape[1],a*i.shape[2],o*i.shape[3]],[i.shape[0],i.shape[1],i.shape[2],i.shape[3]]))}return e}}}},{kernelName:_N,gradFunc:(t,e,n)=>{const i=n,{perm:s}=i,r=TB(s);return{x:()=>qF(t,r)}}},{kernelName:yN,gradFunc:(t,e,n)=>{const i=n,{axis:s}=i;return{value:()=>mU(t,s)}}},{kernelName:IN,inputsToSave:["segmentIds"],gradFunc:(t,e)=>{const[n]=e;return{x:()=>function(t,e){const n=TF(e,zL(e)),i=NB(t,n);let s=DB(e,tF(0,"int32"));const r=i.rank-s.rank;for(let t=0;t<r;++t)s=RB(s,t+1);s=qB(s,oV(i.shape,"bool"));const a=zL(i);return rB(s,i,a)}(t,n)}}},{kernelName:bN,gradFunc:t=>({x:()=>zL(t)})}];for(const t of xW)PN(t);
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.abs=function(){return this.throwIfDisposed(),fF(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.acos=function(){return this.throwIfDisposed(),zP(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.acosh=function(){return this.throwIfDisposed(),XP(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.add=function(t){return this.throwIfDisposed(),VL(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.all=function(t,e){return this.throwIfDisposed(),qP(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.any=function(t,e){return this.throwIfDisposed(),KP(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.argMax=function(t){return this.throwIfDisposed(),QP(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.argMin=function(t){return this.throwIfDisposed(),JP(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.asScalar=function(){return this.throwIfDisposed(),_O(1===this.size,(()=>"The array must have only 1 element.")),y$(this,[])},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.asType=function(t){return this.throwIfDisposed(),PL(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.as1D=function(){return this.throwIfDisposed(),y$(this,[this.size])},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.as2D=function(t,e){return this.throwIfDisposed(),y$(this,[t,e])},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.as3D=function(t,e,n){return this.throwIfDisposed(),y$(this,[t,e,n])},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.as4D=function(t,e,n,i){return this.throwIfDisposed(),y$(this,[t,e,n,i])},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.as5D=function(t,e,n,i,s){return this.throwIfDisposed(),y$(this,[t,e,n,i,s])},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.asin=function(){return this.throwIfDisposed(),ZP(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.asinh=function(){return this.throwIfDisposed(),t$(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.atan=function(){return this.throwIfDisposed(),e$(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.atan2=function(t){return this.throwIfDisposed(),n$(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.atanh=function(){return this.throwIfDisposed(),i$(this)},Rk().prototype.avgPool=function(t,e,n,i){return this.throwIfDisposed(),I$(this,t,e,n,i)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.batchToSpaceND=function(t,e){return this.throwIfDisposed(),R$(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.batchNorm=function(t,e,n,i,s){return this.throwIfDisposed(),O$(this,t,e,n,i,s)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.broadcastTo=function(t){return this.throwIfDisposed(),L$(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.cast=function(t){return this.throwIfDisposed(),PL(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.ceil=function(){return this.throwIfDisposed(),F$(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.clipByValue=function(t,e){return this.throwIfDisposed(),P$(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.concat=function(t,e){return this.throwIfDisposed(),t instanceof xk&&(t=[t]),b$([this,...t],e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.conv1d=function(t,e,n,i,s,r){return this.throwIfDisposed(),G$(this,t,e,n,i,s,r)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.conv2dTranspose=function(t,e,n,i,s){return this.throwIfDisposed(),W$(this,t,e,n,i,s)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.conv2d=function(t,e,n,i,s,r){return this.throwIfDisposed(),Y$(this,t,e,n,i,s,r)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.cos=function(){return this.throwIfDisposed(),q$(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.cosh=function(){return this.throwIfDisposed(),K$(this)},
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.cumprod=function(t,e,n){return this.throwIfDisposed(),Q$(this,t,e,n)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.cumsum=function(t,e,n){return this.throwIfDisposed(),J$(this,t,e,n)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),tB(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.depthwiseConv2d=function(t,e,n,i,s,r){return this.throwIfDisposed(),eB(this,t,e,n,i,s,r)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.dilation2d=function(t,e,n,i,s){return this.throwIfDisposed(),iB(this,t,e,n,i,s)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.divNoNan=function(t){return this.throwIfDisposed(),aB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.div=function(t){return this.throwIfDisposed(),YL(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.dot=function(t){return this.throwIfDisposed(),oB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.elu=function(){return this.throwIfDisposed(),uB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.equal=function(t){return this.throwIfDisposed(),sB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.erf=function(){return this.throwIfDisposed(),pB(this)},
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.euclideanNorm=function(t,e){return this.throwIfDisposed(),SB(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.exp=function(){return this.throwIfDisposed(),xB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.expandDims=function(t){return this.throwIfDisposed(),RB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.expm1=function(){return this.throwIfDisposed(),OB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.fft=function(){return this.throwIfDisposed(),lU(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.flatten=function(){return this.throwIfDisposed(),y$(this,[this.size])},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.floor=function(){return this.throwIfDisposed(),CB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.floorDiv=function(t){return this.throwIfDisposed(),UL(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.gather=function(t,e,n){return this.throwIfDisposed(),NB(this,t,e,n)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.greaterEqual=function(t){return this.throwIfDisposed(),DB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.greater=function(t){return this.throwIfDisposed(),kB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.ifft=function(){return this.throwIfDisposed(),uU(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.irfft=function(){return this.throwIfDisposed(),hU(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.isFinite=function(){return this.throwIfDisposed(),LB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.isInf=function(){return this.throwIfDisposed(),FB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.isNaN=function(){return this.throwIfDisposed(),PB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.leakyRelu=function(t){return this.throwIfDisposed(),$B(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.lessEqual=function(t){return this.throwIfDisposed(),VB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.less=function(t){return this.throwIfDisposed(),BB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.localResponseNormalization=function(t,e,n,i){return this.throwIfDisposed(),YB(this,t,e,n,i)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.logSigmoid=function(){return this.throwIfDisposed(),zB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.logSoftmax=function(t){return this.throwIfDisposed(),XB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.logSumExp=function(t,e){return this.throwIfDisposed(),jB(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.log=function(){return this.throwIfDisposed(),GB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.log1p=function(){return this.throwIfDisposed(),HB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.logicalAnd=function(t){return this.throwIfDisposed(),qB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.logicalNot=function(){return this.throwIfDisposed(),KB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.logicalOr=function(t){return this.throwIfDisposed(),QB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.logicalXor=function(t){return this.throwIfDisposed(),JB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.matMul=function(t,e,n){return this.throwIfDisposed(),HF(this,t,e,n)},Rk().prototype.maxPool=function(t,e,n,i){return this.throwIfDisposed(),nV(this,t,e,n,i)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.max=function(t,e){return this.throwIfDisposed(),IB(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.maximum=function(t){return this.throwIfDisposed(),TF(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.mean=function(t,e){return this.throwIfDisposed(),rV(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.min=function(t,e){return this.throwIfDisposed(),EB(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.minimum=function(t){return this.throwIfDisposed(),uV(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.mirrorPad=function(t,e){return this.throwIfDisposed(),hV(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.mod=function(t){return this.throwIfDisposed(),pV(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.mul=function(t){return this.throwIfDisposed(),GL(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.neg=function(){return this.throwIfDisposed(),XF(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.norm=function(t,e,n){return this.throwIfDisposed(),wB(this,t,e,n)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.notEqual=function(t){return this.throwIfDisposed(),mV(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.oneHot=function(t,e=1,n=0){return this.throwIfDisposed(),WF(this,t,e,n)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.onesLike=function(){return this.throwIfDisposed(),gV(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.pad=function(t,e){return this.throwIfDisposed(),TV(this,t,e)},Rk().prototype.pool=function(t,e,n,i,s,r){return this.throwIfDisposed(),wV(this,t,e,n,i,s,r)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.pow=function(t){return this.throwIfDisposed(),pF(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.prelu=function(t){return this.throwIfDisposed(),SV(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.prod=function(t,e){return this.throwIfDisposed(),xV(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.reciprocal=function(){return this.throwIfDisposed(),UV(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.relu=function(){return this.throwIfDisposed(),YV(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.relu6=function(){return this.throwIfDisposed(),GV(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.reshapeAs=function(t){return this.throwIfDisposed(),y$(this,t.shape)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.reshape=function(t){return this.throwIfDisposed(),y$(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.resizeBilinear=function(t,e,n){return this.throwIfDisposed(),wY(this,t,e,n)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.resizeNearestNeighbor=function(t,e,n){return this.throwIfDisposed(),SY(this,t,e,n)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.reverse=function(t){return this.throwIfDisposed(),HV(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.rfft=function(){return this.throwIfDisposed(),cU(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.round=function(){return this.throwIfDisposed(),qV(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.rsqrt=function(){return this.throwIfDisposed(),KV(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.selu=function(){return this.throwIfDisposed(),QV(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.separableConv2d=function(t,e,n,i,s,r){return this.throwIfDisposed(),JV(this,t,e,n,i,s,r)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.sigmoid=function(){return this.throwIfDisposed(),v$(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.sign=function(){return this.throwIfDisposed(),tU(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.sin=function(){return this.throwIfDisposed(),eU(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.sinh=function(){return this.throwIfDisposed(),nU(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.slice=function(t,e){return this.throwIfDisposed(),w$(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.softmax=function(t){return this.throwIfDisposed(),oU(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.softplus=function(){return this.throwIfDisposed(),WB(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),vV(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.split=function(t,e){return this.throwIfDisposed(),pU(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.sqrt=function(){return this.throwIfDisposed(),HL(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.square=function(){return this.throwIfDisposed(),WL(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.squaredDifference=function(t){return this.throwIfDisposed(),dU(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.squeeze=function(t){return this.throwIfDisposed(),fU(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.stack=function(t,e){this.throwIfDisposed();const n=t instanceof xk?[this,t]:[this,...t];return mU(n,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.step=function(t){return this.throwIfDisposed(),gU(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.stridedSlice=function(t,e,n,i,s,r,a,o){return this.throwIfDisposed(),_U(this,t,e,n,i,s,r,a,o)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.sub=function(t){return this.throwIfDisposed(),cF(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.sum=function(t,e){return this.throwIfDisposed(),bB(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.tan=function(){return this.throwIfDisposed(),TU(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.tanh=function(){return this.throwIfDisposed(),S$(this)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.tile=function(t){return this.throwIfDisposed(),AB(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.toBool=function(){return this.throwIfDisposed(),PL(this,"bool")},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.toFloat=function(){return this.throwIfDisposed(),PL(this,"float32")},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.toInt=function(){return this.throwIfDisposed(),PL(this,"int32")},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.topk=function(t,e){return this.throwIfDisposed(),SU(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.transpose=function(t){return this.throwIfDisposed(),qF(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.unique=function(t){return this.throwIfDisposed(),RU(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),OU(this,t,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.unstack=function(t){return this.throwIfDisposed(),AU(this,t)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.where=function(t,e){return this.throwIfDisposed(),rB(t,this,e)},
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Rk().prototype.zerosLike=function(){return this.throwIfDisposed(),zL(this)};
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class RW extends Error{constructor(t){super(t),Object.setPrototypeOf(this,RW.prototype)}}class OW extends Error{constructor(t){super(t),Object.setPrototypeOf(this,OW.prototype)}}class AW extends Error{constructor(t){super(t),Object.setPrototypeOf(this,AW.prototype)}}class MW extends Error{constructor(t){super(t),Object.setPrototypeOf(this,MW.prototype)}}class CW extends Error{constructor(t){super(t),Object.setPrototypeOf(this,CW.prototype)}}Error;
/**
* @license
* Copyright 2022 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class NW{constructor(t){this.maxEntries=t||100,this.cache=new Map}get(t){let e;return this.cache.has(t)&&(e=this.cache.get(t),this.cache.delete(t),this.cache.set(t,e)),e}put(t,e){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.maxEntries){const t=this.cache.keys().next().value;this.cache.delete(t)}this.cache.set(t,e)}getMaxEntries(){return this.maxEntries}setMaxEntries(t){if(t<0)throw new Error(`The maxEntries of LRU caches must be at least 0, but got ${t}.`);if(this.maxEntries>t)for(let e=0;e<this.maxEntries-t;e++){const t=this.cache.keys().next().value;this.cache.delete(t)}this.maxEntries=t}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function kW(t,e){if(Array.isArray(t)){let n=[];for(let i=0;i<e;i++)n=n.concat(t);return n}{const n=new Array(e);return n.fill(t),n}}function DW(t,e){if(!t)throw new CW(e)}function LW(t,e){let n=0;for(const i of t)i===e&&n++;return n}function FW(t){return 1===t.length?t[0]:t}function PW(t){return Array.isArray(t)?t:[t]}function $W(t){const e=t.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return"_"!==e[0]?e:"private"+e}function BW(t){return t.length<=1||-1===t.indexOf("_")?t:t.replace(/[_]+(\w|$)/g,((t,e)=>e.toUpperCase()))}let VW={};function UW(t){if(null==t)return null;const e={};return e.className=t.getClassName(),e.config=t.getConfig(),e}function YW(t){if(null!=t&&"object"==typeof t)if(Array.isArray(t))t.forEach((t=>YW(t)));else{const e=Object.keys(t);for(const n of e){const e=t[n];null!=e&&"object"==typeof e&&(Array.isArray(e)||"ndarray"!==e.type||"number"!=typeof e.value?YW(e):t[n]=e.value)}}}function GW(t,e={},n={},i="object",s=!1){if("string"==typeof t){const s=t;let r;if(s in n)r=n[s];else if(s in VW)r=VW[s];else if(r=e[s],null==r)throw new AW(`Unknown ${i}: ${t}. This may be due to one of the following reasons:\n1. The ${i} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${i} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);return r}{const r=t;if(null==r.className||null==r.config)throw new AW(`${i}: Improper config format: ${JSON.stringify(r)}.\n'className' and 'config' must set.`);const a=r.className;let o,l;if(a in n?[o,l]=n[a]:a in VW?[o,l]=VW.className:a in e&&([o,l]=e[a]),null==o)throw new AW(`Unknown ${i}: ${a}. This may be due to one of the following reasons:\n1. The ${i} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${i} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);if(null!=l){const t={};for(const e of Object.keys(VW))t[e]=VW[e];for(const e of Object.keys(n))t[e]=n[e];r.config.customObjects=t;const e=Object.assign({},VW);for(const t of Object.keys(n))VW[t]=n[t];YW(r.config);const i=l(o,r.config,n,s);return VW=Object.assign({},e),i}{const t=Object.assign({},VW);for(const t of Object.keys(n))VW[t]=n[t];const e=new o(r.config);return VW=Object.assign({},t),e}}}function HW(t,e){return-1*function(t,e){return t<e?-1:t>e?1:0}(t,e)}function WW(t){if(null==t)return t;const e=[];for(const n of t)-1===e.indexOf(n)&&e.push(n);return e}function zW(t){if(null==t)throw new AW(`Invalid value in obj: ${JSON.stringify(t)}`);for(const e in t)if(t.hasOwnProperty(e))return!1;return!0}function XW(t,e,n){if(null!=n&&t.indexOf(n)<0)throw new AW(`${n} is not a valid ${e}. Valid values are ${t} or null/undefined.`)}function jW(t,e,n=0,i=1/0){return DW(n>=0),DW(i>=n),Array.isArray(t)&&t.length>=n&&t.length<=i&&t.every((t=>typeof t===e))}function qW(t,e){Array.isArray(t)?(_O(t.length>0,(()=>`${e} is unexpectedly an empty array.`)),t.forEach(((t,n)=>qW(t,`element ${n+1} of ${e}`)))):_O(Number.isInteger(t)&&t>0,(()=>`Expected ${e} to be a positive integer, but got ${KW(t)}.`))}function KW(t){return null===t?"null":Array.isArray(t)?"["+t.map((t=>KW(t))).join(",")+"]":"string"==typeof t?`"${t}"`:`${t}`}function QW(t){return"relu"===t?"relu":"linear"===t?"linear":"elu"===t?"elu":null}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
let JW=0;function ZW(){return JW++}const tz={};function ez(t=""){return t in tz||(tz[t]=0),tz[t]+=1,t+tz[t].toString()}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const nz=["channelsFirst","channelsLast"],iz=["nearest","bilinear"],sz=["valid","same","causal"],rz=["max","avg"],az=["sum","mul","concat","ave"],oz=new Map;function lz(t){XW(nz,"DataFormat",t)}function uz(t){XW(sz,"PaddingMode",t)}function hz(t){XW(rz,"PoolMode",t)}const pz=[],cz="/";function dz(t,e){pz.push(t);try{const t=e();return pz.pop(),t}catch(t){throw pz.pop(),t}}function fz(t){if(!_z(t))throw new Error("Not a valid tensor name: '"+t+"'");return(0===pz.length?"":pz.join(cz)+cz)+t}function mz(t){if(!_z(t))throw new Error("Not a valid tensor name: '"+t+"'");oz.has(t)||oz.set(t,0);const e=oz.get(t);if(oz.set(t,oz.get(t)+1),e>0){const n=`${t}_${e}`;return oz.set(n,1),n}return t}const gz=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function _z(t){return!!t.match(gz)}function Tz(t,e,n){null==e&&(e=0),null==n&&(n=t.length);let i=1;for(let s=e;s<n;++s)i*=t[s];return i}function yz(t){if(0===t.length)return Number.NaN;let e=Number.POSITIVE_INFINITY;for(let n=0;n<t.length;n++){const i=t[n];i<e&&(e=i)}return e}function Iz(t){if(0===t.length)return Number.NaN;let e=Number.NEGATIVE_INFINITY;for(let n=0;n<t.length;n++){const i=t[n];i>e&&(e=i)}return e}function Ez(t,e){if(e<t)throw new AW(`end (${e}) < begin (${t}) is forbidden.`);const n=[];for(let i=t;i<e;++i)n.push(i);return n}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
let bz;function vz(){return null==bz&&(bz=ND().epsilon()),bz}function wz(t,e){return PL(t,e)}function Sz(t,e=-1){const n=t.shape.slice();return e<0&&(e=n.length+e+1),n.splice(e,0,1),y$(t,n)}function xz(t,e,n){return ED((()=>{switch(t.rank){case 1:return iU(t,e,n);case 2:return sU(t,[e,0],[n,t.shape[1]]);case 3:return rU(t,[e,0,0],[n,t.shape[1],t.shape[2]]);case 4:return aU(t,[e,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3]]);case 5:return w$(t,[e,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4]]);case 6:return w$(t,[e,0,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4],t.shape[5]]);default:throw new AW(`sliceAlongFirstAxis() received an unsupported tensor rank: ${t.rank}`)}}))}function Rz(t,e,n){return ED((()=>{switch(t.rank){case 1:return iU(t,e,n);case 2:return sU(t,[0,e],[t.shape[0],n]);case 3:return rU(t,[0,0,e],[t.shape[0],t.shape[1],n]);case 4:return aU(t,[0,0,0,e],[t.shape[0],t.shape[1],t.shape[2],n]);default:throw new AW(`sliceAlongLastAxis() received an unsupported tensor rank: ${t.rank}`)}}))}function Oz(t,e,n,i){return ED((()=>{switch(t.rank){case 1:return iU(t,e,n);case 2:switch(i){case 1:return xz(t,e,n);case 2:return Rz(t,e,n);default:throw new AW(`The axis is not within the rank of the tensor ${i}`)}case 3:switch(i){case 1:return xz(t,e,n);case 2:return rU(t,[0,e,0],[t.shape[0],n,t.shape[2]]);case 3:return Rz(t,e,n);default:throw new AW(`The axis is not within the rank of the tensor ${i}`)}case 4:switch(i){case 1:return xz(t,e,n);case 2:return aU(t,[0,e,0,0],[t.shape[0],n,t.shape[2],t.shape[3]]);case 3:return aU(t,[0,0,e,0],[t.shape[0],t.shape[1],n,t.shape[3]]);case 4:return Rz(t,e,n);default:throw new AW(`The axis is not within the rank of the tensor ${i}`)}default:throw new AW(`sliceAlongLastAxis() received an unsupported tensor rank: ${t.rank}`)}}))}function Az(t,e=-1){let n;return e<0&&(n=t[0].rank,e=0!==n?n:0),e===t[0].rank&&(e=-1),b$(t,e)}function Mz(t,e){switch(t.rank){case 1:return $$([t,e]);case 2:return B$([t,e],0);case 3:return V$([t,e],0);case 4:return U$([t,e],0);default:throw new AW(`concatAlongFirstAxis() received an unsupported tensor rank: ${t.rank}`)}}function Cz(t,e){if(Array.isArray(e)||(e=[e]),t.rank!==e.length)throw new AW(`The length of input n (${e.length}) does not match the number of dimensions in input x (${t.rank})`);return AB(t,e)}function Nz(t,e=0,n=1,i,s){return FV(t,e,n,i,s)}function kz(t,e,n,i){if(t.rank<2||e.rank<2)throw new MW(`dot requires both inputs to be rank >= 2 but got x shape = ${t.shape} and y shape = ${e.shape}`);if(e.rank>=3){if(t.shape.slice(-1)[0]!==e.shape.slice(-2)[0])throw new MW(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${t.shape} and y shape = ${e.shape}`)}if(2===t.rank&&2===e.rank){return JU({a:t,b:e,transposeA:!1,transposeB:!1,bias:i?Fz(t.rank,i,"channelsLast"):null,activation:n})}{const s=t.shape.slice(),r=s.pop();t=y$(t,[-1,r]);const a=e.shape.slice(),o=a.pop(),l=a.pop(),u=[...a,o],h=Array.from({length:e.rank},((t,n)=>0===n?e.rank-2:n<=e.rank-2?n-1:n));e=y$(qF(e,h),[l,-1]);const p=[...s,...u];return y$(JU({a:t,b:e,transposeA:!1,transposeB:!1,bias:i?Fz(t.rank,i,"channelsLast"):null,activation:n}),p)}}function Dz(t,e,n){return ED((()=>(e=Array.isArray(e)?yU(e,"int32"):PL(e,"int32"),NB(t,e,n))))}function Lz(t){return GL(t,t)}function Fz(t,e,n){const i=e.shape;if(1!==e.rank&&e.rank!==t)throw new AW(`Unexpected bias dimensions: ${e.rank}; expected it to be 1 or ${t}`);if(5===t){if("channelsFirst"===n)return 1===i.length?y$(e,[1,i[0],1,1,1]):y$(e,[1,i[3],i[0],i[1],i[2]]);if("channelsLast"===n)return 1===i.length?y$(e,[1,1,1,1,i[0]]):y$(e,[1].concat(i))}else if(4===t){if("channelsFirst"===n)return 1===i.length?y$(e,[1,i[0],1,1]):y$(e,[1,i[2],i[0],i[1]]);if("channelsLast"===n)return 1===i.length?y$(e,[1,1,1,i[0]]):y$(e,[1].concat(i))}else if(3===t){if("channelsFirst"===n)return 1===i.length?y$(e,[1,i[0],1]):y$(e,[1,i[1],i[0]]);if("channelsLast"===n)return 1===i.length?y$(e,[1,1,i[0]]):y$(e,[1].concat(i))}else if(t<3)return e;throw new AW(`Unsupported input rank by biasAdd: ${e.rank}`)}function Pz(t,e,n){return ED((()=>(null==n&&(n="channelsLast"),lz(n),VL(t,Fz(t.rank,e,n)))))}function $z(t,e,n,i){return ED((()=>BU(t,e,n,i)))}function Bz(t,e,n=!1){return n?t():e()}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const Vz=["fanIn","fanOut","fanAvg"],Uz=["normal","uniform","truncatedNormal"];class Yz extends iF{fromConfigUsesCustomObjects(){return!1}getConfig(){return{}}}class Gz extends Yz{apply(t,e){return aV(t,e)}}Gz.className="Zeros",rF(Gz);class Hz extends Yz{apply(t,e){return oV(t,e)}}Hz.className="Ones",rF(Hz);class Wz extends Yz{constructor(t){if(super(),"object"!=typeof t)throw new AW(`Expected argument of type ConstantConfig but got ${t}`);if(void 0===t.value)throw new AW(`config must have value set but got ${t}`);this.value=t.value}apply(t,e){return ED((()=>GL(tF(this.value),oV(t,e))))}getConfig(){return{value:this.value}}}Wz.className="Constant",rF(Wz);class zz extends Yz{constructor(t){super(),this.DEFAULT_MINVAL=-.05,this.DEFAULT_MAXVAL=.05,this.minval=t.minval||this.DEFAULT_MINVAL,this.maxval=t.maxval||this.DEFAULT_MAXVAL,this.seed=t.seed}apply(t,e){return $V(t,this.minval,this.maxval,e,this.seed)}getConfig(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}}}zz.className="RandomUniform",rF(zz);class Xz extends Yz{constructor(t){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=t.mean||this.DEFAULT_MEAN,this.stddev=t.stddev||this.DEFAULT_STDDEV,this.seed=t.seed}apply(t,e){if("float32"!==(e=e||"float32")&&"int32"!==e)throw new MW(`randomNormal does not support dType ${e}.`);return Nz(t,this.mean,this.stddev,e,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}Xz.className="RandomNormal",rF(Xz);class jz extends Yz{constructor(t){super(),this.DEFAULT_MEAN=0,this.DEFAULT_STDDEV=.05,this.mean=t.mean||this.DEFAULT_MEAN,this.stddev=t.stddev||this.DEFAULT_STDDEV,this.seed=t.seed}apply(t,e){if("float32"!==(e=e||"float32")&&"int32"!==e)throw new MW(`truncatedNormal does not support dType ${e}.`);return xU(t,this.mean,this.stddev,e,this.seed)}getConfig(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}}}jz.className="TruncatedNormal",rF(jz);class qz extends Yz{constructor(t){super(),this.gain=null!=t.gain?t.gain:1}apply(t,e){return ED((()=>{if(2!==t.length||t[0]!==t[1])throw new AW("Identity matrix initializer can only be used for 2D square matrices.");return GL(this.gain,MB(t[0]))}))}getConfig(){return{gain:this.gain}}}qz.className="Identity",rF(qz);class Kz extends Yz{constructor(t){if(super(),t.scale<0)throw new AW(`scale must be a positive float. Got: ${t.scale}`);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
var e;this.scale=null==t.scale?1:t.scale,this.mode=null==t.mode?"fanIn":t.mode,e=this.mode,XW(Vz,"FanMode",e),this.distribution=null==t.distribution?"normal":t.distribution,function(t){XW(Uz,"Distribution",t)}(this.distribution),this.seed=t.seed}apply(t,e){const n=function(t,e="channelsLast"){let n,i;if(lz(e),2===t.length)n=t[0],i=t[1];else if(-1!==[3,4,5].indexOf(t.length)){if("channelsFirst"===e){const e=Tz(t,2);n=t[1]*e,i=t[0]*e}else if("channelsLast"===e){const e=Tz(t,0,t.length-2);n=t[t.length-2]*e,i=t[t.length-1]*e}}else{const e=Tz(t);n=Math.sqrt(e),i=Math.sqrt(e)}return[n,i]}(t),i=n[0],s=n[1];let r=this.scale;if("fanIn"===this.mode?r/=Math.max(1,i):"fanOut"===this.mode?r/=Math.max(1,s):r/=Math.max(1,(i+s)/2),"normal"===this.distribution){const n=Math.sqrt(r);if("float32"!==(e=e||"float32")&&"int32"!==e)throw new MW(`${this.getClassName()} does not support dType ${e}.`);return xU(t,0,n,e,this.seed)}{const n=Math.sqrt(3*r);return $V(t,-n,n,e,this.seed)}}getConfig(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}}}Kz.className="VarianceScaling",rF(Kz);class Qz extends Kz{constructor(t){super({scale:1,mode:"fanAvg",distribution:"uniform",seed:null==t?null:t.seed})}getClassName(){return Kz.className}}Qz.className="GlorotUniform",rF(Qz);class Jz extends Kz{constructor(t){super({scale:1,mode:"fanAvg",distribution:"normal",seed:null==t?null:t.seed})}getClassName(){return Kz.className}}Jz.className="GlorotNormal",rF(Jz);class Zz extends Kz{constructor(t){super({scale:2,mode:"fanIn",distribution:"normal",seed:null==t?null:t.seed})}getClassName(){return Kz.className}}Zz.className="HeNormal",rF(Zz);class tX extends Kz{constructor(t){super({scale:2,mode:"fanIn",distribution:"uniform",seed:null==t?null:t.seed})}getClassName(){return Kz.className}}tX.className="HeUniform",rF(tX);class eX extends Kz{constructor(t){super({scale:1,mode:"fanIn",distribution:"normal",seed:null==t?null:t.seed})}getClassName(){return Kz.className}}eX.className="LeCunNormal",rF(eX);class nX extends Kz{constructor(t){super({scale:1,mode:"fanIn",distribution:"uniform",seed:null==t?null:t.seed})}getClassName(){return Kz.className}}nX.className="LeCunUniform",rF(nX);class iX extends Yz{constructor(t){super(),this.DEFAULT_GAIN=1,this.ELEMENTS_WARN_SLOW=2e3,this.gain=null==t.gain?this.DEFAULT_GAIN:t.gain,this.seed=t.seed}apply(t,e){return ED((()=>{if(t.length<2)throw new MW("Shape must be at least 2D.");if("int32"!==e&&"float32"!==e&&void 0!==e)throw new TypeError(`Unsupported data type ${e}.`);const n=IO(t.slice(0,-1)),i=t[t.length-1],s=n*i;s>this.ELEMENTS_WARN_SLOW&&console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${s}) elements: Slowness may result.`);const r=Nz([Math.max(i,n),Math.min(i,n)],0,1,e,this.seed),a=ZY.qr(r,!1);let o=a[0];const l=a[1].flatten().stridedSlice([0],[Math.min(i,n)*Math.min(i,n)],[Math.min(i,n)+1]);return o=GL(o,l.sign()),n<i&&(o=o.transpose()),GL(tF(this.gain),o.reshape(t))}))}getConfig(){return{gain:this.gain,seed:this.seed}}}iX.className="Orthogonal",rF(iX);const sX={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function rX(t,e={}){return GW(t,sF.getMap().classNameMap,e,"initializer")}function aX(t){return UW(t)}function oX(t){if("string"==typeof t){const e=t in sX?sX[t]:t;if("GlorotNormal"===e)return new Jz;if("GlorotUniform"===e)return new Qz;if("HeNormal"===e)return new Zz;if("HeUniform"===e)return new tX;if("LeCunNormal"===e)return new eX;if("LeCunUniform"===e)return new nX;{const t={};return t.className=e,t.config={},rX(t)}}return t instanceof Yz?t:rX(t)}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function lX(t){return Array.isArray(t)&&Array.isArray(t[0])}function uX(t){return 0===t.length?[]:Array.isArray(t[0])?t:[t]}function hX(t){let e;if(Array.isArray(t)){if(1!==t.length)throw new AW(`Expected Tensor length to be 1; got ${t.length}`);e=t[0]}else e=t;return e}function pX(t){if(Array.isArray(t)&&Array.isArray(t[0])){if(1===t.length)return t[0];throw new AW(`Expected exactly 1 Shape; got ${t.length}`)}return t}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function cX(t){let e=0;for(const n of t)0===n.shape.length?e+=1:e+=n.shape.reduce(((t,e)=>t*e));return e}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const dX="Variable";class fX{constructor(t,e="float32",n=dX,i=!0,s=null){this.dtype=null==e?"float32":e,this.shape=t.shape,this.id=ZW(),n=null==n?dX:n,this.originalName=fz(n),this.name=mz(this.originalName),this.trainable_=i,this.constraint=s,this.val=CU(t,this.trainable_,this.name,this.dtype)}read(){return this.assertNotDisposed(),this.val}write(t){return this.assertNotDisposed(),function(t,e){if(t.shape.toString()!==e.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(t.shape)+" vs. "+JSON.stringify(e.shape))}(this.val,t),this.val.id!==t.id&&(this.val.assign(t),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this}dispose(){this.assertNotDisposed(),this.val.dispose()}assertNotDisposed(){if(this.val.isDisposed)throw new Error(`LayersVariable ${this.name} is already disposed.`)}get trainable(){return this.trainable_}set trainable(t){this.trainable_=t,this.val.trainable=t}}function mX(t){return t.map((t=>t.read()))}function gX(t){t.forEach((t=>{t[0].write(t[1])}))}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class _X{constructor(t){this.dtype=t.dtype,this.shape=t.shape,null!=t.shape?this.ndim=t.shape.length:this.ndim=t.ndim,this.maxNDim=t.maxNDim,this.minNDim=t.minNDim,this.axes=t.axes||{}}}class TX{constructor(t,e,n,i,s,r,a){this.dtype=t,this.shape=e,this.sourceLayer=n,this.inputs=i,this.callArgs=s,this.outputTensorIndex=a,this.id=ZW(),null!=r&&(this.originalName=fz(r),this.name=mz(this.originalName)),this.rank=e.length}}let yX=0;class IX{constructor(t,e){this.callArgs=e,this.id=yX++,this.outboundLayer=t.outboundLayer,this.inboundLayers=t.inboundLayers,this.nodeIndices=t.nodeIndices,this.tensorIndices=t.tensorIndices,this.inputTensors=t.inputTensors,this.outputTensors=t.outputTensors,this.inputMasks=t.inputMasks,this.outputMasks=t.outputMasks,this.inputShapes=t.inputShapes,this.outputShapes=t.outputShapes;for(const e of t.inboundLayers)null!=e&&e.outboundNodes.push(this);t.outboundLayer.inboundNodes.push(this)}getConfig(){const t=[];for(const e of this.inboundLayers)null!=e?t.push(e.name):t.push(null);return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:t,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}}}let EX=0;class bX extends iF{constructor(t={}){super(),this._callHook=null,this._addedWeightNames=[],this._stateful=!1,this.id=EX++,this.activityRegularizer=null,this.inputSpec=null,this.supportsMasking=!1,this._trainableWeights=[],this._nonTrainableWeights=[],this._losses=[],this._updates=[],this._built=!1,this.inboundNodes=[],this.outboundNodes=[];let e=t.name;if(!e){const t=this.getClassName();e=$W(t)+"_"+ez(t)}if(this.name=e,this.trainable_=null==t.trainable||t.trainable,null!=t.inputShape||null!=t.batchInputShape){let e;if(null!=t.batchInputShape)e=t.batchInputShape;else if(null!=t.inputShape){let n=null;null!=t.batchSize&&(n=t.batchSize),e=[n].concat(t.inputShape)}this.batchInputShape=e;let n=t.dtype;null==n&&(n=t.inputDType),null==n&&(n="float32"),this.dtype=n}null!=t.weights?this.initialWeights=t.weights:this.initialWeights=null,this._refCount=null,this.fastWeightInitDuringBuild=!1}static nodeKey(t,e){return t.name+"_ib-"+e.toString()}getNodeAtIndex(t,e){if(0===this.inboundNodes.length)throw new OW(`The layer has never been called and thus has no defined ${e}.`);if(this.inboundNodes.length<=t)throw new AW(`Asked to get ${e} at node ${t}, but the layer has only ${this.inboundNodes.length} inbound nodes.`);return this.inboundNodes[t]}getInputAt(t){return FW(this.getNodeAtIndex(t,"input").inputTensors)}getOutputAt(t){return FW(this.getNodeAtIndex(t,"output").outputTensors)}get input(){if(this.inboundNodes.length>1)throw new RW(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`);if(0===this.inboundNodes.length)throw new RW(`Layer ${this.name} is not connected, no input to return.`);return FW(this.getNodeAtIndex(0,"input").inputTensors)}get output(){if(0===this.inboundNodes.length)throw new RW(`Layer ${this.name} has no inbound nodes.`);if(this.inboundNodes.length>1)throw new RW(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`);return FW(this.getNodeAtIndex(0,"output").outputTensors)}get losses(){return this._losses}calculateLosses(){return this.losses.map((t=>t()))}get updates(){return this._updates}get built(){return this._built}set built(t){this._built=t}get trainable(){return this.trainable_}set trainable(t){this._trainableWeights.forEach((e=>e.trainable=t)),this.trainable_=t}get trainableWeights(){return this.trainable_?this._trainableWeights.filter((t=>t.trainable)):[]}set trainableWeights(t){this._trainableWeights=t}get nonTrainableWeights(){return this.trainable?this._trainableWeights.filter((t=>!t.trainable)).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)}set nonTrainableWeights(t){this._nonTrainableWeights=t}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}get stateful(){return this._stateful}resetStates(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")}assertInputCompatibility(t){const e=PW(t);if(null==this.inputSpec||0===this.inputSpec.length)return;const n=PW(this.inputSpec);if(e.length!==n.length)throw new AW(`Layer ${this.name} expects ${n.length} inputs, but it received ${e.length} input tensors. Input received: ${t}`);for(let t=0;t<e.length;t++){const i=e[t],s=n[t];if(null==s)continue;const r=i.rank;if(null!=s.ndim&&r!==s.ndim)throw new AW(`Input ${t} is incompatible with layer ${this.name}: expected ndim=${s.ndim}, found ndim=${r}`);if(null!=s.maxNDim&&r>s.maxNDim)throw new AW(`Input ${t} is incompatible with layer ${this.name}: expected max_ndim=${s.maxNDim}, found ndim=${r}`);if(null!=s.minNDim&&r<s.minNDim)throw new AW(`Input ${t} is incompatible with layer ${this.name}: expected min_ndim=${s.minNDim}, found ndim=${r}.`);if(null!=s.dtype&&i.dtype!==s.dtype)throw new AW(`Input ${t} is incompatible with layer ${this.name} : expected dtype=${s.dtype}, found dtype=${i.dtype}.`);if(s.axes){const e=i.shape;for(const n in s.axes){const i=Number(n),r=s.axes[n],a=i>=0?e[i]:e[e.length+i];if(null!=r&&-1===[r,null].indexOf(a))throw new AW(`Input ${t} is incompatible with layer ${this.name}: expected axis ${i} of input shape to have value ${r} but got shape ${e}.`)}}if(null!=s.shape)for(let e=0;e<s.shape.length;++e){const n=s.shape[e],r=i.shape[e];if(null!=n&&null!=r&&n!==r)throw new AW(`Input ${t} is incompatible with layer ${this.name}: expected shape=${s.shape}, found shape=${i.shape}.`)}}}call(t,e){return t}invokeCallHook(t,e){null!=this._callHook&&this._callHook(t,e)}setCallHook(t){this._callHook=t}clearCallHook(){this._callHook=null}apply(t,e){e=e||{},this.assertNotDisposed();const n=PW(t),i=function(t){let e=!0;for(const n of PW(t))if(!(n instanceof TX)){e=!1;break}return e}(t),s=function(t){let e=!0;for(const n of PW(t))if(n instanceof TX){e=!1;break}return e}(t);if(i===s)throw new AW("Arguments to apply() must be all SymbolicTensors or all Tensors");return dz(this.name,(()=>{if(!this.built){this.assertInputCompatibility(t);const e=[];for(const n of PW(t))e.push(n.shape);this.build(FW(e)),this.built=!0,this.initialWeights&&this.setWeights(this.initialWeights),null===this._refCount&&s&&(this._refCount=1)}if(this.assertInputCompatibility(t),s){let i=this.call(t,e);this.supportsMasking&&this.setMaskMetadata(t,i);const s=PW(i),r=[];for(let t of s)-1!==n.indexOf(t)&&(t=t.clone()),r.push(t);if(i=FW(r),null!=this.activityRegularizer)throw new MW("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return i}{const n=function(t){t=PW(t);const e=[];for(const n of t)e.push(n.shape);return FW(e)}(t),i=this.computeOutputShape(n);let s;const r="float32";if(this.warnOnIncompatibleInputShape(Array.isArray(t)?n[0]:n),s=null!=i&&i.length>0&&Array.isArray(i[0])?i.map(((n,i)=>new TX(r,n,this,PW(t),e,this.name,i))):new TX(r,i,this,PW(t),e,this.name),this.addInboundNode(t,s,null,null,n,i,e),this._refCount++,null!=this.activityRegularizer)throw new MW("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return s}}))}warnOnIncompatibleInputShape(t){if(null!=this.batchInputShape)if(t.length!==this.batchInputShape.length)console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(t)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`);else{let e=!1;this.batchInputShape.forEach(((n,i)=>{null!=n&&null!=t[i]&&t[i]!==n&&(e=!0)})),e&&console.warn(`The shape of the input tensor (${JSON.stringify(t)}) does not match the expectation of layer ${this.name}: ${JSON.stringify(this.batchInputShape)}`)}}get outputShape(){if(null==this.inboundNodes||0===this.inboundNodes.length)throw new RW(`The layer ${this.name} has never been called and thus has no defined output shape.`);const t=[];for(const e of this.inboundNodes){const n=JSON.stringify(e.outputShapes);-1===t.indexOf(n)&&t.push(n)}if(1===t.length){const t=this.inboundNodes[0].outputShapes;return Array.isArray(t)&&Array.isArray(t[0])&&1===t.length?t[0]:t}throw new RW(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`)}countParams(){if(!this.built)throw new OW(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`);return cX(this.weights)}build(t){this.built=!0}getWeights(t=!1){return mX(t?this.trainableWeights:this.weights)}setWeights(t){ED((()=>{const e=this.weights;if(e.length!==t.length)throw new AW(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${t.length}, but the layer was expecting ${e.length} weights. Provided weights: ${t}...`);if(0===e.length)return;const n=[],i=mX(e);for(let s=0;s<i.length;++s){const r=i[s],a=e[s],o=t[s];if(!vO(r.shape,o.shape))throw new AW(`Layer weight shape ${r.shape} not compatible with provided weight shape ${o.shape}`);n.push([a,o])}gX(n)}))}addWeight(t,e,n,i,s,r,a,o){if(-1!==this._addedWeightNames.indexOf(t))throw new AW(`Duplicate weight name ${t} for layer ${this.name}`);this._addedWeightNames.push(t),null==n&&(n="float32"),this.fastWeightInitDuringBuild&&(i=null!=o?o():oX("zeros"));const l=i.apply(e,n),u=new fX(l,n,t,r,a);return l.dispose(),null!=s&&this.addLoss((()=>s.apply(u.read()))),null==r&&(r=!0),r?this._trainableWeights.push(u):this._nonTrainableWeights.push(u),u}setFastWeightInitDuringBuild(t){this.fastWeightInitDuringBuild=t}addLoss(t){null==t||Array.isArray(t)&&0===t.length||(t=PW(t),void 0!==this._losses&&null!==this._losses&&this.losses.push(...t))}computeOutputShape(t){return t}computeMask(t,e){if(!this.supportsMasking){if(null!=e){if(!Array.isArray(e))throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`);e.forEach((t=>{if(null!=t)throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`)}))}return null}return e}setMaskMetadata(t,e,n){if(!this.supportsMasking)return;const i=this.computeMask(t,n),s=PW(e),r=PW(i);if(s.length!==r.length)throw new Error(`${this.name} outputs ${s.length} tensors but ${s.length} masks for those tensors`);for(let t=0;t<s.length;t++)s[t].kerasMask=r[t]}addInboundNode(t,e,n,i,s,r,a=null){const o=PW(t);e=PW(e),n=PW(n),i=PW(i),s=uX(s),r=uX(r);const l=[],u=[],h=[];for(const t of o)l.push(t.sourceLayer),u.push(t.nodeIndex),h.push(t.tensorIndex);new IX({outboundLayer:this,inboundLayers:l,nodeIndices:u,tensorIndices:h,inputTensors:o,outputTensors:e,inputMasks:n,outputMasks:i,inputShapes:s,outputShapes:r},a);for(let t=0;t<e.length;t++)e[t].sourceLayer=this,e[t].nodeIndex=this.inboundNodes.length-1,e[t].tensorIndex=t}getConfig(){const t={name:this.name,trainable:this.trainable};return null!=this.batchInputShape&&(t.batchInputShape=this.batchInputShape),null!=this.dtype&&(t.dtype=this.dtype),t}disposeWeights(){return this.weights.forEach((t=>t.dispose())),this.weights.length}assertNotDisposed(){if(0===this._refCount)throw new Error(`Layer '${this.name}' is already disposed.`)}dispose(){if(!this.built)throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`);if(null===this._refCount)throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`);this.assertNotDisposed();let t=0;return 0==--this._refCount&&(t=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:t}}}function vX(t,e,n){if((null==e||null!=n&&n>0)&&(e=t.sourceLayer,n=t.nodeIndex),0===e.inboundNodes.length)return[t];{const t=e.inboundNodes[n];if(0===t.inboundLayers.length)return t.inputTensors;{const e=[];for(let n=0;n<t.inboundLayers.length;n++){const i=vX(t.inputTensors[n],t.inboundLayers[n],t.nodeIndices[n]);for(const t of i)-1===e.indexOf(t)&&e.push(t)}return e}}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class wX extends bX{constructor(t){if(super({dtype:t.dtype,name:null!=t.name?t.name:ez("input").toString()}),null==t.batchSize&&(t.batchSize=null),null==t.sparse&&(t.sparse=!1),this.trainable=!1,this.built=!0,this.sparse=t.sparse,null!=t.inputShape&&null!=t.batchInputShape)throw new AW("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");let e=t.batchInputShape;if(null==e){if(null==t.inputShape)throw new AW("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");e=[t.batchSize].concat(t.inputShape)}else if(null!=t.batchSize)throw new AW("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");const n=t.dtype||"float32";this.batchInputShape=e,this.dtype=n,this.inputSpec=[{shape:e}];const i=new TX(this.dtype,this.batchInputShape,this,[],{},this.name);i.nodeIndex=0,i.tensorIndex=0,new IX({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[i],outputTensors:[i],inputMasks:[null],outputMasks:[null],inputShapes:[e],outputShapes:[e]})}apply(t,e){throw new AW(`Cannot pass any input to an InputLayer's apply() method. InputLayer name: ${this.name}`)}dispose(){return{refCountAfterDispose:this._refCount,numDisposedVariables:0}}getConfig(){return{batchInputShape:this.batchInputShape,dtype:this.dtype,sparse:this.sparse,name:this.name}}}function SX(t){if(null==t.batchShape&&null==t.shape)throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");if(null!=t.batchShape&&null!=t.shape)throw new AW("Please provide either a `shape` or `batchShape` argument to Input, but not both.");let e=t.batchShape;null!=t.shape&&null==e&&(e=[null].concat(t.shape));let n=t.dtype;null==n&&(n="float32");return new wX({batchInputShape:e,name:t.name,dtype:n,sparse:t.sparse}).inboundNodes[0].outputTensors[0]}wX.className="InputLayer",rF(wX);class xX{constructor(t){if(this.id2Value={},this.id2Mask={},this.name2Id={},t instanceof xX)for(const e in t.id2Value)this.id2Value[e]=t.id2Value[e],e in t.id2Mask&&(this.id2Mask[e]=t.id2Mask[e]);else{if(null==t)return;for(const e of t)this.add(e.key,e.value)}}add(t,e,n){if(null!=this.id2Value[t.id])throw new AW(`Duplicate key: name=${t.name}, id=${t.id}`);return this.id2Value[t.id]=
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function(t,e){if(null==t.dtype||t.dtype===e.dtype)return e;try{return PL(e,t.dtype)}catch(n){throw new AW(`The dtype of the feed (${e.dtype}) can not be cast to the dtype of the key '${t.name}' (${t.dtype}).`)}}(t,e),this.name2Id[t.name]=t.id,null!=n&&(this.id2Mask[t.id]=n),this}addFeed(t){this.add(t.key,t.value)}hasKey(t){return null!=this.id2Value[t.id]}names(){return Object.keys(this.name2Id)}getValue(t){if(t instanceof TX){if(null==this.id2Value[t.id])throw new AW(`Nonexistent key: ${t.name}`);return this.id2Value[t.id]}{const e=this.name2Id[t];if(null==e)throw new AW(`Feed dict has no SymbolicTensor name: ${t}`);return this.id2Value[e]}}getMask(t){if(t instanceof TX){if(null==this.id2Value[t.id])throw new AW(`Nonexistent key: ${t.name}`);return this.id2Mask[t.id]}{const e=this.name2Id[t];if(null==e)throw new AW(`Feed dict has no SymbolicTensor name: ${t}`);return this.id2Mask[e]}}disposeMasks(){null!=this.id2Mask&&bD(this.id2Mask)}}const RX=new NW,OX=new NW;function AX(t,e,n,i){const s=null!=n&&n.training,r=Array.isArray(t),a=r?t:[t],o=a.map((t=>t.name)),l=[],u=e.names();for(const t of o)-1!==u.indexOf(t)?l.push(e.getValue(t)):l.push(null);null!=i&&(i.maxNumTensors=-1/0,i.minNumTensors=1/0);const h=o.join(",")+"|"+e.names().sort().join(",");let p,c=RX.get(h);if(null==c){const t=function(t,e){_O(null!=t&&t.length>0,(()=>"Expected at least one fetch, got none"));let n=[],i={};if(1===t.length){const s=CX(t[0],e);n=s.sorted,i=s.recipientMap}else{const s=new Set;for(const r of t){const{sorted:t,recipientMap:a}=CX(r,e);for(const e of t)s.has(e.name)||(n.push(e),s.add(e.name));for(const t in a)null==i[t]&&(i[t]=new Set),a[t].forEach((e=>i[t].add(e)))}}return{sorted:n,recipientCounts:MX(i)}}(a,e);c=t.sorted,p=t.recipientCounts,RX.put(h,c),OX.put(h,p)}p={},s||Object.assign(p,OX.get(h));const d=new xX(e);for(let t=0;t<c.length;++t){if(null!=i){const t=yD().numTensors;t>i.maxNumTensors&&(i.maxNumTensors=t),t<i.minNumTensors&&(i.minNumTensors=t)}const r=c[t],a=r.sourceLayer;if(a instanceof wX)continue;const u=[],h=[],f=[];let m=!1;for(const t of r.inputs){const n=d.getValue(t),i=d.getMask(t);u.push(n),h.push(i),null!=i&&(m=!0),s||(p[t.name]--,0!==p[t.name]||e.hasKey(t)||-1!==o.indexOf(t.name)||n.isDisposed||!0===t.sourceLayer.stateful||f.push(n))}m&&((n=n||{}).mask=h[0]);const g=PW(a.apply(u,n));let _=null;a.supportsMasking&&(_=a.computeMask(u,h));const T=NX(r),y=Array.isArray(T)?T:[T];for(let t=0;t<y.length;++t){d.hasKey(y[t])||d.add(y[t],g[t],Array.isArray(_)?_[0]:_);const e=o.indexOf(y[t].name);-1!==e&&(l[e]=g[t])}s||bD(f)}return d.disposeMasks(),r?l:l[0]}function MX(t){const e={};for(const n in t)e[n]=t[n].size;return e}function CX(t,e){const n=new Set,i=[],s={};for(const t of e.names())n.add(t);const r=[],a=[];for(r.push(t);r.length>0;){const t=r[r.length-1];if(n.has(t.name)){r.pop();continue}const e=a[a.length-1]===r.length-1;if(0===t.inputs.length||e)r.pop(),i.push(t),n.add(t.name),e&&a.pop();else{a.push(r.length-1);for(const e of t.inputs)null==s[e.name]&&(s[e.name]=new Set),s[e.name].add(t.name),n.has(e.name)||r.push(e)}}return{sorted:i,recipientMap:s}}function NX(t){let e;if(1===t.sourceLayer.inboundNodes.length)e=t.sourceLayer.output;else{let n=null;for(let e=0;e<t.sourceLayer.inboundNodes.length;++e)for(const i of t.sourceLayer.inboundNodes[e].outputTensors)if(i.id===t.id){n=e;break}e=t.sourceLayer.getOutputAt(n)}return e}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function kX(t,e){return ED((()=>HL(bB(GL(t,t),e,!0))))}aA().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES",(()=>100),(function(t){null!=RX&&RX.setMaxEntries(t),null!=OX&&OX.setMaxEntries(t)}));class DX extends iF{getConfig(){return{}}}class LX extends DX{constructor(t){super(),this.defaultMaxValue=2,this.defaultAxis=0,this.maxValue=null!=t.maxValue?t.maxValue:this.defaultMaxValue,this.axis=null!=t.axis?t.axis:this.defaultAxis}apply(t){return ED((()=>{const e=kX(t,this.axis),n=P$(e,0,this.maxValue);return GL(t,YL(n,VL(vz(),e)))}))}getConfig(){return{maxValue:this.maxValue,axis:this.axis}}}LX.className="MaxNorm",rF(LX);class FX extends DX{constructor(t){super(),this.defaultAxis=0,this.axis=null!=t.axis?t.axis:this.defaultAxis}apply(t){return ED((()=>YL(t,VL(vz(),kX(t,this.axis)))))}getConfig(){return{axis:this.axis}}}FX.className="UnitNorm",rF(FX);class PX extends DX{apply(t){return YV(t)}}PX.className="NonNeg",rF(PX);class $X extends DX{constructor(t){super(),this.defaultMinValue=0,this.defaultMaxValue=1,this.defaultRate=1,this.defaultAxis=0,this.minValue=null!=t.minValue?t.minValue:this.defaultMinValue,this.maxValue=null!=t.maxValue?t.maxValue:this.defaultMaxValue,this.rate=null!=t.rate?t.rate:this.defaultRate,this.axis=null!=t.axis?t.axis:this.defaultAxis}apply(t){return ED((()=>{const e=kX(t,this.axis),n=VL(GL(this.rate,P$(e,this.minValue,this.maxValue)),GL(1-this.rate,e));return GL(t,YL(n,VL(vz(),e)))}))}getConfig(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}}}$X.className="MinMaxNorm",rF($X);const BX={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function VX(t){return UW(t)}function UX(t,e={}){return GW(t,sF.getMap().classNameMap,e,"constraint")}function YX(t){if(null==t)return null;if("string"==typeof t){return UX({className:t in BX?BX[t]:t,config:{}})}return t instanceof DX?t:UX(t)}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function GX(t){return new LX(t)}function HX(t){return new FX(t)}function WX(){return new PX}function zX(t){return new $X(t)}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function XX(){return new Gz}function jX(){return new Hz}function qX(t){return new Wz(t)}function KX(t){return new zz(t)}function QX(t){return new Xz(t)}function JX(t){return new jz(t)}function ZX(t){return new qz(t)}function tj(t){return new Kz(t)}function ej(t){return new Qz(t)}function nj(t){return new Jz(t)}function ij(t){return new Zz(t)}function sj(t){return new tX(t)}function rj(t){return new eX(t)}function aj(t){return new nX(t)}function oj(t){return new iX(t)}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
async function lj(t){if(null==t)return;const e=[],n=[],i=[];for(const s in t){const r=t[s];if("number"!=typeof r){const t=r;e.push(t.data()),n.push(s),i.push(t)}}if(e.length>0){const s=await Promise.all(e);for(let e=0;e<s.length;++e)t[n[e]]=s[e][0];bD(i)}}function uj(t){if(null!=t)for(const e in t){const n=t[e];"number"!=typeof n&&n.dispose()}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
var hj;!function(t){t[t.SILENT=0]="SILENT",t[t.VERBOSE=1]="VERBOSE"}(hj||(hj={}));class pj{constructor(){this.validationData=null}setParams(t){this.params=t}async onEpochBegin(t,e){}async onEpochEnd(t,e){}async onBatchBegin(t,e){}async onBatchEnd(t,e){}async onTrainBegin(t){}async onTrainEnd(t){}setModel(t){}}class cj{constructor(t,e=10){null==t&&(t=[]),this.callbacks=t,this.queueLength=e}append(t){this.callbacks.push(t)}setParams(t){for(const e of this.callbacks)e.setParams(t)}setModel(t){for(const e of this.callbacks)e.setModel(t)}async onEpochBegin(t,e){null==e&&(e={});for(const n of this.callbacks)await n.onEpochBegin(t,e)}async onEpochEnd(t,e){null==e&&(e={});for(const n of this.callbacks)await n.onEpochEnd(t,e)}async onBatchBegin(t,e){null==e&&(e={});for(const n of this.callbacks)await n.onBatchBegin(t,e)}async onBatchEnd(t,e){null==e&&(e={});for(const n of this.callbacks)await n.onBatchEnd(t,e)}async onTrainBegin(t){null==t&&(t={});for(const e of this.callbacks)await e.onTrainBegin(t)}async onTrainEnd(t){null==t&&(t={});for(const e of this.callbacks)await e.onTrainEnd(t)}}class dj extends pj{constructor(){super()}async onEpochBegin(t){this.seen=0,this.totals={}}async onBatchEnd(t,e){null==e&&(e={});const n=null==e.size?0:e.size;this.seen+=n;for(const t in e){const i=e[t];if("number"==typeof i)this.totals.hasOwnProperty(t)||(this.totals[t]=0),this.totals[t]=this.totals[t]+i*n;else{let e;t in this.totals?e=this.totals[t]:this.totals[t]=0;const s=ED((()=>VL(this.totals[t],GL(i,n))));this.totals[t]=s,null!=e&&e.dispose()}}}async onEpochEnd(t,e){if(null!=e)for(const t of this.params.metrics)null!=this.totals[t]&&("number"==typeof this.totals[t]?e[t]=this.totals[t]/this.seen:ED((()=>{const n=GL(YL(1,this.seen),this.totals[t]);e[t]=n,this.totals[t].dispose(),vD(e[t])})))}}class fj extends pj{async onTrainBegin(t){this.epoch=[],this.history={}}async onEpochEnd(t,e){null==e&&(e={}),this.epoch.push(t);for(const t in e)null==this.history[t]&&(this.history[t]=[]),this.history[t].push(e[t])}async syncData(){const t=[],e=[],n=[];for(const i in this.history){const s=this.history[i];for(let r=0;r<s.length;++r)if("number"!=typeof s[r]){const a=s[r];t.push(a.data()),e.push(i),n.push(r)}}const i=await Promise.all(t);for(let t=0;t<i.length;++t){this.history[e[t]][n[t]].dispose(),this.history[e[t]][n[t]]=i[t][0]}}}class mj extends pj{constructor(t,e){if(super(),this.currentEpoch=0,this.nowFunc=t.nowFunc,this.nextFrameFunc=t.nextFrameFunc||rG,this.yieldEvery=e||"auto","auto"===this.yieldEvery&&(this.yieldEvery=125),"never"===this.yieldEvery&&null!=t.onYield)throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");YO(this.yieldEvery)&&(this.maybeWait=function(t,e,n){let i,s=null!=n?n():rk();return(...r)=>{const a=null!=n?n():rk();return a-s<e||(s=a,i=t(...r)),i}}(this.maybeWait.bind(this),this.yieldEvery,this.nowFunc)),this.trainBegin=t.onTrainBegin,this.trainEnd=t.onTrainEnd,this.epochBegin=t.onEpochBegin,this.epochEnd=t.onEpochEnd,this.batchBegin=t.onBatchBegin,this.batchEnd=t.onBatchEnd,this.yield=t.onYield}async maybeWait(t,e,n){const i=[];null!=this.yield&&(await lj(n),i.push(this.yield(t,e,n))),i.push(this.nextFrameFunc()),await Promise.all(i)}async onEpochBegin(t,e){this.currentEpoch=t,null!=this.epochBegin&&(await lj(e),await this.epochBegin(t,e))}async onEpochEnd(t,e){const n=[];null!=this.epochEnd&&(await lj(e),n.push(this.epochEnd(t,e))),"epoch"===this.yieldEvery&&n.push(this.nextFrameFunc()),await Promise.all(n)}async onBatchBegin(t,e){null!=this.batchBegin&&(await lj(e),await this.batchBegin(t,e))}async onBatchEnd(t,e){const n=[];null!=this.batchEnd&&(await lj(e),n.push(this.batchEnd(t,e))),"batch"===this.yieldEvery?n.push(this.nextFrameFunc()):YO(this.yieldEvery)&&n.push(this.maybeWait(this.currentEpoch,t,e)),await Promise.all(n)}async onTrainBegin(t){null!=this.trainBegin&&(await lj(t),await this.trainBegin(t))}async onTrainEnd(t){null!=this.trainEnd&&(await lj(t),await this.trainEnd(t))}}function gj(t,e){if(null==t&&(t={}),t instanceof pj)return[t];if(Array.isArray(t)&&t[0]instanceof pj)return t;return PW(t).map((t=>new mj(t,e)))}class _j{constructor(){}static registerCallbackConstructor(t,e){_O(t>=0&&Number.isInteger(t),(()=>`Verbosity level is expected to be an integer >= 0, but got ${t}`)),_j.checkForDuplicate(e),null==_j.constructors[t]&&(_j.constructors[t]=[]),_j.constructors[t].push(e)}static checkForDuplicate(t){for(const e in _j.constructors){_j.constructors[+e].forEach((e=>{if(e===t)throw new AW("Duplicate callback constructor.")}))}}static clear(){_j.constructors={}}static createCallbacks(t){const e=[];for(const n in _j.constructors){const i=+n;t>=i&&e.push(..._j.constructors[i])}return e.map((t=>new t))}}function Tj(t,e,n,i,s,r,a,o,l){const u=new fj,h=[new dj,..._j.createCallbacks(e)];null!=t&&h.push(...t),h.push(u);const p=new cj(h);return p.setParams({epochs:n,initialEpoch:i,samples:s,steps:r,batchSize:a,verbose:e,doValidation:o,metrics:l}),{callbackList:p,history:u}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function yj(t,e={},n=!1){return GW(t,sF.getMap().classNameMap,e,"layer",n)}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Ij(t,e){return ED((()=>{"float32"!==t.dtype&&(t=PL(t,"float32"));const n=bB(Lz(t),e,!0),i=uF(n.shape,vz()),s=HL(TF(n,i));return YL(t,s)}))}function Ej(t,e){return ED((()=>rV(Lz(cF(e,t)),-1)))}function bj(t,e){return ED((()=>rV(fF(cF(e,t)),-1)))}function vj(t,e){return ED((()=>{const n=cF(t,e),i=P$(fF(t),vz(),Number.MAX_VALUE),s=fF(YL(n,i));return GL(100,rV(s,-1))}))}function wj(t,e){return ED((()=>{const n=P$(e,vz(),Number.MAX_VALUE),i=GB(VL(1,n)),s=P$(t,vz(),Number.MAX_VALUE),r=GB(VL(1,s));return rV(Lz(cF(i,r)),-1)}))}function Sj(t,e,n=!1){return ED((()=>{if(n)e=oU(e);else{const t=bB(e,e.shape.length-1,!0);e=YL(e,t)}return e=P$(e,vz(),1-vz()),XF(bB(GL(PL(t,"float32"),GB(e)),e.shape.length-1))}))}function xj(t,e,n=!1){return ED((()=>{const i=PL(CB(function(t){const e=[Tz(t.shape)];return y$(t,e)}(t)),"int32"),s=(e=P$(e,vz(),1-vz())).shape;return Sj(y$(WF(i,s[s.length-1]),s),e,n)}))}function Rj(t,e){return ED((()=>{let n;return n=P$(e,vz(),1-vz()),n=GB(YL(n,cF(1,n))),rV(function(t,e){if(!vO(t.shape,e.shape))throw new AW(`logits and labels must have the same shape, but got shapes ${JSON.stringify(t.shape)} and ${JSON.stringify(e.shape)}`);return ED((()=>{const n=YV(e),i=XF(fF(e));return VL(cF(n,GL(e,t)),HB(xB(i)))}))}(t,n),-1)}))}function Oj(t,e){return ED((()=>{const n=P$(t,vz(),1),i=P$(e,vz(),1);return bB(GL(t,GB(YL(n,i))),-1)}))}function Aj(t,e){return ED((()=>{const n=Ij(t,-1),i=Ij(e,-1),s=GL(n,i);return XF(bB(s,-1))}))}_j.constructors={};const Mj={meanSquaredError:Ej,meanAbsoluteError:bj,meanAbsolutePercentageError:vj,meanSquaredLogarithmicError:wj,squaredHinge:function(t,e){return ED((()=>{const n=TF(0,cF(1,GL(t,e)));return rV(Lz(n),-1)}))},hinge:function(t,e){return ED((()=>{const n=TF(0,cF(1,GL(t,e)));return rV(n,-1)}))},categoricalHinge:function(t,e){return ED((()=>{const n=bB(GL(t,e),-1),i=IB(GL(cF(1,t),e),-1);return TF(0,VL(1,cF(i,n)))}))},logcosh:function(t,e){return ED((()=>{const n=Math.log(2),i=cF(e,t),s=cF(VL(i,WB(GL(-2,i))),n);return rV(s,-1)}))},categoricalCrossentropy:Sj,sparseCategoricalCrossentropy:xj,binaryCrossentropy:Rj,kullbackLeiblerDivergence:Oj,poisson:function(t,e){return ED((()=>{const n=GB(VL(vz(),e));return rV(cF(e,GL(t,n)),-1)}))},cosineProximity:Aj};function Cj(t){if("string"==typeof t){if(t in Mj)return Mj[t];let e=`Unknown loss ${t}`;throw t.toLowerCase().includes("softmaxcrossentropy")&&(e=`Unknown loss ${t}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`),new AW(e)}return t}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Nj(t,e){return ED((()=>{const n=GL(.5,gV(e)),i=wz(kB(e,n),t.dtype);return rV(sB(t,i),-1)}))}function kj(t,e){return ED((()=>wz(sB(QP(t,-1),QP(e,-1)),"float32")))}function Dj(t,e){return ED((()=>PL(bB(qB(sB(t,1),sB(e,1))),"float32")))}function Lj(t,e){return ED((()=>{const n=Dj(t,e),i=function(t,e){return ED((()=>PL(bB(qB(sB(t,0),sB(e,1))),"float32")))}(t,e),s=VL(n,i);return PL(rB(kB(s,0),YL(n,s),0),"float32")}))}function Fj(t,e){return ED((()=>{const n=Dj(t,e),i=function(t,e){return ED((()=>PL(bB(qB(sB(t,1),sB(e,0))),"float32")))}(t,e),s=VL(n,i);return PL(rB(kB(s,0),YL(n,s),0),"float32")}))}function Pj(t,e){return Rj(t,e)}function $j(t,e){return t.rank===e.rank&&(t=fU(t,[t.rank-1])),(e=QP(e,-1)).dtype!==t.dtype&&(e=PL(e,t.dtype)),PL(sB(t,e),"float32")}const Bj=Sj,Vj=xj,Uj={binaryAccuracy:Nj,categoricalAccuracy:kj,precision:Lj,categoricalCrossentropy:Bj,sparseCategoricalCrossentropy:Vj,mse:Ej,MSE:Ej,mae:bj,MAE:bj,mape:vj,MAPE:vj,cosine:Aj};function Yj(t){if("string"==typeof t&&t in Uj)return Uj[t];if("string"!=typeof t&&null!=t)return t;throw new AW(`Unknown metric ${t}`)}function Gj(t){if(DW(null!==t,`Unknown LossOrMetricFn ${t}`),"string"==typeof t)return t;{let e;for(const n of Object.keys(Mj))if(Mj[n]===t){e=n;break}if(void 0!==e)return e;for(const n of Object.keys(Uj))if(Uj[n]===t){e=n;break}return void 0!==e?e:t.name}}
/**
* @license
* Copyright 2019 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const Hj=1048576;function Wj(t,e,n=!1){if(null==t||"object"!=typeof t||Object.getPrototypeOf(t)!==Object.prototype||!zj(t))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){const n=JSON.stringify(t);n.length>Hj&&console.warn(`User-defined metadata of model "${e}" is too large in size (length=${n.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= 1048576.`)}}function zj(t){if(null===t)return!0;if("object"==typeof t){if(Object.getPrototypeOf(t)===Object.prototype){const e=Object.keys(t);for(const n of e){if("string"!=typeof n)return!1;if(!zj(t[n]))return!1}return!0}if(Array.isArray(t)){for(const e of t)if(!zj(e))return!1;return!0}return!1}{const e=typeof t;return"string"===e||"number"===e||"boolean"===e}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Xj(t,e,n,i=console.log){const s=function(t){let e=!0;const n=[],i=[];for(const e in t.nodesByDepth)n.push(t.nodesByDepth[e]);for(const t of n){if(t.length>1||1===t.length&&t[0].inboundLayers.length>1){e=!1;break}i.push(...t)}if(e)for(const n of t.layers){let t=!1;for(const s of n.inboundNodes)if(-1!==i.indexOf(s)){if(t){e=!1;break}t=!0}if(!e)break}return e}(t),r=["Layer (type)","Input Shape","Output shape","Param #"];let a;if(s?(e=e||90,n=n||[.32,.61,.89,1]):(e=e||115,n=n||[.24,.48,.7,.8,1]),n[n.length-1]<=1&&(n=n.map((t=>Math.floor(e*t)))),!s){r.push("Receives inputs"),a=[];for(const e in t.nodesByDepth)a.push(...t.nodesByDepth[e])}i("_".repeat(e)),jj(r,n,i),i("=".repeat(e));const o=t.layers;for(let t=0;t<o.length;++t)s?qj(o[t],n,i):Kj(o[t],n,a,i),i((t===o.length-1?"=":"_").repeat(e));t.checkTrainableWeightsConsistency();const l=function(t){let e;e=null!=t.collectedTrainableWeights?cX(t.collectedTrainableWeights):cX(t.trainableWeights);return e}(t),u=cX(t.nonTrainableWeights);i(`Total params: ${l+u}`),i(`Trainable params: ${l}`),i(`Non-trainable params: ${u}`),i("_".repeat(e))}function jj(t,e,n=console.log){let i="";for(let n=0;n<t.length;++n)n>0&&(i=i.slice(0,i.length-1)+" "),i+=t[n],i=i.slice(0,e[n]),i+=" ".repeat(e[n]-i.length);n(i)}function qj(t,e,n){let i,s;try{s=t.inboundNodes.map((t=>JSON.stringify(t.inputShapes))).join(",")}catch(t){s="multiple"}try{i=JSON.stringify(t.outputShape)}catch(t){i="multiple"}jj([`${t.name} (${t.getClassName()})`,s,i,t.countParams().toString()],e,n)}function Kj(t,e,n,i){let s,r;try{r=t.inboundNodes.map((t=>JSON.stringify(t.inputShapes))).join(",")}catch(t){r="multiple"}try{s=JSON.stringify(t.outputShape)}catch(t){s="multiple"}const a=[];for(const e of t.inboundNodes)if(!(null!=n&&n.length>0&&-1===n.indexOf(e)))for(let t=0;t<e.inboundLayers.length;++t){const n=e.inboundLayers[t].name,i=e.nodeIndices[t],s=e.tensorIndices[t];a.push(`${n}[${i}][${s}]`)}const o=t.name,l=t.getClassName(),u=0===a.length?"":a[0];jj([`${o} (${l})`,r,s,t.countParams().toString(),u],e,i);for(let t=1;t<a.length;++t)jj(["","","","",a[t]],e,i)}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Qj(t,e,n){return("inboundNodes"===t||"outputLayers"===t||"inputLayers"===t)&&0===e&&"string"==typeof n}function Jj(t,e){if(null===t)return null;if("string"==typeof t)return BW(t);if("number"==typeof t||"boolean"==typeof t)return t;if(t instanceof Array){const n=[],i=t.length;for(let s=0;s<i;++s){const i=t[s];Qj(e,s,i)?n.push(i):n.push(Jj(i,e))}return n}{const e={};for(const n of Object.keys(t)){const i=t[n];if("name"===n&&"string"==typeof i)e[n]=i;else{const t=BW(n);e[t]=Jj(i,t)}}return e}}function Zj(t,e){if(null==t)return null;if("string"==typeof t)return $W(t);if("number"==typeof t||"boolean"==typeof t)return t;if(t instanceof Array){const n=[],i=t.length;for(let s=0;s<i;++s){const i=t[s];Qj(e,s,i)?n.push(i):n.push(Zj(i,e))}return n}{const e={};for(const n of Object.keys(t)){const i=t[n],s=$W(n);e[s]="name"!==n&&"className"!==n||"string"!=typeof i?Zj(i,n):i}return e}}
/** @license See the LICENSE file. */
const tq="4.22.0";class eq extends bX{constructor(t){if(super({}),this.containerNodes=new Set,this.name=t.name,null==this.name){const t=this.getClassName().toLowerCase();this.name=ez(t)}if(this.supportsMasking=!1,this.trainable_=!0,Array.isArray(t.inputs)?this.inputs=t.inputs.slice():this.inputs=[t.inputs],Array.isArray(t.outputs)?this.outputs=t.outputs.slice():this.outputs=[t.outputs],WW(this.inputs).length!==this.inputs.length)throw new AW(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map((t=>t.name))}`);WW(this.outputs).length!==this.outputs.length&&console.warn(`The list of outputs passed to the model is redundant. All outputs should only appear once. Found: ${this.outputs.map((t=>t.name))}`),this.inputLayers=[],this.inputLayersNodeIndices=[],this.inputLayersTensorIndices=[],this.outputLayers=[],this.outputLayersNodeIndices=[],this.outputLayersTensorIndices=[],this.layers=[],this.internalContainerRefs=[];for(const t of this.outputs){const e=t.sourceLayer,n=t.nodeIndex,i=t.tensorIndex;this.outputLayers.push(e),this.outputLayersNodeIndices.push(n),this.outputLayersTensorIndices.push(i)}for(const t of this.inputs){const e=t.sourceLayer,n=t.nodeIndex,i=t.tensorIndex;DW(0===n,"input layer has >1 nodes"),DW(0===i,"input layer has >1 tensors"),this.inputLayers.push(e),this.inputLayersNodeIndices.push(n),this.inputLayersTensorIndices.push(i)}this.inputNames=[],this.outputNames=[],this.feedInputShapes=[],this.feedInputNames=[],this.feedOutputNames=[];for(let e=0;e<this.inputLayers.length;e++){const n=this.inputLayers[e];if(!(n instanceof wX))throw new TypeError(`Input layers to a LayersModel must be InputLayer objects. Received inputs: ${t.inputs}. Input ${e} (0-based) originates from layer type ${n.getClassName()}.`);this.inputNames.push(n.name),this.feedInputShapes.push(n.batchInputShape),this.feedInputNames.push(n.name)}for(const t of this.outputLayers)this.outputNames.push(t.name);this.internalInputShapes=this.inputs.map((t=>t.shape)),this.internalOutputShapes=this.outputs.map((t=>t.shape));const e={},n={},i={},s={},r={},a=[],o=(t,e,n,i,s,l)=>{null!=i&&null!=s&&null!=l||(i=t.sourceLayer,s=t.nodeIndex,l=t.tensorIndex);const u=i.inboundNodes[s];if(-1!==n.indexOf(u))throw new OW(`The tensor ${t.name} at layer "${i.name}" is part of a cycle.`);if(-1!==e.indexOf(u))return;this.containerNodes.add(eq.nodeKey(i,s)),i.id in r||(r[i.id]=Object.keys(r).length),-1===n.indexOf(u)&&n.push(u);const h=u.inboundLayers.length;for(let t=0;t<h;t++){const i=u.inputTensors[t],s=u.inboundLayers[t],r=u.nodeIndices[t],a=u.tensorIndices[t];o(i,e,n,s,r,a)}for(e.push(u);n.indexOf(u)>=0;)n.splice(n.indexOf(u),1);a.push(u)},l=[],u=[];for(const t of this.outputs)o(t,l,u);const h=a.slice().reverse();for(const t of h){n[t.id]=t,t.id in e||(e[t.id]=0);let r=e[t.id];const a=null==i[t.outboundLayer.id]?0:i[t.outboundLayer.id];r=Math.max(r,a),i[t.outboundLayer.id]=r,s[t.outboundLayer.id]=t.outboundLayer,e[t.id]=r;for(let i=0;i<t.inboundLayers.length;i++){const s=t.inboundLayers[i],a=t.nodeIndices[i],o=s.inboundNodes[a],l=null==e[o.id]?0:e[o.id];e[o.id]=Math.max(r+1,l),n[o.id]=o}}const p={};for(const t in e){const i=e[t];i in p||(p[i]=[]),p[i].push(n[t])}const c={};for(const t in i){const e=i[t];e in c||(c[e]=[]),c[e].push(s[t])}let d=Object.keys(c).map((t=>parseInt(t,10))).sort(HW);this.layers=[];for(const t of d){const e=c[t];e.sort(((t,e)=>{const n=r[t.id],i=r[e.id];return n<i?-1:n>i?1:0}));for(const t of e)t instanceof eq&&this.internalContainerRefs.push(t),this.layers.push(t)}this.layersByDepth=c,d=Object.keys(p).map((t=>parseInt(t,10))).sort(HW);const f=this.inputs.slice(),m=[];for(const t of d)for(const e of p[t]){const t=e.outboundLayer;if(null!=t){for(const n of e.inputTensors)if(-1===f.indexOf(n))throw new OW(`Graph disconnected: cannot obtain value for tensor ${n} at layer "${t.name}". The following previous layers were accessed without issue: ${m}`);for(const t of e.outputTensors)f.push(t);m.push(t.name)}}this.nodesByDepth=p;const g=this.layers.map((t=>t.name));for(const t of g){const e=g.filter((e=>e===t)).length;if(1!==e)throw new OW(`The name "${t}" is used ${e} times in the model. All layer names should be unique. Layer names: `+JSON.stringify(g))}this.outboundNodes=[],this.inboundNodes=[],new IX({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:this.inputs.map((t=>null)),outputMasks:this.outputs.map((t=>null)),inputShapes:this.inputs.map((t=>t.shape)),outputShapes:this.outputs.map((t=>t.shape))}),this.built=!0,this._refCount=1}assertNotDisposed(){if(0===this._refCount)throw new Error(`Container '${this.name}' is already disposed.`)}dispose(){this.assertNotDisposed();const t={refCountAfterDispose:null,numDisposedVariables:0};if(0==--this._refCount){for(const e of this.layers)t.numDisposedVariables+=e.dispose().numDisposedVariables;for(const e of this.internalContainerRefs)t.numDisposedVariables+=e.dispose().numDisposedVariables}return t.refCountAfterDispose=this._refCount,t}get trainable(){return this.trainable_}set trainable(t){this.layers.forEach((e=>{e._trainableWeights.forEach((e=>e.trainable=t))})),this.trainable_=t}get trainableWeights(){if(this._trainableWeights.length>0)throw new AW("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];let t=[];for(const e of this.layers)t=t.concat(e.trainableWeights);return t}get nonTrainableWeights(){const t=[];for(const e of this.layers)t.push(...e.nonTrainableWeights);if(!this.trainable){const e=[];for(const t of this.layers)e.push(...t.trainableWeights);return e.concat(t)}return t}get weights(){return this.trainableWeights.concat(this.nonTrainableWeights)}loadWeights(t,e=!0){const n={};let i=0;const s=(t=>{const e=Object.keys(t);if(0===e.length)return!1;const n=e[0].split("/");return!isNaN(parseInt(n[n.length-1],10))})(t);s&&this.parseWeights(t);for(const t of this.layers)for(const[e,r]of t.weights.entries()){const t=s?`${r.name.split("/").slice(0,-1).join("/")+"/"}${e}`:r.originalName;if(null!=n[t])throw new AW(`Duplicate weight name: ${t}`);n[t]=r,i++}const r=[];for(const i in t){let s=i;if(null==n[i]){const t=i.split("/");s=t.slice(0,-2).concat([t[t.length-1]]).join("/")}if(null!=n[s])r.push([n[s],t[i]]);else if(e)throw new AW(`Provided weight data has no target variable: ${i}`);delete n[s]}if(e){const t=[];for(const e in n)t.push(e);if(t.length>0)throw new AW(`${t.length} of ${i} weights are not set: ${t}`)}gX(r)}parseWeights(t){for(const e in Object.keys(t)){const n=e.split("/"),i=["vars","layer_checkpoint_dependencies"],s=n.map((t=>t.startsWith("_")?t.slice(1):t)).filter((t=>!i.includes(t))).join("/");s!==e&&(t[s]=t[e],delete t[e])}}updatedConfig(){const t=this.getConfig(),e={};return e.className=this.getClassName(),e.config=t,e.kerasVersion=`tfjs-layers ${tq}`,e.backend="TensorFlow.js",e}toJSON(t,e=!0){const n=Zj(this.updatedConfig());return e?JSON.stringify(n):n}call(t,e){return ED((()=>{t=PW(t);const n=new xX;for(let e=0;e<this.inputs.length;++e)n.add(this.inputs[e],t[e]);return AX(this.outputs,n,e)}))}computeMask(t,e){return ED((()=>{let n;return t=PW(t),n=null==e?kW(null,t.length):PW(e),this.runInternalGraph(t,n)[1]}))}computeOutputShape(t){const e=uX(t);if(e.length!==this.inputLayers.length)throw new AW(`Invalid inputShape argument ${t}: model has ${this.inputLayers.length} tensor inputs.`);const n={};for(let t=0;t<e.length;t++){const i=this.inputLayers[t],s=e[t];n[i.name+"_0_0"]=s}const i=Object.keys(this.nodesByDepth).map((t=>parseInt(t,10))).sort(HW);if(i.length>1)for(const t of i){const e=this.nodesByDepth[t];for(const t of e){const e=t.outboundLayer;if(-1!==this.inputLayers.map((t=>t.id)).indexOf(e.id))continue;const i=[];for(let e=0;e<t.inboundLayers.length;e++){const s=t.inboundLayers[e],r=t.nodeIndices[e],a=t.tensorIndices[e],o=n[`${s.name}_${r}_${a}`];i.push(o)}const s=uX(e.computeOutputShape(FW(i))),r=e.inboundNodes.indexOf(t);for(let t=0;t<s.length;t++){n[`${e.name}_${r}_${t}`]=s[t]}}}const s=[],r=[];for(let t=0;t<this.outputLayers.length;t++){const e=this.outputLayers[t],n=this.outputLayersNodeIndices[t],i=this.outputLayersTensorIndices[t],s=`${e.name}_${n}_${i}`;r.push(s)}for(let t=0;t<r.length;t++){const e=r[t];DW(e in n),s.push(n[e])}return FW(s)}runInternalGraph(t,e){null==e&&(e=kW(null,t.length));const n={};for(let i=0;i<this.inputs.length;++i){const s=this.inputs[i],r=t[i],a=e[i];n[s.id]=[r,a]}const i=Object.keys(this.nodesByDepth).map((t=>parseInt(t,10))).sort(HW);for(const t of i){const e=this.nodesByDepth[t];for(const t of e){const e=t.outboundLayer,i=t.inputTensors,s=t.outputTensors,r=new Array;for(const t of i)t.id in n&&r.push(n[t.id]);if(r.length===i.length){let i,a,o,l,u={};if(null!=t.callArgs&&(u=t.callArgs),1===r.length){const[t,n]=r[0];null==u.mask&&(u.mask=n),o=PW(e.call(t,u)),l=PW(e.computeMask(t,n)),i=[t],a=[n]}else i=r.map((t=>t[0])),a=r.map((t=>t[1])),null==u.mask&&(u.mask=a),o=PW(e.call(i,u)),l=PW(e.computeMask(i,a));if(e.activityRegularizer)throw new MW("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(let t=0;t<s.length;++t){const e=s[t],i=o[t],r=l[t];n[e.id]=[i,r]}}}}const s=[],r=[],a=[];for(const t of this.outputs){DW(t.id in n,`Could not compute output ${t.name} : ${t.id}`);const[e,i]=n[t.id];a.push(e.shape),s.push(e),r.push(i)}return[s,r,a]}buildNodeConversionMap(t){const e={};let n;for(const t of this.layers){n=t instanceof eq?1:0;for(let i=0;i<t.inboundNodes.length;i++){const s=eq.nodeKey(t,i);this.containerNodes.has(s)&&(e[s]=n,n+=1)}}return e}getLayer(t,e){if(null!=e)return this.findLayer(e);if(null==t)throw new AW("Provide either a layer name or layer index");if("number"==typeof t)return this.findLayer(t);for(const e of this.layers)if(e.name===t)return e;throw new AW(`No such layer: ${t}`)}findLayer(t){if(this.layers.length<=t)throw new AW(`Was asked to retrieve layer at index ${t}, but model only has ${this.layers.length} layer(s).`);return this.layers[t]}calculateLosses(){return ED((()=>{const t=[];for(const e of this.layers)for(let n=0;n<e.inboundNodes.length;++n){const i=eq.nodeKey(e,n);this.containerNodes.has(i)&&t.push(...e.calculateLosses())}return t}))}getConfig(){const t={name:this.name},e=this.buildNodeConversionMap(this.layers),n=[];for(const t of this.layers){const i=t.getClassName(),s=t.getConfig(),r=[];for(let n=0;n<t.inboundNodes.length;n++){const i=t.inboundNodes[n],s=eq.nodeKey(t,n);let a={};if(this.containerNodes.has(s)){if(i.callArgs)try{JSON.stringify(i.callArgs),a=i.callArgs}catch(e){console.warn(`Layer ${t.name} was passed non-serializable keyword arguments: ${i.callArgs}. They will not be included in the serialized model (and thus will be missing at deserialization time).`),a={}}if(i.inboundLayers.length>0){const t=[];for(let n=0;n<i.inboundLayers.length;n++){const s=i.inboundLayers[n],r=i.nodeIndices[n],o=i.tensorIndices[n];let l=e[eq.nodeKey(s,r)];null==l&&(l=0),t.push([s.name,l,o,a])}r.push(t)}}}const a={};a.name=t.name,a.className=i,a.config=s,a.inboundNodes=r,n.push(a)}t.layers=n;const i=[];for(let t=0;t<this.inputLayers.length;t++){const n=this.inputLayers[t],s=this.inputLayersNodeIndices[t],r=eq.nodeKey(n,s);if(!this.containerNodes.has(r))continue;let a=e[r];null==a&&(a=0);const o=this.inputLayersTensorIndices[t];i.push([n.name,a,o])}t.inputLayers=i;const s=[];for(let t=0;t<this.outputLayers.length;t++){const n=this.outputLayers[t],i=this.outputLayersNodeIndices[t],r=eq.nodeKey(n,i);if(!this.containerNodes.has(r))continue;let a=e[r];null==a&&(a=0);const o=this.outputLayersTensorIndices[t];s.push([n.name,a,o])}return t.outputLayers=s,t}static fromConfig(t,e,n={},i=!1){const s={},r={};function a(t,e){t.name in r?r[t.name].push(e):r[t.name]=[e]}function o(t,e){const n=[];let i;for(const r of e){const o=r[0],l=r[1],u=r[2];if(i=null==r[3]?{}:r[3],!(o in s))return void a(t,e);const h=s[o];if(h.inboundNodes.length<=l)return void a(t,e);const p=h.inboundNodes[l];n.push(p.outputTensors[u])}n.length>0&&t.apply(FW(n),i)}function l(t){const n=t.name,r=yj(t,null!=e.customObjects?e.customObjects:{});r.setFastWeightInitDuringBuild(i),s[n]=r;t.inboundNodes.forEach((t=>{if(!(t instanceof Array))throw new AW(`Corrupted configuration, expected array for nodeData: ${t}`);a(r,t)}))}const u=e.name,h=e.layers;for(const t of h)l(t);for(;!zW(r);)for(const t of h){const e=s[t.name];if(e.name in r){const t=r[e.name];delete r[e.name];for(const n of t)o(e,n)}}const p=[],c=[],d=e.inputLayers;for(const t of d){const e=t[0],n=t[1],i=t[2];DW(e in s);const r=s[e].inboundNodes[n].outputTensors;p.push(r[i])}const f=e.outputLayers;for(const t of f){const e=t[0],n=t[1],i=t[2];DW(e in s);const r=s[e].inboundNodes[n].outputTensors;c.push(r[i])}return new t({inputs:p,outputs:c,name:u})}get stateful(){if(this._stateful)throw new AW("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(const t of this.layers)if(t.stateful)return!0;return!1}resetStates(){ED((()=>{this.layers.forEach((t=>{t.stateful&&t.resetStates()}))}))}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function nq(t,e,n){const i=e.length;if(null==t||Array.isArray(t)&&0===t.length)return e.map((t=>null));if(1===i)return Array.isArray(t)&&1===t.length?t:"object"==typeof t&&e[0]in t?[t[e[0]]]:[t];if(Array.isArray(t)){if(t.length!==i)throw new Error(`Provided ${n} is an array of ${t.length} element(s), but the model has ${i} outputs. Make sure a set of weights is provided for each model output.`);return t}if("object"==typeof t&&Object.keys(t).length>0&&"object"==typeof t[Object.keys(t)[0]]){const n=[];return e.forEach((e=>{e in t?n.push(t[e]):n.push(null)})),n}throw new Error(`The model has multiple (${i}) outputs, so ${n} must be either an array with ${i} elements or an object with ${e} keys. Provided ${n} not understood: ${JSON.stringify(t)}`)}function iq(t,e){return nq(t,e,"classWeight")}async function sq(t,e,n,i){if(null!=e||null!=i)throw new Error("Support sampleWeight is not implemented yet");if(null!=n){const e=ED((()=>{if(1===t.shape.length)return $L(t);if(2===t.shape.length){if(t.shape[1]>1){return QP(t,1)}if(1===t.shape[1])return y$(t,[t.shape[0]]);throw new Error(`Encountered unexpected last-dimension size (${t.shape[1]}) during handling of class weights. The size is expected to be >= 1.`)}throw new Error(`Unexpected rank of target (y) tensor (${t.rank}) during handling of class weights. The rank is expected to be 1 or 2.`)})),i=Array.from(await e.data());bD(e);const s=[];return i.forEach((t=>{if(null==n[t])throw new Error(`classWeight must contain all classes in the training data. The class ${t} exists in the data but not in classWeight`);s.push(n[t])})),yU(s,"float32")}return null}function rq(t,e){return GL(t,e)}function aq(t,e){let n,i;const s=e;n=s.xs,i=s.ys,_O(null!=n&&null!=i,(()=>`A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${e}`));const r=oq("input",t.inputNames,n),a=oq("output",t.outputNames,i),o=r[0].shape[0];_O(r.length===t.inputs.length,(()=>`LayersModel has ${t.inputs.length} inputs, but the dataset provides ${r.length} inputs. (Expected input keys: ${JSON.stringify(t.inputNames)})`)),_O(a.length===t.outputs.length,(()=>`LayersModel has ${t.outputs.length} outputs, but the dataset provides ${a.length} outputs. (Expected output keys: ${JSON.stringify(t.outputNames)})`));for(let e=0;e<r.length;e++)_O(r[e].shape[0]===o,(()=>`Batch size mismatch: input ${t.inputNames[e]} has ${r[e].shape[0]}; expected ${o} based on input ${t.inputNames[0]}.`));for(let e=0;e<a.length;e++)_O(a[e].shape[0]===o,(()=>`Batch size mismatch: output ${t.outputNames[e]} has ${a[e].shape[0]}; expected ${o} based on input ${t.inputNames[0]}.`));return{xs:r,ys:a}}function oq(t,e,n){if(n instanceof xk)return[n];if(Array.isArray(n))return _O(n.length===e.length,(()=>`Received an array of ${n.length} Tensors, but expected ${e.length} to match the ${t} keys ${e}.`)),n;{const i=[];for(const s of e){if(null==n[s])throw new AW(`The feature data generated by the dataset lacks the required ${t} key '${s}'.`);i.push(n[s])}return i}}async function lq(t,e,n){const i=null!=n.batchesPerEpoch;if(_O(null!=t.optimizer,(()=>"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig).")),_O(null!=n,(()=>"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call.")),_O(null!=n.epochs&&n.epochs>0&&Number.isInteger(n.epochs),(()=>`For fitDataset(), config.epochs is expected to be a positive integer, but got ${n.epochs}`)),_O(!i||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),(()=>`For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`)),_O(null==n.validationSplit,(()=>"`validationSplit` is not supported by `fitDataset()`. Use validationData instead.")),t.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");t.isTraining=!0;try{const s=null!=n.validationData;let r,a;if(s)if(uq(n.validationData))_O(null==n.validationBatches||n.validationBatches>0&&Number.isInteger(n.validationBatches),(()=>`For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${n.validationBatches}`));else{const t=function(t){if(3===t.length)throw new MW("Validation with sample weights is not implemented yet.");return{xs:t[0],ys:t[1]}}(n.validationData);r=t.xs,a=t.ys}const o=t.makeTrainFunction(),l=t.getDedupedMetricsNames();let u;u=s?l.slice().concat(l.map((t=>"val_"+t))):l.slice();const h=gj(n.callbacks,n.yieldEvery),p=null==n.verbose?1:n.verbose,{callbackList:c,history:d}=Tj(h,p,n.epochs,null,null,function(t,e){let n=null;null!=e.batchesPerEpoch?n=e.batchesPerEpoch:Number.isFinite(t.size)&&(n=t.size);return n}(e,n),null,s,u);c.setModel(t),t.history=d,await c.onTrainBegin(),t.stopTraining_=!1;let f=null==n.initialEpoch?0:n.initialEpoch,m=await e.iterator();for(;f<n.epochs;){const u={};await c.onEpochBegin(f);let h=0,p=0;for(i||(m=await e.iterator());!i||h<n.batchesPerEpoch;){const e=await m.next();if(i&&e.done){console.warn(`You provided \`batchesPerEpoch\` as ${n.batchesPerEpoch}, but your dataset iterator ran out of data after ${h} batches; interrupting training. Make sure that your dataset can generate at least \`batchesPerEpoch * epochs\` batches (in this case, `+n.batchesPerEpoch*n.epochs+" batches). You may need to use the repeat() function when building your dataset.");break}if(null!=e.value){const{xs:i,ys:s}=aq(t,e.value),r={};r.batch=p,r.size=i[0].shape[0],await c.onBatchBegin(p,r);const a=[];if(null!=n.classWeight){const e=iq(n.classWeight,t.outputNames);for(let t=0;t<e.length;++t)a.push(await sq(s[t],null,e[t]))}const u=i.concat(s).concat(a),d=o(u);bD(u);for(let t=0;t<l.length;++t){const e=l[t],n=d[t];r[e]=n,vD(n)}await c.onBatchEnd(p,r),uj(r),p++,h++}if(i?h>=n.batchesPerEpoch:e.done){if(s){let e;e=uq(n.validationData)?PW(await t.evaluateDataset(n.validationData,{batches:n.validationBatches})):PW(t.evaluate(r,a,{batchSize:null==n.validationBatchSize?32:n.validationBatchSize,verbose:0}));for(let n=0;n<t.metricsNames.length;++n)u[`val_${t.metricsNames[n]}`]=e[n]}break}if(t.stopTraining_)break}if(await c.onEpochEnd(f,u),f++,t.stopTraining_)break}return await c.onTrainEnd(),await t.history.syncData(),t.history}finally{t.isTraining=!1}}function uq(t){return"function"==typeof t.iterator}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function hq(t){_O(t>0&&Number.isInteger(t),(()=>`batchSize is required to be a positive integer, but got ${t}`))}function pq(t,e,n){return null==t?[null]:Array.isArray(t)?t.map((t=>xz(t,e,n-e))):xz(t,e,n-e)}function cq(t,e){return ED((()=>null==t?null:Array.isArray(t)?t.map((t=>cq(t,e))):Dz(t,"int32"===e.dtype?e:PL(e,"int32"))))}function dq(t,e){const n=[];let i=0,s=null;for(;i<t;)s=i+e,s>=t&&(s=t),n.push([i,s]),i=s;return n}function fq(t){const e=[];t instanceof xk&&(t=[t]);for(let n=0;n<t.length;++n){const i=t[n];if(1===i.rank)e.push(Sz(i,1));else{if(0===i.rank)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");e.push(i)}}return e}function mq(t,e){if(null==t)return;const n=[];if(e instanceof xk)n.push(e.id);else if(Array.isArray(e))e.forEach((t=>n.push(t.id)));else if(null!=e)for(const t in e){const i=e[t];n.push(i.id)}const i=[];if(t instanceof xk)-1===n.indexOf(t.id)&&i.push(t);else if(Array.isArray(t))t.forEach((t=>{-1===n.indexOf(t.id)&&i.push(t)}));else if(null!=t)for(const e in t){const s=t[e];-1===n.indexOf(s.id)&&i.push(s)}i.forEach((t=>{t.isDisposed||t.dispose()}))}function gq(t){return Array.isArray(t)}function _q(t){return!
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function(t){return t instanceof xk}(t)&&!gq(t)}function Tq(t,e,n,i=!0,s=""){if(null==e||0===e.length){if(null!=t){let e=!1;if(gq(t)&&t.length>0)e=!0;else if(_q(t)){for(const n in t)if(t.hasOwnProperty(n)){e=!0;break}}else e=!0;if(e)throw new AW(`Error when checking model ${s} expected no data, but got ${t}`)}return[]}if(null==t)return e.map((t=>null));let r;if(_q(t)){r=[];for(const n of e){if(null==t[n])throw new AW(`No data provided for "${n}". Need data for each key in: ${e}`);r.push(t[n])}}else if(gq(t)){if(t.length!==e.length)throw new AW(`Error when checking model ${s}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${e.length} Tensor(s), but instead got the following list of Tensor(s): ${t}`);r=t}else{if(e.length>1)throw new AW(`The model ${s} expects ${e.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${t.shape}`);r=[t]}if(r=fq(r),null!=n)for(let t=0;t<e.length;++t){if(null==n[t])continue;const a=r[t];if(a.shape.length!==n[t].length)throw new AW(`Error when checking ${s}: expected ${e[t]} to have ${n[t].length} dimension(s). but got array with shape ${a.shape}`);for(let e=0;e<n[t].length;++e){if(0===e&&!i)continue;const r=a.shape[e],o=n[t][e];if(null!=o&&o>=0&&r!==o)throw new AW(`${s} expected a batch of elements where each example has shape [${n[t].slice(1,n[t].length)}] (i.e.,tensor shape [*,${n[t].slice(1,n[t].length)}]) but the ${s} received an input with ${a.shape[0]} examples, each with shape [${a.shape.slice(1,a.shape.length)}] (tensor shape [${a.shape}])`)}}return r}function yq(t,e,n,i=!0,s=""){let r;if(Array.isArray(t)){if(t.length!==e.length)throw new AW(`Error when checking model ${s}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${e.length} Tensor(s), but instead got ${t.length} Tensors(s).`);r=t}else{if(e.length>1)throw new AW(`The model expects ${e.length} ${s} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(t.shape)}.`);r=[t]}if(null!=n)for(let t=0;t<e.length;++t){if(null==n[t])continue;const a=r[t];if(a.shape.length!==n[t].length)throw new AW(`Error when checking ${s}: expected ${e[t]} to have ${n[t].length} dimension(s), but got array with shape ${JSON.stringify(a.shape)}`);for(let r=0;r<n[t].length;++r){if(0===r&&!i)continue;const o=a.shape[r],l=n[t][r];if(null!=l&&l!==o)throw new AW(`Error when checking ${s}: expected ${e[t]} to have shape ${JSON.stringify(n[t])} but got array with shape ${JSON.stringify(a.shape)}.`)}}}class Iq extends eq{constructor(t){super(t),this.isTraining=!1}summary(t,e,n=console.log){if(!this.built)throw new AW("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");Xj(this,t,e,n)}compile(t){if(null==t.loss&&(t.loss=[]),this.loss=t.loss,"string"==typeof t.optimizer)this.optimizer_=
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function(t){const e={Adagrad:()=>iG.adagrad(.01),Adadelta:()=>iG.adadelta(1,.95,vz()),Adam:()=>iG.adam(.001,.9,.999,vz()),Adamax:()=>iG.adamax(.002,.9,.999,vz(),0),RMSProp:()=>iG.rmsprop(.001,.9,0,vz()),SGD:()=>iG.sgd(.01)};if(e.adagrad=e.Adagrad,e.adadelta=e.Adadelta,e.adam=e.Adam,e.adamax=e.Adamax,e.rmsprop=e.RMSProp,e.sgd=e.SGD,t in e)return e[t]();throw new AW(`Unknown Optimizer ${t}`)}(t.optimizer),this.isOptimizerOwned=!0;else{if(!(t.optimizer instanceof oF))throw new AW("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=t.optimizer,this.isOptimizerOwned=!1}let e=[];if(Array.isArray(t.loss)||"string"==typeof t.loss||"function"==typeof t.loss)if(Array.isArray(t.loss)){if(t.loss.length!==this.outputs.length)throw new AW(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${t.loss}.`);const n=t.loss;e=n.map((t=>Cj(t)))}else{const n=Cj(t.loss);this.outputs.forEach((t=>{e.push(n)}))}else{t.loss=t.loss;for(const e in t.loss)if(-1===this.outputNames.indexOf(e))throw new AW(`Unknown entry in loss dictionary: "${e}". Only expected the following keys: ${this.outputNames}`);for(const n of this.outputNames)null==t.loss[n]&&console.warn(`Output "${n}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${n} during training`),e.push(Cj(t.loss[n]))}this.lossFunctions=e,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(let t=0;t<this.outputs.length;++t){const e=this.internalOutputShapes[t],n=this.outputNames[t];this.feedOutputNames.push(n),this.feedOutputShapes.push(e),this.feedLossFns.push(this.lossFunctions[t])}const n=[];this.metrics=t.metrics,this.metricsNames=["loss"],this.metricsTensors=[],dz("loss",(()=>{for(let t=0;t<this.outputs.length;++t){if(-1!==n.indexOf(t))continue;const e=this.lossFunctions[t];this.outputs.length>1&&(this.metricsTensors.push([e,t]),this.metricsNames.push(this.outputNames[t]+"_loss"))}}));const i=function(t,e){if(null==t||Array.isArray(t)&&0===t.length)return e.map((t=>[]));let n;if("string"==typeof t||"function"==typeof t)n=[t];else{if(!Array.isArray(t)&&"object"!=typeof t)throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${t}`);n=t}if(Array.isArray(n))return e.map((t=>n));{const t=[];for(const i of e){let e=n.hasOwnProperty(i)?n[i]:[];Array.isArray(e)||(e=[e]),t.push(e)}return t}}(t.metrics,this.outputNames),s=(t,e,n)=>{this.outputNames.length>1&&(e=this.outputNames[t]+"_"+e),this.metricsNames.push(e),this.metricsTensors.push([n,t])};dz("metric",(()=>{for(let t=0;t<this.outputs.length;++t){if(-1!==n.indexOf(t))continue;(e=>{let n,i,r;for(const a of e){if("string"==typeof a&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(a)){const e=this.internalOutputShapes[t];let s;1===e[e.length-1]||this.lossFunctions[t]===Rj?-1!==["accuracy","acc"].indexOf(a)?i=Nj:-1!==["crossentropy","ce"].indexOf(a)&&(i=Pj):this.lossFunctions[t]===xj?-1!==["accuracy","acc"].indexOf(a)?i=$j:-1!==["crossentropy","ce"].indexOf(a)&&(i=Vj):-1!==["accuracy","acc"].indexOf(a)?i=kj:-1!==["crossentropy","ce"].indexOf(a)&&(i=Bj),-1!==["accuracy","acc"].indexOf(a)?s="acc":-1!==["crossentropy","ce"].indexOf(a)&&(s="ce"),r=i,n=""+s}else{const t=Yj(a);r=t,n=""+Gj(a)}let e;dz(n,(()=>{e=r})),s(t,n,e)}})(i[t])}})),this.collectedTrainableWeights=this.trainableWeights}checkTrainableWeightsConsistency(){null!=this.collectedTrainableWeights&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")}evaluate(t,e,n={}){const i=null==n.batchSize?32:n.batchSize;hq(i);const s=this.standardizeUserDataXY(t,e,!0,i);try{const t=s[0].concat(s[1]);this.makeTestFunction();const e=this.testFunction;return FW(this.testLoop(e,t,i,n.verbose,n.steps))}finally{mq(s[0],t),mq(s[1],e)}}async evaluateDataset(t,e){return this.makeTestFunction(),async function(t,e,n){const i=null!=(n=n||{}).batches,s=t.testFunction;let r=[];if(n.verbose>0)throw new MW("Verbose mode is not implemented yet.");_O(!i||n.batches>0&&Number.isInteger(n.batches),(()=>`Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`));const a="function"==typeof e.next?e:await e.iterator();let o=0,l=0;for(;!i||l<n.batches;){const e=await a.next();if(r=ED((()=>{if(e.value){const{xs:n,ys:i}=aq(t,e.value),a=n.concat(i),u=ED((()=>s(a)));if(bD(a),0===l)for(let t=0;t<u.length;++t)r.push(tF(0));const h=a[0].shape[0];for(let t=0;t<u.length;++t){const e=u[t],n=r[t];r[t]=ED((()=>VL(r[t],GL(h,e)))),l>0&&bD(n)}bD(u),o+=h,++l}return r})),e.done){i&&console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`);break}}for(let t=0;t<r.length;++t){const e=r[t];r[t]=YL(r[t],o),bD(e)}return FW(r)}(this,t,e)}checkNumSamples(t,e,n,i="steps"){let s;if(null!=n){if(s=null,null!=e)throw new AW(`If ${i} is set, batchSize must be null or undefined.Got batchSize = ${e}`)}else{if(null==t)throw new AW(`Either the input data should have a defined shape, or ${i} shoud be specified.`);s=Array.isArray(t)?t[0].shape[0]:t.shape[0]}return s}execute(t,e){if(Array.isArray(e)&&0===e.length)throw new AW("`outputs` is an empty Array, which is not allowed.");const n=Array.isArray(e),i=n?e:[e],s=this.retrieveSymbolicTensors(i),r=new xX;if(t instanceof xk&&(t=[t]),Array.isArray(t)){if(t.length!==this.inputs.length)throw new AW(`The number of inputs provided (${t.length}) does not match the number of inputs of this model (${this.inputs.length}).`);for(let e=0;e<this.inputs.length;++e)r.add(this.inputs[e],t[e])}else for(const e of this.inputs){const n=t[e.name];if(null==n)throw new AW(`No value is provided for the model's input ${e.name}`);r.add(e,n)}const a=AX(s,r);return n?a:a[0]}retrieveSymbolicTensors(t){const e=kW(null,t.length);let n=t.length;for(const i of this.layers){const s=Array.isArray(i.output)?i.output:[i.output],r=s.map((t=>t.name));for(let i=0;i<t.length;++i){const a=r.indexOf(t[i]);if(-1!==a&&(e[i]=s[a],n--),0===n)break}if(0===n)break}if(n>0){const n=[];throw e.forEach(((e,i)=>{null==e&&n.push(t[i])})),new AW(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(n)}`)}return e}predictLoop(t,e=32,n=!1){return ED((()=>{const i=this.checkNumSamples(t);if(n)throw new MW("Verbose predictLoop() is not implemented yet.");const s=dq(i,e),r=this.outputs.map((t=>[]));for(let e=0;e<s.length;++e){ED((()=>{const n=s[e][0],i=s[e][1],r=pq(t,n,i),a=[];if(Array.isArray(r))for(let t=0;t<r.length;++t)a.push({key:this.inputs[t],value:r[t]});else a.push({key:this.inputs[0],value:r});const o=new xX(a);return AX(this.outputs,o)})).forEach(((t,e)=>r[e].push(t)))}return FW(r.map((t=>b$(t,0))))}))}predict(t,e={}){const n=fq(t);yq(n,this.inputNames,this.feedInputShapes,!1);try{const t=null==e.batchSize?32:e.batchSize;return hq(t),this.predictLoop(n,t)}finally{mq(n,t)}}predictOnBatch(t){yq(t,this.inputNames,this.feedInputShapes,!0);const e=(Array.isArray(t)?t[0]:t).shape[0];return this.predictLoop(t,e)}standardizeUserDataXY(t,e,n=!0,i){if(null==this.optimizer_)throw new OW("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");const s=[];for(let t=0;t<this.feedOutputShapes.length;++t){const e=this.feedOutputShapes[t];this.feedLossFns[t]===xj?s.push(e.slice(0,e.length-1).concat([1])):s.push(e)}if(function(t,e){const n=WW(t.map((t=>t.shape[0])));n.sort();const i=WW(e.map((t=>t.shape[0])));if(i.sort(),n.length>1)throw new AW(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map((t=>t.shape)))}`);if(i.length>1)throw new AW(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map((t=>t.shape)))}`);if(n.length>0&&i.length>0&&!vO(n,i))throw new AW(`Input Tensors should have the same number of samples as target Tensors. Found ${n[0]} input sample(s) and ${i[0]} target sample(s).`)}(t=Tq(t,this.feedInputNames,this.feedInputShapes,!1,"input"),e=Tq(e,this.feedOutputNames,s,!1,"target")),function(t,e,n){const i=[Ej,Rj,Sj];for(let s=0;s<t.length;++s){const r=t[s],a=e[s],o=n[s];if(null!=a){if(a===Sj&&1===r.shape[r.shape.length-1])throw new AW(`You are passing a target array of shape ${r.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`);if(-1!==i.indexOf(a)){const t=r.shape.slice(1),e=o.slice(1);for(let n=0;n<t.length;++n){const i=t[n],s=e[n];if(null!=s&&i!==s)throw new AW(`A target Tensor with shape ${r.shape} was passed for an output of shape ${o}, while using a loss function that expects targets to have the same shape as the output.`)}}}}}(e,this.feedLossFns,this.feedOutputShapes),this.stateful&&null!=i&&i>0&&t[0].shape[0]%i!=0)throw new AW(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${i}. Found: ${t[0].shape[0]} sample(s).`);return[t,e]}async standardizeUserData(t,e,n,i,s=!0,r){const[a,o]=this.standardizeUserDataXY(t,e,s,r);if(null!=n)throw new Error("sample weight is not supported yet.");let l=null;if(null!=i){const t=iq(i,this.outputNames);l=[];for(let e=0;e<t.length;++e)l.push(await sq(o[e],null,t[e]))}return[a,o,l]}testLoop(t,e,n,i=0,s){return ED((()=>{const r=this.checkNumSamples(e,n,s,"steps"),a=[];if(i>0)throw new MW("Verbose mode is not implemented yet.");if(null!=s)throw new MW("steps mode in testLoop() is not implemented yet");{const i=dq(r,n),s=yU(Ez(0,r));for(let n=0;n<i.length;++n){const r=i[n][0],o=i[n][1],l=xz(s,r,o-r),u=cq(e,l),h=t(u);if(0===n)for(let t=0;t<h.length;++t)a.push(tF(0));for(let t=0;t<h.length;++t){const e=h[t];a[t]=VL(a[t],GL(o-r,e))}}for(let t=0;t<a.length;++t)a[t]=YL(a[t],r)}return a}))}getDedupedMetricsNames(){const t=this.metricsNames,e=[];for(let n=0;n<t.length;++n){const i=t[n];let s=i;if(LW(t,i)>1){s+=`_${LW(t.slice(0,n),i)}`}e.push(s)}return e}makeTrainFunction(){return t=>{const e=[],n=t.slice(0,this.inputs.length),i=t.slice(this.inputs.length,this.inputs.length+this.outputs.length),s=t.slice(this.inputs.length+this.outputs.length,this.inputs.length+2*this.outputs.length),r=[],a=this.collectedTrainableWeights.map((t=>t.read()));return[this.optimizer_.minimize((()=>{const t=[];for(let e=0;e<this.inputs.length;++e)t.push({key:this.inputs[e],value:n[e]});const a=new xX(t),o=AX(this.outputs,a,{training:!0});let l;for(let t=0;t<this.lossFunctions.length;++t){let n=(0,this.lossFunctions[t])(i[t],o[t]);null!=s[t]&&(n=rq(n,s[t]));const r=rV(n);e.push(r),l=0===t?n:VL(l,n)}for(let t=0;t<this.metricsTensors.length;++t){let n;if(this.outputs.length>1&&t<this.outputs.length)n=e[t];else{const e=this.metricsTensors[t][0],s=this.metricsTensors[t][1];n=rV(e(i[s],o[s]))}vD(n),r.push(n)}return l=rV(l),this.calculateLosses().forEach((t=>{l=VL(l,t)})),l}),!0,a)].concat(r)}}makeTestFunction(){this.testFunction=t=>ED((()=>{const e=[];let n;const i=t.slice(0,this.inputs.length),s=t.slice(this.inputs.length,this.inputs.length+this.outputs.length),r=[];for(let t=0;t<this.inputs.length;++t)r.push({key:this.inputs[t],value:i[t]});const a=new xX(r),o=AX(this.outputs,a);for(let t=0;t<this.lossFunctions.length;++t){const i=this.lossFunctions[t],r=rV(i(s[t],o[t]));n=0===t?r:VL(n,r),e.push(n)}for(let t=0;t<this.metricsTensors.length;++t){const n=this.metricsTensors[t][0],i=this.metricsTensors[t][1],r=rV(n(s[i],o[i]));e.push(r)}return e}))}async fit(t,e,n={}){if(this.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");let i,s,r,a,o,l,u,h,p;this.isTraining=!0;try{const c=null==n.batchSize?32:n.batchSize;hq(c);const d=!1,f=await this.standardizeUserData(t,e,n.sampleWeight,n.classWeight,d,c);i=f[0],s=f[1],p=f[2];let m,g=!1;if(null!=n.validationData&&n.validationData.length>0){if(g=!0,2!==n.validationData.length)throw 3===n.validationData.length?new MW("validationData including sample weights is not supported yet."):new AW(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${n.validationData} is invalid.`);o=n.validationData[0],l=n.validationData[1];const t=!0,e=await this.standardizeUserData(o,l,null,null,t,c);u=e[0],h=e[1],m=u.concat(h)}else if(null!=n.validationSplit&&n.validationSplit>0&&n.validationSplit<1){g=!0;const t=Math.floor(i[0].shape[0]*(1-n.validationSplit)),e=i[0].shape[0];u=pq(i,t,e),r=i,i=pq(i,0,t),h=pq(s,t,e),a=s,s=pq(s,0,t),m=u.concat(h)}else null!=n.validationSteps&&(g=!0);const _=i.concat(s).concat(p);this.checkTrainableWeightsConsistency();const T=this.makeTrainFunction(),y=this.getDedupedMetricsNames();let I,E;g?(this.makeTestFunction(),I=this.testFunction,E=y.slice().concat(y.map((t=>"val_"+t)))):(I=null,m=[],E=y.slice());const b=gj(n.callbacks,n.yieldEvery);return await this.fitLoop(T,_,y,c,n.epochs,n.verbose,b,I,m,n.shuffle,E,n.initialEpoch,null,null)}finally{this.isTraining=!1,mq(i,t),mq(s,e),mq(r,t),mq(a,e),mq(u,o),mq(h,l),null!=p&&bD(p)}}async fitLoop(t,e,n,i,s,r,a,o,l,u,h,p,c,d){null==i&&(i=32),null==s&&(s=1),null==u&&(u=!0),null==p&&(p=0);let f=!1;if(null!=o&&null!=l&&(f=!0),null!=d&&(f=!0,null==c))throw new AW("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");const m=this.checkNumSamples(e,i,c,"steps_per_epoch");let g;null!=m&&(g=Ez(0,m)),null==r&&(r=1);const{callbackList:_,history:T}=Tj(a,r,s,p,m,c,i,f,h);_.setModel(this),this.history=T,await _.onTrainBegin(),this.stopTraining_=!1;for(let r=p;r<s;++r){await _.onEpochBegin(r);const s={};if(null!=c)throw new MW("stepsPerEpoch mode is not implemented yet.");{if("batch"===u)throw new MW("batch shuffling is not implemneted yet");u&&uO(g);const r=yU(g),a=dq(m,i);for(let u=0;u<a.length;++u){const h={};if(await _.onBatchBegin(u,h),ED((()=>{const p=a[u][0],c=a[u][1],d=xz(r,p,c-p);h.batch=u,h.size=c-p;const m=cq(e,d),g=t(m);for(let t=0;t<n.length;++t){const e=n[t],i=g[t];h[e]=i,vD(i)}if(u===a.length-1&&f){const t=this.testLoop(o,l,i);for(let e=0;e<n.length;++e){const i=n[e],r=t[e];vD(r),s["val_"+i]=r}}})),await _.onBatchEnd(u,h),uj(h),this.stopTraining_)break}r.dispose()}if(await _.onEpochEnd(r,s),this.stopTraining_)break}return await _.onTrainEnd(),await this.history.syncData(),this.history}async fitDataset(t,e){return lq(this,t,e)}async trainOnBatch(t,e){const n=await this.standardizeUserData(t,e),i=n[0],s=n[1],r=this.makeTrainFunction()(i.concat(s)),a=[];for(const t of r){const e=await t.data();a.push(e[0])}return bD(r),mq(n[0],t),mq(n[1],e),FW(a)}getNamedWeights(t){const e=[],n=null!=t&&t.trainableOnly,i=n?this.trainableWeights:this.weights,s=this.getWeights(n);for(let t=0;t<i.length;++t)n&&!i[t].trainable||e.push({name:i[t].originalName,tensor:s[t]});return e}set stopTraining(t){this.stopTraining_=t}get stopTraining(){return this.stopTraining_}get optimizer(){return this.optimizer_}set optimizer(t){this.optimizer_!==t&&(this.optimizer_=t,this.isOptimizerOwned=!1)}dispose(){const t=super.dispose();if(0===t.refCountAfterDispose&&null!=this.optimizer&&this.isOptimizerOwned){const e=yD().numTensors;this.optimizer_.dispose(),t.numDisposedVariables+=e-yD().numTensors}return t}getLossIdentifiers(){let t;if("string"==typeof this.loss)t=$W(this.loss);else if(Array.isArray(this.loss)){for(const t of this.loss)if("string"!=typeof t)throw new Error("Serialization of non-string loss is not supported.");t=this.loss.map((t=>$W(t)))}else{const e=Object.keys(this.loss);t={};const n=this.loss;for(const i of e){if("string"!=typeof n[i])throw new Error("Serialization of non-string loss is not supported.");t[i]=$W(n[i])}}return t}getMetricIdentifiers(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[$W(Gj(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map((t=>$W(Gj(t))));{const t={};for(const e in this.metrics)t[e]=$W(Gj(this.metrics[e]));return t}}getTrainingConfig(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}}loadTrainingConfig(t){if(null!=t.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=t.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=t.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");const e=yj(Jj(t.optimizer_config));let n,i;if("string"==typeof t.loss)n=BW(t.loss);else if(Array.isArray(t.loss))n=t.loss.map((t=>BW(t)));else if(null!=t.loss){n={};for(const e in t.loss)n[e]=BW(t.loss[e])}if(Array.isArray(t.metrics))i=t.metrics.map((t=>BW(t)));else if(null!=t.metrics){i={};for(const e in t.metrics)i[e]=BW(t.metrics[e])}this.compile({loss:n,metrics:i,optimizer:e})}async save(t,e){if("string"==typeof t){const e=eL(t);if(0===e.length)throw new AW(`Cannot find any save handlers for URL '${t}'`);if(e.length>1)throw new AW(`Found more than one (${e.length}) save handlers for URL '${t}'`);t=e[0]}if(null==t.save)throw new AW("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");const n=await LD(this.getNamedWeights(e)),i={modelTopology:this.toJSON(null,!1),format:"layers-model",generatedBy:`TensorFlow.js tfjs-layers v${tq}`,convertedBy:null};if(null!=e&&e.includeOptimizer&&null!=this.optimizer){i.trainingConfig=this.getTrainingConfig();const t="optimizer",{data:e,specs:s}=await LD(await this.optimizer.getWeights(),t);n.specs.push(...s),n.data=WD([n.data,e])}if(null!=this.userDefinedMetadata){const t=!0;Wj(this.userDefinedMetadata,this.name,t),i.userDefinedMetadata=this.userDefinedMetadata}return i.weightData=n.data,i.weightSpecs=n.specs,t.save(i)}setUserDefinedMetadata(t){Wj(t,this.name),this.userDefinedMetadata=t}getUserDefinedMetadata(){return this.userDefinedMetadata}}Iq.className="Model",rF(Iq);class Eq extends Iq{}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
async function bq(t,e){"modelTopology"in t||(t={modelTopology:t});let n=t.modelTopology;null!=n.model_config&&(n=n.model_config);const i=yj(Jj(n),e);if(null!=t.weightsManifest){const e=await MF(t.weightsManifest,t.pathPrefix,i.weights.map((t=>t.originalName))),n={};for(const t of i.weights)n[t.originalName]=e[t.originalName];i.loadWeights(n),bD(e)}return i}async function vq(t,e){if(null==e&&(e={}),"string"==typeof t){const n=nL(t,e);if(0===n.length)n.push(FF(t,e));else if(n.length>1)throw new AW(`Found more than one (${n.length}) load handlers for URL '${t}'`);t=n[0]}return async function(t,e,n){null==n&&(n={});if(null==t.load)throw new AW("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const i=await t.load();let s=i.modelTopology;null!=s.model_config&&(s=s.model_config);const r=null==n.strict||n.strict,a=null!=i.weightData&&null!=i.weightSpecs&&r,o=yj(Jj(s),e,a),l=i.trainingConfig;null!=l&&o.loadTrainingConfig(l);null!=i.userDefinedMetadata&&o.setUserDefinedMetadata(i.userDefinedMetadata);if(null!=i.weightData){if(null==i.weightSpecs)throw new AW("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");const{modelWeights:t,optimizerWeights:e}=function(t,e){const n=FD(t,e),i={},s=[];return e.forEach((t=>{"optimizer"===t.group?s.push({name:t.name,tensor:n[t.name]}):i[t.name]=n[t.name]})),{modelWeights:i,optimizerWeights:s}}(i.weightData,i.weightSpecs);o.loadWeights(t,r),null!=o.optimizer&&e.length>0&&await o.optimizer.setWeights(e),bD(t),bD(e.map((t=>t.tensor)))}return o}(t,void 0,e)}Eq.className="Functional",rF(Eq);class wq extends Iq{constructor(t){if(super({inputs:[],outputs:[]}),t=t||{},this.trainable=!0,this.built=!1,this.name=null!=t.name?t.name:ez("sequential_"),null!=t.layers)for(const e of t.layers)this.add(e)}checkShape(t){if(t.inboundNodes[0].outputTensors[0].shape.some((t=>t<0)))throw new AW(`Negative dimension size caused by adding layer ${t.name} with input shape [${t.inboundNodes[0].inputTensors[0].shape}]`)}add(t){const e=t instanceof wq||t instanceof Iq;let n;if(e){if(n=t,1!==n.outputs.length)throw new AW("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==n.inputs.length)throw new AW("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(0===this.outputs.length){if(0===t.inboundNodes.length){if(null==t.batchInputShape)throw new AW("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");const e=SX({batchShape:t.batchInputShape,dtype:t.dtype,name:t.name+"_input"});t.apply(e)}if(e)this.outputs=n.outputs,this.inputs=n.inputs;else{if(1!==t.inboundNodes.length)throw new AW(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${t.name} which has ${t.inboundNodes.length} pre-existing inbound connections.`);if(1!==t.inboundNodes[0].outputTensors.length)throw new AW("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(t),this.outputs=[t.inboundNodes[0].outputTensors[0]],this.inputs=vX(this.outputs[0])}this.inboundNodes=[],new IX({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:kW(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map((t=>t.shape)),outputShapes:this.outputs[0].shape})}else{const e=t.apply(this.outputs[0]);if(Array.isArray(e))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(t),this.outputs=[e],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(t),this.built=!1}pop(){if(0===this.layers.length)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),0===this.layers.length)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{const t=this.layers.length-1;this.layers[t].outboundNodes=[],this.outputs=[this.layers[t].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}}call(t,e){return null==this.model&&this.build(),this.model.call(t,e)}build(t){if(pX(t),0===this.inputs.length||0===this.outputs.length)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new Iq({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0}countParams(){return this.built||this.build(),super.countParams()}summary(t,e,n=console.log){this.built||this.build(),super.summary(t,e,n)}setWeights(t){null==this.model&&this.build(),this.model.setWeights(t)}evaluate(t,e,n={}){if(!this.built)throw new OW("The model needs to be compiled before being used.");return this.model.evaluate(t,e,n)}async evaluateDataset(t,e){if(!this.built)throw new OW("The model needs to be compiled before being used.");return this.model.evaluateDataset(t,e)}predict(t,e={}){return null==this.model&&this.build(),this.model.predict(t,e)}predictOnBatch(t){return null==this.model&&this.build(),this.model.predictOnBatch(t)}compile(t){this.build(),this.model.compile(t),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames}get optimizer(){return null==this.model?void 0:this.model.optimizer}set optimizer(t){this.model.optimizer=t}async fit(t,e,n={}){if(!this.built)throw new OW("The model needs to be compiled before being used.");return this.model.fit(t,e,n)}async fitDataset(t,e){if(!this.built)throw new OW("The model needs to be compiled before being used.");return this.model.fitDataset(t,e)}async trainOnBatch(t,e){return this.model.trainOnBatch(t,e)}static fromConfig(t,e,n={},i=!1){let s,r={};if(e instanceof Array){if(null==e[0].className||"Merge"===e[0].className)throw new AW("Legacy serialization format not supported yet.");s=e}else _O(null!=e.layers,(()=>"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field.")),s=e.layers,delete e.layers,r=e;const a=new t(r);if(!(a instanceof wq))throw new MW(`Sequential.fromConfig called on non-Sequential input: ${a}`);for(const t of s){const e=yj(t,void 0,i);i&&e.setFastWeightInitDuringBuild(!0),a.add(e)}return a}set stopTraining(t){if(null==this.model)throw new AW("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=t}get stopTraining(){if(null==this.model)throw new AW("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}getConfig(){const t=[];for(const e of this.layers){const n={};n.className=e.getClassName(),n.config=e.getConfig(),t.push(n)}return{name:this.name,layers:t}}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Sq(t){return new Iq(t)}function xq(t){return new wq(t)}function Rq(t){return SX(t)}function Oq(t,e){_j.registerCallbackConstructor(t,e)}wq.className="Sequential",rF(wq);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class Aq extends iF{getConfig(){return{}}}class Mq extends Aq{apply(t,e=1){return function(t,e=1){if(1!==e)throw new MW(`Support for alpha values other than 1 (${e}) is not implemented yet.`);return uB(t)}(t,e)}}Mq.className="elu",rF(Mq);class Cq extends Aq{apply(t){return QV(t)}}Cq.className="selu",rF(Cq);class Nq extends Aq{apply(t){return YV(t)}}Nq.className="relu",rF(Nq);class kq extends Aq{apply(t){return ED((()=>uV(6,YV(t))))}}kq.className="relu6",rF(kq);class Dq extends Aq{apply(t){return t}}Dq.className="linear",rF(Dq);class Lq extends Aq{apply(t){return v$(t)}}Lq.className="sigmoid",rF(Lq);class Fq extends Aq{apply(t){return function(t){return ED((()=>{const e=VL(.5,GL(.2,t));return P$(e,0,1)}))}(t)}}Fq.className="hardSigmoid",rF(Fq);class Pq extends Aq{apply(t){return WB(t)}}Pq.className="softplus",rF(Pq);class $q extends Aq{apply(t){return function(t){return ED((()=>YL(t,VL(fF(t),1))))}(t)}}$q.className="softsign",rF($q);class Bq extends Aq{apply(t){return S$(t)}}Bq.className="tanh",rF(Bq);class Vq extends Aq{apply(t,e=-1){return oU(t,e)}}Vq.className="softmax",rF(Vq);class Uq extends Aq{apply(t,e=-1){return XB(t,e)}}Uq.className="logSoftmax",rF(Uq);class Yq extends Aq{apply(t){return ED((()=>ED((()=>{const e=Math.sqrt(2),n=GL(.5,VL(1,pB(YL(t,e))));return GL(t,n)}))))}}Yq.className="gelu",rF(Yq);class Gq extends Aq{apply(t){return ED((()=>GL(.5,GL(t,VL(1,S$(GL(HL(YL(2,Math.PI)),VL(t,GL(.044715,pF(t,3))))))))))}}Gq.className="gelu_new",rF(Gq);class Hq extends Aq{apply(t){return ED((()=>GL(t,S$(WB(t)))))}}Hq.className="mish",rF(Hq);class Wq extends Aq{apply(t,e=1){return ED((()=>GL(v$(GL(t,e)),t)))}}function zq(t){return t.getClassName()}function Xq(t,e={}){return GW(t,sF.getMap().classNameMap,e,"activation")}function jq(t){if(null==t){const t={className:"linear",config:{}};return Xq(t)}if("string"==typeof t){const e={};return e.className=t,e.config={},Xq(e)}return t instanceof Aq?t:Xq(t)}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function qq(t){if(null!=t&&"object"!=typeof t)throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${t}`)}Wq.className="swish",rF(Wq);class Kq extends iF{}class Qq extends Kq{constructor(t){super(),qq(t),this.l1=null==t||null==t.l1?.01:t.l1,this.l2=null==t||null==t.l2?.01:t.l2,this.hasL1=0!==this.l1,this.hasL2=0!==this.l2}apply(t){return ED((()=>{let e=aV([1]);return this.hasL1&&(e=VL(e,bB(GL(this.l1,fF(t))))),this.hasL2&&(e=VL(e,bB(GL(this.l2,Lz(t))))),y$(e,[])}))}getConfig(){return{l1:this.l1,l2:this.l2}}static fromConfig(t,e){return new t({l1:e.l1,l2:e.l2})}}Qq.className="L1L2",rF(Qq);const Jq={l1l2:"L1L2"};function Zq(t){return UW(t)}function tK(t,e={}){return GW(t,sF.getMap().classNameMap,e,"regularizer")}function eK(t){if(null==t)return null;if("string"==typeof t){return tK({className:t in Jq?Jq[t]:t,config:{}})}return t instanceof Kq?t:tK(t)}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class nK extends bX{constructor(t){super(null==t?{}:t),this.supportsMasking=!0,null!=t&&(this.maxValue=t.maxValue)}call(t,e){t=hX(t);let n=YV(t);return null!=this.maxValue&&(n=P$(n,0,this.maxValue)),n}computeOutputShape(t){return t}getConfig(){const t={maxValue:this.maxValue},e=super.getConfig();return Object.assign(t,e),t}}nK.className="ReLU",rF(nK);class iK extends bX{constructor(t){super(null==t?{}:t),this.DEFAULT_ALPHA=.3,null==t&&(t={}),this.alpha=null==t.alpha?this.DEFAULT_ALPHA:t.alpha}call(t,e){const n=hX(t);return $B(n,this.alpha)}computeOutputShape(t){return t}getConfig(){const t={alpha:this.alpha},e=super.getConfig();return Object.assign(t,e),t}}iK.className="LeakyReLU",rF(iK);class sK extends bX{constructor(t){if(super(null==t?{}:t),this.DEFAULT_ALPHA_INITIALIZER="zeros",null==t&&(t={}),this.supportsMasking=!0,this.alphaInitializer=oX(t.alphaInitializer||this.DEFAULT_ALPHA_INITIALIZER),this.alphaRegularizer=eK(t.alphaRegularizer),this.alphaConstraint=YX(t.alphaConstraint),null==t.sharedAxes)this.sharedAxes=null;else if(Array.isArray(t.sharedAxes))this.sharedAxes=t.sharedAxes;else{if("number"!=typeof t.sharedAxes)throw new AW(`Expected sharedAxes to be a number or an array of numbers, but got ${t.sharedAxes}`);this.sharedAxes=[t.sharedAxes]}}build(t){const e=(t=pX(t)).slice(1);if(null!=this.sharedAxes)for(const t of this.sharedAxes)e[t-1]=1;this.alpha=this.addWeight("alpha",e,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);const n={};if(null!=this.sharedAxes)for(let e=1;e<t.length;++e)n[e]=t[e];this.inputSpec=[new _X({ndim:t.length,axes:n})],this.built=!0}call(t,e){return t=hX(t),SV(t,this.alpha.read())}getConfig(){const t={alphaInitializer:aX(this.alphaInitializer),alphaRegularizer:Zq(this.alphaRegularizer),alphaConstraint:VX(this.alphaConstraint),sharedAxes:this.sharedAxes},e=super.getConfig();return Object.assign(t,e),t}}sK.className="PReLU",rF(sK);class rK extends bX{constructor(t){if(super(null==t?{}:t),this.DEFAULT_ALPHA=1,null==t&&(t={}),null!=t.alpha&&t.alpha!==this.DEFAULT_ALPHA)throw new MW(`Non-default alpha value (${t.alpha}) is not supported by the ELU layer yet.`);this.alpha=null==t.alpha?this.DEFAULT_ALPHA:t.alpha}call(t,e){const n=hX(t);return uB(n)}computeOutputShape(t){return t}getConfig(){const t={alpha:this.alpha},e=super.getConfig();return Object.assign(t,e),t}}rK.className="ELU",rF(rK);class aK extends bX{constructor(t){super(null==t?{}:t),this.DEFAULT_THETA=1,null==t&&(t={}),this.theta=null==t.theta?this.DEFAULT_THETA:t.theta}call(t,e){const n=hX(t);return GL(n,PL(kB(n,this.theta),"float32"))}computeOutputShape(t){return t}getConfig(){const t={theta:this.theta},e=super.getConfig();return Object.assign(t,e),t}}aK.className="ThresholdedReLU",rF(aK);class oK extends bX{constructor(t){super(null==t?{}:t),this.DEFAULT_AXIS=1,null==t&&(t={}),this.softmax=(new Vq).apply,this.axis=null==t.axis?this.DEFAULT_AXIS:t.axis}call(t,e){return ED((()=>{let n=hX(t);const i=e.mask;if(null!=i){const t=GL(cF(oV(n.shape),PL(i,n.dtype)),tF(-1e9));n=VL(n,t)}return this.axis instanceof Array?this.axis.length>1?xB(cF(n,jB(n,this.axis,!0))):this.softmax(n,this.axis[0]):this.softmax(n,this.axis)}))}computeOutputShape(t){return t}getConfig(){const t={axis:this.axis},e=super.getConfig();return Object.assign(t,e),t}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function lK(t,e,n){if("number"==typeof t)return kW(t,e);if(t.length!==e)throw new AW(`The ${n} argument must be an integer or tuple of ${e} integers. Received: ${t.length} elements.`);for(let s=0;s<e;++s){const r=t[s];if((i=r)!==parseInt(i.toString(),10))throw new AW(`The ${n} argument must be an integer or tuple of ${e} integers. Received: ${JSON.stringify(t)} including a non-integer number ${r}`)}return t;
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
var i}function uK(t,e,n,i,s=1){if(null==t)return t;let r;return r="same"===n?t:t-(e+(e-1)*(s-1))+1,Math.floor((r+i-1)/i)}function hK(t,e,n,i){if(null==t)return null;if("valid"===i)t=t*e+Iz([n-e,0]);else{if("same"!==i)throw new AW(`Unsupport padding mode: ${i}.`);t*=e}return t}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function pK(t,e){return ED((()=>(lz(e),"channelsFirst"===e?qF(t,[0,2,3,1]):t)))}function cK(t,e){return ED((()=>(lz(e),"channelsFirst"===e?qF(t,[0,2,3,4,1]):t)))}function dK(t,e,n,i=1,s="valid",r,a=1){return ED((()=>{if(null==r&&(r="channelsLast"),lz(r),3!==t.shape.length)throw new AW(`The input of a conv1dWithBias operation should be 3, but is ${t.shape.length} instead.`);if(3!==e.shape.length)throw new AW(`The kernel for a conv1dWithBias operation should be 3, but is ${e.shape.length} instead`);if(null!=n&&1!==n.shape.length)throw new AW(`The bias for a conv1dWithBias operation should be 1, but is ${n.shape.length} instead`);if("channelsFirst"===r&&(t=qF(t,[0,2,1])),"causal"===s)throw new MW("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");let o=G$(t,e,i,"same"===s?"same":"valid","NWC",a);return null!=n&&(o=Pz(o,n)),o}))}function fK(t,e,n,i=[1,1],s="valid",r,a,o=null){return ED((()=>{if(null==r&&(r="channelsLast"),lz(r),3!==t.rank&&4!==t.rank)throw new AW(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${t.rank}.`);if(3!==e.rank&&4!==e.rank)throw new AW(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${t.rank}.`);let l=pK(t,r);if("causal"===s)throw new MW("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return l=jU({x:l,filter:e,strides:i,pad:"same"===s?"same":"valid",dilations:a,dataFormat:"NHWC",bias:n,activation:o}),"channelsFirst"===r&&(l=qF(l,[0,3,1,2])),l}))}function mK(t,e,n,i=[1,1,1],s="valid",r,a){return ED((()=>{if(null==r&&(r="channelsLast"),lz(r),4!==t.rank&&5!==t.rank)throw new AW(`conv3dWithBias expects input to be of rank 4 or 5, but received ${t.rank}.`);if(4!==e.rank&&5!==e.rank)throw new AW(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${t.rank}.`);let o=cK(t,r);if("causal"===s)throw new MW("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return o=z$(o,e,i,"same"===s?"same":"valid","NDHWC",a),null!=n&&(o=Pz(o,n)),"channelsFirst"===r&&(o=qF(o,[0,4,1,2,3])),o}))}oK.className="Softmax",rF(oK);class gK extends bX{constructor(t,e){if(super(e),this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",gK.verifyArgs(e),this.rank=t,qW(this.rank,"rank"),1!==this.rank&&2!==this.rank&&3!==this.rank)throw new MW(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`);if(this.kernelSize=lK(e.kernelSize,t,"kernelSize"),this.strides=lK(null==e.strides?1:e.strides,t,"strides"),this.padding=null==e.padding?"valid":e.padding,uz(this.padding),this.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,lz(this.dataFormat),this.activation=jq(e.activation),this.useBias=null==e.useBias||e.useBias,this.biasInitializer=oX(e.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.biasConstraint=YX(e.biasConstraint),this.biasRegularizer=eK(e.biasRegularizer),this.activityRegularizer=eK(e.activityRegularizer),this.dilationRate=lK(null==e.dilationRate?1:e.dilationRate,t,"dilationRate"),1===this.rank&&Array.isArray(this.dilationRate)&&1!==this.dilationRate.length)throw new AW(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`);if(2===this.rank){if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate];else if(2!==this.dilationRate.length)throw new AW(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`)}else if(3===this.rank)if("number"==typeof this.dilationRate)this.dilationRate=[this.dilationRate,this.dilationRate,this.dilationRate];else if(3!==this.dilationRate.length)throw new AW(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`)}static verifyArgs(t){if(DW("kernelSize"in t,"required key 'kernelSize' not in config"),"number"!=typeof t.kernelSize&&!jW(t.kernelSize,"number",1,3))throw new AW(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(t.kernelSize)}.`)}getConfig(){const t={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:zq(this.activation),useBias:this.useBias,biasInitializer:aX(this.biasInitializer),biasRegularizer:Zq(this.biasRegularizer),activityRegularizer:Zq(this.activityRegularizer),biasConstraint:VX(this.biasConstraint)},e=super.getConfig();return Object.assign(t,e),t}}class _K extends gK{constructor(t,e){super(t,e),this.kernel=null,_K.verifyArgs(e),this.filters=e.filters,qW(this.filters,"filters"),this.kernelInitializer=oX(e.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.kernelConstraint=YX(e.kernelConstraint),this.kernelRegularizer=eK(e.kernelRegularizer)}build(t){t=pX(t);const e="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[e])throw new AW(`The channel dimension of the input should be defined. Found ${t[e]}`);const n=t[e],i=this.kernelSize.concat([n,this.filters]);this.kernel=this.addWeight("kernel",i,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:{[e]:n}}],this.built=!0}call(t,e){return ED((()=>{let e;t=hX(t);const n=null==this.bias?null:this.bias.read(),i=QW(this.activation.getClassName());if(null!=i&&2===this.rank)e=fK(t,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate,i);else{if(1===this.rank)e=dK(t,this.kernel.read(),n,this.strides[0],this.padding,this.dataFormat,this.dilationRate[0]);else if(2===this.rank)e=fK(t,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate);else{if(3!==this.rank)throw new MW("convolutions greater than 3D are not implemented yet.");e=mK(t,this.kernel.read(),n,this.strides,this.padding,this.dataFormat,this.dilationRate)}null!=this.activation&&(e=this.activation.apply(e))}return e}))}computeOutputShape(t){t=pX(t);const e=[],n="channelsLast"===this.dataFormat?t.slice(1,t.length-1):t.slice(2);for(let t=0;t<n.length;++t){const i=uK(n[t],this.kernelSize[t],this.padding,this.strides[t],"number"==typeof this.dilationRate?this.dilationRate:this.dilationRate[t]);e.push(i)}let i=[t[0]];return"channelsLast"===this.dataFormat?(i=i.concat(e),i.push(this.filters)):(i.push(this.filters),i=i.concat(e)),i}getConfig(){const t={filters:this.filters,kernelInitializer:aX(this.kernelInitializer),kernelRegularizer:Zq(this.kernelRegularizer),kernelConstraint:VX(this.kernelConstraint)},e=super.getConfig();return Object.assign(t,e),t}static verifyArgs(t){if(!("filters"in t)||"number"!=typeof t.filters||t.filters<1)throw new AW(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(t.filters)}`)}}class TK extends _K{constructor(t){super(2,t),TK.verifyArgs(t)}getConfig(){const t=super.getConfig();return delete t.rank,t}static verifyArgs(t){if("number"!=typeof t.kernelSize&&!jW(t.kernelSize,"number",1,2))throw new AW(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(t.kernelSize)}.`)}}TK.className="Conv2D",rF(TK);class yK extends _K{constructor(t){super(3,t),yK.verifyArgs(t)}getConfig(){const t=super.getConfig();return delete t.rank,t}static verifyArgs(t){if("number"!=typeof t.kernelSize&&(!Array.isArray(t.kernelSize)||1!==t.kernelSize.length&&3!==t.kernelSize.length))throw new AW(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(t.kernelSize)}.`)}}yK.className="Conv3D",rF(yK);class IK extends TK{constructor(t){if(super(t),this.inputSpec=[new _X({ndim:4})],"same"!==this.padding&&"valid"!==this.padding)throw new AW(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(t){if(4!==(t=pX(t)).length)throw new AW("Input should have rank 4; Received input shape: "+JSON.stringify(t));const e="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[e])throw new AW("The channel dimension of the inputs should be defined. Found `None`.");const n=t[e],i=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",i,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new _X({ndim:4,axes:{[e]:n}})],this.built=!0}call(t,e){return ED((()=>{let e=hX(t);if(4!==e.shape.length)throw new AW(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${e.shape.length}`);const n=e.shape,i=n[0];let s,r;"channelsFirst"===this.dataFormat?(s=2,r=3):(s=1,r=2);const a=n[s],o=n[r],l=this.kernelSize[0],u=this.kernelSize[1],h=this.strides[0],p=this.strides[1],c=[i,hK(a,h,l,this.padding),hK(o,p,u,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(e=qF(e,[0,2,3,1]));let d=W$(e,this.kernel.read(),c,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(d=qF(d,[0,3,1,2])),null!=this.bias&&(d=Pz(d,this.bias.read(),this.dataFormat)),null!=this.activation&&(d=this.activation.apply(d)),d}))}computeOutputShape(t){const e=(t=pX(t)).slice();let n,i,s;"channelsFirst"===this.dataFormat?(n=1,i=2,s=3):(n=3,i=1,s=2);const r=this.kernelSize[0],a=this.kernelSize[1],o=this.strides[0],l=this.strides[1];return e[n]=this.filters,e[i]=hK(e[i],o,r,this.padding),e[s]=hK(e[s],l,a,this.padding),e}getConfig(){const t=super.getConfig();return delete t.dilationRate,t}}IK.className="Conv2DTranspose",rF(IK);class EK extends yK{constructor(t){if(super(t),this.inputSpec=[new _X({ndim:5})],"same"!==this.padding&&"valid"!==this.padding)throw new AW(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`)}build(t){if(5!==(t=pX(t)).length)throw new AW("Input should have rank 5; Received input shape: "+JSON.stringify(t));const e="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[e])throw new AW("The channel dimension of the inputs should be defined. Found `None`.");const n=t[e],i=this.kernelSize.concat([this.filters,n]);this.kernel=this.addWeight("kernel",i,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new _X({ndim:5,axes:{[e]:n}})],this.built=!0}call(t,e){return ED((()=>{let e=hX(t);if(5!==e.shape.length)throw new AW(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${e.shape.length}`);const n=e.shape,i=n[0];let s,r,a;"channelsFirst"===this.dataFormat?(a=2,s=3,r=4):(a=1,s=2,r=3);const o=n[a],l=n[s],u=n[r],h=this.kernelSize[0],p=this.kernelSize[1],c=this.kernelSize[2],d=this.strides[0],f=this.strides[1],m=this.strides[2],g=[i,hK(o,d,h,this.padding),hK(l,f,p,this.padding),hK(u,m,c,this.padding),this.filters];"channelsLast"!==this.dataFormat&&(e=qF(e,[0,2,3,4,1]));let _=j$(e,this.kernel.read(),g,this.strides,this.padding);return"channelsLast"!==this.dataFormat&&(_=qF(_,[0,4,1,2,3])),null!==this.bias&&(_=Pz(_,this.bias.read(),this.dataFormat)),null!==this.activation&&(_=this.activation.apply(_)),_}))}computeOutputShape(t){const e=(t=pX(t)).slice();let n,i,s,r;"channelsFirst"===this.dataFormat?(n=1,i=2,s=3,r=4):(n=4,i=1,s=2,r=3);const a=this.kernelSize[0],o=this.kernelSize[1],l=this.kernelSize[2],u=this.strides[0],h=this.strides[1],p=this.strides[2];return e[n]=this.filters,e[i]=hK(e[i],u,a,this.padding),e[s]=hK(e[s],h,o,this.padding),e[r]=hK(e[r],p,l,this.padding),e}getConfig(){const t=super.getConfig();return delete t.dilationRate,t}}EK.className="Conv3DTranspose",rF(EK);class bK extends _K{constructor(t,e){if(super(t,e),this.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",this.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",this.depthwiseKernel=null,this.pointwiseKernel=null,null==e.filters)throw new AW("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=e.kernelInitializer||null!=e.kernelRegularizer||null!=e.kernelConstraint)throw new AW("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=e.padding&&"same"!==e.padding&&"valid"!==e.padding)throw new AW(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(e.padding)}`);this.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,this.depthwiseInitializer=oX(e.depthwiseInitializer||this.DEFAULT_DEPTHWISE_INITIALIZER),this.depthwiseRegularizer=eK(e.depthwiseRegularizer),this.depthwiseConstraint=YX(e.depthwiseConstraint),this.pointwiseInitializer=oX(e.depthwiseInitializer||this.DEFAULT_POINTWISE_INITIALIZER),this.pointwiseRegularizer=eK(e.pointwiseRegularizer),this.pointwiseConstraint=YX(e.pointwiseConstraint)}build(t){if((t=pX(t)).length<this.rank+2)throw new AW(`Inputs to SeparableConv${this.rank}D should have rank ${this.rank+2}, but received input shape: ${JSON.stringify(t)}`);const e="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[e]||t[e]<0)throw new AW(`The channel dimension of the inputs should be defined, but found ${JSON.stringify(t[e])}`);const n=t[e],i=this.kernelSize.concat([n,this.depthMultiplier]),s=[];for(let t=0;t<this.rank;++t)s.push(1);s.push(n*this.depthMultiplier,this.filters);const r=!0;this.depthwiseKernel=this.addWeight("depthwise_kernel",i,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,r,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",s,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,r,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,r,this.biasConstraint):this.bias=null,this.inputSpec=[new _X({ndim:this.rank+2,axes:{[e]:n}})],this.built=!0}call(t,e){return ED((()=>{let e;if(t=hX(t),1===this.rank)throw new MW("1D separable convolution is not implemented yet.");return 2===this.rank&&("channelsFirst"===this.dataFormat&&(t=qF(t,[0,2,3,1])),e=JV(t,this.depthwiseKernel.read(),this.pointwiseKernel.read(),this.strides,this.padding,this.dilationRate,"NHWC")),this.useBias&&(e=Pz(e,this.bias.read(),this.dataFormat)),null!=this.activation&&(e=this.activation.apply(e)),"channelsFirst"===this.dataFormat&&(e=qF(e,[0,3,1,2])),e}))}getConfig(){const t=super.getConfig();return delete t.rank,delete t.kernelInitializer,delete t.kernelRegularizer,delete t.kernelConstraint,t.depthwiseInitializer=aX(this.depthwiseInitializer),t.pointwiseInitializer=aX(this.pointwiseInitializer),t.depthwiseRegularizer=Zq(this.depthwiseRegularizer),t.pointwiseRegularizer=Zq(this.pointwiseRegularizer),t.depthwiseConstraint=VX(this.depthwiseConstraint),t.pointwiseConstraint=VX(this.pointwiseConstraint),t}}bK.className="SeparableConv";class vK extends bK{constructor(t){super(2,t)}}vK.className="SeparableConv2D",rF(vK);class wK extends _K{constructor(t){super(1,t),wK.verifyArgs(t),this.inputSpec=[{ndim:3}]}getConfig(){const t=super.getConfig();return delete t.rank,delete t.dataFormat,t}static verifyArgs(t){if("number"!=typeof t.kernelSize&&!jW(t.kernelSize,"number",1,1))throw new AW(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(t.kernelSize)}.`)}}wK.className="Conv1D",rF(wK);class SK extends bX{constructor(t){super(t),"number"==typeof t.cropping?this.cropping=[[t.cropping,t.cropping],[t.cropping,t.cropping]]:"number"==typeof t.cropping[0]?this.cropping=[[t.cropping[0],t.cropping[0]],[t.cropping[1],t.cropping[1]]]:this.cropping=t.cropping,this.dataFormat=void 0===t.dataFormat?"channelsLast":t.dataFormat,this.inputSpec=[{ndim:4}]}computeOutputShape(t){return"channelsFirst"===this.dataFormat?[t[0],t[1],t[2]-this.cropping[0][0]-this.cropping[0][1],t[3]-this.cropping[1][0]-this.cropping[1][1]]:[t[0],t[1]-this.cropping[0][0]-this.cropping[0][1],t[2]-this.cropping[1][0]-this.cropping[1][1],t[3]]}call(t,e){return ED((()=>{if(t=hX(t),"channelsLast"===this.dataFormat){const e=Oz(t,this.cropping[0][0],t.shape[1]-this.cropping[0][0]-this.cropping[0][1],2);return Oz(e,this.cropping[1][0],t.shape[2]-this.cropping[1][1]-this.cropping[1][0],3)}{const e=Oz(t,this.cropping[0][0],t.shape[2]-this.cropping[0][0]-this.cropping[0][1],3);return Oz(e,this.cropping[1][0],t.shape[3]-this.cropping[1][1]-this.cropping[1][0],4)}}))}getConfig(){const t={cropping:this.cropping,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}SK.className="Cropping2D",rF(SK);class xK extends bX{constructor(t){var e;super(t),this.DEFAULT_SIZE=[2,2],this.inputSpec=[{ndim:4}],this.size=null==t.size?this.DEFAULT_SIZE:t.size,this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,lz(this.dataFormat),this.interpolation=null==t.interpolation?"nearest":t.interpolation,e=this.interpolation,XW(iz,"InterpolationFormat",e)}computeOutputShape(t){if("channelsFirst"===this.dataFormat){const e=null==t[2]?null:this.size[0]*t[2],n=null==t[3]?null:this.size[1]*t[3];return[t[0],t[1],e,n]}{const e=null==t[1]?null:this.size[0]*t[1],n=null==t[2]?null:this.size[1]*t[2];return[t[0],e,n,t[3]]}}call(t,e){return ED((()=>{let e=hX(t);const n=e.shape;if("channelsFirst"===this.dataFormat){e=qF(e,[0,2,3,1]);const t=this.size[0]*n[2],i=this.size[1]*n[3],s="nearest"===this.interpolation?JY.resizeNearestNeighbor(e,[t,i]):JY.resizeBilinear(e,[t,i]);return qF(s,[0,3,1,2])}{const t=this.size[0]*n[1],i=this.size[1]*n[2];return"nearest"===this.interpolation?JY.resizeNearestNeighbor(e,[t,i]):JY.resizeBilinear(e,[t,i])}}))}getConfig(){const t={size:this.size,dataFormat:this.dataFormat,interpolation:this.interpolation},e=super.getConfig();return Object.assign(t,e),t}}xK.className="UpSampling2D",rF(xK);class RK extends gK{constructor(t){super(2,t),this.depthwiseKernel=null,this.depthMultiplier=null==t.depthMultiplier?1:t.depthMultiplier,this.depthwiseInitializer=oX(t.depthwiseInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.depthwiseConstraint=YX(t.depthwiseConstraint),this.depthwiseRegularizer=eK(t.depthwiseRegularizer)}build(t){if((t=pX(t)).length<4)throw new AW(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(t)}.`);const e="channelsFirst"===this.dataFormat?1:3;if(null==t[e]||t[e]<0)throw new AW(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${t[e]}).`);const n=t[e],i=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",i,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(t,e){return ED((()=>{let e=
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function(t,e,n=[1,1],i="valid",s,r){return ED((()=>{null==s&&(s="channelsLast"),lz(s);let a=pK(t,s);if(4!==t.rank)throw new AW(`Input for depthwiseConv2d is required to be 4-D, but is instead ${t.rank}-D`);if(4!==e.rank)throw new AW(`depthwiseKernel is required to be 4-D, but is instead ${e.rank}-D`);return a=eB(a,e,n,"same"===i?"same":"valid","NHWC",r),"channelsFirst"===s&&(a=qF(a,[0,3,1,2])),a}))}(t=hX(t),this.depthwiseKernel.read(),this.strides,this.padding,this.dataFormat,null);return this.useBias&&(e=Pz(e,this.bias.read(),this.dataFormat)),null!=this.activation&&(e=this.activation.apply(e)),e}))}computeOutputShape(t){t=pX(t);const e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2],i="channelsFirst"===this.dataFormat?t[1]*this.depthMultiplier:t[3]*this.depthMultiplier,s=uK(e,this.kernelSize[0],this.padding,this.strides[0]),r=uK(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[t[0],i,s,r]:[t[0],s,r,i]}getConfig(){const t=super.getConfig();return t.depthMultiplier=this.depthMultiplier,t.depthwiseInitializer=aX(this.depthwiseInitializer),t.depthwiseRegularizer=Zq(this.depthwiseRegularizer),t.depthwiseConstraint=VX(this.depthwiseRegularizer),t}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function OK(t,e,n,i){if(Array.isArray(t)){if(null!=e||null!=n)throw new AW("When inputs is an array, neither initialState or constants should be provided");null!=i&&(n=t.slice(t.length-i,t.length),t=t.slice(0,t.length-i)),t.length>1&&(e=t.slice(1,t.length)),t=t[0]}function s(t){return null==t||Array.isArray(t)?t:[t]}return{inputs:t,initialState:e=s(e),constants:n=s(n)}}function AK(t,e,n,i=!1,s,r,a=!1,o=!1){return ED((()=>{const l=e.shape.length;if(l<3)throw new AW(`Input should be at least 3D, but is ${l}D.`);const u=[1,0].concat(Ez(2,l));if(e=qF(e,u),null!=r)throw new MW("The rnn() functoin of the deeplearn.js backend does not support constants yet.");a&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=s&&((s=PL(PL(s,"bool"),"float32")).rank===l-1&&(s=RB(s,-1)),s=qF(s,u)),i&&(e=HV(e,0),null!=s&&(s=HV(s,0)));const h=[];let p,c=n;const d=e.shape[0],f=AU(e);let m,g;null!=s&&(m=AU(s));for(let e=0;e<d;++e){const n=f[e],i=ED((()=>t(n,c)));if(null==s)p=i[0],c=i[1];else{const t=ED((()=>{const t=m[e],n=cF(gV(t),t);return{output:VL(GL(i[0],t),GL(c[0],n)),newStates:c.map(((e,s)=>VL(GL(i[1][s],t),GL(e,n))))}}));p=t.output,c=t.newStates}o&&h.push(p)}if(o){g=mU(h,1)}return[p,g,c]}))}RK.className="DepthwiseConv2D",rF(RK);class MK extends bX{constructor(t){let e;if(super(t),null==t.cell)throw new AW("cell property is missing for the constructor of RNN.");if(e=Array.isArray(t.cell)?new $K({cells:t.cell}):t.cell,null==e.stateSize)throw new AW("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");this.cell=e,this.returnSequences=null!=t.returnSequences&&t.returnSequences,this.returnState=null!=t.returnState&&t.returnState,this.goBackwards=null!=t.goBackwards&&t.goBackwards,this._stateful=null!=t.stateful&&t.stateful,this.unroll=null!=t.unroll&&t.unroll,this.supportsMasking=!0,this.inputSpec=[new _X({ndim:3})],this.stateSpec=null,this.states_=null,this.numConstants=null,this.keptStates=[]}getStates(){if(null==this.states_){return Ez(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map((t=>null))}return this.states_}setStates(t){this.states_=t}computeOutputShape(t){lX(t)&&(t=t[0]);let e=this.cell.stateSize;Array.isArray(e)||(e=[e]);const n=e[0];let i;if(i=this.returnSequences?[t[0],t[1],n]:[t[0],n],this.returnState){const n=[];for(const i of e)n.push([t[0],i]);return[i].concat(n)}return i}computeMask(t,e){return ED((()=>{Array.isArray(e)&&(e=e[0]);const t=this.returnSequences?e:null;if(this.returnState){const e=this.states.map((t=>null));return[t].concat(e)}return t}))}get states(){if(null==this.states_){const t=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,e=[];for(let n=0;n<t;++n)e.push(null);return e}return this.states_}set states(t){this.states_=t}build(t){if(null!=this.numConstants)throw new MW("Constants support is not implemented in RNN yet.");lX(t)&&(t=t[0]);const e=this.stateful?t[0]:null,n=t.slice(2);this.inputSpec[0]=new _X({shape:[e,null,...n]});const i=[t[0]].concat(t.slice(2));let s;if(this.cell.build(i),s=Array.isArray(this.cell.stateSize)?this.cell.stateSize:[this.cell.stateSize],null!=this.stateSpec){if(!vO(this.stateSpec.map((t=>t.shape[t.shape.length-1])),s))throw new AW(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`)}else this.stateSpec=s.map((t=>new _X({shape:[null,t]})));this.stateful&&this.resetStates()}resetStates(t,e=!1){ED((()=>{if(!this.stateful)throw new RW("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape[0];if(null==n)throw new AW("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.states_)Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((t=>aV([n,t]))):this.states_=[aV([n,this.cell.stateSize])];else if(null==t)bD(this.states_),null!=this.keptStates&&(bD(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((t=>aV([n,t]))):this.states_[0]=aV([n,this.cell.stateSize]);else{if(Array.isArray(t)||(t=[t]),t.length!==this.states_.length)throw new AW(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${t.length} state value(s). Input received: ${t}`);!0===e?this.keptStates.push(this.states_.slice()):bD(this.states_);for(let e=0;e<this.states_.length;++e){const i=t[e],s=Array.isArray(this.cell.stateSize)?this.cell.stateSize[e]:this.cell.stateSize,r=[n,s];if(!vO(i.shape,r))throw new AW(`State ${e} is incompatible with layer ${this.name}: expected shape=${r}, received shape=${i.shape}`);this.states_[e]=i}}this.states_=this.states_.map((t=>vD(t.clone())))}))}apply(t,e){let n=null==e?null:e.initialState,i=null==e?null:e.constants;null==e&&(e={});const s=OK(t,n,i,this.numConstants);t=s.inputs,n=s.initialState,i=s.constants;let r=[],a=[];if(null!=n){e.initialState=n,r=r.concat(n),this.stateSpec=[];for(const t of n)this.stateSpec.push(new _X({shape:t.shape}));a=a.concat(this.stateSpec)}null!=i&&(e.constants=i,r=r.concat(i),this.numConstants=i.length);if(r[0]instanceof TX){const n=[t].concat(r),i=this.inputSpec.concat(a),s=this.inputSpec;this.inputSpec=i;const o=super.apply(n,e);return this.inputSpec=s,o}return super.apply(t,e)}call(t,e){return ED((()=>{const n=null==e?null:e.mask,i=null==e?null:e.training;let s=null==e?null:e.initialState;t=hX(t),null==s&&(s=this.stateful?this.states_:this.getInitialState(t));const r=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1;if(s.length!==r)throw new AW(`RNN Layer has ${r} state(s) but was passed ${s.length} initial state(s).`);this.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");const a={training:i},o=AK(((t,e)=>{const n=this.cell.call([t].concat(e),a);return[n[0],n.slice(1)]}),t,s,this.goBackwards,n,null,this.unroll,this.returnSequences),l=o[0],u=o[1],h=o[2];this.stateful&&this.resetStates(h,i);const p=this.returnSequences?u:l;return this.returnState?[p].concat(h):p}))}getInitialState(t){return ED((()=>{let e=aV(t.shape);return e=bB(e,[1,2]),e=Sz(e),Array.isArray(this.cell.stateSize)?this.cell.stateSize.map((t=>t>1?Cz(e,[1,t]):e)):this.cell.stateSize>1?[Cz(e,[1,this.cell.stateSize])]:[e]}))}get trainableWeights(){return this.trainable?this.cell.trainableWeights:[]}get nonTrainableWeights(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}setFastWeightInitDuringBuild(t){super.setFastWeightInitDuringBuild(t),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(t)}getConfig(){const t=super.getConfig(),e={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(e.numConstants=this.numConstants);const n=this.cell.getConfig();return this.getClassName()===MK.className&&(e.cell={className:this.cell.getClassName(),config:n}),Object.assign(Object.assign(Object.assign({},n),t),e)}static fromConfig(t,e,n={}){const i=yj(e.cell,n);return new t(Object.assign(e,{cell:i}))}}MK.className="RNN",rF(MK);class CK extends bX{}class NK extends CK{constructor(t){super(t),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=t.units,qW(this.units,"units"),this.activation=jq(null==t.activation?this.DEFAULT_ACTIVATION:t.activation),this.useBias=null==t.useBias||t.useBias,this.kernelInitializer=oX(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=oX(t.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=oX(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=eK(t.kernelRegularizer),this.recurrentRegularizer=eK(t.recurrentRegularizer),this.biasRegularizer=eK(t.biasRegularizer),this.kernelConstraint=YX(t.kernelConstraint),this.recurrentConstraint=YX(t.recurrentConstraint),this.biasConstraint=YX(t.biasConstraint),this.dropout=yz([1,Iz([0,null==t.dropout?0:t.dropout])]),this.recurrentDropout=yz([1,Iz([0,null==t.recurrentDropout?0:t.recurrentDropout])]),this.dropoutFunc=t.dropoutFunc,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(t){t=pX(t),this.kernel=this.addWeight("kernel",[t[t.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(t,e){return ED((()=>{if(2!==t.length)throw new AW(`SimpleRNNCell expects 2 input Tensors, got ${t.length}.`);let n=t[1];t=t[0];const i=null!=e.training&&e.training;let s;0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=BK({ones:()=>gV(t),rate:this.dropout,training:i,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=BK({ones:()=>gV(n),rate:this.recurrentDropout,training:i,dropoutFunc:this.dropoutFunc}));const r=this.dropoutMask,a=this.recurrentDropoutMask;s=kz(null!=r?GL(t,r):t,this.kernel.read()),null!=this.bias&&(s=Pz(s,this.bias.read())),null!=a&&(n=GL(n,a));let o=VL(s,kz(n,this.recurrentKernel.read()));return null!=this.activation&&(o=this.activation.apply(o)),[o,o]}))}getConfig(){const t=super.getConfig(),e={units:this.units,activation:zq(this.activation),useBias:this.useBias,kernelInitializer:aX(this.kernelInitializer),recurrentInitializer:aX(this.recurrentInitializer),biasInitializer:aX(this.biasInitializer),kernelRegularizer:Zq(this.kernelRegularizer),recurrentRegularizer:Zq(this.recurrentRegularizer),biasRegularizer:Zq(this.biasRegularizer),activityRegularizer:Zq(this.activityRegularizer),kernelConstraint:VX(this.kernelConstraint),recurrentConstraint:VX(this.recurrentConstraint),biasConstraint:VX(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign(Object.assign({},t),e)}}NK.className="SimpleRNNCell",rF(NK);class kK extends MK{constructor(t){t.cell=new NK(t),super(t)}call(t,e){return ED((()=>{null!=this.cell.dropoutMask&&(bD(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(bD(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==e?null:e.mask,i=null==e?null:e.training,s=null==e?null:e.initialState;return super.call(t,{mask:n,training:i,initialState:s})}))}static fromConfig(t,e){return new t(e)}}kK.className="SimpleRNN",rF(kK);class DK extends CK{constructor(t){if(super(t),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",t.resetAfter)throw new AW("GRUCell does not support reset_after parameter set to true.");this.units=t.units,qW(this.units,"units"),this.activation=jq(void 0===t.activation?this.DEFAULT_ACTIVATION:t.activation),this.recurrentActivation=jq(void 0===t.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),this.useBias=null==t.useBias||t.useBias,this.kernelInitializer=oX(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=oX(t.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=oX(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelRegularizer=eK(t.kernelRegularizer),this.recurrentRegularizer=eK(t.recurrentRegularizer),this.biasRegularizer=eK(t.biasRegularizer),this.kernelConstraint=YX(t.kernelConstraint),this.recurrentConstraint=YX(t.recurrentConstraint),this.biasConstraint=YX(t.biasConstraint),this.dropout=yz([1,Iz([0,null==t.dropout?0:t.dropout])]),this.recurrentDropout=yz([1,Iz([0,null==t.recurrentDropout?0:t.recurrentDropout])]),this.dropoutFunc=t.dropoutFunc,this.implementation=t.implementation,this.stateSize=this.units,this.dropoutMask=null,this.recurrentDropoutMask=null}build(t){const e=(t=pX(t))[t.length-1];this.kernel=this.addWeight("kernel",[e,3*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,3*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[3*this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0}call(t,e){return ED((()=>{if(2!==t.length)throw new AW(`GRUCell expects 2 input Tensors (inputs, h, c), got ${t.length}.`);const n=null!=e.training&&e.training;let i=t[1];t=t[0],0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=BK({ones:()=>gV(t),rate:this.dropout,training:n,count:3,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=BK({ones:()=>gV(i),rate:this.recurrentDropout,training:n,count:3,dropoutFunc:this.dropoutFunc}));const s=this.dropoutMask,r=this.recurrentDropoutMask;let a,o,l;0<this.dropout&&this.dropout<1&&(t=GL(t,s[0]));let u=kz(t,this.kernel.read());this.useBias&&(u=Pz(u,this.bias.read())),0<this.recurrentDropout&&this.recurrentDropout<1&&(i=GL(i,r[0]));const h=this.recurrentKernel.read(),[p,c]=pU(h,[2*this.units,this.units],h.rank-1),d=kz(i,p),[f,m,g]=pU(u,3,u.rank-1),[_,T]=pU(d,2,d.rank-1);a=this.recurrentActivation.apply(VL(f,_)),o=this.recurrentActivation.apply(VL(m,T));const y=kz(GL(o,i),c);l=this.activation.apply(VL(g,y));const I=VL(GL(a,i),GL(VL(1,XF(a)),l));return[I,I]}))}getConfig(){const t=super.getConfig(),e={units:this.units,activation:zq(this.activation),recurrentActivation:zq(this.recurrentActivation),useBias:this.useBias,kernelInitializer:aX(this.kernelInitializer),recurrentInitializer:aX(this.recurrentInitializer),biasInitializer:aX(this.biasInitializer),kernelRegularizer:Zq(this.kernelRegularizer),recurrentRegularizer:Zq(this.recurrentRegularizer),biasRegularizer:Zq(this.biasRegularizer),activityRegularizer:Zq(this.activityRegularizer),kernelConstraint:VX(this.kernelConstraint),recurrentConstraint:VX(this.recurrentConstraint),biasConstraint:VX(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return Object.assign(Object.assign({},t),e)}}DK.className="GRUCell",rF(DK);class LK extends MK{constructor(t){0===t.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),t.cell=new DK(t),super(t)}call(t,e){return ED((()=>{null!=this.cell.dropoutMask&&(bD(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(bD(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==e?null:e.mask,i=null==e?null:e.training,s=null==e?null:e.initialState;return super.call(t,{mask:n,training:i,initialState:s})}))}static fromConfig(t,e){return 0===e.implmentation&&(e.implementation=1),new t(e)}}LK.className="GRU",rF(LK);class FK extends CK{constructor(t){super(t),this.DEFAULT_ACTIVATION="tanh",this.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_RECURRENT_INITIALIZER="orthogonal",this.DEFAULT_BIAS_INITIALIZER="zeros",this.units=t.units,qW(this.units,"units"),this.activation=jq(void 0===t.activation?this.DEFAULT_ACTIVATION:t.activation),this.recurrentActivation=jq(void 0===t.recurrentActivation?this.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),this.useBias=null==t.useBias||t.useBias,this.kernelInitializer=oX(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.recurrentInitializer=oX(t.recurrentInitializer||this.DEFAULT_RECURRENT_INITIALIZER),this.biasInitializer=oX(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.unitForgetBias=t.unitForgetBias,this.kernelRegularizer=eK(t.kernelRegularizer),this.recurrentRegularizer=eK(t.recurrentRegularizer),this.biasRegularizer=eK(t.biasRegularizer),this.kernelConstraint=YX(t.kernelConstraint),this.recurrentConstraint=YX(t.recurrentConstraint),this.biasConstraint=YX(t.biasConstraint),this.dropout=yz([1,Iz([0,null==t.dropout?0:t.dropout])]),this.recurrentDropout=yz([1,Iz([0,null==t.recurrentDropout?0:t.recurrentDropout])]),this.dropoutFunc=t.dropoutFunc,this.implementation=t.implementation,this.stateSize=[this.units,this.units],this.dropoutMask=null,this.recurrentDropoutMask=null}build(t){var e;const n=(t=pX(t))[t.length-1];let i;if(this.kernel=this.addWeight("kernel",[n,4*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,4*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){if(this.unitForgetBias){const t=this.biasInitializer,n=this.units;i=new((e=class extends Yz{apply(e,i){const s=t.apply([n]),r=(new Hz).apply([n]),a=t.apply([2*n]);return Mz(Mz(s,r),a)}}).className="CustomInit",e)}else i=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,i,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0}call(t,e){return ED((()=>{const n=null!=e.training&&e.training;if(3!==t.length)throw new AW(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${t.length}.`);let i=t[1];const s=t[2];t=t[0],0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=BK({ones:()=>gV(t),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc})),0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=BK({ones:()=>gV(i),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const r=this.dropoutMask,a=this.recurrentDropoutMask;let o,l,u,h;0<this.dropout&&this.dropout<1&&(t=GL(t,r[0]));let p=kz(t,this.kernel.read());0<this.recurrentDropout&&this.recurrentDropout<1&&(i=GL(i,a[0])),p=VL(p,kz(i,this.recurrentKernel.read())),this.useBias&&(p=Pz(p,this.bias.read()));const[c,d,f,m]=pU(p,4,p.rank-1);o=this.recurrentActivation.apply(c),l=this.recurrentActivation.apply(d),u=VL(GL(l,s),GL(o,this.activation.apply(f))),h=this.recurrentActivation.apply(m);const g=GL(h,this.activation.apply(u));return[g,g,u]}))}getConfig(){const t=super.getConfig(),e={units:this.units,activation:zq(this.activation),recurrentActivation:zq(this.recurrentActivation),useBias:this.useBias,kernelInitializer:aX(this.kernelInitializer),recurrentInitializer:aX(this.recurrentInitializer),biasInitializer:aX(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:Zq(this.kernelRegularizer),recurrentRegularizer:Zq(this.recurrentRegularizer),biasRegularizer:Zq(this.biasRegularizer),activityRegularizer:Zq(this.activityRegularizer),kernelConstraint:VX(this.kernelConstraint),recurrentConstraint:VX(this.recurrentConstraint),biasConstraint:VX(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return Object.assign(Object.assign({},t),e)}}FK.className="LSTMCell",rF(FK);class PK extends MK{constructor(t){0===t.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),t.cell=new FK(t),super(t)}call(t,e){return ED((()=>{null!=this.cell.dropoutMask&&(bD(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(bD(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null);const n=null==e?null:e.mask,i=null==e?null:e.training,s=null==e?null:e.initialState;return super.call(t,{mask:n,training:i,initialState:s})}))}static fromConfig(t,e){return 0===e.implmentation&&(e.implementation=1),new t(e)}}PK.className="LSTM",rF(PK);class $K extends CK{constructor(t){super(t),this.cells=t.cells}get stateSize(){const t=[];for(const e of this.cells.slice().reverse())Array.isArray(e.stateSize)?t.push(...e.stateSize):t.push(e.stateSize);return t}call(t,e){return ED((()=>{let n=t.slice(1);const i=[];for(const t of this.cells.slice().reverse())Array.isArray(t.stateSize)?i.push(n.splice(0,t.stateSize.length)):i.push(n.splice(0,1));i.reverse();const s=[];let r;for(let a=0;a<this.cells.length;++a){const o=this.cells[a];n=i[a],r=0===a?[t[0]].concat(n):[r[0]].concat(n),r=o.call(r,e),s.push(r.slice(1))}n=[];for(const t of s.slice().reverse())n.push(...t);return[r[0]].concat(n)}))}build(t){let e;lX(t)&&(t=t[0]),this.cells.forEach(((n,i)=>{dz(`RNNCell_${i}`,(()=>{n.build(t),e=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,t=[t[0],e]}))})),this.built=!0}getConfig(){const t=super.getConfig(),e={cells:this.cells.map((t=>({className:t.getClassName(),config:t.getConfig()})))};return Object.assign(Object.assign({},t),e)}static fromConfig(t,e,n={}){const i=[];for(const t of e.cells)i.push(yj(t,n));return new t({cells:i})}get trainableWeights(){if(!this.trainable)return[];const t=[];for(const e of this.cells)t.push(...e.trainableWeights);return t}get nonTrainableWeights(){const t=[];for(const e of this.cells)t.push(...e.nonTrainableWeights);if(!this.trainable){const e=[];for(const t of this.cells)e.push(...t.trainableWeights);return e.concat(t)}return t}getWeights(){const t=[];for(const e of this.cells)t.push(...e.weights);return mX(t)}setWeights(t){const e=[];for(const n of this.cells){const i=n.weights.length,s=t.splice(i);for(let t=0;t<n.weights.length;++t)e.push([n.weights[t],s[t]])}gX(e)}}function BK(t){const{ones:e,rate:n,training:i=!1,count:s=1,dropoutFunc:r}=t,a=()=>null!=r?r(e(),n):$z(e(),n),o=()=>Bz(a,e,i);if(!s||s<=1)return vD(o().clone());return Array(s).fill(void 0).map(o).map((t=>vD(t.clone())))}$K.className="StackedRNNCells",rF($K);
/**
* @license
* Copyright 2020 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
var VK=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(n[i[s]]=t[i[s]])}return n};class UK extends MK{constructor(t){if(t.unroll)throw new MW("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(t.cell))throw new MW("It is not possible at the moment to stack convolutional cells.");super(t),this.inputSpec=[new _X({ndim:5})]}call(t,e){return ED((()=>{if(null!=this.cell.dropoutMask&&(bD(this.cell.dropoutMask),this.cell.dropoutMask=null),null!=this.cell.recurrentDropoutMask&&(bD(this.cell.recurrentDropoutMask),this.cell.recurrentDropoutMask=null),e&&e.constants)throw new AW("ConvRNN2D cell does not support constants");const n=null==e?null:e.mask,i=null==e?null:e.training,s=null==e?null:e.initialState;return super.call(t,{mask:n,training:i,initialState:s})}))}computeOutputShape(t){let e=this.computeSingleOutputShape(t);return this.returnSequences||(e=[e[0],...e.slice(2)]),this.returnState&&(e=[e,...Array(2).fill([t[0],...e.slice(-3)])]),e}getInitialState(t){return ED((()=>{const{stateSize:e}=this.cell,n=t.shape,i=this.computeSingleOutputShape(n),s=aV([i[0],...i.slice(2)]);return Array.isArray(e)?Array(e.length).fill(s):[s]}))}resetStates(t,e=!1){ED((()=>{if(!this.stateful)throw new RW("Cannot call resetStates() on an RNN Layer that is not stateful.");const n=this.inputSpec[0].shape,i=this.computeSingleOutputShape(n),s=[i[0],...i.slice(2)];if(null==n[0])throw new AW("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==this.getStates())Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>aV(s))):this.states_=[aV(s)];else if(null==t)bD(this.states_),null!=this.keptStates&&(bD(this.keptStates),this.keptStates=[]),Array.isArray(this.cell.stateSize)?this.states_=this.cell.stateSize.map((()=>aV(s))):this.states_[0]=aV(s);else{if(Array.isArray(t)||(t=[t]),t.length!==this.states_.length)throw new AW(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${t.length} state value(s). Input received: ${t}`);e?this.keptStates.push(this.states_.slice()):bD(this.states_);for(let e=0;e<this.states_.length;++e){const n=t[e],i=s;if(!vO(n.shape,i))throw new AW(`State ${e} is incompatible with layer ${this.name}: expected shape=${i}, received shape=${n.shape}`);this.states_[e]=n}}this.states_=this.states_.map((t=>vD(t.clone())))}))}computeSingleOutputShape(t){const{dataFormat:e,filters:n,kernelSize:i,padding:s,strides:r,dilationRate:a}=this.cell,o="channelsFirst"===e,l=t[o?3:2],u=t[o?4:3],h=uK(l,i[0],s,r[0],a[0]),p=uK(u,i[1],s,r[1],a[1]);return[...t.slice(0,2),...o?[n,h,p]:[h,p,n]]}}UK.className="ConvRNN2D";class YK extends FK{constructor(t){const{filters:e,kernelSize:n,strides:i,padding:s,dataFormat:r,dilationRate:a}=t;super(Object.assign(Object.assign({},t),{units:e})),this.filters=e,qW(this.filters,"filters"),this.kernelSize=lK(n,2,"kernelSize"),this.kernelSize.forEach((t=>qW(t,"kernelSize"))),this.strides=lK(i||1,2,"strides"),this.strides.forEach((t=>qW(t,"strides"))),this.padding=s||"valid",uz(this.padding),this.dataFormat=r||"channelsLast",lz(this.dataFormat),this.dilationRate=lK(a||1,2,"dilationRate"),this.dilationRate.forEach((t=>qW(t,"dilationRate")))}build(t){var e;t=pX(t);const n="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[n])throw new AW(`The channel dimension of the input should be defined. Found ${t[n]}`);const i=t[n],s=this.kernelSize.concat([i,4*this.filters]);this.kernel=this.addWeight("kernel",s,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);const r=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",r,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){let t;if(this.unitForgetBias){const n=this.biasInitializer,i=this.filters;t=new((e=class extends Yz{apply(t,e){return Az([n.apply([i]),oV([i]),n.apply([2*i])])}}).className="CustomInit",e)}else t=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,t,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0}call(t,e){return ED((()=>{if(3!==t.length)throw new AW(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${t.length}.`);const n=e.training||!1,i=t[0],s=t[1],r=t[2];0<this.dropout&&this.dropout<1&&null==this.dropoutMask&&(this.dropoutMask=BK({ones:()=>gV(i),rate:this.dropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const a=this.dropoutMask,o=(t,e,n)=>e&&e[n]?GL(e[n],t):t;let l=o(i,a,0),u=o(i,a,1),h=o(i,a,2),p=o(i,a,3);0<this.recurrentDropout&&this.recurrentDropout<1&&null==this.recurrentDropoutMask&&(this.recurrentDropoutMask=BK({ones:()=>gV(s),rate:this.recurrentDropout,training:n,count:4,dropoutFunc:this.dropoutFunc}));const c=this.recurrentDropoutMask;let d=o(s,c,0),f=o(s,c,1),m=o(s,c,2),g=o(s,c,3);const[_,T,y,I]=pU(this.kernel.read(),4,3),[E,b,v,w]=this.useBias?pU(this.bias.read(),4):[null,null,null,null];l=this.inputConv(l,_,E,this.padding),u=this.inputConv(u,T,b,this.padding),h=this.inputConv(h,y,v,this.padding),p=this.inputConv(p,I,w,this.padding);const[S,x,R,O]=pU(this.recurrentKernel.read(),4,3);d=this.recurrentConv(d,S),f=this.recurrentConv(f,x),m=this.recurrentConv(m,R),g=this.recurrentConv(g,O);const A=this.recurrentActivation.apply(VL(l,d)),M=this.recurrentActivation.apply(VL(u,f)),C=VL(GL(M,r),GL(A,this.activation.apply(VL(h,m)))),N=GL(this.recurrentActivation.apply(VL(p,g)),this.activation.apply(C));return[N,N,C]}))}getConfig(){const t=super.getConfig(),{units:e}=t,n=VK(t,["units"]),i={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign(Object.assign({},n),i)}inputConv(t,e,n,i){const s=Y$(t,e,this.strides,i||"valid","channelsFirst"===this.dataFormat?"NCHW":"NHWC",this.dilationRate);return n?Pz(s,n,this.dataFormat):s}recurrentConv(t,e){return Y$(t,e,1,"same","channelsFirst"===this.dataFormat?"NCHW":"NHWC")}}YK.className="ConvLSTM2DCell",rF(YK);class GK extends UK{constructor(t){const e=new YK(t);super(Object.assign(Object.assign({},t),{cell:e}))}static fromConfig(t,e){return new t(e)}}GK.className="ConvLSTM2D",rF(GK);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class HK extends bX{constructor(t){super(t),this.rate=Math.max(Math.min(t.rate,1),0),this.noiseShape=t.noiseShape,this.seed=t.seed,this.supportsMasking=!0}getNoiseShape(t){if(null==this.noiseShape)return this.noiseShape;const e=t.shape,n=[];for(let t=0;t<this.noiseShape.length;++t)n.push(null==this.noiseShape[t]?e[t]:this.noiseShape[t]);return n}call(t,e){return ED((()=>{this.invokeCallHook(t,e);const n=hX(t);if(0<this.rate&&this.rate<1){const t=null!=e.training&&e.training,i=this.getNoiseShape(n);return Bz((()=>$z(n,this.rate,i,this.seed)),(()=>n),t)}return t}))}getConfig(){const t={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},e=super.getConfig();return Object.assign(t,e),t}dispose(){return super.dispose()}}HK.className="Dropout",rF(HK);class WK extends HK{constructor(t){super(t),this.inputSpec=[{ndim:3}]}getNoiseShape(t){const e=t.shape;return[e[0],1,e[2]]}}WK.className="SpatialDropout1D",rF(WK);class zK extends bX{constructor(t){if(super(t),this.activation=null,this.useBias=!0,this.kernel=null,this.bias=null,this.DEFAULT_KERNEL_INITIALIZER="glorotNormal",this.DEFAULT_BIAS_INITIALIZER="zeros",null==t.batchInputShape&&null==t.inputShape&&null!=t.inputDim){let e=null;null!=t.batchSize&&(e=t.batchSize),this.batchInputShape=[e,t.inputDim]}this.units=t.units,qW(this.units,"units"),this.activation=jq(t.activation),null!=t.useBias&&(this.useBias=t.useBias),this.kernelInitializer=oX(t.kernelInitializer||this.DEFAULT_KERNEL_INITIALIZER),this.biasInitializer=oX(t.biasInitializer||this.DEFAULT_BIAS_INITIALIZER),this.kernelConstraint=YX(t.kernelConstraint),this.biasConstraint=YX(t.biasConstraint),this.kernelRegularizer=eK(t.kernelRegularizer),this.biasRegularizer=eK(t.biasRegularizer),this.activityRegularizer=eK(t.activityRegularizer),this.supportsMasking=!0,this.inputSpec=[{minNDim:2}]}build(t){const e=(t=pX(t))[t.length-1];null==this.kernel&&(this.kernel=this.addWeight("kernel",[e,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:{[-1]:e}}],this.built=!0}computeOutputShape(t){const e=(t=pX(t)).slice();return e[e.length-1]=this.units,e}call(t,e){return ED((()=>{this.invokeCallHook(t,e);const n=hX(t),i=QW(this.activation.getClassName());let s;return null!=i?s=kz(n,this.kernel.read(),i,this.bias?this.bias.read():null):(s=kz(n,this.kernel.read()),null!=this.bias&&(s=Pz(s,this.bias.read())),null!=this.activation&&(s=this.activation.apply(s))),s}))}getConfig(){const t={units:this.units,activation:zq(this.activation),useBias:this.useBias,kernelInitializer:aX(this.kernelInitializer),biasInitializer:aX(this.biasInitializer),kernelRegularizer:Zq(this.kernelRegularizer),biasRegularizer:Zq(this.biasRegularizer),activityRegularizer:Zq(this.activityRegularizer),kernelConstraint:VX(this.kernelConstraint),biasConstraint:VX(this.biasConstraint)},e=super.getConfig();return Object.assign(t,e),t}}zK.className="Dense",rF(zK);class XK extends bX{constructor(t){super(t=t||{}),this.inputSpec=[{minNDim:3}],this.dataFormat=t.dataFormat}computeOutputShape(t){t=pX(t);for(const e of t.slice(1))if(null==e)throw new AW(`The shape of the input to "Flatten" is not fully defined (got ${t.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`);return[t[0],Tz(t,1)]}call(t,e){return ED((()=>{this.invokeCallHook(t,e);let n=hX(t);if("channelsFirst"===this.dataFormat&&n.rank>1){const t=[0];for(let e=2;e<n.rank;++e)t.push(e);t.push(1),n=qF(n,t)}return function(t){if(t.rank<=1)throw new AW(`batchFlatten requires a minimum rank of 2. Got rank: ${t.rank}.`);const e=[t.shape[0],Tz(t.shape,1)];return y$(t,e)}(n)}))}getConfig(){const t={};null!=this.dataFormat&&(t.dataFormat=this.dataFormat);const e=super.getConfig();return Object.assign(t,e),t}}XK.className="Flatten",rF(XK);class jK extends bX{constructor(t){super(t),this.supportsMasking=!0,this.activation=jq(t.activation)}call(t,e){return ED((()=>{this.invokeCallHook(t,e);const n=hX(t);return this.activation.apply(n)}))}getConfig(){const t={activation:zq(this.activation)},e=super.getConfig();return Object.assign(t,e),t}}jK.className="Activation",rF(jK);class qK extends bX{constructor(t){super(t),this.n=t.n,this.inputSpec=[{ndim:2}]}computeOutputShape(t){return[t[0],this.n,t[1]]}call(t,e){return ED((()=>{return t=hX(t),e=t,n=this.n,ED((()=>{if(2!==e.shape.length)throw new AW(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);return Cz(Sz(e,1),[1,n,1])}));var e,n}))}getConfig(){const t={n:this.n},e=super.getConfig();return Object.assign(t,e),t}}qK.className="RepeatVector",rF(qK);class KK extends bX{constructor(t){super(t),this.targetShape=t.targetShape;for(let t=0;t<this.targetShape.length;++t)this.isUnknown(this.targetShape[t])&&(this.targetShape[t]=null)}isUnknown(t){return t<0||null==t}fixUnknownDimension(t,e){const n="Total size of new array must be unchanged.",i=e.slice();let s=1,r=null;for(let t=0;t<i.length;++t){const e=i[t];if(this.isUnknown(e)){if(null!==r)throw new AW("Can only specifiy one unknown dimension.");r=t}else s*=e}const a=Tz(t);if(null!==r){if(0===s||a%s!=0)throw new AW(n);i[r]=a/s}else if(a!==s)throw new AW(n);return i}computeOutputShape(t){let e=!1;for(let n=0;n<t.length;++n)if(this.isUnknown(t[n])){e=!0;break}return e?t.slice(0,1).concat(this.targetShape):t.slice(0,1).concat(this.fixUnknownDimension(t.slice(1),this.targetShape))}call(t,e){return ED((()=>{this.invokeCallHook(t,e);const n=hX(t),i=n.shape,s=i.slice(0,1).concat(this.fixUnknownDimension(i.slice(1),this.targetShape));return y$(n,s)}))}getConfig(){const t={targetShape:this.targetShape},e=super.getConfig();return Object.assign(t,e),t}}KK.className="Reshape",rF(KK);class QK extends bX{constructor(t){if(super(t),null==t.dims)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(t.dims))throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${t.dims} instead.`);const e=Ez(1,t.dims.length+1);if(!vO(t.dims.slice().sort(),e))throw new Error("Invalid permutation `dims`: "+JSON.stringify(t.dims)+" `dims` must contain consecutive integers starting from 1.");this.dims=t.dims,this.dimsIncludingBatch=[0].concat(this.dims),this.inputSpec=[new _X({ndim:this.dims.length+1})]}computeOutputShape(t){const e=(t=pX(t)).slice();return this.dims.forEach(((n,i)=>{e[i+1]=t[n]})),e}call(t,e){return qF(hX(t),this.dimsIncludingBatch)}getConfig(){const t={dims:this.dims},e=super.getConfig();return Object.assign(t,e),t}}QK.className="Permute",rF(QK);class JK extends bX{constructor(t){super(null==t?{}:t),this.supportsMasking=!0,this.maskValue=null!=t?null==t.maskValue?0:t.maskValue:0}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={maskValue:this.maskValue};return Object.assign(e,t),e}computeMask(t,e){const n=hX(t);return KP(mV(n,this.maskValue),-1)}call(t,e){return ED((()=>{this.invokeCallHook(t,e);const n=hX(t),i=KP(mV(n,this.maskValue),-1,!0);return GL(n,PL(i,n.dtype))}))}}JK.className="Masking",rF(JK);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class ZK extends bX{constructor(t){if(super(t),this.embeddings=null,this.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==t.batchInputShape&&null==t.inputShape){let e=null;null!=t.batchSize&&(e=t.batchSize),null==t.inputLength?this.batchInputShape=[e,null]:this.batchInputShape=[e].concat(PW(t.inputLength))}this.inputDim=t.inputDim,qW(this.inputDim,"inputDim"),this.outputDim=t.outputDim,qW(this.outputDim,"outputDim"),this.embeddingsInitializer=oX(t.embeddingsInitializer||this.DEFAULT_EMBEDDINGS_INITIALIZER),this.embeddingsRegularizer=eK(t.embeddingsRegularizer),this.activityRegularizer=eK(t.activityRegularizer),this.embeddingsConstraint=YX(t.embeddingsConstraint),this.maskZero=t.maskZero,this.supportsMasking=t.maskZero,this.inputLength=t.inputLength}build(t){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0}warnOnIncompatibleInputShape(t){}computeMask(t,e){return ED((()=>this.maskZero?(t=hX(t),mV(t,zL(t))):null))}computeOutputShape(t){if(t=pX(t),null==this.inputLength)return[...t,this.outputDim];const e=PW(this.inputLength);if(e.length!==t.length-1)throw new AW(`"inputLength" is ${this.inputLength}, but received input shape has shape ${t}`);{let n=0;for(let i=0;i<e.length;++i){const s=e[i],r=t[i+1];if(null!=s&&null!=r&&s!==r)throw new AW(`"inputLength" is ${this.inputLength}, but received input shape has shape ${t}`);null==s&&(e[n]=r),n++}}return[t[0],...e,this.outputDim]}call(t,e){return ED((()=>{this.invokeCallHook(t,e);let n=hX(t);"int32"!==n.dtype&&(n=wz(n,"int32"));const i=Dz(this.embeddings.read(),y$(n,[n.size]));return y$(i,pX(this.computeOutputShape(n.shape)))}))}getConfig(){const t={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:aX(this.embeddingsInitializer),embeddingsRegularizer:Zq(this.embeddingsRegularizer),activityRegularizer:Zq(this.activityRegularizer),embeddingsConstraint:VX(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},e=super.getConfig();return Object.assign(t,e),t}}ZK.className="Embedding",rF(ZK);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class tQ extends bX{constructor(t){super(t||{}),this.supportsMasking=!0}mergeFunction(t){throw new MW}computeElementwiseOpOutputShape(t,e){if(null==t||null==e)return null;if(t.length<e.length)return this.computeElementwiseOpOutputShape(e,t);if(0===e.length)return t;const n=t.slice(0,t.length-e.length);for(let i=0;i<e.length;++i){const s=t[t.length-e.length+i],r=e[i];if(null==s||null==r||s<0||r<0)n.push(null);else if(1===s)n.push(r);else if(1===r)n.push(s);else{if(s!==r)throw new AW("Operands could not be broadcast together with shapes "+JSON.stringify(t)+" "+JSON.stringify(e));n.push(s)}}return n}build(t){if(Array.isArray(t)&&!Array.isArray(t[0])&&(t=[pX(t)]),t.length<2)throw new AW(`A merge layer should be called on an Array of at least 2 inputs. Got ${t.length} input(s).`);let e=[];for(const n of t)null!=n&&null!==n[0]&&e.push(n[0]);if(e=WW(e),e.length>1)throw new AW(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(t)}.`);let n=null==t[0]?null:t[0].slice(1);for(let e=1;e<t.length;++e){const i=null==t[e]?null:t[e].slice(1);n=this.computeElementwiseOpOutputShape(n,i)}const i=t.map((t=>t.length));-1===t.indexOf(null)&&1===WW(i).length?this.reshapeRequired=!1:this.reshapeRequired=!0}call(t,e){return ED((()=>{if(this.reshapeRequired){const e=[],n=t.map((t=>t.rank));if(-1===n.indexOf(null)){const i=Iz(n);for(let n of t){const t=n.rank;for(let e=0;e<i-t;++e)n=Sz(n,1);e.push(n)}return this.mergeFunction(e)}{let n=!1;for(const i of t){const t=i.rank;if(null==t){const t=i.shape,s=t[0],r=t.slice(1).concat([s]);let a=y$(i,[s].concat(Tz(t.slice(1))));a=qF(a,[1,0]),a=y$(a,r),e.push(a),n=!0}else if(t>1){const s=Ez(1,t).concat([0]);e.push(qF(i,s)),n=!0}else e.push(i)}let i=this.mergeFunction(e);const s=i.rank;if(n)if(null==s){const t=i.shape,e=t[t.length-1],n=[e].concat(t.slice(0,t.length-1));i=y$(qF(y$(i,[-1,e]),[1,0]),n)}else if(s>1){const t=[s-1].concat(Ez(0,s-1));i=qF(i,t)}return i}}return this.mergeFunction(t)}))}computeOutputShape(t){let e;e=null==t[0]?null:t[0].slice(1);for(let n=1;n<t.length;++n){const i=null==t[n]?null:t[n].slice(1);e=this.computeElementwiseOpOutputShape(e,i)}let n=[];for(const e of t)null!=e&&null!==e[0]&&n.push(e[0]);return n=WW(n),e=1===n.length?n.concat(e):[null].concat(e),e}computeMask(t,e){return ED((()=>{if(null==e)return null;if(!Array.isArray(e))throw new AW("`mask` should be an Array");if(!Array.isArray(t))throw new AW("`inputs` should be an Array");if(e.length!==t.length)throw new AW(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${t.length} vs ${e.length})`);if(e.every((t=>null==t)))return null;let n=(e=e.map((t=>null==t?t:RB(t,0))))[0];for(let t=1;t<e.length-1;++t)n=qB(n,e[t]);return n}))}}class eQ extends tQ{constructor(t){super(t)}mergeFunction(t){return ED((()=>{let e=t[0].clone();for(let n=1;n<t.length;++n)e=VL(e,t[n]);return e}))}}eQ.className="Add",rF(eQ);class nQ extends tQ{constructor(t){super(t)}mergeFunction(t){return ED((()=>{let e=t[0].clone();for(let n=1;n<t.length;++n)e=GL(e,t[n]);return e}))}}nQ.className="Multiply",rF(nQ);class iQ extends tQ{constructor(t){super(t)}mergeFunction(t){return ED((()=>{let e=t[0].clone();for(let n=1;n<t.length;++n)e=VL(e,t[n]);return GL(1/t.length,e)}))}}iQ.className="Average",rF(iQ);class sQ extends tQ{constructor(t){super(t)}mergeFunction(t){return ED((()=>{let e=t[0];for(let n=1;n<t.length;++n)e=TF(e,t[n]);return e}))}}sQ.className="Maximum",rF(sQ);class rQ extends tQ{constructor(t){super(t)}mergeFunction(t){return ED((()=>{let e=t[0];for(let n=1;n<t.length;++n)e=uV(e,t[n]);return e}))}}rQ.className="Minimum",rF(rQ);class aQ extends tQ{constructor(t){super(t),this.DEFAULT_AXIS=-1,null==t&&(t={}),this.axis=null==t.axis?this.DEFAULT_AXIS:t.axis,this.supportsMasking=!0,this.reshapeRequired=!1}build(t){if(!Array.isArray(t)||!Array.isArray(t[0])||1===t.length)throw new AW("A `Concatenate` layer should be called on a list of at least 2 inputs");let e=!0;for(const n of t)if(null!=n){e=!1;break}if(e)return;const n=[];for(let e=0;e<t.length;++e){const i=t[e].slice();i.splice(this.axis,1);let s=!1;for(const t of n)if(vO(t,i)){s=!0;break}s||n.push(i)}if(n.length>1)throw new AW("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(t))}mergeFunction(t){return ED((()=>Az(t,this.axis)))}computeOutputShape(t){if(!Array.isArray(t)||!Array.isArray(t[0]))throw new AW("A `Concatenate` layer should be called on a list of inputs.");const e=t,n=e[0].slice(),i=this.axis<0?n.length+this.axis:this.axis;for(const t of e.slice(1)){if(null==n[i]||null==t[i]){n[i]=null;break}n[i]+=t[i]}return n}computeMask(t,e){if(null==e)return null;if(!Array.isArray(e))throw new AW("`mask` should be an array for Concatenate");if(!Array.isArray(t))throw new AW("`inputs` should be an array for Concatenate");if(e.length!==t.length)throw new AW(`Mismatch in the length of mask (${e.length}) and the legnth of inputs (${t.length})`);return ED((()=>{let n=!0;if(e.forEach((t=>{null==t||(n=!1)})),n)return null;const i=[];for(let n=0;n<t.length;++n)null==e[n]?i.push(PL(gV(t[n]),"bool")):e[n].rank<t[n].rank?i.push(RB(e[n],-1)):i.push(e[n]);const s=b$(i,this.axis);return qP(s,-1,!1)}))}getConfig(){const t={axis:this.axis},e=super.getConfig();return Object.assign(t,e),t}}function oQ(t,e){for(;t<0;)t+=e;return t}aQ.className="Concatenate",rF(aQ);class lQ extends tQ{constructor(t){super(t),this.axes=t.axes,this.normalize=null!=t.normalize&&t.normalize,this.supportsMasking=!0,this.reshapeRequired=!1}build(t){_O(Array.isArray(t)&&2===t.length&&Array.isArray(t[0])&&Array.isArray(t[1]),(()=>"A `Dot` layer should be called on a list of exactly 2 inputs."));const e=t[0],n=t[1];if(e.length>3||n.length>3)throw new MW("Dot layer does not support tensors of 4D or higher rank yet.");const i=this.interpretAxes(e,n);if(e[i[0]]!==n[i[1]])throw new AW(`Dimension incompatibility: ${e[i[0]]} !== ${n[i[1]]}`)}mergeFunction(t){if(2!==t.length)throw new AW(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${t.length} input(s).`);let e,n=t[0],i=t[1];return e=Array.isArray(this.axes)?this.axes.map(((e,n)=>oQ(e,t[n].shape.length))):[oQ(this.axes,n.shape.length),oQ(this.axes,i.shape.length)],this.normalize&&(n=Ij(n,e[0]),i=Ij(i,e[1])),function(t,e,n){if(t.shape.length>3||e.shape.length>3)throw new MW("batchDot is not implemented for tensors of 4D or higher rank yet");if(_O(t.shape.length>=2,(()=>`batchDot requires the rank of x to be >= 2, but got ${t.shape.length}`)),_O(t.shape.length>=2,(()=>`batchDot requires the rank of y to be >= 2, but got ${e.shape.length}`)),"number"==typeof n&&(n=[n,n]),"complex64"===t.dtype||"complex64"===e.dtype)throw new MW("batchDot is not implemented for complex64-type Tensors yet.");const i=t.shape.length,s=e.shape.length;null==n&&(n=[i-1,s-2]);const r=n;return ED((()=>{let n,a;if(i>s){n=i-s;const t=[];for(let e=0;e<n;++e)t.push(1);e=y$(e,e.shape.concat(t))}else if(s>i){n=s-i;const e=[];for(let t=0;t<n;++t)e.push(1);t=y$(t,t.shape.concat(e))}else n=0;if(2===t.shape.length&&2===e.shape.length)a=r[0]===r[1]?bB(GL(t,e),r[0]):bB(GL(qF(t,[1,0]),e),r[1]);else{const n=r[0]!==t.shape.length-1,i=r[1]===e.shape.length-1;a=HF(t,e,n,i)}if(n>0){let t;t=i>s?i+s-3:i-1;const e=[];for(let i=t;i<t+n;++i)e.push(i);a=fU(a,e)}return 1===a.shape.length&&(a=RB(a,1)),a}))}(n,i,e)}interpretAxes(t,e){let n;return n=Array.isArray(this.axes)?this.axes:[oQ(this.axes,t.length),oQ(this.axes,e.length)],n}computeOutputShape(t){_O(Array.isArray(t)&&2===t.length&&Array.isArray(t[0])&&Array.isArray(t[1]),(()=>"A `Dot` layer should be called on a list of exactly 2 inputs."));const e=t[0].slice(),n=t[1].slice();if(e.length>3||n.length>3)throw new MW("Dot layer does not support tensors of 4D or higher rank yet.");const i=this.interpretAxes(e,n);e.splice(i[0],1),n.splice(i[1],1),n.splice(0,1);const s=e.concat(n);return 1===s.length&&s.push(1),s}computeMask(t,e){return null}getConfig(){const t={axes:this.axes,normalize:this.normalize},e=super.getConfig();return Object.assign(t,e),t}}lQ.className="Dot",rF(lQ);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class uQ extends bX{constructor(t){super(t),this.supportsMasking=!0,this.stddev=t.stddev}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={stddev:this.stddev};return Object.assign(e,t),e}call(t,e){return ED((()=>{this.invokeCallHook(t,e);const n=hX(t);return Bz((()=>VL(Nz(n.shape,0,this.stddev),n)),(()=>n),e.training||!1)}))}}uQ.className="GaussianNoise",rF(uQ);class hQ extends bX{constructor(t){super(t),this.supportsMasking=!0,this.rate=t.rate}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={rate:this.rate};return Object.assign(e,t),e}call(t,e){return ED((()=>{this.invokeCallHook(t,e);const n=hX(t);if(this.rate>0&&this.rate<1){return Bz((()=>{const t=Math.sqrt(this.rate/(1-this.rate));return GL(n,Nz(n.shape,1,t))}),(()=>n),e.training||!1)}return n}))}}hQ.className="GaussianDropout",rF(hQ);class pQ extends bX{constructor(t){super(t),this.supportsMasking=!0,this.rate=t.rate,this.noiseShape=t.noiseShape}_getNoiseShape(t){return this.noiseShape||hX(t).shape}computeOutputShape(t){return t}getConfig(){const t=super.getConfig(),e={rate:this.rate};return Object.assign(e,t),e}call(t,e){return ED((()=>{if(this.rate<1&&this.rate>0){const n=this._getNoiseShape(t),i=()=>{const e=hX(t),i=-1.7580993408473766;let s=DB($V(n),this.rate);s=wz(s,"float32");const r=((1-this.rate)*(1+this.rate*i**2))**-.5,a=-r*i*this.rate,o=VL(GL(e,s),GL(VL(s,-1),i));return VL(GL(o,r),a)};return Bz(i,(()=>hX(t)),e.training||!1)}return t}))}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function cQ(t,e,n,i,s,r=.001){let a;if(2===t.rank)a=A$(t,e,n,i,s,r);else if(3===t.rank)a=M$(t,e,n,i,s,r);else{if(4!==t.rank)throw new MW(`batchNormalization is not implemented for array of rank ${t.rank} yet`);a=C$(t,e,n,i,s,r)}return a}function dQ(t,e,n,i,s=.001){return vO(i.slice().sort(),Ez(0,t.rank-1))?function(t,e,n,i,s=.001){return ED((()=>{const r=cV(t,i),a=r.mean,o=r.variance;return[cQ(t,a,o,n,e,s),a,o]}))}(t,e,n,i,s):function(t,e,n,i,s=.001){return ED((()=>{const r=cV(t,i),a=r.mean,o=r.variance,l=[];for(const e of Ez(0,t.rank))-1!==i.indexOf(e)?l.push(1):l.push(t.shape[e]);const u=y$(a,l),h=y$(o,l),p=null==e?null:y$(e,l),c=null==n?null:y$(n,l);return[cQ(t,u,h,c,p,s),a,o]}))}(t,e,n,i,s)}pQ.className="AlphaDropout",rF(pQ);class fQ extends bX{constructor(t){null==t&&(t={}),super(t),this.supportsMasking=!0,this.axis=null==t.axis?-1:t.axis,this.momentum=null==t.momentum?.99:t.momentum,this.epsilon=null==t.epsilon?.001:t.epsilon,this.center=null==t.center||t.center,this.scale=null==t.scale||t.scale,this.betaInitializer=oX(t.betaInitializer||"zeros"),this.gammaInitializer=oX(t.gammaInitializer||"ones"),this.movingMeanInitializer=oX(t.movingMeanInitializer||"zeros"),this.movingVarianceInitializer=oX(t.movingVarianceInitializer||"ones"),this.betaConstraint=YX(t.betaConstraint),this.gammaConstraint=YX(t.gammaConstraint),this.betaRegularizer=eK(t.betaRegularizer),this.gammaRegularizer=eK(t.gammaRegularizer)}build(t){t=pX(t);const e=this.axis>=0?this.axis:this.axis+t.length,n=t[e];if(null==n)throw new AW(`Axis ${e} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(t)}.`);this.inputSpec=[new _X({ndim:t.length,axes:{[e]:n}})];const i=[n];this.scale&&(this.gamma=this.addWeight("gamma",i,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",i,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",i,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",i,null,this.movingVarianceInitializer,null,!1),this.built=!0}call(t,e){return ED((()=>{const n=null!=e.training&&e.training,i=hX(t),s=i.shape,r=s.length,a=Ez(0,r),o=this.axis>=0?this.axis:this.axis+r;a.splice(o,1);const l=kW(1,r);l[o]=s[o];const u=a.slice();u.sort();const h=!vO(u,Ez(0,r).slice(0,r-1));if(!n)return(()=>{if(h){const t=y$(this.movingMean.read(),l),e=y$(this.movingVariance.read(),l),n=this.center?y$(this.beta.read(),l):null,s=this.scale?y$(this.gamma.read(),l):null;return cQ(i,t,e,n,s,this.epsilon)}return cQ(i,this.movingMean.read(),this.movingVariance.read(),null==this.beta?null:this.beta.read(),null==this.gamma?null:this.gamma.read(),this.epsilon)})();const[p,c,d]=dQ(i,this.gamma.read(),this.beta.read(),a,this.epsilon),f=(t,e,n)=>{ED((()=>{const i=1-n,s=t.read(),r=GL(cF(s,e),i);t.write(cF(s,r))}))};return(()=>{f(this.movingMean,c,this.momentum),f(this.movingVariance,d,this.momentum)})(),p}))}getConfig(){const t={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:aX(this.betaInitializer),gammaInitializer:aX(this.gammaInitializer),movingMeanInitializer:aX(this.movingMeanInitializer),movingVarianceInitializer:aX(this.movingVarianceInitializer),betaRegularizer:Zq(this.betaRegularizer),gammaRegularizer:Zq(this.gammaRegularizer),betaConstraint:VX(this.betaConstraint),gammaConstraint:VX(this.gammaConstraint)},e=super.getConfig();return Object.assign(t,e),t}}fQ.className="BatchNormalization",rF(fQ);class mQ extends bX{constructor(t){if(null==t&&(t={}),super(t),this.axis=null==t.axis?-1:t.axis,"number"==typeof this.axis){if(!Number.isInteger(this.axis))throw new Error(`Expected axis to be an integer, but received ${this.axis}`)}else{if(!Array.isArray(this.axis))throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`);for(const t of this.axis)if(!Number.isInteger(t))throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`)}this.epsilon=null==t.epsilon?.001:t.epsilon,this.center=null==t.center||t.center,this.scale=null==t.scale||t.scale,this.betaInitializer=oX(t.betaInitializer||"zeros"),this.gammaInitializer=oX(t.gammaInitializer||"ones"),this.betaRegularizer=eK(t.betaRegularizer),this.gammaRegularizer=eK(t.gammaRegularizer),this.supportsMasking=!0}build(t){const e=(t=pX(t)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(let t=0;t<this.axis.length;++t)this.axis[t]<0&&(this.axis[t]+=e);for(const t of this.axis)if(t<0||t>=e)throw new Error(`Invalid axis: ${t}`);if(this.axis.length!==WW(this.axis).length)throw new Error(`Found duplicate axes in: ${this.axis}`);const n=this.axis.map((e=>t[e])),i=!0;this.scale?this.gamma=this.addWeight("gamma",n,"float32",this.gammaInitializer,this.gammaRegularizer,i):this.gamma=null,this.center?this.beta=this.addWeight("beta",n,"float32",this.betaInitializer,this.betaRegularizer,i):this.beta=null,this.built=!0}call(t,e){const n=hX(t),i=n.shape,s=i.length;return ED((()=>{let{mean:t,variance:e}=cV(n,this.axis,!0);const r=kW(1,s);for(const t of this.axis)r[t]=i[t];const a=t=>null!=t&&t.shape.length!==s?y$(t,r):t;let o=this.scale?a(this.gamma.read()):null,l=this.center?a(this.beta.read()):null;const u=[],h=[];for(let t=0;t<s;++t)-1!==this.axis.indexOf(t)?(u.push(i[t]),h.push(1)):(u.push(1),h.push(i[t]));return t=AB(t,u),e=AB(e,u),null!=o&&(o=AB(o,h)),null!=l&&(l=AB(l,h)),cQ(n,t,e,l,o,this.epsilon)}))}getConfig(){const t={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:aX(this.betaInitializer),gammaInitializer:aX(this.gammaInitializer),betaRegularizer:Zq(this.betaRegularizer),gammaRegularizer:Zq(this.gammaRegularizer)},e=super.getConfig();return Object.assign(t,e),t}}mQ.className="LayerNormalization",rF(mQ);class gQ extends bX{constructor(t){if(null==t&&(t={}),super(t),this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,null==t.padding)this.padding=[[1,1],[1,1]];else if("number"==typeof t.padding)this.padding=[[t.padding,t.padding],[t.padding,t.padding]];else{if(t.padding=t.padding,2!==t.padding.length)throw new AW(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${t.padding.length} array.`);let e,n;if("number"==typeof t.padding[0])e=[t.padding[0],t.padding[0]],n=[t.padding[1],t.padding[1]];else{if(t.padding=t.padding,2!==t.padding[0].length)throw new AW(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${t.padding[0].length} array.`);if(e=t.padding[0],2!==t.padding[1].length)throw new AW(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${t.padding[1].length} array.`);n=t.padding[1]}this.padding=[e,n]}this.inputSpec=[new _X({ndim:4})]}computeOutputShape(t){let e,n;return t=pX(t),"channelsFirst"===this.dataFormat?(e=null!=t[2]&&t[2]>=0?t[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=t[3]&&t[3]>=0?t[3]+this.padding[1][0]+this.padding[1][1]:null,[t[0],t[1],e,n]):(e=null!=t[1]&&t[1]>=0?t[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=t[2]&&t[2]>=0?t[2]+this.padding[1][0]+this.padding[1][1]:null,[t[0],e,n,t[3]])}call(t,e){return ED((()=>{return e=hX(t),n=this.padding,i=this.dataFormat,ED((()=>{if(4!==e.rank)throw new AW(`temporalPadding expects input tensor to be 4-D, but received a ${e.rank}-D tensor.`);if(null==n&&(n=[[1,1],[1,1]]),2!==n.length||2!==n[0].length||2!==n[1].length)throw new AW("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==i&&(i="channelsLast"),"channelsLast"!==i&&"channelsFirst"!==i)throw new AW(`Unknown data format: ${i}. Supported data formats are 'channelsLast' and 'channelsFirst.`);let t;return t="channelsFirst"===i?[[0,0],[0,0],n[0],n[1]]:[[0,0],n[0],n[1],[0,0]],TV(e,t)}));var e,n,i}))}getConfig(){const t={padding:this.padding,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function _Q(t,e,n,i,s,r){return ED((()=>{let a;lz(s),hz(r),uz(i),null==n&&(n=[1,1]),null==i&&(i="valid"),null==s&&(s="channelsLast"),null==r&&(r="max"),t=pK(t,s);const o="same"===i?"same":"valid";return a="max"===r?nV(t,e,n,o):I$(t,e,n,o),"channelsFirst"===s&&(a=qF(a,[0,3,1,2])),a}))}function TQ(t,e,n,i,s,r){return ED((()=>{let a;lz(s),hz(r),uz(i),null==n&&(n=[1,1,1]),null==i&&(i="valid"),null==s&&(s="channelsLast"),null==r&&(r="max"),t=cK(t,s);const o="same"===i?"same":"valid";return a="max"===r?iV(t,e,n,o):E$(t,e,n,o),"channelsFirst"===s&&(a=qF(a,[0,4,1,2,3])),a}))}gQ.className="ZeroPadding2D",rF(gQ);class yQ extends bX{constructor(t){if(null==t.poolSize&&(t.poolSize=2),super(t),"number"==typeof t.poolSize)this.poolSize=[t.poolSize];else{if(!Array.isArray(t.poolSize)||1!==t.poolSize.length||"number"!=typeof t.poolSize[0])throw new AW(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(t.poolSize)}`);this.poolSize=t.poolSize}if(qW(this.poolSize,"poolSize"),null==t.strides)this.strides=this.poolSize;else if("number"==typeof t.strides)this.strides=[t.strides];else{if(!Array.isArray(t.strides)||1!==t.strides.length||"number"!=typeof t.strides[0])throw new AW(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(t.strides)}`);this.strides=t.strides}qW(this.strides,"strides"),this.padding=null==t.padding?"valid":t.padding,uz(this.padding),this.inputSpec=[new _X({ndim:3})]}computeOutputShape(t){const e=uK((t=pX(t))[1],this.poolSize[0],this.padding,this.strides[0]);return[t[0],e,t[2]]}call(t,e){return ED((()=>{this.invokeCallHook(t,e),t=Sz(hX(t),2);const n=this.poolingFunction(hX(t),[this.poolSize[0],1],[this.strides[0],1],this.padding,"channelsLast");return fU(n,[2])}))}getConfig(){const t={poolSize:this.poolSize,padding:this.padding,strides:this.strides},e=super.getConfig();return Object.assign(t,e),t}}class IQ extends yQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return lz(s),uz(i),_Q(t,e,n,i,s,"max")}}IQ.className="MaxPooling1D",rF(IQ);class EQ extends yQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return lz(s),uz(i),_Q(t,e,n,i,s,"avg")}}EQ.className="AveragePooling1D",rF(EQ);class bQ extends bX{constructor(t){if(null==t.poolSize&&(t.poolSize=[2,2]),super(t),this.poolSize=Array.isArray(t.poolSize)?t.poolSize:[t.poolSize,t.poolSize],null==t.strides)this.strides=this.poolSize;else if(Array.isArray(t.strides)){if(2!==t.strides.length)throw new AW(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${t.strides.length}.`);this.strides=t.strides}else this.strides=[t.strides,t.strides];qW(this.poolSize,"poolSize"),qW(this.strides,"strides"),this.padding=null==t.padding?"valid":t.padding,this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,lz(this.dataFormat),uz(this.padding),this.inputSpec=[new _X({ndim:4})]}computeOutputShape(t){t=pX(t);let e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2];return e=uK(e,this.poolSize[0],this.padding,this.strides[0]),n=uK(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[t[0],t[1],e,n]:[t[0],e,n,t[3]]}call(t,e){return ED((()=>(this.invokeCallHook(t,e),this.poolingFunction(hX(t),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const t={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}class vQ extends bQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return lz(s),uz(i),_Q(t,e,n,i,s,"max")}}vQ.className="MaxPooling2D",rF(vQ);class wQ extends bQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return lz(s),uz(i),_Q(t,e,n,i,s,"avg")}}wQ.className="AveragePooling2D",rF(wQ);class SQ extends bX{constructor(t){if(null==t.poolSize&&(t.poolSize=[2,2,2]),super(t),this.poolSize=Array.isArray(t.poolSize)?t.poolSize:[t.poolSize,t.poolSize,t.poolSize],null==t.strides)this.strides=this.poolSize;else if(Array.isArray(t.strides)){if(3!==t.strides.length)throw new AW(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${t.strides.length}.`);this.strides=t.strides}else this.strides=[t.strides,t.strides,t.strides];qW(this.poolSize,"poolSize"),qW(this.strides,"strides"),this.padding=null==t.padding?"valid":t.padding,this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,lz(this.dataFormat),uz(this.padding),this.inputSpec=[new _X({ndim:5})]}computeOutputShape(t){t=pX(t);let e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2],i="channelsFirst"===this.dataFormat?t[4]:t[3];return e=uK(e,this.poolSize[0],this.padding,this.strides[0]),n=uK(n,this.poolSize[1],this.padding,this.strides[1]),i=uK(i,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[t[0],t[1],e,n,i]:[t[0],e,n,i,t[4]]}call(t,e){return ED((()=>(this.invokeCallHook(t,e),this.poolingFunction(hX(t),this.poolSize,this.strides,this.padding,this.dataFormat))))}getConfig(){const t={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}class xQ extends SQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return lz(s),uz(i),TQ(t,e,n,i,s,"max")}}xQ.className="MaxPooling3D",rF(xQ);class RQ extends SQ{constructor(t){super(t)}poolingFunction(t,e,n,i,s){return lz(s),uz(i),TQ(t,e,n,i,s,"avg")}}RQ.className="AveragePooling3D",rF(RQ);class OQ extends bX{constructor(t){super(t),this.inputSpec=[new _X({ndim:3})]}computeOutputShape(t){return[t[0],t[2]]}call(t,e){throw new MW}}class AQ extends OQ{constructor(t){super(t||{})}call(t,e){return ED((()=>{const e=hX(t);return rV(e,1)}))}}AQ.className="GlobalAveragePooling1D",rF(AQ);class MQ extends OQ{constructor(t){super(t||{})}call(t,e){return ED((()=>{const e=hX(t);return IB(e,1)}))}}MQ.className="GlobalMaxPooling1D",rF(MQ);class CQ extends bX{constructor(t){super(t),this.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,lz(this.dataFormat),this.inputSpec=[new _X({ndim:4})]}computeOutputShape(t){return"channelsLast"===this.dataFormat?[t[0],t[3]]:[t[0],t[1]]}call(t,e){throw new MW}getConfig(){const t={dataFormat:this.dataFormat},e=super.getConfig();return Object.assign(t,e),t}}class NQ extends CQ{call(t,e){return ED((()=>{const e=hX(t);return"channelsLast"===this.dataFormat?rV(e,[1,2]):rV(e,[2,3])}))}}NQ.className="GlobalAveragePooling2D",rF(NQ);class kQ extends CQ{call(t,e){return ED((()=>{const e=hX(t);return"channelsLast"===this.dataFormat?IB(e,[1,2]):IB(e,[2,3])}))}}kQ.className="GlobalMaxPooling2D",rF(kQ);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class DQ extends bX{constructor(t){super(t),this.layer=t.layer}build(t){this.built=!0}get trainable(){return null!=this.layer&&this.layer.trainable}set trainable(t){null!=this.layer&&(this.layer.trainable=t)}get trainableWeights(){return this.layer.trainableWeights}get nonTrainableWeights(){return this.layer.nonTrainableWeights}get updates(){return this.layer._updates}get losses(){return this.layer.losses}getWeights(){return this.layer.getWeights()}setWeights(t){this.layer.setWeights(t)}getConfig(){const t={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},e=super.getConfig();return Object.assign(t,e),t}setFastWeightInitDuringBuild(t){super.setFastWeightInitDuringBuild(t),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(t)}static fromConfig(t,e,n={}){const i=yj(e.layer,n);delete e.layer;const s={layer:i};return Object.assign(s,e),new t(s)}}class LQ extends DQ{constructor(t){super(t),this.supportsMasking=!0}build(t){if((t=pX(t)).length<3)throw new AW(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(t)}`);this.inputSpec=[{shape:t}];const e=[t[0]].concat(t.slice(2));this.layer.built||(this.layer.build(e),this.layer.built=!0),super.build(t)}computeOutputShape(t){const e=[(t=pX(t))[0]].concat(t.slice(2)),n=this.layer.computeOutputShape(e),i=t[1];return[n[0],i].concat(n.slice(1))}call(t,e){return ED((()=>AK(((t,n)=>[hX(this.layer.call(t,e)),[]]),t=hX(t),[],!1,null,null,!1,!0)[1]))}}LQ.className="TimeDistributed",rF(LQ);class FQ extends DQ{constructor(t){super(t);const e=t.layer.getConfig(),n={};n.className=t.layer.getClassName(),n.config=e,this.forwardLayer=yj(n),e.goBackwards=!0!==e.goBackwards;const i={};var s;if(i.className=t.layer.getClassName(),i.config=e,this.backwardLayer=yj(i),this.forwardLayer.name="forward_"+this.forwardLayer.name,this.backwardLayer.name="backward_"+this.backwardLayer.name,this.mergeMode=void 0===t.mergeMode?"concat":t.mergeMode,s=this.mergeMode,XW(az,"BidirectionalMergeMode",s),t.weights)throw new MW("weights support is not implemented for Bidirectional layer yet.");this._stateful=t.layer.stateful,this.returnSequences=t.layer.returnSequences,this.returnState=t.layer.returnState,this.supportsMasking=!0,this._trainable=!0,this.inputSpec=t.layer.inputSpec,this.numConstants=null}get trainable(){return this._trainable}set trainable(t){this._trainable=t,null!=this.forwardLayer&&(this.forwardLayer.trainable=t),null!=this.backwardLayer&&(this.backwardLayer.trainable=t)}getWeights(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())}setWeights(t){const e=t.length,n=Math.floor(e/2);this.forwardLayer.setWeights(t.slice(0,n)),this.backwardLayer.setWeights(t.slice(n))}computeOutputShape(t){let e,n,i,s=this.forwardLayer.computeOutputShape(t);return Array.isArray(s)&&Array.isArray(s[0])||(s=[s]),this.returnState?(i=s.slice(1),e=s[0]):e=s[0],"concat"===this.mergeMode?(e[e.length-1]*=2,n=[e]):n=null==this.mergeMode?[e,e.slice()]:[e],this.returnState?null==this.mergeMode?n.concat(i).concat(i.slice()):[e].concat(i).concat(i.slice()):FW(n)}apply(t,e){let n=null==e?null:e.initialState,i=null==e?null:e.constants;null==e&&(e={});const s=OK(t,n,i,this.numConstants);if(t=s.inputs,n=s.initialState,i=s.constants,Array.isArray(t)&&(n=t.slice(1),t=t[0]),(null==n||0===n.length)&&null==i)return super.apply(t,e);const r=[],a=[];if(null!=n){const t=n.length;if(t%2>0)throw new AW("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");e.initialState=n,r.push(...n);const i=n.map((t=>new _X({shape:t.shape})));this.forwardLayer.stateSpec=i.slice(0,t/2),this.backwardLayer.stateSpec=i.slice(t/2),a.push(...i)}if(null!=i)throw new MW("Support for constants in Bidirectional layers is not implemented yet.");const o=r[0]instanceof TX;for(const t of r)if(t instanceof TX!==o)throw new AW("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");if(o){const n=[t].concat(r),i=this.inputSpec.concat(a),s=this.inputSpec;this.inputSpec=i;const o=super.apply(n,e);return this.inputSpec=s,o}return super.apply(t,e)}call(t,e){return ED((()=>{const n=e.initialState;let i,s,r,a;if(null==n)i=this.forwardLayer.call(t,e),s=this.backwardLayer.call(t,e);else{const r=n.slice(0,n.length/2),a=n.slice(n.length/2);i=this.forwardLayer.call(t,Object.assign(e,{initialState:r})),s=this.backwardLayer.call(t,Object.assign(e,{initialState:a}))}return this.returnState&&(Array.isArray(i)&&(r=i.slice(1).concat(s.slice(1))),i=i[0],s=s[0]),this.returnSequences&&(s=HV(s,1)),"concat"===this.mergeMode?a=Az([i,s]):"sum"===this.mergeMode?a=VL(i,s):"ave"===this.mergeMode?a=GL(.5,VL(i,s)):"mul"===this.mergeMode?a=GL(i,s):null==this.mergeMode&&(a=[i,s]),this.returnState?null==this.mergeMode?a.concat(r):[a].concat(r):a}))}resetStates(t){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()}build(t){dz(this.forwardLayer.name,(()=>{this.forwardLayer.build(t)})),dz(this.backwardLayer.name,(()=>{this.backwardLayer.build(t)})),this.built=!0}computeMask(t,e){let n;if(Array.isArray(e)&&(e=e[0]),n=this.returnSequences?null==this.mergeMode?[e,e]:e:null==this.mergeMode?[null,null]:null,this.returnState){const t=this.forwardLayer.states.map((t=>null));return Array.isArray(n)?n.concat(t).concat(t):[n].concat(t).concat(t)}return n}get trainableWeights(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}get nonTrainableWeights(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}setFastWeightInitDuringBuild(t){super.setFastWeightInitDuringBuild(t),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(t),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(t)}getConfig(){const t={mergeMode:this.mergeMode},e=super.getConfig();return Object.assign(t,e),t}static fromConfig(t,e){const n=yj(e.layer);if(delete e.layer,null!=e.numConstants)throw new MW("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");const i=e;return i.layer=n,new t(i)}}FQ.className="Bidirectional",rF(FQ);
/**
* @license
* Copyright 2022 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class PQ extends bX{constructor(t){super(t),this.scale=t.scale,t.offset?this.offset=t.offset:this.offset=0}getConfig(){const t={scale:this.scale,offset:this.offset},e=super.getConfig();return Object.assign(t,e),t}call(t,e){return ED((()=>("float32"!==(t=hX(t)).dtype&&(t=wz(t,"float32")),VL(GL(t,this.scale),this.offset))))}}PQ.className="Rescaling",rF(PQ);
/**
* @license
* Copyright 2022 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const{resizeBilinear:$Q,cropAndResize:BQ}=JY;class VQ extends bX{constructor(t){super(t),this.height=t.height,this.width=t.width}centerCrop(t,e,n,i,s,r,a,o){return ED((()=>{let l,u=!1;const h=[e/r,n/a,(i+e)/r,(s+n)/a],p=[];3===t.rank?(u=!0,l=mU([t])):l=t;for(let t=0;t<l.shape[0];t++)p.push(h);const c=hD(p,[p.length,4]),d=VV(0,p.length,1,"int32"),f=BQ(l,c,d,[i,s],"nearest");return wz(u?hX(AU(f)):f,o)}))}upsize(t,e,n,i){return ED((()=>wz($Q(t,[e,n]),i)))}call(t,e){return ED((()=>{const e=hX(t),n=e.dtype,i=e.shape,s=i[i.length-3],r=i[i.length-2];let a=0;s!==this.height&&(a=Math.floor((s-this.height)/2));let o=0;return r!==this.width&&(o=Math.floor((r-this.width)/2),0===o&&(o=1)),a>=0&&o>=0?this.centerCrop(e,a,o,this.height,this.width,s,r,n):this.upsize(t,this.height,this.width,n)}))}getConfig(){const t={height:this.height,width:this.width},e=super.getConfig();return Object.assign(t,e),t}computeOutputShape(t){const e=(t=pX(t)).length-3,n=t.length-2;return t[e]=this.height,t[n]=this.width,t}}VQ.className="CenterCrop",rF(VQ);
/**
* @license
* Copyright 2022 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class UQ extends bX{constructor(t){super(t),this.numTokens=t.numTokens,t.outputMode?this.outputMode=t.outputMode:this.outputMode="multiHot"}getConfig(){const t={numTokens:this.numTokens,outputMode:this.outputMode},e=super.getConfig();return Object.assign(t,e),t}computeOutputShape(t){return null==(t=pX(t))?[this.numTokens]:"oneHot"===this.outputMode&&1!==t[t.length-1]?(t.push(this.numTokens),t):(t[t.length-1]=this.numTokens,t)}call(t,e){return ED((()=>{let n;if("int32"!==(t=hX(t)).dtype&&(t=wz(t,"int32")),void 0!==e.countWeights){if("count"!==this.outputMode)throw new AW(`countWeights is not used when outputMode !== count.\n Received countWeights=${e.countWeights}`);n=hX(e.countWeights)}const i=IB(t),s=EB(t),r=kB(this.numTokens,i).bufferSync().get(0),a=DB(s,0).bufferSync().get(0);if(!r||!a)throw new AW(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`);
/**
* @license
* Copyright 2022 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
return function(t,e,n,i){let s=hX(t);if("int32"!==s.dtype&&(s=wz(s,"int32")),"int"===e)return s;const r=s.shape;if(0===s.rank&&(s=RB(s,-1)),"oneHot"===e&&1!==s.shape[s.shape.length-1]&&(s=RB(s,-1)),s.rank>2)throw new AW(`When outputMode is not int, maximum output rank is 2 Received outputMode ${e} and input shape ${r} which would result in output rank ${s.rank}.`);const a=["multiHot","oneHot"].includes(e),o=s;let l;if(l=Z$(o,void 0!==i&&"count"===e?i:[],n,a),"tfIdf"!==e)return l;if(i)return GL(l,i);throw new AW("When outputMode is 'tfIdf', weights must be provided.")}(t,this.outputMode,this.numTokens,n)}))}}UQ.className="CategoryEncoding",rF(UQ);
/**
* @license
* Copyright 2022 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const YQ=new Set(["bilinear","nearest"]);class GQ extends bX{constructor(t){if(super(t),this.height=t.height,this.width=t.width,t.interpolation){if(!YQ.has(t.interpolation))throw new AW(`Invalid interpolation parameter: ${t.interpolation} is not implemented`);this.interpolation=t.interpolation}else this.interpolation="bilinear";this.cropToAspectRatio=Boolean(t.cropToAspectRatio)}computeOutputShape(t){const e=(t=pX(t))[2];return[this.height,this.width,e]}getConfig(){const t={height:this.height,width:this.width,interpolation:this.interpolation,cropToAspectRatio:this.cropToAspectRatio},e=super.getConfig();return Object.assign(t,e),t}call(t,e){return ED((()=>{const e=[this.height,this.width];if("bilinear"===this.interpolation)return JY.resizeBilinear(t,e,!this.cropToAspectRatio);if("nearest"===this.interpolation)return JY.resizeNearestNeighbor(t,e,!this.cropToAspectRatio);throw new Error(`Interpolation is ${this.interpolation} but only ${[...YQ]} are supported`)}))}}GQ.className="Resizing",rF(GQ);
/**
* @license
* Copyright 2023 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class HQ{constructor(t){this.seed=t}next(){if(void 0!==this.seed)return this.seed++}}HQ.className="RandomSeed";
/**
* @license
* Copyright 2023 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class WQ extends bX{constructor(t){super(t),this.randomGenerator=new HQ(t.seed)}getConfig(){const t={seed:this.randomGenerator.seed},e=super.getConfig();return Object.assign(t,e),t}}WQ.className="BaseRandomLayer";
/**
* @license
* Copyright 2023 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const zQ=new Set(["bilinear","nearest"]);class XQ extends WQ{constructor(t){super(t);const{factor:e,interpolation:n="bilinear"}=t;if(this.factor=e,Array.isArray(this.factor)&&2===this.factor.length)this.widthLower=this.factor[0],this.widthUpper=this.factor[1];else{if(Array.isArray(this.factor)||!(this.factor>0))throw new AW(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`);this.widthLower=-this.factor,this.widthUpper=this.factor}if(this.widthLower<-1||this.widthUpper<-1)throw new AW(`factor must have values larger than -1. Got: ${this.factor}`);if(this.widthUpper<this.widthLower)throw new AW(`factor cannot have upper bound less than lower bound.\n Got upper bound: ${this.widthUpper}.\n Got lower bound: ${this.widthLower}\n `);if(n){if(!zQ.has(n))throw new AW(`Invalid interpolation parameter: ${n} is not implemented`);this.interpolation=n}}getConfig(){const t={factor:this.factor,interpolation:this.interpolation},e=super.getConfig();return Object.assign(t,e),t}computeOutputShape(t){const e=(t=pX(t))[2];return[this.imgHeight,-1,e]}call(t,e){return ED((()=>{const e=hX(t);this.imgHeight=e.shape[e.shape.length-3];const n=e.shape[e.shape.length-2];this.widthFactor=$V([1],1+this.widthLower,1+this.widthUpper,"float32",this.randomGenerator.next());let i=this.widthFactor.dataSync()[0]*n;i=Math.round(i);const s=[this.imgHeight,i];switch(this.interpolation){case"bilinear":return JY.resizeBilinear(t,s);case"nearest":return JY.resizeNearestNeighbor(t,s);default:throw new Error(`Interpolation is ${this.interpolation}\n but only ${[...zQ]} are supported`)}}))}}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function jQ(t){return new wX(t)}function qQ(t){return new rK(t)}function KQ(t){return new nK(t)}function QQ(t){return new iK(t)}function JQ(t){return new sK(t)}function ZQ(t){return new oK(t)}function tJ(t){return new aK(t)}function eJ(t){return new wK(t)}function nJ(t){return new TK(t)}function iJ(t){return new IK(t)}function sJ(t){return new yK(t)}function rJ(t){return new EK(t)}function aJ(t){return new vK(t)}function oJ(t){return new SK(t)}function lJ(t){return new xK(t)}function uJ(t){return new RK(t)}function hJ(t){return new jK(t)}function pJ(t){return new zK(t)}function cJ(t){return new HK(t)}function dJ(t){return new WK(t)}function fJ(t){return new XK(t)}function mJ(t){return new qK(t)}function gJ(t){return new KK(t)}function _J(t){return new QK(t)}function TJ(t){return new ZK(t)}function yJ(t){return new eQ(t)}function IJ(t){return new iQ(t)}function EJ(t){return new aQ(t)}function bJ(t){return new sQ(t)}function vJ(t){return new rQ(t)}function wJ(t){return new nQ(t)}function SJ(t){return new lQ(t)}function xJ(t){return new fQ(t)}function RJ(t){return new mQ(t)}function OJ(t){return new gQ(t)}function AJ(t){return new EQ(t)}function MJ(t){return AJ(t)}function CJ(t){return AJ(t)}function NJ(t){return new wQ(t)}function kJ(t){return NJ(t)}function DJ(t){return NJ(t)}function LJ(t){return new RQ(t)}function FJ(t){return LJ(t)}function PJ(t){return LJ(t)}function $J(t){return new AQ(t)}function BJ(t){return new NQ(t)}function VJ(t){return new MQ(t)}function UJ(t){return new kQ(t)}function YJ(t){return new IQ(t)}function GJ(t){return new vQ(t)}function HJ(t){return new xQ(t)}function WJ(t){return new LK(t)}function zJ(t){return new DK(t)}function XJ(t){return new PK(t)}function jJ(t){return new FK(t)}function qJ(t){return new kK(t)}function KJ(t){return new NK(t)}function QJ(t){return new GK(t)}function JJ(t){return new YK(t)}function ZJ(t){return new MK(t)}function tZ(t){return new $K(t)}function eZ(t){return new FQ(t)}function nZ(t){return new LQ(t)}XQ.className="RandomWidth",rF(XQ);const iZ=VJ,sZ=UJ,rZ=YJ,aZ=GJ;function oZ(t){return new uQ(t)}function lZ(t){return new hQ(t)}function uZ(t){return new pQ(t)}function hZ(t){return new JK(t)}function pZ(t){return new PQ(t)}function cZ(t){return new VQ(t)}function dZ(t){return new GQ(t)}function fZ(t){return new UQ(t)}function mZ(t){return new XQ(t)}function gZ(t,e){return Nj(t,e)}function _Z(t,e){return Pj(t,e)}function TZ(t,e){return $j(t,e)}function yZ(t,e){return kj(t,e)}function IZ(t,e){return Bj(t,e)}function EZ(t,e){return Lj(t,e)}function bZ(t,e){return Fj(t,e)}function vZ(t,e){return Aj(t,e)}function wZ(t,e){return bj(t,e)}function SZ(t,e){return vj(t,e)}function xZ(t,e){return vj(t,e)}function RZ(t,e){return vj(t,e)}function OZ(t,e){return Ej(t,e)}function AZ(t,e){return Ej(t,e)}function MZ(t,e){return Ej(t,e)}function CZ(t,e){return function(t,e){return ED((()=>{const n=t.sub(e).square().sum(),i=t.sub(t.mean()).square().sum();return tF(1).sub(n.div(i))}))}(t,e)}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function NZ(t){return new Qq(t)}function kZ(t){return qq(e=t),new Qq({l1:null!=e?e.l1:null,l2:0});var e}function DZ(t){return qq(e=t),new Qq({l2:null!=e?e.l2:null,l1:0});var e}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class LZ extends pj{constructor(){super(...arguments),this.model=null}setModel(t){if(!(t instanceof Iq))throw new Error("model must be a LayersModel, not some other Container");this.model=t}}function FZ(t,e){return t<e}function PZ(t,e){return t>e}class $Z extends LZ{constructor(t){if(super(),null==t&&(t={}),t.restoreBestWeights)throw new MW("restoreBestWeights = True is not implemented in EarlyStopping yet.");this.monitor=t.monitor||"val_loss",this.minDelta=Math.abs(t.minDelta||0),this.patience=t.patience||0,this.verbose=t.verbose||0,this.mode=t.mode||"auto",this.baseline=t.baseline,-1===["auto","min","max"].indexOf(this.mode)&&(console.warn(`EarlyStopping mode '${this.mode}' is invalid. Falling back to mode 'auto'.`),this.mode="auto"),"min"===this.mode?this.monitorFunc=FZ:"max"===this.mode||-1!==this.monitor.indexOf("acc")?this.monitorFunc=PZ:this.monitorFunc=FZ,this.monitorFunc===FZ&&(this.minDelta*=-1)}async onTrainBegin(t){this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===FZ?1/0:-1/0}async onEpochEnd(t,e){await lj(e);const n=this.getMonitorValue(e);null!=n&&(this.monitorFunc(n-this.minDelta,this.best)?(this.best=n,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=t,this.model.stopTraining=!0)))}async onTrainEnd(t){this.stoppedEpoch>0&&this.verbose&&console.log(`Epoch ${this.stoppedEpoch}: early stopping.`)}getMonitorValue(t){null==t&&(t={});const e=t[this.monitor];return null==e&&console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(t)}`),e}}const BZ={earlyStopping:function(t){return new $Z(t)}};
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
var VZ,UZ;aA().registerFlag("KEEP_INTERMEDIATE_TENSORS",(()=>!1),(t=>{t&&console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.")})),function(t){t[t.DT_INVALID=0]="DT_INVALID",t[t.DT_FLOAT=1]="DT_FLOAT",t[t.DT_DOUBLE=2]="DT_DOUBLE",t[t.DT_INT32=3]="DT_INT32",t[t.DT_UINT8=4]="DT_UINT8",t[t.DT_INT16=5]="DT_INT16",t[t.DT_INT8=6]="DT_INT8",t[t.DT_STRING=7]="DT_STRING",t[t.DT_COMPLEX64=8]="DT_COMPLEX64",t[t.DT_INT64=9]="DT_INT64",t[t.DT_BOOL=10]="DT_BOOL",t[t.DT_QINT8=11]="DT_QINT8",t[t.DT_QUINT8=12]="DT_QUINT8",t[t.DT_QINT32=13]="DT_QINT32",t[t.DT_BFLOAT16=14]="DT_BFLOAT16",t[t.DT_QINT16=15]="DT_QINT16",t[t.DT_QUINT16=16]="DT_QUINT16",t[t.DT_UINT16=17]="DT_UINT16",t[t.DT_COMPLEX128=18]="DT_COMPLEX128",t[t.DT_HALF=19]="DT_HALF",t[t.DT_RESOURCE=20]="DT_RESOURCE",t[t.DT_VARIANT=21]="DT_VARIANT",t[t.DT_UINT32=22]="DT_UINT32",t[t.DT_UINT64=23]="DT_UINT64",t[t.DT_FLOAT_REF=101]="DT_FLOAT_REF",t[t.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",t[t.DT_INT32_REF=103]="DT_INT32_REF",t[t.DT_UINT8_REF=104]="DT_UINT8_REF",t[t.DT_INT16_REF=105]="DT_INT16_REF",t[t.DT_INT8_REF=106]="DT_INT8_REF",t[t.DT_STRING_REF=107]="DT_STRING_REF",t[t.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",t[t.DT_INT64_REF=109]="DT_INT64_REF",t[t.DT_BOOL_REF=110]="DT_BOOL_REF",t[t.DT_QINT8_REF=111]="DT_QINT8_REF",t[t.DT_QUINT8_REF=112]="DT_QUINT8_REF",t[t.DT_QINT32_REF=113]="DT_QINT32_REF",t[t.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",t[t.DT_QINT16_REF=115]="DT_QINT16_REF",t[t.DT_QUINT16_REF=116]="DT_QUINT16_REF",t[t.DT_UINT16_REF=117]="DT_UINT16_REF",t[t.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",t[t.DT_HALF_REF=119]="DT_HALF_REF",t[t.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",t[t.DT_VARIANT_REF=121]="DT_VARIANT_REF",t[t.DT_UINT32_REF=122]="DT_UINT32_REF",t[t.DT_UINT64_REF=123]="DT_UINT64_REF"}(VZ||(VZ={})),function(t){let e;!function(t){t[t.LEGACY=0]="LEGACY",t[t.V1=1]="V1",t[t.V2=2]="V2"}(e=t.CheckpointFormatVersion||(t.CheckpointFormatVersion={}))}(UZ||(UZ={}));
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const YZ={};function GZ(t,e){const n={tfOpName:t,category:"custom",inputs:[],attrs:[],customExecutor:e};YZ[t]=n}function HZ(t){return YZ[t]}function WZ(t){delete YZ[t]}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function zZ(t,e,n,i,s){const r=e.inputParams[t];if(r&&void 0!==r.inputIndexStart){const t=r.inputIndexStart,a=0===r.inputIndexEnd?void 0:void 0===r.inputIndexEnd?t+1:r.inputIndexEnd,o=t<0?e.inputNames.length+t:t;if("tensor"===r.type)return XZ(e.inputNames[o],n,i,s);if("tensors"===r.type){const r=e.inputs.slice(t,a);return e.inputNames.slice(t,a).filter(((t,e)=>{var n;return"NoOp"!==(null===(n=r[e])||void 0===n?void 0:n.op)})).map((t=>XZ(t,n,i,s)))}const l=XZ(e.inputNames[o],n,i,s),u=l.dataSync();return"number"===r.type?u[0]:jO(l.shape,u)}const a=e.attrParams[t];return a&&a.value}function XZ(t,e,n,i){const[s,r]=QZ(t,n);if(null!=i){const t=i.getHashTableHandleByName(s);if(null!=t)return t}const a=n.currentContextIds.find((t=>!!e[KZ(s,t)]));return void 0!==a?e[KZ(s,a)][r]:void 0}function jZ(t,e,n){return e[KZ(t,n.currentContextId)]}function qZ(t,e){const[n,i,s]=QZ(t,e);return[KZ(n,e&&e.currentContextId),i,s]}function KZ(t,e){return e?`${t}-${e}`:t}function QZ(t,e){if(""===t)return["",0,void 0];const n=null!=e&&null!=e.parseNodeNameCache;if(n){const n=e.parseNodeNameCache.get(t);if(null!=n)return n}const i=t.split(":");let s;if(1===i.length)s=[t,0,void 0];else{const t=i[0],e=3===i.length?i[1]:void 0;s=[t,Number(i[i.length-1]),e]}return n&&e.parseNodeNameCache.set(t,s),s}function JZ(t,e,n){let i=zZ("pad",t,e,n);if("explicit"===i){i=zZ("explicitPaddings",t,e,n);const s=[[0,0],[0,0],[0,0],[0,0]];for(let t=0;t<4;t++)s[t][0]=i[2*t],s[t][1]=i[2*t+1];return s}return i}function ZZ(t){return t.kept?t:$L(t)}
/**
* @license
* Copyright 2023 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const t0=[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],e0=[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsFinite",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsInf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],n0=[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}],i0=[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}],s0=[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniformInt",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number"},{tfName:"maxval",name:"maxval",type:"number"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}],r0=[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}],a0=[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}],o0=[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}],l0=[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"InitializeTable",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]},{tfOpName:"InitializeTableV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],u0=[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}],h0=[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BitwiseAnd",category:"logical",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}]}],p0=[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"MatrixBandPart",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"numLower",type:"tensor"},{start:1,name:"numUpper",type:"tensor"}]}],c0=[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]}],d0=[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}],f0=[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]},{tfOpName:"TensorScatterUpdate",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"values",type:"tensor"}]}],m0=[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}],g0=[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}],_0=[{tfOpName:"StaticRegexReplace",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"pattern",name:"pattern",type:"string"},{tfName:"rewrite",name:"rewrite",type:"string"},{tfName:"replace_global",name:"replaceGlobal",type:"bool"}]},{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}],T0=[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"EnsureShape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}];
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class y0{static get Instance(){return this._instance||(this._instance=new this)}constructor(){const t=[].concat(...[Rt,Ot,At,Mt,Ct,Nt,kt,Dt,Lt,Ft,Pt,$t,Bt,Vt,Ut,Yt,Gt,Ht,Wt].map((t=>t.json)));this.opMappers=t.reduce(((t,e)=>(t[e.tfOpName]=e,t)),{})}transformGraph(t,e={}){const n=t.node,i=[],s=[],r=[],a=n.reduce(((t,e)=>(t[e.name]=this.mapNode(e),e.op.startsWith("Placeholder")?i.push(t[e.name]):"Const"===e.op?s.push(t[e.name]):null!=e.input&&0!==e.input.length||r.push(t[e.name]),t)),{});let o=[];const l=[];let u={},h={};null!=e&&(u=this.mapSignatureEntries(e.inputs),h=this.mapSignatureEntries(e.outputs));const p=Object.keys(a);p.forEach((t=>{const e=a[t];e.inputNames.forEach(((t,n)=>{const[i,,s]=qZ(t),r=a[i];if(null!=r.outputs){const t=r.outputs.indexOf(s);if(-1!==t){const s=`${i}:${t}`;e.inputNames[n]=s}}e.inputs.push(r),r.children.push(e)}))})),0===Object.keys(h).length?p.forEach((t=>{const e=a[t];0===e.children.length&&l.push(e)})):Object.keys(h).forEach((t=>{const[e]=qZ(t),n=a[e];null!=n&&(n.signatureKey=h[t],l.push(n))})),Object.keys(u).length>0?Object.keys(u).forEach((t=>{const[e]=qZ(t),n=a[e];n&&(n.signatureKey=u[t],o.push(n))})):o=i;let c={};null!=t.library&&null!=t.library.function&&(c=t.library.function.reduce(((t,e)=>(t[e.signature.name]=this.mapFunction(e),t)),{}));const d={nodes:a,inputs:o,outputs:l,weights:s,placeholders:i,signature:e,functions:c};return r.length>0&&(d.initNodes=r),d}mapSignatureEntries(t){return Object.keys(t||{}).reduce(((e,n)=>(e[t[n].name]=n,e)),{})}mapNode(t){const e=HZ(t.op)||this.opMappers[t.op]||{};null==t.attr&&(t.attr={});const n={name:t.name,op:t.op,category:e.category,inputNames:(t.input||[]).map((t=>t.startsWith("^")?t.slice(1):t)),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:t.attr,outputs:e.outputs};return null!=e.inputs&&(n.inputParams=e.inputs.reduce(((t,e)=>(t[e.name]={type:e.type,inputIndexStart:e.start,inputIndexEnd:e.end},t)),{})),null!=e.attrs&&(n.attrParams=e.attrs.reduce(((e,n)=>{const i=n.type;let s;switch(n.type){case"string":s=E0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=E0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":s=C0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=C0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":s=v0(t.attr,n.tfName,n.defaultValue||0),void 0===s&&n.tfDeprecatedName&&(s=v0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":s=M0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=M0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":s=b0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=b0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":s=k0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=k0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":s=A0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=A0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":s=N0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=N0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":s=x0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=x0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":s=R0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=R0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":s=S0(t.attr,n.tfName,n.defaultValue),void 0===s&&n.tfDeprecatedName&&(s=S0(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${n.type} for op: ${t.op}`)}return e[n.name]={value:s,type:i},e}),{})),n}mapFunction(t){const e=t.nodeDef,n=[];let i={};null!=e&&(i=e.reduce(((t,e)=>(t[e.name]=this.mapNode(e),"Const"===e.op&&n.push(t[e.name]),t)),{}));const s=[],r=[];t.signature.inputArg.forEach((t=>{const[e]=qZ(t.name),n={name:e,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:w0(t.type),type:"dtype"}},children:[]};n.signatureKey=t.name,s.push(n),i[e]=n}));Object.keys(i).forEach((t=>{const e=i[t];e.inputNames.forEach(((t,n)=>{const[s,,r]=qZ(t),a=i[s];if(null!=a.outputs){const t=a.outputs.indexOf(r);if(-1!==t){const i=`${s}:${t}`;e.inputNames[n]=i}}e.inputs.push(a),a.children.push(e)}))}));const a=t.ret;t.signature.outputArg.forEach((t=>{const[e,n]=qZ(a[t.name]),s=i[e];null!=s&&(s.defaultOutput=n,r.push(s))}));const o=this.mapArgsToSignature(t);return{nodes:i,inputs:s,outputs:r,weights:n,placeholders:[],signature:o}}mapArgsToSignature(t){return{methodName:t.signature.name,inputs:t.signature.inputArg.reduce(((t,e)=>(t[e.name]=this.mapArgToTensorInfo(e),t)),{}),outputs:t.signature.outputArg.reduce(((e,n)=>(e[n.name]=this.mapArgToTensorInfo(n,t.ret),e)),{})}}mapArgToTensorInfo(t,e){let n=t.name;return null!=e&&(n=e[n]),{name:n,dtype:t.type}}}function I0(t,e){const n=Array.isArray(t)?String.fromCharCode.apply(null,t):function(t){const e=aA().global;if(void 0!==e.atob)return e.atob(t);if("undefined"!=typeof Buffer)return new Buffer(t,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(t);return e?n:n.toLowerCase()}function E0(t,e,n,i=!1){const s=t[e];return null!=s?I0(s.s,i):n}function b0(t,e,n){const i=t[e];return i?i.b:n}function v0(t,e,n){const i=t[e]||{},s=null!=i.i?i.i:null!=i.f?i.f:n;return"number"==typeof s?s:parseInt(s,10)}function w0(t){switch("string"==typeof t&&(t=VZ[t]),t){case VZ.DT_FLOAT:case VZ.DT_HALF:return"float32";case VZ.DT_INT32:case VZ.DT_INT64:case VZ.DT_INT8:case VZ.DT_UINT8:return"int32";case VZ.DT_BOOL:return"bool";case VZ.DT_DOUBLE:return"float32";case VZ.DT_STRING:return"string";case VZ.DT_COMPLEX64:case VZ.DT_COMPLEX128:return"complex64";default:return null}}function S0(t,e,n){const i=t[e];return i&&i.func?i.func.name:n}function x0(t,e,n){const i=t[e];return i&&i.type?w0(i.type):n}function R0(t,e,n){const i=t[e];return i&&i.list&&i.list.type?i.list.type.map((t=>w0(t))):n}function O0(t){if(!t.unknownRank)return null!=t.dim?t.dim.map((t=>"number"==typeof t.size?t.size:parseInt(t.size,10))):[]}function A0(t,e,n){const i=t[e];return i&&i.shape?O0(i.shape):n}function M0(t,e,n){const i=t[e];return i?((i.list.f&&i.list.f.length?i.list.f:i.list.i)||[]).map((t=>"number"==typeof t?t:parseInt(t,10))):n}function C0(t,e,n,i=!1){const s=t[e];return s&&s.list&&s.list.s?s.list.s.map((t=>I0(t,i))):n}function N0(t,e,n){const i=t[e];return i&&i.list&&i.list.shape?i.list.shape.map((t=>O0(t))):n}function k0(t,e,n){const i=t[e];return i&&i.list&&i.list.b?i.list.b:n}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class D0{constructor(t,e,n){this.node=t,this.tensorMap=e,this.context=n,this.inputs=[],this.attrs={},this.inputs=t.inputNames.map((t=>this.getInput(t))),null!=t.rawAttrs&&(this.attrs=Object.keys(t.rawAttrs).reduce(((t,e)=>(t[e]=this.getAttr(e),t)),{}))}getInput(t){return XZ(t,this.tensorMap,this.context)}getAttr(t,e){const n=this.node.rawAttrs[t];if(null!=n.tensor)return XZ(t,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return v0(this.node.rawAttrs,t,e);if(null!=n.s)return E0(this.node.rawAttrs,t,e);if(null!=n.b)return b0(this.node.rawAttrs,t,e);if(null!=n.shape)return A0(this.node.rawAttrs,t,e);if(null!=n.type)return x0(this.node.rawAttrs,t,e);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return M0(this.node.rawAttrs,t,e);if(null!=n.list.s)return C0(this.node.rawAttrs,t,e);if(null!=n.list.shape)return N0(this.node.rawAttrs,t,e);if(null!=n.list.b)return k0(this.node.rawAttrs,t,e);if(null!=n.list.type)return R0(this.node.rawAttrs,t,e)}return e}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function L0(t,e,n=""){if("number"!=typeof t&&"number"!=typeof e){_O(t.length===e.length,(()=>n+` Shapes ${t} and ${e} must match`));for(let i=0;i<t.length;i++){const s=t[i],r=e[i];_O(s<0||r<0||s===r,(()=>n+` Shapes ${t} and ${e} must match`))}}}function F0(t){return"number"!=typeof t&&!t.some((t=>t<0))}function P0(t,e,n){let i=$0(t,n);const s=!F0(i);if(s&&0===e.length)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${i}`);if(s&&e.forEach((t=>{i=$0(t.shape,i)})),!F0(i))throw new Error(`Non-fully-defined elementShape: ${i}`);return i}function $0(t,e){if("number"==typeof t)return e;if("number"==typeof e)return t;if(t.length!==e.length)throw new Error(`Incompatible ranks during merge: ${t} vs. ${e}`);const n=[];for(let i=0;i<t.length;++i){const s=t[i],r=e[i];if(s>=0&&r>=0&&s!==r)throw new Error(`Incompatible shape during merge: ${t} vs. ${e}`);n[i]=s>=0?s:r}return n}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class B0{constructor(t,e,n,i,s,r,a){this.name=t,this.dtype=e,this.maxSize=n,this.elementShape=i,this.identicalElementShapes=s,this.dynamicSize=r,this.clearAfterRead=a,this.tensors=[],this.closed_=!1,this.idTensor=tF(0),vD(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(t){this.tensors.forEach((e=>{null!=t&&t.has(e.tensor.id)||e.tensor.dispose()})),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(t<0||t>=this.size())throw new Error(`Tried to read from index ${t}, but array size is: ${this.size()}`);const e=this.tensors[t];if(e.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${t} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(e.cleared=!0),e.read=!0,e.tensor}readMany(t){return t.map((t=>this.read(t)))}write(t,e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(t<0||!this.dynamicSize&&t>=this.maxSize)throw new Error(`Tried to write to index ${t}, but array is not resizeable and size is: ${this.maxSize}`);const n=this.tensors[t]||{};if(e.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${t},\n because the value dtype is ${e.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=e.shape),L0(this.elementShape,e.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${t}.`),n.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${t}, because it has already been read.`);if(n.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${t}, because it has already been written.`);n.tensor=e,vD(e),n.written=!0,this.tensors[t]=n}writeMany(t,e){if(t.length!==e.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${t.length} is not the same as tensors size: ${e.length}.`);t.forEach(((t,n)=>this.write(t,e[n])))}gather(t,e){if(e&&e!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${e}`);if(t)t=t.slice(0,this.size());else{t=[];for(let e=0;e<this.size();e++)t.push(e)}if(0===t.length)return hD([],[0].concat(this.elementShape));const n=this.readMany(t);return L0(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),mU(n,0)}concat(t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${t}`);if(0===this.size())return hD([],[0].concat(this.elementShape));const e=[];for(let t=0;t<this.size();t++)e.push(t);const n=this.readMany(e);return L0(this.elementShape,n[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`),b$(n,0)}scatter(t,e){if(e.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${e.dtype}`);if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);const n=Math.max(...t);if(!this.dynamicSize&&n>=this.maxSize)throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`);this.writeMany(t,AU(e,0))}split(t,e){if(e.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${e.dtype}`);let n=0;const i=t.map((t=>(n+=t,n)));if(n!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${n}, and tensor's shape is: ${e.shape}`);if(!this.dynamicSize&&t.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${t.length}), and the TensorArray is not marked as dynamically resizeable`);const s=0===n?0:e.size/n,r=[];ED((()=>{e=y$(e,[1,n,s]);for(let n=0;n<t.length;++n){const a=[0,0===n?0:i[n-1],0],o=[1,t[n],s];r[n]=y$(w$(e,a,o),this.elementShape)}return r}));const a=[];for(let e=0;e<t.length;e++)a[e]=e;this.writeMany(a,r)}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class V0{get id(){return this.idTensor.id}constructor(t,e,n,i=-1){this.tensors=t,this.elementShape=e,this.elementDtype=n,null!=t&&t.forEach((t=>{if(n!==t.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${t.dtype}`);L0(e,t.shape,"TensorList shape mismatch: "),vD(t)})),this.idTensor=tF(0),this.maxNumElements=i,vD(this.idTensor)}copy(){return new V0([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(t){this.tensors.forEach((e=>{null!=t&&t.has(e.id)||e.dispose()})),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(t,e,n=-1){if(e!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e}, but list elements ${this.elementDtype}`);if(-1!==n&&this.tensors.length!==n)throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`);L0(t,this.elementShape,"TensorList shape mismatch: ");const i=P0(this.elementShape,this.tensors,t);return ED((()=>{const t=this.tensors.map((t=>y$(t,i)));return mU(t,0)}))}popBack(t,e){if(e!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e}, but list elements ${this.elementDtype}`);if(0===this.size())throw new Error("Trying to pop from an empty list.");const n=P0(this.elementShape,this.tensors,t),i=this.tensors.pop();return i.kept=!1,L0(i.shape,t,"TensorList shape mismatch: "),y$(i,n)}pushBack(t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(L0(t.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");vD(t),this.tensors.push(t)}resize(t){if(t<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${t}`);if(-1!==this.maxNumElements&&t>this.maxNumElements)throw new Error(`TensorListResize input size ${t} is greater maxNumElement ${this.maxNumElements}.`);const e=new V0([],this.elementShape,this.elementDtype,this.maxNumElements);e.tensors.length=t;for(let n=0;n<Math.min(this.tensors.length,t);++n)e.tensors[n]=this.tensors[n];return e}getItem(t,e,n){if(n!==this.elementDtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${this.elementDtype}`);if(t<0||t>this.tensors.length)throw new Error(`Trying to access element ${t} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[t])throw new Error(`element at index ${t} is null.`);L0(this.tensors[t].shape,e,"TensorList shape mismatch: ");const i=P0(this.elementShape,this.tensors,e);return y$(this.tensors[t],i)}setItem(t,e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(t<0||-1!==this.maxNumElements&&t>=this.maxNumElements)throw new Error(`Trying to set element ${t} in a list with max ${this.maxNumElements} elements.`);L0(this.elementShape,e.shape,"TensorList shape mismatch: "),vD(e),null!=this.tensors[t]&&(this.tensors[t].kept=!1),this.tensors[t]=e}gather(t,e,n){if(e!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e}, but list elements ${this.elementDtype}`);L0(this.elementShape,n,"TensorList shape mismatch: "),t=t.slice(0,this.size());const i=P0(this.elementShape,this.tensors,n);return 0===t.length?hD([],[0].concat(i)):ED((()=>{const e=t.map((t=>y$(this.tensors[t],i)));return mU(e,0)}))}concat(t,e){if(t&&t!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${t}`);L0(this.elementShape,e,"TensorList shape mismatch: ");const n=P0(this.elementShape,this.tensors,e);return 0===this.size()?hD([],[0].concat(n)):ED((()=>{const t=this.tensors.map((t=>y$(t,n)));return b$(t,0)}))}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const U0=async(t,e,n)=>{switch(t.op){case"If":case"StatelessIf":{const i=zZ("thenBranch",t,e,n),s=zZ("elseBranch",t,e,n),r=zZ("cond",t,e,n),a=zZ("args",t,e,n);return(await r.data())[0]?n.functionMap[i].executeFunctionAsync(a,n.tensorArrayMap,n.tensorListMap):n.functionMap[s].executeFunctionAsync(a,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const i=zZ("body",t,e,n),s=zZ("cond",t,e,n),r=zZ("args",t,e,n),a=await n.functionMap[s].executeFunctionAsync(r,n.tensorArrayMap,n.tensorListMap),o=r.map((t=>t.id));let l=await a[0].data();a.forEach((t=>{t.kept||-1!==o.indexOf(t.id)||t.dispose()}));let u=r;for(;l[0];){const t=u;u=await n.functionMap[i].executeFunctionAsync(u,n.tensorArrayMap,n.tensorListMap);const e=u.map((t=>t.id));t.forEach((t=>{t.kept||-1!==o.indexOf(t.id)||-1!==e.indexOf(t.id)||t.dispose()}));const r=await n.functionMap[s].executeFunctionAsync(u,n.tensorArrayMap,n.tensorListMap);l=await r[0].data(),r.forEach((t=>{t.kept||-1!==o.indexOf(t.id)||-1!==e.indexOf(t.id)||t.dispose()}))}return u}case"LoopCond":return[ZZ(zZ("pred",t,e,n))];case"Switch":{const i=zZ("pred",t,e,n);let s=zZ("data",t,e,n);return s.kept||(s=ZZ(s)),(await i.data())[0]?[void 0,s]:[s,void 0]}case"Merge":{const i=t.inputNames.find((t=>void 0!==XZ(t,e,n)));if(i){return[ZZ(XZ(i,e,n))]}return}case"Enter":{const i=zZ("frameName",t,e,n),s=zZ("tensor",t,e,n);return n.enterFrame(i),[ZZ(s)]}case"Exit":{const i=zZ("tensor",t,e,n);return n.exitFrame(),[ZZ(i)]}case"NextIteration":{const i=zZ("tensor",t,e,n);return n.nextIteration(),[ZZ(i)]}case"TensorArrayV3":{const i=zZ("size",t,e,n),s=zZ("dtype",t,e,n),r=zZ("elementShape",t,e,n),a=zZ("dynamicSize",t,e,n),o=zZ("clearAfterRead",t,e,n),l=zZ("identicalElementShapes",t,e,n),u=zZ("name",t,e,n),h=new B0(u,s,i,r,l,a,o);return n.addTensorArray(h),[h.idTensor,tF(1)]}case"TensorArrayWriteV3":{const i=zZ("tensorArrayId",t,e,n),s=zZ("index",t,e,n),r=zZ("tensor",t,e,n),a=n.getTensorArray(i.id);return a.write(s,r),[a.idTensor]}case"TensorArrayReadV3":{const i=zZ("tensorArrayId",t,e,n),s=zZ("index",t,e,n);return[n.getTensorArray(i.id).read(s)]}case"TensorArrayGatherV3":{const i=zZ("tensorArrayId",t,e,n),s=zZ("indices",t,e,n),r=zZ("dtype",t,e,n);return[n.getTensorArray(i.id).gather(s,r)]}case"TensorArrayScatterV3":{const i=zZ("tensorArrayId",t,e,n),s=zZ("indices",t,e,n),r=zZ("tensor",t,e,n),a=n.getTensorArray(i.id);return a.scatter(s,r),[a.idTensor]}case"TensorArrayConcatV3":{const i=zZ("tensorArrayId",t,e,n),s=n.getTensorArray(i.id),r=zZ("dtype",t,e,n);return[s.concat(r)]}case"TensorArraySplitV3":{const i=zZ("tensorArrayId",t,e,n),s=zZ("tensor",t,e,n),r=zZ("lengths",t,e,n),a=n.getTensorArray(i.id);return a.split(r,s),[a.idTensor]}case"TensorArraySizeV3":{const i=zZ("tensorArrayId",t,e,n);return[tF(n.getTensorArray(i.id).size(),"int32")]}case"TensorArrayCloseV3":{const i=zZ("tensorArrayId",t,e,n),s=n.getTensorArray(i.id);return s.clearAndClose(),[s.idTensor]}case"TensorListSetItem":{const i=zZ("tensorListId",t,e,n),s=zZ("index",t,e,n),r=zZ("tensor",t,e,n),a=n.getTensorList(i.id);return a.setItem(s,r),[a.idTensor]}case"TensorListGetItem":{const i=zZ("tensorListId",t,e,n),s=zZ("index",t,e,n),r=zZ("elementShape",t,e,n),a=zZ("elementDType",t,e,n);return[n.getTensorList(i.id).getItem(s,r,a)]}case"TensorListScatterV2":case"TensorListScatter":{const i=zZ("indices",t,e,n),s=function(t,e,n,i){if(e.length!==t.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t.shape[0]}`);const s=Math.max(...e);if(null!=i&&-1!==i&&s>=i)throw new Error(`Max index must be < array size (${s} vs. ${i})`);const r=new V0([],n,t.dtype,i),a=AU(t,0);return e.forEach(((t,e)=>{r.setItem(t,a[e])})),r}(zZ("tensor",t,e,n),i,zZ("elementShape",t,e,n),zZ("numElements",t,e,n));return n.addTensorList(s),[s.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const i=zZ("elementShape",t,e,n),s=zZ("elementDType",t,e,n);let r;r="TensorListReserve"===t.op?"numElements":"maxNumElements";const a=zZ(r,t,e,n),o=function(t,e,n,i){return new V0([],t,e,i)}(i,s,0,"TensorListReserve"===t.op?-1:a);return n.addTensorList(o),[o.idTensor]}case"TensorListGather":{const i=zZ("tensorListId",t,e,n),s=zZ("indices",t,e,n),r=zZ("elementShape",t,e,n),a=zZ("elementDType",t,e,n);return[n.getTensorList(i.id).gather(s,a,r)]}case"TensorListStack":{const i=zZ("tensorListId",t,e,n),s=zZ("elementShape",t,e,n),r=zZ("elementDType",t,e,n),a=zZ("numElements",t,e,n);return[n.getTensorList(i.id).stack(s,r,a)]}case"TensorListFromTensor":{const i=function(t,e,n){const i=t.dtype;if(t.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${t.shape}`);if(t.dtype!==n)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${n}`);L0(t.shape.slice(1),e,"TensorList shape mismatch: ");const s=AU(t);return new V0(s,e,i)}(zZ("tensor",t,e,n),zZ("elementShape",t,e,n),zZ("elementDType",t,e,n));return n.addTensorList(i),[i.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const i=zZ("tensorListId",t,e,n),s=n.getTensorList(i.id),r=zZ("dtype",t,e,n),a=zZ("elementShape",t,e,n);return[s.concat(r,a)]}case"TensorListPushBack":{const i=zZ("tensorListId",t,e,n),s=zZ("tensor",t,e,n),r=n.getTensorList(i.id);return r.pushBack(s),[r.idTensor]}case"TensorListPopBack":{const i=zZ("tensorListId",t,e,n),s=zZ("elementShape",t,e,n),r=zZ("elementDType",t,e,n);return[n.getTensorList(i.id).popBack(s,r)]}case"TensorListSplit":{const i=zZ("tensor",t,e,n),s=zZ("elementShape",t,e,n),r=function(t,e,n){let i=0;const s=e.map((t=>(i+=t,i)));if(i!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${i}, and tensor's shape is: ${t.shape}`);const r=$0(t.shape.slice(1),n),a=0===i?0:t.size/i,o=ED((()=>{const n=[];t=y$(t,[1,i,a]);for(let i=0;i<e.length;++i){const o=[0,0===i?0:s[i-1],0],l=[1,e[i],a];n[i]=y$(w$(t,o,l),r)}return t.dispose(),n})),l=new V0([],n,t.dtype,e.length);for(let t=0;t<o.length;t++)l.setItem(t,o[t]);return l}(i,zZ("lengths",t,e,n),s);return n.addTensorList(r),[r.idTensor]}case"TensorListLength":{const i=zZ("tensorListId",t,e,n);return[tF(n.getTensorList(i.id).size(),"int32")]}case"TensorListResize":{const i=zZ("tensorListId",t,e,n),s=zZ("size",t,e,n),r=n.getTensorList(i.id).resize(s);return n.addTensorList(r),[r.idTensor]}default:throw TypeError(`Node type ${t.op} is not implemented`)}};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Y0(t,e,n){const[i,s]=zZ("fusedOps",t,e,n),r="biasadd"===i,a=!r,o="prelu"===s,l="fusedbatchnorm"===i,u=zZ("numArgs",t,e,n);if(r){if(o&&2!==u)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&r&&1!==u)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(l)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const h=zZ("strides",t,e,n),p=JZ(t,e,n),c=zZ("dataFormat",t,e,n).toUpperCase(),d=zZ("dilations",t,e,n);let[f,m]=zZ("args",t,e,n);a&&(m=f,f=void 0);return{stride:h,pad:p,dataFormat:c,dilations:d,biasArg:f,preluArg:m,activationFunc:s,leakyreluAlpha:zZ("leakyreluAlpha",t,e,n)}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function G0(t,e,n){return{boxes:zZ("boxes",t,e,n),scores:zZ("scores",t,e,n),maxOutputSize:zZ("maxOutputSize",t,e,n),iouThreshold:zZ("iouThreshold",t,e,n),scoreThreshold:zZ("scoreThreshold",t,e,n),softNmsSigma:zZ("softNmsSigma",t,e,n)}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class H0{get id(){return this.handle.id}constructor(t,e){this.keyDType=t,this.valueDType=e,this.handle=tF(0),this.tensorMap=new Map,vD(this.handle)}clearAndClose(){this.tensorMap.forEach((t=>t.dispose())),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return tF(this.size(),"int32")}async import(t,e){this.checkKeyAndValueTensor(t,e);const n=await t.data();return this.tensorMap.forEach((t=>t.dispose())),this.tensorMap.clear(),ED((()=>{const t=AU(e),i=n.length,s=t.length;_O(i===s,(()=>`The number of elements doesn't match, keys has ${i} elements, the values has ${s} elements.`));for(let e=0;e<i;e++){const i=n[e],s=t[e];vD(s),this.tensorMap.set(i,s)}return this.handle}))}async find(t,e){this.checkKeyAndValueTensor(t,e);const n=await t.data();return ED((()=>{const t=[];for(let i=0;i<n.length;i++){const s=n[i],r=this.findWithDefault(s,e);t.push(r)}return mU(t)}))}findWithDefault(t,e){const n=this.tensorMap.get(t);return null!=n?n:e}checkKeyAndValueTensor(t,e){if(t.dtype!==this.keyDType)throw new Error(`Expect key dtype ${this.keyDType}, but got ${t.dtype}`);if(e.dtype!==this.valueDType)throw new Error(`Expect value dtype ${this.valueDType}, but got ${e.dtype}`)}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function W0(t,e,n,i,s=ED){const r=((t,e,n)=>{switch(t.category){case"arithmetic":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"BiasAdd":case"AddV2":case"Add":return[i.add(zZ("a",t,e,n),zZ("b",t,e,n))];case"AddN":return[i.addN(zZ("tensors",t,e,n))];case"FloorMod":case"Mod":return[i.mod(zZ("a",t,e,n),zZ("b",t,e,n))];case"Mul":return[i.mul(zZ("a",t,e,n),zZ("b",t,e,n))];case"RealDiv":case"Div":return[i.div(zZ("a",t,e,n),zZ("b",t,e,n))];case"DivNoNan":return[i.divNoNan(zZ("a",t,e,n),zZ("b",t,e,n))];case"FloorDiv":return[i.floorDiv(zZ("a",t,e,n),zZ("b",t,e,n))];case"Sub":return[i.sub(zZ("a",t,e,n),zZ("b",t,e,n))];case"Minimum":return[i.minimum(zZ("a",t,e,n),zZ("b",t,e,n))];case"Maximum":return[i.maximum(zZ("a",t,e,n),zZ("b",t,e,n))];case"Pow":return[i.pow(zZ("a",t,e,n),zZ("b",t,e,n))];case"SquaredDifference":return[i.squaredDifference(zZ("a",t,e,n),zZ("b",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"basic_math":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Abs":case"ComplexAbs":return[i.abs(zZ("x",t,e,n))];case"Acos":return[i.acos(zZ("x",t,e,n))];case"Acosh":return[i.acosh(zZ("x",t,e,n))];case"Asin":return[i.asin(zZ("x",t,e,n))];case"Asinh":return[i.asinh(zZ("x",t,e,n))];case"Atan":return[i.atan(zZ("x",t,e,n))];case"Atan2":return[i.atan2(zZ("x",t,e,n),zZ("y",t,e,n))];case"Atanh":return[i.atanh(zZ("x",t,e,n))];case"Ceil":return[i.ceil(zZ("x",t,e,n))];case"Complex":return[i.complex(zZ("real",t,e,n),zZ("imag",t,e,n))];case"Cos":return[i.cos(zZ("x",t,e,n))];case"Cosh":return[i.cosh(zZ("x",t,e,n))];case"Elu":return[i.elu(zZ("x",t,e,n))];case"Erf":return[i.erf(zZ("x",t,e,n))];case"Exp":return[i.exp(zZ("x",t,e,n))];case"Expm1":return[i.expm1(zZ("x",t,e,n))];case"Floor":return[i.floor(zZ("x",t,e,n))];case"Log":return[i.log(zZ("x",t,e,n))];case"Log1p":return[i.log1p(zZ("x",t,e,n))];case"Imag":return[i.imag(zZ("x",t,e,n))];case"Neg":return[i.neg(zZ("x",t,e,n))];case"Reciprocal":return[i.reciprocal(zZ("x",t,e,n))];case"Real":return[i.real(zZ("x",t,e,n))];case"Relu":return[i.relu(zZ("x",t,e,n))];case"Round":return[i.round(zZ("x",t,e,n))];case"Selu":return[i.selu(zZ("x",t,e,n))];case"Sigmoid":return[i.sigmoid(zZ("x",t,e,n))];case"Sin":return[i.sin(zZ("x",t,e,n))];case"Sign":return[i.sign(zZ("x",t,e,n))];case"Sinh":return[i.sinh(zZ("x",t,e,n))];case"Softplus":return[i.softplus(zZ("x",t,e,n))];case"Sqrt":return[i.sqrt(zZ("x",t,e,n))];case"Square":return[i.square(zZ("x",t,e,n))];case"Tanh":return[i.tanh(zZ("x",t,e,n))];case"Tan":return[i.tan(zZ("x",t,e,n))];case"ClipByValue":return[i.clipByValue(zZ("x",t,e,n),zZ("clipValueMin",t,e,n),zZ("clipValueMax",t,e,n))];case"Relu6":return[i.relu6(zZ("x",t,e,n))];case"Rsqrt":return[i.rsqrt(XZ(t.inputNames[0],e,n))];case"LeakyRelu":return[i.leakyRelu(zZ("x",t,e,n),zZ("alpha",t,e,n))];case"Prelu":return[i.prelu(zZ("x",t,e,n),zZ("alpha",t,e,n))];case"IsNan":return[i.isNaN(XZ(t.inputNames[0],e,n))];case"IsInf":return[i.isInf(XZ(t.inputNames[0],e,n))];case"IsFinite":return[i.isFinite(XZ(t.inputNames[0],e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"control":return U0(t,e,n);case"convolution":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Conv1D":{const s=zZ("stride",t,e,n),r=zZ("pad",t,e,n),a=zZ("dataFormat",t,e,n).toUpperCase(),o=zZ("dilation",t,e,n);return[i.conv1d(zZ("x",t,e,n),zZ("filter",t,e,n),s,r,a,o)]}case"Conv2D":{const s=zZ("strides",t,e,n),r=JZ(t,e,n),a=zZ("dataFormat",t,e,n).toUpperCase(),o=zZ("dilations",t,e,n);return[i.conv2d(zZ("x",t,e,n),zZ("filter",t,e,n),[s[1],s[2]],r,a,[o[1],o[2]])]}case"_FusedConv2D":{const{stride:s,pad:r,dataFormat:a,dilations:o,biasArg:l,preluArg:u,activationFunc:h,leakyreluAlpha:p}=Y0(t,e,n);return[i.fused.conv2d({x:zZ("x",t,e,n),filter:zZ("filter",t,e,n),strides:[s[1],s[2]],pad:r,dataFormat:a,dilations:[o[1],o[2]],bias:l,activation:h,preluActivationWeights:u,leakyreluAlpha:p})]}case"FusedDepthwiseConv2dNative":{const{stride:s,pad:r,dataFormat:a,dilations:o,biasArg:l,preluArg:u,activationFunc:h,leakyreluAlpha:p}=Y0(t,e,n);return[i.fused.depthwiseConv2d({x:zZ("x",t,e,n),filter:zZ("filter",t,e,n),strides:[s[1],s[2]],pad:r,dataFormat:a,dilations:[o[1],o[2]],bias:l,activation:h,preluActivationWeights:u,leakyreluAlpha:p})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const s=zZ("outputShape",t,e,n),r=zZ("strides",t,e,n),a=JZ(t,e,n);return[i.conv2dTranspose(zZ("x",t,e,n),zZ("filter",t,e,n),s,[r[1],r[2]],a)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const s=zZ("strides",t,e,n),r=JZ(t,e,n),a=zZ("dilations",t,e,n),o=zZ("dataFormat",t,e,n).toUpperCase();return[i.depthwiseConv2d(zZ("input",t,e,n),zZ("filter",t,e,n),[s[1],s[2]],r,o,[a[1],a[2]])]}case"Conv3D":{const s=zZ("strides",t,e,n),r=zZ("pad",t,e,n),a=zZ("dataFormat",t,e,n).toUpperCase(),o=zZ("dilations",t,e,n);return[i.conv3d(zZ("x",t,e,n),zZ("filter",t,e,n),[s[1],s[2],s[3]],r,a,[o[1],o[2],o[3]])]}case"AvgPool":{const s=zZ("strides",t,e,n),r=zZ("pad",t,e,n),a=zZ("kernelSize",t,e,n);return[i.avgPool(zZ("x",t,e,n),[a[1],a[2]],[s[1],s[2]],r)]}case"MaxPool":{const s=zZ("strides",t,e,n),r=zZ("pad",t,e,n),a=zZ("kernelSize",t,e,n);return[i.maxPool(zZ("x",t,e,n),[a[1],a[2]],[s[1],s[2]],r)]}case"MaxPoolWithArgmax":{const s=zZ("strides",t,e,n),r=zZ("pad",t,e,n),a=zZ("kernelSize",t,e,n),o=zZ("includeBatchInIndex",t,e,n),{result:l,indexes:u}=i.maxPoolWithArgmax(zZ("x",t,e,n),[a[1],a[2]],[s[1],s[2]],r,o);return[l,u]}case"AvgPool3D":{const s=zZ("strides",t,e,n),r=zZ("pad",t,e,n),a=zZ("kernelSize",t,e,n);return[i.avgPool3d(zZ("x",t,e,n),[a[1],a[2],a[3]],[s[1],s[2],s[3]],r)]}case"MaxPool3D":{const s=zZ("strides",t,e,n),r=zZ("pad",t,e,n),a=zZ("kernelSize",t,e,n);return[i.maxPool3d(zZ("x",t,e,n),[a[1],a[2],a[3]],[s[1],s[2],s[3]],r)]}case"Dilation2D":{const s=zZ("strides",t,e,n),r=zZ("pad",t,e,n),a=zZ("dilations",t,e,n),o=s[1],l=s[2],u=a[1],h=a[2];return[i.dilation2d(zZ("x",t,e,n),zZ("filter",t,e,n),[o,l],r,[u,h],"NHWC")]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"creation":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Fill":{const s=zZ("shape",t,e,n),r=zZ("dtype",t,e,n),a=zZ("value",t,e,n);return[i.fill(s,a,r)]}case"LinSpace":{const s=zZ("start",t,e,n),r=zZ("stop",t,e,n),a=zZ("num",t,e,n);return[i.linspace(s,r,a)]}case"Multinomial":{const s=zZ("logits",t,e,n),r=zZ("numSamples",t,e,n),a=zZ("seed",t,e,n);return[i.multinomial(s,r,a)]}case"OneHot":{const s=zZ("indices",t,e,n),r=zZ("depth",t,e,n),a=zZ("onValue",t,e,n),o=zZ("offValue",t,e,n),l=zZ("dtype",t,e,n);return[i.oneHot(s,r,a,o,l)]}case"Ones":return[i.ones(zZ("shape",t,e,n),zZ("dtype",t,e,n))];case"OnesLike":return[i.onesLike(zZ("x",t,e,n))];case"RandomStandardNormal":return[i.randomStandardNormal(zZ("shape",t,e,n),zZ("dtype",t,e,n),zZ("seed",t,e,n))];case"RandomUniform":return[i.randomUniform(zZ("shape",t,e,n),zZ("minval",t,e,n),zZ("maxval",t,e,n),zZ("dtype",t,e,n))];case"RandomUniformInt":return[i.randomUniformInt(zZ("shape",t,e,n),zZ("minval",t,e,n),zZ("maxval",t,e,n),zZ("seed",t,e,n))];case"Range":{const s=zZ("start",t,e,n),r=zZ("stop",t,e,n),a=zZ("step",t,e,n);return[i.range(s,r,a,zZ("dtype",t,e,n))]}case"TruncatedNormal":{const s=zZ("shape",t,e,n),r=zZ("mean",t,e,n),a=zZ("stdDev",t,e,n),o=zZ("seed",t,e,n);return[i.truncatedNormal(s,r,a,zZ("dtype",t,e,n),o)]}case"Zeros":return[i.zeros(zZ("shape",t,e,n),zZ("dtype",t,e,n))];case"ZerosLike":return[i.zerosLike(zZ("x",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"dynamic":return(async(t,e,n,i,s=zt)=>{switch(t.op){case"NonMaxSuppressionV5":{const{boxes:i,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:l,softNmsSigma:u}=G0(t,e,n),h=await s.image.nonMaxSuppressionWithScoreAsync(i,r,a,o,l,u);return[h.selectedIndices,h.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:i,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:l}=G0(t,e,n),u=zZ("padToMaxOutputSize",t,e,n),h=await s.image.nonMaxSuppressionPaddedAsync(i,r,a,o,l,u);return[h.selectedIndices,h.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:i,scores:r,maxOutputSize:a,iouThreshold:o,scoreThreshold:l}=G0(t,e,n);return[await s.image.nonMaxSuppressionAsync(i,r,a,o,l)]}case"Where":{const i=s.cast(zZ("condition",t,e,n),"bool"),r=[await s.whereAsync(i)];return i.dispose(),r}case"ListDiff":return s.setdiff1dAsync(zZ("x",t,e,n),zZ("y",t,e,n));default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n);case"evaluation":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"LowerBound":{const s=zZ("sortedSequence",t,e,n),r=zZ("values",t,e,n);return[i.lowerBound(s,r)]}case"TopKV2":{const s=zZ("x",t,e,n),r=zZ("k",t,e,n),a=zZ("sorted",t,e,n),o=i.topk(s,r,a);return[o.values,o.indices]}case"UpperBound":{const s=zZ("sortedSequence",t,e,n),r=zZ("values",t,e,n);return[i.upperBound(s,r)]}case"Unique":{const s=zZ("x",t,e,n),r=i.unique(s);return[r.values,r.indices]}case"UniqueV2":{const s=zZ("x",t,e,n),r=zZ("axis",t,e,n),a=i.unique(s,r);return[a.values,a.indices]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"image":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"ResizeBilinear":{const s=zZ("images",t,e,n),r=zZ("size",t,e,n),a=zZ("alignCorners",t,e,n),o=zZ("halfPixelCenters",t,e,n);return[i.image.resizeBilinear(s,[r[0],r[1]],a,o)]}case"ResizeNearestNeighbor":{const s=zZ("images",t,e,n),r=zZ("size",t,e,n),a=zZ("alignCorners",t,e,n),o=zZ("halfPixelCenters",t,e,n);return[i.image.resizeNearestNeighbor(s,[r[0],r[1]],a,o)]}case"CropAndResize":{const s=zZ("image",t,e,n),r=zZ("boxes",t,e,n),a=zZ("boxInd",t,e,n),o=zZ("cropSize",t,e,n),l=zZ("method",t,e,n),u=zZ("extrapolationValue",t,e,n);return[i.image.cropAndResize(s,r,a,o,l,u)]}case"ImageProjectiveTransformV3":{const s=zZ("images",t,e,n),r=zZ("transforms",t,e,n),a=zZ("outputShape",t,e,n),o=zZ("fillValue",t,e,n),l=zZ("interpolation",t,e,n),u=zZ("fillMode",t,e,n);return[i.image.transform(s,r,l.toLowerCase(),u.toLowerCase(),o,a)]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"graph":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Const":return e[t.name];case"PlaceholderWithDefault":const s=zZ("default",t,e,n);return[XZ(t.name,e,n)||s];case"Placeholder":return[XZ(t.name,e,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[ZZ(zZ("x",t,e,n))];case"IdentityN":return zZ("x",t,e,n).map((t=>ZZ(t)));case"Shape":return[i.tensor1d(zZ("x",t,e,n).shape,"int32")];case"ShapeN":return zZ("x",t,e,n).map((t=>i.tensor1d(t.shape)));case"Size":return[i.scalar(zZ("x",t,e,n).size,"int32")];case"Rank":return[i.scalar(zZ("x",t,e,n).rank,"int32")];case"NoOp":return[i.scalar(1)];case"Print":const r=zZ("x",t,e,n),a=zZ("data",t,e,n),o=zZ("message",t,e,n),l=zZ("summarize",t,e,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(let t=0;t<a.length;t++)console.log(Array.prototype.slice.call(a[t].dataSync()).slice(0,l));return[r];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"logical":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Equal":return[i.equal(zZ("a",t,e,n),zZ("b",t,e,n))];case"NotEqual":return[i.notEqual(zZ("a",t,e,n),zZ("b",t,e,n))];case"Greater":return[i.greater(zZ("a",t,e,n),zZ("b",t,e,n))];case"GreaterEqual":return[i.greaterEqual(zZ("a",t,e,n),zZ("b",t,e,n))];case"Less":return[i.less(zZ("a",t,e,n),zZ("b",t,e,n))];case"LessEqual":return[i.lessEqual(zZ("a",t,e,n),zZ("b",t,e,n))];case"LogicalAnd":return[i.logicalAnd(zZ("a",t,e,n),zZ("b",t,e,n))];case"LogicalNot":return[i.logicalNot(zZ("a",t,e,n))];case"LogicalOr":return[i.logicalOr(zZ("a",t,e,n),zZ("b",t,e,n))];case"Select":case"SelectV2":return[i.where(zZ("condition",t,e,n),zZ("a",t,e,n),zZ("b",t,e,n))];case"BitwiseAnd":return[i.bitwiseAnd(zZ("a",t,e,n),zZ("b",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"matrices":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[i.matMul(zZ("a",t,e,n),zZ("b",t,e,n),zZ("transposeA",t,e,n),zZ("transposeB",t,e,n))];case"Einsum":return[i.einsum(zZ("equation",t,e,n),...zZ("tensors",t,e,n))];case"Transpose":return[i.transpose(zZ("x",t,e,n),zZ("perm",t,e,n))];case"_FusedMatMul":const[s,r]=zZ("fusedOps",t,e,n),a="biasadd"===s,o="prelu"===r,l=zZ("numArgs",t,e,n),u=zZ("leakyreluAlpha",t,e,n);if(a){if(o&&2!==l)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&1!==l)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[h,p]=zZ("args",t,e,n);return[i.fused.matMul({a:zZ("a",t,e,n),b:zZ("b",t,e,n),transposeA:zZ("transposeA",t,e,n),transposeB:zZ("transposeB",t,e,n),bias:h,activation:r,preluActivationWeights:p,leakyreluAlpha:u})];case"MatrixBandPart":return[i.linalg.bandPart(zZ("a",t,e,n),zZ("numLower",t,e,n),zZ("numUpper",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"normalization":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"EuclideanNorm":return[i.euclideanNorm(zZ("x",t,e,n),zZ("axis",t,e,n),zZ("keepDims",t,e,n))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[i.batchNorm(zZ("x",t,e,n),zZ("mean",t,e,n),zZ("variance",t,e,n),zZ("offset",t,e,n),zZ("scale",t,e,n),zZ("epsilon",t,e,n))];case"LRN":return[i.localResponseNormalization(zZ("x",t,e,n),zZ("radius",t,e,n),zZ("bias",t,e,n),zZ("alpha",t,e,n),zZ("beta",t,e,n))];case"Softmax":return[i.softmax(zZ("x",t,e,n))];case"LogSoftmax":return[i.logSoftmax(zZ("x",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"ragged":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"RaggedGather":{const{outputNestedSplits:s,outputDenseValues:r}=i.raggedGather(zZ("paramsNestedSplits",t,e,n),zZ("paramsDenseValues",t,e,n),zZ("indices",t,e,n),zZ("outputRaggedRank",t,e,n));return s.concat(r)}case"RaggedRange":{const{rtNestedSplits:s,rtDenseValues:r}=i.raggedRange(zZ("starts",t,e,n),zZ("limits",t,e,n),zZ("splits",t,e,n));return[s,r]}case"RaggedTensorToTensor":return[i.raggedTensorToTensor(zZ("shape",t,e,n),zZ("values",t,e,n),zZ("defaultValue",t,e,n),zZ("rowPartitionTensors",t,e,n),zZ("rowPartitionTypes",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"reduction":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Max":{const s=zZ("axis",t,e,n),r=zZ("keepDims",t,e,n);return[i.max(zZ("x",t,e,n),s,r)]}case"Mean":{const s=zZ("axis",t,e,n),r=zZ("keepDims",t,e,n);return[i.mean(zZ("x",t,e,n),s,r)]}case"Min":{const s=zZ("axis",t,e,n),r=zZ("keepDims",t,e,n);return[i.min(zZ("x",t,e,n),s,r)]}case"Sum":{const s=zZ("axis",t,e,n),r=zZ("keepDims",t,e,n);return[i.sum(zZ("x",t,e,n),s,r)]}case"All":{const s=zZ("axis",t,e,n),r=zZ("keepDims",t,e,n);return[i.all(zZ("x",t,e,n),s,r)]}case"Any":{const s=zZ("axis",t,e,n),r=zZ("keepDims",t,e,n);return[i.any(zZ("x",t,e,n),s,r)]}case"ArgMax":{const s=zZ("axis",t,e,n);return[i.argMax(zZ("x",t,e,n),s)]}case"ArgMin":{const s=zZ("axis",t,e,n);return[i.argMin(zZ("x",t,e,n),s)]}case"Prod":{const s=zZ("axis",t,e,n),r=zZ("keepDims",t,e,n);return[i.prod(zZ("x",t,e,n),s,r)]}case"Cumprod":{const s=zZ("axis",t,e,n),r=zZ("exclusive",t,e,n),a=zZ("reverse",t,e,n);return[i.cumprod(zZ("x",t,e,n),s,r,a)]}case"Cumsum":{const s=zZ("axis",t,e,n),r=zZ("exclusive",t,e,n),a=zZ("reverse",t,e,n);return[i.cumsum(zZ("x",t,e,n),s,r,a)]}case"Bincount":const s=zZ("x",t,e,n),r=zZ("weights",t,e,n),a=zZ("size",t,e,n);return[i.bincount(s,r,a)];case"DenseBincount":{const s=zZ("x",t,e,n),r=zZ("weights",t,e,n),a=zZ("size",t,e,n),o=zZ("binaryOutput",t,e,n);return[i.denseBincount(s,r,a,o)]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"slice_join":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"ConcatV2":case"Concat":{const s=zZ("n",t,e,n),r=zZ("axis",t,e,n);let a=zZ("tensors",t,e,n);return a=a.slice(0,s),[i.concat(a,r)]}case"Gather":{const s=zZ("x",t,e,n),r=zZ("indices",t,e,n);return[i.gather(s,i.cast(r,"int32"),0)]}case"GatherV2":{const s=zZ("axis",t,e,n),r=zZ("batchDims",t,e,n),a=zZ("x",t,e,n),o=zZ("indices",t,e,n);return[i.gather(a,i.cast(o,"int32"),s,r)]}case"Reverse":{const s=zZ("dims",t,e,n),r=[];for(let t=0;t<s.length;t++)s[t]&&r.push(t);const a=zZ("x",t,e,n);return[i.reverse(a,r)]}case"ReverseV2":{const s=zZ("axis",t,e,n),r=zZ("x",t,e,n);return[i.reverse(r,s)]}case"Slice":{const s=zZ("begin",t,e,n),r=zZ("size",t,e,n);return[i.slice(zZ("x",t,e,n),s,r)]}case"StridedSlice":{const s=zZ("begin",t,e,n),r=zZ("end",t,e,n),a=zZ("strides",t,e,n),o=zZ("beginMask",t,e,n),l=zZ("endMask",t,e,n),u=zZ("ellipsisMask",t,e,n),h=zZ("newAxisMask",t,e,n),p=zZ("shrinkAxisMask",t,e,n),c=zZ("x",t,e,n);return[i.stridedSlice(c,s,r,a,o,l,u,h,p)]}case"Pack":return ED((()=>{const s=zZ("axis",t,e,n),r=zZ("tensors",t,e,n),a=r[0].shape,o=i.squeeze(r[0]).shape,l=r.map((t=>{const e=vO(t.shape,a);if(!e&&!vO(i.squeeze(t).shape,o))throw new Error("the input tensors shape does not match");return e?t:i.reshape(t,a)}));return[i.stack(l,s)]}));case"Unpack":{const s=zZ("axis",t,e,n),r=zZ("tensor",t,e,n);return i.unstack(r,s)}case"Tile":{const s=zZ("reps",t,e,n);return[i.tile(zZ("x",t,e,n),s)]}case"Split":case"SplitV":{const s=zZ("axis",t,e,n),r=zZ("numOrSizeSplits",t,e,n),a=zZ("x",t,e,n);return i.split(a,r,s)}case"ScatterNd":{const s=zZ("indices",t,e,n),r=zZ("values",t,e,n),a=zZ("shape",t,e,n);return[i.scatterND(s,r,a)]}case"GatherNd":{const s=zZ("x",t,e,n),r=zZ("indices",t,e,n);return[i.gatherND(s,r)]}case"SparseToDense":{const s=zZ("sparseIndices",t,e,n),r=zZ("outputShape",t,e,n),a=zZ("sparseValues",t,e,n),o=zZ("defaultValue",t,e,n);return[i.sparseToDense(s,a,r,a.dtype===o.dtype?o:i.cast(o,a.dtype))]}case"TensorScatterUpdate":{const s=zZ("indices",t,e,n),r=zZ("values",t,e,n),a=zZ("tensor",t,e,n);return[i.tensorScatterUpdate(a,s,r)]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"sparse":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"SparseFillEmptyRows":{const{outputIndices:s,outputValues:r,emptyRowIndicator:a,reverseIndexMap:o}=i.sparse.sparseFillEmptyRows(zZ("indices",t,e,n),zZ("values",t,e,n),zZ("denseShape",t,e,n),zZ("defaultValue",t,e,n));return[s,r,a,o]}case"SparseReshape":{const{outputIndices:s,outputShape:r}=i.sparse.sparseReshape(zZ("inputIndices",t,e,n),zZ("inputShape",t,e,n),zZ("newShape",t,e,n));return[s,r]}case"SparseSegmentMean":return[i.sparse.sparseSegmentMean(zZ("data",t,e,n),zZ("indices",t,e,n),zZ("segmentIds",t,e,n))];case"SparseSegmentSum":return[i.sparse.sparseSegmentSum(zZ("data",t,e,n),zZ("indices",t,e,n),zZ("segmentIds",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"spectral":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"FFT":return[i.fft(zZ("x",t,e,n))];case"IFFT":return[i.ifft(zZ("x",t,e,n))];case"RFFT":return[i.rfft(zZ("x",t,e,n))];case"IRFFT":return[i.irfft(zZ("x",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"string":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"StaticRegexReplace":return[i.string.staticRegexReplace(zZ("input",t,e,n),zZ("pattern",t,e,n),zZ("rewrite",t,e,n),zZ("replaceGlobal",t,e,n))];case"StringNGrams":{const{nGrams:s,nGramsSplits:r}=i.string.stringNGrams(zZ("data",t,e,n),zZ("dataSplits",t,e,n),zZ("separator",t,e,n),zZ("nGramWidths",t,e,n),zZ("leftPad",t,e,n),zZ("rightPad",t,e,n),zZ("padWidth",t,e,n),zZ("preserveShortSequences",t,e,n));return[s,r]}case"StringSplit":{const{indices:s,values:r,shape:a}=i.string.stringSplit(zZ("input",t,e,n),zZ("delimiter",t,e,n),zZ("skipEmpty",t,e,n));return[s,r,a]}case"StringToHashBucketFast":return[i.string.stringToHashBucketFast(zZ("input",t,e,n),zZ("numBuckets",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"transformation":return s((()=>((t,e,n,i=zt)=>{switch(t.op){case"Cast":return[i.cast(zZ("x",t,e,n),zZ("dtype",t,e,n))];case"ExpandDims":{const s=zZ("axis",t,e,n);return[i.expandDims(zZ("x",t,e,n),s)]}case"Squeeze":{const s=zZ("axis",t,e,n);return[i.squeeze(zZ("x",t,e,n),s)]}case"Reshape":return[i.reshape(zZ("x",t,e,n),zZ("shape",t,e,n))];case"EnsureShape":return[i.ensureShape(zZ("x",t,e,n),zZ("shape",t,e,n))];case"MirrorPad":return[i.mirrorPad(zZ("x",t,e,n),zZ("padding",t,e,n),zZ("mode",t,e,n))];case"PadV2":case"Pad":return[i.pad(zZ("x",t,e,n),zZ("padding",t,e,n),zZ("constantValue",t,e,n))];case"SpaceToBatchND":{const s=zZ("blockShape",t,e,n),r=zZ("paddings",t,e,n);return[i.spaceToBatchND(zZ("x",t,e,n),s,r)]}case"BatchToSpaceND":{const s=zZ("blockShape",t,e,n),r=zZ("crops",t,e,n);return[i.batchToSpaceND(zZ("x",t,e,n),s,r)]}case"DepthToSpace":{const s=zZ("blockSize",t,e,n),r=zZ("dataFormat",t,e,n).toUpperCase();return[i.depthToSpace(zZ("x",t,e,n),s,r)]}case"BroadcastTo":return[i.broadcastTo(zZ("x",t,e,n),zZ("shape",t,e,n))];case"BroadcastArgs":return[i.broadcastArgs(zZ("s0",t,e,n),zZ("s1",t,e,n))];default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n)));case"hash_table":return(async(t,e,n,i)=>{switch(t.op){case"HashTable":case"HashTableV2":{const s=i.getHashTableHandleByName(t.name);if(null!=s)return[s];{const s=zZ("keyDType",t,e,n),r=zZ("valueDType",t,e,n),a=new H0(s,r);return i.addHashTable(t.name,a),[a.handle]}}case"InitializeTable":case"InitializeTableV2":case"LookupTableImport":case"LookupTableImportV2":{const s=zZ("tableHandle",t,e,n,i),r=zZ("keys",t,e,n),a=zZ("values",t,e,n),o=i.getHashTableById(s.id);return[await o.import(r,a)]}case"LookupTableFind":case"LookupTableFindV2":{const s=zZ("tableHandle",t,e,n,i),r=zZ("keys",t,e,n),a=zZ("defaultValue",t,e,n),o=i.getHashTableById(s.id);return[await o.find(r,a)]}case"LookupTableSize":case"LookupTableSizeV2":{const s=zZ("tableHandle",t,e,n,i);return[i.getHashTableById(s.id).tensorSize()]}default:throw TypeError(`Node type ${t.op} is not implemented`)}})(t,e,n,i);case"custom":const r=HZ(t.op);if(r&&r.customExecutor)return r.customExecutor(new D0(t,e,n));throw TypeError(`Custom op ${t.op} is not registered.`);default:throw TypeError(`Unknown op '${t.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(t,e,n);return nA(r)?r.then((t=>[].concat(t))):[].concat(r)}class z0{constructor(t={},e={},n={},i={},s){this.weightMap=t,this.tensorArrayMap=e,this.tensorListMap=n,this.functionMap=i,this.parseNodeNameCache=s,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(t,e){return{id:t,frameName:e,iterationId:0}}set currentContext(t){this.contexts!==t&&(this.contexts=t,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const t=[];for(let e=0;e<this.contexts.length-1;e++){const n=this.contexts.slice(0,this.contexts.length-e);t.push(this.contextIdforContexts(n))}t.push(""),this._currentContextIds=t}contextIdforContexts(t){return t?t.map((t=>0===t.id&&0===t.iterationId?"":`${t.frameName}-${t.iterationId}`)).join("/"):""}enterFrame(t){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,t)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()}nextIteration(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");{this.contexts=this.contexts.slice(),this.lastId++;const t=Object.assign({},this.contexts[this.contexts.length-1]);t.iterationId+=1,t.id=this.lastId,this.contexts.splice(-1,1,t),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}}getWeight(t){return this.weightMap[t]}addTensorArray(t){this.tensorArrayMap[t.id]=t}getTensorArray(t){return this.tensorArrayMap[t]}addTensorList(t){this.tensorListMap[t.id]=t}getTensorList(t){return this.tensorListMap[t]}dispose(t){for(const e in this.tensorArrayMap)this.tensorArrayMap[e].clearAndClose(t);for(const e in this.tensorListMap)this.tensorListMap[e].clearAndClose(t)}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function X0(t,e,n,i){const s=new Set,r=[];let a=null,o=null;const l=new Set,u=new Set(Object.keys(t).map((t=>QZ(t)[0])));i=i||[];const h=new Set(i.map((t=>QZ(t.name)[0]))),p=[...e];for(;p.length>0;){const t=p.pop();(Z0(t)||t1(t)||e1(t))&&null==a&&(a=t,o=a.children.map((t=>t.name)).filter((t=>s.has(t)))),s.add(t.name),null==n[t.name]&&(u.has(t.name)||h.has(t.name)||(0!==t.inputs.length?t.inputs.forEach((t=>{l.has(t.name)||(l.add(t.name),p.push(t))})):r.push(t.name)))}return{inputs:t,outputs:e,usedNodes:s,missingInputs:r,dynamicNode:a,syncInputs:o}}function j0(t,e){const{usedNodes:n,inputs:i}=e,s=Object.keys(i).map((t=>QZ(t)[0])).map((e=>t.nodes[e])),r=t.initNodes||[],a=t=>n.has("string"==typeof t?t:t.name);function o(t){return[...new Map(t.map((t=>[t.name,t]))).values()]}const l=o([...s,...t.weights,...r]).filter(a),u=o([...l,...Object.values(t.nodes)]).filter(a),h=new Map(u.map((t=>[t.name,t]))),p={};for(const t of u){p[t.name]=p[t.name]||0;for(const e of t.children)a(e)||(p[e.name]=Number.POSITIVE_INFINITY),p[e.name]=(p[e.name]||0)+1}const c=Object.entries(p).filter((([,t])=>0===t)).map((([t])=>t)),d=[...c];for(;c.length>0;){const t=c.pop(),e=h.get(t);for(const t of e.children.filter(a))0==--p[t.name]&&(d.push(t.name),c.push(t.name))}const f=function(t,e){const n=new Map(t.map((t=>[t.name,t]))),i=e.map((t=>t.name)),s=new Set(i);for(;i.length>0;){const t=i.pop(),e=n.get(t);for(const t of e.children)n.has(t.name)&&!s.has(t.name)&&(s.add(t.name),i.push(t.name))}const r=t.filter((t=>s.has(t.name)));return r}(d.map((t=>h.get(t))),l);return function(t,e){const n=new Map(t.map(((t,e)=>[t.name,e]))),i=new Set(e.map((t=>t.name))),s=t=>i.has("string"==typeof t?t:t.name),r=new Set(t.map((t=>t.name))),a=t=>r.has("string"==typeof t?t:t.name);for(const e of t){for(const t of e.children.filter(a)){if(!n.has(t.name))throw new q0(`Child ${t.name} of node ${e.name} is unreachable.`);if(n.get(e.name)>n.get(t.name))throw new q0(`Node ${e.name} is scheduled to run after its child ${t.name}.`)}if(!s(e))for(const t of e.inputs){if(!n.has(t.name))throw new q0(`Input ${t.name} of node ${e.name} is unreachable.`);if(n.get(t.name)>n.get(e.name))throw new q0(`Node ${e.name} is scheduled to run before its input ${t.name}.`)}}}(f,l),f}class q0 extends Error{constructor(t){super(`NodesExecutionOrderError: ${t}`)}}const K0=new Set(["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"]),Q0=new Set(["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"]),J0=new Set(["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"]);function Z0(t){return K0.has(t.op)}function t1(t){return Q0.has(t.op)}function e1(t){return J0.has(t.op)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class n1{get weightIds(){return this.parent?this.parent.weightIds:this._weightIds}get functionExecutorMap(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}get weightMap(){return this.parent?this.parent.weightMap:this._weightMap}set weightMap(t){const e=Object.keys(t).map((e=>t[e].map((t=>t.id))));this._weightIds=[].concat(...e),this._weightMap=t}set resourceManager(t){this._resourceManager=t}get inputs(){return this._inputs.map((t=>({name:t.name,shape:t.attrParams.shape?t.attrParams.shape.value:void 0,dtype:t.attrParams.dtype?t.attrParams.dtype.value:void 0})))}get outputs(){return this._outputs.map((t=>({name:t.name,shape:t.attrParams.shape?t.attrParams.shape.value:void 0,dtype:t.attrParams.dtype?t.attrParams.dtype.value:void 0})))}get inputNodes(){return this._inputs.map((t=>t.signatureKey||t.name))}get outputNodes(){return this._outputs.map((t=>{const e=t.signatureKey||t.name;return t.defaultOutput?`${e}:${t.defaultOutput}`:e}))}get functions(){return Object.keys(this._functions).reduce(((t,e)=>(t[e]=this._functions[e].signature,t)),{})}constructor(t,e){this.graph=t,this.parent=e,this.compiledMap=new Map,this.parseNodeNameCache=new Map,this._weightMap={},this.SEPARATOR=",",this._functions={},this._functionExecutorMap={},this.keepIntermediateTensors=!1,this._outputs=t.outputs,this._inputs=t.inputs,this._initNodes=t.initNodes,this._signature=t.signature,this._functions=t.functions,null!=t.functions&&Object.keys(t.functions).forEach((e=>{this._functionExecutorMap[e]=new n1(t.functions[e],this)}))}getCompilationKey(t,e){const n=t.map((t=>t.name)).sort(),i=e.map((t=>t.name)).sort();return n.join(this.SEPARATOR)+"--"+i.join(this.SEPARATOR)}compile(t,e){const n=X0(t,e,this.weightMap,this._initNodes),{missingInputs:i,dynamicNode:s,syncInputs:r}=n;if(null!=s)throw new Error(`This execution contains the node '${s.name}', which has the dynamic op '${s.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${r}]`);if(i.length>0){const n=e.map((t=>t.name)),s=Object.keys(t);throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${s}]. Missing the following inputs: [${i}]`)}const a=j0(this.graph,n),o=function(t){const e=new Map(t.map(((t,e)=>[t.name,e]))),n=Number.MAX_SAFE_INTEGER,i=t.map(((t,e)=>Z0(t)?n:e)),s=t=>{const n=i[e.get(t.name)];return null==n?-1:n},r=t.map(((t,e)=>t.children.map(s).reduce(((t,e)=>Math.max(t,e)),i[e]))),a=new Map;for(let e=0;e<t.length;++e){const i=r[e];if(i===n)continue;const s=t[e],o=t[i];a.has(o.name)||a.set(o.name,[]),a.get(o.name).push(s)}return a}(a);return{orderedNodes:a,nodeLiveUntilMap:o}}cloneAndKeepTensor(t){if(null==t)return null;const e=t.clone();return vD(e),e}cloneTensorList(t){if(!t)return null;const e=t.map((t=>this.cloneAndKeepTensor(t)));return e}cloneTensorMap(t){return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,this.cloneTensorList(e)])))}execute(t,e){this.disposeIntermediateTensors(),t=this.mapInputs(t);const n=Object.keys(t).sort();this.checkInputs(t),this.checkInputShapeAndType(t),e=this.mapOutputs(e),this.checkOutputs(e);const i=n.map((t=>this.graph.nodes[QZ(t)[0]])),s=e.map((t=>QZ(t)[0])),r=new Set(s);let a=s.map((t=>this.graph.nodes[t]));0===a.length&&(a=this._outputs);const o=this.getCompilationKey(i,a);let l=this.compiledMap.get(o);null==l&&(l=this.compile(t,a),this.compiledMap.set(o,l));try{this.keepIntermediateTensors=aA().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(t){this.keepIntermediateTensors=!1,console.warn(t.message)}const u={},h={};return ED((()=>{const n=new z0(this.weightMap,u,h,this.functionExecutorMap,this.parseNodeNameCache),i=Object.assign({},this.weightMap);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap)),Object.keys(t).forEach((e=>{const[s,r]=QZ(e,n),a=[];a[r]=t[e],i[s]=a,this.keepIntermediateTensors&&(this.clonedTensorsMap[s]=this.cloneTensorList(a))}));const s=this.getFrozenTensorIds(i),{orderedNodes:a,nodeLiveUntilMap:o}=l;for(const t of a){if(i[t.name])continue;const e=W0(t,i,n,this._resourceManager);if(nA(e))throw new Error(`The execution of the op '${t.op}' returned a promise. Please use model.executeAsync() instead.`);i[t.name]=e,this.keepIntermediateTensors&&(this.clonedTensorsMap[t.name]=this.cloneTensorList(e)),this.checkTensorForDisposalWithNodeLiveUntilInfo(t,i,n,s,r,o.get(t.name))}return null==this.parent&&n.dispose(s),e.map((t=>XZ(t,i,n)))}))}getFrozenTensorIds(t){const e=[].concat.apply([],Object.keys(t).map((e=>t[e])).map((t=>t.map((t=>t.id)))));return new Set(e)}checkTensorForDisposal(t,e,n,i,s,r,a){if(!Z0(e)&&!r.has(t)){for(const i of n[t])null!=i&&(a[i.id]=(a[i.id]||0)+e.children.length);for(const t of e.inputs){if(Z0(t))continue;const e=jZ(t.name,n,i);if(null!=e)for(const t of e){if(!t||t.kept||s.has(t.id))continue;const e=a[t.id];1===e?(t.dispose(),delete a[t.id]):null!=e&&a[t.id]--}}}}checkTensorForDisposalWithNodeLiveUntilInfo(t,e,n,i,s,r){function a(t){return Z0(t)||s.has(t.name)}if(!Z0(t)&&null!=r)for(const t of r){if(a(t))continue;const s=jZ(t.name,e,n);for(const t of s)!t||t.kept||i.has(t.id)||t.dispose()}}async executeAsync(t,e){return this._executeAsync(t,e)}disposeIntermediateTensors(){this.clonedTensorsMap&&(Object.values(this.clonedTensorsMap).forEach((t=>{for(const e of t)e&&!e.isDisposed&&e.dispose()})),this.clonedTensorsMap=null)}getIntermediateTensors(){return this.clonedTensorsMap}async _executeAsync(t,e,n=!1,i={},s={}){this.disposeIntermediateTensors(),n||(t=this.mapInputs(t),this.checkInputs(t),this.checkInputShapeAndType(t),e=this.mapOutputs(e),this.checkOutputs(e));try{this.keepIntermediateTensors=aA().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(t){this.keepIntermediateTensors=!1,console.warn(t.message)}const r=new z0(this.weightMap,i,s,this.functionExecutorMap,this.parseNodeNameCache);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap));const a=await this.executeWithControlFlow(t,r,e,n),o=e.map((t=>XZ(t,a,r))),l=o.map((t=>t.id)),u=Object.keys(t).map((e=>t[e].id)),h=new Set([...l,...u,...this.weightIds]);return Object.values(a).forEach((t=>{t.forEach((t=>{!t||t.isDisposed||h.has(t.id)||t.dispose()}))})),null==this.parent&&r.dispose(h),o}async executeFunctionAsync(t,e,n){const i=t.reduce(((t,e,n)=>(t[this.inputs[n].name]=e,t)),{});return this._executeAsync(i,this.outputNodes,!0,e,n)}async executeWithControlFlow(t,e,n,i){const s=Object.keys(t),r=s.map((t=>this.graph.nodes[QZ(t)[0]])),a=n.map((t=>QZ(t)[0])),o=new Set(a);let l=a.map((t=>this.graph.nodes[t]));0===l.length&&(l=this._outputs);const{usedNodes:u,missingInputs:h,dynamicNode:p,syncInputs:c}=X0(t,l,this.weightMap,this._initNodes),d=[...r,...this.graph.weights,...this._initNodes||[]].map((t=>({node:t,contexts:e.currentContext}))),f=Object.assign({},this.weightMap);Object.keys(t).forEach((e=>{const[n,i]=QZ(e),s=[];s[i]=t[e],f[n]=s}));const m={},g=this.getFrozenTensorIds(f),_={};for(;d.length>0;){const t=this.processStack(r,d,e,f,_,g,o,m,u);await Promise.all(t)}null!=p||i||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const T=l.filter((t=>!Z0(t)&&!XZ(t.name,f,e))).map((t=>t.name));if(T.length>0){let t="";throw null!=p&&(t=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${c}]`),new Error(`Cannot compute the outputs [${T}] from the provided inputs [${s}]. Consider providing the following inputs: [${h}]. ${t}`)}return f}processStack(t,e,n,i,s,r,a,o,l){const u=[];for(;e.length>0;){const t=e.pop();n.currentContext=t.contexts;let h="";if("Enter"===t.node.op&&zZ("isConstant",t.node,i,n)&&([h]=qZ(t.node.name,n)),null==i[t.node.name]){const p=W0(t.node,i,n,this._resourceManager);h||([h]=qZ(t.node.name,n));const c=n.currentContext;nA(p)?u.push(p.then((u=>(i[h]=u,this.keepIntermediateTensors&&(this.clonedTensorsMap[h]=this.cloneTensorList(u)),n.currentContext=c,this.checkTensorForDisposal(h,t.node,i,n,r,a,o),this.processChildNodes(t.node,e,n,i,s,l),u)))):(i[h]=p,this.keepIntermediateTensors&&(this.clonedTensorsMap[h]=this.cloneTensorList(p)),this.checkTensorForDisposal(h,t.node,i,n,r,a,o),this.processChildNodes(t.node,e,n,i,s,l))}else this.processChildNodes(t.node,e,n,i,s,l)}return u}processChildNodes(t,e,n,i,s,r){t.children.forEach((t=>{const[a]=qZ(t.name,n);!s[a]&&r.has(t.name)&&("Merge"===t.op?t.inputNames.some((t=>!!XZ(t,i,n)))&&(s[a]=!0,e.push({contexts:n.currentContext,node:t})):t.inputNames.every((t=>!!XZ(t,i,n)))&&(s[a]=!0,e.push({contexts:n.currentContext,node:t})))}))}dispose(){Object.keys(this.weightMap).forEach((t=>this.weightMap[t].forEach((t=>t.dispose()))))}checkInputShapeAndType(t){Object.keys(t).forEach((e=>{const n=t[e],[i]=QZ(e),s=this.graph.nodes[i];if(s.attrParams.shape&&s.attrParams.shape.value){const t=s.attrParams.shape.value;_O(t.length===n.shape.length&&n.shape.every(((e,n)=>-1===t[n]||t[n]===e)),(()=>`The shape of dict['${s.name}'] provided in model.execute(dict) must be [${t}], but was [${n.shape}]`))}s.attrParams.dtype&&s.attrParams.dtype.value&&_O(n.dtype===s.attrParams.dtype.value,(()=>`The dtype of dict['${s.name}'] provided in model.execute(dict) must be ${s.attrParams.dtype.value}, but was ${n.dtype}`))}))}mapInputs(t){var e,n;const i={};for(const s in t){const r=null===(n=null===(e=this._signature)||void 0===e?void 0:e.inputs)||void 0===n?void 0:n[s];null!=r?i[r.name]=t[s]:i[s]=t[s]}return i}checkInputs(t){const e=Object.keys(t).filter((t=>{const[e]=QZ(t);return null==this.graph.nodes[e]}));if(e.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${e}] that are not part of graph`)}mapOutputs(t){return t.map((t=>{var e,n;const i=null===(n=null===(e=this._signature)||void 0===e?void 0:e.outputs)||void 0===n?void 0:n[t];return null!=i?i.name:t}),{})}checkOutputs(t){t.forEach((t=>{const[e]=QZ(t);if(!this.graph.nodes[e])throw new Error(`The output '${t}' is not found in the graph`)}))}}class i1{constructor(t={},e={}){this.hashTableNameToHandle=t,this.hashTableMap=e}addHashTable(t,e){this.hashTableNameToHandle[t]=e.handle,this.hashTableMap[e.id]=e}getHashTableHandleByName(t){return this.hashTableNameToHandle[t]}getHashTableById(t){return this.hashTableMap[t]}dispose(){for(const t in this.hashTableMap)this.hashTableMap[t].clearAndClose(),delete this.hashTableMap[t];for(const t in this.hashTableNameToHandle)this.hashTableNameToHandle[t].dispose(),delete this.hashTableNameToHandle[t]}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const s1="?tfjs-format=file",r1="model.json";class a1{get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}constructor(t,e={},n=ht){this.modelUrl=t,this.loadOptions=e,this.version="n/a",this.io=n,null==e&&(this.loadOptions={}),this.resourceManager=new i1}findIOHandler(){const t=this.modelUrl;if(null!=t.load)this.handler=t;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(t,this.loadOptions);else{const e=this.io.getLoadHandlers(t,this.loadOptions);if(0===e.length)e.push(this.io.browserHTTPRequest(t,this.loadOptions));else if(e.length>1)throw new Error(`Found more than one (${e.length}) load handlers for URL '${[t]}'`);this.handler=e[0]}}load(){if(this.findIOHandler(),null==this.handler.load)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const t=this.handler.load();return nA(t)?t.then((t=>null==t.getWeightStream?this.loadSync(t):this.loadStreaming(t))):this.loadSync(t)}loadSync(t){const e=this.io.decodeWeights(t.weightData,t.weightSpecs);return this.loadWithWeightMap(t,e)}async loadStreaming(t){if(null==t.getWeightStream)throw new Error("Model artifacts missing streamWeights function");const e=await UD(t.getWeightStream(),t.weightSpecs);return this.loadWithWeightMap(t,e)}loadWithWeightMap(t,e){this.artifacts=t;const n=this.artifacts.modelTopology;let i=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){const t=this.artifacts.userDefinedMetadata;null!=t.signature&&(i=t.signature),null!=t.structuredOutputKeys&&(this.structuredOutputKeys=t.structuredOutputKeys)}if(this.signature=i,this.version=`${n.versions.producer}.${n.versions.minConsumer}`,this.executor=new n1(y0.Instance.transformGraph(n,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(e),this.executor.resourceManager=this.resourceManager,null!=t.modelInitializer&&null!=t.modelInitializer.node){const e=y0.Instance.transformGraph(t.modelInitializer);this.initializer=new n1(e),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializerSignature=t.initializerSignature}return!0}async save(t,e){if("string"==typeof t){const e=this.io.getSaveHandlers(t);if(0===e.length)throw new Error(`Cannot find any save handlers for URL '${t}'`);if(e.length>1)throw new Error(`Found more than one (${e.length}) save handlers for URL '${t}'`);t=e[0]}if(null==t.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return t.save(this.artifacts)}addStructuredOutputNames(t){if(this.structuredOutputKeys){const e={};return(t instanceof xk?[t]:t).forEach(((t,n)=>e[this.structuredOutputKeys[n]]=t)),e}return t}predict(t,e){const n=this.execute(t,this.outputNodes);return this.addStructuredOutputNames(n)}async predictAsync(t,e){const n=await this.executeAsync(t,this.outputNodes);return this.addStructuredOutputNames(n)}normalizeInputs(t){var e;if(!(t instanceof xk||Array.isArray(t))){const n=null===(e=this.signature)||void 0===e?void 0:e.inputs;if(null!=n)for(const e in n){const i=n[e];null!=i.resourceId&&(t[e]=this.resourceIdToCapturedInput[i.resourceId])}return t}t=Array.isArray(t)?t:[t];const n=Object.keys(this.resourceIdToCapturedInput).length;if(t.length+n!==this.inputNodes.length)throw new Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length-n} non-resource placeholders, while there are ${t.length} input tensors provided.`);let i=0;return this.inputNodes.reduce(((e,n)=>{var s,r,a;const o=null===(a=null===(r=null===(s=this.signature)||void 0===s?void 0:s.inputs)||void 0===r?void 0:r[n])||void 0===a?void 0:a.resourceId;return e[n]=null!=o?this.resourceIdToCapturedInput[o]:t[i++],e}),{})}normalizeOutputs(t){return t=t||this.outputNodes,Array.isArray(t)?t:[t]}executeInitializerGraph(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.execute({},[]):this.initializer.execute({},Object.keys(this.initializerSignature.outputs))}async executeInitializerGraphAsync(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.executeAsync({},[]):this.initializer.executeAsync({},Object.keys(this.initializerSignature.outputs))}setResourceIdToCapturedInput(t){if(this.resourceIdToCapturedInput={},this.initializerSignature){const e=this.initializerSignature.outputs,n=Object.keys(e);for(let i=0;i<n.length;i++){const s=e[n[i]];this.resourceIdToCapturedInput[s.resourceId]=t[i]}}}execute(t,e){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(this.executeInitializerGraph()),t=this.normalizeInputs(t),e=this.normalizeOutputs(e);const n=this.executor.execute(t,e);return n.length>1?n:n[0]}async executeAsync(t,e){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()),t=this.normalizeInputs(t),e=this.normalizeOutputs(e);const n=await this.executor.executeAsync(t,e);return n.length>1?n:n[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(t){return Object.keys(t).reduce(((e,n)=>(e[n]=[t[n]],e)),{})}dispose(){this.executor.dispose(),this.initializer&&(this.initializer.dispose(),this.resourceIdToCapturedInput&&bD(this.resourceIdToCapturedInput)),this.resourceManager.dispose()}}async function o1(t,e={},n=ht){if(null==t)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==e&&(e={}),e.fromTFHub&&"string"==typeof t&&(t=function(t){t.endsWith("/")||(t+="/");return`${t}${r1}${s1}`}(t));const i=new a1(t,e,n);return await i.load(),i}function l1(t){if(null==t)throw new Error("modelUrl in loadGraphModelSync() cannot be null. Please provide model artifacts or an IOHandler that loads the model");let e;if(t instanceof Array){const[n,i]=t;if(!n)throw new Error("modelJSON must be the first element of the array");if(!(i&&i instanceof ArrayBuffer))throw new Error("An ArrayBuffer of weights must be the second element of the array");if(!("modelTopology"in n))throw new Error("Model JSON is missing 'modelTopology'");if(!("weightsManifest"in n))throw new Error("Model JSON is missing 'weightsManifest'");e=UF(jD(n,QD(n.weightsManifest),i))}else if("load"in t)e=t;else{if(!("modelTopology"in t&&"weightSpecs"in t&&"weightData"in t))throw new Error("Unknown model format");e=UF(t)}const n=new a1(e);return n.load(),n}
/** @license See the LICENSE file. */
const u1="4.22.0";function h1(t,e,n=new Map,i=new Set){if(null==t)return null;if("function"==typeof Blob&&t instanceof Blob)return t.slice();if(i.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);const s=e(t);if(s.recurse&&null!==s.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(s.recurse){if(m1(t)){const s=Array.isArray(t)?[]:{};i.add(t);for(const r in t){const a=h1(t[r],e,n,i);s[r]=a}return i.delete(t),t.__proto__&&(s.__proto__=t.__proto__),s}throw new Error(`Can't recurse into non-iterable type: ${t}`)}return n.set(t,s.value),s.value}function p1(t,e=d1){return c1(t,e)}function c1(t,e,n=new Set){const i=t[0];if(n.has(i))throw new Error("Circular references are not supported.");const s=e(t);if(s.recurse&&null!==s.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(s.recurse){if(m1(i)){const s=Array.isArray(i)?[]:{};n.add(i);for(const r in i){const i=c1(t.map((t=>t[r])),e,n);s[r]=i}return n.delete(i),s}throw new Error(`Can't recurse into non-iterable type: ${i}`)}return s.value}function d1(t){return null===t?null:m1(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}async function f1(t,e){const n=new Map;h1(t,e,n);for(const t of Array.from(n.keys())){const e=n.get(t);if(nA(e)){const i=await e;n.set(t,i)}}return h1(t,e,n)}function m1(t){let e=!1;if(aA().get("IS_BROWSER"))e=t instanceof TextDecoder;else{const{StringDecoder:n}=__webpack_require__(551);e=t instanceof n}return null!=t&&!ArrayBuffer.isView(t)&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof xk)&&!(t instanceof Promise)&&!e)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
function g1(t){
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
return function(t,e){return h1(t,e)}(t,_1)}function _1(t){return t instanceof xk?{value:t.clone(),recurse:!1}:m1(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class T1{constructor(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}wrap(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity}get(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]}set(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e}length(){let t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)}pushAll(t){for(const e of t)this.push(e)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const t=this.get(this.end);return this.set(this.end,void 0),t}unshift(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t}shuffleExcise(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class y1 extends T1{constructor(){super(y1.INITIAL_CAPACITY)}isFull(){return!1}push(t){super.isFull()&&this.expand(),super.push(t)}unshift(t){super.isFull()&&this.expand(),super.unshift(t)}expand(){const t=2*this.capacity,e=new Array(t),n=this.length();for(let t=0;t<n;t++)e[t]=this.get(this.wrap(this.begin+t));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
function I1(t){return new w1(t)}function E1(t){return new S1(t)}function b1(t,e){return new F1(t,e)}y1.INITIAL_CAPACITY=32;class v1{async toArray(){const t=[];let e=await this.next();for(;!e.done;)t.push(e.value),e=await this.next();return t}async toArrayForTest(){const t=this.prefetch(100),e=[];let n=await t.next();for(;!n.done;)e.push(n.value),n=await t.next();return e}async resolveFully(){let t=await this.next();for(;!t.done;)t=await this.next()}async resolveWhile(t){let e=await this.next(),n=t(e.value);for(;!e.done&&n;)e=await this.next(),n=t(e.value)}handleErrors(t){return new N1(this,t)}filter(t){return new M1(this,t)}map(t){return new C1(this,t)}mapAsync(t){return new k1(this,t)}serialMapAsync(t){return new k1(this,t).serial()}flatmap(t){return new L1(this,t)}async forEachAsync(t){return this.map(t).resolveFully()}async serialForEach(t){return this.serialMapAsync(t).resolveWhile((t=>!0===t))}rowMajorBatch(t,e=!0){return new A1(this,t,e)}columnMajorBatch(t,e=!0,n=d1){return this.rowMajorBatch(t,e).map((t=>p1(t,n)))}concatenate(t,e){return new F1(I1([this,t]),e)}take(t){return t<0||null==t?this:new O1(this,t)}skip(t){return t<0||null==t?this:new R1(this,t)}prefetch(t){return new B1(this,t)}shuffle(t,e){return new V1(this,t,e)}serial(){return new x1(this)}}class w1 extends v1{constructor(t){super(),this.items=t,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};const t=this.items[this.trav];return this.trav++,{value:g1(t),done:!1}}}class S1 extends v1{constructor(t){super(),this.nextFn=t}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(t){throw t.message=`Error thrown while iterating through a dataset: ${t.message}`,t}}}class x1 extends v1{constructor(t){super(),this.upstream=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){return this.upstream.next()}}class R1 extends v1{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;this.count++<this.maxCount;){const t=await this.upstream.next();if(t.done)return t;bD(t.value)}return this.upstream.next()}}class O1 extends v1{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0}summary(){return`${this.upstream.summary()} -> Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class A1 extends v1{constructor(t,e,n=!0){super(),this.upstream=t,this.batchSize=e,this.enableSmallLastBatch=n,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){const t=[];for(;t.length<this.batchSize;){const e=await this.upstream.next();if(e.done)return this.enableSmallLastBatch&&t.length>0?{value:t,done:!1}:{value:null,done:!0};t.push(e.value)}return{value:t,done:!1}}}class M1 extends v1{constructor(t,e){super(),this.upstream=t,this.predicate=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;){const t=await this.upstream.next();if(t.done||this.predicate(t.value))return t;bD(t.value)}}}class C1 extends v1{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Map`}async next(){const t=await this.upstream.next();if(t.done)return{value:null,done:!0};const e=Yk(t.value),n=this.transform(t.value),i=Yk(n);for(const t of e)Uk(t,i)||t.dispose();return{value:n,done:!1}}}class N1 extends v1{constructor(t,e){super(),this.upstream=t,this.handler=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(t){if(!this.handler(t))return{value:null,done:!0}}}}class k1 extends v1{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){const t=await this.upstream.next();if(t.done)return{value:null,done:!0};const e=Yk(t.value),n=await this.transform(t.value),i=Yk(n);for(const t of e)Uk(t,i)||t.dispose();return{value:n,done:!1}}}class D1 extends v1{constructor(){super(),this.outputQueue=new y1,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class L1 extends D1{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){const t=await this.upstream.next();if(t.done)return!1;const e=Yk(t.value),n=this.transform(t.value),i=Yk(n);this.outputQueue.pushAll(n);for(const t of e)Uk(t,i)||t.dispose();return!0}}class F1 extends v1{constructor(t,e){super(),this.baseErrorHandler=e,this.lastRead=null,this.iterator=null,this.moreIterators=t}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(t){if(await t,null==this.iterator){const t=await this.moreIterators.next();if(t.done)return{value:null,done:!0};this.iterator=t.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const e=await this.iterator.next();return e.done?(this.iterator=null,this.readFromChain(t)):e}}var P1;!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(P1||(P1={}));class $1 extends v1{constructor(t,e=P1.FAIL){super(),this.iterators=t,this.mismatchMode=e,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(t){await t;let e=0,n=0;const i=await f1(this.iterators,(function(t){if(t instanceof v1){return{value:t.next().then((t=>(e++,t.done&&n++,t.value))),recurse:!1}}return{value:null,recurse:!0}}));if(e===n)return{value:null,done:!0};if(n>0)switch(this.mismatchMode){case P1.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case P1.SHORTEST:return{value:null,done:!0};case P1.LONGEST:}return this.count++,{value:i,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class B1 extends v1{constructor(t,e){super(),this.upstream=t,this.bufferSize=e,this.buffer=new T1(e)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){const t=this.upstream.next();this.buffer.push(t)}}next(){return this.refill(),this.buffer.shift()}}class V1 extends B1{constructor(t,e,n){super(t,e),this.upstream=t,this.windowSize=e,this.upstreamExhausted=!1,this.random=CV.alea(n||rk().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}randomInt(t){return Math.floor(this.random()*t)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const t=this.chooseIndex(),e=await this.buffer.shuffleExcise(t);if(!e.done)return this.refill(),e;this.upstreamExhausted=!0}return{value:null,done:!0}}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class U1{constructor(){this.size=null}batch(t,e=!0){const n=this;let i;return _O(t>0,(()=>`batchSize needs to be positive, but it is\n ${t}`)),i=this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t),Y1((async()=>(await n.iterator()).columnMajorBatch(t,e,W1)),i)}concatenate(t){const e=this;let n;return n=this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null,Y1((async()=>(await e.iterator()).concatenate(await t.iterator())),n)}filter(t){const e=this;let n;return n=this.size===1/0?1/0:null,Y1((async()=>(await e.iterator()).filter((e=>ED((()=>t(e)))))),n)}async forEachAsync(t){return(await this.iterator()).forEachAsync(t)}map(t){const e=this;return Y1((async()=>(await e.iterator()).map((e=>ED((()=>t(e)))))),this.size)}mapAsync(t){const e=this;return Y1((async()=>(await e.iterator()).mapAsync(t)),this.size)}prefetch(t){if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const e=this;return Y1((async()=>(await e.iterator()).prefetch(t)),this.size)}repeat(t){const e=this;let n;return n=null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null,Y1((async()=>b1(E1((async()=>({value:await e.iterator(),done:!1}))).take(t))),n)}skip(t){const e=this;let n;return n=null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null,Y1((async()=>(await e.iterator()).skip(t)),n)}shuffle(t,e,n=!0){if(null==t||t<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);const i=this,s=CV.alea(e||rk().toString());return Y1((async()=>{let e=s.int32();return n&&(e+=s.int32()),(await i.iterator()).shuffle(t,e.toString())}),this.size)}take(t){const e=this;let n;return n=null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null,Y1((async()=>(await e.iterator()).take(t)),n)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function Y1(t,e=null){return new class extends U1{constructor(){super(...arguments),this.size=e}async iterator(){return t()}}}function G1(t){return Y1((async()=>I1(t)),t.length)}function H1(t){if(!m1(t))throw new Error("The argument to zip() must be an object or array.");let e;if(Array.isArray(t))for(let n=0;n<t.length;n++)e=null==e?t[n].size:Math.min(e,t[n].size);else if(t instanceof Object)for(const n in t)e=null==e?t[n].size:Math.min(e,t[n].size);return Y1((async()=>function(t,e=P1.FAIL){return new $1(t,e)}(await f1(t,(t=>{if(t instanceof U1)return{value:t.iterator(),recurse:!1};if(m1(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})),P1.SHORTEST)),e)}function W1(t){if(null===t)return null;const e=t[0];if(null==(n=e)||null===(i=n)||"object"!=typeof i&&"function"!=typeof i||Array.isArray(n)||"object"==typeof n&&n instanceof xk||uk(n)){return{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof xk?mU(t):hD(t)}(t),recurse:!1}}var n,i;return{value:null,recurse:!0}}U1.MAX_BUFFER_SIZE=1e4;
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class z1 extends U1{constructor(t){super(),this.input=t}async iterator(){return(await this.input.iterator()).decodeUTF8().split("\n").map((t=>(t.endsWith("\r")&&(t=t.slice(0,-1)),t)))}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
const X1='"',j1=Symbol("out"),q1=Symbol("field"),K1=Symbol("quote"),Q1=Symbol("quoteafterquote"),J1=Symbol("quoteinquote");class Z1 extends U1{async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const t=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&t&&_O(t.length===this.fullColumnNames.length,(()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+").")),this.fullColumnNames||(this.fullColumnNames=t);const e=this.fullColumnNames.reduce(((t,e)=>(t[e]=t[e]+1||1,t)),{}),n=Object.keys(e).filter((t=>e[t]>1));if(_O(0===n.length,(()=>"Duplicate column names found: "+n.toString())),this.columnConfigs)for(const t of Object.keys(this.columnConfigs)){if(-1===this.fullColumnNames.indexOf(t))throw new Error('The key "'+t+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const t=await this.base.iterator(),e=await t.next();if(e.done)throw new Error("No data was found for CSV parsing.");const n=e.value;return this.parseRow(n,!1)}return null}constructor(t,e){super(),this.input=t,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new z1(t),e||(e={}),this.hasHeader=!1!==e.hasHeader,this.fullColumnNames=e.columnNames,this.columnConfigs=e.columnConfigs,this.configuredColumnsOnly=e.configuredColumnsOnly,e.delimWhitespace?(_O(null==e.delimiter,(()=>"Delimiter should not be provided when delimWhitespace is true.")),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=e.delimiter?e.delimiter:","}async iterator(){this.columnNamesValidated||await this.setColumnNames();let t=await this.base.iterator();return this.hasHeader&&(t=t.skip(1)),t.map((t=>this.makeDataElement(t)))}makeDataElement(t){const e=this.parseRow(t),n={},i={};for(let s=0;s<this.fullColumnNames.length;s++){const r=this.fullColumnNames[s],a=this.columnConfigs?this.columnConfigs[r]:null;if(!this.configuredColumnsOnly||a){const o=e[s];let l=null;if(""===o)if(a&&void 0!==a.default)l=a.default;else{if(a&&(a.required||a.isLabel))throw new Error(`Required column ${r} is empty in this line: ${t}`);l=void 0}else{const t=Number(o);if(isNaN(t))l=a&&"bool"===a.dtype?this.getBoolean(o):o;else if(a&&a.dtype)switch(a.dtype){case"float32":default:l=t;break;case"int32":l=Math.floor(t);break;case"bool":l=this.getBoolean(o)}else l=t}a&&a.isLabel?i[r]=l:n[r]=l}}return 0===Object.keys(i).length?n:{xs:n,ys:i}}getBoolean(t){return"1"===t||"true"===t.toLowerCase()?1:0}parseRow(t,e=!0){const n=[];let i=0;const s=t.length;let r=j1;for(let e=0;e<s;e++)switch(r){case j1:switch(t.charAt(e)){case X1:i=e+1,r=K1;break;case this.delimiter:if(i=e+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),r=j1;break;default:r=q1,i=e}break;case q1:if(t.charAt(e)===this.delimiter)n.push(t.substring(i,e)),r=j1,i=e+1;break;case K1:if(t.charAt(e)===X1)r=Q1;break;case Q1:switch(t.charAt(e)){case this.delimiter:n.push(t.substring(i,e-1)),r=j1,i=e+1;break;case X1:r=K1;break;default:r=J1}break;case J1:if(t.charAt(e)===X1)r=K1}if(r===Q1?n.push(t.substring(i,s-1)):n.push(t.substring(i)),e&&n.length!==this.fullColumnNames.length)throw new Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${n}`);return n}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class t2 extends v1{constructor(t){super(),this.microphoneConfig=t,this.isClosed=!1,this.fftSize=t.fftSize||1024;const e=Math.log2(this.fftSize);if(this.fftSize<0||e<4||e>14||!Number.isInteger(e))throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=t.numFramesPerSpectrogram||43,this.sampleRateHz=t.sampleRateHz,this.columnTruncateLength=t.columnTruncateLength||this.fftSize,this.audioTrackConstraints=t.audioTrackConstraints,this.smoothingTimeConstant=t.smoothingTimeConstant||0,this.includeSpectrogram=!1!==t.includeSpectrogram,this.includeWaveform=!0===t.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(t={}){if(!aA().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");const e=new t2(t);return await e.start(),e}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(t){throw new Error(`Error thrown while initializing video stream: ${t.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const t=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new t,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`)}else this.sampleRateHz=this.audioContext.sampleRate;const e=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,e.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let t,e;const n=await this.getAudioData();if(this.includeSpectrogram){const e=this.flattenQueue(n.freqDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const t=this.flattenQueue(n.timeDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:t,waveform:e},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const t=[],e=[];let n=0;return new Promise((i=>{const s=setInterval((()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),e.push(this.timeData.slice())),++n===this.numFrames&&(clearInterval(s),i({freqDataQueue:t,timeDataQueue:e}))}),this.fftSize/this.sampleRateHz*1e3)}))}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(t){const e=t[0].length,n=new Float32Array(t.length*e);return t.forEach(((t,i)=>n.set(t,i*e))),n}getTensorFromAudioDataArray(t,e){const n=new Float32Array(IO(e));return n.set(t,n.length-t.length),hD(n,e)}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class e2 extends v1{constructor(t,e){if(super(),this.webcamVideoElement=t,this.webcamConfig=e,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=yU([0],"int32"),this.webcamConfig.centerCrop){const t=1*this.webcamConfig.resizeWidth/this.webcamVideoElement.width,e=1*this.webcamConfig.resizeHeight/this.webcamVideoElement.height,n=(1-t)/2,i=(1-e)/2,s=n+t,r=e+i;this.cropBox=IU([i,n,r,s],[1,4])}else this.cropBox=IU([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(t,e={}){if(!aA().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!e.resizeWidth||!e.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=e.resizeWidth,t.height=e.resizeHeight}const n=new e2(t,e);return await n.start(),n}async start(){this.webcamConfig.facingMode&&_O("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`));try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(t){throw t.message=`Error thrown while initializing video stream: ${t.message}`,t}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise((t=>{this.webcamVideoElement.onloadedmetadata=()=>{t()}}))}async next(){if(this.isClosed)return{value:null,done:!0};let t;try{t=aP(this.webcamVideoElement)}catch(t){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(t)}`)}if(!this.resize)return{value:t,done:!1};try{return{value:this.cropAndResizeFrame(t),done:!1}}catch(t){throw new Error(`Error thrown cropping the video: ${t.message}`)}finally{t.dispose()}}needToResize(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}cropAndResizeFrame(t){return ED((()=>{const e=RB(PL(t,"float32"),0);let n;n=JY.cropAndResize(e,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const i=n.shape;return y$(n,i.slice(1))}))}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach((t=>t.stop()));try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class n2{}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class i2 extends v1{split(t){return new s2(this,t)}}class s2 extends i2{constructor(t,e){super(),this.upstream=t,this.impl=new r2(t,e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class r2 extends D1{constructor(t,e){super(),this.upstream=t,this.separator=e,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const t=await this.upstream.next();if(t.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);const e=t.value.split(this.separator);e[0]=this.carryover+e[0];for(const t of e.slice(0,-1))this.outputQueue.push(t);return this.carryover=e[e.length-1],!0}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class a2 extends v1{decodeUTF8(){return new o2(this)}}class o2 extends i2{constructor(t){super(),this.upstream=t,this.impl=new l2(t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class l2 extends D1{constructor(t){if(super(),this.upstream=t,aA().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:t}=__webpack_require__(4530);this.decoder=new t("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){const t=await this.upstream.next();let e,n;return!t.done&&(e=t.value,n=aA().get("IS_BROWSER")?this.decoder.decode(e,{stream:!0}):this.decoder.write(Buffer.from(e.buffer)),this.outputQueue.push(n),!0)}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class u2 extends a2{constructor(t,e={}){super(),this.file=t,this.options=e,_O(t instanceof Uint8Array||!!aA().get("IS_BROWSER")&&(t instanceof File||t instanceof Blob),(()=>"FileChunkIterator only supports File, Blob and Uint8Array right now.")),this.offset=e.offset||0,this.chunkSize=e.chunkSize||1048576}summary(){return`FileChunks ${this.file}`}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};const t=new Promise(((t,e)=>{const n=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)t(new Uint8Array(this.file.slice(this.offset,n)));else{const i=new FileReader;i.onload=n=>{let s=i.result;if(s instanceof ArrayBuffer&&(s=new Uint8Array(s)),!(s instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(s)},i.onabort=t=>e(new Error("Aborted")),i.onerror=t=>e(new Error(t.type));const s=this.file.slice(this.offset,n);i.readAsArrayBuffer(s)}this.offset=n}));return{value:await t,done:!1}}}const h2=t=>({method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity});
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
function p2(t){return"string"==typeof t&&"file://"===t.slice(0,7)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class c2 extends n2{constructor(t,e={}){super(),this.input=t,this.options=e}async iterator(){if(p2(this.input)&&aA().get("IS_NODE")){const t=__webpack_require__(8108);this.input=t.readFileSync(this.input.slice(7))}return new u2(this.input,this.options)}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
class d2 extends n2{constructor(t,e={}){super(),this.url=t,this.fileOptions=e}async iterator(){return p2(this.url)?new c2(this.url,this.fileOptions).iterator():
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
async function(t,e={},n){let i,s;"string"==typeof t?i=t:(i=t.url,s=h2(t));const r=await(n||ak)(i,s);if(r.ok){const t=new Uint8Array(await r.arrayBuffer());return new u2(t,e)}throw new Error(r.statusText)}(this.url,this.fileOptions)}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
function f2(t,e={}){return new Z1(new d2(t),e)}function m2(t){const e=E1(t);return Y1((async()=>e))}function g2(t){return Y1((async()=>{const e=await t();return E1((()=>e.next()))}))}async function _2(t,e){return e2.create(t,e)}async function T2(t){return t2.create(t)}
/** @license See the LICENSE file. */
const y2="4.22.0";
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function I2(t,e){Array.isArray(t)||(t=[t]),t.forEach((t=>{null!=t&&_O("complex64"!==t.dtype,(()=>`${e} does not support complex64 tensors in the CPU backend.`))}))}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const E2=NU;class b2 extends oO{nextDataId(){return b2.nextDataId++}constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new aO(this,TD())}write(t,e,n){this.firstUse&&(this.firstUse=!1,aA().get("IS_NODE")&&AN("\n============================\nHi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. \n============================"));const i={id:this.nextDataId()};return this.data.set(i,{values:t,dtype:n,refCount:1}),i}makeTensorInfo(t,e,n){let i;if("string"===e&&null!=n&&n.length>0&&VO(n[0])){const s=n.map((t=>ok(t)));i=this.write(s,t,e)}else i=this.write(n,t,e);return{dataId:i,shape:t,dtype:e}}refCount(t){if(this.data.has(t)){return this.data.get(t).refCount}return 0}incRef(t){this.data.get(t).refCount++}decRef(t){if(this.data.has(t)){this.data.get(t).refCount--}}move(t,e,n,i,s){this.data.set(t,{values:e,dtype:i,refCount:s})}numDataIds(){return this.data.numDataIds()}async read(t){return this.readSync(t)}readSync(t){const{dtype:e,complexTensorInfos:n}=this.data.get(t);if("complex64"===e){return AG(this.readSync(n.real.dataId),this.readSync(n.imag.dataId))}return qO(this.data.get(t).values,e)}bufferSync(t){const e=this.readSync(t.dataId);if("string"===t.dtype)try{const n=e.map((t=>lk(t)));return FL(t.shape,t.dtype,n)}catch(t){throw new Error("Failed to decode encoded string bytes into utf-8")}return FL(t.shape,t.dtype,e)}makeOutput(t,e,n){return TD().makeTensorFromTensorInfo(this.makeTensorInfo(e,n,t),this)}disposeData(t,e=!1){if(this.data.has(t)){if(this.data.get(t).refCount--,!e&&this.data.get(t).refCount>0)return!1;const{complexTensorInfos:n}=this.data.get(t);null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(t)}return!0}disposeIntermediateTensorInfo(t){this.disposeData(t.dataId)}async time(t){const e=rk();t();return{kernelMs:rk()-e}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(t){I2([t],"where");const e=this.readSync(t.dataId);return E2(t.shape,e)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function v2(t){const e=new Float32Array(t.length);for(let n=0;n<t.length;++n)e[n]=Math.abs(t[n]);return e}b2.nextDataId=0;const w2={kernelName:pA,backendName:"cpu",kernelFunc:t=>{const{x:e}=t.inputs,n=t.backend;I2(e,"abs");let i=new Float32Array(IO(e.shape));return i=v2(n.data.get(e.dataId).values),n.makeOutput(i,e.shape,e.dtype)}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function S2(t){return(e,n,i,s,r)=>{const a=_F(e,n),o=a.length,l=zO(a),u=kO(r,IO(a)),h=e.length,p=n.length,c=zO(e),d=zO(n),f=mF(e,a),m=mF(n,a);if(f.length+m.length===0)for(let e=0;e<u.length;++e)u[e]=t(i[e%i.length],s[e%s.length]);else for(let e=0;e<u.length;++e){const n=eA(e,o,l),r=n.slice(-h);f.forEach((t=>r[t]=0));const a=tA(r,h,c),g=n.slice(-p);m.forEach((t=>g[t]=0));const _=tA(g,p,d);u[e]=t(i[a],s[_])}return[u,a]}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function x2(t){const{inputs:e,backend:n}=t,{real:i,imag:s}=e,r=n.data.get(i.dataId).values,a=n.data.get(s.dataId).values,o=n.makeTensorInfo(i.shape,"complex64");return n.data.get(o.dataId).complexTensorInfos={real:n.makeTensorInfo(i.shape,"float32",r),imag:n.makeTensorInfo(s.shape,"float32",a)},o}const R2={kernelName:$A,backendName:"cpu",kernelFunc:x2};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function O2(t,e,n="float32"){if("complex64"===n){return x2({inputs:{real:O2(t,e,"float32"),imag:O2(t,e,"float32")},backend:t})}const i=QO(IO(e),n);return t.makeTensorInfo(e,n,i)}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function A2(t){const{inputs:e,backend:n}=t,{x:i}=e;return n.incRef(i.dataId),{dataId:i.dataId,shape:i.shape,dtype:i.dtype}}const M2={kernelName:RM,backendName:"cpu",kernelFunc:A2};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function C2(t){const{inputs:e,backend:n}=t,{input:i}=e,s=n.data.get(i.dataId).complexTensorInfos.real,r=n.data.get(s.dataId).values;return n.makeTensorInfo(s.shape,s.dtype,r)}const N2={kernelName:SC,backendName:"cpu",kernelFunc:C2};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function k2(t,e,n,i){if("int32"===i){return[e,"int32",Int32Array.from(t)]}if("bool"===i){const i=sk([0],n),[s,r]=S2(((t,e)=>t!==e?1:0))(e,[],t,i,"bool");return[r,"bool",s]}throw new Error(`Error in Cast: failed to cast ${n} to ${i}`)}function D2(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{dtype:r}=i;if("complex64"===r){if("complex64"===s.dtype)return A2({inputs:{x:s},backend:n});const t=O2(n,s.shape,s.dtype),e=D2({inputs:{x:s},backend:n,attrs:{dtype:"float32"}}),i=x2({inputs:{real:e,imag:t},backend:n});return n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(e),i}if("complex64"===s.dtype){const t=C2({inputs:{input:s},backend:n}),e=D2({inputs:{x:t},backend:n,attrs:{dtype:r}});return n.disposeIntermediateTensorInfo(t),e}if(!PO(s.dtype,r)){const t=A2({inputs:{x:s},backend:n});return{dataId:t.dataId,shape:t.shape,dtype:r}}const a=n.data.get(s.dataId).values,[o,l,u]=k2(a,s.shape,s.dtype,r);return n.makeTensorInfo(o,l,u)}const L2={kernelName:LA,backendName:"cpu",kernelFunc:D2};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function F2(t,e,n,i){return null==n?({inputs:n,backend:s})=>{const{a:r,b:a}=n,o=s;I2([r,a],t);const l=o.data.get(r.dataId).values,u=o.data.get(a.dataId).values,h="string"===r.dtype?uH(l):l,p="string"===r.dtype?uH(u):u,c=i||r.dtype,[d,f]=e(r.shape,a.shape,h,p,c);return o.makeTensorInfo(f,c,d)}:({inputs:t,backend:s})=>{const{a:r,b:a}=t,o=s;if("complex64"===r.dtype||"complex64"===a.dtype){const t=D2({inputs:{x:r},backend:o,attrs:{dtype:"complex64"}}),e=o.data.get(t.dataId),i=e.complexTensorInfos.real,s=e.complexTensorInfos.imag,l=o.data.get(i.dataId).values,u=o.data.get(s.dataId).values,h=D2({inputs:{x:a},backend:o,attrs:{dtype:"complex64"}}),p=o.data.get(h.dataId),c=p.complexTensorInfos.real,d=p.complexTensorInfos.imag,f=o.data.get(c.dataId).values,m=o.data.get(d.dataId).values,[g,_,T]=n(r.shape,a.shape,l,u,f,m),y=o.makeTensorInfo(T,"float32",g),I=o.makeTensorInfo(T,"float32",_),E=x2({inputs:{real:y,imag:I},backend:o});return o.disposeIntermediateTensorInfo(t),o.disposeIntermediateTensorInfo(h),o.disposeIntermediateTensorInfo(y),o.disposeIntermediateTensorInfo(I),E}{const t=o.data.get(r.dataId).values,n=o.data.get(a.dataId).values,s=i||r.dtype,[l,u]=e(r.shape,a.shape,t,n,s);return o.makeTensorInfo(u,s,l)}}}function P2(t){return(e,n,i,s,r,a)=>{const o=_F(e,n),l=IO(o),u=o.length,h=zO(o),p=kO("float32",l),c=kO("float32",l),d=mF(e,o),f=mF(n,o),m=AG(i,s),g=AG(r,a),_=e.length,T=zO(e),y=n.length,I=zO(n);if(d.length+f.length===0)for(let e=0;e<p.length;e++){const n=e%m.length,i=e%g.length,s=t(m[2*n],m[2*n+1],g[2*i],g[2*i+1]);p[e]=s.real,c[e]=s.imag}else for(let e=0;e<p.length;e++){const n=eA(e,u,h),i=n.slice(-_);d.forEach((t=>i[t]=0));const s=tA(i,_,T),r=n.slice(-y);f.forEach((t=>r[t]=0));const a=tA(r,y,I),o=t(m[2*s],m[2*s+1],g[2*a],g[2*a+1]);p[e]=o.real,c[e]=o.imag}return[p,c,o]}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const $2=S2(((t,e)=>t+e)),B2=P2(((t,e,n,i)=>({real:t+n,imag:e+i}))),V2=F2(fA,$2,B2),U2={kernelName:fA,backendName:"cpu",kernelFunc:V2};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Y2(t,e,n,i,s){const r=IO(i),a=QO(s,n);for(let n=0;n<t.length;n++){const i=t[n];if(i<0)throw new Error("Input x must be non-negative!");i>=s||(a[i]+=r>0?e[n]:1)}return a}function G2(t,e,n,i=!1){const s=t.shape[0],r=t.shape[1],a=FL([s,n],e.dtype);for(let o=0;o<s;o++)for(let s=0;s<r;s++){const r=t.get(o,s);if(r<0)throw new Error("Input x must be non-negative!");r>=n||(i?a.set(1,o,r):e.size>0?a.set(a.get(o,r)+e.get(o,s),o,r):a.set(a.get(o,r)+1,o,r))}return a}
/**
* @license
* Copyright 2023 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const H2=S2(((t,e)=>t&e)),W2=F2(NA,H2),z2={kernelName:NA,backendName:"cpu",kernelFunc:W2};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function X2(t){return(e,n,i)=>{const s=DO(n,e.length);for(let n=0;n<e.length;++n)s[n]=t(e[n],i);return s}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function j2(t,e,n){return q2(t,X2(e),n)}function q2(t,e,n){return({inputs:i,attrs:s,backend:r})=>{const{x:a}=i;I2(a,t);const o=r,l=o.data.get(a.dataId).values;let u;if("string"===a.dtype){if(!Array.isArray(l))throw new Error("String tensor's value was not an instance of Array");u=uH(l)}else u=l;const h=n||a.dtype,p=e(u,h,s);return o.makeTensorInfo(a.shape,h,p)}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const K2=X2((t=>Math.ceil(t))),Q2=q2(FA,K2),J2={kernelName:FA,backendName:"cpu",kernelFunc:Q2};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Z2(t,e,n,i){const s=DO(n,IO(e));if(i&&"string"!==n){let e=0;t.forEach((t=>{const n=IO(t.shape);s.set(t.vals,e),e+=n}))}else{let i=0;t.forEach((t=>{const r="string"===n?uH(t.vals):t.vals;let a=0;for(let n=0;n<t.shape[0];++n){const o=n*e[1]+i;for(let e=0;e<t.shape[1];++e)s[o+e]=r[a++]}i+=t.shape[1]}))}return s}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const t3=S2(((t,e)=>t===e?1:0)),e3=F2(dM,t3,null,"bool"),n3={kernelName:dM,backendName:"cpu",kernelFunc:e3},i3=X2((t=>Math.exp(t))),s3=q2(fM,i3,"float32"),r3={kernelName:fM,backendName:"cpu",kernelFunc:s3},a3=X2((t=>Math.expm1(t))),o3=q2(gM,a3),l3={kernelName:gM,backendName:"cpu",kernelFunc:o3},u3=X2((t=>Math.floor(t))),h3=q2(IM,u3),p3={kernelName:IM,backendName:"cpu",kernelFunc:h3},c3=S2(((t,e)=>Math.floor(t/e))),d3=F2(EM,c3,null,"int32"),f3={kernelName:EM,backendName:"cpu",kernelFunc:d3};
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function m3(t,e,n,i,s,r,a,o,l){const u=FL([i,r],n);for(let n=0;n<i;n++){const i=[];let h=0;for(let e=0;e<s;e++){const r=t[n*s+e];h+=r*a[e],i.push(r)}if(h<0||h>=l/r)throw new Error(`Invalid indices: ${i} does not index into ${o}`);for(let t=0;t<r;t++)u.values[n*r+t]=e.get(...e.indexToLoc(h*r+t))}return u}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function g3(t,e,n){const i=FL(n,t.dtype);for(let n=0;n<i.size;++n){const s=i.indexToLoc(n).slice(),r=s[0],a=s[2],o=e.locToIndex([r,a]);s[2]=e.values[o];const l=t.locToIndex(s);0<=l&&l<t.values.length&&(i.values[n]=t.values[l])}return i}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const _3=S2(((t,e)=>t>e?1:0)),T3=F2(SM,_3,null,"bool"),y3={kernelName:SM,backendName:"cpu",kernelFunc:T3},I3=S2(((t,e)=>t>=e?1:0)),E3=F2(xM,I3,null,"bool"),b3={kernelName:xM,backendName:"cpu",kernelFunc:E3},v3=S2(((t,e)=>t<e?1:0)),w3=F2(DM,v3,null,"bool"),S3={kernelName:DM,backendName:"cpu",kernelFunc:w3},x3=S2(((t,e)=>t<=e?1:0)),R3=F2(LM,x3,null,"bool"),O3={kernelName:LM,backendName:"cpu",kernelFunc:R3};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function A3(t,e,n){const i=(e-t)/(n-1),s=QO(n,"float32");s[0]=t;for(let t=1;t<s.length;t++)s[t]=s[t-1]+i;return s}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const M3=X2((t=>Math.log(t))),C3=q2(PM,M3),N3={kernelName:PM,backendName:"cpu",kernelFunc:C3};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function k3(t,e,n,i){const s=kO(i,IO(n));for(let n=0;n<s.length;++n){const i=n*e;let r=t[i];for(let n=0;n<e;++n){const e=t[i+n];(Number.isNaN(e)||e>r)&&(r=e)}s[n]=r}return s}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const D3=S2(((t,e)=>Math.max(t,e))),L3=F2(qM,D3),F3={kernelName:qM,backendName:"cpu",kernelFunc:L3},P3=S2(((t,e)=>Math.min(t,e))),$3=F2(iC,P3),B3={kernelName:iC,backendName:"cpu",kernelFunc:$3},V3=S2(((t,e)=>t*e)),U3=P2(((t,e,n,i)=>({real:t*n-e*i,imag:t*i+e*n}))),Y3=F2(oC,V3,U3),G3={kernelName:oC,backendName:"cpu",kernelFunc:Y3};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function H3(t,e,n){const i=ik(-1,n);return V3([],e,i,t,n)}const W3={kernelName:lC,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n}=t,{x:i}=e;I2(i,"neg");const s=n.data.get(i.dataId).values,[r,a]=H3(s,i.shape,i.dtype);return n.makeTensorInfo(a,i.dtype,r)}},z3=S2(((t,e)=>t!==e?1:0)),X3=F2(uC,z3,null,"bool"),j3={kernelName:uC,backendName:"cpu",kernelFunc:X3};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function q3(t,e,n,i,s){const r=e.length,a=IO(e),o=zO(e),l=zO(s),u=kO(n,IO(s));for(let e=0;e<a;++e){const n=eA(e,r,o),s=new Array(n.length);for(let t=0;t<s.length;t++)s[t]=n[i[t]];u[tA(s,r,l)]=t[e]}return u}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function K3(t){const{inputs:e,attrs:n,backend:i}=t,{x:s}=e,{perm:r}=n;I2(s,"transpose");const a=s.shape.length,o=new Array(a);for(let t=0;t<o.length;t++)o[t]=s.shape[r[t]];const l=q3(i.data.get(s.dataId).values,s.shape,s.dtype,r,o);return{dataId:i.write(l,o,s.dtype),shape:o,dtype:s.dtype}}const Q3={kernelName:_N,backendName:"cpu",kernelFunc:K3};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function J3(t,e,n,i){const[s,r]=fB(t,i),a=Lk(e,"int32"),o=QO(IO(s),a),l=IO(r);for(let t=0;t<o.length;++t){const e=t*l;let i=1;for(let t=0;t<l;++t)i*=n[e+t];o[t]=i}return{outVals:o,outShape:s,outDtype:a}}const Z3={kernelName:IC,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i;I2(s,"prod");const o=s.shape.length,l=CO(r,s.shape),u=_B(l,o);let h=l,p=s;const c=[];null!=u&&(p=K3({inputs:{x:s},backend:n,attrs:{perm:u}}),c.push(p),h=yB(h.length,o));const d=n.data.get(p.dataId).values,{outVals:f,outShape:m,outDtype:g}=J3(p.shape,p.dtype,d,h);let _=m;return a&&(_=mB(m,l)),c.forEach((t=>n.disposeIntermediateTensorInfo(t))),n.makeTensorInfo(_,g,f)}};function t4(t,e,n,i){const s=[];let r=0;const a=e.length-1+n.length,o=new Array(a).fill(null).map((()=>[0]));!function(t,e){for(let n=0;n<t.length;++n){const i=t[n],s=n===t.length-1?e:t[n+1].length;if(0===i.length)throw new Error("Ragged splits may not be empty");if(i[0]<0)throw new Error("Ragged splits must be non-negative");if(i[i.length-1]>s)throw new Error("Ragged splits must not point past values");for(let t=1;t<i.length;++t)if(i[t-1]>i[t])throw new Error("Ragged splits must be sorted in ascending order")}}(n,i);let l=1;for(let t=0;t<e.length-1;++t){l*=e[t];const n=e[t+1];for(let e=1;e<l+1;++e)o[t].push(e*n)}for(let i=0;i<t.length;++i){let a=t[i],l=t[i]+1;for(let t=0;t<n.length;++t){const i=n[t],s=t+e.length-1;if(s>=0){const t=o[s],e=t[t.length-1]-i[a];for(let t=a;t<l;++t)o[s].push(i[t+1]+e)}a=i[a],l=i[l]}l!==a&&(s.push([a,l]),r+=l-a)}return{outSplits:o,valueSlices:s,numValues:r}}function e4(t,e){const n=t.slice(0,e);for(;n.length<e;)n.push(1);for(let i=e;i<t.length;i++)n[e-1]*=t[i];return n}function n4(t,e,n,i,s){const r=e.slice();r[0]=s;const a=DO(n,IO(r)),o=t.length;return function(t,e,n,i,s,r){const a=e4(e,2)[1],o=e4(r,2)[1];let l=0;for(const e of n)for(let n=e[0];n<e[1];++n){for(let e=0;e<i;++e)s[l*o+e]=t[n*a+e];++l}}(t,e,i,0===o?0:o/e[0],a,r),[a,r]}function i4(t,e,n,i,s,r,a,o){if(0===t.length)throw new Error("paramsNestedSplits must be non empty");if(0===e[0].length)throw new Error("Split tensors must not be scalars");if(
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){t.forEach(((t,i)=>{if(t<0||t>=n){const s=eA(i,e.length,zO(e)).join(",");throw new Error(`indices[${s}] = ${t} is not in [0, ${n})`)}}))}(r,a,e[0][0]-1),0===i.length)throw new Error("params.rank must be nonzero");const l=i[0],{outSplits:u,valueSlices:h,numValues:p}=t4(r,a,t,l),c=function(t){const e=[];for(let n=0;n<t.length;++n){const i=DO("int32",t[n].length);e.push(i),t[n].forEach(((t,e)=>i[e]=t))}return e}(u),d=n4(n,i,s,h,p);return[c,d[0],d[1]]}
/**
* @license
* Copyright 2022 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const s4=2147483647;function r4(t,e,n,i,s,r,a){if(e.length>1)throw new Error("starts must be a scalar or vector");if(s.length>1)throw new Error("limits must be a scalar or vector");if(a.length>1)throw new Error("deltas must be a scalar or vector");const o=0===e.length,l=0===s.length,u=0===a.length,h=[];o||h.push(e[0]),l||h.push(s[0]),u||h.push(a[0]);for(let t=1;t<h.length;++t)if(h[t]!==h[t-1])throw new Error("starts, limits, and deltas must have the same shape");const p=0===h.length?1:h[0],c=DO("int32",p+1);c[0]=0;for(let e=0;e<p;++e){const n=o?t[0]:t[e],s=l?i[0]:i[e],a=u?r[0]:r[e];if(0===a)throw new Error("Requires delta != 0");let h;if(a>0&&s<n||a<0&&s>n)h=0;else if(h=Math.ceil(Math.abs((s-n)/a)),h>s4)throw new Error(`Requires ((limit - start) / delta) <= ${s4}`);c[e+1]=c[e]+h}const d=DO(n,c[p]);let f=0;for(let e=0;e<p;++e){const n=c[e+1]-c[e];let i=o?t[0]:t[e];const s=u?r[0]:r[e];for(let t=0;t<n;++t)d[f++]=i,i+=s}return[c,d]}
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
var a4=lG;class o4{constructor(t,e,n,i,s,r,a,o,l,u){this.shape=t,this.shapeShape=e,this.values=n,this.valuesShape=i,this.valuesDType=s,this.defaultValue=r,this.defaultValueShape=a,this.rowPartitionValues=o,this.rowPartitionValuesShapes=l,this.rowPartitionTypes=hG(u),this.raggedRank=pG(this.rowPartitionTypes)}getRowPartitionTypeByDimension(t){return this.rowPartitionTypes[0]===a4.FIRST_DIM_SIZE?this.rowPartitionTypes[t+1]:this.rowPartitionTypes[t]}getRowPartitionTensor(t){return this.rowPartitionTypes[0]===a4.FIRST_DIM_SIZE?this.rowPartitionValues[t+1]:this.rowPartitionValues[t]}getMaxWidth(t){const e=this.getRowPartitionTensor(t-1);switch(this.getRowPartitionTypeByDimension(t-1)){case a4.VALUE_ROWIDS:return o4.getMaxWidthValueRowID(e);case a4.ROW_SPLITS:return o4.getMaxWidthRowSplit(e);default:throw new Error(`Cannot handle partition type ${a4[this.getRowPartitionTypeByDimension(t-1)]}`)}}static getMaxWidthRowSplit(t){const e=t.length;if(0===e||1===e)return 0;let n=0;for(let i=0;i<e-1;++i){const e=t[i+1]-t[i];e>n&&(n=e)}return n}static getMaxWidthValueRowID(t){const e=t.length;if(0===e)return 0;let n=0,i=t[0],s=0;for(let r=1;r<e;++r){const e=t[r];e!==i&&(i=e,s=Math.max(r-n,s),n=r)}return Math.max(e-n,s)}tensorShapeFromTensor(t,e,n=!0){if(0===e.length){if(-1===t[0])return[];throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.")}return u4(t,n)}calculateOutputSize(t){const e=this.valuesShape;cG(this.defaultValueShape,e);const n=this.tensorShapeFromTensor(this.shape,this.shapeShape),i=uG(this.raggedRank,n,e);i[0]<0&&(i[0]=t);for(let t=1;t<=this.raggedRank;++t)i[t]<0&&(i[t]=this.getMaxWidth(t));return i}calculateFirstParentOutputIndex(t,e,n){const i=Math.min(t,n),s=[];let r=0;for(let t=0;t<i;++t,r+=e)s.push(r);for(let e=i;e<t;++e)s.push(-1);return _O(s.length===t,(()=>"Final length of result must be equal to firstDimension.")),s}calculateOutputIndexRowSplit(t,e,n,i){const s=t.length,r=[];for(let a=0;a<s-1;++a){const s=t[a+1]-t[a];let o=Math.min(i,s),l=e[a];-1===l&&(o=0);for(let t=0;t<o;++t)r.push(l),l+=n;for(let t=0;t<s-o;++t)r.push(-1)}if(s>0&&r.length!==t[s-1])throw new Error("Invalid row split size.");return r}calculateOutputIndexValueRowID(t,e,n,i){const s=t.length,r=[];if(0===s)return[];let a=0,o=t[0];if(o>=e.length)throw new Error(`Got currentValueRowId=${o}, which is not less than ${e.length}`);let l=e[o];r.push(l);for(let u=1;u<s;++u){const s=t[u];if(s===o)l>=0&&(++a,a<i?l+=n:l=-1);else{if(a=0,o=s,s>=e.length)throw new Error(`Got nextValueRowId=${s} which is not less than ${e.length}`);l=e[s]}r.push(l)}if(r.length!==t.length)throw new Error("Invalid row ids.");return r}calculateOutputIndex(t,e,n,i){const s=this.getRowPartitionTensor(t),r=this.getRowPartitionTypeByDimension(t);switch(r){case a4.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(s,e,n,i);case a4.ROW_SPLITS:if(s.length-1>e.length)throw new Error(`Row partition size is greater than output size: ${s.length-1} > ${e.length}`);return this.calculateOutputIndexRowSplit(s,e,n,i);default:throw new Error(`Unsupported partition type: ${a4[r]}`)}}getFirstDimensionSize(){const t=this.rowPartitionValues[0];if(0===this.rowPartitionTypes.length)throw new Error("No row_partition_types given.");const e=this.rowPartitionTypes[0];switch(e){case a4.FIRST_DIM_SIZE:return t[0];case a4.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case a4.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${a4[e]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const t=this.getFirstDimensionSize(),e=this.calculateOutputSize(t),n=new Array(this.raggedRank+1);n[n.length-1]=1;for(let t=n.length-2;t>=0;--t)n[t]=n[t+1]*e[t+1];const i=u4(e,!1),s=DO(this.valuesDType,IO(i));if(n[0]*e[0]>0){let r=this.calculateFirstParentOutputIndex(t,n[0],e[0]);for(let t=1;t<=this.raggedRank;++t){r=this.calculateOutputIndex(t-1,r,n[t],e[t])}this.setOutput(this.raggedRank,r,s,i)}return[i,s]}setOutput(t,e,n,i){if(0===n.length)return;const s=this.values,r=n;let a=i.slice();a=a.slice(t+1);const o=IO(a),l=e.length;let u=this.defaultValue;if(u.length!==o&&1!==u.length){const t=this.defaultValueShape;ED((()=>{const e=y$(u,t),n=L$(e,a);u=n.dataSync()}))}let h=0,p=0,c=0;for(let t=0;t<=l;++t){let i=t<l?e[t]:-1;if(i!==c){if(p<c){const t=s.subarray(h*o);l4(r.subarray(p*o),t,(c-p)*o)}if(t>=l){const t=n.length;i=Math.floor(t/o)}if(i>c)if(1===this.defaultValue.length)r.subarray(c*o,i*o).fill(this.defaultValue[0]),c=i;else for(;i>c;){l4(r.slice(c*o),u,o),++c}i<0?(h=t+1,p=c):(h=t,p=c,c=p+1)}else++c}}}function l4(t,e,n){for(let i=0;i<n;i++)t[i]=e[i]}function u4(t,e){const n=[];for(let i of t){if(i<0){if(!e)throw new Error(`Dimension ${i} must be >= 0`);if(i<-1)throw new Error(`Dimension ${i} must be >= -1`);i=-1}n.push(i)}return n}function h4(t,e,n,i,s,r,a,o,l,u){return new o4(t,e,n,i,s,r,a,o,l,u).compute()}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function p4(t,e,n,i){if(t===e||t<e&&n<0||e<t&&n>1)return QO(0,i);const s=QO(Math.abs(Math.ceil((e-t)/n)),i);e<t&&1===n&&(n=-1),s[0]=t;for(let t=1;t<s.length;t++)s[t]=s[t-1]+n;return s}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const c4=X2((t=>1/Math.sqrt(t))),d4=q2(FC,c4),f4={kernelName:FC,backendName:"cpu",kernelFunc:d4};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function m4(t,e,n,i,s,r,a,o,l,u){const h=[i/s,s],p=t.values,c=e.values;if(0===i)return FL(n,e.dtype);const d=l instanceof bk?l:FL(h,e.dtype);"string"==typeof l||"number"==typeof l?d.values.fill(l):"boolean"==typeof l&&d.values.fill(+l);for(let t=0;t<r;t++){const r=[];let l=0;for(let e=0;e<a;e++){const n=p[t*a+e];r.push(n),l+=n*o[e]}if(l<0||l>=i/s)throw new Error(`Invalid indices: ${r} does not index into ${n}`);for(let n=0;n<s;n++)u?d.values[l*s+n]+=c[t*s+n]:d.values[l*s+n]=0===e.rank?c[0]:c[t*s+n]}return d}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const g4=X2((t=>1/(1+Math.exp(-t)))),_4=j2(zC,(t=>1/(1+Math.exp(-t)))),T4={kernelName:zC,backendName:"cpu",kernelFunc:_4};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function y4(t,e,n,i,s){const r=SP(i,e,n),a=IO(n),o=zO(i);if(r){const n=xP(e,o);return"string"===s?t.slice(n,n+a):t.subarray(n,n+a)}const l=FL(i,s,"string"===s?uH(t):t),u=FL(n,s);for(let t=0;t<u.size;++t){const n=u.indexToLoc(t),i=n.map(((t,n)=>t+e[n]));u.set(l.get(...i),...n)}return"string"===s?hH(u.values):u.values}function I4(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{begin:r,size:a}=i;I2(s,"slice");const[o,l]=RP(s,r,a);dP(s,o,l);const u=y4(n.data.get(s.dataId).values,o,l,s.shape,s.dtype);return n.makeTensorInfo(l,s.dtype,u)}const E4={kernelName:YC,backendName:"cpu",kernelFunc:I4};
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function b4(t,e,n,i,s,r,a){const o=e[0],l=r[0],u=new Array(l),h=new Array(o),p=e[1];if(0===l){if(0!==o)throw new Error(jG(o));return[DO(n,0),[0,p],DO(s,0),u,h]}let c=!0,d=0;const f=new Array(l).fill(0);for(let e=0;e<o;++e){const n=t[e*p];if(n<0)throw new Error(qG(e,n));if(n>=l)throw new Error(KG(e,n,l));++f[n],c=c&&n>=d,d=n}let m=!0;for(let t=0;t<l;++t){const e=0===f[t];u[t]=e,m=m&&!e,f[t]=Math.max(f[t],1),t>0&&(f[t]+=f[t-1])}if(m&&c){const e=t,n=i;for(let t=0;t<o;++t)h[t]=t;return[e,[o,p],n,u,h]}{const e=f[l-1],r=DO(n,e*p),c=DO(s,e),d=new Array(l).fill(0);for(let e=0;e<o;++e){const n=t[e*p],s=d[n],a=(0===n?0:f[n-1])+s;d[n]++;for(let n=0;n<p;++n)r[a*p+n]=t[e*p+n];c[a]=i[e],h[e]=a}for(let t=0;t<l;++t){if(0===d[t]){const e=0===t?0:f[t-1];r[e*p+0]=t;for(let t=1;t<p;++t)r[e*p+t]=0;c[e]=a}}return[r,[e,p],c,u,h]}}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function v4(t,e,n,i,s){const r=IO(i),a=e[0],o=s.length,l=[];let u=1,h=-1;for(let t=0;t<o;++t){const e=s[t];if(-1===e){if(-1!==h)throw new Error(QG(h,t));h=t,l.push(1)}else{if(e<0)throw new Error(JG(t,e));u*=e,l.push(e)}}if(-1!==h){if(u<=0)throw new Error("reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero");const t=Math.trunc(r/u);if(u*t!==r)throw new Error(tH(i,l));l[h]=t}if(IO(l)!==r)throw new Error(eH(i,l));const p=i.length,c=[];if(p>0){c[p-1]=1;for(let t=p-2;t>=0;--t)c[t]=c[t+1]*i[t+1]}const d=[];if(o>0){d[o-1]=1;for(let t=o-2;t>=0;--t)d[t]=d[t+1]*l[t+1]}const f=DO(n,a*o);for(let e=0;e<a;++e){let n=0;for(let i=0;i<p;++i)n+=t[e*p+i]*c[i];for(let t=0;t<o;++t)f[e*o+t]=Math.trunc(n/d[t]),n%=d[t]}return[f,[a,o],l]}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function w4(t,e,n,i,s,r=!1,a=0){const o=i.length,l=[e[0],t.length/e[0]],u=l[1],h=o>0?s[o-1]+1:0;if(h<0)throw new Error("segment ids must be >= 0");const p=e.slice();p[0]=h;const c=DO(n,p.reduce(((t,e)=>t*e),1));if(0===o)return h>0&&c.fill(a),[c,p];if(h<=0)throw new Error("segment ids must be >= 0");let d=0,f=1,m=0,g=s[d];for(;;){let e=0;if(f<o){if(e=s[f],g===e){++f;continue}if(g>=e)throw new Error("segment ids are not increasing")}if(g<0||g>=h)throw new Error(sH(g,h));g>m&&c.fill(a,m*u,g*u);for(let e=d;e<f;++e){const n=i[e];if(n<0||n>=l[0])throw new Error(rH(e,i[e],l[0]));for(let e=0;e<u;e++)c[g*u+e]+=t[n*u+e]}if(r)for(let t=0;t<u;t++)c[g*u+t]/=f-d;if(d=f,++f,m=g+1,g=e,f>o)break}return m<h&&c.fill(a,m*u,h*u),[c,p]}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const S4=X2((t=>Math.sqrt(t))),x4=j2(jC,(t=>Math.sqrt(t))),R4={kernelName:jC,backendName:"cpu",kernelFunc:x4},O4=S2(((t,e)=>{const n=t-e;return n*n})),A4=F2(sN,O4),M4={kernelName:sN,backendName:"cpu",kernelFunc:A4},C4=X2(((t,e)=>{const{pattern:n,replaceGlobal:i,rewrite:s}=e;return t.replace(new RegExp(n,i?"g":""),s)})),N4=q2(aN,C4),k4={kernelName:aN,backendName:"cpu",kernelFunc:N4};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function D4(t,e,n,i){const s=FL(t,e.dtype);for(let t=0;t<s.size;t++){const r=s.indexToLoc(t),a=new Array(r.length);for(let t=0;t<a.length;t++)a[t]=r[t]*n[t]+i[t];s.set(e.get(...a),...r)}return s}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class L4{constructor(t,e,n,i,s,r){this.separator=ok(t),this.nGramWidths=e,this.leftPad=ok(n),this.rightPad=ok(i),this.padWidth=s,this.preserveShort=r}getPadWidth(t){return Math.min(this.padWidth<0?t-1:this.padWidth,t-1)}getNumNGrams(t,e){const n=this.getPadWidth(e);return Math.max(0,t+2*n-e+1)}createNGrams(t,e,n,i,s,r){for(let a=0;a<s;++a){const o=this.getPadWidth(r),l=Math.max(0,o-a),u=Math.max(0,o-(s-(a+1))),h=r-(l+u),p=e+(l>0?0:a-o);let c=0;c+=l*this.leftPad.length;for(let e=0;e<h;++e)c+=t[p+e].length;c+=u*this.rightPad.length;c+=(l+u+h-1)*this.separator.length,n[i+a]=new Uint8Array(c);const d=n[i+a];let f=0;const m=t=>t.forEach((t=>d[f++]=t));for(let t=0;t<l;++t)m(this.leftPad),m(this.separator);for(let e=0;e<h-1;++e)m(t[p+e]),m(this.separator);if(h>0){m(t[p+h-1]);for(let t=0;t<u;++t)m(this.separator),m(this.rightPad)}else{for(let t=0;t<u-1;++t)m(this.rightPad),m(this.separator);m(this.rightPad)}}}compute(t,e){const n=t.length,i=e.length;if(i>0){let t=e[0];if(0!==t)throw new Error(`First split value must be 0, got ${t}`);for(let s=1;s<i;++s){let i=e[s]>=t;if(i=i&&e[s]<=n,!i)throw new Error(`Invalid split value ${e[s]}, must be in [${t}, ${n}]`);t=e[s]}if(t!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${t}`)}const s=i-1,r=DO("int32",i);if(0===n||0===i){const t=new Array(n);for(let t=0;t<=s;++t)r[t]=0;return[t,r]}r[0]=0;for(let t=1;t<=s;++t){const n=e[t]-e[t-1];let i=0;this.nGramWidths.forEach((t=>{i+=this.getNumNGrams(n,t)})),this.preserveShort&&n>0&&0===i&&(i=1),r[t]=r[t-1]+i}const a=new Array(r[s]);for(let n=0;n<s;++n){const i=e[n];let s=r[n];if(this.nGramWidths.forEach((r=>{const o=e[n+1]-e[n],l=this.getNumNGrams(o,r);this.createNGrams(t,i,a,s,l,r),s+=l})),this.preserveShort&&s===r[n]){const r=e[n+1]-e[n];if(0===r)continue;const o=r+2*this.padWidth,l=1;this.createNGrams(t,i,a,s,l,o)}}return[a,r]}}function F4(t,e,n,i,s,r,a,o){return new L4(n,i,s,r,a,o).compute(t,e)}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function P4(t,e,n,i){if(!t.length)return;if(0===e.length){for(let e=0;e<t.length;++e)i.push(t.subarray(e,e+1));return}if(1===e.length){const s=e[0];let r=t.indexOf(s);for(;-1!==r;){const e=t.subarray(0,r);n&&0===e.length||i.push(e),r=(t=t.subarray(r+1)).indexOf(s)}return void(n&&0===t.length||i.push(t))}let s=0;for(let r=0;r<t.length+1;r++)if(r===t.length||-1!==e.indexOf(t[r])){const e=t.subarray(s,r);n&&0===e.length||i.push(e),s=r+1}}function $4(t,e,n){const i=t.length,s=[];let r=0,a=0;const o=new Array(i);for(let l=0;l<i;++l){const i=s.length;P4(t[l],e,n,s);const u=s.length-i;o[l]=u,r+=u,a=Math.max(a,u)}const l=DO("int32",2*r),u=new Array(r),h=[i,a];let p=0;for(let t=0;t<i;++t)for(let e=0;e<o[t];++e)l[2*p]=t,l[2*p+1]=e,u[p]=s[p],++p;return[l,u,h]}
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function B4(t,e){const n=DO("int32",t.length);for(let i=0;i<t.length;++i)n[i]=nk(t[i]).modulo(e).getLowBitsUnsigned();return n}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const V4=S2(((t,e)=>t-e)),U4=P2(((t,e,n,i)=>({real:t-n,imag:e-i}))),Y4=F2(pN,V4,U4),G4={kernelName:pN,backendName:"cpu",kernelFunc:Y4};
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function H4(t,e){const n=new Array(t.rank);for(let i=0;i<n.length;i++)n[i]=t.shape[i]*e[i];const i=FL(n,t.dtype);for(let e=0;e<i.values.length;++e){const n=i.indexToLoc(e),s=new Array(t.rank);for(let e=0;e<s.length;e++)s[e]=n[e]%t.shape[e];const r=t.locToIndex(s);i.values[e]=t.values[r]}return i}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const W4=(t,e)=>{const n=e.value-t.value;return 0===n?t.index-e.index:n};function z4(t,e,n=0,i=t.length-1){for(;i>n;){if(i-n>600){const s=i-n+1,r=e-n+1,a=Math.log(s),o=.5*Math.exp(2*a/3),l=.5*Math.sqrt(a*o*(s-o)/s)*Math.sign(r-s/2);z4(t,e,Math.max(n,Math.floor(e-r*o/s+l)),Math.min(i,Math.floor(e+(s-r)*o/s+l)))}const s=t[e];let r=n,a=i;for(dO(t,n,e),W4(t[i],s)>0&&dO(t,n,i);r<a;){for(dO(t,r,a),r++,a--;W4(t[r],s)<0;)r+=1;for(;W4(t[a],s)>0;)a-=1}0===W4(t[n],s)?dO(t,n,a):(a+=1,dO(t,a,i)),a<=e&&(n=a+1),e<=a&&(i=a-1)}}function X4(t,e,n,i,s){const r=e[e.length-1],[a,o]=[t.length/r,r],l=kO(n,a*i),u=kO("int32",a*i);for(let e=0;e<a;e++){const n=e*o,r=t.subarray(n,n+o);let a=new Array(r.length);r.forEach(((t,e)=>a[e]={value:t,index:e})),i<a.length&&(z4(a,i),a=a.slice(0,i)),s&&a.sort(W4);const h=e*i,p=l.subarray(h,h+i),c=u.subarray(h,h+i);for(let t=0;t<i;t++)p[t]=a[t].value,c[t]=a[t].index}const h=e.slice();return h[h.length-1]=i,[FL(h,n,l),FL(h,"int32",u)]}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function j4(t,e,n,i){const s=CO(e,n)[0],r=[1,n[0],1];for(let t=0;t<s;t++)r[0]*=n[t];r[1]=n[s];for(let t=s+1;t<n.length;t++)r[2]*=n[t];const a=new Map,o=new Int32Array(n[s]),l=new bk(r,i,t),u=[],h=1===r[0]&&1===r[2];for(let e=0;e<n[s];e++){let n;if(h)n=t[e].toString();else{const t=[];for(let n=0;n<r[0];n++)for(let i=0;i<r[2];i++)t.push(l.get(n,e,i));n=t.join(",")}const i=a.get(n);if(null!=i)o[e]=i;else{const t=a.size;a.set(n,t),o[e]=t,u.push(e)}}const p=r.slice();p[1]=a.size;const c=new bk(p,i);u.forEach(((t,e)=>{for(let n=0;n<r[0];n++)for(let i=0;i<r[2];i++)c.set(l.get(n,t,i),n,e,i)}));const d=n.slice();return d[s]=p[1],{outputValues:c.values,outputShape:d,indices:o}}
/** @license See the LICENSE file. */
const q4="4.22.0";
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
CD("cpu",(()=>new b2),1);
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const K4=j2(hM,(t=>t>=0?t:Math.exp(t)-1)),Q4={kernelName:hM,backendName:"cpu",kernelFunc:K4};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function J4(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{alpha:r}=i;I2([s],"leakyRelu");const a=IO(s.shape),o=n.data.get(s.dataId).values,l=kO("float32",a);for(let t=0;t<o.length;t++)l[t]=o[t]<0?r*o[t]:o[t];return n.makeTensorInfo(s.shape,"float32",l)}const Z4={kernelName:kM,backendName:"cpu",kernelFunc:J4},t5=S2(((t,e)=>t<0?e*t:t));function e5(t){const{inputs:e,backend:n}=t,{x:i,alpha:s}=e;I2([i,s],"prelu");const r=n.data.get(i.dataId).values,a=n.data.get(s.dataId).values,[o,l]=t5(i.shape,s.shape,r,a,"float32");return n.makeTensorInfo(l,"float32",o)}const n5={kernelName:yC,backendName:"cpu",kernelFunc:e5},i5=j2(RC,(t=>Math.max(0,t))),s5={kernelName:RC,backendName:"cpu",kernelFunc:i5},r5=j2(kC,(t=>Math.min(Math.max(0,t),6))),a5={kernelName:kC,backendName:"cpu",kernelFunc:r5};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function o5(t,e,n,i,s){if("linear"===n)return A2({inputs:{x:e},backend:t});if("relu"===n)return i5({inputs:{x:e},backend:t});if("elu"===n)return K4({inputs:{x:e},backend:t});if("relu6"===n)return r5({inputs:{x:e},backend:t});if("prelu"===n)return e5({inputs:{x:e,alpha:i},backend:t});if("leakyrelu"===n)return J4({inputs:{x:e},backend:t,attrs:{alpha:s}});if("sigmoid"===n)return _4({inputs:{x:e},backend:t});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function l5(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{shape:r}=i,a=IO(s.shape),o=MO(r,a),l=IO(o);_O(a===l,(()=>`The new shape (${o}) has ${l} elements and the old shape (${s.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(s.dataId);const u=n.data.get(s.dataId);if(null!=u.complexTensorInfos){const t=u.complexTensorInfos.real,e=u.complexTensorInfos.imag;t.shape=o,e.shape=o}return{dataId:s.dataId,shape:o,dtype:s.dtype}}const u5={kernelName:OC,backendName:"cpu",kernelFunc:l5};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function h5(t){const{inputs:e,backend:n,attrs:i}=t,{a:s,b:r}=e,{transposeA:a,transposeB:o}=i;I2([s,r],"matMul");const l=s.shape.length,u=r.shape.length,h=a?s.shape[l-2]:s.shape[l-1],p=o?r.shape[u-1]:r.shape[u-2],c=a?s.shape[l-1]:s.shape[l-2],d=o?r.shape[u-2]:r.shape[u-1],f=s.shape.slice(0,-2),m=r.shape.slice(0,-2),g=IO(f),_=IO(m),T=_F(s.shape.slice(0,-2),r.shape.slice(0,-2)).concat([c,d]);_O(h===p,(()=>`Error in matMul: inner shapes (${h}) and (${p}) of Tensors with shapes ${s.shape} and ${r.shape} and transposeA=${a} and transposeB=${o} must match.`));const y=o?[_,d,p]:[_,p,d],I=l5({inputs:{x:s},backend:n,attrs:{shape:a?[g,h,c]:[g,c,h]}}),E=l5({inputs:{x:r},backend:n,attrs:{shape:y}}),b=a?I.shape[1]:I.shape[2],v=a?I.shape[2]:I.shape[1],w=o?E.shape[1]:E.shape[2],S=Math.max(g,_),x=n.data.get(I.dataId).values,R=n.data.get(E.dataId).values,O=zO(I.shape),A=zO(E.shape),[M,C,N]=a?[O[0],1,O[1]]:[O[0],O[1],1],[k,D,L]=o?[1,A[1],A[0]]:[A[1],1,A[0]],F=v*w,P=FL([S,v,w],I.dtype),$=P.values,B=n.blockSize;for(let t=0;t<S;t++){const e=t%g,n=t%_;for(let i=0;i<v;i+=B){const s=Math.min(i+B,v);for(let r=0;r<w;r+=B){const a=Math.min(r+B,w);for(let o=0;o<b;o+=B){const l=Math.min(o+B,b);for(let u=i;u<s;u++)for(let i=r;i<a;i++){let s=0;for(let t=o;t<l;t++){s+=x[e*M+u*C+t*N]*R[t*k+i*D+n*L]}$[t*F+(u*w+i)]+=s}}}}}return n.disposeIntermediateTensorInfo(I),n.disposeIntermediateTensorInfo(E),n.makeTensorInfo(T,P.dtype,P.values)}const p5={kernelName:AA,backendName:"cpu",kernelFunc:h5};const c5={kernelName:xN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{a:s,b:r,bias:a,preluActivationWeights:o}=e,{transposeA:l,transposeB:u,activation:h,leakyreluAlpha:p}=i;let c,d,f;const m=[];c=h5({inputs:{a:s,b:r},attrs:{transposeA:l,transposeB:u},backend:n}),a&&(d=V2({inputs:{a:c,b:a},backend:n}),m.push(c),c=d),h&&(f=o5(n,c,h,o,p),m.push(c),c=f);for(const t of m)n.disposeIntermediateTensorInfo(t);return c}},d5=j2(cA,(t=>Math.acos(t))),f5={kernelName:cA,backendName:"cpu",kernelFunc:d5},m5=j2(dA,(t=>Math.acosh(t))),g5={kernelName:dA,backendName:"cpu",kernelFunc:m5};const _5={kernelName:mA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,i=e;I2(e,"addN");const s=i.map((t=>n.data.get(t.dataId).values)),r=FL(i[0].shape,i[0].dtype),a=r.values;for(let t=0;t<i.length;t++){const e=s[t];for(let t=0;t<a.length;t++)a[t]+=e[t]}return n.makeTensorInfo(r.shape,r.dtype,r.values)}};const T5={kernelName:gA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i;I2(s,"all");const o=CO(r,s.shape);let l=o;const u=_B(l,s.shape.length);let h=s;null!=u&&(h=K3({inputs:{x:s},backend:n,attrs:{perm:u}}),l=yB(l.length,s.shape.length)),gB("all",l,h.shape.length);const[p,c]=fB(h.shape,l),d=IO(c),f=QO(IO(p),h.dtype),m=n.data.get(h.dataId).values;for(let t=0;t<f.length;++t){const e=t*d;let n=m[e];for(let t=0;t<d;++t){const i=m[e+t];n=n&&i}f[t]=n}null!=u&&n.disposeIntermediateTensorInfo(h);const g=n.makeTensorInfo(p,h.dtype,f);if(a){const t=l5({inputs:{x:g},backend:n,attrs:{shape:mB(p,o)}});return n.disposeIntermediateTensorInfo(g),t}return g}};const y5={kernelName:_A,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i;I2(s,"any");const o=CO(r,s.shape);let l=o;const u=_B(l,s.shape.length);let h=s;null!=u&&(h=K3({inputs:{x:s},backend:n,attrs:{perm:u}}),l=yB(l.length,s.shape.length)),gB("any",l,h.shape.length);const[p,c]=fB(h.shape,l),d=IO(c),f=QO(IO(p),h.dtype),m=n.data.get(h.dataId).values;for(let t=0;t<f.length;++t){const e=t*d;let n=m[e];for(let t=0;t<d;++t){const i=m[e+t];n=n||i}f[t]=n}null!=u&&n.disposeIntermediateTensorInfo(h);const g=n.makeTensorInfo(p,h.dtype,f);if(a){const t=l5({inputs:{x:g},backend:n,attrs:{shape:mB(p,o)}});return n.disposeIntermediateTensorInfo(g),t}return g}};const I5={kernelName:TA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r}=i;I2(s,"argMax");let a=CO(r,s.shape);const o=_B(a,s.shape.length);let l=s;const u=[];null!=o&&(l=K3({inputs:{x:s},backend:n,attrs:{perm:o}}),u.push(l),a=yB(a.length,l.shape.length)),a=[a[0]],gB("argMax",a,l.shape.length);const[h,p]=fB(l.shape,a),c=QO(IO(h),"int32"),d=IO(p),f=n.data.get(l.dataId).values;for(let t=0;t<c.length;++t){const e=t*d;let n=f[e],i=0;for(let t=0;t<d;++t){const s=f[e+t];s>n&&(n=s,i=t)}c[t]=i}return u.forEach((t=>n.disposeIntermediateTensorInfo(t))),n.makeTensorInfo(h,"int32",c)}};const E5={kernelName:yA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r}=i;I2(s,"argMin");let a=CO(r,s.shape);const o=_B(a,s.shape.length);let l=s;const u=[];null!=o&&(l=K3({inputs:{x:s},backend:n,attrs:{perm:o}}),u.push(l),a=yB(a.length,l.shape.length)),a=[a[0]],gB("argMin",a,l.shape.length);const[h,p]=fB(l.shape,a),c=QO(IO(h),"int32"),d=IO(p),f=n.data.get(l.dataId).values;for(let t=0;t<c.length;++t){const e=t*d;let n=f[e],i=0;for(let t=0;t<d;++t){const s=f[e+t];s<n&&(n=s,i=t)}c[t]=i}return u.forEach((t=>n.disposeIntermediateTensorInfo(t))),n.makeTensorInfo(h,"int32",c)}},b5=j2(IA,(t=>Math.asin(t))),v5={kernelName:IA,backendName:"cpu",kernelFunc:b5},w5=j2(EA,(t=>Math.asinh(t))),S5={kernelName:EA,backendName:"cpu",kernelFunc:w5},x5=j2(bA,(t=>Math.atan(t))),R5={kernelName:bA,backendName:"cpu",kernelFunc:x5},O5=S2(((t,e)=>Math.atan2(t,e))),A5=F2(wA,O5),M5={kernelName:wA,backendName:"cpu",kernelFunc:A5},C5=j2(vA,(t=>Math.atanh(t))),N5={kernelName:vA,backendName:"cpu",kernelFunc:C5};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function k5(t,e,n,i,s,r){const a=s.strideHeight,o=s.strideWidth,l=s.dilationHeight,u=s.dilationWidth,h=s.effectiveFilterHeight,p=s.effectiveFilterWidth,c=s.padInfo.top,d=s.padInfo.left,f="max"===r?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=FL(s.outShape,n),g=m.values,_=s.outShape[1]*s.outShape[2]*s.outShape[3],T=s.outShape[2]*s.outShape[3],y=s.outShape[3];for(let e=0;e<s.batchSize;++e){const n=e*_,m=e*i[0];for(let e=0;e<s.inChannels;++e)for(let _=0;_<s.outHeight;++_){const I=_*a-c,E=Math.max(0,I),b=Math.min(s.inHeight,h+I),v=n+_*T;for(let n=0;n<s.outWidth;++n){const a=n*o-d,h=Math.max(0,a),c=Math.min(s.inWidth,p+a);let _=f,T=0,I=0;for(let n=E;n<b;n+=l){const s=m+n*i[1];for(let n=h;n<c;n+=u){const a=t[s+n*i[2]+e];"max"===r&&a>_?_=a:"avg"===r&&(T+=a,I++)}if(isNaN(_))break}g[v+n*y+e]="avg"===r?T/I:_}}}return m}function D5(t,e,n,i,s=!1,r=!1){const a=FL(i.outShape,"int32"),o=i.strideHeight,l=i.strideWidth,u=i.dilationHeight,h=i.dilationWidth,p=i.effectiveFilterHeight,c=i.effectiveFilterWidth,d=i.padInfo.top,f=i.padInfo.left,m=FL(e,n,t);for(let t=0;t<i.batchSize;++t)for(let e=0;e<i.inChannels;++e)for(let n=0;n<i.outHeight;++n){const g=n*o-d;let _=g;for(;_<0;)_+=u;const T=Math.min(i.inHeight,p+g);for(let o=0;o<i.outWidth;++o){const p=o*l-f;let d=p;for(;d<0;)d+=h;const y=Math.min(i.inWidth,c+p);let I=Number.NEGATIVE_INFINITY,E=-1;for(let n=_;n<T;n+=u){const a=n-g;for(let o=d;o<y;o+=h){const l=o-p,u=m.get(t,n,o,e);u>I&&(I=u,E=s?r?((t*i.inHeight+n)*i.inWidth+o)*i.inChannels+e:(n*i.inWidth+o)*i.inChannels+e:a*c+l)}}a.set(E,t,n,o,e)}}return a}function L5(t,e,n,i,s,r){const a=s.strideDepth,o=s.strideHeight,l=s.strideWidth,u=s.dilationDepth,h=s.dilationHeight,p=s.dilationWidth,c=s.effectiveFilterDepth,d=s.effectiveFilterHeight,f=s.effectiveFilterWidth,m=s.padInfo.front,g=s.padInfo.top,_=s.padInfo.left,T="max"===r?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,y=FL(s.outShape,n),I=y.values,E=s.outShape[1]*s.outShape[2]*s.outShape[3]*s.outShape[4],b=s.outShape[2]*s.outShape[3]*s.outShape[4],v=s.outShape[3]*s.outShape[4],w=s.outShape[4];for(let e=0;e<s.batchSize;++e){const n=e*E,y=e*i[0];for(let e=0;e<s.inChannels;++e)for(let E=0;E<s.outDepth;++E){const S=E*a-m;let x=S;for(;x<0;)x+=u;const R=Math.min(s.inDepth,c+S),O=n+E*b;for(let n=0;n<s.outHeight;++n){const a=n*o-g;let c=a;for(;c<0;)c+=h;const m=Math.min(s.inHeight,d+a),E=O+n*v;for(let n=0;n<s.outWidth;++n){const a=n*l-_;let o=a;for(;o<0;)o+=p;const d=Math.min(s.inWidth,f+a),g=E+n*w;let b=T,v=0,S=0;for(let n=x;n<R;n+=u){const s=y+n*i[1];for(let n=c;n<m;n+=h){const a=s+n*i[2];for(let n=o;n<d;n+=p){const s=t[a+n*i[3]+e];if("max"===r&&s>b?b=s:"avg"===r&&(v+=s,S++),isNaN(b))break}if(isNaN(b))break}if(isNaN(b))break}I[g+e]="avg"===r?v/Math.max(S,1):b}}}}return y}const F5={kernelName:SA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e;I2(s,"avgPool");const{filterSize:r,strides:a,pad:o,dimRoundingMode:l}=i;_O(m$(a,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const u=r$(s.shape,r,a,1,o,l);let h;if(1===u.filterWidth&&1===u.filterHeight&&vO(u.inShape,u.outShape))h=A2({inputs:{x:s},backend:n});else{const t=n.data.get(s.dataId).values,e=zO(s.shape),i=k5(t,s.shape,s.dtype,e,u,"avg");h=n.makeTensorInfo(u.outShape,s.dtype,i.values)}return h}};const P5={kernelName:RA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{filterSize:r,strides:a,pad:o,dimRoundingMode:l,dataFormat:u}=i;I2(s,"avgPool3d");const h=a$(s.shape,r,a,1,o,l,u),p=L5(n.data.get(s.dataId).values,s.shape,s.dtype,zO(s.shape),h,"avg");return n.makeTensorInfo(p.shape,"float32",p.values)}};const $5={kernelName:OA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,{filterSize:a,strides:o,pad:l,dimRoundingMode:u}=i;I2([s,r],"avgPool3DGrad");const h=a$(r.shape,a,o,1,l,u),p=h.strideDepth,c=h.strideHeight,d=h.strideWidth,f=h.filterDepth,m=h.filterHeight,g=h.filterWidth,_=h.dilationDepth,T=h.dilationHeight,y=h.dilationWidth,I=h.effectiveFilterDepth,E=h.effectiveFilterHeight,b=h.effectiveFilterWidth,v=I-1-h.padInfo.front,w=b-1-h.padInfo.left,S=E-1-h.padInfo.top,x=FL(r.shape,"float32"),R=1/(f*m*g),O=n.bufferSync(s);for(let t=0;t<h.batchSize;++t)for(let e=0;e<h.inChannels;++e)for(let n=0;n<h.inDepth;++n)for(let i=0;i<h.inHeight;++i)for(let s=0;s<h.inWidth;++s){const r=n-v,a=i-S,o=s-w;let l=0;for(let n=0;n<I;n+=_){const i=(r+n)/p;if(!(i<0||i>=h.outDepth||Math.floor(i)!==i))for(let n=0;n<E;n+=T){const s=(a+n)/c;if(!(s<0||s>=h.outHeight||Math.floor(s)!==s))for(let n=0;n<b;n+=y){const r=(o+n)/d;if(r<0||r>=h.outWidth||Math.floor(r)!==r)continue;l+=O.get(t,i,s,r,e)}}}x.set(l*R,t,n,i,s,e)}return n.makeTensorInfo(x.shape,x.dtype,x.values)}};const B5={kernelName:xA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,a=r;I2([s,r],"avgPoolGrad");const{filterSize:o,strides:l,pad:u}=i,h=r$(a.shape,o,l,1,u),p=h.strideHeight,c=h.strideWidth,d=h.filterHeight,f=h.filterWidth,m=h.dilationHeight,g=h.dilationWidth,_=h.effectiveFilterHeight,T=h.effectiveFilterWidth,y=T-1-h.padInfo.left,I=_-1-h.padInfo.top,E=FL(a.shape,"float32"),b=1/(d*f),v=n.data.get(s.dataId).values,w=FL(s.shape,"float32",v);for(let t=0;t<h.batchSize;++t)for(let e=0;e<h.inChannels;++e)for(let n=0;n<h.inHeight;++n)for(let i=0;i<h.inWidth;++i){const s=n-I,r=i-y;let a=0;for(let n=0;n<_;n+=m){const i=(s+n)/p;if(!(i<0||i>=h.outHeight||Math.floor(i)!==i))for(let n=0;n<T;n+=g){const s=(r+n)/c;if(s<0||s>=h.outWidth||Math.floor(s)!==s)continue;a+=w.get(t,i,s,e)}}E.set(a*b,t,n,i,e)}return n.makeTensorInfo(E.shape,E.dtype,E.values)}};const V5={kernelName:bM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,scale:r,offset:a,mean:o,variance:l}=e;_O(o.shape.length===l.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),_O(null==a||o.shape.length===a.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),_O(null==r||o.shape.length===r.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks.")),I2([s,o,l,r,a],"batchNorm");let{varianceEpsilon:u}=i;null==u&&(u=.001);const h=n.data.get(s.dataId).values,p=n.data.get(o.dataId).values,c=n.data.get(l.dataId).values,d=r?n.data.get(r.dataId).values:new Float32Array([1]),f=a?n.data.get(a.dataId).values:new Float32Array([0]),m=new Float32Array(h.length),g=f.length,_=d.length,T=c.length,y=p.length;let I=0,E=0,b=0,v=0;for(let t=0;t<h.length;++t)m[t]=f[I++]+(h[t]-p[E++])*d[b++]/Math.sqrt(c[v++]+u),I>=g&&(I=0),E>=y&&(E=0),b>=_&&(b=0),v>=T&&(v=0);return n.makeTensorInfo(s.shape,s.dtype,m)}};const U5={kernelName:MA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{blockShape:r,crops:a}=i;I2([s],"batchToSpaceND");const o=r.reduce(((t,e)=>t*e)),l=gG(s.shape,r,o),u=_G(l.length,r.length),h=TG(s.shape,r,o),p=yG(a,r.length),c=IG(h,a,r.length),d=l5({inputs:{x:s},backend:n,attrs:{shape:l}}),f=K3({inputs:{x:d},backend:n,attrs:{perm:u}}),m=l5({inputs:{x:f},backend:n,attrs:{shape:h}}),g=I4({inputs:{x:m},backend:n,attrs:{begin:p,size:c}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}};const Y5={kernelName:CA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,weights:r}=e,{size:a}=i,o=Y2(n.data.get(s.dataId).values,n.data.get(r.dataId).values,r.dtype,r.shape,a);return n.makeTensorInfo([a],r.dtype,o)}};const G5={kernelName:DA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{s0:i,s1:s}=e,r=n.data.get(i.dataId).values,a=n.data.get(s.dataId).values,o=_F(Array.from(r),Array.from(a));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},H5=j2(PA,((t,e)=>{const n=e;return t>n.clipValueMax?n.clipValueMax:t<n.clipValueMin?n.clipValueMin:t})),W5={kernelName:PA,backendName:"cpu",kernelFunc:H5},z5={kernelName:BA,backendName:"cpu",kernelFunc:t=>{const{x:e}=t.inputs,n=t.backend,i=new Float32Array(IO(e.shape)),s=n.data.get(e.dataId),r=s.complexTensorInfos.real,a=s.complexTensorInfos.imag,o=n.data.get(r.dataId).values,l=n.data.get(a.dataId).values;for(let t=0;t<o.length;t++){const e=o[t],n=l[t];i[t]=Math.hypot(e,n)}return n.makeOutput(i,e.shape,"float32")}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function X5(t){const{inputs:e,backend:n}=t,{input:i}=e,s=n.data.get(i.dataId).complexTensorInfos.imag,r=n.data.get(s.dataId).values;return n.makeTensorInfo(s.shape,s.dtype,r)}const j5={kernelName:AM,backendName:"cpu",kernelFunc:X5};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function q5(t){const{inputs:e,backend:n,attrs:i}=t,{axis:s}=i,r=CO(s,e[0].shape)[0];aG(e.map((t=>t.shape)),r);let a=oG(e.map((t=>t.shape)),r);if(0===IO(a))return n.makeTensorInfo(a,e[0].dtype,[]);const o=e.filter((t=>IO(t.shape)>0));if(1===o.length)return A2({inputs:{x:o[0]},backend:n});if("complex64"===o[0].dtype){const t=o.map((t=>C2({inputs:{input:t},backend:n}))),e=o.map((t=>X5({inputs:{input:t},backend:n}))),i=q5({inputs:t,backend:n,attrs:{axis:r}}),s=q5({inputs:e,backend:n,attrs:{axis:r}}),a=x2({inputs:{real:i,imag:s},backend:n});return t.forEach((t=>n.disposeIntermediateTensorInfo(t))),e.forEach((t=>n.disposeIntermediateTensorInfo(t))),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(s),a}const l=o.map((t=>{const e=IO(t.shape.slice(r));return l5({inputs:{x:t},backend:n,attrs:{shape:[-1,e]}})})),u=l.map((t=>({vals:n.data.get(t.dataId).values,shape:t.shape})));a=oG(l.map((t=>t.shape)),1);const h=1===l[0].shape[0],p=Z2(u,a,e[0].dtype,h),c=oG(o.map((t=>t.shape)),r),d=n.makeTensorInfo(c,e[0].dtype,p);return l.forEach((t=>n.disposeIntermediateTensorInfo(t))),d}const K5={kernelName:VA,backendName:"cpu",kernelFunc:q5};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Q5(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r}=e,{strides:a,pad:o,dataFormat:l,dilations:u,dimRoundingMode:h}=i;I2([s,r],"conv2d");const p=_$(l),c=o$(s.shape,r.shape,a,u,o,h,!1,p),d=c.filterHeight,f=c.filterWidth,m=c.dilationHeight,g=c.dilationWidth,_=c.padInfo.left,T=c.padInfo.top,y="channelsLast"===c.dataFormat,I=new bk(c.outShape,s.dtype),E=zO(s.shape),b=zO(r.shape),v=E[0],w=y?E[1]:E[2],S=y?E[2]:1,x=y?1:E[1],R=I.strides[0],O=y?I.strides[1]:I.strides[2],A=y?I.strides[2]:1,M=y?1:I.strides[1],C=n.data.get(s.dataId).values,N=n.data.get(r.dataId).values,k=I.values;for(let t=0;t<c.batchSize;++t){const e=t*v,n=t*R;for(let t=0;t<c.outHeight;++t){const i=n+t*O,s=t*c.strideHeight-T;for(let t=0;t<d;++t){const n=s+t*m;if(n<0||n>=c.inHeight)continue;const r=t*b[0],a=e+n*w;for(let t=0;t<c.outWidth;++t){const e=i+t*A,n=t*c.strideWidth-_;for(let t=0;t<f;++t){const i=n+t*g;if(i<0||i>=c.inWidth)continue;const s=a+i*S;let o=r+t*b[1];for(let t=0;t<c.inChannels;++t){const n=C[s+t*x];for(let t=0;t<c.outChannels;++t)k[e+t*M]+=n*N[o+t];o+=c.outChannels}}}}}}return n.makeTensorInfo(I.shape,I.dtype,k)}const J5={kernelName:UA,backendName:"cpu",kernelFunc:Q5};const Z5={kernelName:YA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,dy:r}=e,{strides:a,pad:o,dataFormat:l,dimRoundingMode:u,filterShape:h}=i;I2([s,r],"conv2dBackpropFilter");const p=_$(l),c=o$(s.shape,h,a,1,o,u,!1,p),{strideHeight:d,strideWidth:f,filterHeight:m,filterWidth:g}=c,_="channelsLast"===c.dataFormat,T=new bk(c.filterShape,"float32"),y=c.padInfo.left,I=c.padInfo.top,E=n.data.get(s.dataId).values,b=n.data.get(r.dataId).values,v=new bk(s.shape,s.dtype,E),w=new bk(r.shape,r.dtype,b);for(let t=0;t<m;++t){const e=Math.max(0,Math.ceil((I-t)/d)),n=Math.min(c.outHeight,(c.inHeight+I-t)/d);for(let i=0;i<g;++i){const s=Math.max(0,Math.ceil((y-i)/f)),r=Math.min(c.outWidth,(c.inWidth+y-i)/f);for(let a=0;a<c.inChannels;++a)for(let o=0;o<c.outChannels;++o){let l=0;for(let u=0;u<c.batchSize;++u)for(let h=e;h<n;++h){const e=t+h*d-I;for(let t=s;t<r;++t){const n=i+t*f-y;l+=_?v.get(u,e,n,a)*w.get(u,h,t,o):v.get(u,a,e,n)*w.get(u,o,h,t)}}T.set(l,t,i,a,o)}}}return n.makeTensorInfo(T.shape,T.dtype,T.values)}};const t6={kernelName:GA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,filter:r}=e,{inputShape:a,strides:o,pad:l,dataFormat:u,dimRoundingMode:h}=i;I2([s,r],"conv2dBackpropInput");const p=zO(r.shape),c=zO(s.shape);let d=_$(u);const f=o$(a,r.shape,o,1,l,h,!1,d),m=new bk(f.inShape,"float32"),g=m.values,_=n.data.get(s.dataId).values,T=n.data.get(r.dataId).values,[y,I,E]=p,{batchSize:b,filterHeight:v,filterWidth:w,inChannels:S,inHeight:x,inWidth:R,outChannels:O,outHeight:A,outWidth:M,strideHeight:C,strideWidth:N}=f;d=f.dataFormat;const k=v-1-f.padInfo.top,D=w-1-f.padInfo.left,L="channelsLast"===d,F=m.strides[0],P=L?m.strides[1]:m.strides[2],$=L?m.strides[2]:1,B=L?1:m.strides[1],V=c[0],U=L?c[1]:c[2],Y=L?c[2]:1,G=L?1:c[1];for(let t=0;t<b;++t)for(let e=0;e<S;++e)for(let n=0;n<x;++n){const i=n-k,s=Math.max(0,Math.ceil(i/C)),r=Math.min(A,(v+i)/C);for(let a=0;a<R;++a){const o=a-D,l=Math.max(0,Math.ceil(o/N)),u=Math.min(M,(w+o)/N);let h=0;for(let n=s;n<r;++n){const s=n*C-i;for(let i=l;i<u;++i){const r=V*t+U*n+Y*i,a=y*(v-1-s)+I*(w-1-(i*N-o))+E*e;for(let t=0;t<O;++t){h+=_[r+G*t]*T[a+t]}}}g[F*t+P*n+$*a+B*e]=h}}return n.makeTensorInfo(m.shape,m.dtype,m.values)}};const e6={kernelName:HA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r}=e,{strides:a,pad:o,dilations:l}=i;I2([s,r],"conv3d");const u=l$(s.shape,r.shape,a,l,o),{filterDepth:h,filterHeight:p,filterWidth:c,dilationDepth:d,dilationHeight:f,dilationWidth:m,padInfo:g}=u,_=g.front,T=g.left,y=g.top,I=new bk(u.outShape,s.dtype),E=n.data.get(s.dataId).values,b=n.data.get(r.dataId).values,v=I.values,w=zO(s.shape),S=zO(r.shape);for(let t=0;t<u.batchSize;++t){const e=t*w[0],n=t*I.strides[0];for(let t=0;t<u.outDepth;++t){const i=n+t*I.strides[1],s=t*u.strideDepth-_;for(let t=0;t<h;++t){const n=s+t*d;if(n<0||n>=u.inDepth)continue;const r=t*S[0],a=e+n*w[1];for(let t=0;t<u.outHeight;++t){const e=i+t*I.strides[2],n=t*u.strideHeight-y;for(let t=0;t<p;++t){const i=n+t*f;if(i<0||i>=u.inHeight)continue;const s=r+t*S[1],o=a+i*w[2];for(let t=0;t<u.outWidth;++t){const n=e+t*u.outChannels,i=t*u.strideWidth-T;for(let t=0;t<c;++t){const e=i+t*m;if(e<0||e>=u.inWidth)continue;const r=s+t*S[2],a=o+e*u.inChannels;let l=r;for(let t=0;t<u.inChannels;++t){const e=E[a+t];for(let t=0;t<u.outChannels;++t)v[n+t]+=e*b[l+t];l+=u.outChannels}}}}}}}}return n.makeTensorInfo(I.shape,I.dtype,I.values)}};const n6={kernelName:WA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,dy:r}=e,{strides:a,pad:o,filterShape:l}=i;I2([s,r],"conv3dBackpropFilterV2");const u=zO(s.shape),h=zO(r.shape),p=l$(s.shape,l,a,1,o),c=p.strideDepth,d=p.strideHeight,f=p.strideWidth,m=p.filterDepth,g=p.filterHeight,_=p.filterWidth,T=new bk(p.filterShape,"float32"),y=T.values,[I,E,b,v]=T.strides,w=n.data.get(r.dataId).values,[S,x,R,O]=h,A=n.data.get(s.dataId).values,[M,C,N,k]=u,D=p.padInfo.front,L=p.padInfo.left,F=p.padInfo.top;for(let t=0;t<m;++t){const e=Math.max(0,Math.ceil((D-t)/c)),n=Math.min(p.outDepth,(p.inDepth+D-t)/c),i=t*I;for(let s=0;s<g;++s){const r=Math.max(0,Math.ceil((F-s)/d)),a=Math.min(p.outHeight,(p.inHeight+F-s)/d),o=s*E+i;for(let i=0;i<_;++i){const l=Math.max(0,Math.ceil((L-i)/f)),u=Math.min(p.outWidth,(p.inWidth+L-i)/f),h=i*b+o;for(let o=0;o<p.inChannels;++o){const m=o*v+h;for(let h=0;h<p.outChannels;++h){let g=0;for(let m=0;m<p.batchSize;++m){const p=m*M,_=m*S;for(let m=e;m<n;++m){const e=(t+m*c-D)*C+p,n=m*x+_;for(let t=r;t<a;++t){const r=(s+t*d-F)*N+e,a=t*R+n;for(let t=l;t<u;++t){const e=t*O+a;g+=A[(i+t*f-L)*k+r+o]*w[e+h]}}}}y[m+h]=g}}}}}return n.makeTensorInfo(T.shape,T.dtype,T.values)}};const i6={kernelName:zA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,filter:r}=e,{pad:a,strides:o,inputShape:l}=i;I2([s],"conv3dBackpropInputV2");const u=zO(s.shape),h=zO(r.shape),p=l$(l,r.shape,o,1,a),c=new bk(p.inShape,"float32"),d=c.values,[f,m,g,_]=c.strides,T=n.data.get(s.dataId).values,[y,I,E,b]=u,v=n.data.get(r.dataId).values,[w,S,x,R]=h,{batchSize:O,filterDepth:A,filterHeight:M,filterWidth:C,inChannels:N,inDepth:k,inHeight:D,inWidth:L,outChannels:F,outDepth:P,outHeight:$,outWidth:B,strideDepth:V,strideHeight:U,strideWidth:Y}=p,G=A-1-p.padInfo.front,H=M-1-p.padInfo.top,W=C-1-p.padInfo.left;for(let t=0;t<O;++t)for(let e=0;e<N;++e)for(let n=0;n<k;++n){const i=n-G,s=Math.max(0,Math.ceil(i/V)),r=Math.min(P,(A+i)/V);for(let a=0;a<D;++a){const o=a-H,l=Math.max(0,Math.ceil(o/U)),u=Math.min($,(M+o)/U);for(let h=0;h<L;++h){const p=h-W,c=Math.max(0,Math.ceil(p/Y)),O=Math.min(B,(C+p)/Y);let N=0;for(let n=s;n<r;++n){const s=n*V-i;for(let i=l;i<u;++i){const r=i*U-o;for(let a=c;a<O;++a){const o=y*t+I*n+E*i+b*a,l=w*(A-1-s)+S*(M-1-r)+x*(C-1-(a*Y-p))+R*e;for(let t=0;t<F;++t){N+=T[o+t]*v[l+t]}}}}d[f*t+m*n+g*a+_*h+e]=N}}}return n.makeTensorInfo(c.shape,c.dtype,c.values)}},s6=j2(XA,(t=>Math.cos(t))),r6={kernelName:XA,backendName:"cpu",kernelFunc:s6},a6=j2(jA,(t=>Math.cosh(t))),o6={kernelName:jA,backendName:"cpu",kernelFunc:a6};const l6={kernelName:QA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{image:s,boxes:r,boxInd:a}=e,{cropSize:o,method:l,extrapolationValue:u}=i,[h,p,c,d]=s.shape,f=r.shape[0],[m,g]=o,_=FL([f,m,g,d],"float32"),T=n.data.get(r.dataId).values,y=n.data.get(a.dataId).values,I=n.data.get(s.dataId).values,E=zO(s.shape),b=zO(_.shape);for(let t=0;t<f;t++){const e=4*t,n=T[e],i=T[e+1],s=T[e+2],r=T[e+3],a=y[t];if(a>=h)continue;const o=m>1?(s-n)*(p-1)/(m-1):0,f=g>1?(r-i)*(c-1)/(g-1):0;for(let e=0;e<m;e++){const h=m>1?n*(p-1)+e*o:.5*(n+s)*(p-1);if(h<0||h>p-1)for(let n=0;n<g;n++)for(let i=0;i<d;i++){const s=i+n*b[2]+e*b[1]+t*b[0];_.values[s]=u}else if("bilinear"===l){const n=Math.floor(h),s=Math.ceil(h),o=h-n;for(let l=0;l<g;l++){const h=g>1?i*(c-1)+l*f:.5*(i+r)*(c-1);if(h<0||h>c-1){for(let n=0;n<d;n++){const i=n+l*b[2]+e*b[1]+t*b[0];_.values[i]=u}continue}const p=Math.floor(h),m=Math.ceil(h),T=h-p;for(let i=0;i<d;i++){let r=i+p*E[2]+n*E[1]+a*E[0];const u=I[r];r=i+m*E[2]+n*E[1]+a*E[0];const h=I[r];r=i+p*E[2]+s*E[1]+a*E[0];const c=I[r];r=i+m*E[2]+s*E[1]+a*E[0];const d=u+(h-u)*T,f=c+(I[r]-c)*T;r=i+l*b[2]+e*b[1]+t*b[0],_.values[r]=d+(f-d)*o}}}else for(let n=0;n<g;++n){const s=g>1?i*(c-1)+n*f:.5*(i+r)*(c-1);if(s<0||s>c-1){for(let i=0;i<d;i++){const s=i+n*b[2]+e*b[1]+t*b[0];_.values[s]=u}continue}const o=Math.round(s),l=Math.round(h);for(let i=0;i<d;i++){const s=i+o*E[2]+l*E[1]+a*E[0],r=i+n*b[2]+e*b[1]+t*b[0];_.values[r]=I[s]}}}}return n.makeTensorInfo(_.shape,_.dtype,_.values)}};const u6={kernelName:qA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,exclusive:a,reverse:o}=i;I2(s,"cumprod");const l=_B([r],s.shape.length);let u=s;null!=l&&(u=K3({inputs:{x:s},backend:n,attrs:{perm:l}}));const h=yB(1,s.shape.length)[0];if(h!==u.shape.length-1)throw new Error(`backend.cumprod in CPU expects an inner-most axis=${u.shape.length-1} but got axis=${h}`);const p=Lk(u.dtype,"int32"),c=KO(IO(u.shape),p),d=n.data.get(u.dataId).values,f=u.shape[u.shape.length-1],m=o?(t,e)=>t+f-e-1:(t,e)=>t+e;for(let t=0;t<d.length;t+=f)for(let e=0;e<f;e++){const n=m(t,e);if(0===e)c[n]=a?1:d[n];else{const i=m(t,e-1);c[n]=a?d[i]*c[i]:d[n]*c[i]}}const g=n.makeTensorInfo(u.shape,p,c);if(null!=l){const t=K3({inputs:{x:g},backend:n,attrs:{perm:TB(l)}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(u),t}return g}};const h6={kernelName:KA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,exclusive:a,reverse:o}=i;I2(s,"cumsum");const l=_B([r],s.shape.length);let u=s;null!=l&&(u=K3({inputs:{x:s},backend:n,attrs:{perm:l}}));const h=yB(1,s.shape.length)[0];if(h!==u.shape.length-1)throw new Error(`backend.cumsum in CPU expects an inner-most axis=${u.shape.length-1} but got axis=${h}`);const p=Lk(u.dtype,"int32"),c=QO(IO(u.shape),p),d=n.data.get(u.dataId).values,f=u.shape[u.shape.length-1],m=o?(t,e)=>t+f-e-1:(t,e)=>t+e;for(let t=0;t<d.length;t+=f)for(let e=0;e<f;e++){const n=m(t,e);if(0===e)c[n]=a?0:d[n];else{const i=m(t,e-1);c[n]=a?d[i]+c[i]:d[n]+c[i]}}const g=n.makeTensorInfo(u.shape,p,c);if(null!=l){const t=K3({inputs:{x:g},backend:n,attrs:{perm:TB(l)}});return n.disposeIntermediateTensorInfo(g),n.disposeIntermediateTensorInfo(u),t}return g}};const p6={kernelName:JA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,weights:r}=e,{size:a,binaryOutput:o}=i;if(1===s.shape.length){const t=Y2(n.data.get(s.dataId).values,n.data.get(r.dataId).values,r.dtype,r.shape,a);return n.makeTensorInfo([a],r.dtype,t)}if(2===s.shape.length){const t=G2(n.bufferSync(s),n.bufferSync(r),a,o);return n.makeTensorInfo(t.shape,r.dtype,t.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${s.shape.length}.`)}};const c6={kernelName:ZA,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{blockSize:r,dataFormat:a}=i;_O("NHWC"===a,(()=>`Only NHWC dataFormat supported on CPU for depthToSpace. Got ${a}`));const o=s.shape[0],l=s.shape[1],u=s.shape[2],h=s.shape[3],p=l*r,c=u*r,d=h/(r*r),f=n.data.get(s.dataId).values,m=new Float32Array(o*p*c*d);let g=0;for(let t=0;t<o;++t)for(let e=0;e<p;++e){const n=Math.floor(e/r),i=e%r;for(let e=0;e<c;++e){const s=Math.floor(e/r),a=(i*r+e%r)*d;for(let e=0;e<d;++e){const i=e+a+h*(s+u*(n+l*t));m[g++]=f[i]}}}return n.makeTensorInfo([o,p,c,d],s.dtype,m)}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function d6(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r}=e,{strides:a,pad:o,dilations:l,dimRoundingMode:u}=i;I2([s,r],"depthwiseConv2DNative");const h=zO(s.shape),p=zO(r.shape);let c=l;null==c&&(c=[1,1]),_O(m$(a,c),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${c}'`));const d=o$(s.shape,r.shape,a,c,o,u,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:_,padInfo:T}=d,y=T.left,I=T.top,E=d.outChannels/d.inChannels,b=new bk(d.outShape,s.dtype),v=n.data.get(s.dataId).values,w=n.data.get(r.dataId).values,S=b.values;for(let t=0;t<d.batchSize;++t){const e=t*h[0],n=t*b.strides[0];for(let t=0;t<d.outHeight;++t){const i=n+t*b.strides[1],s=t*d.strideHeight-I;for(let t=0;t<f;++t){const n=s+t*g;if(n<0||n>=d.inHeight)continue;const r=t*p[0],a=e+n*h[1];for(let t=0;t<d.outWidth;++t){const e=i+t*b.strides[2],n=t*d.strideWidth-y;for(let t=0;t<m;++t){const i=n+t*_;if(i<0||i>=d.inWidth)continue;const s=r+t*p[1],o=a+i*d.inChannels;let l=e,u=s;for(let t=0;t<d.inChannels;++t){const e=v[o+t];for(let t=0;t<E;++t)S[l+t]+=e*w[u+t];l+=E,u+=E}}}}}}return n.makeTensorInfo(b.shape,b.dtype,b.values)}const f6={kernelName:tM,backendName:"cpu",kernelFunc:d6};const m6={kernelName:eM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,dy:r}=e,{strides:a,dilations:o,pad:l,dimRoundingMode:u,filterShape:h}=i;I2([s,r],"depthwiseConv2dNativeBackpropFilter");const p=o$(s.shape,h,a,o,l,u,!0),{strideHeight:c,strideWidth:d,filterHeight:f,filterWidth:m}=p,g=new bk(p.filterShape,"float32"),_=p.padInfo.left,T=p.padInfo.top,y=p.outChannels/p.inChannels,I=n.data.get(s.dataId).values,E=new bk(s.shape,s.dtype,I),b=n.data.get(r.dataId).values,v=new bk(r.shape,r.dtype,b);for(let t=0;t<f;++t){const e=Math.max(0,Math.ceil((T-t)/c)),n=Math.min(p.outHeight,(p.inHeight+T-t)/c);for(let i=0;i<m;++i){const s=Math.max(0,Math.ceil((_-i)/d)),r=Math.min(p.outWidth,(p.inWidth+_-i)/d);for(let a=0;a<p.outChannels;++a){const o=Math.trunc(a/y),l=a%y;let u=0;for(let l=0;l<p.batchSize;++l)for(let h=e;h<n;++h){const e=t+h*c-T;for(let t=s;t<r;++t){const n=i+t*d-_;u+=E.get(l,e,n,o)*v.get(l,h,t,a)}}g.set(u,t,i,o,l)}}}return n.makeTensorInfo(g.shape,g.dtype,g.values)}};const g6={kernelName:nM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,filter:r}=e,{strides:a,dilations:o,pad:l,dimRoundingMode:u,inputShape:h}=i;I2([s,r],"depthwiseConv2DNativeBackpropInput");const p=zO(s.shape),c=zO(r.shape),d=o$(h,r.shape,a,o,l,u,!0),f=new bk(d.inShape,"float32"),m=f.values,[g,_,T]=f.strides,y=n.data.get(s.dataId).values,[I,E,b]=p,v=n.data.get(r.dataId).values,[w,S,x]=c,{batchSize:R,filterHeight:O,filterWidth:A,inChannels:M,inHeight:C,inWidth:N,outChannels:k,outHeight:D,outWidth:L,strideHeight:F,strideWidth:P}=d,$=O-1-d.padInfo.top,B=A-1-d.padInfo.left,V=k/M;for(let t=0;t<R;++t)for(let e=0;e<M;++e)for(let n=0;n<C;++n){const i=n-$,s=Math.max(0,Math.ceil(i/F)),r=Math.min(D,(O+i)/F);for(let a=0;a<N;++a){const o=a-B,l=Math.max(0,Math.ceil(o/P)),u=Math.min(L,(A+o)/P);let h=0;for(let n=s;n<r;++n){const s=n*F-i;for(let i=l;i<u;++i){const r=I*t+E*n+b*i,a=w*(O-1-s)+S*(A-1-(i*P-o))+x*e;for(let t=0;t<V;++t){h+=y[r+(e*V+t)]*v[a+t]}}}m[g*t+_*n+T*a+e]=h}}return n.makeTensorInfo(f.shape,f.dtype,f.values)}};const _6={kernelName:iM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{x:i}=e,s=IO(i.shape),r=n.data.get(i.dataId).values,a=FL([s,s],i.dtype),o=a.values;for(let t=0;t<r.length;t++)o[t*s+t]=r[t];const l=[...i.shape,...i.shape];return n.makeTensorInfo(l,a.dtype,a.values)}},T6={kernelName:sM,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:i,filter:s}=t,{strides:r,pad:a,dilations:o}=n,l=e,u=l.data.get(i.dataId).values,h=i.shape.length,p=l.data.get(s.dataId).values,c=s.shape.length,{batchSize:d,inHeight:f,inWidth:m,inChannels:g,outHeight:_,outWidth:T,padInfo:y,strideHeight:I,strideWidth:E,filterHeight:b,filterWidth:v,dilationHeight:w,dilationWidth:S,outShape:x}=s$(i.shape,s.shape,r,a,"NHWC",o),R=IO(x),O=x.length,A=DO(i.dtype,R);for(let t=0;t<d;++t)for(let e=0;e<_;++e){const n=e*I-y.top;for(let r=0;r<T;++r){const a=r*E-y.left;for(let o=0;o<g;++o){let l=Number.MIN_SAFE_INTEGER;for(let e=0;e<b;++e){const r=n+e*w;if(r>=0&&r<f)for(let n=0;n<v;++n){const d=a+n*S;if(d>=0&&d<m){const a=tA([t,r,d,o],h,zO(i.shape)),f=tA([e,n,o],c,zO(s.shape)),m=u[a]+p[f];m>l&&(l=m)}}}A[tA([t,e,r,o],O,zO(x))]=l}}}return{dataId:l.write(sk(A,i.dtype),x,i.dtype),shape:x,dtype:i.dtype}}},y6={kernelName:aM,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:i,filter:s,dy:r}=t,{strides:a,pad:o,dilations:l}=n,u=e,h=jO(i.shape,u.data.get(i.dataId).values),p=jO(s.shape,u.data.get(s.dataId).values),{batchSize:c,inHeight:d,inWidth:f,inChannels:m,outHeight:g,outWidth:_,padInfo:T,strideHeight:y,strideWidth:I,filterHeight:E,filterWidth:b,dilationHeight:v,dilationWidth:w,outShape:S}=s$(i.shape,s.shape,a,o,"NHWC",l);_O(r.rank===S.length,(()=>`Error in ${aM}, dy must have the same rank as output ${S.length}, but got ${r.rank}`));const x=jO(S,u.data.get(r.dataId).values),R=JO(s.shape,s.dtype);for(let t=0;t<c;++t)for(let e=0;e<g;++e){const n=e*y-T.top;for(let i=0;i<_;++i){const s=i*I-T.left;for(let r=0;r<m;++r){let a=Number.MIN_SAFE_INTEGER,o=0,l=0;for(let e=0;e<E;++e){const i=n+e*v;if(i>=0&&i<d)for(let n=0;n<b;++n){const u=s+n*w;if(u>=0&&u<f){const s=h[t][i][u][r]+p[e][n][r];s>a&&(a=s,o=e,l=n)}}}R[o][l][r]+=x[t][e][i][r]}}}return{dataId:u.write(sk(R,i.dtype),s.shape,s.dtype),shape:s.shape,dtype:s.dtype}}},I6={kernelName:rM,backendName:"cpu",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:i,filter:s,dy:r}=t,{strides:a,pad:o,dilations:l}=n,u=e,h=jO(i.shape,u.data.get(i.dataId).values),p=jO(s.shape,u.data.get(s.dataId).values),{batchSize:c,inHeight:d,inWidth:f,inChannels:m,outHeight:g,outWidth:_,padInfo:T,strideHeight:y,strideWidth:I,filterHeight:E,filterWidth:b,dilationHeight:v,dilationWidth:w,outShape:S}=s$(i.shape,s.shape,a,o,"NHWC",l);_O(r.rank===S.length,(()=>`Error in ${rM}, dy must have the same rank as output ${S.length}, but got ${r.rank}`));const x=jO(S,u.data.get(r.dataId).values),R=JO(i.shape,i.dtype);for(let t=0;t<c;++t)for(let e=0;e<g;++e){const n=e*y-T.top;for(let i=0;i<_;++i){const s=i*I-T.left;for(let r=0;r<m;++r){let a=Number.MIN_SAFE_INTEGER,o=n<0?0:n,l=s<0?0:s;for(let e=0;e<E;++e){const i=n+e*v;if(i>=0&&i<d)for(let n=0;n<b;++n){const u=s+n*w;if(u>=0&&u<f){const s=h[t][i][u][r]+p[e][n][r];s>a&&(a=s,o=i,l=u)}}}R[t][o][l][r]+=x[t][e][i][r]}}}return{dataId:u.write(sk(R,i.dtype),i.shape,i.dtype),shape:i.shape,dtype:i.dtype}}};const E6={kernelName:oM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2023 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{image:s}=e,{canvas:r,options:a}=i,{contextOptions:o,imageOptions:l}=a||{},u=(null==l?void 0:l.alpha)||1,h=(null==o?void 0:o.contextType)||"2d";if("2d"!==h)throw new Error(`Context type ${o.contextType} is not supported by the CPU backend.`);const p=r.getContext(h,(null==o?void 0:o.contextAttributes)||{});if(null==p)throw new Error(`Could not get the context with ${h} type.`);const[c,d]=s.shape.slice(0,2),f=2===s.shape.length?1:s.shape[2],m=n.data.get(s.dataId).values,g="float32"===s.dtype?255:1,_=new Uint8ClampedArray(d*c*4);for(let t=0;t<c*d;++t){const e=[0,0,0,255*u];for(let n=0;n<f;n++){const i=m[t*f+n];if("float32"===s.dtype){if(i<0||i>1)throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${i}.`)}else if("int32"===s.dtype&&(i<0||i>255))throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${i}.`);1===f?(e[0]=i*g,e[1]=i*g,e[2]=i*g):e[n]=i*g}const n=4*t;_[n+0]=Math.round(e[0]),_[n+1]=Math.round(e[1]),_[n+2]=Math.round(e[2]),_[n+3]=Math.round(e[3])}r.width=d,r.height=c;const T=new ImageData(_,d,c);return p.putImageData(T,0,0),s}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function b6(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i;let o;I2(s,"sum"),o="bool"===s.dtype?D2({inputs:{x:s},backend:n,attrs:{dtype:"int32"}}):A2({inputs:{x:s},backend:n});const l=o.shape.length,u=CO(r,o.shape),h=_B(u,l);let p=u,c=o;null!=h&&(c=K3({inputs:{x:o},backend:n,attrs:{perm:h}}),p=yB(p.length,l)),gB("sum",p,c.shape.length);const[d,f]=fB(c.shape,p);let m=O2(n,d,Lk(c.dtype,"int32"));const g=IO(f),_=n.data.get(m.dataId).values,T=n.data.get(c.dataId).values;for(let t=0;t<_.length;++t){const e=t*g;let n=0;for(let t=0;t<g;++t)n+=T[e+t];_[t]=n}if(a){const t=m;m=l5({inputs:{x:m},backend:n,attrs:{shape:mB(m.shape,u)}}),n.disposeIntermediateTensorInfo(t)}return n.disposeIntermediateTensorInfo(o),null!=h&&n.disposeIntermediateTensorInfo(c),m}const v6={kernelName:qC,backendName:"cpu",kernelFunc:b6};const w6={kernelName:uM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{equation:s}=i,r=e,{allDims:a,summedDims:o,idDims:l}=UG(s,r.length);GG(a.length,l,r);const{path:u,steps:h}=HG(o,l),p=h.length;let c=null,d=a.length;const f=[];for(let t=0;t<p;++t){for(const e of h[t]){const{permutationIndices:t,expandDims:i}=YG(d,l[e]);let s;WG(t)?s=r[e]:(s=K3({inputs:{x:r[e]},backend:n,attrs:{perm:t}}),f.push(s));const a=s.shape.slice();for(let t=0;t<i.length;++t)a.splice(i[t],0,1);vO(s.shape,a)||(s=l5({inputs:{x:s},backend:n,attrs:{shape:a}}),f.push(s)),null===c?c=s:(c=Y3({inputs:{a:s,b:c},backend:n}),f.push(c))}t<p-1&&(u[t]>=0&&(c=b6({inputs:{x:c},backend:n,attrs:{axis:u[t]-(a.length-d),keepDims:!1}}),f.push(c)),d--)}for(const t of f)t!==c&&n.disposeIntermediateTensorInfo(t);return c}};const S6={kernelName:pM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{dy:i,y:s}=e;I2([i,s],"eluGrad");const r=new Float32Array(IO(s.shape)),a=n.data.get(s.dataId).values,o=n.data.get(i.dataId).values;for(let t=0;t<a.length;++t){const e=a[t];r[t]=e>=0?o[t]:o[t]*(e+1)}return n.makeTensorInfo(s.shape,"float32",r)}},x6=vG,R6=wG,O6=SG,A6=xG,M6=RG,C6=OG,N6=j2(cM,(t=>{const e=Math.sign(t),n=Math.abs(t),i=1/(1+x6*n);return e*(1-((((C6*i+M6)*i+A6)*i+O6)*i+R6)*i*Math.exp(-n*n))})),k6={kernelName:cM,backendName:"cpu",kernelFunc:N6};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function D6(t){const{inputs:e,backend:n,attrs:i}=t,{input:s}=e,{dim:r}=i,a=s.shape.length,o=s.shape.slice();let l=r;return r<0&&(_O(-(a+1)<=r,(()=>`Axis must be in the interval [${-(a+1)}, ${a}]`)),l=a+r+1),o.splice(l,0,1),l5({inputs:{x:s},backend:n,attrs:{shape:o}})}const L6={kernelName:mM,backendName:"cpu",kernelFunc:D6},F6=S2(((t,e)=>t/e)),P6=F2(lM,F6),$6={kernelName:lM,backendName:"cpu",kernelFunc:P6};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function B6(t,e,n){const i=t.shape,s=i[0],r=i[1],a=n.data.get(t.dataId),o=a.complexTensorInfos.real,l=a.complexTensorInfos.imag,u=[s,r],h=IO(u),p=kO("float32",h),c=kO("float32",h);for(let t=0;t<s;t++){const i=I4({inputs:{x:o},backend:n,attrs:{begin:[t,0],size:[1,r]}}),s=I4({inputs:{x:l},backend:n,attrs:{begin:[t,0],size:[1,r]}}),a=x2({inputs:{real:i,imag:s},backend:n}),{real:u,imag:h}=V6(a,e,n),d=AG(u,h);for(let e=0;e<r;e++){const n=kG(d,e);p[t*r+e]=n.real,c[t*r+e]=n.imag}n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(a)}const d=n.makeTensorInfo(u,"float32",p),f=n.makeTensorInfo(u,"float32",c),m=x2({inputs:{real:d,imag:f},backend:n});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),m}function V6(t,e,n){const i=IO(t.shape),s=n.data.get(t.dataId),r=n.data.get(s.complexTensorInfos.real.dataId).values,a=n.data.get(s.complexTensorInfos.imag.dataId).values;if((o=i)&o-1){const t=function(t,e,n){const i=new Float32Array(2*e);for(let s=0;s<e;s++){let r=0,a=0;for(let i=0;i<e;i++){const o=FG(s*i,e,n),l=kG(t,i);r+=l.real*o.real-l.imag*o.imag,a+=l.real*o.imag+l.imag*o.real}n&&(r/=e,a/=e),DG(i,r,a,s)}return i}(AG(r,a),i,e);return MG(t)}{const s=U6(r,a,i,e,n),o=[t.shape[0],t.shape[1]];if(e){const t=n.makeTensorInfo(o,"float32",s.real),e=n.makeTensorInfo(o,"float32",s.imag),r=n.makeTensorInfo([],"float32",ik(i,"float32")),a=A2({inputs:{x:r},backend:n}),l=$6.kernelFunc({inputs:{a:t,b:r},backend:n}),u=$6.kernelFunc({inputs:{a:e,b:a},backend:n}),h=n.data.get(l.dataId).values,p=n.data.get(u.dataId).values;return n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(u),{real:h,imag:p}}return s}var o}function U6(t,e,n,i,s){if(1===n)return{real:t,imag:e};const r=AG(t,e),a=n/2,o=CG(r),l=o.real,u=o.imag,h=[l.length],p=s.makeTensorInfo(h,"float32",l),c=s.makeTensorInfo(h,"float32",u),d=x2({inputs:{real:p,imag:c},backend:s}),f=NG(r),m=f.real,g=f.imag,_=[m.length],T=s.makeTensorInfo(_,"float32",m),y=s.makeTensorInfo(_,"float32",g),I=x2({inputs:{real:T,imag:y},backend:s}),E=U6(l,u,a,i,s),b=E.real,v=E.imag,w=[b.length],S=s.makeTensorInfo(w,"float32",b),x=s.makeTensorInfo(w,"float32",v),R=x2({inputs:{real:S,imag:x},backend:s}),O=U6(m,g,a,i,s),A=O.real,M=O.imag,C=[A.length],N=s.makeTensorInfo(C,"float32",A),k=s.makeTensorInfo(C,"float32",M),D=x2({inputs:{real:N,imag:k},backend:s}),L=LG(n,i),F=[L.real.length],P=s.makeTensorInfo(F,"float32",L.real),$=s.makeTensorInfo(F,"float32",L.imag),B=x2({inputs:{real:P,imag:$},backend:s}),V=Y3({inputs:{a:B,b:D},backend:s}),U=V2({inputs:{a:R,b:V},backend:s}),Y=Y4({inputs:{a:R,b:V},backend:s}),G=C2({inputs:{input:U},backend:s}),H=C2({inputs:{input:Y},backend:s}),W=X5({inputs:{input:U},backend:s}),z=X5({inputs:{input:Y},backend:s}),X=q5({inputs:[G,H],backend:s,attrs:{axis:0}}),j=q5({inputs:[W,z],backend:s,attrs:{axis:0}}),q=s.data.get(X.dataId).values,K=s.data.get(j.dataId).values;return s.disposeIntermediateTensorInfo(p),s.disposeIntermediateTensorInfo(c),s.disposeIntermediateTensorInfo(d),s.disposeIntermediateTensorInfo(T),s.disposeIntermediateTensorInfo(y),s.disposeIntermediateTensorInfo(I),s.disposeIntermediateTensorInfo(S),s.disposeIntermediateTensorInfo(x),s.disposeIntermediateTensorInfo(R),s.disposeIntermediateTensorInfo(N),s.disposeIntermediateTensorInfo(k),s.disposeIntermediateTensorInfo(D),s.disposeIntermediateTensorInfo(P),s.disposeIntermediateTensorInfo($),s.disposeIntermediateTensorInfo(B),s.disposeIntermediateTensorInfo(V),s.disposeIntermediateTensorInfo(U),s.disposeIntermediateTensorInfo(Y),s.disposeIntermediateTensorInfo(G),s.disposeIntermediateTensorInfo(W),s.disposeIntermediateTensorInfo(H),s.disposeIntermediateTensorInfo(z),s.disposeIntermediateTensorInfo(X),s.disposeIntermediateTensorInfo(j),{real:q,imag:K}}const Y6={kernelName:_M,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{input:i}=e,s=IO(i.shape),r=i.shape[i.shape.length-1],a=l5({inputs:{x:i},backend:n,attrs:{shape:[s/r,r]}}),o=B6(a,!1,n),l=l5({inputs:{x:o},backend:n,attrs:{shape:i.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),l}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function G6(t){const{backend:e,attrs:n}=t,{shape:i,value:s,dtype:r}=n,a=r||GO(s),o=DO(a,IO(i));return function(t,e){t.fill(e)}(o,s),e.makeTensorInfo(i,a,o)}const H6={kernelName:TM,backendName:"cpu",kernelFunc:G6};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const W6={kernelName:yM,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{image:i}=t,s=n,r=kO(i.dtype,IO(i.shape)),[a,o,l,u]=i.shape,h=s.data.get(i.dataId).values;for(let t=0;t<a;t++){const e=t*l*o*u;for(let t=0;t<o;t++){const n=t*(l*u);for(let t=0;t<l;t++){const i=t*u;for(let s=0;s<u;s++){const a=Math.round(l-t-1),o=e+n+i+s;let p=h[o];if(a>=0&&a<l){p=h[e+n+a*u+s]}r[o]=p}}}}return{dataId:s.write(r,i.shape,i.dtype),shape:i.shape,dtype:i.dtype}}};const z6={kernelName:RN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r,bias:a,preluActivationWeights:o}=e,{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:c,activation:d,leakyreluAlpha:f}=i;let m=Q5({inputs:{x:s,filter:r},backend:n,attrs:{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:c}});if(a){const t=m;if("NCHW"===h&&1===a.shape.length&&1!==a.shape[0]){const t=l5({inputs:{x:a},backend:n,attrs:{shape:[a.shape[0],1,1]}});m=V2({inputs:{a:m,b:t},backend:n}),n.disposeIntermediateTensorInfo(t)}else m=V2({inputs:{a:m,b:a},backend:n});n.disposeIntermediateTensorInfo(t)}if(d){const t=m;if("NCHW"===h&&"prelu"===d&&1===o.shape.length&&1!==o.shape[0]){const t=l5({inputs:{x:o},backend:n,attrs:{shape:[o.shape[0],1,1]}});m=o5(n,m,d,t,f),n.disposeIntermediateTensorInfo(t)}else m=o5(n,m,d,o,f);n.disposeIntermediateTensorInfo(t)}return m}};const X6={kernelName:ON,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r,bias:a,preluActivationWeights:o}=e,{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:c,activation:d,leakyreluAlpha:f}=i;let m=d6({inputs:{x:s,filter:r},backend:n,attrs:{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:c}});if(a){const t=m;m=V2({inputs:{a:m,b:a},backend:n}),n.disposeIntermediateTensorInfo(t)}if(d){const t=m;m=o5(n,m,d,o,f),n.disposeIntermediateTensorInfo(t)}return m}};const j6={kernelName:wM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{params:i,indices:s}=e,r=IO(i.shape),a=s.shape,o=a[a.length-1],[l,u,h,p]=oP(i,s);if(0===u)return n.makeTensorInfo(l,i.dtype,[]);const c=m3(n.data.get(s.dataId).values,n.bufferSync(i),i.dtype,u,o,h,p,i.shape,r);return n.makeTensorInfo(l,i.dtype,c.values)}};const q6={kernelName:vM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,indices:r}=e,{axis:a,batchDims:o}=i;I2([s,r],"gatherV2");const l=CO(a,s.shape)[0],u=n.data.get(r.dataId).values,h=s.shape[l];for(let t=0;t<u.length;++t){const e=u[t];_O(e<=h-1&&e>=0,(()=>`GatherV2: the index value ${e} is not in [0, ${h-1}]`))}let p=o;null==o&&(p=0);const c=IO(r.shape),d=lH(s,r,l,p),f=l5({inputs:{x:s},backend:n,attrs:{shape:[d.batchSize,d.outerSize,d.dimSize,d.sliceSize]}}),m=l5({inputs:{x:r},backend:n,attrs:{shape:[d.batchSize,c/d.batchSize]}}),g=[d.batchSize,d.outerSize,c/d.batchSize,d.sliceSize],_=n.bufferSync(m),T=g3(n.bufferSync(f),_,g);return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.makeTensorInfo(d.outputShape,T.dtype,T.values)}};const K6={kernelName:OM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{input:i}=e,s=IO(i.shape),r=i.shape[i.shape.length-1],a=l5({inputs:{x:i},backend:n,attrs:{shape:[s/r,r]}}),o=B6(a,!0,n),l=l5({inputs:{x:o},backend:n,attrs:{shape:i.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(o),l}},Q6=j2(MM,(t=>Number.isFinite(t)?1:0),"bool"),J6={kernelName:MM,backendName:"cpu",kernelFunc:Q6},Z6=j2(CM,(t=>Math.abs(t)===1/0?1:0),"bool"),t8={kernelName:CM,backendName:"cpu",kernelFunc:Z6},e8=j2(NM,(t=>Number.isNaN(t)?1:0),"bool"),n8={kernelName:NM,backendName:"cpu",kernelFunc:e8};const i8={kernelName:FM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{backend:e,attrs:n}=t,{start:i,stop:s,num:r}=n,a=A3(i,s,r);return e.makeTensorInfo([a.length],"float32",a)}},s8=j2($M,(t=>Math.log1p(t))),r8={kernelName:$M,backendName:"cpu",kernelFunc:s8},a8=S2(((t,e)=>t&&e)),o8=F2(BM,a8,null,"bool"),l8={kernelName:BM,backendName:"cpu",kernelFunc:o8},u8=j2(VM,(t=>t?0:1),"bool"),h8={kernelName:VM,backendName:"cpu",kernelFunc:u8},p8=S2(((t,e)=>t||e)),c8=F2(UM,p8,null,"bool"),d8={kernelName:UM,backendName:"cpu",kernelFunc:c8};const f8={kernelName:WM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{depthRadius:r,bias:a,alpha:o,beta:l}=i;I2(s,"LRN");const u=s.shape[3],h=u-1,p=n.data.get(s.dataId).values,c=IO(s.shape),d=new Float32Array(c);function f(t){const e=t%u;let n=t-e+Math.max(0,e-r);const i=t-e+Math.min(e+r,h);let s=0;for(;n<=i;n++){const t=p[n];s+=t*t}return s}for(let t=0;t<c;t++){const e=f(t),n=p[t]*Math.pow(a+o*e,-l);d[t]=n}return n.makeTensorInfo(s.shape,s.dtype,d)}};const m8={kernelName:zM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,y:r,dy:a}=e,{depthRadius:o,bias:l,alpha:u,beta:h}=i;I2(a,"LRNGrad");const p=IO(a.shape),c=a.shape[3],d=n.data.get(a.dataId).values,f=n.data.get(s.dataId).values,m=n.data.get(r.dataId).values,g=new Float32Array(p),_=p;for(let t=0;t<_;t++){const e=t%c,n=t-e+Math.max(0,e-o),i=t-e+Math.min(c,e+o+1);let s=0;for(let t=n;t<i;t++)s+=Math.pow(f[t],2);s=u*s+l;for(let e=n;e<i;e++){let n=-2*u*h*f[e]*m[t]/s;t===e&&(n+=Math.pow(s,-h)),n*=d[t],g[e]+=n}}return n.makeTensorInfo(a.shape,s.dtype,g)}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function g8(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{reductionIndices:r,keepDims:a}=i,o=n;let l=s.shape;const u=l.length,h=CO(r,l);let p=h;const c=_B(p,u);let d=o.data.get(s.dataId).values;if(null!=c){const t=new Array(u);for(let e=0;e<t.length;e++)t[e]=l[c[e]];d=q3(d,l,s.dtype,c,t),p=yB(p.length,u),l=t}I2(s,"max"),gB("max",p,u);const[f,m]=fB(l,p),g=k3(d,IO(m),f,s.dtype),_=o.write(g,f,s.dtype);let T=f;if(a){T=mB(f,h)}return{dataId:_,shape:T,dtype:s.dtype}}const _8={kernelName:jM,backendName:"cpu",kernelFunc:g8};const T8={kernelName:KM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e;I2(s,"maxPool");const{filterSize:r,strides:a,pad:o,dimRoundingMode:l}=i;_O(m$(a,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const u=r$(s.shape,r,a,1,o,l);let h;if(1===u.filterWidth&&1===u.filterHeight&&vO(u.inShape,u.outShape))h=A2({inputs:{x:s},backend:n});else{const t=n.data.get(s.dataId).values,e=zO(s.shape),i=k5(t,s.shape,s.dtype,e,u,"max");h=n.makeTensorInfo(u.outShape,s.dtype,i.values)}return h}};const y8={kernelName:JM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{filterSize:r,strides:a,pad:o,dimRoundingMode:l,dataFormat:u}=i;I2(s,"maxPool3d");const h=a$(s.shape,r,a,1,o,l,u),p=L5(n.data.get(s.dataId).values,s.shape,s.dtype,zO(s.shape),h,"max");return n.makeTensorInfo(p.shape,"float32",p.values)}};const I8={kernelName:ZM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,{filterSize:a,strides:o,pad:l,dimRoundingMode:u}=i;I2([s,r],"maxPool3DGrad");const h=a$(r.shape,a,o,1,l,u),p=function(t,e){const n=FL(e.outShape,"int32"),i=e.strideDepth,s=e.strideHeight,r=e.strideWidth,a=e.dilationDepth,o=e.dilationHeight,l=e.dilationWidth,u=e.effectiveFilterDepth,h=e.effectiveFilterHeight,p=e.effectiveFilterWidth,c=e.padInfo.front,d=e.padInfo.top,f=e.padInfo.left;for(let m=0;m<e.batchSize;++m)for(let g=0;g<e.inChannels;++g)for(let _=0;_<e.outDepth;++_){const T=_*i-c;let y=T;for(;y<0;)y+=a;const I=Math.min(e.inDepth,u+T);for(let i=0;i<e.outHeight;++i){const u=i*s-d;let c=u;for(;c<0;)c+=o;const E=Math.min(e.inHeight,h+u);for(let s=0;s<e.outWidth;++s){const d=s*r-f;let b=d;for(;b<0;)b+=l;const v=Math.min(e.inWidth,p+d);let w=Number.NEGATIVE_INFINITY,S=-1;for(let e=y;e<I;e+=a){const n=e-T;for(let i=c;i<E;i+=o){const s=i-u;for(let r=b;r<v;r+=l){const a=r-d,o=t.get(m,e,i,r,g);o>=w&&(w=o,S=n*h*p+s*h+a)}}}n.set(S,m,_,i,s,g)}}}return n}(n.bufferSync(r),h),c=h.strideDepth,d=h.strideHeight,f=h.strideWidth,m=h.dilationDepth,g=h.dilationHeight,_=h.dilationWidth,T=h.effectiveFilterDepth,y=h.effectiveFilterHeight,I=h.effectiveFilterWidth,E=T-1-h.padInfo.front,b=I-1-h.padInfo.left,v=y-1-h.padInfo.top,w=FL(r.shape,"float32"),S=n.bufferSync(s);for(let t=0;t<h.batchSize;++t)for(let e=0;e<h.inChannels;++e)for(let n=0;n<h.inDepth;++n)for(let i=0;i<h.inHeight;++i)for(let s=0;s<h.inWidth;++s){const r=n-E,a=i-v,o=s-b;let l=0;for(let n=0;n<T;n+=m){const i=(r+n)/c;if(!(i<0||i>=h.outDepth||Math.floor(i)!==i))for(let s=0;s<y;s+=g){const r=(a+s)/d;if(!(r<0||r>=h.outHeight||Math.floor(r)!==r))for(let a=0;a<I;a+=_){const u=(o+a)/f;if(u<0||u>=h.outWidth||Math.floor(u)!==u)continue;const c=T*y*I-1-p.get(t,i,r,u,e)===n*y*I+s*I+a?1:0;if(0===c)continue;l+=S.get(t,i,r,u,e)*c}}}w.set(l,t,n,i,s,e)}return n.makeTensorInfo(w.shape,w.dtype,w.values)}};const E8={kernelName:QM,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r,output:a}=e,o=r;I2([r,a],"maxPoolGrad");const{filterSize:l,strides:u,pad:h,dimRoundingMode:p}=i,c=r$(o.shape,l,u,1,h,p),d=n.data.get(o.dataId).values,f=FL(c.outShape,o.dtype,D5(d,o.shape,o.dtype,c).values),m=c.strideHeight,g=c.strideWidth,_=c.dilationHeight,T=c.dilationWidth,y=c.effectiveFilterHeight,I=c.effectiveFilterWidth,E=I-1-c.padInfo.left,b=y-1-c.padInfo.top,v=FL(o.shape,"float32"),w=n.data.get(s.dataId).values,S=FL(s.shape,"float32",w);for(let t=0;t<c.batchSize;++t)for(let e=0;e<c.inChannels;++e)for(let n=0;n<c.inHeight;++n)for(let i=0;i<c.inWidth;++i){const s=n-b,r=i-E;let a=0;for(let n=0;n<y;n+=_){const i=(s+n)/m;if(!(i<0||i>=c.outHeight||Math.floor(i)!==i))for(let s=0;s<I;s+=T){const o=(r+s)/g;if(o<0||o>=c.outWidth||Math.floor(o)!==o)continue;const l=y*I-1-f.get(t,i,o,e)===n*I+s?1:0;if(0===l)continue;a+=S.get(t,i,o,e)*l}}v.set(a,t,n,i,e)}return n.makeTensorInfo(v.shape,v.dtype,v.values)}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const b8={kernelName:tC,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:i}=t,{filterSize:s,strides:r,pad:a,includeBatchInIndex:o}=e,l=n;I2(i,"MaxPoolWithArgmax");const u=l.data.get(i.dataId).values,h=r$(i.shape,s,r,[1,1],a),[p,c]=
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i,s){const r=k5(t,0,n,zO(e),s,"max"),a=D5(t,e,n,s,!0,i);return[r.values,a.values]}(u,i.shape,i.dtype,o,h),d=l.write(p,h.outShape,i.dtype),f=l.write(c,h.outShape,i.dtype);return[{dataId:d,shape:h.outShape,dtype:i.dtype},{dataId:f,shape:h.outShape,dtype:"int32"}]}};const v8={kernelName:eC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i,o=CO(r,s.shape),l=IO(fB(s.shape,o)[1]),u=[],h=n.makeTensorInfo([],"float32",new Float32Array([l]));u.push(h);const p=D2({inputs:{x:s},backend:n,attrs:{dtype:"float32"}});u.push(p);const c=P6({inputs:{a:p,b:h},backend:n});u.push(c);const d=b6({inputs:{x:c},backend:n,attrs:{axis:r,keepDims:a}});return u.forEach((t=>n.disposeIntermediateTensorInfo(t))),d}};const w8={kernelName:nC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i;I2(s,"min");const o=CO(r,s.shape);let l=o;const u=_B(l,s.shape.length);let h=s;null!=u&&(h=K3({inputs:{x:s},backend:n,attrs:{perm:u}}),l=yB(l.length,s.shape.length)),gB("min",l,h.shape.length);const[p,c]=fB(h.shape,l),d=IO(c),f=QO(IO(p),h.dtype),m=n.data.get(h.dataId).values;for(let t=0;t<f.length;++t){const e=t*d;let n=m[e];for(let t=0;t<d;++t){const i=m[e+t];(Number.isNaN(i)||i<n)&&(n=i)}f[t]=n}null!=u&&n.disposeIntermediateTensorInfo(h);const g=n.makeTensorInfo(p,h.dtype,f);if(a){const t=l5({inputs:{x:g},backend:n,attrs:{shape:mB(p,o)}});return n.disposeIntermediateTensorInfo(g),t}return g}};const S8={kernelName:sC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{paddings:r,mode:a}=i;I2(s,"mirrorPad");const o=r.map(((t,e)=>t[0]+s.shape[e]+t[1])),l=r.map((t=>t[0])),u=r.map(((t,e)=>t[0]+s.shape[e])),h="reflect"===a?0:1,p=n.data.get(s.dataId).values,c=s.shape.length,d=zO(s.shape),f=IO(o),m=o.length,g=zO(o),_=kO(s.dtype,f);for(let t=0;t<f;t++){let e=eA(t,m,g);for(let t=0;t<m;t++)e[t]<l[t]?e[t]=2*l[t]-e[t]-h:e[t]>=u[t]&&(e[t]=2*(u[t]-1)-e[t]+h);e=e.map(((t,e)=>t-l[e]));const n=tA(e,c,d);_[t]=p[n]}return{dataId:n.write(_,o,s.dtype),shape:o,dtype:s.dtype}}},x8=S2(((t,e)=>{const n=t%e;return t<0&&e<0||t>=0&&e>=0?n:(n+e)%e})),R8=F2(rC,x8),O8={kernelName:rC,backendName:"cpu",kernelFunc:R8};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function A8(t){const{inputs:e,backend:n,attrs:i}=t,{logits:s}=e,{dim:r}=i,a=s.shape.length;let o=r;if(-1===o&&(o=a-1),o!==a-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${a} and dim was ${o}`);const l=CO([o],s.shape),u=g8({inputs:{x:s},backend:n,attrs:{reductionIndices:l,keepDims:!1}}),h=mB(u.shape,l),p=l5({inputs:{x:u},backend:n,attrs:{shape:h}}),c=Y4({inputs:{a:s,b:p},backend:n}),d=s3({inputs:{x:c},backend:n}),f=b6({inputs:{x:d},backend:n,attrs:{axis:l,keepDims:!1}}),m=l5({inputs:{x:f},backend:n,attrs:{shape:h}}),g=P6({inputs:{a:d,b:m},backend:n});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}const M8={kernelName:JC,backendName:"cpu",kernelFunc:A8};const C8={kernelName:aC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{logits:s}=e,{numSamples:r,seed:a,normalized:o}=i;I2(s,"multinomial");const l=o?s:A8({inputs:{logits:s},backend:n,attrs:{dim:-1}}),u=l.shape[0],h=l.shape[1],p=n.data.get(l.dataId).values,c=[u,r],d=QO(IO(c),"int32");for(let t=0;t<u;++t){const e=t*h,n=new Float32Array(h-1);n[0]=p[e];for(let t=1;t<n.length;++t)n[t]=n[t-1]+p[e+t];const i=CV.alea(a.toString()),s=t*r;for(let t=0;t<r;++t){const e=i();d[s+t]=n.length;for(let i=0;i<n.length;i++)if(e<n[i]){d[s+t]=i;break}}}return o||n.disposeIntermediateTensorInfo(l),n.makeTensorInfo(c,"int32",d)}},N8=cY;const k8={kernelName:hC,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:i}=t,{boxes:s,scores:r}=e,{maxOutputSize:a,iouThreshold:o,scoreThreshold:l}=i;I2(s,"NonMaxSuppression");const u=n.data.get(s.dataId).values,h=n.data.get(r.dataId).values,{selectedIndices:p}=N8(u,h,a,o,l);return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}},D8=dY;const L8={kernelName:pC,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:i}=t,{boxes:s,scores:r}=e,{maxOutputSize:a,iouThreshold:o,scoreThreshold:l,padToMaxOutputSize:u}=i;I2(s,"NonMaxSuppressionPadded");const h=n.data.get(s.dataId).values,p=n.data.get(r.dataId).values,{selectedIndices:c,validOutputs:d}=D8(h,p,a,o,l,u);return[n.makeTensorInfo([c.length],"int32",new Int32Array(c)),n.makeTensorInfo([],"int32",new Int32Array([d]))]}},F8=fY;const P8={kernelName:cC,backendName:"cpu",kernelFunc:function(t){const{inputs:e,backend:n,attrs:i}=t,{boxes:s,scores:r}=e,{maxOutputSize:a,iouThreshold:o,scoreThreshold:l,softNmsSigma:u}=i;I2(s,"NonMaxSuppressionWithScore");const h=n.data.get(s.dataId).values,p=n.data.get(r.dataId).values,c=a,d=o,f=l,m=u,{selectedIndices:g,selectedScores:_}=F8(h,p,c,d,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([_.length],"float32",new Float32Array(_))]}};const $8={kernelName:fC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{indices:s}=e,{dtype:r,depth:a,onValue:o,offValue:l}=i;I2(s,"oneHot");const u=IO(s.shape),h=new Float32Array(u*a);h.fill(l);const p=n.data.get(s.dataId).values;for(let t=0;t<u;++t)p[t]>=0&&p[t]<a&&(h[t*a+p[t]]=o);return n.makeTensorInfo([...s.shape,a],r,h)}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function B8(t){const{inputs:e,backend:n}=t,{x:i}=e;if("string"===i.dtype)throw new Error("zerosLike is not supported for string tensors");if("complex64"===i.dtype){const t=C2({inputs:{input:i},backend:n}),e=B8({inputs:{x:t},backend:n}),s=X5({inputs:{input:i},backend:n}),r=B8({inputs:{x:s},backend:n}),a=x2({inputs:{real:e,imag:r},backend:n});return n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(r),a}return G6({backend:n,attrs:{shape:i.shape,value:0,dtype:i.dtype}})}const V8={kernelName:bN,backendName:"cpu",kernelFunc:B8};const U8={kernelName:dC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function t(e){const{inputs:n,backend:i}=e,{x:s}=n;if("string"===s.dtype)throw new Error("onesLike is not supported for string tensors");if("complex64"===s.dtype){const e=C2({inputs:{input:s},backend:i}),n=t({inputs:{x:e},backend:i}),r=X5({inputs:{input:s},backend:i}),a=B8({inputs:{x:r},backend:i}),o=x2({inputs:{real:n,imag:a},backend:i});return i.disposeIntermediateTensorInfo(e),i.disposeIntermediateTensorInfo(n),i.disposeIntermediateTensorInfo(r),i.disposeIntermediateTensorInfo(a),o}return G6({backend:i,attrs:{shape:s.shape,value:1,dtype:s.dtype}})}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Y8(t){const{inputs:e,backend:n,attrs:i}=t,{axis:s}=i;if(1===e.length)return D6({inputs:{input:e[0]},backend:n,attrs:{dim:s}});const r=e[0].shape,a=e[0].dtype;e.forEach((t=>{TO(r,t.shape,"All tensors passed to stack must have matching shapes"),_O(a===t.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],l=q5({inputs:e.map((t=>{const e=D6({inputs:{input:t},backend:n,attrs:{dim:s}});return o.push(e),e})),backend:n,attrs:{axis:s}});return o.forEach((t=>n.disposeIntermediateTensorInfo(t))),l}const G8={kernelName:mC,backendName:"cpu",kernelFunc:Y8};const H8={kernelName:gC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{paddings:r,constantValue:a}=i;I2(s,"pad");const o=r.map(((t,e)=>t[0]+s.shape[e]+t[1])),l=r.map((t=>t[0])),u=n.data.get(s.dataId).values,h=IO(s.shape),p=s.shape.length,c=zO(s.shape),d=IO(o),f=o.length,m=zO(o),g=kO(s.dtype,d);0!==a&&g.fill(a);for(let t=0;t<h;t++){g[tA(eA(t,p,c).map(((t,e)=>t+l[e])),f,m)]=u[t]}return{dataId:n.write(g,o,s.dtype),shape:o,dtype:s.dtype}}},W8=S2(((t,e)=>Math.pow(t,e))),z8=F2(TC,W8),X8={kernelName:TC,backendName:"cpu",kernelFunc:z8};const j8={kernelName:EC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{paramsNestedSplits:s,paramsDenseValues:r,indices:a}=e,{outputRaggedRank:o}=i,l=s.map((t=>n.data.get(t.dataId).values)),u=s.map((t=>t.shape)),h=n.data.get(r.dataId).values,p=n.data.get(a.dataId).values,[c,d,f]=i4(l,u,h,r.shape,r.dtype,p,a.shape),m=c.map((t=>n.makeTensorInfo([t.length],"int32",t))),g=n.makeTensorInfo(f,r.dtype,d);return m.concat([g])}};const q8={kernelName:bC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{starts:i,limits:s,deltas:r}=e,a=n.data.get(i.dataId).values,o=n.data.get(s.dataId).values,l=n.data.get(r.dataId).values,[u,h]=r4(a,i.shape,i.dtype,o,s.shape,l,r.shape);return[n.makeTensorInfo([u.length],"int32",u),n.makeTensorInfo([h.length],i.dtype,h)]}};const K8={kernelName:vC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{shape:s,values:r,defaultValue:a,rowPartitionTensors:o}=e,{rowPartitionTypes:l}=i,u=n.data.get(s.dataId).values,h=n.data.get(r.dataId).values,p=n.data.get(a.dataId).values,c=o.map((t=>n.data.get(t.dataId).values)),d=o.map((t=>t.shape)),[f,m]=h4(u,s.shape,h,r.shape,r.dtype,p,a.shape,c,d,l);return n.makeTensorInfo(f,r.dtype,m)}};const Q8={kernelName:wC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{backend:e,attrs:n}=t,{start:i,stop:s,dtype:r,step:a}=n,o=p4(i,s,a,r);return e.makeTensorInfo([o.length],r,o)}},J8=j2(xC,(t=>1/t)),Z8={kernelName:xC,backendName:"cpu",kernelFunc:J8};const t9={kernelName:CC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s}=e,{alignCorners:r,halfPixelCenters:a,size:o}=i;I2(s,"resizeBilinear");const l=zO(s.shape),[u,h]=o,[p,c,d,f]=s.shape,m=n.data.get(s.dataId).values,g=new Float32Array(IO([p,u,h,f])),_=[r&&u>1?c-1:c,r&&h>1?d-1:d],T=[r&&u>1?u-1:u,r&&h>1?h-1:h];let y=0;const I=_[0]/T[0],E=_[1]/T[1];for(let t=0;t<p;t++)for(let e=0;e<u;e++){let n;n=a?I*(e+.5)-.5:I*e;const i=Math.max(0,Math.floor(n)),s=n-i,r=Math.min(c-1,Math.ceil(n)),o=t*l[0]+i*l[1],u=t*l[0]+r*l[1];for(let t=0;t<h;t++){let e;e=a?E*(t+.5)-.5:E*t;const n=Math.max(0,Math.floor(e)),i=e-n,r=Math.min(d-1,Math.ceil(e)),h=o+n*l[2],p=u+n*l[2],c=o+r*l[2],_=u+r*l[2];for(let t=0;t<f;t++){const e=m[h+t],n=m[p+t],r=e+(m[c+t]-e)*i,a=r+(n+(m[_+t]-n)*i-r)*s;g[y++]=a}}}return n.makeTensorInfo([p,u,h,f],"float32",g)}};const e9={kernelName:NC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s,dy:r}=e,{alignCorners:a}=i;I2([r,s],"resizeBilinearGrad");const o=zO(s.shape),[l,u,h,p]=s.shape,[,c,d]=r.shape,f=new Float32Array(l*u*h*p),m=[a&&c>1?u-1:u,a&&d>1?h-1:h],g=[a&&c>1?c-1:c,a&&d>1?d-1:d],_=m[0]/g[0],T=m[1]/g[1],y=n.data.get(r.dataId).values;let I=0;for(let t=0;t<l;t++){const e=t*o[0];for(let t=0;t<c;t++){const n=t*_,i=Math.floor(n),s=Math.min(Math.ceil(n),u-1),r=e+i*o[1],a=e+s*o[1],l=n-i,c=1-l;for(let t=0;t<d;t++){const e=t*T,n=Math.floor(e),i=Math.min(Math.ceil(e),h-1),s=e-n,u=1-s,d=r+n*o[2],m=r+i*o[2],g=a+n*o[2],_=a+i*o[2],E=c*u,b=c*s,v=l*u,w=l*s;for(let t=0;t<p;t++){const e=y[I++];f[d+t]+=e*E,f[m+t]+=e*b,f[g+t]+=e*v,f[_+t]+=e*w}}}}return n.makeTensorInfo([l,h,u,p],"float32",f)}};const n9={kernelName:AC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s}=e,{alignCorners:r,halfPixelCenters:a,size:o}=i;I2(s,"resizeNearestNeighbor");const l=zO(s.shape),[u,h]=o,[p,c,d,f]=s.shape,m=n.data.get(s.dataId).values,g=new Float32Array(p*u*h*f),_=[r&&u>1?c-1:c,r&&h>1?d-1:d],T=[r&&u>1?u-1:u,r&&h>1?h-1:h],y=_[0]/T[0],I=_[1]/T[1];let E=0;for(let t=0;t<p;t++){const e=t*l[0];for(let t=0;t<u;t++){const n=a?y*(t+.5):y*t;let i=Math.min(c-1,r?Math.round(n):Math.floor(n));a&&(i=Math.max(0,i));const s=e+i*l[1];for(let t=0;t<h;t++){const e=a?I*(t+.5):I*t;let n=Math.min(d-1,r?Math.round(e):Math.floor(e));a&&(n=Math.max(0,n));const i=s+n*l[2];for(let t=0;t<f;t++){const e=m[i+t];g[E++]=e}}}}return n.makeTensorInfo([p,u,h,f],s.dtype,g)}};const i9={kernelName:MC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s,dy:r}=e,{alignCorners:a}=i;I2([r,s],"resizeNearestNeighborGrad");const o=zO(s.shape),l=zO(r.shape),[u,h,p,c]=s.shape,[,d,f]=r.shape,m=new Float32Array(u*h*p*c),g=n.data.get(r.dataId).values,_=[a&&d>1?h-1:h,a&&f>1?p-1:p],T=[a&&d>1?d-1:d,a&&f>1?f-1:f],y=_[0]/T[0],I=_[1]/T[1],E=1/y,b=1/I,v=2*Math.ceil(E)+2,w=2*Math.ceil(b)+2;for(let t=0;t<u;t++){const e=t*o[0];for(let t=0;t<h;t++){const n=e+t*o[1],i=Math.floor(t*E),s=Math.floor(i-v/2);for(let i=0;i<p;i++){const r=n+i*o[2],u=Math.floor(i*b),_=Math.floor(u-w/2);for(let n=0;n<c;n++){let o=0;for(let r=0;r<v;r++){const u=r+s;if(u<0||u>=d)continue;const c=e+u*l[1],m=u*y;if(t===Math.min(h-1,a?Math.round(m):Math.floor(m)))for(let t=0;t<w;t++){const e=t+_;if(e<0||e>=f)continue;const s=c+e*l[2],r=e*I;i===Math.min(p-1,a?Math.round(r):Math.floor(r))&&(o+=g[s+n])}}m[r+n]=o}}}}return n.makeTensorInfo(s.shape,s.dtype,m)}};const s9={kernelName:DC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{dims:r}=i;I2(s,"reverse");const a=s.shape.length,o=CO(r,s.shape);if(0===a)return A2({inputs:{x:s},backend:n});const l=new bk(s.shape,s.dtype),u=n.bufferSync(s);for(let t=0;t<l.size;t++){const e=l.indexToLoc(t),n=e.slice();o.forEach((t=>n[t]=s.shape[t]-1-n[t])),l.set(u.get(...n),...e)}return n.makeTensorInfo(l.shape,l.dtype,l.values)}},r9={kernelName:SN,backendName:"cpu",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{image:i}=t,{radians:s,fillValue:r,center:a}=e,o=n,l=kO(i.dtype,IO(i.shape)),[u,h,p,c]=i.shape,[d,f]=mG(a,h,p),m=Math.sin(s),g=Math.cos(s),_=o.data.get(i.dataId).values;for(let t=0;t<u;t++){const e=t*p*h*c;for(let t=0;t<h;t++){const n=t*(p*c);for(let i=0;i<p;i++){const s=i*c;for(let a=0;a<c;a++){const o=[u,t,i,a],T=o[2],y=o[1];let I=(T-d)*g-(y-f)*m,E=(T-d)*m+(y-f)*g;I=Math.round(I+d),E=Math.round(E+f);let b=r;if("number"!=typeof r&&(b=3===a?255:r[a]),I>=0&&I<p&&E>=0&&E<h){b=_[e+E*(p*c)+I*c+a]}l[e+n+s+a]=b}}}}return{dataId:o.write(l,i.shape,i.dtype),shape:i.shape,dtype:i.dtype}}},a9=j2(LC,(t=>{const e=Math.floor(t);return t-e<.5?Math.floor(t):t-e>.5?Math.ceil(t):e%2==0?e:e+1})),o9={kernelName:LC,backendName:"cpu",kernelFunc:a9};const l9={kernelName:PC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{indices:s,updates:r}=e,{shape:a}=i,{sliceRank:o,numUpdates:l,sliceSize:u,strides:h,outputSize:p}=hP(0,s,a),c=m4(n.bufferSync(s),n.bufferSync(r),a,p,u,l,o,h,0,!0);return n.makeTensorInfo(a,c.dtype,c.values)}};
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function u9(t,e){let n=0,i=t.length,s=0;for(;n<i;)s=Math.floor((n+i)/2),t[s]<e?n=s+1:i=s;return i}function h9(t,e){let n=0,i=t.length,s=0;for(;n<i;)s=Math.floor((n+i)/2),t[s]<=e?n=s+1:i=s;return i}const p9={kernelName:BC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{sortedSequence:s,values:r}=e,{side:a}=i,o=function(t,e,n,i,s,r){const a=DO("int32",n*s);for(let o=0;o<n;++o){const n=t.slice(o*i,(o+1)*i),l=o*s;for(let t=0;t<s;++t)a[l+t]="left"===r?u9(n,e[t+l]):h9(n,e[t+l])}return a}(n.data.get(s.dataId).values,n.data.get(r.dataId).values,s.shape[0],s.shape[1],r.shape[1],a);return n.makeTensorInfo(r.shape,"int32",o)}};const c9={kernelName:VC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{condition:i,t:s,e:r}=e;I2([i,s,r],"select");const a=i.shape.length,o=n.data.get(i.dataId).values,l=n.data.get(s.dataId).values,u=n.data.get(r.dataId).values,h=Lk(s.dtype,r.dtype),p=QO(IO(s.shape),h);let c=0;const d=0===a||a>1||1===s.shape.length?1:IO(s.shape.slice(1));for(let t=0;t<o.length;t++)for(let e=0;e<d;e++)1===o[t]?p[c++]=l[t]:p[c++]=u[t];return n.makeTensorInfo(s.shape,h,p)}},d9=EG,f9=bG,m9=j2(UC,(t=>t>=0?f9*t:d9*(Math.exp(t)-1))),g9={kernelName:UC,backendName:"cpu",kernelFunc:m9},_9=j2(WC,(t=>t<0?-1:t>0?1:0)),T9={kernelName:WC,backendName:"cpu",kernelFunc:_9},y9=j2(GC,(t=>Math.sin(t))),I9={kernelName:GC,backendName:"cpu",kernelFunc:y9},E9=j2(HC,(t=>Math.sinh(t))),b9={kernelName:HC,backendName:"cpu",kernelFunc:E9},v9=Math.log(1.1920928955078125e-7)+2,w9=j2(XC,(t=>{const e=t>-v9,n=t<v9,i=Math.exp(t);let s;return s=n?i:e?t:Math.log(1+i),s})),S9={kernelName:XC,backendName:"cpu",kernelFunc:w9};const x9={kernelName:KC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{blockShape:r,paddings:a}=i;I2([s],"spaceToBatchND");const o=IO(r),l=[[0,0]];l.push(...a);for(let t=1+r.length;t<s.shape.length;++t)l.push([0,0]);const u=H8.kernelFunc({inputs:{x:s},backend:n,attrs:{paddings:l,constantValue:0}}),h=gG(u.shape,r,o,!1),p=_G(h.length,r.length,!1),c=TG(u.shape,r,o,!1),d=l5({inputs:{x:u},backend:n,attrs:{shape:h}}),f=K3({inputs:{x:d},backend:n,attrs:{perm:p}}),m=l5({inputs:{x:f},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),m}};const R9={kernelName:ZC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{indices:i,values:s,denseShape:r,defaultValue:a}=e;if(1!==r.shape.length)throw new Error(`Dense shape must be a vector, saw:\n ${r.shape}`);if(2!==i.shape.length)throw new Error(`Indices must be a matrix, saw:\n ${i.shape}`);if(1!==s.shape.length)throw new Error(`Values must be a vector, saw:\n ${s.shape}`);if(0!==a.shape.length)throw new Error(`Default value must be a scalar, saw:\n ${a.shape}`);const o=n.data.get(i.dataId).values,l=n.data.get(s.dataId).values,u=n.data.get(r.dataId).values,h=n.data.get(a.dataId).values[0],[p,c,d,f,m]=b4(o,i.shape,i.dtype,l,s.dtype,u,h);return[n.makeTensorInfo(c,i.dtype,p),n.makeTensorInfo([c[0]],s.dtype,d),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map((t=>Number(t))))),n.makeTensorInfo([m.length],i.dtype,new Int32Array(m))]}};const O9={kernelName:tN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{inputIndices:i,inputShape:s,newShape:r}=e;if(2!==i.shape.length)throw new Error(`Input indices should be a matrix but received shape\n ${i.shape}`);if(1!==s.shape.length)throw new Error(`Input shape should be a vector but received shape\n ${s.shape}`);if(1!==r.shape.length)throw new Error(`Target shape should be a vector but received shape ${r.shape}`);const a=Array.from(n.data.get(s.dataId).values),o=n.data.get(i.dataId).values,l=Array.from(n.data.get(r.dataId).values),[u,h,p]=v4(o,i.shape,i.dtype,a,l);return[n.makeTensorInfo(h,i.dtype,u),n.makeTensorInfo([p.length],r.dtype,new Int32Array(p))]}};const A9={kernelName:eN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{data:i,indices:s,segmentIds:r}=e;if(i.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.shape.length)throw new Error(`Indices should be a vector but received shape\n ${s.shape}`);if(1!==r.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${r.shape}`);if(s.shape[0]!==r.shape[0])throw new Error("segmentIds and indices should have same size.");const a=n.data.get(i.dataId).values,o=n.data.get(s.dataId).values,l=n.data.get(r.dataId).values,[u,h]=w4(a,i.shape,i.dtype,o,l,!0);return n.makeTensorInfo(h,i.dtype,u)}};const M9={kernelName:nN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{data:i,indices:s,segmentIds:r}=e;if(i.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.shape.length)throw new Error(`Indices should be a vector but received shape\n ${s.shape}`);if(1!==r.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${r.shape}`);if(s.shape[0]!==r.shape[0])throw new Error("segmentIds and indices should have same size.");const a=n.data.get(i.dataId).values,o=n.data.get(s.dataId).values,l=n.data.get(r.dataId).values,[u,h]=w4(a,i.shape,i.dtype,o,l);return n.makeTensorInfo(h,i.dtype,u)}};const C9={kernelName:iN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{sparseIndices:s,sparseValues:r,defaultValue:a}=e,{outputShape:o}=i,{sliceRank:l,numUpdates:u,sliceSize:h,strides:p,outputSize:c}=hP(0,s,o),d=!1,f=n.bufferSync(s);let m;switch(r.dtype){case"bool":m=m4(f,n.bufferSync(r),o,c,h,u,l,p,Boolean(n.data.get(a.dataId).values[0]),d);break;case"float32":m=m4(f,n.bufferSync(r),o,c,h,u,l,p,n.data.get(a.dataId).values[0],d);break;case"int32":m=m4(f,n.bufferSync(r),o,c,h,u,l,p,n.data.get(a.dataId).values[0],d);break;case"string":m=m4(f,n.bufferSync(r),o,c,h,u,l,p,lk(n.data.get(a.dataId).values[0]),d);break;default:throw new Error(`Unsupported type ${r.dtype}`)}return n.makeTensorInfo(o,m.dtype,m.values)}};const N9={kernelName:QC,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{numOrSizeSplits:r,axis:a}=i,o=CO(a,s.shape)[0],l=XG(s,r,o),u=new Array(s.shape.length).fill(0),h=s.shape.slice();return l.map((t=>{const e=[...h];e[o]=t;const i=I4({inputs:{x:s},backend:n,attrs:{begin:u,size:e}});return u[o]+=t,i}))}},k9={kernelName:rN,backendName:"cpu",kernelFunc:({inputs:t,backend:e})=>{const{x:n}=t,i=e;I2(n,"square");const s=i.data.get(n.dataId).values,r=new Float32Array(s.length);for(let t=0;t<s.length;++t){const e=s[t];r[t]=e*e}return{dataId:i.write(r,n.shape,n.dtype),shape:n.shape,dtype:n.dtype}}},D9=j2(vN,((t,e)=>{const n=e;return isNaN(t)?NaN:t>0?1:n.alpha})),L9={kernelName:vN,backendName:"cpu",kernelFunc:D9};const F9={kernelName:oN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{begin:r,end:a,strides:o,beginMask:l,endMask:u,ellipsisMask:h,newAxisMask:p,shrinkAxisMask:c}=i;I2(s,"stridedSlice");const{finalShapeSparse:d,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:_,begin:T,end:y,strides:I}=OP(s.shape,r,a,o,l,u,h,p,c);let E;if(m)E=l5({inputs:{x:s},backend:n,attrs:{shape:f}});else if(g||_){_O(s.shape.length>=1,(()=>`Input must have rank at least 1, got: ${s.shape.length}`));const t=mP(T,y,I),e=I4({inputs:{x:s},backend:n,attrs:{begin:T,size:t}});E=l5({inputs:{x:e},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(e)}else{const t=D4(d,n.bufferSync(s),I,T);E=n.makeTensorInfo(f,t.dtype,t.values)}return E}};const P9={kernelName:lN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{separator:s,nGramWidths:r,leftPad:a,rightPad:o,padWidth:l,preserveShortSequences:u}=i,{data:h,dataSplits:p}=e,c=n.data.get(h.dataId).values,d=n.data.get(p.dataId).values,[f,m]=F4(c,d,s,r,a,o,l,u);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}};const $9={kernelName:uN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{skipEmpty:s}=i,{input:r,delimiter:a}=e;if("string"!==r.dtype)throw new Error("Input must be of datatype string");if(1!==r.shape.length)throw new Error(`Input must be a vector, got shape: ${r.shape}`);if(0!==a.shape.length)throw new Error(`Delimiter must be a scalar, got shape: ${a.shape}`);const o=n.data.get(r.dataId).values,l=n.data.get(a.dataId).values[0],[u,h,p]=$4(o,l,s),c=h.length;return[n.makeTensorInfo([c,2],"int32",u),n.makeTensorInfo([c],"string",h),n.makeTensorInfo([2],"int32",new Int32Array(p))]}};const B9={kernelName:hN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{numBuckets:s}=i,{input:r}=e;if("string"!==r.dtype)throw new Error("Input must be of datatype string");if(s<=0)throw new Error("Number of buckets must be at least 1");const a=B4(n.data.get(r.dataId).values,s);return n.makeTensorInfo(r.shape,"int32",a)}},V9=j2(cN,(t=>Math.tan(t))),U9={kernelName:cN,backendName:"cpu",kernelFunc:V9},Y9=j2(dN,(t=>Math.tanh(t)));const G9={kernelName:$C,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{tensor:i,indices:s,updates:r}=e,{sliceRank:a,numUpdates:o,sliceSize:l,strides:u,outputSize:h}=hP(0,s,i.shape),p=n.bufferSync(s),c=n.bufferSync(r),d=n.bufferSync(i),f=m4(p,c,i.shape,h,l,o,a,u,d,!1);return n.makeTensorInfo(i.shape,f.dtype,f.values)}};const H9={kernelName:fN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{reps:r}=i;I2(s,"tile");const a=H4(n.bufferSync(s),r);return n.makeTensorInfo(a.shape,a.dtype,a.values)}};const W9={kernelName:mN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{k:r,sorted:a}=i;I2(s,"topk");const o=n.data.get(s.dataId).values,[l,u]=X4(o,s.shape,s.dtype,r,a);return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(u.shape,u.dtype,u.values)]}};const z9={kernelName:gN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,attrs:n,backend:i}=t,{image:s,transforms:r}=e,{interpolation:a,fillMode:o,fillValue:l,outputShape:u}=n,[h,p,c,d]=s.shape,[f,m]=null!=u?u:[p,c],g=[h,f,m,d],_=zO(s.shape),T=_[0],y=_[1],I=_[2],E=zO(g),b=E[0],v=E[1],w=E[2],S=kO(s.dtype,IO(g));S.fill(l);const x=i.data.get(s.dataId).values,R=i.data.get(r.dataId).values;for(let t=0;t<h;++t){const e=1===r.shape[0]?R:R.subarray(8*t,8*t+8);for(let n=0;n<f;++n)for(let i=0;i<m;++i)for(let s=0;s<d;++s){let r;const u=e[6]*i+e[7]*n+1;if(0===u)continue;const h=(e[0]*i+e[1]*n+e[2])/u,d=(e[3]*i+e[4]*n+e[5])/u,f=X9(h,c,o),m=X9(d,p,o);switch(a){case"nearest":r=q9(x,p,c,T,y,I,t,m,f,s,l);break;case"bilinear":r=K9(x,p,c,T,y,I,t,m,f,s,l);break;default:throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${a}`)}S[t*b+n*v+i*w+s]=r}return i.makeTensorInfo(g,s.dtype,S)}return{dataId:i.write(S,g,s.dtype),shape:s.shape,dtype:s.dtype}}};function X9(t,e,n){switch(n){case"reflect":return function(t,e){let n=t;if(n<0)if(e<=1)n=0;else{const t=2*e;n<t&&(n=t*Math.trunc(-n/t)+n),n=n<-e?n+t:-n-1}else if(n>e-1)if(e<=1)n=0;else{const t=2*e;n-=t*Math.trunc(n/t),n>=e&&(n=t-n-1)}return pO(0,n,e-1)}(t,e);case"wrap":return function(t,e){let n=t;if(n<0)if(e<=1)n=0;else{const t=e-1;n+=e*(Math.trunc(-n/t)+1)}else if(n>e-1)if(e<=1)n=0;else{const t=e-1;n-=e*Math.trunc(n/t)}return pO(0,n,e-1)}(t,e);case"nearest":return function(t,e){return pO(0,t,e-1)}(t,e);default:return function(t){return t}(t)}}function j9(t,e,n,i,s,r,a,o,l,u,h){return 0<=o&&o<e&&0<=l&&l<n?t[a*i+o*s+l*r+u]:h}function q9(t,e,n,i,s,r,a,o,l,u,h){return j9(t,e,n,i,s,r,a,Math.round(o),Math.round(l),u,h)}function K9(t,e,n,i,s,r,a,o,l,u,h){const p=Math.floor(o),c=Math.floor(l),d=p+1,f=c+1;return(d-o)*((f-l)*j9(t,e,n,i,s,r,a,p,c,u,h)+(l-c)*j9(t,e,n,i,s,r,a,p,f,u,h))+(o-p)*((f-l)*j9(t,e,n,i,s,r,a,d,c,u,h)+(l-c)*j9(t,e,n,i,s,r,a,d,f,u,h))}const Q9={kernelName:TN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,attrs:n,backend:i}=t,{axis:s}=n,{x:r}=e;I2(r,"unique");const a=i.data.get(r.dataId).values,{outputValues:o,outputShape:l,indices:u}=j4(a,s,r.shape,r.dtype);return[i.makeTensorInfo(l,r.dtype,o),i.makeTensorInfo([u.length],"int32",u)]}};const J9={kernelName:yN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{value:s}=e;let{axis:r}=i;r<0&&(r+=s.shape.length);const a=s.shape.length,o=s.shape[r],l=new Array(a-1);let u=0;for(let t=0;t<a;t++)t!==r&&(l[u++]=s.shape[t]);const h=new Array(a).fill(0),p=s.shape.slice();p[r]=1;const c=new Array(o);for(let t=0;t<c.length;t++){h[r]=t;const e=I4({inputs:{x:s},backend:n,attrs:{begin:h,size:p}});c[t]=l5({inputs:{x:e},backend:n,attrs:{shape:l}}),n.disposeIntermediateTensorInfo(e)}return c}};const Z9={kernelName:IN,backendName:"cpu",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,segmentIds:r}=e,{numSegments:a}=i;I2(s,"unsortedSegmentSum");const o=[],l=[],u=s.shape.length-r.shape.length;let h=r;for(let t=0;t<u;++t){const e=D6({inputs:{input:h},backend:n,attrs:{dim:t+1}});h=e,l.push(e)}for(let t=0;t<a;++t){const e=ik(t,"int32"),i=n.makeTensorInfo([],"int32",e),r=e3({inputs:{a:i,b:h},backend:n}),a=D2({inputs:{x:r},backend:n,attrs:{dtype:"float32"}}),u=Y3({inputs:{a,b:s},backend:n}),p=b6({inputs:{x:u},backend:n,attrs:{axis:0,keepDims:!1}});o.push(p),l.push(i),l.push(r),l.push(a),l.push(u),l.push(p)}const p=Y8({inputs:o,backend:n,attrs:{axis:0}});return l.forEach((t=>n.disposeIntermediateTensorInfo(t))),p}},t7=[c5,w2,f5,g5,U2,_5,T5,y5,I5,E5,v5,S5,R5,M5,N5,F5,P5,$5,B5,p5,V5,U5,Y5,z2,G5,L2,J2,W5,R2,z5,K5,J5,Z5,t6,e6,n6,i6,r6,o6,l6,u6,h6,p6,c6,f6,m6,g6,_6,T6,y6,I6,E6,w6,Q4,S6,n3,k6,r3,L6,l3,Y6,H6,W6,p3,f3,z6,X6,j6,q6,y3,b3,M2,K6,j5,J6,t8,n8,Z4,S3,O3,i8,N3,r8,l8,h8,d8,f8,m8,_8,F3,T8,y8,I8,E8,b8,v8,w8,B3,S8,O8,C8,G3,W3,k8,L8,P8,j3,$8,U8,G8,H8,X8,n5,Z3,j8,q8,K8,Q8,N2,$6,Z8,s5,a5,u5,t9,e9,n9,i9,s9,r9,o9,f4,l9,p9,c9,g9,T4,T9,I9,b9,E4,M8,S9,x9,R9,O9,A9,M9,C9,N9,R4,k9,M4,k4,L9,F9,P9,$9,B9,G4,v6,U9,{kernelName:dN,backendName:"cpu",kernelFunc:Y9},G9,H9,W9,z9,Q3,Q9,J9,Z9,V8];for(const t of t7)FN(t);
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const e7={},n7={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function i7(t,e){e7[t]=e}function s7(t,e){if(!(t in e7)||null!=e){const n=function(t,e){if(1!==t&&2!==t)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=null==e?function(t){if(aA().getBool("IS_SAFARI")||"undefined"==typeof OffscreenCanvas||2!==t){if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}return new OffscreenCanvas(300,150)}(t):e;n.addEventListener("webglcontextlost",(e=>{e.preventDefault(),delete e7[t]}),!1),aA().getBool("SOFTWARE_WEBGL_ENABLED")&&(n7.failIfMajorPerformanceCaveat=!1);if(1===t)return n.getContext("webgl",n7)||n.getContext("experimental-webgl",n7);return n.getContext("webgl2",n7)}(t,e);if(null===n)return console.log("Could not get context for WebGL version",t),null;e7[t]=n}const n=e7[t];return null==n||n.isContextLost()?(delete e7[t],s7(t)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),e7[t])}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
var r7,a7,o7;function l7(t,e){return[e,t]}function u7(t){const e=IO(t);return xO(Math.ceil(e/4))}function h7(t,e){return[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(t/2))]}function p7(t,e){const n=t;let i,s,r,a,o,l,u,h,p,c;return 2===aA().getNumber("WEBGL_VERSION")?(i=n.R32F,s=n.R16F,r=n.RGBA16F,a=n.RGBA32F,o=n.RED,u=4,h=1,p=n.HALF_FLOAT,c=n.FLOAT,l=n.RGBA8):(i=t.RGBA,s=t.RGBA,r=t.RGBA,a=n.RGBA,o=t.RGBA,u=4,h=4,p=null!=e?e.HALF_FLOAT_OES:null,c=t.FLOAT,l=t.RGBA),{internalFormatFloat:i,internalFormatHalfFloat:s,internalFormatPackedHalfFloat:r,internalFormatPackedFloat:a,textureFormatFloat:o,downloadTextureFormat:l,downloadUnpackNumChannels:u,defaultNumChannels:h,textureTypeHalfFloat:p,textureTypeFloat:c}}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function c7(t,e){const n=e();return aA().getBool("DEBUG")&&function(t){const e=t.getError();if(e!==t.NO_ERROR)throw new Error("WebGL Error: "+g7(t,e))}(t),n}!function(t){t[t.DENSE=0]="DENSE",t[t.SHARED_BATCH=1]="SHARED_BATCH"}(r7||(r7={})),function(t){t[t.RENDER=0]="RENDER",t[t.UPLOAD=1]="UPLOAD",t[t.PIXELS=2]="PIXELS",t[t.DOWNLOAD=3]="DOWNLOAD"}(a7||(a7={})),function(t){t[t.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",t[t.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",t[t.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",t[t.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",t[t.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(o7||(o7={}));const d7=5.96e-8,f7=65504;function m7(t){return!!(aA().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===t||d7<Math.abs(t)&&Math.abs(t)<f7)}function g7(t,e){switch(e){case t.NO_ERROR:return"NO_ERROR";case t.INVALID_ENUM:return"INVALID_ENUM";case t.INVALID_VALUE:return"INVALID_VALUE";case t.INVALID_OPERATION:return"INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${e}`}}function _7(t,e){return Y7(t,(()=>t.getExtension(e)),'Extension "'+e+'" not supported on this browser.')}function T7(t,e){const n=Y7(t,(()=>t.createShader(t.VERTEX_SHADER)),"Unable to create vertex WebGLShader.");if(c7(t,(()=>t.shaderSource(n,e))),c7(t,(()=>t.compileShader(n))),!1===t.getShaderParameter(n,t.COMPILE_STATUS))throw console.log(t.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}function y7(t,e){const n=Y7(t,(()=>t.createShader(t.FRAGMENT_SHADER)),"Unable to create fragment WebGLShader.");if(c7(t,(()=>t.shaderSource(n,e))),c7(t,(()=>t.compileShader(n))),aA().get("ENGINE_COMPILE_ONLY"))return n;if(!1===t.getShaderParameter(n,t.COMPILE_STATUS))throw E7(e,t.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}const I7=/ERROR: [0-9]+:([0-9]+):/g;function E7(t,e){const n=I7.exec(e);if(null==n)return console.log(`Couldn't parse line number in error: ${e}`),void console.log(t);const i=+n[1],s=t.split("\n"),r=s.length.toString().length+2,a=s.map(((t,e)=>OO((e+1).toString(),r)+t));let o=0;for(let t=0;t<a.length;t++)o=Math.max(a[t].length,o);const l=a.slice(0,i-1),u=a.slice(i-1,i),h=a.slice(i);console.log(l.join("\n")),console.log(e.split("\n")[0]),console.log(`%c ${OO(u[0],o)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(h.join("\n"))}function b7(t){return Y7(t,(()=>t.createProgram()),"Unable to create WebGLProgram.")}function v7(t,e){if(c7(t,(()=>t.linkProgram(e))),!aA().get("ENGINE_COMPILE_ONLY")&&!1===t.getProgramParameter(e,t.LINK_STATUS))throw console.log(t.getProgramInfoLog(e)),new Error("Failed to link vertex and fragment shaders.")}function w7(t,e){if(c7(t,(()=>t.validateProgram(e))),!1===t.getProgramParameter(e,t.VALIDATE_STATUS))throw console.log(t.getProgramInfoLog(e)),new Error("Shader program validation failed.")}function S7(t,e){const n=Y7(t,(()=>t.createBuffer()),"Unable to create WebGLBuffer");return c7(t,(()=>t.bindBuffer(t.ARRAY_BUFFER,n))),c7(t,(()=>t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW))),n}function x7(t,e){const n=Y7(t,(()=>t.createBuffer()),"Unable to create WebGLBuffer");return c7(t,(()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n))),c7(t,(()=>t.bufferData(t.ELEMENT_ARRAY_BUFFER,e,t.STATIC_DRAW))),n}function R7(){return 2===aA().getNumber("WEBGL_VERSION")?1:4}function O7(t){return Y7(t,(()=>t.createTexture()),"Unable to create WebGLTexture.")}function A7(t,e){const n=aA().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t<=0||e<=0){throw new Error("Requested texture size "+`[${t}x${e}]`+" is invalid.")}if(t>n||e>n){throw new Error("Requested texture size "+`[${t}x${e}]`+" greater than WebGL maximum on this browser / GPU "+`[${n}x${n}]`+".")}}function M7(t){return Y7(t,(()=>t.createFramebuffer()),"Unable to create WebGLFramebuffer.")}function C7(t,e,n,i,s,r,a){const o=t.getAttribLocation(e,n);return-1!==o&&(c7(t,(()=>t.bindBuffer(t.ARRAY_BUFFER,i))),c7(t,(()=>t.vertexAttribPointer(o,s,t.FLOAT,!1,r,a))),c7(t,(()=>t.enableVertexAttribArray(o))),!0)}function N7(t,e,n){G7(t,n),c7(t,(()=>t.activeTexture(t.TEXTURE0+n))),c7(t,(()=>t.bindTexture(t.TEXTURE_2D,e)))}function k7(t,e){G7(t,e),c7(t,(()=>t.activeTexture(t.TEXTURE0+e))),c7(t,(()=>t.bindTexture(t.TEXTURE_2D,null)))}function D7(t,e,n){return Y7(t,(()=>t.getUniformLocation(e,n)),'uniform "'+n+'" not present in program.')}function L7(t,e,n){return t.getUniformLocation(e,n)}function F7(t,e,n,i){c7(t,(()=>N7(t,e,i))),c7(t,(()=>t.uniform1i(n,i)))}function P7(t){c7(t,(()=>t.bindFramebuffer(t.FRAMEBUFFER,null))),c7(t,(()=>t.viewport(0,0,t.canvas.width,t.canvas.height))),c7(t,(()=>t.scissor(0,0,t.canvas.width,t.canvas.height)))}function $7(t,e,n){c7(t,(()=>t.bindFramebuffer(t.FRAMEBUFFER,n))),c7(t,(()=>t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)))}function B7(t,e){c7(t,(()=>t.bindFramebuffer(t.FRAMEBUFFER,e))),c7(t,(()=>t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,null,0)))}function V7(t){const e=t.checkFramebufferStatus(t.FRAMEBUFFER);if(e!==t.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+U7(t,e))}function U7(t,e){switch(e){case t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case t.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${e}`}}function Y7(t,e,n){const i=c7(t,(()=>e()));if(null==i)throw new Error(n);return i}function G7(t,e){const n=t.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,i=e+t.TEXTURE0;if(i<t.TEXTURE0||i>n){throw new Error(`textureUnit must be in ${`[gl.TEXTURE0, gl.TEXTURE${n}]`}.`)}}function H7(t,e=2){return IO(t.slice(0,t.length-e))}function W7(t){if(0===t.length)throw Error("Cannot get rows and columns of an empty shape array.");return[t.length>1?t[t.length-2]:1,t[t.length-1]]}function z7(t){let e=[1,1,1];return 0===t.length||1===t.length&&1===t[0]||(e=[H7(t),...W7(t)]),e}function X7(t,e=!1){let n=aA().getNumber("WEBGL_MAX_TEXTURE_SIZE"),i=aA().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");if(i===1/0&&aA().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(i=n/2),e&&(n*=2,i*=2,1===(t=t.map(((e,n)=>n>=t.length-2?cO(t[n]):t[n]))).length&&(t=[2,t[0]])),2!==t.length){const e=NO(t);t=e.newShape}let s=IO(t),r=null;t.length<=1&&s<=n?r=[1,s]:2===t.length&&t[0]<=n&&t[1]<=n?r=t:3===t.length&&t[0]*t[1]<=n&&t[2]<=n?r=[t[0]*t[1],t[2]]:3===t.length&&t[0]<=n&&t[1]*t[2]<=n?r=[t[0],t[1]*t[2]]:4===t.length&&t[0]*t[1]*t[2]<=n&&t[3]<=n?r=[t[0]*t[1]*t[2],t[3]]:4===t.length&&t[0]<=n&&t[1]*t[2]*t[3]<=n&&(r=[t[0],t[1]*t[2]*t[3]]);const a=null!=r&&Math.max(...r)>i&&Math.min(...r)<=(e?2:1)&&Math.min(...r)>0;if(null==r||a)if(e){const e=H7(t);let n=2,i=2;t.length&&([n,i]=W7(t)),s=e*(n/2)*(i/2),r=xO(s).map((t=>2*t))}else r=xO(s);return r}function j7(t){return t%2==0}function q7(t,e){if(vO(t=t.slice(-2),e=e.slice(-2)))return!0;if(!t.length||!e.length)return!0;if(0===t[0]||0===t[1]||0===e[0]||0===e[1])return!0;if(t.length!==e.length){const n=t[t.length-1],i=e[e.length-1];if(n===i)return!0;if(j7(n)&&j7(i)&&(1===t[0]||1===e[0]))return!0}return t[1]===e[1]&&j7(t[0])&&j7(e[0])}let K7,Q7;function J7(t){if(null==K7){const e=s7(t);K7=e.getParameter(e.MAX_TEXTURE_SIZE)}return K7}function Z7(){K7=null}function ttt(){Q7=null}function ett(t){if(null==Q7){const e=s7(t);Q7=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Q7)}function ntt(t){if(0===t)return 0;let e;const n=s7(t);return e=itt(n,"EXT_disjoint_timer_query_webgl2")&&2===t?2:itt(n,"EXT_disjoint_timer_query")?1:0,e}function itt(t,e){return null!=t.getExtension(e)}function stt(t){try{if(null!=s7(t))return!0}catch(t){return console.log("Error when getting WebGL context: ",t),!1}return!1}function rtt(t){if(0===t)return!1;const e=s7(t);if(1===t){if(!itt(e,"OES_texture_float"))return!1}else if(!itt(e,"EXT_color_buffer_float"))return!1;return ott(e)}function att(t){if(0===t)return!1;const e=s7(t);if(1!==t){if(itt(e,"EXT_color_buffer_float"))return ott(e);const t="EXT_color_buffer_half_float";if(itt(e,t)){const n=e.getExtension(t);return function(t,e){const n=p7(t,e),i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const s=1,r=1;t.texImage2D(t.TEXTURE_2D,0,n.internalFormatHalfFloat,s,r,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const a=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,a),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0);const o=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(i),t.deleteFramebuffer(a),o}(e,n)}return!1}if(!itt(e,"OES_texture_float"))return!1;if(!itt(e,"WEBGL_color_buffer_float"))return!1;return ott(e)}function ott(t){const e=p7(t),n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n);t.texImage2D(t.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);const i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);const s=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(n),t.deleteFramebuffer(i),s}function ltt(t){if(2!==t)return!1;return null!=s7(t).fenceSync}function utt(t,e){Array.isArray(t)||(t=[t]),t.forEach((t=>{null!=t&&_O("complex64"!==t.dtype,(()=>`${e} does not support complex64 tensors in the WebGL backend.`))}))}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const htt=aA();
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function ptt(){let t,e,n,i,s,r,a,o,l,u;return 2===aA().getNumber("WEBGL_VERSION")?(t="#version 300 es",e="in",n="out",i="in",s="texture",r="outputColor",a="out vec4 outputColor;",o=aA().getBool("WEBGL2_ISNAN_CUSTOM")?"\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n ":"",l="",u="\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "):(t="",e="attribute",n="varying",i="varying",s="texture2D",r="gl_FragColor",a="",o="\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ",l="\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ",u="\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "),{version:t,attribute:e,varyingVs:n,varyingFs:i,texture2D:s,output:r,defineOutput:a,defineSpecialNaN:o,defineSpecialInf:l,defineRound:u}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function ctt(t,e,n="index"){const i=zO(e);return i.map(((e,s)=>`${`int ${t[s]} = ${n} / ${e}`}; ${s===i.length-1?`int ${t[s+1]} = ${n} - ${t[s]} * ${e}`:`index -= ${t[s]} * ${e}`};`)).join("")}function dtt(t,e,n="index"){const i=zO(e);return i.map(((e,s)=>`${`int ${t[s]} = ${n} / outShapeStrides[${s}]`}; ${s===i.length-1?`int ${t[s+1]} = ${n} - ${t[s]} * outShapeStrides[${s}]`:`index -= ${t[s]} * outShapeStrides[${s}]`};`)).join("")}function ftt(t,e,n="index"){const i=function(t,e){const n=t.length,i=t.map((t=>`${e}[${t}]`)),s=new Array(n-1);s[n-2]=i[n-1];for(let t=n-3;t>=0;--t)s[t]=`(${s[t+1]} * ${i[t+1]})`;return s}(t.map(((t,e)=>e)),e);return i.map(((e,s)=>`${`int ${t[s]} = ${n} / ${i[s]}`}; ${s===i.length-1?`int ${t[s+1]} = ${n} - ${t[s]} * ${i[s]}`:`index -= ${t[s]} * ${i[s]}`};`)).join("")}function mtt(t){const e=zO(t).map((t=>t.toString()));return`\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${e[0]} + coords.y * ${e[1]} + coords.z;\n }\n`}htt.registerFlag("HAS_WEBGL",(()=>htt.getNumber("WEBGL_VERSION")>0)),htt.registerFlag("WEBGL_VERSION",(()=>stt(2)?2:stt(1)?1:0)),htt.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(()=>!1)),htt.registerFlag("WEBGL_BUFFER_SUPPORTED",(()=>2===htt.get("WEBGL_VERSION"))),htt.registerFlag("WEBGL_CPU_FORWARD",(()=>!0)),htt.registerFlag("WEBGL_FORCE_F16_TEXTURES",(()=>!1)),htt.registerFlag("WEBGL_PACK",(()=>htt.getBool("HAS_WEBGL"))),htt.registerFlag("WEBGL_PACK_NORMALIZATION",(()=>htt.getBool("WEBGL_PACK"))),htt.registerFlag("WEBGL_PACK_CLIP",(()=>htt.getBool("WEBGL_PACK"))),htt.registerFlag("WEBGL_PACK_DEPTHWISECONV",(()=>htt.getBool("WEBGL_PACK"))),htt.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(()=>htt.getBool("WEBGL_PACK"))),htt.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(()=>htt.getBool("WEBGL_PACK"))),htt.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(()=>htt.getBool("WEBGL_PACK"))),htt.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(()=>htt.getBool("WEBGL_PACK"))),htt.registerFlag("WEBGL_PACK_REDUCE",(()=>htt.getBool("WEBGL_PACK"))),htt.registerFlag("WEBGL_LAZILY_UNPACK",(()=>htt.getBool("WEBGL_PACK"))),htt.registerFlag("WEBGL_CONV_IM2COL",(()=>htt.getBool("WEBGL_PACK"))),htt.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE",(()=>htt.getBool("WEBGL_PACK"))),htt.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(()=>J7(htt.getNumber("WEBGL_VERSION")))),htt.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(()=>ett(htt.getNumber("WEBGL_VERSION")))),htt.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(()=>{const t=htt.getNumber("WEBGL_VERSION");return 0===t?0:ntt(t)})),htt.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(()=>htt.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Jk())),htt.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(()=>rtt(htt.getNumber("WEBGL_VERSION")))),htt.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(()=>!htt.getBool("WEBGL_FORCE_F16_TEXTURES")&&htt.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))),htt.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(()=>att(htt.getNumber("WEBGL_VERSION")))),htt.registerFlag("WEBGL_FENCE_API_ENABLED",(()=>ltt(htt.getNumber("WEBGL_VERSION")))),htt.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(()=>htt.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0)),htt.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(()=>-1),(t=>{if("number"!=typeof t)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${t}.`);if(t<0&&-1!==t)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${t}.`)})),htt.registerFlag("WEBGL_FLUSH_THRESHOLD",(()=>Jk()?1:-1),(t=>{if("number"!=typeof t)throw new Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${t}.`);if(t<0&&-1!==t)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${t}.`)})),htt.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",(()=>128)),htt.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",(()=>!1)),htt.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",(()=>1e5)),htt.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",(()=>128)),htt.registerFlag("WEBGL_EXP_CONV",(()=>!1)),htt.registerFlag("SOFTWARE_WEBGL_ENABLED",(()=>htt.getBool("IS_TEST"))),htt.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",(()=>1/0)),htt.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",(()=>!1)),htt.registerFlag("WEBGL2_ISNAN_CUSTOM",(()=>!1)),htt.registerFlag("ENGINE_COMPILE_ONLY",(()=>!1));const gtt="\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n",{getBroadcastDims:_tt}=yt;function Ttt(t,e,n){const i=[];if(t.forEach((t=>{const e=IO(t.shapeInfo.logicalShape);if(t.shapeInfo.isUniform?i.push(`uniform float ${t.name}${e>1?`[${e}]`:""};`):(i.push(`uniform sampler2D ${t.name};`),i.push(`uniform int offset${t.name};`)),n.enableShapeUniforms){const{uniformShape:e}=Att(n.packedInputs,t.shapeInfo.logicalShape,t.shapeInfo.texShape);switch(e.length){case 1:i.push(`uniform int ${t.name}Shape;`);break;case 2:i.push(`uniform ivec2 ${t.name}Shape;`);break;case 3:i.push(`uniform ivec3 ${t.name}Shape;`);break;case 4:i.push(`uniform ivec4 ${t.name}Shape;`)}i.push(`uniform ivec2 ${t.name}TexShape;`)}})),n.enableShapeUniforms){switch(e.logicalShape.length){case 1:i.push("uniform int outShape;");break;case 2:i.push("uniform ivec2 outShape;"),i.push("uniform int outShapeStrides;");break;case 3:i.push("uniform ivec3 outShape;"),i.push("uniform ivec2 outShapeStrides;");break;case 4:i.push("uniform ivec4 outShape;"),i.push("uniform ivec3 outShapeStrides;")}i.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach((t=>{i.push(`uniform ${t.type} ${t.name}${t.arrayIndex?`[${t.arrayIndex}]`:""};`)}));const s=i.join("\n"),r=t.map((t=>function(t,e,n=!1,i){let s="";s+=n?Itt(t,i):ytt(t,i);const r=t.shapeInfo.logicalShape,a=e.logicalShape;r.length<=a.length&&(s+=n?function(t,e){const n=t.name,i=n.charAt(0).toUpperCase()+n.slice(1),s="get"+i+"AtOutCoords",r=t.shapeInfo.logicalShape.length,a=e.logicalShape.length,o=_tt(t.shapeInfo.logicalShape,e.logicalShape),l=Ott(a),u=a-r;let h;const p=["x","y","z","w","u","v"];h=0===r?"":a<2&&o.length>=1?"coords = 0;":o.map((t=>`coords.${p[t+u]} = 0;`)).join("\n");let c="";c=a<2&&r>0?"coords":t.shapeInfo.logicalShape.map(((t,e)=>`coords.${p[e+u]}`)).join(", ");let d="return outputValue;";const f=1===IO(t.shapeInfo.logicalShape),m=IO(e.logicalShape),g=1===m;if(1!==r||f||g){if(f&&!g)d=1===a?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(o.length){const t=r-2,e=r-1;o.indexOf(t)>-1&&o.indexOf(e)>-1?d="return vec4(outputValue.x);":o.indexOf(t)>-1?d="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":o.indexOf(e)>-1&&(d="return vec4(outputValue.xx, outputValue.zz);")}}else d="\n return vec4(outputValue.xy, outputValue.xy);\n ";return`\n vec4 ${s}() {\n ${l} coords = getOutputCoords();\n ${h}\n vec4 outputValue = get${i}(${c});\n ${d}\n }\n `}(t,e):function(t,e){const n=t.name,i=n.charAt(0).toUpperCase()+n.slice(1),s="get"+i+"AtOutCoords",r=e.texShape,a=t.shapeInfo.texShape,o=t.shapeInfo.logicalShape.length,l=e.logicalShape.length;if(!t.shapeInfo.isUniform&&o===l&&null==t.shapeInfo.flatOffset&&vO(a,r))return`\n float ${s}() {\n return sampleTexture(${n}, resultUV);\n }\n `;const u=Ott(l),h=_tt(t.shapeInfo.logicalShape,e.logicalShape),p=l-o;let c;const d=["x","y","z","w","u","v"];c=0===o?"":l<2&&h.length>=1?"coords = 0;":h.map((t=>`coords.${d[t+p]} = 0;`)).join("\n");let f="";f=l<2&&o>0?"coords":t.shapeInfo.logicalShape.map(((t,e)=>`coords.${d[e+p]}`)).join(", ");return`\n float ${s}() {\n ${u} coords = getOutputCoords();\n ${c}\n return get${i}(${f});\n }\n `}(t,e));return s}(t,e,n.packedInputs,n.enableShapeUniforms))).join("\n"),a=e.texShape,o=ptt(),l=function(t){return`\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${t.texture2D}(textureSampler, uv).r;\n }\n `}(o);let u,h,p=function(t){const e=`${t.version}\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ${t.varyingFs} vec2 resultUV;\n ${t.defineOutput}\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n ${t.defineSpecialNaN}\n ${t.defineSpecialInf}\n ${t.defineRound}\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n ${Ett}\n ${btt}\n ${vtt}\n `;return e}(o);e.isPacked?(u=function(t,e,n){switch(t.length){case 0:return Stt();case 1:return function(t,e,n){const i=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(1===i[0])return n?"\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.x * ${i[1]}.0);\n }\n `;if(1===i[1])return n?"\n int getOutputCoords() {\n return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.y * ${i[0]}.0);\n }\n `;if(n)return"\n int getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);\n }\n ";return`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${i[0]}, ${i[1]}));\n return 2 * (resTexRC.x * ${i[1]} + resTexRC.y);\n }\n `}(0,e,n);case 2:return function(t,e,n){const i=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(vO(t,e))return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2(${i[0]}, ${i[1]}));\n }\n `;const s=Math.ceil(t[1]/2);if(n)return"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n ";return`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${i[0]}, ${i[1]}));\n\n int index = resTexRC.x * ${i[1]} + resTexRC.y;\n int r = 2 * (index / ${s});\n int c = imod(index, ${s}) * 2;\n\n return ivec2(r, c);\n }\n `}(t,e,n);case 3:return function(t,e,n){if(n)return"\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n ";const i=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],s=Math.ceil(t[2]/2),r=s*Math.ceil(t[1]/2);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${i[0]}, ${i[1]}));\n int index = resTexRC.x * ${i[1]} + resTexRC.y;\n\n int b = index / ${r};\n index -= b * ${r};\n\n int r = 2 * (index / ${s});\n int c = imod(index, ${s}) * 2;\n\n return ivec3(b, r, c);\n }\n `}(t,e,n);default:return function(t,e,n){if(n)return"\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n ";const i=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],s=Math.ceil(t[t.length-1]/2),r=s*Math.ceil(t[t.length-2]/2);let a=r,o="",l="b, r, c";for(let e=2;e<t.length-1;e++)a*=t[t.length-e-1],o=`\n int b${e} = index / ${a};\n index -= b${e} * ${a};\n `+o,l=`b${e}, `+l;return`\n ivec${t.length} getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${i[0]}, ${i[1]}));\n int index = resTexRC.x * ${i[1]} + resTexRC.y;\n\n ${o}\n\n int b = index / ${r};\n index -= b * ${r};\n\n int r = 2 * (index / ${s});\n int c = imod(index, ${s}) * 2;\n\n return ivec${t.length}(${l});\n }\n `}(t,e,n)}}(e.logicalShape,a,n.enableShapeUniforms),h=function(t){return`\n void setOutput(vec4 val) {\n ${t.output} = val;\n }\n `}(o)):(u=function(t,e,n){switch(t.length){case 0:return Stt();case 1:return function(t,e,n){if(1===e[0])return n?"\n int getOutputCoords() {\n return int(resultUV.x * float(outTexShape[1]));\n }\n ":`\n int getOutputCoords() {\n return int(resultUV.x * ${e[1]}.0);\n }\n `;if(1===e[1])return n?"\n int getOutputCoords() {\n return int(resultUV.y * float(outTexShape[0]));\n }\n ":`\n int getOutputCoords() {\n return int(resultUV.y * ${e[0]}.0);\n }\n `;if(n)return"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n return resTexRC.x * outTexShape[1] + resTexRC.y;\n }\n ";return`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${e[0]}, ${e[1]}));\n return resTexRC.x * ${e[1]} + resTexRC.y;\n }\n `}(0,e,n);case 2:return function(t,e,n){if(vO(t,e))return n?"\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(${e[0]}, ${e[1]}));\n }\n `;if(1===t[1])return n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(index, 0);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${e[0]}, ${e[1]}));\n int index = resTexRC.x * ${e[1]} + resTexRC.y;\n return ivec2(index, 0);\n }\n `;if(1===t[0])return n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(0, index);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${e[0]}, ${e[1]}));\n int index = resTexRC.x * ${e[1]} + resTexRC.y;\n return ivec2(0, index);\n }\n `;if(n)return"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n int r = index / outShape[1];\n int c = index - r * outShape[1];\n return ivec2(r, c);\n }\n ";return`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${e[0]}, ${e[1]}));\n int index = resTexRC.x * ${e[1]} + resTexRC.y;\n int r = index / ${t[1]};\n int c = index - r * ${t[1]};\n return ivec2(r, c);\n }\n `}(t,e,n);case 3:return function(t,e,n){if(n){return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${dtt(["r","c","d"],t)}\n return ivec3(r, c, d);\n }\n`}const i=ctt(["r","c","d"],t);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${e[0]}, ${e[1]}));\n int index = resTexRC.x * ${e[1]} + resTexRC.y;\n ${i}\n return ivec3(r, c, d);\n }\n `}(t,e,n);case 4:return function(t,e,n){if(n){return`\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${dtt(["r","c","d","d2"],t)}\n return ivec4(r, c, d, d2);\n }\n `}const i=ctt(["r","c","d","d2"],t);return`\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${e[0]}, ${e[1]}));\n int index = resTexRC.x * ${e[1]} + resTexRC.y;\n ${i}\n return ivec4(r, c, d, d2);\n }\n `}(t,e,n);case 5:return function(t,e){const n=ctt(["r","c","d","d2","d3"],t);return`\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(${e[0]},\n ${e[1]}));\n\n int index = resTexRC.x * ${e[1]} + resTexRC.y;\n\n ${n}\n\n ivec5 outShape = ivec5(r, c, d, d2, d3);\n return outShape;\n }\n `}(t,e);case 6:return function(t,e){const n=ctt(["r","c","d","d2","d3","d4"],t);return`\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${e[0]}, ${e[1]}));\n int index = resTexRC.x * ${e[1]} + resTexRC.y;\n\n ${n}\n\n ivec6 result = ivec6(r, c, d, d2, d3, d4);\n return result;\n }\n `}(t,e);default:throw new Error(`${t.length}-D output sampling is not yet supported`)}}(e.logicalShape,a,n.enableShapeUniforms),h=function(t){return`\n void setOutput(float val) {\n ${t.output} = vec4(val, 0, 0, 0);\n }\n `}(o)),n.packedInputs&&(p+=wtt);return[p,l,h,s,u,r,n.userCode].join("\n")}function ytt(t,e=!1){const n=t.shapeInfo.logicalShape;switch(n.length){case 0:return function(t,e){const n=t.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1);if(t.shapeInfo.isUniform)return`float ${i}() {return ${n};}`;const[s,r]=t.shapeInfo.texShape;if(1===s&&1===r)return`\n float ${i}() {\n return sampleTexture(${n}, halfCR);\n }\n `;const a=xtt(n);if(e)return`\n float ${i}() {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${a});\n return sampleTexture(${n}, uv);\n }\n `;const[o,l]=t.shapeInfo.texShape;return`\n float ${i}() {\n vec2 uv = uvFromFlat(${o}, ${l}, ${a});\n return sampleTexture(${n}, uv);\n }\n `}(t,e);case 1:return function(t,e){const n=t.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1);if(t.shapeInfo.isUniform)return`\n float ${i}(int index) {\n ${Rtt(t)}\n }\n `;const s=t.shapeInfo.texShape,r=s[0],a=s[1];if(1===a&&1===r)return`\n float ${i}(int index) {\n return sampleTexture(${n}, halfCR);\n }\n `;const o=xtt(n);if(1===a)return e?`\n float ${i}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${o}) + 0.5) / float(${n}TexShape[0]));\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${i}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${o}) + 0.5) / ${r}.0);\n return sampleTexture(${n}, uv);\n }\n `;if(1===r)return e?`\n float ${i}(int index) {\n vec2 uv = vec2((float(index + ${o}) + 0.5) / float(${n}TexShape[1]), 0.5);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${i}(int index) {\n vec2 uv = vec2((float(index + ${o}) + 0.5) / ${a}.0, 0.5);\n return sampleTexture(${n}, uv);\n }\n `;if(e)return`\n float ${i}(int index) {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], index + ${o});\n return sampleTexture(${n}, uv);\n }\n `;return`\n float ${i}(int index) {\n vec2 uv = uvFromFlat(${r}, ${a}, index + ${o});\n return sampleTexture(${n}, uv);\n }\n `}(t,e);case 2:return function(t,e){const n=t.shapeInfo.logicalShape,i=t.name,s="get"+i.charAt(0).toUpperCase()+i.slice(1),r=t.shapeInfo.texShape;if(null!=r&&vO(n,r)){if(e)return`\n float ${s}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}TexShape[1], ${i}TexShape[0]);\n return sampleTexture(${i}, uv);\n }\n `;const t=r[0];return`\n float ${s}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r[1]}.0, ${t}.0);\n return sampleTexture(${i}, uv);\n }\n `}const{newShape:a,keptDims:o}=NO(n),l=a;if(l.length<n.length){const n=["row","col"];return`\n ${ytt(Mtt(t,l),e)}\n float ${s}(int row, int col) {\n return ${s}(${Ctt(n,o)});\n }\n `}if(t.shapeInfo.isUniform)return`\n float ${s}(int row, int col) {\n int index = round(dot(vec2(row, col), vec2(${n[1]}, 1)));\n ${Rtt(t)}\n }\n `;const u=r[0],h=r[1],p=xtt(i);if(1===h)return e?`\n float ${s}(int row, int col) {\n float index = dot(vec3(row, col, ${p}), vec3(${i}Shape[1], 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / float(${i}TexShape[0]));\n return sampleTexture(${i}, uv);\n }\n `:`\n float ${s}(int row, int col) {\n float index = dot(vec3(row, col, ${p}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / ${u}.0);\n return sampleTexture(${i}, uv);\n }\n `;if(1===u)return e?`\n float ${s}(int row, int col) {\n float index = dot(vec3(row, col, ${p}), vec3(${i}Shape[1], 1, 1));\n vec2 uv = vec2((index + 0.5) / float(${i}TexShape[1]), 0.5);\n return sampleTexture(${i}, uv);\n }\n `:`\n float ${s}(int row, int col) {\n float index = dot(vec3(row, col, ${p}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2((index + 0.5) / ${h}.0, 0.5);\n return sampleTexture(${i}, uv);\n }\n `;if(e)return`\n float ${s}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${i}Shape[1] + col + ${p};\n vec2 uv = uvFromFlat(${i}TexShape[0], ${i}TexShape[1], index);\n return sampleTexture(${i}, uv);\n }\n `;return`\n float ${s}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${n[1]} + col + ${p};\n vec2 uv = uvFromFlat(${u}, ${h}, index);\n return sampleTexture(${i}, uv);\n }\n`}(t,e);case 3:return function(t,e){const n=t.shapeInfo.logicalShape,i=t.name,s="get"+i.charAt(0).toUpperCase()+i.slice(1),r=n[1]*n[2],a=n[2],{newShape:o,keptDims:l}=NO(n),u=o;if(u.length<n.length){const n=["row","col","depth"];return`\n ${ytt(Mtt(t,u),e)}\n float ${s}(int row, int col, int depth) {\n return ${s}(${Ctt(n,l)});\n }\n `}if(t.shapeInfo.isUniform)return`\n float ${s}(int row, int col, int depth) {\n int index = round(dot(vec3(row, col, depth),\n vec3(${r}, ${a}, 1)));\n ${Rtt(t)}\n }\n `;const h=t.shapeInfo.texShape,p=h[0],c=h[1],d=t.shapeInfo.flatOffset;if(c===r&&null==d)return e?`\n float ${s}(int row, int col, int depth) {\n int stride1 = ${i}Shape[2];\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(stride1, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${i}TexShape[1], ${i}TexShape[0]);\n return sampleTexture(${i}, uv);\n }\n `:`\n float ${s}(int row, int col, int depth) {\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(${a}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${c}.0, ${p}.0);\n return sampleTexture(${i}, uv);\n }\n `;if(c===a&&null==d)return e?`\n float ${s}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${i}Shape[1], 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${i}TexShape[1], ${i}TexShape[0]);\n return sampleTexture(${i}, uv);\n }\n `:`\n float ${s}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${n[1]}, 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${c}.0, ${p}.0);\n return sampleTexture(${i}, uv);\n }\n `;const f=xtt(i);if(e)return`\n float ${s}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int stride0 = ${i}Shape[1] * ${i}Shape[2];\n int stride1 = ${i}Shape[2];\n int index = row * stride0 + col * stride1 + depth + ${f};\n vec2 uv = uvFromFlat(${i}TexShape[0], ${i}TexShape[1], index);\n return sampleTexture(${i}, uv);\n }\n `;return`\n float ${s}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${r} + col * ${a} + depth + ${f};\n vec2 uv = uvFromFlat(${p}, ${c}, index);\n return sampleTexture(${i}, uv);\n }\n `}(t,e);case 4:return function(t,e){const n=t.shapeInfo.logicalShape,i=t.name,s="get"+i.charAt(0).toUpperCase()+i.slice(1),r=n[3],a=n[2]*r,o=n[1]*a,{newShape:l,keptDims:u}=NO(n);if(l.length<n.length){const n=["row","col","depth","depth2"];return`\n ${ytt(Mtt(t,l),e)}\n float ${s}(int row, int col, int depth, int depth2) {\n return ${s}(${Ctt(n,u)});\n }\n `}if(t.shapeInfo.isUniform)return`\n float ${s}(int row, int col, int depth, int depth2) {\n int index = round(dot(vec4(row, col, depth, depth2),\n vec4(${o}, ${a}, ${r}, 1)));\n ${Rtt(t)}\n }\n `;const h=t.shapeInfo.flatOffset,p=t.shapeInfo.texShape,c=p[0],d=p[1],f=`int stride2 = ${i}Shape[3];`,m=`int stride1 = ${i}Shape[2] * stride2;`,g=`int stride0 = ${i}Shape[1] * stride1;`;if(d===o&&null==h)return e?`\n float ${s}(int row, int col, int depth, int depth2) {\n ${f}\n ${m}\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(stride1, stride2, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${i}TexShape[1], ${i}TexShape[0]);\n return sampleTexture(${i}, uv);\n }\n `:`\n float ${s}(int row, int col, int depth, int depth2) {\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(${a}, ${r}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${c}.0);\n return sampleTexture(${i}, uv);\n }\n `;if(d===r&&null==h)return e?`\n float ${s}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${i}Shape[1] * ${i}Shape[2], ${i}Shape[2], 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${i}TexShape[1], ${i}TexShape[0]);\n return sampleTexture(${i}, uv);\n }\n `:`\n float ${s}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${n[1]*n[2]}, ${n[2]}, 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${c}.0);\n return sampleTexture(${i}, uv);\n }\n `;const _=xtt(i);if(e)return`\n float ${s}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n ${f}\n ${m}\n ${g}\n int index = row * stride0 + col * stride1 +\n depth * stride2 + depth2;\n vec2 uv = uvFromFlat(${i}TexShape[0], ${i}TexShape[1], index + ${_});\n return sampleTexture(${i}, uv);\n }\n `;return`\n float ${s}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${o} + col * ${a} +\n depth * ${r} + depth2;\n vec2 uv = uvFromFlat(${c}, ${d}, index + ${_});\n return sampleTexture(${i}, uv);\n }\n `}(t,e);case 5:return function(t){const e=t.shapeInfo.logicalShape,n=t.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1),s=e[4],r=e[3]*s,a=e[2]*r,o=e[1]*a,{newShape:l,keptDims:u}=NO(e);if(l.length<e.length){const e=["row","col","depth","depth2","depth3"];return`\n ${ytt(Mtt(t,l))}\n float ${i}(int row, int col, int depth, int depth2, int depth3) {\n return ${i}(${Ctt(e,u)});\n }\n `}if(t.shapeInfo.isUniform)return`\n float ${i}(int row, int col, int depth, int depth2, int depth3) {\n float index = dot(\n vec4(row, col, depth, depth2),\n vec4(${o}, ${a}, ${r}, ${s})) +\n depth3;\n ${Rtt(t)}\n }\n `;const h=t.shapeInfo.flatOffset,p=t.shapeInfo.texShape,c=p[0],d=p[1];if(d===o&&null==h)return`\n float ${i}(int row, int col, int depth, int depth2, int depth3) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${a}, ${r}, ${s}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${c}.0);\n return sampleTexture(${n}, uv);\n }\n `;if(d===s&&null==h)return`\n float ${i}(int row, int col, int depth, int depth2, int depth3) {\n float texR = dot(\n vec4(row, col, depth, depth2),\n vec4(${e[1]*e[2]*e[3]},\n ${e[2]*e[3]}, ${e[3]}, 1));\n int texC = depth3;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${c}.0);\n return sampleTexture(${n}, uv);\n }\n `;const f=xtt(n);return`\n float ${i}(int row, int col, int depth, int depth2, int depth3) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${o} + col * ${a} + depth * ${r} +\n depth2 * ${s} + depth3 + ${f};\n vec2 uv = uvFromFlat(${c}, ${d}, index);\n return sampleTexture(${n}, uv);\n }\n `}(t);case 6:return function(t){const e=t.shapeInfo.logicalShape,n=t.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:s,keptDims:r}=NO(e);if(s.length<e.length){const e=["row","col","depth","depth2","depth3","depth4"];return`\n ${ytt(Mtt(t,s))}\n float ${i}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n return ${i}(${Ctt(e,r)});\n }\n `}const a=e[5],o=e[4]*a,l=e[3]*o,u=e[2]*l,h=e[1]*u;if(t.shapeInfo.isUniform)return`\n float ${i}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int index = round(dot(\n vec4(row, col, depth, depth2),\n vec4(${h}, ${u}, ${l}, ${o})) +\n dot(\n vec2(depth3, depth4),\n vec2(${a}, 1)));\n ${Rtt(t)}\n }\n `;const p=t.shapeInfo.flatOffset,c=t.shapeInfo.texShape,d=c[0],f=c[1];if(f===h&&null==p)return`\n float ${i}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${u}, ${l}, ${o}, ${a})) +\n float(depth4);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `;if(f===a&&null==p)return`\n float ${i}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n float texR = dot(vec4(row, col, depth, depth2),\n vec4(${e[1]*e[2]*e[3]*e[4]},\n ${e[2]*e[3]*e[4]},\n ${e[3]*e[4]},\n ${e[4]})) + float(depth3);\n int texC = depth4;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `;const m=xtt(n);return`\n float ${i}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${h} + col * ${u} + depth * ${l} +\n depth2 * ${o} + depth3 * ${a} + depth4 + ${m};\n vec2 uv = uvFromFlat(${d}, ${f}, index);\n return sampleTexture(${n}, uv);\n }\n `}(t);default:throw new Error(`${n.length}-D input sampling is not yet supported`)}}function Itt(t,e){switch(t.shapeInfo.logicalShape.length){case 0:return function(t){const e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1),i=ptt();return`\n vec4 ${n}() {\n return ${i.texture2D}(${e}, halfCR);\n }\n `}(t);case 1:return function(t,e){const n=t.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1),s=t.shapeInfo.texShape,r=ptt();if(e)return`\n vec4 ${i}(int index) {\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n vec2 uv = packedUVfrom1D(\n packedTexShape[0], packedTexShape[1], index);\n return ${r.texture2D}(${n}, uv);\n }\n `;const a=[Math.ceil(s[0]/2),Math.ceil(s[1]/2)];return`\n vec4 ${i}(int index) {\n vec2 uv = packedUVfrom1D(\n ${a[0]}, ${a[1]}, index);\n return ${r.texture2D}(${n}, uv);\n }\n `}(t,e);case 2:return function(t,e){const n=t.shapeInfo.logicalShape,i=t.name,s="get"+i.charAt(0).toUpperCase()+i.slice(1),r=t.shapeInfo.texShape,a=r[0],o=r[1],l=ptt();if(null!=r&&vO(n,r))return e?`\n vec4 ${s}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}TexShape[1], ${i}TexShape[0]);\n\n return ${l.texture2D}(${i}, uv);\n }\n `:`\n vec4 ${s}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}.0, ${a}.0);\n\n return ${l.texture2D}(${i}, uv);\n }\n `;if(e)return`\n vec4 ${s}(int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${i}TexShape[0]) / 2.0), ceil(float(${i}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${i}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);\n return ${l.texture2D}(${i}, uv);\n }\n `;const u=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],h=Math.ceil(n[1]/2);return`\n vec4 ${s}(int row, int col) {\n vec2 uv = packedUVfrom2D(${h}, ${u[0]}, ${u[1]}, row, col);\n return ${l.texture2D}(${i}, uv);\n }\n `}(t,e);case 3:return function(t,e){const n=t.shapeInfo.logicalShape,i=t.name,s="get"+i.charAt(0).toUpperCase()+i.slice(1),r=t.shapeInfo.texShape,a=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)];if(1===n[0]){const i=[1,2],r=["b","row","col"];return`\n ${Itt(Mtt(t,n.slice(1)),e)}\n vec4 ${s}(int b, int row, int col) {\n return ${s}(${Ctt(r,i)});\n }\n `}const o=ptt();if(e)return`\n vec4 ${s}(int b, int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${i}TexShape[0]) / 2.0), ceil(float(${i}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${i}Shape[2]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${i}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom3D(\n packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);\n return ${o.texture2D}(${i}, uv);\n }\n `;const l=a[0],u=a[1],h=Math.ceil(n[2]/2),p=h*Math.ceil(n[1]/2);return`\n vec4 ${s}(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n ${l}, ${u}, ${p}, ${h}, b, row, col);\n return ${o.texture2D}(${i}, uv);\n }\n `}(t,e);default:return function(t,e){const n=t.name,i="get"+n.charAt(0).toUpperCase()+n.slice(1),s=ptt();if(e)return`\n vec4 ${i}(int b2, int b, int row, int col) {\n int valuesPerRow = int(ceil(float(${n}Shape[3]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${n}Shape[2]) / 2.0));\n int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);\n texelsInBatch *= ${n}Shape[1];\n index = b2 * texelsInBatch + index;\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n int texR = index / packedTexShape[1];\n int texC = index - texR * packedTexShape[1];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${s.texture2D}(${n}, uv);\n }\n `;const r=t.shapeInfo.logicalShape,a=r.length,o=t.shapeInfo.texShape,l=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)],u=l[0],h=l[1],p=Math.ceil(r[a-1]/2);let c=p*Math.ceil(r[a-2]/2),d="int b, int row, int col",f=`b * ${c} + (row / 2) * ${p} + (col / 2)`;for(let t=2;t<a-1;t++)d=`int b${t}, `+d,c*=r[a-t-1],f=`b${t} * ${c} + `+f;return`\n vec4 ${i}(${d}) {\n int index = ${f};\n int texR = index / ${h};\n int texC = index - texR * ${h};\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${h}, ${u});\n return ${s.texture2D}(${n}, uv);\n }\n `}(t,e)}}const Ett="\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",btt="\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",vtt="\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",wtt="\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n";function Stt(){return"\n int getOutputCoords() {\n return 0;\n }\n "}function xtt(t){return`offset${t}`}function Rtt(t){const e=t.name,n=IO(t.shapeInfo.logicalShape);return n<2?`return ${e};`:`\n for (int i = 0; i < ${n}; i++) {\n if (i == index) {\n return ${e}[i];\n }\n }\n `}function Ott(t){if(t<=1)return"int";if(2===t)return"ivec2";if(3===t)return"ivec3";if(4===t)return"ivec4";if(5===t)return"ivec5";if(6===t)return"ivec6";throw Error(`GPU for rank ${t} is not yet supported`)}function Att(t,e,n){const{newShape:i,keptDims:s}=NO(e),r=e.length,a=t&&3===r&&1===e[0],o=a?e.slice(1):i,l=!t&&r>1&&!vO(e,n)&&i.length<r||a;return{useSqueezeShape:l,uniformShape:l?o:e,keptDims:s}}function Mtt(t,e){const n=JSON.parse(JSON.stringify(t));return n.shapeInfo.logicalShape=e,n}function Ctt(t,e){return e.map((e=>t[e])).join(", ")}function Ntt(t,e,n){const i=[],s=[];let r,a,o,l=null,u=null;u=t.getUniformLocation(n,"NAN",!1),1===aA().getNumber("WEBGL_VERSION")&&(l=t.getUniformLocation(n,"INFINITY",!1));const h=!1;for(const s of e.variableNames){const r={name:s,uniform:t.getUniformLocation(n,s,h),offset:t.getUniformLocation(n,`offset${s}`,h)};e.enableShapeUniforms&&(r.shape=t.getUniformLocation(n,`${s}Shape`,h),r.texShape=t.getUniformLocation(n,`${s}TexShape`,h)),i.push(r)}if(e.enableShapeUniforms&&(r=t.getUniformLocation(n,"outShape",h),o=t.getUniformLocation(n,"outShapeStrides",h),a=t.getUniformLocation(n,"outTexShape",h)),e.customUniforms)for(const i of e.customUniforms)s.push(t.getUniformLocation(n,i.name,h));return{variablesLocations:i,customUniformLocations:s,infLoc:l,nanLoc:u,outShapeLocation:r,outShapeStridesLocation:o,outTexShapeLocation:a}}function ktt(t,e){if(t.length!==e.length)throw Error(`Binary was compiled with ${t.length} inputs, but was executed with ${e.length} inputs`);t.forEach(((t,n)=>{const i=t.logicalShape,s=e[n],r=s.shape;if(!vO(i,r))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${i} and ${r} must match`);if(t.isUniform&&s.isUniform)return;const a=t.texShape,o=s.isUniform?null:s.texData.texShape;if(!vO(a,o))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${a} and ${o} must match`)}))}function Dtt(t){return aA().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&t<=4}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Ltt{constructor(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=r7.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const e=ptt();this.outputShape=t,this.enableShapeUniforms=Dtt(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?dtt(["r","c","d"],t):ctt(["r","c","d"],t)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n ${e.output} = result;\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Ftt{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=r7.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const e=ptt();this.outputShape=t,this.enableShapeUniforms=Dtt(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?dtt(["r","c","d"],t):ctt(["r","c","d"],t)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n ${e.output} = result;\n }\n `}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Ptt{constructor(t){this.variableNames=["A"],this.outTexUsage=a7.DOWNLOAD;const e=ptt();this.outputShape=t,this.userCode=`\n ${gtt}\n\n void main() {\n float x = getAAtOutCoords();\n ${e.output} = encode_float(x);\n }\n `}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class $tt{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=a7.DOWNLOAD;const e=ptt();this.outputShape=t,this.userCode=`\n ${gtt}\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n ${e.output} = encode_float(x);\n }\n `}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const Btt={R:0,G:1,B:2,A:3};class Vtt{constructor(t,e=!1,n="RGBA"){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const i=ptt();this.outputShape=t,this.enableShapeUniforms=Dtt(this.outputShape.length);let s="result";e&&(s="floor(result * 255. + 0.5)");let r="";for(let t=0;t<n.length;t++){const e=n[t];r+=`\n if(offset == ${t}) {\n result = values[${Btt[e]}];\n }`}this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":mtt(t)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n int flatIndex = getFlatIndex(coords);\n float result = 0.;\n int offset = imod(flatIndex, ${n.length});\n\n flatIndex = idiv(flatIndex, ${n.length}, 1.);\n\n int r = flatIndex / texShape[1];\n if (r < texShape[0]) {\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n vec4 values = ${i.texture2D}(A, uv);\n ${r}\n }\n ${i.output} = vec4(${s}, 0., 0., 0.);\n }\n `}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Utt{constructor(t,e=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=ptt();this.outputShape=t,this.enableShapeUniforms=Dtt(this.outputShape.length);let i="",s="result";e&&(s="floor(result * 255. + 0.5)");for(let e=0;e<=1;e++)for(let s=0;s<=1;s++){const r=2*e+s;i+=`\n localCoords = coords;\n if(localCoords[2] + ${s} < ${this.enableShapeUniforms?"outShape[2]":`${t[2]}`}) {\n localCoords[2] += ${s};\n if (localCoords[1] + ${e} < ${this.enableShapeUniforms?"outShape[1]":`${t[1]}`}) {\n localCoords[1] += ${e};\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n values = ${n.texture2D}(A, uv);\n\n if (offset == 0) {\n result[${r}] = values[0];\n } else if (offset == 1) {\n result[${r}] = values[1];\n } else if (offset == 2) {\n result[${r}] = values[2];\n } else {\n result[${r}] = values[3];\n }\n }\n }\n `}this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":mtt(t)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n ${i}\n\n ${n.output} = ${s};\n }\n `}}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Ytt(t){const e=ptt();return T7(t,`${e.version}\n precision highp float;\n ${e.attribute} vec3 clipSpacePos;\n ${e.attribute} vec2 uv;\n ${e.varyingVs} vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }`)}function Gtt(t){return S7(t,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}function Htt(t){return x7(t,new Uint16Array([0,1,2,2,1,3]))}function Wtt(t,e,n,i,s,r){A7(e,n);const a=O7(t),o=t.TEXTURE_2D;return c7(t,(()=>t.bindTexture(o,a))),c7(t,(()=>t.texParameteri(o,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE))),c7(t,(()=>t.texParameteri(o,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE))),c7(t,(()=>t.texParameteri(o,t.TEXTURE_MIN_FILTER,t.NEAREST))),c7(t,(()=>t.texParameteri(o,t.TEXTURE_MAG_FILTER,t.NEAREST))),1===aA().getNumber("WEBGL_VERSION")?c7(t,(()=>t.texImage2D(o,0,i,e,n,0,s,r,null))):c7(t,(()=>t.texStorage2D(o,1,i,e,n))),c7(t,(()=>t.bindTexture(t.TEXTURE_2D,null))),{texture:a,texShape:[n,e]}}function ztt(t){return t.internalFormatFloat}function Xtt(t,e,n,i){const[s,r]=l7(e,n);return Wtt(t,s,r,ztt(i),i.textureFormatFloat,t.FLOAT)}function jtt(t){return t.internalFormatHalfFloat}function qtt(t,e,n,i){const[s,r]=l7(e,n);return Wtt(t,s,r,jtt(i),i.textureFormatFloat,i.textureTypeHalfFloat)}function Ktt(t){return t.downloadTextureFormat}function Qtt(t,e,n,i){const[s,r]=l7(e,n);return Wtt(t,s,r,Ktt(i),t.RGBA,t.UNSIGNED_BYTE)}function Jtt(t){return t.internalFormatPackedFloat}function Ztt(t,e,n,i){const[s,r]=h7(e,n);return Wtt(t,s,r,Jtt(i),t.RGBA,t.FLOAT)}function tet(t){return t.internalFormatPackedHalfFloat}function eet(t,e,n,i){const[s,r]=h7(e,n);return Wtt(t,s,r,tet(i),t.RGBA,i.textureTypeHalfFloat)}function net(t,e,n){c7(t,(()=>t.bindBuffer(t.ARRAY_BUFFER,n)));return C7(t,e,"clipSpacePos",n,3,20,0)&&C7(t,e,"uv",n,2,20,12)}function iet(t,e,n,i,s,r){let a,o,l;c7(t,(()=>t.bindTexture(t.TEXTURE_2D,e))),s instanceof Uint8Array?(a=new Uint8Array(n*i*4),o=t.UNSIGNED_BYTE,l=t.RGBA):(a=new Float32Array(n*i*4),o=t.FLOAT,l=r.internalFormatPackedFloat),a.set(s),2===aA().getNumber("WEBGL_VERSION")?c7(t,(()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,n,i,t.RGBA,o,a))):c7(t,(()=>t.texImage2D(t.TEXTURE_2D,0,l,n,i,0,t.RGBA,o,a))),c7(t,(()=>t.bindTexture(t.TEXTURE_2D,null)))}function set(t,e,n){c7(t,(()=>t.bindTexture(t.TEXTURE_2D,e))),n.data instanceof Uint8Array?2===aA().getNumber("WEBGL_VERSION")?c7(t,(()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,n.width,n.height,t.RGBA,t.UNSIGNED_BYTE,n.data))):c7(t,(()=>t.texImage2D(t.TEXTURE_2D,0,t.RGBA,n.width,n.height,0,t.RGBA,t.UNSIGNED_BYTE,n.data))):2===aA().getNumber("WEBGL_VERSION")?c7(t,(()=>t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,n))):c7(t,(()=>t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n))),c7(t,(()=>t.bindTexture(t.TEXTURE_2D,null)))}function ret(t,e,n,i){const s=t.createBuffer();c7(t,(()=>t.bindBuffer(t.PIXEL_PACK_BUFFER,s)));const r=16*e*n;return c7(t,(()=>t.bufferData(t.PIXEL_PACK_BUFFER,r,t.STREAM_READ))),c7(t,(()=>t.readPixels(0,0,n,e,t.RGBA,t.FLOAT,0))),c7(t,(()=>t.bindBuffer(t.PIXEL_PACK_BUFFER,null))),s}function aet(t,e,n){const i=t,s=new Float32Array(n);return i.bindBuffer(i.PIXEL_PACK_BUFFER,e),i.getBufferSubData(i.PIXEL_PACK_BUFFER,0,s),i.bindBuffer(i.PIXEL_PACK_BUFFER,null),s}function oet(t,e,n,i){const[s,r]=l7(e,n),a=new Uint8Array(e*n*4);return c7(t,(()=>t.readPixels(0,0,s,r,i.downloadTextureFormat,t.UNSIGNED_BYTE,a))),new Float32Array(a.buffer)}function uet(t,e,n,i,s,r,a,o){const l=t,u=new Float32Array(function(t,e){const[n,i]=h7(t,e);return n*i*4}(r,a));return l.bindBuffer(l.PIXEL_PACK_BUFFER,e),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,u),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),u}function het(t,e,n){const i=new Float32Array(e*n*4);return c7(t,(()=>t.readPixels(0,0,n,e,t.RGBA,t.FLOAT,i))),i}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class pet{constructor(t){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];const e=aA().getNumber("WEBGL_VERSION");if(null!=t?(this.gl=t,i7(e,t)):this.gl=s7(e),t=this.gl,2===aA().getNumber("WEBGL_VERSION")){const e=t;this.createVertexArray=()=>c7(e,(()=>e.createVertexArray())),this.bindVertexArray=t=>c7(e,(()=>e.bindVertexArray(t))),this.deleteVertexArray=t=>c7(e,(()=>e.deleteVertexArray(t))),this.getVertexArray=()=>c7(e,(()=>e.getParameter(e.VERTEX_ARRAY_BINDING)))}else if(null!=t){const e=t.getExtension("OES_vertex_array_object");if(null==e)throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>c7(t,(()=>e.createVertexArrayOES())),this.bindVertexArray=n=>c7(t,(()=>e.bindVertexArrayOES(n))),this.deleteVertexArray=n=>c7(t,(()=>e.deleteVertexArrayOES(n))),this.getVertexArray=()=>c7(t,(()=>t.getParameter(e.VERTEX_ARRAY_BINDING_OES)))}let n="WEBGL_color_buffer_float";const i="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===aA().getNumber("WEBGL_VERSION")){const t="OES_texture_float",e="OES_texture_half_float";if(this.textureFloatExtension=_7(this.gl,t),itt(this.gl,e))this.textureHalfFloatExtension=_7(this.gl,e);else if(aA().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(n),itt(this.gl,i))this.colorBufferHalfFloatExtension=_7(this.gl,i);else if(aA().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(n="EXT_color_buffer_float",itt(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!itt(this.gl,i))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(i)}this.vertexBuffer=Gtt(this.gl),this.indexBuffer=Htt(this.gl),this.framebuffer=M7(this.gl),this.textureConfig=p7(this.gl,this.textureHalfFloatExtension)}get debug(){return aA().getBool("DEBUG")}dispose(){if(this.disposed)return;null!=this.program&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),null!=this.outputTexture&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");const t=this.gl;c7(t,(()=>t.finish())),c7(t,(()=>t.bindFramebuffer(t.FRAMEBUFFER,null))),c7(t,(()=>t.deleteFramebuffer(this.framebuffer))),c7(t,(()=>t.bindBuffer(t.ARRAY_BUFFER,null))),c7(t,(()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null))),c7(t,(()=>t.deleteBuffer(this.indexBuffer))),this.disposed=!0}createFloat32MatrixTexture(t,e){return this.throwIfDisposed(),Xtt(this.gl,t,e,this.textureConfig)}createFloat16MatrixTexture(t,e){return this.throwIfDisposed(),qtt(this.gl,t,e,this.textureConfig)}createUnsignedBytesMatrixTexture(t,e){return this.throwIfDisposed(),Qtt(this.gl,t,e,this.textureConfig)}uploadPixelDataToTexture(t,e){this.throwIfDisposed(),set(this.gl,t,e)}uploadDenseMatrixToTexture(t,e,n,i){this.throwIfDisposed(),iet(this.gl,t,e,n,i,this.textureConfig)}createFloat16PackedMatrixTexture(t,e){return this.throwIfDisposed(),eet(this.gl,t,e,this.textureConfig)}createPackedMatrixTexture(t,e){return this.throwIfDisposed(),Ztt(this.gl,t,e,this.textureConfig)}deleteMatrixTexture(t){this.throwIfDisposed(),this.outputTexture===t&&(B7(this.gl,this.framebuffer),this.outputTexture=null),c7(this.gl,(()=>this.gl.deleteTexture(t)))}downloadByteEncodedFloatMatrixFromOutputTexture(t,e,n){return this.downloadMatrixDriver(t,(()=>oet(this.gl,e,n,this.textureConfig)))}downloadPackedMatrixFromBuffer(t,e,n,i,s,r){return uet(this.gl,t,0,0,0,s,r,this.textureConfig)}downloadFloat32MatrixFromBuffer(t,e){return aet(this.gl,t,e)}createBufferFromTexture(t,e,n){this.bindTextureToFrameBuffer(t);const i=ret(this.gl,e,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),i}createAndWaitForFence(){const t=this.createFence(this.gl);return this.pollFence(t)}createFence(t){let e,n;if(aA().getBool("WEBGL_FENCE_API_ENABLED")){const i=t,s=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);t.flush(),n=()=>{const t=i.clientWaitSync(s,0,0);return t===i.ALREADY_SIGNALED||t===i.CONDITION_SATISFIED},e=s}else aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(e=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(e,aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:e,isFencePassed:n}}downloadMatrixFromPackedTexture(t,e,n){return this.downloadMatrixDriver(t,(()=>het(this.gl,e,n)))}createProgram(t){this.throwIfDisposed();const e=this.gl;null==this.vertexShader&&(this.vertexShader=Ytt(e));const n=b7(e);c7(e,(()=>e.attachShader(n,this.vertexShader))),c7(e,(()=>e.attachShader(n,t))),v7(e,n);const i=Object.assign(n,{vao:this.createVertexArray()});return this.debug&&w7(e,i),i}buildVao(t){this.setProgram(t),this.bindVertexArray(t.vao);const e=this.gl;c7(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.indexBuffer))),net(e,t,this.vertexBuffer)}deleteProgram(t){this.throwIfDisposed(),t===this.program&&(this.program=null),null!=t&&(c7(this.gl,(()=>this.gl.deleteProgram(t))),this.deleteVertexArray(t.vao))}setProgram(t){this.throwIfDisposed(),this.program=t,null!=this.program&&this.debug&&w7(this.gl,this.program),c7(this.gl,(()=>this.gl.useProgram(t)))}getUniformLocation(t,e,n=!0){return this.throwIfDisposed(),n?D7(this.gl,t,e):L7(this.gl,t,e)}getAttributeLocation(t,e){return this.throwIfDisposed(),c7(this.gl,(()=>this.gl.getAttribLocation(t,e)))}getUniformLocationNoThrow(t,e){return this.throwIfDisposed(),this.gl.getUniformLocation(t,e)}setInputMatrixTexture(t,e,n){this.throwIfDisposed(),this.throwIfNoProgram(),F7(this.gl,t,e,n)}setOutputMatrixTexture(t,e,n){this.setOutputMatrixTextureDriver(t,n,e)}setOutputPackedMatrixTexture(t,e,n){this.throwIfDisposed();const[i,s]=h7(e,n);this.setOutputMatrixTextureDriver(t,i,s)}setOutputMatrixWriteRegion(t,e,n,i){this.setOutputMatrixWriteRegionDriver(n,t,i,e)}setOutputPackedMatrixWriteRegion(t,e,n,i){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&w7(this.gl,this.program),V7(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const t=this.gl;if(this.debug){const t=this.getVertexArray();console.assert(t===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()}c7(t,(()=>t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0)))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),c7(this.gl,(()=>this.gl.finish()))}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=_7(this.gl,2===aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const t=this.gl,e=this.getQueryTimerExtensionWebGL2(),n=t.createQuery();return t.beginQuery(e.TIME_ELAPSED_EXT,n),n}const t=this.getQueryTimerExtensionWebGL1(),e=t.createQueryEXT();return t.beginQueryEXT(t.TIME_ELAPSED_EXT,e),e}endQuery(){if(2===aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const t=this.gl,e=this.getQueryTimerExtensionWebGL2();return void t.endQuery(e.TIME_ELAPSED_EXT)}const t=this.getQueryTimerExtensionWebGL1();t.endQueryEXT(t.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(t){return await AO((()=>this.disposed||this.isQueryAvailable(t,aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))),this.getQueryTime(t,aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(t,e){if(0===e)return null;if(2===e){const e=this.gl;return e.getQueryParameter(t,e.QUERY_RESULT)/1e6}{const e=this.getQueryTimerExtensionWebGL1();return e.getQueryObjectEXT(t,e.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(t,e){if(0===e)return!0;if(2===e){const e=this.gl,n=this.getQueryTimerExtensionWebGL2(),i=e.getQueryParameter(t,e.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),i&&!this.disjoint}{const e=this.getQueryTimerExtensionWebGL1(),n=e.getQueryObjectEXT(t,e.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(e.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(t){return new Promise((e=>{this.addItemToPoll((()=>t.isFencePassed()),(()=>e()))}))}pollItems(){const t=function(t){let e=0;for(;e<t.length;++e){if(!t[e]())break}return e-1}(this.itemsToPoll.map((t=>t.isDoneFn)));for(let e=0;e<=t;++e){const{resolveFn:t}=this.itemsToPoll[e];t()}this.itemsToPoll=this.itemsToPoll.slice(t+1)}addItemToPoll(t,e){if(this.itemsToPoll.push({isDoneFn:t,resolveFn:e}),this.itemsToPoll.length>1)return;let n;"setTimeoutCustom"in aA().platform&&(n=aA().platform.setTimeoutCustom.bind(aA().platform)),AO((()=>(this.pollItems(),0===this.itemsToPoll.length)),(()=>0),null,n)}bindTextureToFrameBuffer(t){this.throwIfDisposed(),$7(this.gl,t,this.framebuffer),this.debug&&V7(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?($7(this.gl,this.outputTexture,this.framebuffer),this.debug&&V7(this.gl)):B7(this.gl,this.framebuffer)}downloadMatrixDriver(t,e){this.bindTextureToFrameBuffer(t);const n=e();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(t,e,n){this.throwIfDisposed();const i=this.gl;$7(i,t,this.framebuffer),this.debug&&V7(i),this.outputTexture=t,c7(i,(()=>i.viewport(0,0,e,n))),c7(i,(()=>i.scissor(0,0,e,n)))}setOutputMatrixWriteRegionDriver(t,e,n,i){this.throwIfDisposed(),c7(this.gl,(()=>this.gl.scissor(t,e,n,i)))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw new Error("No GPU program is currently set.")}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const{addImpl:cet,bincountImpl:det,bincountReduceImpl:fet,bitwiseAndImpl:met,castImpl:get,ceilImpl:_et,concatImpl:Tet,equalImpl:yet,expImpl:Iet,expm1Impl:Eet,floorImpl:bet,gatherNdImpl:vet,gatherV2Impl:wet,greaterImpl:xet,greaterEqualImpl:Ret,lessImpl:Oet,lessEqualImpl:Aet,linSpaceImpl:Met,logImpl:Cet,maxImpl:Net,maximumImpl:ket,minimumImpl:Det,multiplyImpl:Let,negImpl:Fet,notEqualImpl:Pet,prodImpl:$et,raggedGatherImpl:Bet,raggedRangeImpl:Vet,raggedTensorToTensorImpl:Uet,rangeImpl:Yet,rsqrtImpl:Get,scatterImpl:Het,sigmoidImpl:Wet,simpleAbsImpl:zet,sliceImpl:Xet,sparseFillEmptyRowsImpl:jet,sparseReshapeImpl:qet,sparseSegmentReductionImpl:Ket,sqrtImpl:Qet,staticRegexReplaceImpl:Jet,stridedSliceImpl:Zet,stringNGramsImpl:tnt,stringSplitImpl:ent,stringToHashBucketFastImpl:nnt,subImpl:int,tileImpl:snt,topKImpl:rnt,transposeImpl:ant,uniqueImpl:ont}=jt;
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function lnt(t,e){return["x","y","z","w","u","v"].slice(0,e).map((e=>`${t}.${e}`))}function unt(t,e){return 1===e?[t]:lnt(t,e)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class hnt{constructor(t){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=t,this.rank=t.length,this.enableShapeUniforms=Dtt(this.outputShape.length),0===this.rank)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{const t=unt("rc",this.rank),e=Ott(this.rank),n=this.getOutOfBoundsCondition(t),i=this.getSetup(t),s=this.getOutput(t);this.userCode=`\n void main() {\n ${e} rc = getOutputCoords();\n\n if(${n}) {\n setOutput(vec4(0));\n } else {\n ${i}\n\n setOutput(vec4(${s}));\n }\n }\n `}}getSourceCoordsArr(t){const e=[];for(let n=0;n<=1;n++)for(let i=0;i<=1;i++){let s=`${0===n?"r":"rp1"}, ${0===i?"c":"cp1"}`;for(let e=2;e<this.rank;e++)s=`${t[t.length-1-e]},`+s;e.push(s)}return e}getOutOfBoundsCondition(t){if(1===this.rank)return`rc > ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let e="";for(let n=this.rank-2;n<this.rank;n++)e+=`${t[n]} >= ${this.enableShapeUniforms?`outShape[${n}]`:this.outputShape[n]}`,n<this.rank-1&&(e+="||");return e}getSetup(t){if(1===this.rank)return"";const e=t.slice(-2),n=this.enableShapeUniforms?`outShape[${this.rank} - 1]`:this.outputShape[this.rank-1],i=this.enableShapeUniforms?`outShape[${this.rank} - 2]`:this.outputShape[this.rank-2];return`\n int r = ${e[0]};\n int c = ${e[1]};\n int rp1 = r + 1;\n int cp1 = c + 1;\n\n bool cEdge = cp1 >= ${n};\n bool rEdge = rp1 >= ${i};\n `}getOutput(t){const e=this.getSourceCoordsArr(t);if(1===this.rank){return`getA(rc), (rc + 1 >= ${this.enableShapeUniforms?"outShape":this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0`}return`getA(${e[0]}),\n cEdge ? 0. : getA(${e[1]}),\n rEdge ? 0. : getA(${e[2]}),\n rEdge || cEdge ? 0. : getA(${e[3]})`}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class pnt{constructor(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=t,this.enableShapeUniforms=Dtt(this.outputShape.length);let n="";for(let t=0;t<4;t++){let e="thisRC = rc;";t%2==1&&(e+="thisRC.z += 1;"),t>1&&(e+="thisRC.y += 1;"),n+=`\n ${e}\n ${t>0?"if(thisRC.y < rows && thisRC.z < cols){":""}\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result[${t}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${t>0?"}":""}\n `}var i,s;this.userCode=`\n ${i=e,s=this.enableShapeUniforms,`\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${s?ftt(["r","c","d"],"inputShape"):ctt(["r","c","d"],i)}\n return ivec3(r, c, d);\n }\n `}\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":mtt(t)}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ${this.enableShapeUniforms?"outShape[1]":t[1]};\n int cols = ${this.enableShapeUniforms?"outShape[2]":t[2]};\n\n ${n}\n\n setOutput(result);\n }\n `}}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class cnt{constructor(t){this.gpgpu=t,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.usedTextures={},this.logEnabled=!1}acquireTexture(t,e,n){const i=fnt(e,n),s=mnt(t,i,n);s in this.freeTextures||(this.freeTextures[s]=[]),s in this.usedTextures||(this.usedTextures[s]=[]);const r=dnt(t,i,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[s].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=r,this.log();const t=this.freeTextures[s].pop();return this.usedTextures[s].push(t),t}let a;return i===o7.PACKED_2X2_FLOAT32?a=this.gpgpu.createPackedMatrixTexture(t[0],t[1]):i===o7.PACKED_2X2_FLOAT16?a=this.gpgpu.createFloat16PackedMatrixTexture(t[0],t[1]):i===o7.UNPACKED_FLOAT32?a=this.gpgpu.createFloat32MatrixTexture(t[0],t[1]):i===o7.UNPACKED_FLOAT16?a=this.gpgpu.createFloat16MatrixTexture(t[0],t[1]):i===o7.PACKED_4X1_UNSIGNED_BYTE&&(a=this.gpgpu.createUnsignedBytesMatrixTexture(t[0],t[1])),this.usedTextures[s].push(a),this.numUsedTextures++,this._numBytesAllocated+=r,this.log(),a}releaseTexture(t,e,n,i){if(null==this.freeTextures)return;const s=fnt(n,i),r=mnt(e,s,i);r in this.freeTextures||(this.freeTextures[r]=[]);const a=dnt(e,s,this.gpgpu.gl,this.gpgpu.textureConfig,i),o=aA().getNumber("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==o&&this._numBytesAllocated>o?(this.gpgpu.deleteMatrixTexture(t.texture),this._numBytesAllocated-=a):(this.freeTextures[r].push(t),this.numFreeTextures++,this._numBytesFree+=a),this.numUsedTextures--;const l=this.usedTextures[r],u=l&&l.indexOf(t);if(null==u||u<0)throw new Error("Cannot release a texture that was never provided by this texture manager");l[u]=l[l.length-1],l.pop(),this.log()}log(){if(!this.logEnabled)return;const t=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${t})`);const e=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*e)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(null!=this.freeTextures){for(const t in this.freeTextures)this.freeTextures[t].forEach((t=>{this.gpgpu.deleteMatrixTexture(t.texture)}));for(const t in this.usedTextures)this.usedTextures[t].forEach((t=>{this.gpgpu.deleteMatrixTexture(t.texture)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function dnt(t,e,n,i,s){const r=function(t,e){switch(t){case o7.PACKED_2X2_FLOAT32:return Jtt(e);case o7.PACKED_2X2_FLOAT16:return tet(e);case o7.UNPACKED_FLOAT32:return ztt(e);case o7.UNPACKED_FLOAT16:return jtt(e);case o7.PACKED_4X1_UNSIGNED_BYTE:return Ktt(e);default:throw new Error(`Unknown physical texture type ${t}`)}}(e,i);let a;if(s){const[e,n]=h7(t[0],t[1]);a=e*n}else{const[e,n]=l7(t[0],t[1]);a=e*n}const o=function(t,e){const n=t;if(e===n.R32F)return 4;if(e===n.R16F)return 2;if(e===n.RGBA32F)return 16;if(e===t.RGBA)return 16;if(e===n.RGBA16F)return 8;if(e===n.RGBA8)return 4;throw new Error(`Unknown internal format ${e}`)}(n,r);return a*o}function fnt(t,e){if(t===a7.UPLOAD)return o7.PACKED_2X2_FLOAT32;if(t===a7.RENDER||null==t)return function(t){return aA().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?t?o7.PACKED_2X2_FLOAT32:o7.UNPACKED_FLOAT32:t?o7.PACKED_2X2_FLOAT16:o7.UNPACKED_FLOAT16}(e);if(t===a7.DOWNLOAD||t===a7.PIXELS)return o7.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${t}`)}function mnt(t,e,n){return`${t[0]}_${t[1]}_${e}_${n}`}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class gnt{constructor(t,e){this.variableNames=["A"],this.outputShape=t,this.enableShapeUniforms=Dtt(this.outputShape.length),this.userCode=`\n float unaryOperation(float x) {\n ${e}\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}const _nt="if (isnan(x)) return x;",Tnt="return x;",ynt="return abs(x);";const Int="return (x >= 0.0) ? x : (exp(x) - 1.0);",Ent=_nt+"\n return (x < 0.0) ? 0.0 : x;\n",bnt=_nt+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",vnt="return x;",wnt="return 1.0 / (1.0 + exp(-1.0 * x));",Snt="return x;",xnt="\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n",Rnt="\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",Ont="\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",Ant="return 1.0 / (1.0 + exp(-1.0 * x));";class Mnt{constructor(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.enableShapeUniforms=Dtt(this.outputShape.length),this.userCode=`\n vec4 unaryOperation(vec4 x) {\n ${e}\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Cnt{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=t,this.enableShapeUniforms=Dtt(this.outputShape.length);const e=t.length,n=unt("rc",e),i=Ott(e),s=function(t,e){if(1===t)return"rc";let n="";for(let i=0;i<t;i++)n+=e[i],i<t-1&&(n+=",");return n}(e,n),r=n.slice(-2),a=e<=1?"rc":`vec2(${r.join(",")})`;this.userCode=`\n void main() {\n ${i} rc = getOutputCoords();\n vec4 packedInput = getA(${s});\n\n setOutput(getChannel(packedInput, ${a}));\n }\n `}}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const Nnt=NU,knt={};const Dnt=aA().getNumber("CPU_HANDOFF_SIZE_THRESHOLD");class Lnt extends oO{nextDataId(){return Lnt.nextDataId++}constructor(t){if(super(),this.pendingRead=new WeakMap,this.pendingDisposal=new WeakSet,this.dataRefCount=new WeakMap,this.numBytesInGPU=0,this.uploadWaitMs=0,this.downloadWaitMs=0,this.lastGlFlushTime=0,this.warnedAboutMemory=!1,this.pendingDeletes=0,this.disposed=!1,!aA().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");let e;if(null!=t){if(t instanceof pet)e=t;else{const n=s7(aA().getNumber("WEBGL_VERSION"),t);e=new pet(n)}this.binaryCache={},this.gpgpuCreatedLocally=!1}else{const t=s7(aA().getNumber("WEBGL_VERSION"));e=new pet(t),this.binaryCache=((n=aA().getNumber("WEBGL_VERSION"))in knt||(knt[n]={}),knt[n]),this.gpgpuCreatedLocally=!0}var n;this.gpgpu=e,this.canvas=this.gpgpu.gl.canvas,this.textureManager=new cnt(this.gpgpu),this.numMBBeforeWarning=null==aA().global.screen?1024:aA().global.screen.height*aA().global.screen.width*window.devicePixelRatio*600/1024/1024,this.texData=new aO(this,TD())}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}writeTexture(t,e,n,i,s,r){const a=this.makeTensorInfo(e,n),o=this.texData.get(a.dataId);o.isPacked=!1,o.texture={texture:t,texShape:[i,s]},o.texShape=[i,s];const l=z7(e),u=new Vtt(l,!1,r),h=this.runWebGLProgram(u,[a],n,[[i,s]]);return h.shape=e,o.texture=null,this.disposeIntermediateTensorInfo(a),h.dataId}write(t,e,n){if((aA().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||aA().getBool("DEBUG"))&&this.checkNumericalProblems(t),"complex64"===n&&null!=t)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");const i={id:this.nextDataId()};return this.texData.set(i,{shape:e,dtype:n,values:t,usage:a7.UPLOAD,refCount:1}),i}refCount(t){if(this.texData.has(t)){return this.texData.get(t).refCount}return 0}incRef(t){this.texData.get(t).refCount++}decRef(t){if(this.texData.has(t)){this.texData.get(t).refCount--}}move(t,e,n,i,s){if(aA().getBool("DEBUG")&&this.checkNumericalProblems(e),"complex64"===i)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(t,{shape:n,dtype:i,values:e,usage:a7.UPLOAD,refCount:s})}disposeIntermediateTensorInfo(t){this.disposeData(t.dataId)}readSync(t){const e=this.texData.get(t),{values:n,dtype:i,complexTensorInfos:s,slice:r,shape:a,isPacked:o}=e;if(null!=r){let e;e=o?new Mnt(a,vnt):new gnt(a,vnt);const n=this.runWebGLProgram(e,[{dataId:t,shape:a,dtype:i}],i),s=this.readSync(n.dataId);return this.disposeIntermediateTensorInfo(n),s}if(null!=n)return this.convertAndCacheOnCPU(t);if("string"===i)return n;const l=null!=this.activeTimers;let u,h;if(l&&(u=rk()),"complex64"===i){h=AG(this.readSync(s.real.dataId),this.readSync(s.imag.dataId))}else h=this.getValuesFromTexture(t);return l&&(this.downloadWaitMs+=rk()-u),this.convertAndCacheOnCPU(t,h)}async read(t){if(this.pendingRead.has(t)){const e=this.pendingRead.get(t);return new Promise((t=>e.push(t)))}const e=this.texData.get(t),{values:n,shape:i,slice:s,dtype:r,complexTensorInfos:a,isPacked:o}=e;if(null!=s){let e;e=o?new Mnt(i,vnt):new gnt(i,vnt);const n=this.runWebGLProgram(e,[{dataId:t,shape:i,dtype:r}],r),s=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),s}if(null!=n)return this.convertAndCacheOnCPU(t);if(aA().getBool("DEBUG")&&!aA().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===aA().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let l,u,h=null;if("complex64"!==r&&aA().get("WEBGL_BUFFER_SUPPORTED")){l=this.decode(t);const e=this.texData.get(l.dataId);h=this.gpgpu.createBufferFromTexture(e.texture.texture,...u7(i))}if(this.pendingRead.set(t,[]),"complex64"!==r&&await this.gpgpu.createAndWaitForFence(),"complex64"===r){const t=await Promise.all([this.read(a.real.dataId),this.read(a.imag.dataId)]);u=AG(t[0],t[1])}else if(null==h)u=this.getValuesFromTexture(t);else{const t=IO(i);u=this.gpgpu.downloadFloat32MatrixFromBuffer(h,t)}if(null!=l&&this.disposeIntermediateTensorInfo(l),null!=h){const t=this.gpgpu.gl;c7(t,(()=>t.deleteBuffer(h)))}const p=this.convertAndCacheOnCPU(t,u),c=this.pendingRead.get(t);return this.pendingRead.delete(t),c.forEach((t=>t(p))),this.pendingDisposal.has(t)&&(this.pendingDisposal.delete(t),this.disposeData(t)&&TD().removeDataId(t,this),this.pendingDeletes--),p}readToGPU(t,e={}){const n=this.texData.get(t),{values:i,shape:s,slice:r,dtype:a,isPacked:o,texture:l}=n;if("complex64"===a)throw new Error("Does not support reading texture for complex64 dtype.");if(null!=r){let n;n=o?new Mnt(s,vnt):new gnt(s,vnt);const i=this.runWebGLProgram(n,[{dataId:t,shape:s,dtype:a}],a),r=this.readToGPU(i,e);return this.disposeIntermediateTensorInfo(i),r}if(null==l)throw null!=i?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const u=this.decode(t,e.customTexShape),h=TD().makeTensorFromTensorInfo(u),p=this.texData.get(u.dataId);return Object.assign({tensorRef:h},p.texture)}bufferSync(t){const e=this.readSync(t.dataId);if("string"===t.dtype)try{const n=e.map((t=>lk(t)));return FL(t.shape,t.dtype,n)}catch(t){throw new Error("Failed to decode encoded string bytes into utf-8")}return FL(t.shape,t.dtype,e)}checkNumericalProblems(t){if(null!=t)for(let e=0;e<t.length;e++){const n=t[e];if(!m7(n)){if(aA().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error(`The value ${n} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`);throw Error(`The value ${n} cannot be represented on this device.`)}}}getValuesFromTexture(t){const{shape:e,dtype:n,isPacked:i}=this.texData.get(t),s=IO(e);if(aA().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){const n=this.decode(t),i=this.texData.get(n.dataId),r=this.gpgpu.downloadMatrixFromPackedTexture(i.texture.texture,...u7(e)).subarray(0,s);return this.disposeIntermediateTensorInfo(n),r}const r=aA().getBool("WEBGL_PACK")&&!0===i,a=r?z7(e):e,o=r?new $tt(a):new Ptt(a),l=this.runWebGLProgram(o,[{shape:a,dtype:n,dataId:t}],"float32"),u=this.texData.get(l.dataId),h=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(u.texture.texture,u.texShape[0],u.texShape[1]).subarray(0,s);return this.disposeIntermediateTensorInfo(l),h}timerAvailable(){return aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}time(t){const e=this.activeTimers,n=[];let i=!1;null==this.programTimersStack?(this.programTimersStack=n,i=!0):this.activeTimers.push(n),this.activeTimers=n,t();const s=hk(this.activeTimers.map((t=>t.query))).filter((t=>null!=t)),r=hk(this.activeTimers.map((t=>t.name))).filter((t=>null!=t));this.activeTimers=e,i&&(this.programTimersStack=null);const a={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const t=await Promise.all(s);a.kernelMs=fO(t),a.getExtraProfileInfo=()=>t.map(((t,e)=>({name:r[e],ms:t}))).map((t=>`${t.name}: ${t.ms}`)).join(", ")}else a.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,a})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:rk(),endMs:null}}endTimer(t){return aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),t):(t.endMs=rk(),t)}async getQueryTime(t){if(aA().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(t);const e=t;return e.endMs-e.startMs}disposeData(t,e=!1){if(this.pendingDisposal.has(t))return!1;if(!this.texData.has(t))return!0;if(e?this.texData.get(t).refCount=0:this.texData.get(t).refCount--,!e&&this.texData.get(t).refCount>0)return!1;if(this.pendingRead.has(t))return this.pendingDisposal.add(t),this.pendingDeletes++,!1;this.releaseGPUData(t);const{complexTensorInfos:n}=this.texData.get(t);return null!=n&&(this.disposeData(n.real.dataId,e),this.disposeData(n.imag.dataId,e)),this.texData.delete(t),!0}releaseGPUData(t){const{texture:e,dtype:n,texShape:i,usage:s,isPacked:r,slice:a}=this.texData.get(t),o=a&&a.origDataId||t,l=this.dataRefCount.get(o);l>1?this.dataRefCount.set(o,l-1):(this.dataRefCount.delete(o),null!=e&&(this.numBytesInGPU-=this.computeBytes(i,n),this.textureManager.releaseTexture(e,i,s,r)));const u=this.texData.get(t);u.texture=null,u.texShape=null,u.isPacked=!1,u.slice=null}getTexture(t){return this.uploadToGPU(t),this.texData.get(t).texture.texture}getDataInfo(t){return this.texData.get(t)}shouldExecuteOnCPU(t,e=Dnt){return aA().getBool("WEBGL_CPU_FORWARD")&&t.every((t=>null==this.texData.get(t.dataId).texture&&IO(t.shape)<e))}getGPGPUContext(){return this.gpgpu}where(t){AN("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");const e=t.dataSync();return Nnt(t.shape,e)}packedUnaryOp(t,e,n){const i=new Mnt(t.shape,e),s=this.compileAndRun(i,[t],n);return TD().makeTensorFromTensorInfo(s)}abs(t){if(this.shouldExecuteOnCPU([t])&&"complex64"!==t.dtype){const e=zet(this.texData.get(t.dataId).values);return this.makeOutput(t.shape,t.dtype,e)}if(aA().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,ynt,t.dtype);const e=new gnt(t.shape,ynt),n=this.compileAndRun(e,[t]);return TD().makeTensorFromTensorInfo(n)}makeTensorInfo(t,e,n){let i;if("string"===e&&null!=n&&n.length>0&&VO(n[0])){const s=n.map((t=>ok(t)));i=this.write(s,t,e)}else i=this.write(n,t,e);return this.texData.get(i).usage=null,{dataId:i,shape:t,dtype:e}}makeOutput(t,e,n){return TD().makeTensorFromTensorInfo(this.makeTensorInfo(t,e,n),this)}unpackTensor(t){const e=new Cnt(t.shape);return this.runWebGLProgram(e,[t],t.dtype)}packTensor(t){const e=new hnt(t.shape);return this.runWebGLProgram(e,[t],t.dtype,null,!0)}packedReshape(t,e){const n=[H7(t.shape),...W7(t.shape)],i={dtype:t.dtype,shape:n,dataId:t.dataId},s=[H7(e),...W7(e)],r=new pnt(s,n),a=[n],o=this.runWebGLProgram(r,[i],t.dtype,a,!0);return{dataId:o.dataId,shape:e,dtype:o.dtype}}decode(t,e){const n=this.texData.get(t),{isPacked:i,shape:s,dtype:r}=n;if(null!=e){_O(IO(s)<=e[0]*e[1]*4,(()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data."))}const a=z7(s);let o;o=i?new Ftt(a):new Ltt(a);const l=[null!=e?e:u7(a)];return{dtype:r,shape:s,dataId:this.runWebGLProgram(o,[{shape:a,dtype:r,dataId:t}],r,l,!0,e).dataId}}runWebGLProgram(t,e,n,i,s=!1,r){const a=this.makeTensorInfo(t.outputShape,n),o=this.texData.get(a.dataId);if(t.packedOutput&&(o.isPacked=!0),t.outPackingScheme===r7.DENSE){const e=null!=r?r:u7(t.outputShape);o.texShape=e.map((t=>2*t))}if(null!=t.outTexUsage&&(o.usage=t.outTexUsage),0===IO(a.shape))return o.values=kO(a.dtype,0),a;const l=[],u=e.map((e=>{if("complex64"===e.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let n=this.texData.get(e.dataId);if(null==n.texture){if(!t.packedInputs&&IO(e.shape)<=aA().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:e.shape,texData:null,isUniform:!0,uniformValues:n.values};t.packedInputs&&(n.isPacked=!0,n.shape=e.shape)}if(this.uploadToGPU(e.dataId),!!n.isPacked!=!!t.packedInputs)e=n.isPacked?this.unpackTensor(e):this.packTensor(e),l.push(e),n=this.texData.get(e.dataId);else if(n.isPacked&&!q7(n.shape,e.shape)){const t=e,i=e.shape;e.shape=n.shape,e=this.packedReshape(e,i),l.push(e),n=this.texData.get(e.dataId),t.shape=i}return{shape:e.shape,texData:n,isUniform:!1}}));this.uploadToGPU(a.dataId);const h={shape:a.shape,texData:o,isUniform:!1},p=function(t,e,n){let i="";e.concat(n).forEach((e=>{const s=null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0;if(t.enableShapeUniforms&&!e.isUniform){const r=e.texData.texShape,{useSqueezeShape:a,uniformShape:o,keptDims:l}=Att(t.packedInputs,e.shape,r);let u="",h="",p="";if(1===o.length&&t.packedInputs){const t=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)];u=`${t[0]>1}_${t[1]>1}`}else if(2!==o.length||t.packedInputs){if(o.length>2&&!t.packedInputs){const t=zO(o);p=`${t[0]===r[1]}_${t[t.length-1]===r[1]}`}}else h=`${o[0]>1}_${o[1]>1}`;const c=e.shape.length,d=2===o.length&&vO(e.shape,r),f=1===IO(e.shape),m=mF(e.shape,n.shape),g=!t.packedInputs&&c===n.shape.length&&vO(r,n.texData.texShape),_=t.packedInputs||o.length>2?"":`${r[0]>1}_${r[1]>1}`;i+=`${c}_${g}_${a?l:""}_${o.length}_${f}_${m}_${d}_${u}_${h}_${p}_${_}_${s}`}else{const t=e.isUniform?"uniform":e.texData.texShape;i+=`${e.shape}_${t}_${s}`}}));const s=t.userCode;let r=t.constructor.name;return r+="_"+i+"_"+s+`${aA().getNumber("WEBGL_VERSION")}`,r}(t,u,h),c=this.getAndSaveBinary(p,(()=>
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i){const s=n.map(((t,n)=>{const i={logicalShape:t.shape,texShape:t.isUniform?null:t.texData.texShape,isUniform:t.isUniform,isPacked:!t.isUniform&&t.texData.isPacked,flatOffset:null};return null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0&&(i.flatOffset=t.texData.slice.flatOffset),{name:e.variableNames[n],shapeInfo:i}})),r=s.map((t=>t.shapeInfo)),a={logicalShape:i.shape,texShape:i.texData.texShape,isUniform:!1,isPacked:i.texData.isPacked,flatOffset:null},o=Ttt(s,a,e),l=y7(t.gl,o),u=t.createProgram(l);return aA().get("ENGINE_COMPILE_ONLY")?{program:e,fragmentShader:l,source:o,webGLProgram:u,inShapeInfos:r,outShapeInfo:a,variablesLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:(t.buildVao(u),Object.assign({program:e,fragmentShader:l,source:o,webGLProgram:u,inShapeInfos:r,outShapeInfo:a},Ntt(t,e,u)))}(this.gpgpu,t,u,h))),d=null!=this.activeTimers;let f;d&&(f=this.startTimer()),aA().get("ENGINE_COMPILE_ONLY")||function(t,e,n,i,s){e.program.enableShapeUniforms||(ktt(e.inShapeInfos,n),ktt([e.outShapeInfo],[i]));const r=i.texData.texture,a=i.texData.texShape;i.texData.isPacked?t.setOutputPackedMatrixTexture(r.texture,a[0],a[1]):t.setOutputMatrixTexture(r.texture,a[0],a[1]),t.setProgram(e.webGLProgram),t.bindVertexArray(e.webGLProgram.vao),1===aA().getNumber("WEBGL_VERSION")&&null!==e.infLoc&&t.gl.uniform1f(e.infLoc,1/0),null!==e.nanLoc&&t.gl.uniform1f(e.nanLoc,NaN);for(let i=0;i<n.length;++i){const s=n[i],{uniform:r,offset:a,shape:o,texShape:l}=e.variablesLocations[i];if(o){const{uniformShape:n}=Att(e.program.packedInputs,s.shape,s.texData.texShape);switch(n.length){case 1:t.gl.uniform1iv(o,new Int32Array(n));break;case 2:t.gl.uniform2iv(o,new Int32Array(n));break;case 3:t.gl.uniform3iv(o,new Int32Array(n));break;case 4:t.gl.uniform4iv(o,new Int32Array(n))}}if(l&&t.gl.uniform2i(l,s.texData.texShape[0],s.texData.texShape[1]),null!=r)if(s.isUniform)if(IO(s.shape)<2)t.gl.uniform1f(r,s.uniformValues[0]);else{let e=s.uniformValues;e instanceof Float32Array||(e=new Float32Array(e)),t.gl.uniform1fv(r,e)}else null!=s.texData.slice&&null!=a&&t.gl.uniform1i(a,s.texData.slice.flatOffset),t.setInputMatrixTexture(s.texData.texture.texture,r,i)}const o=e.outShapeLocation;if(o)switch(i.shape.length){case 1:t.gl.uniform1iv(o,new Int32Array(i.shape));break;case 2:t.gl.uniform2iv(o,new Int32Array(i.shape));break;case 3:t.gl.uniform3iv(o,new Int32Array(i.shape));break;case 4:t.gl.uniform4iv(o,new Int32Array(i.shape))}if(e.outShapeStridesLocation){const n=zO(i.shape);switch(i.shape.length){case 2:t.gl.uniform1iv(e.outShapeStridesLocation,new Int32Array(n));break;case 3:t.gl.uniform2iv(e.outShapeStridesLocation,new Int32Array(n));break;case 4:t.gl.uniform3iv(e.outShapeStridesLocation,new Int32Array(n))}}if(e.outTexShapeLocation&&t.gl.uniform2i(e.outTexShapeLocation,i.texData.texShape[0],i.texData.texShape[1]),e.program.customUniforms&&s)for(let n=0;n<e.program.customUniforms.length;++n){const i=e.program.customUniforms[n],r=e.customUniformLocations[n],a=s[n];if("float"===i.type)t.gl.uniform1fv(r,a);else if("vec2"===i.type)t.gl.uniform2fv(r,a);else if("vec3"===i.type)t.gl.uniform3fv(r,a);else if("vec4"===i.type)t.gl.uniform4fv(r,a);else if("int"===i.type)t.gl.uniform1iv(r,a);else if("ivec2"===i.type)t.gl.uniform2iv(r,a);else if("ivec3"===i.type)t.gl.uniform3iv(r,a);else{if("ivec4"!==i.type)throw Error(`uniform type ${i.type} is not supported yet.`);t.gl.uniform4iv(r,a)}}t.executeProgram()}(this.gpgpu,c,u,h,i),l.forEach((t=>this.disposeIntermediateTensorInfo(t))),d&&(f=this.endTimer(f),this.activeTimers.push({name:t.constructor.name,query:this.getQueryTime(f)}));const m=aA().getNumber("WEBGL_FLUSH_THRESHOLD");if(m>0){const t=rk();t-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=t)}if(!aA().getBool("WEBGL_LAZILY_UNPACK")&&o.isPacked&&!1===s){const t=this.unpackTensor(a);return this.disposeIntermediateTensorInfo(a),t}return a}compileAndRun(t,e,n,i,s=!1){n=n||e[0].dtype;return this.runWebGLProgram(t,e,n,i,s)}getAndSaveBinary(t,e){return t in this.binaryCache||(this.binaryCache[t]=e()),this.binaryCache[t]}getTextureManager(){return this.textureManager}dispose(){if(!this.disposed){if(!aA().getBool("IS_TEST")){Object.keys(this.binaryCache).forEach((t=>{this.gpgpu.deleteProgram(this.binaryCache[t].webGLProgram),delete this.binaryCache[t]}))}this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0}}floatPrecision(){return null==this.floatPrecisionValue&&(this.floatPrecisionValue=ED((()=>{if(!aA().get("WEBGL_RENDER_FLOAT32_ENABLED")){const t=aA().getBool("DEBUG");aA().set("DEBUG",!1);const e=this.abs(tF(1e-8)).dataSync()[0];if(aA().set("DEBUG",t),e>0)return 32}return 16}))),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}uploadToGPU(t){const e=this.texData.get(t),{shape:n,dtype:i,values:s,texture:r,usage:a,isPacked:o}=e;if(null!=r)return;const l=null!=this.activeTimers;let u;l&&(u=rk());let h=e.texShape;if(null==h&&(h=X7(n,o),e.texShape=h),null!=s){const t=z7(n);let r,a=h[1],p=h[0];const c=s instanceof Uint8Array||s instanceof Uint8ClampedArray;!o&&c||([a,p]=h7(h[0],h[1])),r=o?new Utt(t,c):new Vtt(t,c);const d=c?[p,a]:h,f=this.makeTensorInfo(d,i),m=this.texData.get(f.dataId);m.usage=c?a7.PIXELS:a7.UPLOAD,m.texShape=d,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(f.dataId),a,p,s);const g=[[p,a]],_=!0,T=this.runWebGLProgram(r,[f],i,g,_),y=this.texData.get(T.dataId);e.texShape=y.texShape,e.isPacked=y.isPacked,e.usage=y.usage,aA().get("ENGINE_COMPILE_ONLY")?this.disposeData(T.dataId):(e.texture=y.texture,e.values=null,this.texData.delete(T.dataId)),this.disposeIntermediateTensorInfo(f),l&&(this.uploadWaitMs+=rk()-u)}else{const t=this.acquireTexture(h,a,i,o);e.texture=t}}convertAndCacheOnCPU(t,e){const n=this.texData.get(t),{dtype:i}=n;return null!=e&&(n.values=function(t,e){if("float32"===e||"complex64"===e)return t;if("int32"===e||"bool"===e){const n="int32"===e?new Int32Array(t.length):new Uint8Array(t.length);for(let e=0;e<n.length;++e)n[e]=Math.round(t[e]);return n}throw new Error(`Unknown dtype ${e}`)}(e,i)),n.values}acquireTexture(t,e,n,i){if(this.numBytesInGPU+=this.computeBytes(t,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){const t=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${t} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(t,e,i)}computeBytes(t,e){return t[0]*t[1]*$O(e)}checkCompileCompletion(){for(const[,t]of Object.entries(this.binaryCache))this.checkCompletion_(t)}async checkCompileCompletionAsync(){const t=[];if(this.gpgpu.parallelCompilationExtension){for(const[,e]of Object.entries(this.binaryCache))t.push(this.checkCompletionAsync_(e));return Promise.all(t)}for(const[,e]of Object.entries(this.binaryCache)){const n=new Promise((t=>{try{this.checkCompletion_(e),t(!0)}catch(t){throw t}}));t.push(n)}return Promise.all(t)}async checkCompletionAsync_(t){return this.gpgpu.gl.getProgramParameter(t.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(t):(await rG(),this.checkCompletionAsync_(t))}checkCompletion_(t){if(!1===this.gpgpu.gl.getProgramParameter(t.webGLProgram,this.gpgpu.gl.LINK_STATUS)){if(console.log(this.gpgpu.gl.getProgramInfoLog(t.webGLProgram)),!1===this.gpgpu.gl.getShaderParameter(t.fragmentShader,this.gpgpu.gl.COMPILE_STATUS))throw E7(t.source,this.gpgpu.gl.getShaderInfoLog(t.fragmentShader)),new Error("Failed to compile fragment shader.");throw new Error("Failed to link vertex and fragment shaders.")}return!0}getUniformLocations(){for(const t of Object.values(this.binaryCache)){this.gpgpu.buildVao(t.webGLProgram);const{variablesLocations:e,customUniformLocations:n,infLoc:i,nanLoc:s,outShapeLocation:r,outShapeStridesLocation:a,outTexShapeLocation:o}=Ntt(this.gpgpu,t.program,t.webGLProgram);t.variablesLocations=e,t.customUniformLocations=n,t.infLoc=i,t.nanLoc=s,t.outShapeLocation=r,t.outShapeStridesLocation=a,t.outTexShapeLocation=o}}createTensorFromGPUData(t,e,n){t.channels=t.channels||"RGBA";const{texture:i,height:s,width:r,channels:a}=t,o=TD().backend;if(!o.gpgpu.gl.isTexture(i))throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'.");const l=o.writeTexture(i,e,n,s,r,a);return TD().makeTensorFromDataId(l,e,n,o)}}Lnt.nextDataId=0;
/** @license See the LICENSE file. */
const Fnt="4.22.0";
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Pnt(){aA().set("WEBGL_FORCE_F16_TEXTURES",!0)}
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
Zk()&&CD("webgl",(()=>new Lnt),2);const $nt={forceHalfFloat:Pnt},Bnt="\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n";class Vnt{constructor(t,e,n){this.variableNames=["A","B"],this.outputShape=_F(e,n),this.enableShapeUniforms=Dtt(this.outputShape.length),this.userCode=`\n float binaryOperation(float a, float b) {\n ${t}\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n `}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const Unt="\n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n";class Ynt{constructor(t,e,n,i=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=_F(e,n);const s=this.outputShape.length;this.enableShapeUniforms=Dtt(s);let r="";if(i)if(0===s||1===IO(this.outputShape))r="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else{if(r=`\n ${Ott(s)} coords = getOutputCoords();\n `,1===s)this.enableShapeUniforms?r+="\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ":r+=`\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `;else{const t=unt("coords",s);this.enableShapeUniforms?r+=`\n bool nextRowOutOfBounds =\n (${t[s-2]} + 1) >= outShape[${s} - 2];\n bool nextColOutOfBounds =\n (${t[s-1]} + 1) >= outShape[${s} - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `:r+=`\n bool nextRowOutOfBounds =\n (${t[s-2]} + 1) >= ${this.outputShape[s-2]};\n bool nextColOutOfBounds =\n (${t[s-1]} + 1) >= ${this.outputShape[s-1]};\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `}}this.userCode=`\n vec4 binaryOperation(vec4 a, vec4 b) {\n ${t}\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n ${r}\n\n setOutput(result);\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Gnt(t){const{inputs:e,backend:n}=t,{x:i}=e;return n.incRef(i.dataId),{dataId:i.dataId,shape:i.shape,dtype:i.dtype}}const Hnt={kernelName:RM,backendName:"webgl",kernelFunc:Gnt};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Wnt(t){const{inputs:e,backend:n}=t,{real:i,imag:s}=e,r=n.makeTensorInfo(i.shape,"complex64"),a=n.texData.get(r.dataId),o=Gnt({inputs:{x:i},backend:n}),l=Gnt({inputs:{x:s},backend:n});return a.complexTensorInfos={real:o,imag:l},r}const znt={kernelName:$A,backendName:"webgl",kernelFunc:Wnt},Xnt="return (a < 0.) ? b * a : a;",jnt="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";const qnt={kernelName:kM,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{alpha:r}=i,a=n.makeTensorInfo([],"float32",ik(r,"float32")),o=aA().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Ynt(jnt,s.shape,a.shape):new Vnt(Xnt,s.shape,a.shape),l=n.runWebGLProgram(o,[s,a],"float32");return n.disposeIntermediateTensorInfo(a),l}},Knt="return (a < 0.) ? b * a : a;",Qnt="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";const Jnt={kernelName:yC,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{x:i,alpha:s}=e,r=aA().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Ynt(Qnt,i.shape,s.shape):new Vnt(Knt,i.shape,s.shape);return n.runWebGLProgram(r,[i,s],"float32")}},Znt="if (isnan(x)) return x;";function tit({opSnippet:t,packedOpSnippet:e,cpuKernelImpl:n,dtype:i}){return({inputs:s,backend:r})=>{const{x:a}=s,o=r,l=i||a.dtype;if(o.shouldExecuteOnCPU([a])&&null!=n){const t=o.texData.get(a.dataId),e=n(t.values,l);return o.makeTensorInfo(a.shape,l,e)}let u;return u=aA().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=e?new Mnt(a.shape,e):new gnt(a.shape,t),o.runWebGLProgram(u,[a],l)}}function eit({opSnippet:t,packedOpSnippet:e,checkOutOfBounds:n=!1,supportsComplex:i=!1,cpuKernelImpl:s,dtype:r}){return({inputs:a,backend:o})=>{const{a:l,b:u}=a,h=o;if(i&&"complex64"===l.dtype){const e=h.texData.get(l.dataId),n=h.texData.get(u.dataId),[i,s]=[[e.complexTensorInfos.real,n.complexTensorInfos.real],[e.complexTensorInfos.imag,n.complexTensorInfos.imag]].map((e=>{const[n,i]=e,s={dataId:n.dataId,dtype:n.dtype,shape:l.shape},r={dataId:i.dataId,dtype:i.dtype,shape:u.shape},a=new Vnt(t,l.shape,u.shape);return h.runWebGLProgram(a,[s,r],Lk(n.dtype,i.dtype))})),r=Wnt({inputs:{real:i,imag:s},backend:h});return h.disposeIntermediateTensorInfo(i),h.disposeIntermediateTensorInfo(s),r}const p=r||Lk(l.dtype,u.dtype);if(("string"===l.dtype||"string"===u.dtype||h.shouldExecuteOnCPU([l,u]))&&null!=s){const t=h.texData.get(l.dataId).values,e=h.texData.get(u.dataId).values,n="string"===l.dtype?uH(t):t,i="string"===l.dtype?uH(e):e,[r,a]=s(l.shape,u.shape,n,i,p),o=h.makeTensorInfo(a,p);return h.texData.get(o.dataId).values=r,o}let c;return c=aA().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=e?new Ynt(e,l.shape,u.shape,n):new Vnt(t,l.shape,u.shape),h.runWebGLProgram(c,[l,u],p)}}function nit(t,e=!1){if("linear"===t)return e?Snt:Tnt;if("relu"===t)return e?Rnt:Ent;if("elu"===t)return e?xnt:Int;if("relu6"===t)return e?Ont:bnt;if("prelu"===t)return e?Qnt:Knt;if("leakyrelu"===t)return e?jnt:Xnt;if("sigmoid"===t)return e?Ant:wnt;throw new Error(`Activation ${t} has not been implemented for the WebGL backend.`)}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class iit{constructor(t,e,n,i=!1,s=!1,r=!1,a=null,o=!1,l=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=Dtt(this.outputShape.length);const u=i?t[1]:t[2],h=Math.ceil(u/2),p=i?"i * 2, rc.y":"rc.y, i * 2",c=s?"rc.z, i * 2":"i * 2, rc.z",d=i?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=s?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",g="";a&&(m=o?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${a}\n }`:l?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${a}\n }`:`vec4 activation(vec4 x) {\n ${a}\n }`,g="result = activation(result);");const _=r?"result += getBiasAtOutCoords();":"";r&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),l&&this.variableNames.push("leakyreluAlpha");let T="rc.x",y="rc.x";t[0]<e[0]?T=`imod(rc.x, ${t[0]})`:e[0]<t[0]&&(y=`imod(rc.x, ${e[0]})`),this.userCode=`\n ${m}\n // Don't use uniform for sharedDimensionPacked for performance.\n const float sharedDimension = ${h}.0;\n\n vec4 dot2x2ARowBCol(ivec3 rc) {\n vec4 result = vec4(0);\n int batchA = ${T};\n int batchB = ${y};\n for (int i = 0; i < ${h}; i++) {\n vec4 a = getMatrixA(batchA, ${p});\n vec4 b = getMatrixB(batchB, ${c});\n\n // These swizzled products need to be separately added.\n // See: https://github.com/tensorflow/tfjs/issues/1735\n result += (${d[0]} * ${f[0]});\n result += (${d[1]} * ${f[1]});\n }\n return result;\n }\n\n void main() {\n ivec3 rc = getOutputCoords();\n vec4 result = dot2x2ARowBCol(rc);\n\n ${_}\n\n ${g}\n\n setOutput(result);\n }\n `}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const sit={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class rit{constructor(t,e,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=_F(e,n),this.userCode=`\n float binaryOpComplex(\n float areal, float aimag, float breal, float bimag) {\n ${t}\n }\n\n void main() {\n float areal = getARealAtOutCoords();\n float aimag = getAImagAtOutCoords();\n float breal = getBRealAtOutCoords();\n float bimag = getBImagAtOutCoords();\n setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const ait="return a * b;";function oit(t){const{inputs:e,backend:n}=t,{a:i,b:s}=e,r=Lk(i.dtype,s.dtype);if("complex64"===i.dtype){const t=n.texData.get(i.dataId),e=n.texData.get(s.dataId),r=new rit(sit.REAL,i.shape,s.shape),a=new rit(sit.IMAG,i.shape,s.shape),o=[{dataId:t.complexTensorInfos.real.dataId,dtype:t.complexTensorInfos.real.dtype,shape:i.shape},{dataId:t.complexTensorInfos.imag.dataId,dtype:t.complexTensorInfos.imag.dtype,shape:i.shape},{dataId:e.complexTensorInfos.real.dataId,dtype:e.complexTensorInfos.real.dtype,shape:s.shape},{dataId:e.complexTensorInfos.imag.dataId,dtype:e.complexTensorInfos.imag.dtype,shape:s.shape}],l=n.runWebGLProgram(r,o,"float32"),u=n.runWebGLProgram(a,o,"float32"),h=Wnt({inputs:{real:l,imag:u},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(u),h}if(n.shouldExecuteOnCPU([i,s])){const t=n.texData.get(i.dataId),e=n.texData.get(s.dataId),[a,o]=Let(i.shape,s.shape,t.values,e.values,r),l=n.makeTensorInfo(o,r);return n.texData.get(l.dataId).values=a,l}let a;return a=aA().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Ynt(ait,i.shape,s.shape):new Vnt(ait,i.shape,s.shape),n.runWebGLProgram(a,[i,s],r)}const lit={kernelName:oC,backendName:"webgl",kernelFunc:oit};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function uit(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{shape:r}=i,a=n,o=IO(s.shape),l=MO(r,o),u=IO(l);_O(o===u,(()=>`The new shape (${l}) has ${u} elements and the old shape (${s.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`));const h=a.texData.get(s.dataId);return!h.isPacked||q7(s.shape,l)||null!==h.texture&&q7(h.shape,l)?(a.incRef(s.dataId),{dataId:s.dataId,shape:l,dtype:s.dtype}):
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n){const i=[H7(t.shape),...W7(t.shape)],s={dtype:t.dtype,shape:i,dataId:t.dataId},r=[H7(e),...W7(e)],a=new pnt(r,i),o=[i],l=n.runWebGLProgram(a,[s],t.dtype,o,!0);return{dataId:l.dataId,shape:e,dtype:l.dtype}}(s,l,a)}const hit={kernelName:OC,backendName:"webgl",kernelFunc:uit};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class pit{constructor(t,e){this.variableNames=["x"];const{windowSize:n,batchSize:i,inSize:s,outSize:r}=t;this.outputShape=[i,r];const a=4*Math.floor(n/4),o=n%4;let l="sumValue += dot(values, ones);";if(null!=e){const t=1/e;l=`sumValue += dot(values * ${wO(t)?t.toPrecision(2):t}, ones);`}let u="";s%n>0&&(u=`\n if (inIdx < 0 || inIdx >= ${s}) {\n return 0.0;\n }\n `),this.userCode=`\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${u}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${a}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${l}\n }\n\n int inIdx = inOffset + ${a};\n if (${1===o}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${l}\n } else if (${2===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${l}\n } else if (${3===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ${l}\n }\n setOutput(sumValue);\n }\n `}}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class cit{constructor(t,e){this.variableNames=["x"];const{windowSize:n,batchSize:i,inSize:s,outSize:r}=t;this.outputShape=[i,r];let a="0.0",o="";"prod"===e?a="1.0":"min"===e?(a="1.0 / 1e-20",o="min"):"max"===e&&(a="-1.0 / 1e-20",o="max");let l=`${e}(${e}(${e}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===e?l="sumValue":"prod"===e?l="prodValue":"all"===e?l="allValue":"any"===e&&(l="anyValue");const u=4*Math.floor(n/4),h=n%4;let p=`\n if (${"sum"===e}) {\n sumValue += dot(values, ones);\n } else if (${"prod"===e}) {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = ${o}(values, minMaxValue);\n if (${"min"===e} || ${"max"===e}) {\n minMaxValue = ${o}(values, minMaxValue);\n bvec4 isNaN = isnan(values);\n if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {\n minMaxValue = vec4(NAN);\n }\n }\n }\n `,c="vec4";"all"===e?(a="1.0",p="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",c="bvec4"):"any"===e&&(a="0.0",p="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",c="bvec4");let d="";s%n>0&&(d=`\n if (inIdx < 0 || inIdx >= ${s}) {\n return initializationValue;\n }\n `),this.userCode=`\n const float initializationValue = ${a};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${d}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n vec4 minMaxValue = vec4(${a});\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < ${u}; i += 4) {\n int inIdx = inOffset + i;\n ${c} values = ${c}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${p}\n }\n\n int inIdx = inOffset + ${u};\n if (${1===h}) {\n ${c} values = ${c}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${2===h}) {\n ${c} values = ${c}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${p}\n } else if (${3===h}) {\n ${c} values = ${c}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${p}\n }\n setOutput(${l});\n }\n `}}function dit(t,e,n,i){const s=
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const e=[];for(;0===e.length||1!==e[e.length-1].outSize;){const n=e.length?e[e.length-1].outSize:t[1],i=fG(n);e.push({inSize:n,windowSize:i,outSize:Math.ceil(n/i)})}return e}(t.shape);let r=t;for(let a=0;a<s.length;a++){const{inSize:o,windowSize:l,outSize:u}=s[a];let h,p;h="mean"===n?0===a?new pit({windowSize:l,inSize:o,batchSize:t.shape[0],outSize:u},o):new pit({windowSize:l,inSize:o,batchSize:t.shape[0],outSize:u}):new cit({windowSize:l,inSize:o,batchSize:t.shape[0],outSize:u},n),p=r,r=i.runWebGLProgram(h,[r],e),p.dataId!==t.dataId&&i.disposeIntermediateTensorInfo(p)}return r}
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class fit{constructor(t,e){this.variableNames=["A"];const n=new Array(t.length);for(let i=0;i<n.length;i++)n[i]=t[e[i]];this.outputShape=n,this.rank=n.length;const i=Ott(this.rank),s=function(t){const e=t.length;if(e>6)throw Error(`Transpose for rank ${e} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],i=new Array(e);for(let e=0;e<t.length;e++)i[t[e]]=n[e];return i.join()}(e);this.userCode=`\n void main() {\n ${i} resRC = getOutputCoords();\n setOutput(getA(${s}));\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class mit{constructor(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;const n=new Array(t.length);for(let i=0;i<n.length;i++)n[i]=t[e[i]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const i=Ott(this.rank),s=lnt("rc",this.rank),r=new Array(this.rank);for(let t=0;t<e.length;t++)r[e[t]]=s[t];const a=`vec2(${r.slice(-2).join()})`,o=`++${s[this.rank-1]} < ${n[this.rank-1]}`,l=`getChannel(getA(${r.join()}), ${a})`;this.userCode=`\n void main() {\n ${i} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result[0] = ${l};\n if(${o}) {\n result[1] = ${l};\n }\n --${s[this.rank-1]};\n if(++${s[this.rank-2]} < ${n[this.rank-2]}) {\n result[2] = ${l};\n if(${o}) {\n result[3] = ${l};\n }\n }\n setOutput(result);\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function git(t,e,n){const i=aA().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new mit(t.shape,e):new fit(t.shape,e);return n.runWebGLProgram(i,[t],t.dtype)}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function _it(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i;
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
return function(t,e,n,i){const s=e,r=t.shape.length,a=CO(s,t.shape);let o=a;const l=_B(o,r),u=null!=l;let h=t;u&&(h=git(t,l,i),o=yB(o.length,r)),gB("sum",o,r);const[p,c]=fB(h.shape,o);let d=p;n&&(d=mB(p,a));const f=IO(c),m=uit({inputs:{x:h},attrs:{shape:[IO(t.shape)/f,f]},backend:i}),g=dit(m,Fk(t.dtype),"sum",i),_=uit({inputs:{x:g},attrs:{shape:d},backend:i});return i.disposeIntermediateTensorInfo(m),i.disposeIntermediateTensorInfo(g),u&&i.disposeIntermediateTensorInfo(h),_}(s,r,a,n)}const Tit={kernelName:qC,backendName:"webgl",kernelFunc:_it};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function yit(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{perm:r}=i,a=n,o=s.shape.length,l=new Array(o);for(let t=0;t<l.length;t++)l[t]=s.shape[r[t]];let u;if(a.shouldExecuteOnCPU([s])){const t=a.texData.get(s.dataId).values,e=ant(t,s.shape,s.dtype,r,l);u=a.makeTensorInfo(l,s.dtype);a.texData.get(u.dataId).values=e}else u=git(s,r,a);return u}const Iit={kernelName:_N,backendName:"webgl",kernelFunc:yit},Eit=1e3;function bit({a:t,b:e,transposeA:n,transposeB:i,backend:s,bias:r=null,preluActivationWeights:a=null,leakyreluAlpha:o=0,activation:l=null}){const u=t.shape.length,h=e.shape.length,p=n?t.shape[u-2]:t.shape[u-1],c=i?e.shape[h-1]:e.shape[h-2],d=n?t.shape[u-1]:t.shape[u-2],f=i?e.shape[h-2]:e.shape[h-1],m=t.shape.slice(0,-2),g=e.shape.slice(0,-2),_=IO(m),T=IO(g),y=_F(t.shape.slice(0,-2),e.shape.slice(0,-2)).concat([d,f]);_O(p===c,(()=>`Error in matMul: inner shapes (${p}) and (${c}) of Tensors with shapes ${t.shape} and ${e.shape} and transposeA=${n} and transposeB=${i} must match.`));const I=n?[_,p,d]:[_,d,p],E=i?[T,f,c]:[T,c,f],b=uit({inputs:{x:t},backend:s,attrs:{shape:I}}),v=uit({inputs:{x:e},backend:s,attrs:{shape:E}}),w=[b,v],S=Math.max(_,T),x=n?b.shape[1]:b.shape[2],R=null!=r,O=null!=a,A="leakyrelu"===l,M=null!=l?nit(l,!0):null;let C;if((1===d||1===f)&&x>Eit&&!1===(R||O||A||null!=M)){let t=b,e=v;n&&(t=yit({inputs:{x:b},backend:s,attrs:{perm:[0,2,1]}}),w.push(t)),i&&(e=yit({inputs:{x:v},backend:s,attrs:{perm:[0,2,1]}}),w.push(e));const r=1===f;let a=t;1!==f&&(a=uit({inputs:{x:t},backend:s,attrs:{shape:[S,x,1]}}),w.push(a));const o=1===f?2:1;let l=e;r&&(l=uit({inputs:{x:e},backend:s,attrs:{shape:[S,1,x]}}),w.push(l));const u=oit({inputs:{a,b:l},backend:s});C=_it({inputs:{x:u},backend:s,attrs:{axis:o,keepDims:!0}}),w.push(u)}else{const l=Lk(t.dtype,e.dtype),u=new iit(I,E,[S,d,f],n,i,R,M,O,A),h=[b,v];if(null!=r&&h.push(r),O&&h.push(a),A){const t=s.makeTensorInfo([],"float32",ik(o,"float32"));h.push(t),w.push(t)}C=s.runWebGLProgram(u,h,l)}const N=uit({inputs:{x:C},backend:s,attrs:{shape:y}});w.push(C);for(const t of w)s.disposeIntermediateTensorInfo(t);return N}const vit={kernelName:xN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{a:s,b:r,bias:a,preluActivationWeights:o}=e,{transposeA:l,transposeB:u,activation:h,leakyreluAlpha:p}=i;return bit({a:s,b:r,transposeA:l,transposeB:u,backend:n,bias:a,preluActivationWeights:o,leakyreluAlpha:p,activation:h})}},wit="return abs(x);";const Sit={kernelName:pA,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{x:i}=e;if(n.shouldExecuteOnCPU([i])&&"complex64"!==i.dtype){const t=n.texData.get(i.dataId),e=zet(t.values);return n.makeTensorInfo(i.shape,i.dtype,e)}let s;return s=aA().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new Mnt(i.shape,wit):new gnt(i.shape,wit),n.runWebGLProgram(s,[i],i.dtype)}},xit=tit({opSnippet:_nt+"\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n"}),Rit={kernelName:cA,backendName:"webgl",kernelFunc:xit},Oit=tit({opSnippet:_nt+"\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));"}),Ait={kernelName:dA,backendName:"webgl",kernelFunc:Oit},Mit="return a + b;",Cit=eit({opSnippet:Mit,packedOpSnippet:Mit,supportsComplex:!0,cpuKernelImpl:cet}),Nit={kernelName:fA,backendName:"webgl",kernelFunc:Cit};
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class kit{constructor(t,e){this.outputShape=[],this.outputShape=t,this.variableNames=e.map(((t,e)=>`T${e}`));const n=[];this.variableNames.forEach((t=>{n.push(`float v${t} = get${t}AtOutCoords();`)}));const i=this.variableNames.map((t=>`v${t}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n float result = ${i};\n setOutput(result);\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Dit{constructor(t,e){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.variableNames=e.map(((t,e)=>`T${e}`));const n=[];this.variableNames.forEach((t=>{n.push(`vec4 v${t} = get${t}AtOutCoords();`)}));const i=this.variableNames.map((t=>`v${t}`)).join(" + ");this.userCode=`\n void main() {\n ${n.join("\n ")}\n\n vec4 result = ${i};\n setOutput(result);\n }\n `}}const Lit={kernelName:mA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function t(e){const{inputs:n,backend:i}=e,s=n;if(1===s.length)return Gnt({inputs:{x:s[0]},backend:i});if(s.length>aA().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){const e=Math.floor(s.length/2),n=t({inputs:s.slice(0,e),backend:i}),r=t({inputs:s.slice(e),backend:i});return t({inputs:[n,r],backend:i})}const r=s.map((t=>t.dtype)).reduce(((t,e)=>Lk(t,e))),a=s.map((t=>t.shape)),o=aA().getBool("WEBGL_PACK")?new Dit(s[0].shape,a):new kit(s[0].shape,a);return i.runWebGLProgram(o,s,r)}};const Fit={kernelName:gA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i,o=s.shape.length,l=CO(r,s.shape);let u=l;const h=_B(u,o);let p=s;null!=h&&(p=yit({inputs:{x:s},backend:n,attrs:{perm:h}}),u=yB(u.length,o)),gB("all",u,o);const[c,d]=fB(p.shape,u),f=uit({inputs:{x:p},backend:n,attrs:{shape:[-1,IO(d)]}}),m=dit(f,f.dtype,"all",n);let g;if(a){g=uit({inputs:{x:m},backend:n,attrs:{shape:mB(c,l)}})}else g=uit({inputs:{x:m},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=h&&n.disposeIntermediateTensorInfo(p),g}};const Pit={kernelName:_A,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i,o=s.shape.length,l=CO(r,s.shape);let u=l;const h=_B(u,o);let p=s;null!=h&&(p=yit({inputs:{x:s},backend:n,attrs:{perm:h}}),u=yB(u.length,o)),gB("any",u,o);const[c,d]=fB(p.shape,u),f=uit({inputs:{x:p},backend:n,attrs:{shape:[-1,IO(d)]}}),m=dit(f,f.dtype,"any",n);let g;if(a){g=uit({inputs:{x:m},backend:n,attrs:{shape:mB(c,l)}})}else g=uit({inputs:{x:m},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=h&&n.disposeIntermediateTensorInfo(p),g}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class $it{constructor(t,e,n){this.variableNames=["A"];const{windowSize:i,batchSize:s,outSize:r}=t;n||this.variableNames.push("bestIndicesA"),this.outputShape=[s,r];const a="max"===e?">":"<",o=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${i};\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < ${i}; i++) {\n int inIdx = ${o};\n float candidate = getA(batch, inIdx);\n if (candidate ${a} bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Bit{constructor(t,e,n,i){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,_O(t.length>2,(()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`));const s=t[t.length-1],r=Math.ceil(s/e);this.outputShape=t.slice(0,-1),r>1&&this.outputShape.push(r),i||this.variableNames.push("bestIndicesA");const a=this.outputShape,o=a.length,l=Ott(o),u=unt("coords",o);let h,p;if(1===r){p=o+1;const t=Ott(p);h=`\n ${t} sourceLocR = ${t}(${u.join()}, 0);\n ++${u[o-1]};\n ${t} sourceLocG = ${t}(${u.join()}, 0);\n ++${u[o-2]};\n ${t} sourceLocA = ${t}(${u.join()}, 0);\n --${u[o-1]};\n ${t} sourceLocB = ${t}(${u.join()}, 0);\n --${u[o-2]};`}else p=o,h=`\n ${l} sourceLocR = coords;\n ++${u[o-1]};\n ${l} sourceLocG = coords;\n ++${u[o-2]};\n ${l} sourceLocA = coords;\n --${u[o-1]};\n ${l} sourceLocB = coords;\n --${u[o-2]};`;const c=["x","y","z","w","u","v"].slice(0,p),d="."+c[p-1],f=c.map((t=>"int "+t)),m=unt("sourceLocR",p-1).concat("inIdx.r"),g=unt("sourceLocG",p-1).concat("inIdx.g"),_=unt("sourceLocB",p-1).concat("inIdx.b"),T=unt("sourceLocA",p-1).concat("inIdx.a"),y="max"===n?"greaterThan":"lessThan",I=i?"":`\n inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${_.join()}),\n getBestIndicesAChannel(${T.join()})));`,E=`vec4(\n getAChannel(${m.join()}),\n hasNextCol ? getAChannel(${g.join()}) : 0.,\n hasNextRow ? getAChannel(${_.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${T.join()}) : 0.)`,b=i?"":`\n float getBestIndicesAChannel(${f.join()}) {\n return getChannel(getBestIndicesA(${c.join()}),\n vec2(${c.slice(-2).join()}));\n }`;this.userCode=`\n float getAChannel(${f.join()}) {\n return getChannel(getA(${c.join()}),\n vec2(${c.slice(-2).join()}));\n }\n ${b}\n void main() {\n ${l} coords = getOutputCoords();\n bool hasNextCol = ${u[o-1]} < ${a[o-1]-1};\n bool hasNextRow = ${u[o-2]} < ${a[o-2]-1};\n ${h}\n ivec4 srcIdx = ivec4(sourceLocR${d}, sourceLocG${d},\n sourceLocB${d}, sourceLocA${d}) * ${e};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${E};\n\n for (int i = 0; i < ${e}; i++) {\n inIdx = srcIdx;\n ${I}\n vec4 candidate = ${E};\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4(${y}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Vit(t,e,n,i=null){let s=e.shape[0],r=e.shape[1];null!=i&&(s=i.shape[0],r=i.shape[1]);const a=fG(r),o={windowSize:a,inSize:r,batchSize:s,outSize:Math.ceil(r/a)},l=new $it(o,n,null==i),u=[e];null!=i&&u.push(i);const h=t.runWebGLProgram(l,u,"int32");if(1===h.shape[1])return h;const p=Vit(t,e,n,h);return t.disposeIntermediateTensorInfo(h),p}function Uit(t,e,n,i=null){const s=null!=i?i.shape:e.shape,r=fG(s[s.length-1]),a=new Bit(s,r,n,null==i),o=null==i?[e]:[e,i],l=t.runWebGLProgram(a,o,"int32");if(l.shape.length===e.shape.length){const i=Uit(t,e,n,l);return t.disposeIntermediateTensorInfo(l),i}return l}function Yit(t,e,n,i){const s=[n];if(gB("arg"+i.charAt(0).toUpperCase()+i.slice(1),s,e.shape.length),!aA().getBool("WEBGL_PACK_REDUCE")||e.shape.length<=2){const n=[],r=t.texData.get(e.dataId);let a=e;null!==r&&r.isPacked&&(a=t.unpackTensor(e),n.push(a));const[o,l]=fB(a.shape,s),u=IO(l),h=uit({inputs:{x:a},backend:t,attrs:{shape:[-1,u]}});n.push(h);const p=Vit(t,h,i);n.push(p);const c=uit({inputs:{x:p},backend:t,attrs:{shape:o}});return n.forEach((e=>t.disposeIntermediateTensorInfo(e))),c}return Uit(t,e,i)}const Git={kernelName:TA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r}=i;let a=CO(r,s.shape);const o=_B(a,s.shape.length);let l=s;const u=[];null!=o&&(l=yit({inputs:{x:s},backend:n,attrs:{perm:o}}),u.push(l),a=yB(a.length,l.shape.length)),gB("argMax",[a[0]],l.shape.length);const h=Yit(n,l,a[0],"max");return u.forEach((t=>n.disposeIntermediateTensorInfo(t))),h}};const Hit={kernelName:yA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r}=i;let a=CO(r,s.shape);const o=_B(a,s.shape.length);let l=s;const u=[];null!=o&&(l=yit({inputs:{x:s},backend:n,attrs:{perm:o}}),u.push(l),a=yB(a.length,l.shape.length)),gB("argMin",[a[0]],l.shape.length);const h=Yit(n,l,a[0],"min");return u.forEach((t=>n.disposeIntermediateTensorInfo(t))),h}},Wit=tit({opSnippet:_nt+"\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n"}),zit={kernelName:IA,backendName:"webgl",kernelFunc:Wit},Xit=tit({opSnippet:_nt+"return log(x + sqrt(x * x + 1.0));"}),jit={kernelName:EA,backendName:"webgl",kernelFunc:Xit},qit=tit({opSnippet:_nt+"\n return atan(x);\n"}),Kit={kernelName:bA,backendName:"webgl",kernelFunc:qit},Qit=eit({opSnippet:Bnt+"\n return atan(a, b);\n",packedOpSnippet:"\n vec4 result = atan(a, b);\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n "+Unt+"\n return result;\n"}),Jit={kernelName:wA,backendName:"webgl",kernelFunc:Qit},Zit=tit({opSnippet:_nt+"\n if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;"}),tst={kernelName:vA,backendName:"webgl",kernelFunc:Zit};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class est{constructor(t,e,n,i=!1,s=!1){if(this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");const r=t.filterWidth,a=t.strideHeight,o=t.strideWidth,l=t.dilationHeight,u=t.dilationWidth,h=t.effectiveFilterHeight,p=t.effectiveFilterWidth,c=t.padInfo.top,d=t.padInfo.left;this.outputShape=t.outShape;const f="avg"===e,m=`((batch * ${t.inHeight} + xR) * ${t.inWidth} + xC) * ${t.inChannels} + d`,g=`(xR * ${t.inWidth} + xC) * ${t.inChannels} + d`;let _="0.0";if(f||(_="-1.0 / 1e-20"),n){const e=">=";return void(this.userCode=`\n const ivec2 strides = ivec2(${a}, ${o});\n const ivec2 pads = ivec2(${c}, ${d});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < ${h};\n wR += ${l}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${p};\n wC += ${u}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${t.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${e} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${i?s?m:g:`wR * ${p} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let T=`${e}(${e}(${e}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===e&&(T="avgValue / max(count, 1.0)");const y=4*Math.floor(r/4),I=r%4,E=`\n if (${f}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec2 strides = ivec2(${a}, ${o});\n const ivec2 pads = ivec2(${c}, ${d});\n const float initializationValue = ${_};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= ${t.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4(${_});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${h};\n wR += ${l}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${y}; wC += 4) {\n int xC = xCCorner + wC * ${u};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${u}, d),\n getValue(batch, xR, xC + 2 * ${u}, d),\n getValue(batch, xR, xC + 3 * ${u}, d)\n );\n\n ${E}\n }\n\n int xC = xCCorner + ${y};\n if (${1===I}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${E}\n } else if (${2===I}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${u}, d),\n initializationValue,\n initializationValue\n );\n\n ${E}\n } else if (${3===I}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${u}, d),\n getValue(batch, xR, xC + 2 * ${u}, d),\n initializationValue\n );\n\n ${E}\n }\n }\n setOutput(${T});\n }\n `}}class nst{constructor(t,e,n,i=!1,s=!1){if(this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");const r=t.filterWidth,a=t.strideDepth,o=t.strideHeight,l=t.strideWidth,u=t.dilationDepth,h=t.dilationHeight,p=t.dilationWidth,c=t.effectiveFilterDepth,d=t.effectiveFilterHeight,f=t.effectiveFilterWidth,m=t.padInfo.front,g=t.padInfo.top,_=t.padInfo.left;this.outputShape=t.outShape;const T="avg"===e;let y="0.0";if(T||(y="-1.0 / 1e-20"),n){const e=">=";return void(this.userCode=`\n const ivec3 strides =\n ivec3(${a}, ${o}, ${l});\n const ivec3 pads = ivec3(${m}, ${g}, ${_});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n\n for (int wD = 0; wD < ${c};\n wD += ${u}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${t.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${d};\n wR += ${h}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${f};\n wC += ${p}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${t.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xD, xR, xC, ch);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${e} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${i?s?`(((batch * ${t.inDepth} + xD) * ${t.inHeight} + xR) * ${t.inWidth} + xC) * ${t.inChannels} + ch`:`((xD * ${t.inHeight} + xR) * ${t.inWidth} + xC) * ${t.inChannels} + ch`:`wD * ${d} * ${f} +\n wR * ${f} + wC`};\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let I=`${e}(${e}(${e}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===e&&(I="avgValue / max(count, 1.0)");const E=4*Math.floor(r/4),b=r%4,v=`\n if (${T}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec3 strides =\n ivec3(${a}, ${o}, ${l});\n const ivec3 pads = ivec3(${m}, ${g}, ${_});\n const float initializationValue = ${y};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xD, int xR, int xC, int ch) {\n if (xC < 0 || xC >= ${t.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xD, xR, xC, ch);\n }\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n // ? = to be determined\n vec4 minMaxValue = vec4(${y});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < ${c};\n wD += ${u}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${t.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${d};\n wR += ${h}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${E}; wC += 4) {\n int xC = xCCorner + wC * ${p};\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n getValue(batch, xD, xR, xC + 3 * ${p}, ch)\n );\n\n ${v}\n }\n\n int xC = xCCorner + ${E};\n if (${1===b}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${v}\n } else if (${2===b}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n initializationValue,\n initializationValue\n );\n\n ${v}\n } else if (${3===b}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${p}, ch),\n getValue(batch, xD, xR, xC + 2 * ${p}, ch),\n initializationValue\n );\n\n ${v}\n }\n }\n }\n setOutput(${I});\n }\n `}}const ist={kernelName:SA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e;utt(s,"avgPool");const{filterSize:r,strides:a,pad:o,dimRoundingMode:l}=i;_O(m$(a,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const u=r$(s.shape,r,a,1,o,l);if(1===u.filterWidth&&1===u.filterHeight&&vO(u.inShape,u.outShape))return Gnt({inputs:{x:s},backend:n});const h=new est(u,"avg",!1);return n.runWebGLProgram(h,[s],"float32")}};const sst={kernelName:RA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{filterSize:r,strides:a,pad:o,dimRoundingMode:l,dataFormat:u}=i,h=a$(s.shape,r,a,[1,1,1],o,l,u),p=new nst(h,"avg",!1);return n.runWebGLProgram(p,[s],"float32")}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class rst{constructor(t){this.variableNames=["dy"],this.outputShape=t.inShape;const e=t.filterHeight,n=t.filterWidth,i=t.strideHeight,s=t.strideWidth,r=t.dilationHeight,a=t.dilationWidth,o=t.effectiveFilterHeight,l=t.effectiveFilterWidth,u=o-1-t.padInfo.top,h=l-1-t.padInfo.left,p=1/(e*n);this.userCode=`\n const ivec2 pads = ivec2(${u}, ${h});\n const float avgMultiplier = float(${p});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${o};\n wR += ${r}) {\n float dyR = float(dyRCorner + wR) / ${i}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${l};\n wC+= ${a}) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n `}}class ast{constructor(t){this.variableNames=["dy"],this.outputShape=t.inShape;const e=t.filterDepth,n=t.filterHeight,i=t.filterWidth,s=t.strideDepth,r=t.strideHeight,a=t.strideWidth,o=t.dilationDepth,l=t.dilationHeight,u=t.dilationWidth,h=t.effectiveFilterDepth,p=t.effectiveFilterHeight,c=t.effectiveFilterWidth,d=h-1-t.padInfo.front,f=p-1-t.padInfo.top,m=c-1-t.padInfo.left,g=1/(e*n*i);this.userCode=`\n const ivec3 pads = ivec3(${d}, ${f}, ${m});\n const float avgMultiplier = float(${g});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${h};\n wD += ${o}) {\n float dyD = float(dyDCorner + wD) / ${s}.0;\n\n if (dyD < 0.0 || dyD >= ${t.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${p};\n wR += ${l}) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${c};\n wC += ${u}) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const ost={kernelName:OA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,a=r,{filterSize:o,strides:l,pad:u,dimRoundingMode:h}=i,p=a$(a.shape,o,l,[1,1,1],u,h),c=new ast(p);return n.runWebGLProgram(c,[s],a.dtype)}};const lst={kernelName:xA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,a=r;utt([s,r],"avgPoolGrad");const{filterSize:o,strides:l,pad:u}=i,h=r$(a.shape,o,l,1,u),p=new rst(h);return n.runWebGLProgram(p,[s],a.dtype)}};const ust={kernelName:AA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{a:s,b:r}=e,{transposeA:a,transposeB:o}=i;return bit({a:s,b:r,transposeA:a,transposeB:o,backend:n})}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class hst{constructor(t,e,n,i,s,r){this.outputShape=[],this.variableNames=["x","mean","variance"],_F(t,e),_F(t,n);let a="0.0";null!=i&&(_F(t,i),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let o="1.0";null!=s&&(_F(t,s),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=t,this.userCode=`\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = ${a};\n float scale = ${o};\n float inv = scale * inversesqrt(variance + float(${r}));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n `}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class pst{constructor(t,e,n,i,s,r){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],_F(t,e),_F(t,n);let a="vec4(0.0)";null!=i&&(_F(t,i),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");let o="vec4(1.0)";null!=s&&(_F(t,s),this.variableNames.push("scale"),o="getScaleAtOutCoords()"),this.outputShape=t,this.userCode=`\n void main() {\n vec4 offset = ${a};\n vec4 scale = ${o};\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4(${r}));\n\n setOutput((x - mean) * inv + offset);\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const cst={kernelName:bM,backendName:"webgl",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:i,mean:s,variance:r,offset:a,scale:o}=t;_O(s.shape.length===r.shape.length,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),_O(null==a||s.shape.length===a.shape.length,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),_O(null==o||s.shape.length===o.shape.length,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));let{varianceEpsilon:l}=n;null==l&&(l=.001);const u=[i,s,r];let h=null;null!=a&&(h=a.shape,u.push(a));let p=null;null!=o&&(p=o.shape,u.push(o));const c=aA().getBool("WEBGL_PACK_NORMALIZATION")?new pst(i.shape,s.shape,r.shape,h,p,l):new hst(i.shape,s.shape,r.shape,h,p,l);return e.runWebGLProgram(c,u,u[0].dtype)}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class dst{constructor(t){this.variableNames=["source"],this.outputShape=t,this.rank=t.length;const e=Ott(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const n=function(t){if(1===t)return"sourceLoc";if(t<=6)return fst.slice(0,t).map((t=>"sourceLoc."+t)).join(",");throw Error(`Slicing for rank ${t} is not yet supported`)}(this.rank);let i;i=`\n ${e} sourceLoc;\n ${e} coords = getOutputCoords();\n ${t.map(((t,e)=>`sourceLoc.${fst[e]} = start[${e}] + coords.${fst[e]};`)).join("\n")}\n `,this.userCode=`\n void main() {\n ${i}\n setOutput(getSource(${n}));\n }\n `}}const fst=["x","y","z","w","u","v"];
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class mst{constructor(t){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.rank=t.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const e=Ott(this.rank),n=unt("coords",this.rank),i=unt("sourceLoc",this.rank),s=1===this.rank?"sourceLoc":`vec2(${i.slice(-2).join()})`,r=`getChannel(getSource(${i.join()}), ${s})`,a=`\n result.x = ${r};\n if (++${n[this.rank-1]} < ${t[this.rank-1]}) {\n ++${i[this.rank-1]};\n result.y = ${r};\n --${i[this.rank-1]};\n }\n `,o=1===this.rank?"":`\n --${n[this.rank-1]};\n if (++${n[this.rank-2]} < ${t[this.rank-2]}) {\n ++${i[this.rank-2]};\n result.z = ${r};\n if (++${n[this.rank-1]} < ${t[this.rank-1]}) {\n ++${i[this.rank-1]};\n result.w = ${r};\n }\n }\n `,l=this.rank<=4?`sourceLoc = coords +\n ${e}(${t.map(((t,e)=>`start[${e}]`)).join()});`:t.map(((t,e)=>`${i[e]} = ${n[e]} + start[${e}];`)).join("\n");this.userCode=`\n void main() {\n ${e} coords = getOutputCoords();\n ${e} sourceLoc;\n ${l}\n vec4 result = vec4(0.);\n ${a}\n ${o}\n setOutput(result);\n }\n `}}function gst(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{begin:r,size:a}=i,[o,l]=RP(s,r,a);if(dP(s,o,l),0===IO(l))return n.makeTensorInfo(l,s.dtype,[]);if(n.shouldExecuteOnCPU([s])||"string"===s.dtype){const t=n.texData.get(s.dataId),e=Xet(t.values,o,l,s.shape,s.dtype);return n.makeTensorInfo(l,s.dtype,e)}const{isPacked:u}=n.texData.get(s.dataId),h=SP(s.shape,o,l);if(u||!h){const t=aA().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new mst(l):new dst(l),e=[o];return n.runWebGLProgram(t,[s],s.dtype,e)}return n.uploadToGPU(s.dataId),
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i){const s=i.texData.get(t.dataId),r=i.makeTensorInfo(n,t.dtype),a=i.texData.get(r.dataId);Object.assign(a,s),a.refCount=1,a.shape=n,a.dtype=t.dtype;let o=xP(e,zO(t.shape));s.slice&&(o+=s.slice.flatOffset),a.slice={flatOffset:o,origDataId:s.slice&&s.slice.origDataId||t.dataId};const l=i.dataRefCount.get(a.slice.origDataId)||1;return i.dataRefCount.set(a.slice.origDataId,l+1),r}(s,o,l,n)}const _st={kernelName:YC,backendName:"webgl",kernelFunc:gst},Tst={kernelName:MA,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{blockShape:r,crops:a}=i;_O(s.shape.length<=4,(()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"));const o=r.reduce(((t,e)=>t*e)),l=gG(s.shape,r,o),u=_G(l.length,r.length),h=TG(s.shape,r,o),p=yG(a,r.length),c=IG(h,a,r.length),d=[],f=uit({inputs:{x:s},backend:n,attrs:{shape:l}}),m=yit({inputs:{x:f},backend:n,attrs:{perm:u}}),g=uit({inputs:{x:m},backend:n,attrs:{shape:h}}),_=gst({inputs:{x:g},backend:n,attrs:{begin:p,size:c}});return d.push(f),d.push(m),d.push(g),d.forEach((t=>n.disposeIntermediateTensorInfo(t))),_}};const yst={kernelName:CA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,weights:r}=e,{size:a}=i,o=n.readSync(s.dataId),l=n.readSync(r.dataId),u=det(o,l,r.dtype,r.shape,a);return n.makeTensorInfo([a],r.dtype,u)}};const Ist={kernelName:NA,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{a:i,b:s}=e,r=aA().getBool("WEBGL_PACK_BINARY_OPERATIONS"),a=aA().getNumber("WEBGL_VERSION");if(n.shouldExecuteOnCPU([i,s])||1===a){const t=n.texData.get(i.dataId).values,e=n.texData.get(s.dataId).values,[r,a]=met(i.shape,s.shape,t,e,i.dtype),o=n.makeTensorInfo(a,i.dtype);return n.texData.get(o.dataId).values=r,o}let o;return o=r?new Ynt("\n int r = int(a.r) & int(b.r);\n int g = int(a.g) & int(b.g);\n int rb = int(a.b) & int(b.b);\n int ra = int(a.a) & int(b.a);\n return vec4(r, g, rb, ra);\n",i.shape,s.shape,!1):new Vnt("\n return float(int(a.r) & int(b.r));\n",i.shape,s.shape),n.runWebGLProgram(o,[i,s],i.dtype)}};const Est={kernelName:DA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{s0:i,s1:s}=e,r=n.readSync(i.dataId),a=n.readSync(s.dataId),o=_F(Array.from(r),Array.from(a));return n.makeTensorInfo([o.length],"int32",Int32Array.from(o))}},bst=eit({opSnippet:"return float(a != b);",cpuKernelImpl:Pet,dtype:"bool"}),vst={kernelName:uC,backendName:"webgl",kernelFunc:bst};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function wst(t){const{inputs:e,backend:n}=t,{input:i}=e;return Gnt({inputs:{x:n.texData.get(i.dataId).complexTensorInfos.real},backend:n})}const Sst={kernelName:SC,backendName:"webgl",kernelFunc:wst},xst="return float(int(x));";const Rst={kernelName:LA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function t(e){const{inputs:n,backend:i,attrs:s}=e,{x:r}=n,{dtype:a}=s;if("complex64"===a){if("complex64"===r.dtype)return Gnt({inputs:{x:r},backend:i});const e=aV(r.shape),n=t({inputs:{x:r},backend:i,attrs:{dtype:"float32"}}),s=Wnt({inputs:{real:n,imag:e},backend:i});return e.dispose(),i.disposeIntermediateTensorInfo(n),s}if("complex64"===r.dtype){const e=wst({inputs:{input:r},backend:i}),n=t({inputs:{x:e},backend:i,attrs:{dtype:a}});return i.disposeIntermediateTensorInfo(e),n}if(!PO(r.dtype,a)){const t=Gnt({inputs:{x:r},backend:i});return{dataId:t.dataId,shape:t.shape,dtype:a}}if(i.shouldExecuteOnCPU([r])){const t=i.texData.get(r.dataId).values,[e,n,s]=get(t,r.shape,r.dtype,a);return i.makeTensorInfo(e,n,s)}if("int32"===a)return function(t,e){const n=new gnt(t.shape,xst),i=e.runWebGLProgram(n,[t],"int32");return{dataId:i.dataId,shape:i.shape,dtype:i.dtype}}(r,i);if("bool"===a){const t=i.makeTensorInfo([],"bool",kO("bool",1)),e=bst({inputs:{a:r,b:t},backend:i});return i.disposeIntermediateTensorInfo(t),e}throw new Error(`Error in Cast: failed to cast ${r.dtype} to ${a}`)}},Ost="return ceil(x);",Ast=tit({opSnippet:Ost,packedOpSnippet:Ost,cpuKernelImpl:_et}),Mst={kernelName:FA,backendName:"webgl",kernelFunc:Ast};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Cst{constructor(t){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=t,this.userCode="\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n "}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Nst{constructor(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=t,this.userCode="\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n "}}const kst={kernelName:PA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{clipValueMin:r,clipValueMax:a}=i;let o;o=aA().getBool("WEBGL_PACK_CLIP")?new Nst(s.shape):new Cst(s.shape);const l=[[r],[a]];return n.runWebGLProgram(o,[s],s.dtype,l)}};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Dst{constructor(t){this.variableNames=["real","imag"],this.outputShape=t,this.userCode="\n void main() {\n float re = abs(getRealAtOutCoords());\n float im = abs(getImagAtOutCoords());\n float mx = max(re, im);\n\n // sadly the length function in glsl is not underflow-safe\n // (at least not on Intel GPUs). So the safe solution is\n // to ensure underflow-safety in all cases.\n setOutput(\n mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n );\n }\n "}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Lst(t,e){return{dataId:e.dataId,dtype:e.dtype,shape:t.shape}}const Fst={kernelName:BA,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{x:i}=e,s=n.texData.get(i.dataId),r=new Dst(i.shape),a=[Lst(i,s.complexTensorInfos.real),Lst(i,s.complexTensorInfos.imag)];return n.runWebGLProgram(r,a,a[0].dtype)}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Pst{constructor(t){this.outputShape=[],this.outputShape=oG(t,1),this.variableNames=t.map(((t,e)=>`T${e}`));const e=new Array(t.length-1);e[0]=t[0][1];for(let n=1;n<e.length;n++)e[n]=e[n-1]+t[n][1];const n=[`if (yC < ${e[0]}) setOutput(getT0(yR, yC));`];for(let t=1;t<e.length;t++){const i=e[t-1];n.push(`else if (yC < ${e[t]}) setOutput(getT${t}(yR, yC-${i}));`)}const i=e.length,s=e[e.length-1];n.push(`else setOutput(getT${i}(yR, yC-${s}));`),this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int yR = coords.x;\n int yC = coords.y;\n\n ${n.join("\n ")}\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class $st{constructor(t,e){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=oG(t,e);const n=this.outputShape,i=n.length,s=Ott(i),r=unt("coords",i),a=["x","y","z","w","u","v"].slice(0,i);this.variableNames=t.map(((t,e)=>`T${e}`));const o=new Array(t.length-1);o[0]=t[0][e];for(let n=1;n<o.length;n++)o[n]=o[n-1]+t[n][e];const l=a[e],u=a.slice(-2),h=a.join();let p=`if (${l} < ${o[0]}) {\n return getChannel(\n getT0(${h}), vec2(${u.join()}));\n }`;for(let t=1;t<o.length;t++){const e=o[t-1];p+=`\n if (${l} < ${o[t]} && ${l} >= ${o[t-1]}) {\n return getChannel(\n getT${t}(${Bst(a,l,e)}),\n vec2(${Bst(u,l,e)}));\n }`}const c=o.length,d=o[o.length-1];p+=`\n return getChannel(\n getT${c}(${Bst(a,l,d)}),\n vec2(${Bst(u,l,d)}));`,this.userCode=`\n float getValue(${a.map((t=>"int "+t))}) {\n ${p}\n }\n\n void main() {\n ${s} coords = getOutputCoords();\n vec4 result = vec4(getValue(${r}), 0., 0., 0.);\n\n ${r[i-1]} = ${r[i-1]} + 1;\n if (${r[i-1]} < ${n[i-1]}) {\n result.g = getValue(${r});\n }\n\n ${r[i-2]} = ${r[i-2]} + 1;\n if (${r[i-2]} < ${n[i-2]}) {\n result.a = getValue(${r});\n }\n\n ${r[i-1]} = ${r[i-1]} - 1;\n if (${r[i-2]} < ${n[i-2]} &&\n ${r[i-1]} < ${n[i-1]}) {\n result.b = getValue(${r});\n }\n setOutput(result);\n }\n `}}function Bst(t,e,n){const i=t.indexOf(e);return t.map(((t,e)=>e===i?`${t} - ${n}`:t)).join()}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Vst(t){const{inputs:e,backend:n}=t,{input:i}=e;return Gnt({inputs:{x:n.texData.get(i.dataId).complexTensorInfos.imag},backend:n})}const Ust={kernelName:AM,backendName:"webgl",kernelFunc:Vst};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Yst(t,e,n){const i=t[0].dtype;if("complex64"===i){const i=t.map((t=>wst({inputs:{input:t},backend:n}))),s=t.map((t=>Vst({inputs:{input:t},backend:n}))),r=Yst(i,e,n),a=Yst(s,e,n),o=Wnt({inputs:{real:r,imag:a},backend:n});return i.forEach((t=>n.disposeIntermediateTensorInfo(t))),s.forEach((t=>n.disposeIntermediateTensorInfo(t))),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),o}let s=n.shouldExecuteOnCPU(t);if("string"===i&&(s=!0),s){const s=t.map((t=>{const i=IO(t.shape.slice(e));return uit({inputs:{x:t},backend:n,attrs:{shape:[-1,i]}})})),r=s.map((t=>({vals:n.readSync(t.dataId),shape:t.shape}))),a=oG(s.map((t=>t.shape)),1),o=1===s[0].shape[0],l=Tet(r,a,i,o),u=oG(t.map((t=>t.shape)),e),h=n.makeTensorInfo(u,i,l);return s.forEach((t=>n.disposeIntermediateTensorInfo(t))),h}const r=t.filter((t=>IO(t.shape)>0)),a=aA().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&r[0].shape.length>1;if(1===r.length){const e=a?new gnt(t[0].shape,vnt):new Mnt(t[0].shape,vnt);return n.runWebGLProgram(e,t,i)}const o=aA().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(r.length>o){const t=[];for(let i=0;i<r.length;i+=o){const s=r.slice(i,i+o);t.push(Yst(s,e,n))}const i=Yst(t,e,n);for(const e of t)n.disposeIntermediateTensorInfo(e);return i}if(a){const t=new $st(r.map((t=>t.shape)),e);return n.runWebGLProgram(t,r,i)}const{tensors2D:l,outShape:u}=function(t,e,n){const i=oG(t.map((t=>t.shape)),e),s=t.map((t=>uit({inputs:{x:t},attrs:{shape:[-1,IO(t.shape.slice(e))]},backend:n})));return{tensors2D:s,outShape:i}}(r,e,n),h=new Pst(l.map((t=>t.shape))),p=n.runWebGLProgram(h,l,i);l.forEach((t=>n.disposeIntermediateTensorInfo(t)));const c=uit({inputs:{x:p},attrs:{shape:u},backend:n});return n.disposeIntermediateTensorInfo(p),c}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Gst(t){const{inputs:e,backend:n,attrs:i}=t,{axis:s}=i,r=CO(s,e[0].shape)[0];aG(e.map((t=>t.shape)),r);const a=oG(e.map((t=>t.shape)),r);if(0===IO(a))return n.makeTensorInfo(a,e[0].dtype,[]);const o=e.filter((t=>IO(t.shape)>0));return 1===o.length?Gnt({inputs:{x:o[0]},backend:n}):Yst(o,r,n)}const Hst={kernelName:VA,backendName:"webgl",kernelFunc:Gst};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Wst{constructor(t,e=!1,n=null,i=!1,s=!1){this.variableNames=["x","W"],this.outputShape=t.outShape;const r=t.padInfo.top,a=t.padInfo.left,o=t.strideHeight,l=t.strideWidth,u=t.dilationHeight,h=t.dilationWidth,p=t.filterHeight,c=t.filterWidth,d=4*Math.floor(t.inChannels/4),f=t.inChannels%4,m="channelsLast"===t.dataFormat,g=m?1:2,_=m?2:3,T=m?3:1;let y="",I="";n&&(y=i?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:s?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,I="result = activation(result);");const E=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${y}\n\n const ivec2 strides = ivec2(${o}, ${l});\n const ivec2 pads = ivec2(${r}, ${a});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${T}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${_}]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${p}; wR++) {\n int xR = xRCorner + wR * ${u};\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${c}; wC++) {\n int xC = xCCorner + wC * ${h};\n\n if (xC < 0 || xC >= ${t.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${d}; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if (${m}) {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if (${1===f}) {\n\n if (${m}) {\n dotProd +=\n getX(batch, xR, xC, ${d}) *\n getW(wR, wC, ${d}, d2);\n } else {\n dotProd +=\n getX(batch, ${d}, xR, xC) *\n getW(wR, wC, ${d}, d2);\n }\n\n } else if (${2===f}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${d}, d2),\n getW(wR, wC, ${d} + 1, d2)\n );\n\n if (${m}) {\n vec2 xValues = vec2(\n getX(batch, xR, xC, ${d}),\n getX(batch, xR, xC, ${d} + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, ${d}, xR, xC),\n getX(batch, ${d} + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if (${3===f}) {\n vec3 wValues = vec3(\n getW(wR, wC, ${d}, d2),\n getW(wR, wC, ${d} + 1, d2),\n getW(wR, wC, ${d} + 2, d2)\n );\n\n if (${m}) {\n vec3 xValues = vec3(\n getX(batch, xR, xC, ${d}),\n getX(batch, xR, xC, ${d} + 1),\n getX(batch, xR, xC, ${d} + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, ${d}, xR, xC),\n getX(batch, ${d} + 1, xR, xC),\n getX(batch, ${d} + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n ${E}\n ${I}\n setOutput(result);\n }\n `}}class zst{constructor(t){this.variableNames=["x","W"],this.outputShape=t.outShape;const e=t.padInfo.front,n=t.padInfo.top,i=t.padInfo.left,s=t.strideDepth,r=t.strideHeight,a=t.strideWidth,o=t.dilationDepth,l=t.dilationHeight,u=t.dilationWidth,h=t.filterDepth,p=t.filterHeight,c=t.filterWidth,d=4*Math.floor(t.inChannels/4),f=t.inChannels%4;this.userCode=`\n const ivec3 strides = ivec3(${s}, ${r}, ${a});\n const ivec3 pads = ivec3(${e}, ${n}, ${i});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d2 = coords.u;\n\n ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xFCorner = xFRCCorner.x;\n int xRCorner = xFRCCorner.y;\n int xCCorner = xFRCCorner.z;\n\n // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n // y(yF, yR, yC, d2). ? = to be determined. : = across all\n // values in that axis.\n float dotProd = 0.0;\n for (int wF = 0; wF < ${h}; wF++) {\n int xF = xFCorner + wF * ${o};\n\n if (xF < 0 || xF >= ${t.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${p}; wR++) {\n int xR = xRCorner + wR * ${l};\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${c}; wC++) {\n int xC = xCCorner + wC * ${u};\n\n if (xC < 0 || xC >= ${t.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${d}; d1 += 4) {\n vec4 xValues = vec4(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3)\n );\n vec4 wValues = vec4(\n getW(wF, wR, wC, d1, d2),\n getW(wF, wR, wC, d1 + 1, d2),\n getW(wF, wR, wC, d1 + 2, d2),\n getW(wF, wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if (${1===f}) {\n dotProd +=\n getX(batch, xF, xR, xC, ${d}) *\n getW(wF, wR, wC, ${d}, d2);\n } else if (${2===f}) {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, ${d}),\n getX(batch, xF, xR, xC, ${d} + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, ${d}, d2),\n getW(wF, wR, wC, ${d} + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (${3===f}) {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, ${d}),\n getX(batch, xF, xR, xC, ${d} + 1),\n getX(batch, xF, xR, xC, ${d} + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, ${d}, d2),\n getW(wF, wR, wC, ${d} + 1, d2),\n getW(wF, wR, wC, ${d} + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Xst{constructor(t,e=!1,n=null,i=!1,s=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=t.outShape,this.enableShapeUniforms=Dtt(this.outputShape.length);const r=t.padInfo.left,a=t.strideWidth,o=t.dilationWidth,l=t.filterHeight,u=t.filterWidth,h=u;let p="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let t=0;t<u;t++)p+=`\n vec4 xTexelC${2*t};\n int xTexelC${2*t}Ready;\n vec4 xTexelC${2*t+1};\n int xTexelC${2*t+1}Ready;\n vec4 xC${t};`;p+=`\n for (int r = 0; r < ${l}; r++) {\n for (int d1 = 0; d1 < ${t.inChannels}; d1 += 2) {\n `;for(let t=0;t<u;t++)p+=`\n xTexelC${2*t} = vec4(0.0);\n xTexelC${2*t}Ready = 0;\n xTexelC${2*t+1} = vec4(0.0);\n xTexelC${2*t+1}Ready = 0;\n xC${t} = vec4(0.0);`;p+="\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n ";for(let e=0;e<(h+1)/2;e++){const n=2*e;if(p+=`\n xC = xCCorner + ${n*o};\n `,1===a){if(n<u&&(r%2==1?(p+=`\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n `,p+=1===o&&n>0?`\n xC${n} = vec4(xTexelC${n-2}.zw, xTexelC${n}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${n} = vec4(previous.zw, xTexelC${n}.xy);\n } else {\n xC${n} = vec4(0.0, 0.0, xTexelC${n}.xy);\n }\n `):p+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xC${n} = xTexelC${n};\n `,n+1<u)){const t=r%2==0?cO(o):o;o%2==0&&r%2==1||o%2!=0&&r%2!=1?(p+=`\n xCOffset = xC + imod(pads[1], 2) + ${t};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n `,p+=o>1?`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${n+1} = vec4(previous.zw, xTexelC${n+1}.xy);\n } else {\n xC${n+1} = vec4(0.0, 0.0, xTexelC${n+1}.xy);\n }\n `:`\n xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+1}.xy);\n `):p+=1===t?`\n xC${n+1} = xTexelC${n};\n `:`\n xCOffset = xC + ${t};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n+1} = xTexelC${n+1};\n `}}else n<u&&(r%2==1?(p+=`\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n} = vec4(xTexelC${n}.zw, xTexelC${n+1}.zw);\n `,n+1<u&&(p+=`\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${n+1} = vec4(xTexelC${n+1}.xy, final.xy);\n `)):(p+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n} = vec4(\n xTexelC${n}.xy, xTexelC${n+1}.xy);\n `,n+1<u&&(p+=`\n xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+1}.zw);\n `)));n<u&&(p+=`\n wTexel = getW(r, ${n}, d1, d2);\n dotProd += xC${n}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${t.inChannels}) {\n dotProd += xC${n}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `,n+1<u&&(p+=`\n wTexel = getW(r, ${n+1}, d1, d2);\n dotProd += xC${n+1}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${t.inChannels}) {\n dotProd += xC${n+1}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `))}p+="\n }\n ",p+="\n }\n ",p+="\n }\n ";let c="",d="";n&&(c=i?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:s?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`vec4 activation(vec4 x) {\n ${n}\n }`,d="result = activation(result);");const f=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${c}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${p}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${f}\n ${d}\n setOutput(result);\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class jst{constructor(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=t,this.enableShapeUniforms=Dtt(this.outputShape.length);const{dataFormat:n}=e,i=ptt(),s="channelsLast"===n,r=s?1:2,a=s?2:3,o=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${t[2]} && pos < ${t[1]}) {`;let l="";for(let t=0;t<=1;t++)for(let e=0;e<=1;e++)l+=`\n blockIndex = rc.z + ${e};\n pos = rc.y + ${t};\n\n ${o}\n offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];\n d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);\n\n if(d0 < inputShape[${r}] && d0 >= 0) {\n // Use custom imod instead mod. On Intel GPU, mod may generate\n // unexpected value.\n // https://github.com/tensorflow/tfjs/issues/5447\n offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];\n d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /\n inChannels);\n\n if(d1 < inputShape[${a}] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if (${s}) {\n innerDims = vec2(d1, ch);\n result[${2*t+e}] = getChannel(\n getA(rc.x, d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2*t+e}] = getChannel(\n getA(rc.x, ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n `;this.userCode=`\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n ${l}\n\n ${i.output} = result;\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function qst(t,e){const n=t.length;return n>=3?e?[...t.slice(0,-3),t[n-3]*t[n-2],t[n-1]]:[...t.slice(0,-3),t[n-3],t[n-2]*t[n-1]]:!e&&1===n&&t[0]>1?[t[0],1]:null}function Kst({x:t,filter:e,convInfo:n,backend:i,bias:s=null,preluActivationWeights:r=null,leakyreluAlpha:a=0,activation:o=null}){const l=t.shape,u=i.texData.get(t.dataId),h=n.inChannels,p=l[0]*l[1]*l[2],c=n.outChannels,d="channelsLast"===n.dataFormat,f=!1;let m;const g=[];if(null!=r){const t=qst(r.shape,d);null!=t&&(r=uit({inputs:{x:r},backend:i,attrs:{shape:t}}),g.push(r))}if(null!=s){const t=qst(s.shape,d);null!=t&&(s=uit({inputs:{x:s},backend:i,attrs:{shape:t}}),g.push(s))}if(!((1===p||1===c)&&h>Eit)&&u.isPacked&&d&&null!=u.texture&&l[2]%2!=0&&vO(u.shape.slice(-3),l.slice(-3))){const h=l[0]*l[1]*(l[2]+1),p={dataId:t.dataId,shape:[1,h,n.inChannels],dtype:t.dtype},c=u.shape;u.shape=u.shape.slice(),u.shape[u.shape.length-2]++,_O(q7(u.shape,p.shape),(()=>`packed reshape ${u.shape} to ${p.shape} isn't free`));const d=uit({inputs:{x:e},backend:i,attrs:{shape:[1,n.inChannels,n.outChannels]}});g.push(d);const _=bit({a:p,b:d,backend:i,transposeA:false,transposeB:f,bias:s,activation:o,preluActivationWeights:r,leakyreluAlpha:a}),T=i.texData.get(_.dataId);_O(T.isPacked,(()=>"batchMatMul result is expected to be packed")),u.shape=c,T.shape=n.outShape,m=Gnt({inputs:{x:_},backend:i}),m.shape=n.outShape,g.push(_)}else{const l=n.outHeight*n.outWidth,u=uit({inputs:{x:t},backend:i,attrs:{shape:d?[n.batchSize,l,n.inChannels]:[n.batchSize,n.inChannels,l]}}),h=uit({inputs:{x:e},backend:i,attrs:{shape:[1,n.inChannels,n.outChannels]}}),p=bit({a:d?u:h,b:d?h:u,transposeA:!d,transposeB:f,backend:i,bias:s,activation:o,preluActivationWeights:r,leakyreluAlpha:a});m=uit({inputs:{x:p},backend:i,attrs:{shape:n.outShape}}),g.push(u),g.push(h),g.push(p)}for(const t of g)i.disposeIntermediateTensorInfo(t);return m}function Qst({x:t,filter:e,convInfo:n,backend:i,bias:s=null,preluActivationWeights:r=null,leakyreluAlpha:a=0,activation:o=null}){const{filterWidth:l,filterHeight:u,inChannels:h,outWidth:p,outHeight:c,dataFormat:d}=n,f="channelsLast"===d,m=l*u*h,g=c*p,_=[n.batchSize,m,g],T=[];if(null!=r){const t=qst(r.shape,f);null!=t&&(r=uit({inputs:{x:r},backend:i,attrs:{shape:t}}),T.push(r))}if(null!=s){const t=qst(s.shape,f);null!=t&&(s=uit({inputs:{x:s},backend:i,attrs:{shape:t}}),T.push(s))}const y=uit({inputs:{x:e},backend:i,attrs:{shape:[1,m,IO(e.shape)/m]}});T.push(y);const I=new jst(_,n),E=[t.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],b=i.runWebGLProgram(I,[t],"float32",E),v=uit({inputs:{x:b},backend:i,attrs:{shape:_}});T.push(b),T.push(v);const w=null!=s,S=null!=r,x="leakyrelu"===o,R=o?nit(o,!0):null,O=new iit(f?v.shape:y.shape,f?y.shape:v.shape,f?[n.batchSize,g,n.outChannels]:[n.batchSize,n.outChannels,g],!0,!1,w,R,S,x),A=f?[v,y]:[y,v];if(s&&A.push(s),S&&A.push(r),x){const t=i.makeTensorInfo([],"float32",ik(a,"float32"));A.push(t),T.push(t)}const M=i.runWebGLProgram(O,A,"float32"),C=uit({inputs:{x:M},backend:i,attrs:{shape:n.outShape}});T.push(M);for(const t of T)i.disposeIntermediateTensorInfo(t);return C}const Jst={kernelName:UA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r}=e,{strides:a,pad:o,dataFormat:l,dilations:u,dimRoundingMode:h}=i,p=_$(l),c=o$(s.shape,r.shape,a,u,o,h,!1,p);let d;if(1!==c.filterHeight||1!==c.filterWidth||1!==c.dilationHeight||1!==c.dilationWidth||1!==c.strideHeight||1!==c.strideWidth||"SAME"!==c.padInfo.type&&"VALID"!==c.padInfo.type)if(c.strideWidth<=2&&"channelsLast"===p&&aA().getBool("WEBGL_EXP_CONV")){const t=new Xst(c),e=[[c.padInfo.top,c.padInfo.left],[c.strideHeight,c.strideWidth],[c.dilationHeight,c.dilationWidth],[c.inHeight,c.inWidth]];d=n.runWebGLProgram(t,[s,r],"float32",e)}else if(aA().getBool("WEBGL_CONV_IM2COL"))d=Qst({x:s,filter:r,convInfo:c,backend:n});else{const t=new Wst(c);d=n.runWebGLProgram(t,[s,r],"float32")}else d=Kst({x:s,filter:r,convInfo:c,backend:n});const f=uit({inputs:{x:d},backend:n,attrs:{shape:c.outShape}});return n.disposeIntermediateTensorInfo(d),f}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Zst{constructor(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;const e=t.strideHeight,n=t.strideWidth,i=t.padInfo.top,s=t.padInfo.left,r="channelsLast"===t.dataFormat;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int d2 = coords.w;\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int b = 0; b < ${t.batchSize}; b++) {\n for (int yR = 0; yR < ${t.outHeight}; yR++) {\n int xR = wR + yR * ${e} - ${i};\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${t.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${s};\n\n if (xC < 0 || xC >= ${t.inWidth}) {\n continue;\n }\n\n ${r?"float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);":"float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);"}\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class trt{constructor(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;const e=t.filterHeight,n=t.filterWidth,i=t.strideHeight,s=t.strideWidth,r="channelsLast"===t.dataFormat,a=e-1-t.padInfo.top,o=n-1-t.padInfo.left,l=r?1:2,u=r?2:3,h=r?3:1;this.userCode=`\n const ivec2 pads = ivec2(${a}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${h}];\n\n ivec2 dyCorner = ivec2(coords[${l}], coords[${u}]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${e}; wR++) {\n float dyR = float(dyRCorner + wR) / ${i}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${e} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n for (int d2 = 0; d2 < ${t.outChannels}; d2++) {\n\n if (${r}) {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class ert{constructor(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;const e=t.strideDepth,n=t.strideHeight,i=t.strideWidth,s=t.padInfo.front,r=t.padInfo.top,a=t.padInfo.left;this.userCode=`\n void main() {\n ivec5 coords = getOutputCoords();\n int wF = coords.x;\n int wR = coords.y;\n int wC = coords.z;\n int d1 = coords.w;\n int d2 = coords.u;\n\n float dotProd = 0.0;\n\n for (int b = 0; b < ${t.batchSize}; b++) {\n for (int yF = 0; yF < ${t.outDepth}; yF++) {\n int xF = wF + yF * ${e} - ${s};\n\n if (xF < 0 || xF >= ${t.inDepth}) {\n continue;\n }\n\n for (int yR = 0; yR < ${t.outHeight}; yR++) {\n int xR = wR + yR * ${n} - ${r};\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${t.outWidth}; yC++) {\n int xC = wC + yC * ${i} - ${a};\n\n if (xC < 0 || xC >= ${t.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yF, yR, yC, d2);\n float xValue = getX(b, xF, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class nrt{constructor(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;const e=t.filterDepth,n=t.filterHeight,i=t.filterWidth,s=t.strideDepth,r=t.strideHeight,a=t.strideWidth,o=e-1-t.padInfo.front,l=n-1-t.padInfo.top,u=i-1-t.padInfo.left;this.userCode=`\n const ivec3 pads = ivec3(${o}, ${l}, ${u});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.u;\n\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyFCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n float dotProd = 0.0;\n for (int wF = 0; wF < ${e}; wF++) {\n float dyF = float(dyFCorner + wF) / ${s}.0;\n\n if (dyF < 0.0 || dyF >= ${t.outDepth}.0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = ${e} - 1 - wF;\n\n for (int wR = 0; wR < ${n}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${n} - 1 - wR;\n\n for (int wC = 0; wC < ${i}; wC++) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${i} - 1 - wC;\n\n for (int d2 = 0; d2 < ${t.outChannels}; d2++) {\n float xValue = getDy(batch, idyF, idyR, idyC, d2);\n float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const irt={kernelName:YA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,dy:r}=e,{strides:a,pad:o,dataFormat:l,dimRoundingMode:u,filterShape:h}=i,p=_$(l),c=o$(s.shape,h,a,1,o,u,!1,p),d=new Zst(c);return n.runWebGLProgram(d,[s,r],"float32")}};
/**
* @license
* Copyright 2023 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class srt{constructor(t){this.variableNames=["dy","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"strides",type:"vec2"}],this.outputShape=t.inShape,this.enableShapeUniforms=Dtt(this.outputShape.length);const e=t.filterHeight,n=t.filterWidth,i=e-1-t.padInfo.top,s=n-1-t.padInfo.left;this.userCode=`\n const ivec2 pads = ivec2(${i}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n\n ivec2 dyCorner = ivec2(coords[1], coords[2]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n vec4 result = vec4(0.);\n for (int wR = 0; wR < ${e}; wR++) {\n float dyR = float(dyRCorner + wR) / strides[0];\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n int wRPerm = ${e} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n int wCPerm = ${n} - 1 - wC;\n\n float dyC = float(dyCCorner + wC) / strides[1];\n bool idyCVal = (dyC >= 0.0) && (dyC < ${t.outWidth}.0)\n && (fract(dyC) == 0.0);\n int idyC = int(dyC);\n\n float dyC2 = float(dyCCorner + wC + 1) / strides[1];\n bool idyCVal2 = (dyC2 >= 0.0) && (dyC2 < ${t.outWidth}.0)\n && (fract(dyC2) == 0.0);\n int idyC2 = int(dyC2);\n\n if (idyCVal && idyCVal2) {\n for (int d2 = 0; d2 < ${t.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC, d2);\n vec4 dySample2 = (idyC / 2 == idyC2 / 2) ?\n dySample : getDy(batch, idyR, idyC2, d2);\n\n vec2 dyValue = mod(float(idyC), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.xy += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n\n dyValue = mod(float(idyC2), 2.) == 0. ?\n dySample2.xy : dySample2.zw;\n result.zw += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n } else if (idyCVal) {\n for (int d2 = 0; d2 < ${t.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC, d2);\n vec2 dyValue = mod(float(idyC), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.xy += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n } else if (idyCVal2) {\n for (int d2 = 0; d2 < ${t.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC2, d2);\n vec2 dyValue = mod(float(idyC2), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.zw += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n }\n }\n }\n setOutput(result);\n }\n `}}const rrt={kernelName:GA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,filter:r}=e,{inputShape:a,strides:o,pad:l,dataFormat:u,dimRoundingMode:h}=i,p=_$(u),c=o$(a,r.shape,o,1,l,h,!1,p);if(aA().getBool("WEBGL_PACK_CONV2DTRANSPOSE")&&"channelsLast"===p){const t=[[c.strideHeight,c.strideWidth]],e=new srt(c);return n.runWebGLProgram(e,[s,r],"float32",t)}{const t=new trt(c);return n.runWebGLProgram(t,[s,r],"float32")}}};const art={kernelName:HA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r}=e,{strides:a,pad:o,dilations:l}=i,u=l$(s.shape,r.shape,a,l,o),h=new zst(u);return n.runWebGLProgram(h,[s,r],"float32")}};const ort={kernelName:WA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,dy:r}=e,{strides:a,pad:o,filterShape:l}=i,u=l$(s.shape,l,a,1,o),h=new ert(u);return n.runWebGLProgram(h,[s,r],"float32")}};const lrt={kernelName:zA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,filter:r}=e,{pad:a,strides:o,inputShape:l}=i,u=l$(l,r.shape,o,1,a),h=new nrt(u);return n.runWebGLProgram(h,[s,r],"float32")}},urt=tit({opSnippet:Znt+"\n return cos(x);\n",packedOpSnippet:`\n vec4 result = cos(x);\n bvec4 isNaN = isnan(x);\n ${Unt}\n return result;\n`}),hrt={kernelName:XA,backendName:"webgl",kernelFunc:urt},prt=tit({opSnippet:"\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n"}),crt={kernelName:jA,backendName:"webgl",kernelFunc:prt};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class drt{constructor(t,e,n,i,s){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[r,a,o,l]=t,[u]=e,[h,p]=n;this.outputShape=[u,h,p,l];const c="bilinear"===i?1:0,[d,f]=[a-1+".0",o-1+".0"],[m,g,_]=h>1?[""+(a-1)/(h-1),"(y2-y1) * height_ratio",`y1*${d} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${d}`],[T,y,I]=p>1?[""+(o-1)/(p-1),"(x2-x1) * width_ratio",`x1*${f} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${f}`];this.userCode=`\n const float height_ratio = float(${m});\n const float width_ratio = float(${T});\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= ${r}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${y};\n\n float in_y = ${_};\n if( in_y < 0.0 || in_y > ${d} ) {\n setOutput(float(${s}));\n return;\n }\n float in_x = ${I};\n if( in_x < 0.0 || in_x > ${f} ) {\n setOutput(float(${s}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${c} == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const frt={kernelName:QA,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{image:s,boxes:r,boxInd:a}=e,{cropSize:o,method:l,extrapolationValue:u}=i,h=new drt(s.shape,r.shape,o,l,u);return n.runWebGLProgram(h,[s,r,a],"float32")}};var mrt;!function(t){t.Prod="*",t.Sum="+"}(mrt||(mrt={}));class grt{constructor(t,e,n,i){this.op=t,this.outputShape=e,this.variableNames=["x"],this.customUniforms=[{name:"index",type:"float"}];const s=this.outputShape.length,r=this.op===mrt.Prod?"1.0":"0.0",a=n?r:`getX(${_rt(s,"coords",this.op)})`,o=this.outputShape[this.outputShape.length-1];let l="",u="";n?(l=i?"end != "+(o-1):"end != 0",u=i?"end + 1":"end - 1"):(l=i?`end + pow2 < ${o}`:"end >= pow2",u=i?"end + pow2":"end - pow2"),this.userCode=`\n void main() {\n ${Ott(s)} coords = getOutputCoords();\n int end = ${Trt(s,"coords",this.op)};\n float val = ${a};\n int pow2 = int(pow(2.0, index));\n if (${l}) {\n int idx = ${u};\n ${Trt(s,"coords",this.op)} = idx;\n val ${this.op}= getX(${_rt(s,"coords",this.op)});\n }\n setOutput(val);\n }\n `}}function _rt(t,e,n){if(1===t)return`${e}`;if(2===t)return`${e}.x, ${e}.y`;if(3===t)return`${e}.x, ${e}.y, ${e}.z`;if(4===t)return`${e}.x, ${e}.y, ${e}.z, ${e}.w`;throw new Error(`Cumulative ${n} for rank ${t} is not yet supported`)}function Trt(t,e,n){if(1===t)return`${e}`;if(2===t)return`${e}.y`;if(3===t)return`${e}.z`;if(4===t)return`${e}.w`;throw new Error(`Cumulative ${n} for rank ${t} is not yet supported`)}
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function yrt(t,e,n,i,s,r){const a=e.shape.length,o=_B([i],a);let l=e;null!=o&&(l=yit({inputs:{x:e},backend:n,attrs:{perm:o}}));const u=yB(1,a)[0];if(u!==a-1)throw new Error(`WebGL cumprod shader expects an inner-most axis=${e.shape.length-1} but got axis=${i}`);const h=l.shape[u];let p=Gnt({inputs:{x:l},backend:n});for(let e=0;e<=Math.ceil(Math.log2(h))-1;e++){const i=new grt(t,l.shape,!1,r),s=[[e]],a=p;p=n.runWebGLProgram(i,[p],p.dtype,s),n.disposeIntermediateTensorInfo(a)}if(s){const e=new grt(t,l.shape,s,r),i=p;p=n.runWebGLProgram(e,[p],p.dtype),n.disposeIntermediateTensorInfo(i)}if(null!=o){const t=yit({inputs:{x:p},backend:n,attrs:{perm:TB(o)}});return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(l),t}return p}const Irt={kernelName:qA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,exclusive:a,reverse:o}=i;return yrt(mrt.Prod,s,n,r,a,o)}};const Ert={kernelName:KA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,exclusive:a,reverse:o}=i;return yrt(mrt.Sum,s,n,r,a,o)}};const brt={kernelName:JA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,weights:r}=e,{size:a,binaryOutput:o}=i;if(1===s.shape.length){const t=n.readSync(s.dataId),e=n.readSync(r.dataId),i=det(t,e,r.dtype,r.shape,a);return n.makeTensorInfo([a],r.dtype,i)}if(2===s.shape.length){const t=n.bufferSync(s),e=n.bufferSync(r),i=fet(t,e,a,o);return n.makeTensorInfo(i.shape,r.dtype,i.values)}throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${s.shape.length}.`)}};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class vrt{constructor(t,e,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=t,this.blockSize=e,this.dataFormat=n,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int h = ${this.getHeightCoordString()};\n int w = ${this.getWidthCoordString()};\n int d = ${this.getDepthCoordString()};\n\n int in_h = h / ${e};\n int offset_h = imod(h, ${e});\n int in_w = w / ${e};\n int offset_w = imod(w, ${e});\n int offset_d = (offset_h * ${e} + offset_w) *\n ${this.getOutputDepthSize()};\n int in_d = d + offset_d;\n\n float result = ${this.getInputSamplingString()};\n setOutput(result);\n }\n `}getHeightCoordString(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"}getWidthCoordString(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"}getDepthCoordString(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"}getOutputDepthSize(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]}getInputSamplingString(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"}}const wrt={kernelName:ZA,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{blockSize:r,dataFormat:a}=i,o=s.shape[0],l=("NHWC"===a?s.shape[1]:s.shape[2])*r,u=("NHWC"===a?s.shape[2]:s.shape[3])*r,h=("NHWC"===a?s.shape[3]:s.shape[1])/(r*r),p=new vrt("NHWC"===a?[o,l,u,h]:[o,h,l,u],r,a);return n.runWebGLProgram(p,[s],s.dtype)}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Srt{constructor(t,e=!1,n=null,i=!1,s=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=t.outShape,this.enableShapeUniforms=Dtt(this.outputShape.length);const r=t.filterHeight,a=t.filterWidth,o=t.outChannels/t.inChannels;let l="",u="";n&&(l=i?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:s?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,u="result = activation(result);");const h=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${l}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${o};\n int q = d2 - d1 * ${o};\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < ${r}; wR++) {\n int xR = xRCorner + wR * dilations[0];\n\n if (xR < 0 || xR >= inDims[0]) {\n continue;\n }\n\n for (int wC = 0; wC < ${a}; wC++) {\n int xC = xCCorner + wC * dilations[1];\n\n if (xC < 0 || xC >= inDims[1]) {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n ${h}\n ${u}\n setOutput(result);\n }\n `}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class xrt{constructor(t,e=!1,n=null,i=!1,s=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=t.outShape,this.enableShapeUniforms=Dtt(this.outputShape.length);const r=t.outChannels/t.inChannels,a=t.padInfo.left,o=t.strideWidth,l=t.dilationWidth,u=t.filterHeight,h=t.filterWidth,p=h;let c="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let t=0;t<h;t++)c+=`\n vec4 xTexelC${2*t};\n int xTexelC${2*t}Ready;\n vec4 xTexelC${2*t+1};\n int xTexelC${2*t+1}Ready;\n vec4 xC${t};`;c+=`\n for (int r = 0; r < ${u}; r++) {\n `;for(let t=0;t<h;t++)c+=`\n xTexelC${2*t} = vec4(0.0);\n xTexelC${2*t}Ready = 0;\n xTexelC${2*t+1} = vec4(0.0);\n xTexelC${2*t+1}Ready = 0;\n xC${t} = vec4(0.0);`;c+="\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n ";for(let t=0;t<(p+1)/2;t++){const e=2*t;if(c+=`\n xC = xCCorner + ${e*l};\n `,1===o){if(e<h&&(a%2==1?(c+=`\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${e}Ready == 0) {\n xTexelC${e} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${e}.zw = vec2(0.0);\n }\n xTexelC${e}Ready = 1;\n }\n `,c+=1===l&&e>0?`\n xC${e} = vec4(xTexelC${e-2}.zw, xTexelC${e}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${e} = vec4(previous.zw, xTexelC${e}.xy);\n } else {\n xC${e} = vec4(0.0, 0.0, xTexelC${e}.xy);\n }\n `):c+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${e}Ready == 0) {\n xTexelC${e} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${e}.zw = vec2(0.0);\n }\n xTexelC${e}Ready = 1;\n }\n\n xC${e} = xTexelC${e};\n `,e+1<h)){const t=a%2==0?cO(l):l;l%2==0&&a%2==1||l%2!=0&&a%2!=1?(c+=`\n xCOffset = xC + imod(pads[1], 2) + ${t};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${e+1}Ready == 0) {\n xTexelC${e+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${e+1}.zw = vec2(0.0);\n }\n xTexelC${e+1}Ready = 1;\n }\n `,c+=l>1?`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${e+1} = vec4(previous.zw, xTexelC${e+1}.xy);\n } else {\n xC${e+1} = vec4(0.0, 0.0, xTexelC${e+1}.xy);\n }\n `:`\n xC${e+1} = vec4(xTexelC${e}.zw, xTexelC${e+1}.xy);\n `):c+=1===t?`\n xC${e+1} = xTexelC${e};\n `:`\n xCOffset = xC + ${t};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${e+1}Ready == 0) {\n xTexelC${e+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${e+1}.zw = vec2(0.0);\n }\n xTexelC${e+1}Ready = 1;\n }\n\n xC${e+1} = xTexelC${e+1};\n `}}else e<h&&(a%2==1?(c+=`\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${e}Ready == 0) {\n xTexelC${e} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${e}.zw = vec2(0.0);\n }\n xTexelC${e}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${e+1}Ready == 0) {\n xTexelC${e+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${e+1}.zw = vec2(0.0);\n }\n xTexelC${e+1}Ready = 1;\n }\n\n xC${e} = vec4(xTexelC${e}.zw, xTexelC${e+1}.zw);\n `,e+1<h&&(c+=`\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${e+1} = vec4(xTexelC${e+1}.xy, final.xy);\n `)):(c+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${e}Ready == 0) {\n xTexelC${e} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${e}.zw = vec2(0.0);\n }\n xTexelC${e}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${e+1}Ready == 0) {\n xTexelC${e+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${e+1}.zw = vec2(0.);\n }\n xTexelC${e+1}Ready = 1;\n }\n\n xC${e} = vec4(\n xTexelC${e}.xy, xTexelC${e+1}.xy);\n `,e+1<h&&(c+=`\n xC${e+1} = vec4(xTexelC${e}.zw, xTexelC${e+1}.zw);\n `)));e<h&&(c+=`\n wTexel = getW(r, ${e}, d1, q);\n dotProd += xC${e} * vec4(wTexel.xz, wTexel.xz);\n `,e+1<h&&(c+=`\n wTexel = getW(r, ${e+1}, d1, q);\n dotProd += xC${e+1} * vec4(wTexel.xz, wTexel.xz);\n `))}c+="\n }\n ",c+="\n }\n ";let d="",f="";n&&(d=i?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:s?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`vec4 activation(vec4 x) {\n ${n}\n }`,f="result = activation(result);");const m=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),i&&this.variableNames.push("preluActivationWeights"),s&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${d}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${r};\n int q = d2 - d1 * ${r};\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${c}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${m}\n ${f}\n setOutput(result);\n }\n `}}const Rrt={kernelName:tM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r}=e,{strides:a,pad:o,dilations:l,dimRoundingMode:u}=i;let h=l;null==h&&(h=[1,1]),_O(m$(a,h),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${a} and dilations '${h}'`));const p=o$(s.shape,r.shape,a,h,o,u,!0);let c;c=aA().getBool("WEBGL_PACK_DEPTHWISECONV")&&p.strideWidth<=2&&p.outChannels/p.inChannels==1?new xrt(p):new Srt(p);const d=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];return n.runWebGLProgram(c,[s,r],"float32",d)}};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Ort{constructor(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;const e=t.strideHeight,n=t.strideWidth,i=t.padInfo.top,s=t.padInfo.left,r=t.outChannels/t.inChannels;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int dm = coords.w;\n int d2 = d1 * ${r} + dm;\n\n float dotProd = 0.0;\n\n // TO DO: Vec4 over the batch size\n for (int b = 0; b < ${t.batchSize}; b++) {\n for (int yR = 0; yR < ${t.outHeight}; yR++) {\n int xR = wR + yR * ${e} - ${i};\n\n if (xR < 0 || xR >= ${t.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${t.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${s};\n\n if (xC < 0 || xC >= ${t.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n `}}class Art{constructor(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;const e=t.filterHeight,n=t.filterWidth,i=t.strideHeight,s=t.strideWidth,r=e-1-t.padInfo.top,a=n-1-t.padInfo.left,o=t.outChannels/t.inChannels;this.userCode=`\n const ivec2 pads = ivec2(${r}, ${a});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n ivec2 dyCorner = coords.yz - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n float dotProd = 0.0;\n\n for (int wR = 0; wR < ${e}; wR++) {\n float dyR = float(dyRCorner + wR) / ${i}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${e} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${s}.0;\n\n if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n // TO DO: Vec4 over the channelMul\n for (int dm = 0; dm < ${o}; dm++) {\n int d2 = d1 * ${o} + dm;\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, dm);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const Mrt={kernelName:eM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,dy:r}=e,{strides:a,dilations:o,pad:l,dimRoundingMode:u,filterShape:h}=i,p=o$(s.shape,h,a,o,l,u,!0),c=new Ort(p);return n.runWebGLProgram(c,[s,r],"float32")}};const Crt={kernelName:nM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,filter:r}=e,{strides:a,dilations:o,pad:l,dimRoundingMode:u,inputShape:h}=i,p=o$(h,r.shape,a,o,l,u,!0),c=new Art(p);return n.runWebGLProgram(c,[s,r],"float32")}};
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Nrt{constructor(t){this.variableNames=["X"],this.outputShape=[t,t],this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n setOutput(val);\n }\n "}}const krt={kernelName:iM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{x:i}=e,s=[...i.shape,...i.shape],r=IO(i.shape),a=uit({inputs:{x:i},backend:n,attrs:{shape:[r]}}),o=new Nrt(r),l=n.runWebGLProgram(o,[a],a.dtype),u=uit({inputs:{x:l},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(l),u}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Drt{constructor(t){this.variableNames=["x","W"],this.outputShape=t.outShape;const{inHeight:e,inWidth:n,padInfo:i,strideHeight:s,strideWidth:r,filterHeight:a,filterWidth:o,dilationHeight:l,dilationWidth:u}=t,{top:h,left:p}=i;this.userCode=`\n const ivec2 strides = ivec2(${s}, ${r});\n const ivec2 pads = ivec2(${h}, ${p});\n const float neg_infinity = -3.4e38;\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.w;\n ivec2 outTopLeftCorner =\n coords.yz * strides - pads;\n int hBeg = outTopLeftCorner.x;\n int wBeg = outTopLeftCorner.y;\n\n float curVal = neg_infinity;\n for (int h = 0; h < ${a}; h++) {\n int hIn = hBeg + h * ${l};\n\n if (hIn >= 0 && hIn < ${e}) {\n for (int w = 0; w < ${o}; w++) {\n int wIn = wBeg + w * ${u};\n\n if (wIn >= 0 && wIn < ${n}) {\n float xVal = getX(batch, hIn, wIn, d1);\n float wVal = getW(h, w, d1);\n\n float val = xVal + wVal;\n if (val > curVal) {\n curVal = val;\n }\n }\n }\n }\n }\n\n float result = curVal;\n setOutput(result);\n }\n `}}const Lrt={kernelName:sM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r}=e,{strides:a,pad:o,dilations:l}=i,u=s$(s.shape,r.shape,a,o,"NHWC",l);let h;const p=new Drt(u);h=n.runWebGLProgram(p,[s,r],"float32");const c=uit({inputs:{x:h},backend:n,attrs:{shape:u.outShape}});return n.disposeIntermediateTensorInfo(h),c}};const Frt={kernelName:uM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{equation:s}=i,r=e,{allDims:a,summedDims:o,idDims:l}=UG(s,r.length);GG(a.length,l,r);const{path:u,steps:h}=HG(o,l),p=h.length;let c=null,d=a.length;const f=[];for(let t=0;t<p;++t){for(const e of h[t]){const{permutationIndices:t,expandDims:i}=YG(d,l[e]);let s;WG(t)?s=r[e]:(s=yit({inputs:{x:r[e]},backend:n,attrs:{perm:t}}),f.push(s));const a=s.shape.slice();for(let t=0;t<i.length;++t)a.splice(i[t],0,1);vO(s.shape,a)||(s=uit({inputs:{x:s},backend:n,attrs:{shape:a}}),f.push(s)),null===c?c=s:(c=oit({inputs:{a:s,b:c},backend:n}),f.push(c))}t<p-1&&(u[t]>=0&&(c=_it({inputs:{x:c},backend:n,attrs:{axis:u[t]-(a.length-d),keepDims:!1}}),f.push(c)),d--)}for(const t of f)t!==c&&n.disposeIntermediateTensorInfo(t);return c}},Prt=tit({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:"\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n"}),$rt={kernelName:hM,backendName:"webgl",kernelFunc:Prt},Brt={kernelName:pM,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n}=t,{dy:i,y:s}=e,r=aA().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Ynt("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",i.shape,s.shape):new Vnt("return (b >= 0.0) ? a : a * (b + 1.0);",i.shape,s.shape);return n.runWebGLProgram(r,[i,s],i.dtype)}},Vrt=eit({opSnippet:"return float(a == b);",packedOpSnippet:"\n return vec4(equal(a, b));\n",dtype:"bool",cpuKernelImpl:yet}),Urt={kernelName:dM,backendName:"webgl",kernelFunc:Vrt},Yrt=tit({opSnippet:`\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas,\n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n float p = ${vG};\n float a1 = ${wG};\n float a2 = ${SG};\n float a3 = ${xG};\n float a4 = ${RG};\n float a5 = ${OG};\n\n float sign = sign(x);\n x = abs(x);\n float t = 1.0 / (1.0 + p * x);\n return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n`}),Grt={kernelName:cM,backendName:"webgl",kernelFunc:Yrt},Hrt=tit({opSnippet:Znt+"\n return exp(x);\n",packedOpSnippet:"\n vec4 result = exp(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:Iet,dtype:"float32"}),Wrt={kernelName:fM,backendName:"webgl",kernelFunc:Hrt};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function zrt(t){const{inputs:e,attrs:n,backend:i}=t,{dim:s}=n,{input:r}=e,a=r.shape.length,o=r.shape.slice();let l=s;return s<0&&(_O(-(a+1)<=s,(()=>`Axis must be in the interval [${-(a+1)}, ${a}]`)),l=a+s+1),o.splice(l,0,1),uit({inputs:{x:r},backend:i,attrs:{shape:o}})}const Xrt={kernelName:mM,backendName:"webgl",kernelFunc:zrt},jrt="return exp(x) - 1.0;",qrt=tit({opSnippet:jrt,packedOpSnippet:jrt,cpuKernelImpl:Eet}),Krt={kernelName:gM,backendName:"webgl",kernelFunc:qrt};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Qrt{constructor(t,e,n){this.variableNames=["real","imag"];const i=e[1];this.outputShape=e;const s=n?`2.0 * ${Math.PI}`:`-2.0 * ${Math.PI}`,r=n?`${i}.0`:"1.0";let a;if("real"===t)a="return real * expR - imag * expI;";else{if("imag"!==t)throw new Error(`FFT component must be either "real" or "imag", got ${t}.`);a="return real * expI + imag * expR;"}this.userCode=`\n const float exponentMultiplier = ${s};\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n ${a}\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float(${i});\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < ${i}; i++) {\n // x = (-2|2 * PI / N) * index * i;\n float x = exponentMultiplierTimesIndexRatio * float(i);\n float expR = cos(x);\n float expI = sin(x);\n float real = getReal(batch, i);\n float imag = getImag(batch, i);\n\n result +=\n unaryOpComplex(real, expR, imag, expI) / ${r};\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Jrt(t,e,n){const i=n.texData.get(t.dataId),s=IO(t.shape),r=t.shape[t.shape.length-1],a=uit({inputs:{x:t},backend:n,attrs:{shape:[s/r,r]}}),o=a.shape,l=new Qrt("real",o,e),u=new Qrt("imag",o,e),h=[{dataId:i.complexTensorInfos.real.dataId,dtype:i.complexTensorInfos.real.dtype,shape:o},{dataId:i.complexTensorInfos.imag.dataId,dtype:i.complexTensorInfos.imag.dtype,shape:o}],p=n.runWebGLProgram(l,h,"float32"),c=n.runWebGLProgram(u,h,"float32"),d=Wnt({inputs:{real:p,imag:c},backend:n});n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c);const f=uit({inputs:{x:d},backend:n,attrs:{shape:t.shape}});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(d),f}const Zrt={kernelName:_M,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{input:i}=e;return Jrt(i,!1,n)}};
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class tat{constructor(t,e){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=t,this.userCode="\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function eat(t){const{backend:e,attrs:n}=t,{shape:i,value:s}=n;let{dtype:r}=n;if(r=r||GO(s),"string"===r){const t=DO(r,IO(i));return t.fill(s),e.makeTensorInfo(i,r,t)}{const t=new tat(i,s),n=[[s]];return e.runWebGLProgram(t,[],r,n)}}const nat={kernelName:TM,backendName:"webgl",kernelFunc:eat};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class iat{constructor(t){this.variableNames=["Image"],this.outputShape=[];const e=t[2];this.outputShape=t,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = ${e} - x - 1;\n float outputValue;\n if(coordX >= 0 && coordX < ${e}) {\n outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n } else {\n outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n }\n setOutput(outputValue);\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const sat={kernelName:yM,backendName:"webgl",kernelFunc:({inputs:t,backend:e})=>{const{image:n}=t,i=e,s=new iat(n.shape);return i.runWebGLProgram(s,[n],n.dtype)}},rat="return floor(x);",aat=tit({opSnippet:rat,packedOpSnippet:rat,cpuKernelImpl:bet}),oat={kernelName:IM,backendName:"webgl",kernelFunc:aat},lat=eit({opSnippet:"\n float s = sign(a) * sign(b);\n int ia = round(a);\n int ib = round(b);\n if (ib != 0) {\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n return float(idiv(ia, ib, s));\n } else {\n return NAN;\n }\n",packedOpSnippet:"\n ivec4 ia = round(a);\n ivec4 ib = round(b);\n bvec4 cond = notEqual(ib, ivec4(0));\n ivec4 result = ivec4(0);\n vec4 s = sign(a) * sign(b);\n\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n if (cond[0]) {\n result[0] = idiv(ia[0], ib[0], s[0]);\n }\n if (cond[1]) {\n result[1] = idiv(ia[1], ib[1], s[1]);\n }\n if (cond[2]) {\n result[2] = idiv(ia[2], ib[2], s[2]);\n }\n if (cond[3]) {\n result[3] = idiv(ia[3], ib[3], s[3]);\n }\n return vec4(result);\n",dtype:"int32"}),uat={kernelName:EM,backendName:"webgl",kernelFunc:lat};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class hat{constructor(t){this.variableNames=["A"];const e=ptt(),[n,i]=t;this.outputShape=t,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${i}.0, ${n}.0);\n\n vec4 values = ${e.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n `}}
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class pat{constructor(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const e=ptt(),[n,i]=t;this.outputShape=t,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${i}.0, ${n}.0);\n vec4 values = ${e.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n ${e.output} = result;\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const cat={kernelName:wN,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n,attrs:i}=t;let{pixels:s}=e;const{numChannels:r}=i,a="undefined"!=typeof HTMLVideoElement&&s instanceof HTMLVideoElement,o="undefined"!=typeof HTMLImageElement&&s instanceof HTMLImageElement,[l,u]=a?[s.videoWidth,s.videoHeight]:[s.width,s.height],h=[u,l],p=[u,l,r];if(o||a){const t=aA().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");null!=dat&&t===fat||(fat=t,dat=document.createElement("canvas").getContext("2d",{willReadFrequently:fat})),dat.canvas.width=l,dat.canvas.height=u,dat.drawImage(s,0,0,l,u),s=dat.canvas}const c=n.makeTensorInfo(h,"int32");n.texData.get(c.dataId).usage=a7.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(c.dataId),s);const d=aA().getBool("WEBGL_PACK")?new pat(p):new hat(p),f=n.runWebGLProgram(d,[c],"int32");return n.disposeData(c.dataId),f}};let dat,fat=aA().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");const mat={kernelName:RN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r,bias:a,preluActivationWeights:o}=e,{strides:l,pad:u,dataFormat:h,dilations:p,dimRoundingMode:c,activation:d,leakyreluAlpha:f}=i,m=_$(h),g=o$(s.shape,r.shape,l,p,u,c,!1,m);let _;const T=[],y=null!=a,I=null!=o,E="leakyrelu"===d,b=()=>{const t=[s,r],e=(t,e)=>{if("NCHW"===e&&1===t.shape.length&&1!==t.shape[0]){const e=uit({inputs:{x:t},backend:n,attrs:{shape:[t.shape[0],1,1]}});return T.push(e),e}return t};if(y&&t.push(e(a,h)),I&&t.push(e(o,h)),E){const e=n.makeTensorInfo([],"float32",ik(f,"float32"));t.push(e),T.push(e)}return t};if(1!==g.filterHeight||1!==g.filterWidth||1!==g.dilationHeight||1!==g.dilationWidth||1!==g.strideHeight||1!==g.strideWidth||"SAME"!==g.padInfo.type&&"VALID"!==g.padInfo.type)if(g.strideWidth<=2&&"channelsLast"===m&&aA().getBool("WEBGL_EXP_CONV")){const t=d?nit(d,!0):null,e=new Xst(g,y,t,I,E),i=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],s=b();_=n.runWebGLProgram(e,s,"float32",i)}else if(aA().getBool("WEBGL_CONV_IM2COL"))_=Qst({x:s,filter:r,convInfo:g,backend:n,bias:a,activation:d,preluActivationWeights:o,leakyreluAlpha:f});else{const t=d?nit(d,!1):null,e=new Wst(g,y,t,I,E),i=b();_=n.runWebGLProgram(e,i,"float32")}else _=Kst({x:s,filter:r,convInfo:g,backend:n,bias:a,activation:d,preluActivationWeights:o,leakyreluAlpha:f});const v=uit({inputs:{x:_},backend:n,attrs:{shape:g.outShape}});return T.push(_),T.forEach((t=>n.disposeIntermediateTensorInfo(t))),v}};const gat={kernelName:ON,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,filter:r,bias:a,preluActivationWeights:o}=e,{strides:l,pad:u,dilations:h,dimRoundingMode:p,activation:c,leakyreluAlpha:d}=i,f=[];let m=h;null==m&&(m=[1,1]),_O(m$(l,m),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${l} and dilations '${m}'`));const g=o$(s.shape,r.shape,l,m,u,p,!0),_=aA().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,T=c?nit(c,_):null,y=[s,r],I=null!=a,E=null!=o,b="leakyrelu"===c;if(I&&y.push(a),E&&y.push(o),b){const t=n.makeTensorInfo([],"float32",ik(d,"float32"));y.push(t),f.push(t)}let v;v=_?new xrt(g,I,T,E,b):new Srt(g,I,T,E,b);const w=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],S=n.runWebGLProgram(v,y,"float32",w);return f.forEach((t=>n.disposeIntermediateTensorInfo(t))),S}};class _at{constructor(t,e,n,i){this.sliceDim=t,this.strides=e,this.paramsShape=i,this.variableNames=["x","indices"],this.outputShape=n;const s=Ott(n.length);let r="\n int index;";for(let t=0;t<this.sliceDim;t++)r+=`\n index = round(getIndices(coords[0], ${t}));\n out_of_bounds = out_of_bounds || index < 0;\n out_of_bounds = out_of_bounds || index >= ${this.paramsShape[t]};\n flattenIndex += index * ${this.strides[t]};`;this.userCode=`\n void main() {\n ${s} coords = getOutputCoords();\n int flattenIndex = 0;\n bool out_of_bounds = false;\n\n ${r}\n\n setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1]));\n }\n `}}const Tat={kernelName:wM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{params:i,indices:s}=e,r=s.shape,a=r[r.length-1],o=IO(i.shape),[l,u,h,p]=oP(i,s),c=uit({inputs:{x:s},backend:n,attrs:{shape:[u,a]}}),d=uit({inputs:{x:i},backend:n,attrs:{shape:[IO(i.shape)/h,h]}});if(n.shouldExecuteOnCPU([i,s])||"string"===i.dtype){const t=n.readSync(s.dataId),e=n.bufferSync(i),r=vet(t,e,i.dtype,u,a,h,p,i.shape,o);return n.makeTensorInfo(l,i.dtype,r.values)}const f=new _at(a,p,[u,h],i.shape),m=n.runWebGLProgram(f,[d,c],d.dtype),g=uit({inputs:{x:m},backend:n,attrs:{shape:l}});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(m),g}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class yat{constructor(t,e){this.variableNames=["A","indices"],this.outputShape=e,this.rank=e.length;const n=Ott(this.rank),i=function(t){const e=["resRC.x","resRC.y","resRC.z","resRC.w"],n=[];for(let i=0;i<t.length;i++)2===i?n.push("index"):n.push(`${e[i]}`);return n.join()}(t);this.userCode=`\n void main() {\n ${n} resRC = getOutputCoords();\n int index = int(getIndices(resRC.x, resRC.z));\n float inBounds = (index >= 0) && (index < ${t[2]}) ? 1.0 : 0.0;\n setOutput(inBounds * getA(${i}));\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Iat(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,indices:r}=e,{axis:a,batchDims:o}=i,l=CO(a,s.shape)[0];if(aA().get("DEBUG")){const t=n.readSync(r.dataId),e=s.shape[l];for(let n=0;n<t.length;++n){const i=t[n];_O(i<=e-1&&i>=0,(()=>`GatherV2: the index value ${i} is not in [0, ${e-1}]`))}}const u=lH(s,r,l,o),h=IO(r.shape),p=[],c=uit({inputs:{x:s},backend:n,attrs:{shape:[u.batchSize,u.outerSize,u.dimSize,u.sliceSize]}}),d=uit({inputs:{x:r},backend:n,attrs:{shape:[u.batchSize,h/u.batchSize]}});p.push(c),p.push(d);const f=[u.batchSize,u.outerSize,h/u.batchSize,u.sliceSize];if(n.shouldExecuteOnCPU([s,r])||"string"===s.dtype){const t=n.bufferSync(d),e=n.bufferSync(c),i=wet(e,t,f);return p.forEach((t=>n.disposeIntermediateTensorInfo(t))),n.makeTensorInfo(u.outputShape,i.dtype,i.values)}const m=new yat(c.shape,f),g=n.runWebGLProgram(m,[c,d],c.dtype);p.push(g);const _=uit({inputs:{x:g},backend:n,attrs:{shape:u.outputShape}});return p.forEach((t=>n.disposeIntermediateTensorInfo(t))),_}const Eat={kernelName:vM,backendName:"webgl",kernelFunc:Iat},bat=eit({opSnippet:"return float(a > b);",packedOpSnippet:"\n return vec4(greaterThan(a, b));\n",cpuKernelImpl:xet,dtype:"bool"}),vat={kernelName:SM,backendName:"webgl",kernelFunc:bat},wat=eit({opSnippet:"return float(a >= b);",packedOpSnippet:"\n return vec4(greaterThanEqual(a, b));\n",dtype:"bool",cpuKernelImpl:Ret}),Sat={kernelName:xM,backendName:"webgl",kernelFunc:wat};const xat={kernelName:OM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{input:i}=e;return Jrt(i,!0,n)}},Rat=tit({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"}),Oat={kernelName:MM,backendName:"webgl",kernelFunc:Rat},Aat=tit({opSnippet:"return float(isinf(x));",dtype:"bool"}),Mat={kernelName:CM,backendName:"webgl",kernelFunc:Aat},Cat=tit({opSnippet:"return float(isnan(x));",dtype:"bool"}),Nat={kernelName:NM,backendName:"webgl",kernelFunc:Cat},kat=eit({opSnippet:"return float(a < b);",packedOpSnippet:"\n return vec4(lessThan(a, b));\n",cpuKernelImpl:Oet,dtype:"bool"}),Dat={kernelName:DM,backendName:"webgl",kernelFunc:kat},Lat=eit({opSnippet:"return float(a <= b);",packedOpSnippet:"\n return vec4(lessThanEqual(a, b));\n",cpuKernelImpl:Aet,dtype:"bool"}),Fat={kernelName:LM,backendName:"webgl",kernelFunc:Lat};const Pat={kernelName:FM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{backend:e,attrs:n}=t,{start:i,stop:s,num:r}=n,a=Met(i,s,r);return e.makeTensorInfo([a.length],"float32",a)}},$at=tit({opSnippet:Znt+"\n return x < 0.0 ? 0./0. : log(x);\n",packedOpSnippet:"\n vec4 result = log(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);\n result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g);\n result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);\n result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);\n return result;\n",cpuKernelImpl:Cet}),Bat={kernelName:PM,backendName:"webgl",kernelFunc:$at},Vat=tit({opSnippet:Znt+"\n return log(1.0 + x);\n"}),Uat={kernelName:$M,backendName:"webgl",kernelFunc:Vat},Yat=eit({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:"\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n",dtype:"bool"}),Gat={kernelName:BM,backendName:"webgl",kernelFunc:Yat},Hat=tit({opSnippet:"return float(!(x >= 1.0));"}),Wat={kernelName:VM,backendName:"webgl",kernelFunc:Hat},zat=eit({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:"\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n",dtype:"bool"}),Xat={kernelName:UM,backendName:"webgl",kernelFunc:zat};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class jat{constructor(t,e,n,i,s){this.variableNames=["x"],this.outputShape=[];const r=e,a=t[3]-1;let o;this.outputShape=t;const l=`float(${n}) + float(${i}) * sum`;o=.5===s?`inversesqrt(${l})`:1===s?`1.0/(${l})`:`exp(log(${l}) * float(-${s}));`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n int d = coords[3];\n float x = getX(b, r, c, d);\n float sum = 0.0;\n for (int j = -${r}; j <= ${r}; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= ${a}) {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * ${o};\n setOutput(val);\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class qat{constructor(t,e,n,i,s){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;const r=e,a=t[3]-1;let o;this.outputShape=t;const l=`float(${n}) + float(${i}) * sum`;o=.5===s?`inversesqrt(${l})`:1===s?`1.0/(${l})`:`exp(log(${l}) * float(-${s}));`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords.x;\n int r = coords.y;\n int c = coords.z;\n int d = coords.w;\n\n bool hasNextCol = d < ${this.outputShape[3]};\n bool hasNextRow = c < ${this.outputShape[2]};\n\n vec4 sum = vec4(0.);\n vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n vec4 xAtOutputCoords = vec4(\n getChannel(xFragAtOutputCoords, vec2(c, d)),\n hasNextCol ?\n getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n hasNextRow ?\n getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n (hasNextRow && hasNextCol) ?\n getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n );\n\n int firstChannel = d - ${r};\n vec2 cache = vec2(0.);\n if(firstChannel >= 0){\n vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n if(hasNextRow){\n cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n }\n }\n\n ivec2 depth = ivec2(d, d + 1);\n for (int j = - ${r}; j <= ${r}; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${a}));\n\n bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n if(depthInRange || depthPlusOneInRange){\n vec4 z = vec4(0.);\n vec4 xFragAtCurrentDepth;\n z.xz = cache.xy;\n if(depthPlusOneInRange && hasNextCol){\n xFragAtCurrentDepth = idx.y != d ?\n getX(b, r, c, idx.y) : xFragAtOutputCoords;\n z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n if(hasNextRow){\n z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n }\n }\n cache.xy = z.yw;\n sum += z * z;\n }\n }\n vec4 result = xAtOutputCoords * ${o};\n setOutput(result);\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const Kat={kernelName:WM,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{depthRadius:r,bias:a,alpha:o,beta:l}=i,u=aA().getBool("WEBGL_PACK_NORMALIZATION")?new qat(s.shape,r,a,o,l):new jat(s.shape,r,a,o,l);return n.runWebGLProgram(u,[s],s.dtype)}};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Qat{constructor(t,e,n,i,s){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=t,this.depth=t[3],this.depthRadius=e,this.bias=n,this.alpha=i,this.beta=s,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n\n float result = 0.0;\n for (int d = 0; d < ${this.depth}; ++d) {\n int depthBegin = int(max(0.0, float(d - ${e})));\n int depthEnd = int(min(float(${this.depth}),\n float(d + ${e} + 1)));\n\n const int MIN_DEPTH_BEGIN = 0;\n const int MAX_DEPTH_END = ${this.depth};\n\n float norm = 0.0;\n for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd) {\n norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n }\n else {\n break;\n }\n }\n\n norm = float(${i}) * norm + float(${n});\n\n for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd){\n float dyi = -2.0 * float(${i})\n * float(${s})\n * getInputImage(b, r, c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * ${s});\n }\n if (k == coords[3]) {\n dyi *= getDy(b, r, c, d);\n result += dyi;\n }\n }\n else {\n break;\n }\n }\n }\n setOutput(result);\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const Jat={kernelName:zM,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{x:s,y:r,dy:a}=e,{depthRadius:o,bias:l,alpha:u,beta:h}=i,p=new Qat(s.shape,o,l,u,h);return n.runWebGLProgram(p,[s,r,a],s.dtype)}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Zat(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{reductionIndices:r,keepDims:a}=i,o=s.shape.length,l=CO(r,s.shape);let u=l;const h=_B(u,o),p=null!=h,c=n.shouldExecuteOnCPU([s]);let d=s;if(p){if(c){const t=n.texData.get(d.dataId).values,e=new Array(o);for(let t=0;t<e.length;t++)e[t]=s.shape[h[t]];const i=ant(t,s.shape,s.dtype,h,e);d=n.makeTensorInfo(e,s.dtype);n.texData.get(d.dataId).values=i}else d=git(s,h,n);u=yB(u.length,o)}gB("max",u,o);const[f,m]=fB(d.shape,u);let g,_=f;if(a&&(_=mB(f,l)),c){const t=n.texData.get(d.dataId).values,e=Net(t,IO(m),_,s.dtype);g=n.makeTensorInfo(_,s.dtype);n.texData.get(g.dataId).values=e}else g=
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i){const s=IO(e),r=uit({inputs:{x:t},attrs:{shape:[IO(t.shape)/s,s]},backend:i}),a=dit(r,t.dtype,"max",i),o=uit({inputs:{x:a},attrs:{shape:n},backend:i});return i.disposeIntermediateTensorInfo(r),i.disposeIntermediateTensorInfo(a),o}(d,m,_,n);return p&&n.disposeIntermediateTensorInfo(d),g}const tot={kernelName:jM,backendName:"webgl",kernelFunc:Zat},eot=eit({opSnippet:Bnt+"\n return max(a, b);\n",packedOpSnippet:"\n vec4 result = vec4(max(a, b));\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n "+Unt+"\n return result;\n",cpuKernelImpl:ket}),not={kernelName:qM,backendName:"webgl",kernelFunc:eot};const iot={kernelName:KM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e;utt(s,"maxPool");const{filterSize:r,strides:a,pad:o,dimRoundingMode:l}=i;_O(m$(a,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '1'`));const u=r$(s.shape,r,a,1,o,l);if(1===u.filterWidth&&1===u.filterHeight&&vO(u.inShape,u.outShape))return Gnt({inputs:{x:s},backend:n});const h=new est(u,"max",!1);return n.runWebGLProgram(h,[s],s.dtype)}};const sot={kernelName:JM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{filterSize:r,strides:a,pad:o,dataFormat:l,dimRoundingMode:u}=i,h=a$(s.shape,r,a,[1,1,1],o,u,l),p=new nst(h,"max",!1);return n.runWebGLProgram(p,[s],s.dtype)}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class rot{constructor(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;const e=t.strideHeight,n=t.strideWidth,i=t.dilationHeight,s=t.effectiveFilterHeight,r=t.effectiveFilterWidth,a=s-1-t.padInfo.top,o=r-1-t.padInfo.left,l=s*r-1;this.userCode=`\n const ivec2 pads = ivec2(${a}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${s};\n wR += ${i}) {\n float dyR = float(dyRCorner + wR) / ${e}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${r}; wC++) {\n float dyC = float(dyCCorner + wC) / ${n}.0;\n\n if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = ${l} - int(getMaxPos(b, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue = wR * ${r} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n `}}class aot{constructor(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;const e=t.strideDepth,n=t.strideHeight,i=t.strideWidth,s=t.dilationDepth,r=t.dilationHeight,a=t.dilationWidth,o=t.effectiveFilterDepth,l=t.effectiveFilterHeight,u=t.effectiveFilterWidth,h=o-1-t.padInfo.front,p=l-1-t.padInfo.top,c=u-1-t.padInfo.left,d=o*l*u-1;this.userCode=`\n const ivec3 pads = ivec3(${h}, ${p}, ${c});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${o};\n wD += ${s}) {\n float dyD = float(dyDCorner + wD) / ${e}.0;\n\n if (dyD < 0.0 || dyD >= ${t.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${l};\n wR += ${r}) {\n float dyR = float(dyRCorner + wR) / ${n}.0;\n\n if (dyR < 0.0 || dyR >= ${t.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${u};\n wC += ${a}) {\n float dyC = float(dyCCorner + wC) / ${i}.0;\n\n if (dyC < 0.0 || dyC >= ${t.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n int maxPosValue = ${d} -\n int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue =\n wD * ${l} * ${u} +\n wR * ${u} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const oot={kernelName:ZM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r}=e,a=r,{filterSize:o,strides:l,pad:u,dimRoundingMode:h}=i,p=a$(a.shape,o,l,[1,1,1],u,h),c=new nst(p,"max",!0),d=n.runWebGLProgram(c,[a],a.dtype),f=new aot(p),m=n.runWebGLProgram(f,[s,d],a.dtype);return n.disposeIntermediateTensorInfo(d),m}};const lot={kernelName:QM,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{dy:s,input:r,output:a}=e,o=r;utt([r,a],"maxPoolGrad");const{filterSize:l,strides:u,pad:h,dimRoundingMode:p}=i,c=r$(o.shape,l,u,1,h,p),d=new est(c,"max",!0),f=n.runWebGLProgram(d,[o],o.dtype),m=new rot(c),g=n.runWebGLProgram(m,[s,f],o.dtype);return n.disposeIntermediateTensorInfo(f),g}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const uot={kernelName:tC,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:i}=t,{filterSize:s,strides:r,pad:a,includeBatchInIndex:o}=e,l=n;_O(4===i.shape.length,(()=>`Error in maxPool: input must be rank 4 but got rank ${i.shape.length}.`));const u=[1,1];_O(m$(r,u),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${u}'`));const h=r$(i.shape,s,r,u,a),[p,c]=
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i){let s=new est(n,"max",!1);const r=i.runWebGLProgram(s,[t],"float32");return s=new est(n,"max",!0,!0,e),[r,i.runWebGLProgram(s,[t],"float32")]}(i,o,h,l);return[p,c]}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const hot={kernelName:eC,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{x:i}=t,{keepDims:s,axis:r}=e,a=n,o=i.shape.length,l=CO(r,i.shape);let u=l;const h=_B(u,o),p=null!=h,c=a.shouldExecuteOnCPU([i]),d=[];let f=i;if(p){if(c){const t=a.texData.get(f.dataId).values,e=new Array(o);for(let t=0;t<e.length;t++)e[t]=i.shape[h[t]];const n=ant(t,i.shape,i.dtype,h,e);f=a.makeTensorInfo(e,i.dtype);a.texData.get(f.dataId).values=n}else f=git(i,h,a);d.push(f),u=yB(u.length,o)}gB("sum",u,o);const[m,g]=fB(f.shape,u);let _=m;s&&(_=mB(m,l));const T=
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t,e,n,i){const s=IO(e),r=uit({inputs:{x:t},attrs:{shape:[IO(t.shape)/s,s]},backend:i}),a=dit(r,"float32","mean",i),o=uit({inputs:{x:a},attrs:{shape:n},backend:i});return i.disposeIntermediateTensorInfo(r),i.disposeIntermediateTensorInfo(a),o}(f,g,_,a);for(const t of d)a.disposeIntermediateTensorInfo(t);return T}};const pot={kernelName:nC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i,o=s.shape.length,l=CO(r,s.shape);let u=l;const h=_B(u,o);let p=s;null!=h&&(p=yit({inputs:{x:s},backend:n,attrs:{perm:h}}),u=yB(u.length,s.shape.length)),gB("min",u,o);const[c,d]=fB(p.shape,u),f=uit({inputs:{x:p},backend:n,attrs:{shape:[-1,IO(d)]}}),m=dit(f,f.dtype,"min",n);let g;if(a){g=uit({inputs:{x:m},backend:n,attrs:{shape:mB(c,l)}})}else g=uit({inputs:{x:m},backend:n,attrs:{shape:c}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),null!=h&&n.disposeIntermediateTensorInfo(p),g}},cot=eit({opSnippet:Bnt+"\n return min(a, b);\n",packedOpSnippet:"\n vec4 result = vec4(min(a, b));\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n "+Unt+"\n return result;\n",cpuKernelImpl:Det}),dot={kernelName:iC,backendName:"webgl",kernelFunc:cot};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class fot{constructor(t,e,n){this.variableNames=["x"],this.outputShape=e.map(((e,n)=>e[0]+t[n]+e[1]));const i=t.length,s=Ott(i),r=e.map((t=>t[0])).join(","),a=e.map(((e,n)=>e[0]+t[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,i),l="reflect"===n?0:1;this.userCode=1!==i?`\n ${s} start = ${s}(${r});\n ${s} end = ${s}(${a});\n\n void main() {\n ${s} outC = getOutputCoords();\n for (int i = 0; i < ${i}; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - ${l};\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + ${l};\n }\n }\n ${s} coords = outC - start;\n setOutput(getX(${o}));\n }\n `:`\n int start = ${r};\n int end = ${a};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - ${l};\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + ${l};\n }\n setOutput(getX(outC - start));\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class mot{constructor(t,e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.map(((e,n)=>e[0]+t[n]+e[1]));const i=t.length,s=Ott(i),r=e.map((t=>t[0])).join(","),a=e.map(((e,n)=>e[0]+t[n])).join(","),o=unt("rc",i),l=unt("source",i),u=`${o[i-1]} < ${this.outputShape[i-1]}`,h=1===i?"source":`vec2(${l.slice(-2).join()})`,p="reflect"===n?0:1;let c="";if(1===i){const t=`\n ${s} source = rc;\n if (source < start) {\n source = start * 2 - source - ${p};\n } else if (source >= end) {\n source = (end - 1) * 2 - source + ${p};\n }\n source -= start;\n `;c=`\n ${s} rc = outputLoc;\n ${t}\n result[0] = getChannel(getX(${l.join()}), ${h});\n ${o[i-1]} += 1;\n if(${u}) {\n ${t}\n result[1] = getChannel(getX(${l.join()}), ${h});\n }\n `}else{const t=`\n ${s} source = rc;\n ${s} lt = ${s}(lessThan(source, start));\n ${s} gte = ${s}(greaterThanEqual(source, end));\n ${s} orig = 1 - (lt + gte);\n source = orig * source +\n lt * (start * 2 - source - ${p}) +\n gte * ((end - 1) * 2 - source + ${p});\n source -= start;\n `;c=`\n ${s} rc = outputLoc;\n ${t}\n result[0] = getChannel(getX(${l.join()}), ${h});\n ${o[i-1]} += 1;\n if(${u}) {\n ${t}\n result[1] = getChannel(getX(${l.join()}), ${h});\n }\n rc = outputLoc;\n ${o[i-2]} += 1;\n if(${o[i-2]} < ${this.outputShape[i-2]}) {\n ${t}\n result[2] = getChannel(getX(${l.join()}), ${h});\n ${o[i-1]} += 1;\n if(${u}) {\n ${t}\n result[3] = getChannel(getX(${l.join()}), ${h});\n }\n }\n `}this.userCode=`\n const ${s} start = ${s}(${r});\n const ${s} end = ${s}(${a});\n\n void main() {\n ${s} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${c}\n setOutput(result);\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const got={kernelName:sC,backendName:"webgl",kernelFunc:({inputs:t,backend:e,attrs:n})=>{const{x:i}=t,{paddings:s,mode:r}=n,a=aA().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new mot(i.shape,s,r):new fot(i.shape,s,r);return e.runWebGLProgram(a,[i],i.dtype)}},_ot=eit({opSnippet:"if (b == 0.0) return NAN;\n return mod(a, b);",packedOpSnippet:"\n vec4 result = mod(a, b);\n bvec4 isNaN = equal(b, vec4(0.0));\n "+Unt+"\n return result;\n"}),Tot={kernelName:rC,backendName:"webgl",kernelFunc:_ot};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class yot{constructor(t,e,n){this.variableNames=["probs"],this.customUniforms=[{name:"seed",type:"float"}],this.outputShape=[t,n],this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n\n float r = random(seed);\n float cdf = 0.0;\n\n for (int i = 0; i < ${e-1}; i++) {\n cdf += getProbs(batch, i);\n\n if (r < cdf) {\n setOutput(float(i));\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutput(float(${e-1}));\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const Iot=eit({opSnippet:"\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",packedOpSnippet:"\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n",checkOutOfBounds:!0}),Eot={kernelName:lM,backendName:"webgl",kernelFunc:Iot},bot="return a - b;",vot=eit({opSnippet:bot,packedOpSnippet:bot,supportsComplex:!0,cpuKernelImpl:int}),wot={kernelName:pN,backendName:"webgl",kernelFunc:vot};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Sot(t){const{inputs:e,backend:n,attrs:i}=t,{logits:s}=e,{dim:r}=i,a=CO([r],s.shape),o=Zat({inputs:{x:s},backend:n,attrs:{reductionIndices:a,keepDims:!1}}),l=mB(o.shape,a),u=uit({inputs:{x:o},backend:n,attrs:{shape:l}}),h=vot({inputs:{a:s,b:u},backend:n}),p=Hrt({inputs:{x:h},backend:n}),c=_it({inputs:{x:p},backend:n,attrs:{axis:a,keepDims:!1}}),d=uit({inputs:{x:c},backend:n,attrs:{shape:l}}),f=Iot({inputs:{a:p,b:d},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),f}const xot={kernelName:JC,backendName:"webgl",kernelFunc:Sot};const Rot={kernelName:aC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{logits:s}=e,{numSamples:r,seed:a,normalized:o}=i,l=o?s:Sot({inputs:{logits:s},backend:n,attrs:{dim:s.shape.length-1}}),u=l.shape[0],h=l.shape[1],p=new yot(u,h,r),c=[[a]],d=n.runWebGLProgram(p,[l],"int32",c);return o||n.disposeIntermediateTensorInfo(l),d}},Oot=_nt+"\n return -x;\n";const Aot={kernelName:lC,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n}=t,{x:i}=e;if(n.shouldExecuteOnCPU([i])){const t=n.texData.get(i.dataId),[e,s]=Fet(t.values,i.shape,i.dtype);return n.makeTensorInfo(s,i.dtype,e)}let s;return s=aA().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new Mnt(i.shape,"\n vec4 result = -x;\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"):new gnt(i.shape,Oot),n.runWebGLProgram(s,[i],i.dtype)}},Mot=cY;const Cot={kernelName:hC,backendName:"webgl",kernelFunc:function(t){AN("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:i}=t,{boxes:s,scores:r}=e,{maxOutputSize:a,iouThreshold:o,scoreThreshold:l}=i,u=n.readSync(s.dataId),h=n.readSync(r.dataId),{selectedIndices:p}=Mot(u,h,a,o,l);return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}},Not=dY;const kot={kernelName:pC,backendName:"webgl",kernelFunc:function(t){AN("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:i}=t,{boxes:s,scores:r}=e,{maxOutputSize:a,iouThreshold:o,scoreThreshold:l,padToMaxOutputSize:u}=i,h=n.readSync(s.dataId),p=n.readSync(r.dataId),{selectedIndices:c,validOutputs:d}=Not(h,p,a,o,l,u);return[n.makeTensorInfo([c.length],"int32",new Int32Array(c)),n.makeTensorInfo([],"int32",new Int32Array([d]))]}},Dot=fY;const Lot={kernelName:cC,backendName:"webgl",kernelFunc:function(t){AN("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");const{inputs:e,backend:n,attrs:i}=t,{boxes:s,scores:r}=e,{maxOutputSize:a,iouThreshold:o,scoreThreshold:l,softNmsSigma:u}=i,h=n.readSync(s.dataId),p=n.readSync(r.dataId),c=a,d=o,f=l,m=u,{selectedIndices:g,selectedScores:_}=Dot(h,p,c,d,f,m);return[n.makeTensorInfo([g.length],"int32",new Int32Array(g)),n.makeTensorInfo([_.length],"float32",new Float32Array(_))]}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Fot{constructor(t,e,n,i){this.variableNames=["indices"],this.outputShape=[t,e],this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float(${i}), float(${n}),\n float(index == coords.y)));\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const Pot={kernelName:fC,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{indices:s}=e,{dtype:r,depth:a,onValue:o,offValue:l}=i,u=IO(s.shape),h=new Fot(u,a,o,l),p=uit({inputs:{x:s},backend:n,attrs:{shape:[u]}}),c=n.runWebGLProgram(h,[p],r);n.disposeIntermediateTensorInfo(p);const d=uit({inputs:{x:c},backend:n,attrs:{shape:[...s.shape,a]}});return n.disposeIntermediateTensorInfo(c),d}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function $ot(t){const{inputs:e,backend:n}=t,{x:i}=e;if("complex64"===i.dtype){const t=wst({inputs:{input:i},backend:n}),e=$ot({inputs:{x:t},backend:n}),s=Vst({inputs:{input:i},backend:n}),r=$ot({inputs:{x:s},backend:n}),a=Wnt({inputs:{real:e,imag:r},backend:n});return n.disposeIntermediateTensorInfo(t),n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(s),n.disposeIntermediateTensorInfo(r),a}return eat({attrs:{shape:i.shape,dtype:i.dtype,value:"string"===i.dtype?"":0},backend:n})}const Bot={kernelName:bN,backendName:"webgl",kernelFunc:$ot};const Vot={kernelName:dC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function t(e){const{inputs:n,backend:i}=e,{x:s}=n;if("string"===s.dtype)throw new Error("onesLike is not supported under string dtype");if("complex64"===s.dtype){const e=wst({inputs:{input:s},backend:i}),n=t({inputs:{x:e},backend:i}),r=Vst({inputs:{input:s},backend:i}),a=$ot({inputs:{x:r},backend:i}),o=Wnt({inputs:{real:n,imag:a},backend:i});return i.disposeIntermediateTensorInfo(e),i.disposeIntermediateTensorInfo(n),i.disposeIntermediateTensorInfo(r),i.disposeIntermediateTensorInfo(a),o}return eat({attrs:{shape:s.shape,dtype:s.dtype,value:1},backend:i})}};const Uot={kernelName:mC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{axis:s}=i;if(1===e.length)return zrt({inputs:{input:e[0]},backend:n,attrs:{dim:s}});const r=e[0].shape,a=e[0].dtype;e.forEach((t=>{TO(r,t.shape,"All tensors passed to stack must have matching shapes"),_O(a===t.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],l=Gst({inputs:e.map((t=>{const e=zrt({inputs:{input:t},backend:n,attrs:{dim:s}});return o.push(e),e})),backend:n,attrs:{axis:s}});return o.forEach((t=>n.disposeIntermediateTensorInfo(t))),l}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Yot{constructor(t,e,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=e.map(((e,n)=>e[0]+t[n]+e[1]));const i=t.length,s=Ott(i),r=e.map((t=>t[0])).join(","),a=e.map(((e,n)=>e[0]+t[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,i);this.userCode=1!==i?`\n ${s} start = ${s}(${r});\n ${s} end = ${s}(${a});\n\n void main() {\n ${s} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${s} coords = outC - start;\n setOutput(getX(${o}));\n }\n }\n `:`\n int start = ${r};\n int end = ${a};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Got{constructor(t,e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=e.map(((e,n)=>e[0]+t[n]+e[1]));const i=t.length,s=Ott(i),r=e.map((t=>t[0])).join(","),a=e.map(((e,n)=>e[0]+t[n])).join(","),o=unt("rc",i),l=unt("source",i),u=`${o[i-1]} < ${this.outputShape[i-1]}`,h=1===i?"source":`vec2(${l.slice(-2).join()})`,p=[`${s} rc = outputLoc;`,`${o[i-1]} += 1;\n if(${u}) {\n `,1===i?"":`}\n rc = outputLoc;\n ${o[i-2]} += 1;\n if(${o[i-2]} < ${this.outputShape[i-2]}) {`,1===i?"":` ${o[i-1]} += 1;\n if(${u}) {`],c=1===i?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let d="";for(let t=0,e=1===i?2:4;t<e;t++)d+=`\n ${p[t]}\n if (${c}) {\n result[${t}] = float(value);\n } else {\n ${s} source = rc - start;\n result[${t}] = getChannel(getX(${l.join()}), ${h});\n }\n `;d+=1===i?"} ":"}}",this.userCode=`\n const ${s} start = ${s}(${r});\n const ${s} end = ${s}(${a});\n\n void main() {\n ${s} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${d}\n setOutput(result);\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const Hot=t=>{const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{paddings:r,constantValue:a}=i;if(0===IO(s.shape)){const t=r.map(((t,e)=>t[0]+s.shape[e]+t[1]));return eat({backend:n,attrs:{shape:t,value:a,dtype:s.dtype}})}const o=aA().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Got(s.shape,r,a):new Yot(s.shape,r,a),l=[[a]];return n.runWebGLProgram(o,[s],s.dtype,l)},Wot={kernelName:gC,backendName:"webgl",kernelFunc:Hot},zot=eit({opSnippet:"\n if(a < 0.0 && floor(b) < b){\n return NAN;\n }\n if (b == 0.0) {\n return 1.0;\n }\n return (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",packedOpSnippet:"\n // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n vec4 result = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n bvec4 isExpZero = equal(b, vec4(0.0));\n result.r = isExpZero.r ? 1.0 : result.r;\n result.g = isExpZero.g ? 1.0 : result.g;\n result.b = isExpZero.b ? 1.0 : result.b;\n result.a = isExpZero.a ? 1.0 : result.a;\n\n bvec4 isNaN1 = lessThan(a, vec4(0.0));\n bvec4 isNaN2 = lessThan(floor(b), b);\n bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w);\n "+Unt+"\n return result;\n"}),Xot={kernelName:TC,backendName:"webgl",kernelFunc:zot};const jot={kernelName:IC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{axis:r,keepDims:a}=i,o=s.shape.length,l=[],u=CO(r,s.shape);let h=u;const p=_B(h,o);let c,d=s;if(null!=p&&(d=yit({inputs:{x:s},backend:n,attrs:{perm:p}}),h=yB(h.length,o),l.push(d)),gB("prod",h,o),n.shouldExecuteOnCPU([d])){const t=n.texData.get(d.dataId).values,{outVals:e,outShape:i,outDtype:s}=$et(d.shape,d.dtype,t,h);c=n.makeTensorInfo(i,s,e)}else{const[t,e]=fB(d.shape,h),i=IO(e),r=uit({inputs:{x:d},backend:n,attrs:{shape:[-1,i]}}),a=dit(r,Fk(s.dtype),"prod",n);c=uit({inputs:{x:a},backend:n,attrs:{shape:t}}),l.push(r),l.push(a)}if(a){l.push(c);const t=mB(c.shape,u);c=uit({inputs:{x:c},backend:n,attrs:{shape:t}})}return l.forEach((t=>n.disposeIntermediateTensorInfo(t))),c}};const qot={kernelName:EC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{paramsNestedSplits:s,paramsDenseValues:r,indices:a}=e,{outputRaggedRank:o}=i,l=s.map((t=>n.readSync(t.dataId))),u=s.map((t=>t.shape)),h=n.readSync(r.dataId),p=n.readSync(a.dataId),[c,d,f]=Bet(l,u,h,r.shape,r.dtype,p,a.shape,o),m=c.map((t=>n.makeTensorInfo([t.length],"int32",t))),g=n.makeTensorInfo(f,r.dtype,d);return m.concat([g])}};const Kot={kernelName:bC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{starts:i,limits:s,deltas:r}=e,a=n.readSync(i.dataId),o=n.readSync(s.dataId),l=n.readSync(r.dataId),[u,h]=Vet(a,i.shape,i.dtype,o,s.shape,l,r.shape);return[n.makeTensorInfo([u.length],"int32",u),n.makeTensorInfo([h.length],i.dtype,h)]}};const Qot={kernelName:vC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{shape:s,values:r,defaultValue:a,rowPartitionTensors:o}=e,{rowPartitionTypes:l}=i,u=n.readSync(s.dataId),h=n.readSync(r.dataId),p=n.readSync(a.dataId),c=o.map((t=>n.readSync(t.dataId))),d=o.map((t=>t.shape)),[f,m]=Uet(u,s.shape,h,r.shape,r.dtype,p,a.shape,c,d,l);return n.makeTensorInfo(f,r.dtype,m)}},Jot=t=>{const{backend:e,attrs:n}=t,{start:i,stop:s,step:r,dtype:a}=n,o=Yet(i,s,r,a);return e.makeTensorInfo([o.length],a,o)},Zot={kernelName:wC,backendName:"webgl",kernelFunc:Jot},tlt=tit({opSnippet:"return 1.0 / x;"}),elt={kernelName:xC,backendName:"webgl",kernelFunc:tlt},nlt=tit({opSnippet:_nt+"\n return (x < 0.0) ? 0.0 : x;\n",packedOpSnippet:"\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),ilt={kernelName:RC,backendName:"webgl",kernelFunc:nlt},slt=tit({opSnippet:_nt+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",packedOpSnippet:"\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),rlt={kernelName:kC,backendName:"webgl",kernelFunc:slt};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class alt{constructor(t,e,n,i,s){this.variableNames=["A"],this.outputShape=[];const[r,a,o,l]=t;this.outputShape=[r,e,n,l];const u=[i&&e>1?a-1:a,i&&n>1?o-1:o],h=[i&&e>1?e-1:e,i&&n>1?n-1:n];let p;p=s?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${u[0]/h[0]},\n ${u[1]/h[1]});\n const vec2 inputShapeRC = vec2(${a}.0, ${o}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${p};\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class olt{constructor(t,e,n,i,s){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[r,a,o,l]=t;this.outputShape=[r,e,n,l];const u=[i&&e>1?a-1:a,i&&n>1?o-1:o],h=[i&&e>1?e-1:e,i&&n>1?n-1:n];let p;p=s?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${u[0]/h[0]},\n ${u[1]/h[1]},\n ${u[1]/h[1]});\n const vec3 inputShapeRC = vec3(${a}.0, ${o}.0,\n ${o}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${p};\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${l-1};\n bool hasNextRow = coords.z < ${n-1};\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n `}}const llt={kernelName:CC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s}=e,{alignCorners:r,halfPixelCenters:a,size:o}=i,[l,u]=o,h=aA().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new olt(s.shape,l,u,r,a):new alt(s.shape,l,u,r,a);return n.runWebGLProgram(h,[s],"float32")}};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class ult{constructor(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e;const[,i,s]=e,[,r,a]=t,o=[n&&r>1?i-1:i,n&&a>1?s-1:s],l=[n&&r>1?r-1:r,n&&a>1?a-1:a],u=o[0]/l[0],h=o[1]/l[1],p=1/u,c=1/h,d=2*Math.ceil(p)+2,f=2*Math.ceil(c)+2;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${u});\n const float widthScale = float(${h});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${c});\n\n const int winHeight = int(${d});\n const int winWidth = int(${f});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(startRLerp - float(winHeight / 2));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(startCLerp - float(winWidth / 2));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${r}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${a}) {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), ${i-1}.0));\n float dxRLerp = dxR - float(topDxRIndex);\n float inverseDxRLerp = 1.0 - dxRLerp;\n\n float dxC = float(dyC) * widthScale;\n int leftDxCIndex = int(floor(dxC));\n int rightDxCIndex = int(min(ceil(dxC), ${s-1}.0));\n float dxCLerp = dxC - float(leftDxCIndex);\n float inverseDxCLerp = 1.0 - dxCLerp;\n\n if (r == topDxRIndex && c == leftDxCIndex) {\n // topLeft\n accumulator +=\n getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n }\n\n if (r == topDxRIndex && c == rightDxCIndex) {\n // topRight\n accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n }\n\n if (r == bottomDxRIndex && c == leftDxCIndex) {\n // bottomLeft\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n }\n\n if (r == bottomDxRIndex && c == rightDxCIndex) {\n // bottomRight\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n `}}const hlt={kernelName:NC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s,dy:r}=e,{alignCorners:a}=i,o=new ult(r.shape,s.shape,a);return n.runWebGLProgram(o,[r],r.dtype)}};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class plt{constructor(t,e,n,i,s){this.variableNames=["A"],this.outputShape=[];const[r,a,o,l]=t;this.outputShape=[r,e,n,l];const u=[i&&e>1?a-1:a,i&&n>1?o-1:o],h=[i&&e>1?e-1:e,i&&n>1?n-1:n],p=i?"0.5":"0.0";let c;c=s?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${u[0]/h[0]},\n ${u[1]/h[1]});\n const vec2 inputShapeRC = vec2(${a}.0, ${o}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${c};\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class clt{constructor(t,e,n,i,s){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[r,a,o,l]=t;this.outputShape=[r,e,n,l];const u=[i&&e>1?a-1:a,i&&n>1?o-1:o],h=[i&&e>1?e-1:e,i&&n>1?n-1:n],p=i?"0.5":"0.0";let c;c=s?"max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${u[0]/h[0]},\n ${u[1]/h[1]},\n ${u[1]/h[1]});\n const vec3 inputShapeRC = vec3(${a}.0, ${o}.0,\n ${o}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${c};\n\n // Compute the coordinators of nearest neighbor point.\n ivec3 sourceNearestRC = ivec3(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${p})));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${l-1};\n bool hasNextRow = coords.z < ${n-1};\n\n vec4 newValue = vec4(\n getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),\n hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);\n\n setOutput(newValue);\n }\n `}}const dlt={kernelName:AC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s}=e,{alignCorners:r,halfPixelCenters:a,size:o}=i,[l,u]=o,h=aA().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new clt(s.shape,l,u,r,a):new plt(s.shape,l,u,r,a);return n.runWebGLProgram(h,[s],s.dtype)}};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class flt{constructor(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e;const[,i,s]=e,[,r,a]=t,o=[n&&r>1?i-1:i,n&&a>1?s-1:s],l=[n&&r>1?r-1:r,n&&a>1?a-1:a],u=o[0]/l[0],h=o[1]/l[1],p=1/u,c=1/h,d=2*Math.ceil(p)+2,f=2*Math.ceil(c)+2;this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${u});\n const float widthScale = float(${h});\n\n const float invHeightScale = float(${p});\n const float invWidthScale = float(${c});\n\n const int winHeight = int(${d});\n const int winWidth = int(${f});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${r}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${a}) {\n continue;\n }\n\n float sourceFracRow =\n float(${o[0]}) *\n (float(dyR) / float(${l[0]}));\n\n float sourceFracCol =\n float(${o[1]}) *\n (float(dyC) / float(${l[1]}));\n\n int sourceNearestRow = int(min(\n float(int(${i}) - 1),\n ${n} ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int(${s}) - 1),\n ${n} ? float(round(sourceFracCol)) :\n float(floor(sourceFracCol))));\n\n if (r == sourceNearestRow && c == sourceNearestCol) {\n accumulator += getDy(b, dyR, dyC, d);\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n `}}const mlt={kernelName:MC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{images:s,dy:r}=e,{alignCorners:a}=i,o=new flt(r.shape,s.shape,a);return n.runWebGLProgram(o,[r],r.dtype)}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class glt{constructor(t,e){this.variableNames=["x"];const n=t.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);if(this.outputShape=t,1===n)return void(this.userCode=`\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${t[0]} - coord - 1));\n }\n `);const i=t.map(((n,i)=>(n=>-1!==e.indexOf(n)&&1!==t[n]?`${t[n]} - coords[${n}] - 1`:`coords[${n}]`)(i))).join(","),s=Ott(n);this.userCode=`\n void main() {\n ${s} coords = getOutputCoords();\n setOutput(getX(${i}));\n }\n `}}
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class _lt{constructor(t,e){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=t.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=t;const i=unt("rc",n),s=`${i[n-1]} + 1 < ${this.outputShape[n-1]}`,r=`${i[n-2]} + 1 < ${this.outputShape[n-2]}`,a=Ott(n);function o(n){const i=t.map(((i,s)=>function(n,i){return-1!==e.indexOf(n)&&1!==t[n]?`${t[n]} - ${i[n]} - 1`:`${i[n]}`}(s,n)));return`getChannel(getX(${i.join(",")}), vec2(${i.slice(-2).join(",")}))`}this.userCode=1===n?`\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX(${t[0]} - rc - 1),\n ${t[0]} - rc - 1);\n if(${s}){\n result.g = getChannel(getX(${t[0]} - (rc + 1) - 1),\n ${t[0]} - (rc + 1) - 1);\n }\n setOutput(result);\n }\n `:`\n void main() {\n ${a} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${function(t){return o(t)}(i.slice())};\n if(${s}){\n result.g = ${function(t){return t[n-1]="("+t[n-1]+" + 1)",o(t)}(i.slice())};\n }\n if(${r}) {\n result.b = ${function(t){return t[n-2]="("+t[n-2]+" + 1)",o(t)}(i.slice())};\n if(${s}) {\n result.a = ${function(t){return t[n-1]="("+t[n-1]+" + 1)",t[n-2]="("+t[n-2]+" + 1)",o(t)}(i.slice())};\n }\n }\n setOutput(result);\n }\n `}}const Tlt={kernelName:DC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{dims:r}=i,a=s.shape.length,o=CO(r,s.shape);if(0===a)return Gnt({inputs:{x:s},backend:n});const l=aA().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new _lt(s.shape,o):new glt(s.shape,o);return n.runWebGLProgram(l,[s],s.dtype)}};
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class ylt{constructor(t,e){this.variableNames=["Image"],this.outputShape=[],this.customUniforms=[{name:"params",type:"vec4"}];const n=t[1],i=t[2];this.outputShape=t;let s="";s="number"==typeof e?`float outputValue = ${e.toFixed(2)};`:`\n vec3 fill = vec3(${e.join(",")});\n float outputValue = fill[coords[3]];`,this.userCode=`\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n int y = coords[1];\n float coordXFloat = (float(x) - params[0]) * params[3] -\n (float(y) - params[1]) * params[2];\n float coordYFloat = (float(x) - params[0]) * params[2] +\n (float(y) - params[1]) * params[3];\n int coordX = int(round(coordXFloat + params[0]));\n int coordY = int(round(coordYFloat + params[1]));\n ${s}\n if(coordX >= 0 && coordX < ${i} && coordY >= 0 && coordY < ${n}) {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
const Ilt={kernelName:SN,backendName:"webgl",kernelFunc:({inputs:t,attrs:e,backend:n})=>{const{image:i}=t,{radians:s,fillValue:r,center:a}=e,o=n,l=new ylt(i.shape,r),[u,h]=mG(a,i.shape[1],i.shape[2]),p=[[u,h,Math.sin(s),Math.cos(s)]];return o.runWebGLProgram(l,[i],i.dtype,p)}},Elt=tit({opSnippet:"\n // OpenGL ES does not support round function.\n // The algorithm is based on banker's rounding.\n float base = floor(x);\n if ((x - base) < 0.5) {\n return floor(x);\n } else if ((x - base) > 0.5) {\n return ceil(x);\n } else {\n if (mod(base, 2.0) == 0.0) {\n return base;\n } else {\n return base + 1.0;\n }\n }\n"}),blt={kernelName:LC,backendName:"webgl",kernelFunc:Elt},vlt=tit({opSnippet:"return inversesqrt(x);",cpuKernelImpl:Get}),wlt={kernelName:FC,backendName:"webgl",kernelFunc:vlt};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Slt{constructor(t,e,n,i,s,r,a=!0,o=!1){this.variableNames=["updates","indices","defaultValue"],this.outputShape=r;const l=Ott(s.length),u=Ott(r.length);let h="";1===n?h="i":2===n&&(h="i, j");const p=`getIndices(${h})`;let c="";1===i?c="i":2===i&&(c="i, coords[1]");const d=`getUpdates(${c})`;let f="";o&&(f="coords[0], coords[1]");const m=`getDefaultValue(${f})`,g=e>1?"strides[j]":"strides";this.userCode=`\n ${l} strides = ${l}(${s});\n\n void main() {\n ${u} coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < ${t}; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < ${e}; j++) {\n int index = round(${p});\n flattenedIndex += index * ${g};\n }\n if (flattenedIndex == coords[0]) {\n sum += ${d};\n found = true;\n }\n }\n setOutput(mix(${m}, sum, float(found)));\n }\n `}}
/**
* @license
* Copyright 2023 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class xlt{constructor(t,e,n,i,s,r,a=!0,o=!1){this.variableNames=["updates","indices","defaultValue"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=r;const l=Ott(s.length),u=Ott(r.length);let h="";1===n?h="i":2===n&&(h="i, j");const p=`getIndices(${h})`;let c="";1===i?c="i":2===i&&(c="i, coords[1]");const d=`getUpdates(${c})`;let f="";o&&(f="coords[0], coords[1]");const m=`getDefaultValue(${f})`,g=e>1?"strides[j]":"strides",_=e>1?"strides[j + 1]":"strides";this.userCode=`\n ${l} strides = ${l}(${s});\n\n void main() {\n ${u} coords = getOutputCoords();\n vec4 sum = vec4(0.);\n vec4 found = vec4(0.);\n for (int i = 0; i < ${t}; i+=2) {\n ivec2 flattenedIndex = ivec2(0);\n for (int j = 0; j < ${e}; j+=2) {\n ivec4 index = round(${p});\n flattenedIndex += index.xz * ${g};\n if (j + 1 < ${e}) {\n flattenedIndex += index.yw * ${_};\n }\n }\n if (flattenedIndex[0] == coords[0] || flattenedIndex[1] == coords[0] ||\n flattenedIndex[0] == coords[0] + 1 || flattenedIndex[1] == coords[0] + 1) {\n vec4 updVals = ${d};\n if (flattenedIndex[0] == coords[0]) {\n sum.xy += updVals.xy;\n found.xy = vec2(1.);\n } else if (flattenedIndex[0] == coords[0] + 1) {\n sum.zw += updVals.xy;\n found.zw = vec2(1.);\n }\n if (flattenedIndex[1] == coords[0]) {\n sum.xy += updVals.zw;\n found.xy = vec2(1.);\n } else if (flattenedIndex[1] == coords[0] + 1) {\n sum.zw += updVals.zw;\n found.zw = vec2(1.);\n }\n }\n }\n setOutput(mix(${m}, sum, found));\n }\n `}}const Rlt={kernelName:PC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{indices:s,updates:r}=e,{shape:a}=i,{sliceRank:o,numUpdates:l,sliceSize:u,strides:h,outputSize:p}=hP(0,s,a),c=[p/u,u];if(0===p)return n.makeTensorInfo(a,s.dtype);const d=uit({inputs:{x:s},backend:n,attrs:{shape:[l,o]}}),f=uit({inputs:{x:r},backend:n,attrs:{shape:[l,u]}}),m=n.makeTensorInfo([],"float32",new Float32Array([0]));let g;g=aA().getBool("WEBGL_PACK")?new xlt(l,o,d.shape.length,f.shape.length,h,c):new Slt(l,o,d.shape.length,f.shape.length,h,c);const _=n.runWebGLProgram(g,[f,d,m],f.dtype),T=uit({inputs:{x:_},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(_),n.disposeIntermediateTensorInfo(m),T}};
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Olt{constructor(t,e,n,i){this.variableNames=["sortedSequence","values"],this.customUniforms=[{name:"numInputs",type:"int"}],this.outputShape=[t,n];const s=`for (int i = 0; i < ${Math.ceil(Math.log2(e+1))}; ++i) { if (left >= right) break;`,r=2===aA().getNumber("WEBGL_VERSION")?"while (left < right) {":s,a="left"===i?"<":"<=";this.userCode=`\n int findBound(int batch, float value) {\n int left = 0;\n int right = numInputs;\n int mid;\n ${r}\n mid = (left + right) / 2;\n if (getSortedSequence(batch, mid) ${a} value) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return right;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int valueIndex = coords[1];\n\n float value = getValues(batch, valueIndex);\n\n setOutput(float(findBound(batch, value)));\n }\n `}}const Alt={kernelName:BC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{sortedSequence:s,values:r}=e,{side:a}=i,o=new Olt(s.shape[0],s.shape[1],r.shape[1],a),l=[[s.shape[1]]];return n.runWebGLProgram(o,[s,r],"int32",l)}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Mlt{constructor(t,e,n){let i,s;if(this.variableNames=["c","a","b"],this.outputShape=e,n>4)throw Error(`Where for rank ${n} is not yet supported`);if(1===n)s="resRC",i="resRC";else{const n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[],a=[];for(let i=0;i<e.length;i++)a.push(`${n[i]}`),i<t&&r.push(`${n[i]}`);i=r.join(),s=a.join()}const r=Ott(n);this.userCode=`\n void main() {\n ${r} resRC = getOutputCoords();\n float cVal = getC(${i});\n if (cVal >= 1.0) {\n setOutput(getA(${s}));\n } else {\n setOutput(getB(${s}));\n }\n }\n `}}const Clt={kernelName:VC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{condition:i,t:s,e:r}=e,a=new Mlt(i.shape.length,s.shape,s.shape.length);return n.runWebGLProgram(a,[i,s,r],Lk(s.dtype,r.dtype))}},Nlt=tit({opSnippet:`\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = ${EG};\n float scale = ${bG};\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n`}),klt={kernelName:UC,backendName:"webgl",kernelFunc:Nlt},Dlt=tit({opSnippet:Znt+"\n return 1.0 / (1.0 + exp(-1.0 * x));\n",packedOpSnippet:"\n vec4 result = 1.0 / (1.0 + exp(-1.0 * x));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:Wet}),Llt={kernelName:zC,backendName:"webgl",kernelFunc:Dlt},Flt=tit({opSnippet:"\n if (isnan(x)) { return 0.0; }\n return sign(x);\n"}),Plt={kernelName:WC,backendName:"webgl",kernelFunc:Flt},$lt=tit({opSnippet:Znt+"\n return sin(x);\n",packedOpSnippet:`\n vec4 result = sin(x);\n bvec4 isNaN = isnan(x);\n ${Unt}\n return result;\n`}),Blt={kernelName:GC,backendName:"webgl",kernelFunc:$lt},Vlt=tit({opSnippet:"\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n"}),Ult={kernelName:HC,backendName:"webgl",kernelFunc:Vlt},Ylt=tit({opSnippet:"\n float epsilon = 1.1920928955078125e-7;\n float threshold = log(epsilon) + 2.0;\n\n bool too_large = x > -threshold;\n bool too_small = x < threshold;\n\n float result;\n float exp_x = exp(x);\n\n if (too_large){\n result = x;\n }\n else if (too_small){\n result = exp_x;\n }\n else{\n result = log(exp_x + 1.0);\n }\n return result;\n"}),Glt={kernelName:XC,backendName:"webgl",kernelFunc:Ylt},Hlt={kernelName:KC,backendName:"webgl",kernelFunc:t=>{const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{blockShape:r,paddings:a}=i;_O(s.shape.length<=4,(()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"));const o=r.reduce(((t,e)=>t*e)),l=[[0,0]];l.push(...a);for(let t=1+r.length;t<s.shape.length;++t)l.push([0,0]);const u=[],h=Hot({inputs:{x:s},backend:n,attrs:{paddings:l,constantValue:0}}),p=gG(h.shape,r,o,!1),c=_G(p.length,r.length,!1),d=TG(h.shape,r,o,!1),f=uit({inputs:{x:h},backend:n,attrs:{shape:p}}),m=yit({inputs:{x:f},backend:n,attrs:{perm:c}}),g=uit({inputs:{x:m},backend:n,attrs:{shape:d}});return u.push(h),u.push(f),u.push(m),u.forEach((t=>n.disposeIntermediateTensorInfo(t))),g}};const Wlt={kernelName:ZC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{indices:i,values:s,denseShape:r,defaultValue:a}=e;if(1!==r.shape.length)throw new Error(`Dense shape must be a vector, saw:\n ${r.shape}`);if(2!==i.shape.length)throw new Error(`Indices must be a matrix, saw:\n ${i.shape}`);if(1!==s.shape.length)throw new Error(`Values must be a vector, saw:\n ${s.shape}`);if(0!==a.shape.length)throw new Error(`Default value must be a scalar, saw:\n ${a.shape}`);const o=n.readSync(i.dataId),l=n.readSync(s.dataId),u=n.readSync(r.dataId),h=n.readSync(a.dataId)[0],[p,c,d,f,m]=jet(o,i.shape,i.dtype,l,s.dtype,u,h);return[n.makeTensorInfo(c,i.dtype,p),n.makeTensorInfo([c[0]],s.dtype,d),n.makeTensorInfo([f.length],"bool",new Uint8Array(f.map((t=>Number(t))))),n.makeTensorInfo([m.length],i.dtype,new Int32Array(m))]}};const zlt={kernelName:tN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{inputIndices:i,inputShape:s,newShape:r}=e;if(2!==i.shape.length)throw new Error(`Input indices should be a matrix but received shape ${i.shape}`);if(1!==s.shape.length)throw new Error(`Input shape should be a vector but received shape ${s.shape}`);if(1!==r.shape.length)throw new Error(`Target shape should be a vector but received shape ${r.shape}`);const a=Array.from(n.readSync(s.dataId)),o=n.readSync(i.dataId),l=Array.from(n.readSync(r.dataId)),[u,h,p]=qet(o,i.shape,i.dtype,a,l);return[n.makeTensorInfo(h,i.dtype,u),n.makeTensorInfo([p.length],r.dtype,new Int32Array(p))]}};const Xlt={kernelName:eN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{data:i,indices:s,segmentIds:r}=e;if(i.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.shape.length)throw new Error(`Indices should be a vector but received shape\n ${s.shape}`);if(1!==r.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${r.shape}`);const a=n.readSync(i.dataId),o=n.readSync(s.dataId),l=n.readSync(r.dataId),[u,h]=Ket(a,i.shape,i.dtype,o,l,!0);return n.makeTensorInfo(h,i.dtype,u)}};const jlt={kernelName:nN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n}=t,{data:i,indices:s,segmentIds:r}=e;if(i.shape.length<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==s.shape.length)throw new Error(`Indices should be a vector but received shape\n ${s.shape}`);if(1!==r.shape.length)throw new Error(`Segment ids should be a vector but received shape\n ${r.shape}`);const a=n.readSync(i.dataId),o=n.readSync(s.dataId),l=n.readSync(r.dataId),[u,h]=Ket(a,i.shape,i.dtype,o,l);return n.makeTensorInfo(h,i.dtype,u)}};const qlt={kernelName:iN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{sparseIndices:s,sparseValues:r,defaultValue:a}=e,{outputShape:o}=i,{sliceRank:l,numUpdates:u,sliceSize:h,strides:p,outputSize:c}=hP(0,s,o),d=!1;if("string"===r.dtype){const t=n.bufferSync(s),e=n.bufferSync(r),i=lk(n.readSync(a.dataId)[0]),f=Het(t,e,o,c,h,u,l,p,i,d);return n.makeTensorInfo(o,f.dtype,f.values)}const f=new Slt(u,l,s.shape.length,r.shape.length,p,[c,1],d),m=n.runWebGLProgram(f,[r,s,a],r.dtype),g=uit({inputs:{x:m},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(m),g}};const Klt={kernelName:QC,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{numOrSizeSplits:r,axis:a}=i,o=CO(a,s.shape)[0],l=XG(s,r,o),u=s.shape.length,h=new Array(u).fill(0),p=s.shape.slice();return l.map((t=>{const e=[...p];e[o]=t;const i=gst({inputs:{x:s},backend:n,attrs:{begin:h,size:e}});return h[o]+=t,i}))}},Qlt="return sqrt(x);",Jlt=tit({opSnippet:Qlt,packedOpSnippet:Qlt,cpuKernelImpl:Qet}),Zlt={kernelName:jC,backendName:"webgl",kernelFunc:Jlt},tut=tit({opSnippet:"return x * x;"}),eut={kernelName:rN,backendName:"webgl",kernelFunc:tut},nut="return (a - b) * (a - b);",iut=eit({opSnippet:nut,packedOpSnippet:nut}),sut={kernelName:sN,backendName:"webgl",kernelFunc:iut};const rut={kernelName:aN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2023 Google LLC.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e;if("string"!==s.dtype)throw new Error("Input must be of datatype string");const r=uH(n.readSync(s.dataId)),a=Jet(r,"string",i);return n.makeTensorInfo(s.shape,"string",a)}};const aut={kernelName:vN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function({inputs:t,attrs:e,backend:n}){const{x:i}=t,s=_nt+`\n return x > 0.0 ? 1.0 : float(${e.alpha});\n `,r=new gnt(i.shape,s);return n.runWebGLProgram(r,[i],i.dtype)}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class out{constructor(t,e,n){this.variableNames=["x"],this.outputShape=n;const i=n.length,s=Ott(n.length),r=Ott(n.length);let a="";if(1===i)a="coords * strides + begin";else{let t=0;a=n.map(((e,i)=>(t++,1===n.length?`coords * strides[${i}] + begin[${i}]`:`coords[${t-1}] * strides[${i}] + begin[${i}]`))).join(",")}this.userCode=`\n ${s} begin = ${s}(${t});\n ${s} strides = ${s}(${e});\n\n void main() {\n ${r} coords = getOutputCoords();\n setOutput(getX(${a}));\n }\n `}}const lut={kernelName:oN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{begin:r,end:a,strides:o,beginMask:l,endMask:u,ellipsisMask:h,newAxisMask:p,shrinkAxisMask:c}=i,{finalShapeSparse:d,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:_,begin:T,end:y,strides:I}=OP(s.shape,r,a,o,l,u,h,p,c);let E;if(m)E=uit({inputs:{x:s},backend:n,attrs:{shape:f}});else if(g||_){_O(s.shape.length>=1,(()=>`Input must have rank at least 1, got: ${s.shape.length}`));const t=mP(T,y,I),e=gst({inputs:{x:s},backend:n,attrs:{begin:T,size:t}});E=uit({inputs:{x:e},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(e)}else{if(n.shouldExecuteOnCPU([s])){const t=n.readSync(s.dataId),e=FL(s.shape,s.dtype,t),i=Zet(d,e,I,T);E=n.makeTensorInfo(f,s.dtype,i.values)}else{const t=new out(T,I,d);E=n.runWebGLProgram(t,[s],s.dtype)}}const b=uit({inputs:{x:E},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(E),b}};const uut={kernelName:lN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{separator:s,nGramWidths:r,leftPad:a,rightPad:o,padWidth:l,preserveShortSequences:u}=i,{data:h,dataSplits:p}=e,c=n.readSync(h.dataId),d=n.readSync(p.dataId),[f,m]=tnt(c,d,s,r,a,o,l,u);return[n.makeTensorInfo([f.length],"string",f),n.makeTensorInfo(p.shape,"int32",m)]}};const hut={kernelName:uN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{skipEmpty:s}=i,{input:r,delimiter:a}=e;if("string"!==r.dtype)throw new Error("Input must be of datatype string");if(1!==r.shape.length)throw new Error(`Input must be a vector, got shape: ${r.shape}`);if(0!==a.shape.length)throw new Error(`Delimiter must be a scalar, got shape: ${a.shape}`);const o=n.readSync(r.dataId),l=n.readSync(a.dataId)[0],[u,h,p]=ent(o,l,s),c=h.length;return[n.makeTensorInfo([c,2],"int32",u),n.makeTensorInfo([c],"string",h),n.makeTensorInfo([2],"int32",new Int32Array(p))]}};const put={kernelName:hN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{numBuckets:s}=i,{input:r}=e;if("string"!==r.dtype)throw new Error("Input must be of datatype string");if(s<=0)throw new Error("Number of buckets must be at least 1");const a=n.readSync(r.dataId),o=nnt(a,s);return n.makeTensorInfo(r.shape,"int32",o)}},cut=tit({opSnippet:"return tan(x);"}),dut={kernelName:cN,backendName:"webgl",kernelFunc:cut},fut=tit({opSnippet:"\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n"}),mut={kernelName:dN,backendName:"webgl",kernelFunc:fut};const gut={kernelName:$C,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2022 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{tensor:s,indices:r,updates:a}=e,{}=i,{sliceRank:o,numUpdates:l,sliceSize:u,strides:h,outputSize:p}=hP(0,r,s.shape),c=[p/u,u];if(0===p)return n.makeTensorInfo(s.shape,r.dtype);const d=uit({inputs:{x:r},backend:n,attrs:{shape:[l,o]}}),f=uit({inputs:{x:a},backend:n,attrs:{shape:[l,u]}}),m=uit({inputs:{x:s},backend:n,attrs:{shape:c}}),g=new Slt(l,o,d.shape.length,f.shape.length,h,c,!1,!0),_=n.runWebGLProgram(g,[f,d,m],m.dtype),T=uit({inputs:{x:_},backend:n,attrs:{shape:s.shape}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(_),T}};
/**
* @license
* Copyright 2017 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class _ut{constructor(t,e){this.variableNames=["A"];const n=new Array(t.length);for(let i=0;i<n.length;i++)n[i]=t[i]*e[i];this.outputShape=n,this.rank=n.length;const i=Ott(this.rank),s=function(t){const e=t.length;if(e>5)throw Error(`Tile for rank ${e} is not yet supported`);if(1===e)return`imod(resRC, ${t[0]})`;const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],i=[];for(let e=0;e<t.length;e++)i.push(`imod(${n[e]}, ${t[e]})`);return i.join()}(t);this.userCode=`\n void main() {\n ${i} resRC = getOutputCoords();\n setOutput(getA(${s}));\n }\n `}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function Tut(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{reps:r}=i;if("string"===s.dtype||s.shape.length>5){const t=n.readSync(s.dataId),e="string"===s.dtype?t.map((t=>lk(t))):t,i=FL(s.shape,s.dtype,e),a=snt(i,r);return n.makeTensorInfo(a.shape,a.dtype,a.values)}const a=new _ut(s.shape,r);return n.runWebGLProgram(a,[s],s.dtype)}const yut={kernelName:fN,backendName:"webgl",kernelFunc:Tut};class Iut{constructor(t){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"negativeInf",type:"float"},{name:"dir",type:"int"},{name:"inc",type:"int"}],this.outputShape=t,this.userCode="\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // We compare elements pair-wise within a group of size 2 * inc.\n // The comparing rule for each group alternates between ascending\n // and descending. Within each group, we compare each pair at\n // positions i and i+inc. To decide whether an element at position i\n // is x0 or x1, we mod it by 2 * inc, if the result is smaller than\n // inc, it is in the first half of the group, we denote it as x0,\n // otherwise we denote it as x1.\n // For example, as shown in the Bitonic top K paper referenced above,\n // Figure5(a) shows that element[1] is in the\n // second half of the group when group size is 2, but it is in the\n // first half of the group when group size is 4.\n\n bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;\n int i = isFirstInPair ? elemIdx : elemIdx - inc;\n\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));\n float x0 = i0 < n ? getX(batch, i0) : negativeInf;\n float x1 = i1 < n ? getX(batch, i1) : negativeInf;\n\n // Denotes which direction indices are in (ascending or descending).\n bool reverse = imod(elemIdx, 2 * dir) >= dir;\n bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);\n if (reverse == isGreater) { // Elements in opposite order of direction\n int iTemp = i0;\n i0 = i1;\n i1 = iTemp;\n }\n if (isFirstInPair) {\n setOutput(float(i0));\n } else {\n setOutput(float(i1));\n }\n }\n "}}class Eut{constructor(t){this.variableNames=["x","indices"],this.customUniforms=[{name:"n",type:"int"},{name:"firstPass",type:"int"},{name:"k",type:"int"}],this.outputShape=t,this.userCode="\n void main() {\n // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // The output size is half of the previous size.\n // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),\n // we only need to output the indices at positions |, the indices at\n // positions _ can be thrown away, see Figure5(b) After Phase 2\n // (Merge phase) in the Bitonic Top K paper referenced above.\n // For example, the paper shows we only need to output the orange bars.\n // The output sequence should look like this | | | | | | | |.\n // Because the sequence is halved, to map the output index back\n // to the previous sequence to find the corresponding value,\n // we need to double the index. When we double the index,\n // we basically interpolate a position, so 2i looks like\n // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position\n // of each 2k positions by - elemIdx % k. E.g. for output at\n // index 4,5,6,7, we want to get the corresponding element at\n // original index 8,9,10,11, for output at index 8,9,10,11,\n // we want to get the corresponding element at original index\n // 16,17,18,19, so on and so forth.\n\n int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));\n\n float x0 = getX(batch, i0);\n float x1 = i1 < n ? getX(batch, i1) : x0;\n\n setOutput(x0 >= x1 ? float(i0) : float(i1));\n }\n "}}
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function but(t,e){null!==e&&t.disposeIntermediateTensorInfo(e)}function vut(t){let e=1;for(;e<t;)e*=2;return e}const wut={kernelName:mN,backendName:"webgl",kernelFunc:function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s}=e,{k:r,sorted:a}=i,o=aA().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"),l=aA().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"),u=s.shape,h=u[u.length-1];if(n.shouldExecuteOnCPU([s])||h<o||r>l){const t=n.readSync(s.dataId),[e,i]=rnt(t,u,s.dtype,r,a);return[n.makeTensorInfo(e.shape,e.dtype,e.values),n.makeTensorInfo(i.shape,i.dtype,i.values)]}if(0===r)return u[u.length-1]=0,[n.makeTensorInfo(u,s.dtype,[]),n.makeTensorInfo(u,"int32",[])];if(1===h)return[s,eat({attrs:{shape:u,dtype:"int32",value:0},backend:n})];const p=n.texData.get(s.dataId),c=null!==p&&p.isPacked,d=c?n.unpackTensor(s):s,f=IO(u)/h,m=uit({inputs:{x:d},attrs:{shape:[f,h]},backend:n});c&&but(n,d);const g=vut(r),_=vut(h);let T=null;const y=()=>null===T?[m,m]:[m,T],I=(t,e,i)=>{const s=y(),r=new Iut(i),a=[[h],[null===T?1:0],[Number.NEGATIVE_INFINITY],[t],[e]],o=T;T=n.runWebGLProgram(r,s,"int32",a),but(n,o)};for(let t=1;t<g;t*=2){const e=2*t;for(let n=t;n>=1;n/=2)I(e,n,[f,_])}for(let t=_;t>g;t/=2){const e=y(),i=new Eut([f,t/2]),s=[[h],[null===T?1:0],[g]],r=T;T=n.runWebGLProgram(i,e,"int32",s),but(n,r);const a=g/2,o=2*a;for(let t=a;t>=1;t/=2)I(o,t,T.shape)}let E=T;T=gst({inputs:{x:T},backend:n,attrs:{begin:0,size:[f,r]}}),but(n,E);let b=Iat({inputs:{x:m,indices:T},backend:n,attrs:{axis:1,batchDims:1}});but(n,m);const v=u.slice(0,-1);v.push(r),E=T,T=uit({inputs:{x:T},attrs:{shape:v},backend:n}),but(n,E);const w=b;return b=uit({inputs:{x:b},attrs:{shape:v},backend:n}),but(n,w),[b,T]}};
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Sut{constructor(t,e,n,i,s,r){this.variableNames=["Image","Transforms"],this.outputShape=r;const a="nearest"===n?1:2;let o;switch(i){case"constant":default:o=1;break;case"reflect":o=2;break;case"wrap":o=3;break;case"nearest":o=4}this.userCode=`\n float mapCoord(float outCoord, float len) {\n float inCoord = outCoord;\n if(${o} == 2) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n if (inCoord < sz2) {\n inCoord = sz2 * float(int(float(-inCoord / sz2))) +\n inCoord;\n }\n inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n inCoord -= sz2 * float(int(float(inCoord / sz2)));\n if (inCoord >= len) {\n inCoord = sz2 - inCoord - 1.0;\n }\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${o} == 3) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord -= len * float(int(float(inCoord / sz)));\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${o} == 4) {\n return clamp(outCoord, 0.0, len - 1.0);\n } else {\n return outCoord;\n }\n }\n\n float readWithFillValue(int batch, int coordY, int coordX,\n int channel) {\n float outputValue;\n if (0 <= coordY && coordY < ${t} && 0 <= coordX && coordX < ${e}) {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float(${s});\n }\n return outputValue;\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n float outputValue;\n int batch = coords[0];\n int x = coords[2];\n int y = coords[1];\n int channel = coords[3];\n float xf = float(x);\n float yf = float(y);\n float a1 = getTransforms(batch, 0);\n float a2 = getTransforms(batch, 1);\n float a3 = getTransforms(batch, 2);\n float b1 = getTransforms(batch, 3);\n float b2 = getTransforms(batch, 4);\n float b3 = getTransforms(batch, 5);\n float c1 = getTransforms(batch, 6);\n float c2 = getTransforms(batch, 7);\n float projection = c1 * xf + c2 * yf + 1.0;\n if (projection == 0.0) {\n outputValue = float(${s});\n } else {\n float inX = (a1 * xf + a2 * yf + a3) / projection;\n float inY = (b1 * xf + b2 * yf + b3) / projection;\n float mapX = mapCoord(inX, float(${e}));\n float mapY = mapCoord(inY, float(${t}));\n\n if (${a} == 1) {\n int coordY = int(round(mapY));\n int coordX = int(round(mapX));\n outputValue = readWithFillValue(batch, coordY, coordX,\n channel);\n } else {\n float yFloor = floor(mapY);\n float xFloor = floor(mapX);\n float yCeil = yFloor + 1.0;\n float xCeil = xFloor + 1.0;\n float valueYFloor = (xCeil - mapX) *\n readWithFillValue(batch, int(yFloor), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yFloor), int(xCeil), channel);\n float valueYCeil = (xCeil - mapX) *\n readWithFillValue(batch, int(yCeil), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yCeil), int(xCeil), channel);\n outputValue = (yCeil - mapY) * valueYFloor +\n (mapY - yFloor) * valueYCeil;\n }\n }\n setOutput(outputValue);\n }\n `}}const xut={kernelName:gN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{image:s,transforms:r}=e,{interpolation:a,fillMode:o,fillValue:l,outputShape:u}=i,[h,p,c,d]=s.shape,[f,m]=null!=u?u:[p,c],g=new Sut(p,c,a,o,l,[h,f,m,d]);return n.runWebGLProgram(g,[s,r],"float32")}};const Rut={kernelName:TN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,attrs:n,backend:i}=t,{axis:s}=n,{x:r}=e;utt(r,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");const a=i.readSync(r.dataId),{outputValues:o,outputShape:l,indices:u}=ont(a,s,r.shape,r.dtype);return[i.makeTensorInfo(l,r.dtype,o),i.makeTensorInfo([u.length],"int32",u)]}};const Out={kernelName:yN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{value:s}=e;let{axis:r}=i;r<0&&(r+=s.shape.length);const a=s,o=a.shape.length,l=s.shape[r],u=new Array(o-1);let h=0;for(let t=0;t<o;t++)t!==r&&(u[h++]=a.shape[t]);const p=[],c=new Array(o).fill(0),d=a.shape.slice();d[r]=1;const f=new Array(l);for(let t=0;t<f.length;t++){c[r]=t;const e=gst({inputs:{x:a},backend:n,attrs:{begin:c,size:d}}),i=uit({inputs:{x:e},backend:n,attrs:{shape:u}});f[t]=i,p.push(e)}return p.forEach((t=>n.disposeIntermediateTensorInfo(t))),f}};
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
class Aut{constructor(t,e){this.variableNames=["x","segmentIds"];const n=t.windowSize,i=t.batchSize,s=t.inSize,r=t.numSegments,a=r*Math.ceil(s/n);this.outputShape=[i,a];const o=4*Math.floor(n/4),l=n%4,u="\n sumValue += dot(values, segFilter);\n ";let h="";s%n>0&&(h=`\n if (inIdx < 0 || inIdx >= ${s}) {\n return initializationValue;\n }\n `);let p="";s%n>0&&(p=`\n if (inIdx < 0 || inIdx >= ${s}) {\n return -1.0;\n }\n `),this.userCode=`\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n ${h}\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n ${p}\n return getSegmentIds(inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = int(floor(float(outIdx) / float(\n ${r})) * float(${n}));\n int currentSeg = int(mod(float(outIdx), float(${r})));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${o}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n );\n\n ${u}\n }\n\n int inIdx = inOffset + ${o};\n if (${1===l}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n 0,\n 0,\n 0\n );\n\n ${u}\n } else if (${2===l}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n 0,\n 0\n );\n\n ${u}\n } else if (${3===l}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n 0\n );\n\n ${u}\n }\n setOutput(sumValue);\n }\n `}}const Mut={kernelName:IN,backendName:"webgl",kernelFunc:
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
function(t){const{inputs:e,backend:n,attrs:i}=t,{x:s,segmentIds:r}=e,{numSegments:a}=i,o=s.shape.length,l=[];let u=0;const h=_B([u],o);let p=s;null!=h&&(p=yit({inputs:{x:s},backend:n,attrs:{perm:h}}),l.push(p),u=yB(1,o)[0]);const c=oH(p.shape,u,a),d=IO([p.shape[u]]),f=uit({inputs:{x:p},backend:n,attrs:{shape:[-1,d]}});l.push(f);const m=Fk(s.dtype),g=(t,e,i,s,r)=>{const a=t.shape[0],o=t.shape[1],u=aH(o,r),h=new Aut({windowSize:u,inSize:o,batchSize:a,numSegments:r},e),p=n.compileAndRun(h,[t,i],s);if(l.push(p),p.shape[1]===r)return p;const c=Jot({backend:n,attrs:{start:0,stop:r,step:1,dtype:"float32"}}),d=Tut({inputs:{x:c},backend:n,attrs:{reps:[o/u]}});l.push(c),l.push(d);return g(p,e,d,s,r)},_=uit({inputs:{x:g(f,"unsortedSegmentSum",r,m,a)},backend:n,attrs:{shape:c}});let T=_;if(null!=h){l.push(_);const t=TB(h);T=yit({inputs:{x:T},backend:n,attrs:{perm:t}})}return l.forEach((t=>n.disposeIntermediateTensorInfo(t))),T}},Cut=[vit,Sit,Rit,Ait,Nit,Lit,Fit,Pit,Git,Hit,zit,jit,Kit,Jit,tst,ist,sst,ost,lst,ust,cst,Tst,yst,Ist,Est,Rst,Mst,kst,znt,Fst,Hst,Jst,irt,rrt,art,ort,lrt,hrt,crt,frt,Irt,Ert,brt,wrt,Rrt,Mrt,Crt,krt,Lrt,Frt,$rt,Brt,Urt,Grt,Wrt,Xrt,Krt,Zrt,nat,sat,oat,uat,cat,mat,gat,Tat,Eat,vat,Sat,Hnt,xat,Ust,Oat,Mat,Nat,qnt,Dat,Fat,Pat,Bat,Uat,Gat,Wat,Xat,Kat,Jat,tot,not,iot,sot,oot,lot,uot,hot,pot,dot,got,Tot,Rot,lit,Aot,Cot,kot,Lot,vst,Pot,Vot,Uot,Wot,Xot,Jnt,jot,qot,Kot,Qot,Zot,Sst,Eot,elt,ilt,rlt,hit,llt,hlt,dlt,mlt,Tlt,Ilt,blt,wlt,Rlt,Alt,Clt,klt,Llt,Plt,Blt,Ult,_st,xot,Glt,Hlt,Wlt,zlt,Xlt,jlt,qlt,Klt,Zlt,eut,sut,rut,aut,lut,uut,hut,put,wot,Tit,dut,mut,gut,yut,wut,xut,Iit,Rut,Out,Mut,Bot];for(const t of Cut)FN(t);
/** @license See the LICENSE file. */
const Nut={"tfjs-core":HP,"tfjs-backend-cpu":q4,"tfjs-backend-webgl":Fnt,"tfjs-data":y2,"tfjs-layers":tq,"tfjs-converter":u1,tfjs:"4.22.0"},kut=new Zt.Registry,Dut=function(t){let e={ok:!1,buffer:null,json:function(){const t=new TextDecoder("utf-8").decode(this.buffer);return JSON.parse(t)},arrayBuffer:function(){return this.buffer}};return kut.hasKey(t)?(e.ok=!0,e.buffer=kut.getItem(t),e):e},Lut={modelsValue:{},loadGraphModel:async function(t){return await o1(t,{fromTFHub:!1,fetchFunc:(...t)=>Dut(t[0])})},loadLayersModel:async function(t){return await vq(t,{fromTFHub:!1,fetchFunc:(...t)=>Dut(t[0])})},setModelsValue:function(t,e){kut.hasKey(t)&&kut.unregister(t),kut.register(t,e),Lut.modelsValue[t]=e}};window.tensorflow=Lut,rO.init(),window.tf=Qt,Object.assign(Jt.Variables,ee),Object.assign(Jt.Procedures,dh),Jt.Python=fh,Jt.generator=fh,Zt.Profile.default={},Object.assign(Jt.Blocks,t,e,n,i,s,r,a,o,l,u,h,p,c,x,R,O,A,M,C,N,k,D,L,F,P,B,V,U),Object.assign(Jt.Python.forBlock,d,f,m,g,_,T,y,I,E,b,v,w,S,Y,G,H,mT,W,z,X,j,q,K,Q,J,Z,tt,et)})()})();