diff --git "a/assets/index-CgXsdcRA.js" "b/assets/index-CgXsdcRA.js" new file mode 100644--- /dev/null +++ "b/assets/index-CgXsdcRA.js" @@ -0,0 +1,179 @@ +var e=Object.defineProperty,t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var i=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function ee(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function te(e,t){return E(e.type,t,e.props)}function D(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function O(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ne=/\/+/g;function re(e,t){return typeof e==`object`&&e&&e.key!=null?O(``+e.key):t.toString(36)}function ie(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(ee,ee):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ae(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ae(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+re(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(ne,`$&/`)+`/`),ae(o,r,i,``,function(e){return e})):o!=null&&(D(o)&&(o=te(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ne,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u{t.exports=i()})),o=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,te());else{var t=n(l);t!==null&&ne(x,t.startTime-e)}}}var S=!1,C=-1,ee=5,w=-1;function T(){return g?!0:!(e.unstable_now()-wt&&T());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ne(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?te():S=!1}}}var te;if(typeof y==`function`)te=function(){y(E)};else if(typeof MessageChannel<`u`){var D=new MessageChannel,O=D.port2;D.port1.onmessage=E,te=function(){O.postMessage(null)}}else te=function(){_(E,0)};function ne(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ne(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,te()))),r},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),s=t(((e,t)=>{t.exports=o()})),c=t((e=>{var t=a();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=c()})),u=t((e=>{var t=s(),n=a(),r=l();function i(e){var t=`https://react.dev/errors/`+e;if(1Te||(e.current=we[Te],we[Te]=null,Te--)}function Oe(e,t){Te++,we[Te]=e.current,e.current=t}var ke=Ee(null),Ae=Ee(null),je=Ee(null),Me=Ee(null);function Ne(e,t){switch(Oe(je,t),Oe(Ae,e),Oe(ke,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?mp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=mp(t),e=hp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}De(ke),Oe(ke,e)}function Pe(){De(ke),De(Ae),De(je)}function Fe(e){var t=e.memoizedState;t!==null&&(dh._currentValue=t.memoizedState,Oe(Me,e)),t=ke.current;var n=hp(t,e.type);t!==n&&(Oe(Ae,e),Oe(ke,n))}function Ie(e){Ae.current===e&&(De(ke),De(Ae)),Me.current===e&&(De(Me),dh._currentValue=Ce)}var Le,Re;function ze(e){if(Le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Le=t&&t[1]||``,Re=-1)`:-1i||c[r]!==l[i]){var u=` +`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Be=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ze(n):``}function He(e,t){switch(e.tag){case 26:case 27:case 5:return ze(e.type);case 16:return ze(`Lazy`);case 13:return e.child!==t&&t!==null?ze(`Suspense Fallback`):ze(`Suspense`);case 19:return ze(`SuspenseList`);case 0:case 15:return Ve(e.type,!1);case 11:return Ve(e.type.render,!1);case 1:return Ve(e.type,!0);case 31:return ze(`Activity`);case 30:return ze(`ViewTransition`);default:return``}}function Ue(e){try{var t=``,n=null;do t+=He(e,n),n=e,e=e.return;while(e);return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}var We=Object.prototype.hasOwnProperty,Ge=t.unstable_scheduleCallback,Ke=t.unstable_cancelCallback,qe=t.unstable_shouldYield,Je=t.unstable_requestPaint,Ye=t.unstable_now,Xe=t.unstable_getCurrentPriorityLevel,Ze=t.unstable_ImmediatePriority,Qe=t.unstable_UserBlockingPriority,$e=t.unstable_NormalPriority,et=t.unstable_LowPriority,tt=t.unstable_IdlePriority,nt=t.log,rt=t.unstable_setDisableYieldValue,it=null,at=null;function ot(e){if(typeof nt==`function`&&rt(e),at&&typeof at.setStrictMode==`function`)try{at.setStrictMode(it,e)}catch{}}var st=Math.clz32?Math.clz32:ut,ct=Math.log,lt=Math.LN2;function ut(e){return e>>>=0,e===0?32:31-(ct(e)/lt|0)|0}var dt=256,ft=262144,pt=4194304;function mt(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function A(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=mt(n))):i=mt(o):i=mt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=mt(n))):i=mt(o)):i=mt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function ht(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function j(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function yt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function bt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=yr),Sr=` `,Cr=!1;function N(e,t){switch(e){case`keyup`:return _r.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function wr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Tr=!1;function Er(e,t){switch(e){case`compositionend`:return wr(t);case`keypress`:return t.which===32?(Cr=!0,Sr):null;case`textInput`:return e=t.data,e===Sr&&Cr?null:e;default:return null}}function Dr(e,t){if(Tr)return e===`compositionend`||!vr&&N(e,t)?(e=Bn(),zn=Rn=Ln=null,Tr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Xr(n)}}function Qr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Qr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function $r(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Yr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Yr(e.document)}return t}function ei(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var ti=Pn&&`documentMode`in document&&11>=document.documentMode,ni=null,ri=null,ii=null,ai=!1;function oi(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ai||ni==null||ni!==Yr(r)||(r=ni,`selectionStart`in r&&ei(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ii&&Jr(ii,r)||(ii=r,r=Zf(ri,`onSelect`),0>=o,i-=o,na=1<<32-st(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),P&&ia(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),P&&ia(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return P&&ia(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),P&&ia(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===ne&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case D:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===ne){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),lo(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===de&&ro(l)===r.type){n(e,r.sibling),c=a(r,o.props),lo(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===ne?(c=Ui(o.props.children,e.mode,c,o.key),lo(c,o),c.return=e,e=c):(c=Hi(o.type,o.key,o.props,null,e.mode,c),lo(c,o),c.return=e,e=c)}return s(e);case O:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Ki(o,e.mode,c),c.return=e,e=c}return s(e);case de:return o=ro(o),_(e,r,o,c)}if(xe(o))return h(e,r,o,c);if(ve(o)){if(l=ve(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,z(o),c);if(o.$$typeof===oe)return _(e,r,ka(e,o),c);uo(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Wi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{co=0;var i=_(e,t,n,r);return so=null,i}catch(t){if(t===Qa||t===eo)throw t;var a=Ri(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var po=fo(!0),mo=fo(!1),ho=!1;function go(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function _o(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function vo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function yo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,$u&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Fi(e),Pi(e,null,n),t}return ji(e,r,t,n),Fi(e)}function bo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,St(e,n)}}function xo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var B=!1;function So(){if(B){var e=Ua;if(e!==null)throw e}}function Co(e,t,n,r){B=!1;var i=e.updateQueue;ho=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(q&f)===f:(r&f)===f){f!==0&&f===Ha&&(B=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=E({},d,f);break a;case 2:ho=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),ld|=o,e.lanes=o,e.memoizedState=d}}function wo(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function To(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=k.T,s={};s.types=o===null?null:o.types,k.T=s,fc(e,!1,t,n);try{var c=i(),l=k.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?dc(e,t,Ka(c,r),Pd(e)):dc(e,t,r,Pd(e))}catch(n){dc(e,t,{then:function(){},status:`rejected`,reason:n},Pd())}finally{Se.p=a,o!==null&&s.types!==null&&(o.types=s.types),k.T=o}}function tc(){}function nc(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=rc(e).queue;ec(e,a,t,Ce,n===null?tc:function(){return ic(e),n(r)})}function rc(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Ce,baseState:Ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:Ce},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ic(e){var t=rc(e);t.next===null&&(t=e.alternate.memoizedState),dc(e,t.next.queue,{},Pd())}function ac(){return Oa(dh)}function oc(){return cs().memoizedState}function sc(){return cs().memoizedState}function cc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Pd();e=vo(n);var r=yo(t,e,n);r!==null&&(Ld(r,t,n),bo(r,t,n)),t={cache:Fa()},e.payload=t;return}t=t.return}}function lc(e,t,n){var r=Pd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},pc(e)?mc(t,n):(n=Mi(e,t,n,r),n!==null&&(Ld(n,e,r),hc(n,t,r)))}function uc(e,t,n){dc(e,t,n,Pd())}function dc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(pc(e))mc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,qr(s,o))return ji(e,t,i,0),ed===null&&Ai(),!1}catch{}if(n=Mi(e,t,i,r),n!==null)return Ld(n,e,r),hc(n,t,r),!0}return!1}function fc(e,t,n,r){if(r={lane:2,revertLane:Lf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},pc(e)){if(t)throw Error(i(479))}else t=Mi(e,n,r,2),t!==null&&Ld(t,e,2)}function pc(e){var t=e.alternate;return e===V||t!==null&&t===V}function mc(e,t){Ko=Go=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function hc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,St(e,n)}}var gc={readContext:Oa,use:ds,useCallback:Qo,useContext:Qo,useEffect:Qo,useImperativeHandle:Qo,useLayoutEffect:Qo,useInsertionEffect:Qo,useMemo:Qo,useReducer:Qo,useRef:Qo,useState:Qo,useDebugValue:Qo,useDeferredValue:Qo,useTransition:Qo,useSyncExternalStore:Qo,useId:Qo,useHostTransitionStatus:Qo,useFormState:Qo,useActionState:Qo,useOptimistic:Qo,useMemoCache:Qo,useCacheRefresh:Qo,useEffectEvent:Qo},_c={readContext:Oa,use:ds,useCallback:function(e,t){return ss().memoizedState=[e,t===void 0?null:t],e},useContext:Oa,useEffect:Vs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),zs(4194308,4,qs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return zs(4194308,4,e,t)},useInsertionEffect:function(e,t){zs(4,2,e,t)},useMemo:function(e,t){var n=ss();t=t===void 0?null:t;var r=e();if(qo){ot(!0);try{e()}finally{ot(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ss();if(n!==void 0){var i=n(t);if(qo){ot(!0);try{n(t)}finally{ot(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=lc.bind(null,V,e),[r.memoizedState,e]},useRef:function(e){var t=ss();return e={current:e},t.memoizedState=e},useState:function(e){e=Cs(e);var t=e.queue,n=uc.bind(null,V,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Ys,useDeferredValue:function(e,t){return Qs(ss(),e,t)},useTransition:function(){var e=Cs(!1);return e=ec.bind(null,V,e.queue,!0,!1),ss().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=V,a=ss();if(P){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),ed===null)throw Error(i(349));q&127||vs(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Vs(bs.bind(null,r,o,e),[e]),r.flags|=2048,Ls(9,{destroy:void 0},ys.bind(null,r,o,n,t),null),n},useId:function(){var e=ss(),t=ed.identifierPrefix;if(P){var n=ra,r=na;n=(r&~(1<<32-st(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Jo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[kt]=t,o[At]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(op(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&ml(t)}}return yl(t),t.subtreeFlags&=-33554433,hl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&ml(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=je.current,_a(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=la,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[kt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||rp(e.nodeValue,n)),e||ma(t,!0)}else e=pp(e).createTextNode(r),e[kt]=t,t.stateNode=e}return yl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=_a(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[kt]=t}else va(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;yl(t),e=!1}else n=ya(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Lo(t),t):(Lo(t),null);if(t.flags&128)throw Error(i(558))}return yl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=_a(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[kt]=t}else va(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;yl(t),a=!1}else a=ya(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Lo(t),t):(Lo(t),null)}return Lo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),_l(t,t.updateQueue),yl(t),null);case 4:return Pe(),e===null&&Jf(t.stateNode.containerInfo),t.flags|=67108864,yl(t),null;case 10:return Ca(t.type),yl(t),null;case 19:if(Bo(t),r=t.memoizedState,r===null)return yl(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)vl(r,!1);else{if(cd!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Vo(e),o!==null){for(t.flags|=128,vl(r,!1),e=o.updateQueue,t.updateQueue=e,_l(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Vi(n,e),n=n.sibling;return zo(t,Ro.current&1|2),P&&ia(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ye()>yd&&(t.flags|=128,a=!0,vl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Vo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,_l(t,e),vl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!P)return yl(t),null}else 2*Ye()-r.renderingStartTime>yd&&n!==536870912&&(t.flags|=128,a=!0,vl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ye(),e.sibling=null,o=Ro.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||P?zo(t,o):(n=o,Oe(jo,t),Oe(Ro,n),Mo===null&&(Mo=t)),P&&ia(t,r.treeForkCount),e}return yl(t),null;case 22:case 23:return Lo(t),Ao(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(yl(t),t.subtreeFlags&6&&(t.flags|=8192)):yl(t),n=t.updateQueue,n!==null&&_l(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&De(Ja),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ca(Pa),yl(t),null;case 25:return null;case 30:return t.flags|=33554432,yl(t),null}throw Error(i(156,t.tag))}function xl(e,t){switch(sa(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ca(Pa),Pe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ie(t),null;case 31:if(t.memoizedState!==null){if(Lo(t),t.alternate===null)throw Error(i(340));va()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Lo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));va()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Bo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Pe(),null;case 10:return Ca(t.type),null;case 22:case 23:return Lo(t),Ao(),e!==null&&De(Ja),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ca(Pa),null;case 25:return null;default:return null}}function Sl(e,t){switch(sa(t),t.tag){case 3:Ca(Pa),Pe();break;case 26:case 27:case 5:Ie(t);break;case 4:Pe();break;case 31:t.memoizedState!==null&&Lo(t);break;case 13:Lo(t);break;case 19:Bo(t);break;case 10:Ca(t.type);break;case 22:case 23:Lo(t),Ao(),e!==null&&De(Ja);break;case 24:Ca(Pa)}}function Cl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){gf(t,t.return,e)}}function wl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){gf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){gf(t,t.return,e)}}function Tl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{To(t,n)}catch(t){gf(e,e.return,t)}}}function El(e,t,n){n.props=wc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){gf(e,t,n)}}function Dl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=Ci(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Rp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new zp(e);h(e.child,!1,nm,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){gf(e,t,n)}}function Ol(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){gf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){gf(e,t,n)}else n.current=null}}function kl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),op(r,t,n),r[kt]=e,Ut(r),t=r;break a;case`link`:if(o=Ym(`link`,`href`,a).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Zr(s,h),v=Zr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,k.T=null,n=Dd,Dd=null;var o=Cd,s=Td;if(Sd=0,wd=Cd=null,Td=0,$u&6)throw Error(i(331));var c=$u;if($u|=4,Ju(o.current),Bu(o,o.current,s,n),$u=c,Af(0,!1),at&&typeof at.onPostCommitFiberRoot==`function`)try{at.onPostCommitFiberRoot(it,o)}catch{}return!0}finally{Se.p=a,k.T=r,pf(e,t)}}function hf(e,t,n){t=Ji(n,t),t=Ac(e.stateNode,t,2),e=yo(e,t,2),e!==null&&(yt(e,2),kf(e))}function gf(e,t,n){if(e.tag===3)hf(e,e,n);else for(;t!==null;){if(t.tag===3){hf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(xd===null||!xd.has(r))){e=Ji(n,e),n=jc(2),r=yo(t,n,2),r!==null&&(Mc(n,r,t,e),yt(r,2),kf(r));break}}t=t.return}}function _f(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Qu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(od=!0,i.add(n),e=vf.bind(null,e,t,n),t.then(e,e))}function vf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,ed===e&&(q&n)===n&&(cd===4||cd===3&&(q&62914560)===q&&300>Ye()-_d?$u&2?dd|=n:Wd(e,0):dd|=n,pd===q&&(pd=0)),kf(e)}function yf(e,t){t===0&&(t=_t()),e=Ni(e,t),e!==null&&(yt(e,t),kf(e))}function bf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),yf(e,n)}function xf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),yf(e,n)}function Sf(e,t){return Ge(e,t)}var Cf=null,wf=null,Tf=!1,Ef=!1,Df=!1,Of=0;function kf(e){e!==wf&&e.next===null&&(wf===null?Cf=wf=e:wf=wf.next=e),Ef=!0,Tf||(Tf=!0,If())}function Af(e,t){if(!Df&&Ef){Df=!0;do for(var n=!1,r=Cf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-st(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Ff(r,a))}else a=q,a=A(r,r===ed?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||ht(r,a)||(n=!0,Ff(r,a))}r=r.next}while(n);Df=!1}}function jf(){Mf()}function Mf(){Ef=Tf=!1;var e=0;Of!==0&&yp()&&(e=Of);for(var t=Ye(),n=null,r=Cf;r!==null;){var i=r.next,a=Nf(r,t);a===0?(r.next=null,n===null?Cf=i:n.next=i,i===null&&(wf=n)):(n=r,(e!==0||a&3)&&(Ef=!0)),r=i}Sd!==0&&Sd!==5||Af(e,!1),Of!==0&&(Of=0)}function Nf(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&lp(d)&&(c=c.responseEnd,o+=u*(crh){s.length=o;break}f=new Promise(Fp.bind(f)),s.push(f)}}}if(0`u`?null:document;function km(e,t,n){var r=Om;if(r&&typeof t==`string`&&t){var i=un(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Cm.has(i)||(Cm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),op(t,`link`,e),Ut(t),r.head.appendChild(t)))}}function Am(e){Tm.D(e),km(`dns-prefetch`,e,null)}function jm(e,t){Tm.C(e,t),km(`preconnect`,e,t)}function Mm(e,t,n){Tm.L(e,t,n);var r=Om;if(r&&e&&t){var i=`link[rel="preload"][as="`+un(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+un(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+un(n.imageSizes)+`"]`)):i+=`[href="`+un(e)+`"]`;var a=i;switch(t){case`style`:a=Rm(e);break;case`script`:a=Hm(e)}if(!(Sm.has(a)||(e=E({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Sm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(zm(a))||t===`script`&&r.querySelector(Um(a))))){var o=r.createElement(`link`);op(o,`link`,e),t===`style`&&(o[Lt]=!0,o.onload=o.onerror=function(){Wt(o)}),Ut(o),r.head.appendChild(o)}}}function Nm(e,t){Tm.m(e,t);var n=Om;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+un(r)+`"][href="`+un(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Hm(e)}if(!Sm.has(a)&&(e=E({rel:`modulepreload`,href:e},t),Sm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Um(a)))return}r=n.createElement(`link`),op(r,`link`,e),Ut(r),n.head.appendChild(r)}}}function Pm(e,t,n){Tm.S(e,t,n);var r=Om;if(r&&e){var i=Ht(r).hoistableStyles,a=Rm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(zm(a)))s.loading=5;else{e=E({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Sm.get(a))&&Km(e,n);var c=o=r.createElement(`link`);Ut(c),op(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Gm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Fm(e,t){Tm.X(e,t);var n=Om;if(n&&e){var r=Ht(n).hoistableScripts,i=Hm(e),a=r.get(i);a||(a=n.querySelector(Um(i)),a||(e=E({src:e,async:!0},t),(t=Sm.get(i))&&qm(e,t),a=n.createElement(`script`),Ut(a),op(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Im(e,t){Tm.M(e,t);var n=Om;if(n&&e){var r=Ht(n).hoistableScripts,i=Hm(e),a=r.get(i);a||(a=n.querySelector(Um(i)),a||(e=E({src:e,async:!0,type:`module`},t),(t=Sm.get(i))&&qm(e,t),a=n.createElement(`script`),Ut(a),op(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Lm(e,t,n,r){var a=(a=je.current)?wm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Rm(n.href),t=Ht(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Rm(n.href);var o=Ht(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(zm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=Sm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Sm.set(e,o)),Vm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Hm(n),t=Ht(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Rm(e){return`href="`+un(e)+`"`}function zm(e){return`link[rel="stylesheet"][`+e+`]`}function Bm(e){return E({},e,{"data-precedence":e.precedence,precedence:null})}function Vm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Lt]){r.loading=1;return}}else t=e.createElement(`link`),t[Lt]=!0,t.onload=t.onerror=Wt.bind(null,t),op(t,`link`,n),Ut(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Hm(e){return`[src="`+un(e)+`"]`}function Um(e){return`script[async]`+e}function Wm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+un(n.href)+`"]`);if(r)return t.instance=r,Ut(r),r;var a=E({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Ut(r),op(r,`style`,a),Gm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Rm(n.href);var o=e.querySelector(zm(a));if(o)return t.state.loading|=4,t.instance=o,Ut(o),o;r=Bm(n),(a=Sm.get(a))&&Km(r,a),o=(e.ownerDocument||e).createElement(`link`),Ut(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),op(o,`link`,r),t.state.loading|=4,Gm(o,n.precedence,e),t.instance=o;case`script`:return o=Hm(n.src),(a=e.querySelector(Um(o)))?(t.instance=a,Ut(a),a):(r=n,(a=Sm.get(o))&&(r=E({},n),qm(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Ut(a),op(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Gm(r,n.precedence,e));return t.instance}function Gm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Zm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Qm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function $m(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function eh(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function th(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=eh(t),e.suspenseyImages.push(t)),e=sh.bind(e),t.decode().then(e,e))}function nh(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Rm(r.href),a=t.querySelector(zm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=oh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Ut(a);return}a=t.ownerDocument||t,r=Bm(r),(i=Sm.get(i))&&Km(r,i),a=a.createElement(`link`),Ut(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),op(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=oh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var rh=0;function ih(e,t){return e.stylesheets&&e.count===0&&lh(e,e.stylesheets),0rh?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function ah(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)lh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function oh(){this.count--,ah(this)}function sh(){this.imgCount--,ah(this)}var ch=null;function lh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ch=new Map,t.forEach(uh,e),ch=null,oh.call(e))}function uh(e,t){if(!(t.state.loading&4)){var n=ch.get(e);if(n)var r=n.get(null);else{n=new Map,ch.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=u()})),f=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function p(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:f(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var m=e=>{let t=``,n=!1;for(let r of e){if(r===`-`||r===`_`||r<=` `){n=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1}return t},h=e=>{let t=m(e);return t.charAt(0).toUpperCase()+t.slice(1)},g=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),_={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function v(e){return e!=null}function y(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??_.width,a=e.size??e.height??_.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?g(...c):g(`lucide`,...s,...c),u=t.absoluteStrokeWidth?Number(t.strokeWidth??_[`stroke-width`])*Number(e.size??e.width??_.width)/Number(t.size??t.width??_.width):t.strokeWidth??_[`stroke-width`];return[`svg`,{...Object.entries(_).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&v(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&v(t.width)&&{[r(`width`)]:t.width},...`height`in t&&v(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function b(e,t={}){return y(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var x=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},S=a(),C=(0,S.createContext)({}),ee=()=>(0,S.useContext)(C),w=(0,S.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:s=``,children:c,iconNode:l=[],icon:u={node:l,aliases:[],size:24},...d},f)=>{let{size:p=24,strokeWidth:m=2,absoluteStrokeWidth:h=!1,nonScalingStroke:_=!1,color:v=`currentColor`,className:y=``}=ee()??{},C=!!c||x(d),[w,T,E=[]]=b(u,{color:e??v,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??_,className:g(y,s),hasA11yProp:C,attributes:d});return(0,S.createElement)(w,{ref:f,...T},[...E.map(([e,t])=>(0,S.createElement)(e,t)),...Array.isArray(c)?c:[c]])});function T(e,t=[],n=[]){let r=typeof e==`string`?p(e,t,n):e,i=(0,S.forwardRef)(({className:e,...t},n)=>(0,S.createElement)(w,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=h(r.name)),i}var E={name:`activity`,size:24,node:[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]};E.node;var te=T(E),D={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};D.node;var O=T(D),ne={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};ne.node;var re=T(ne),ie={name:`braces`,size:24,node:[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]],aliases:[`curly-braces`]};ie.node;var ae=T(ie),oe={name:`chart-column`,size:24,node:[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]],aliases:[`bar-chart-3`]};oe.node;var se=T(oe),ce={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};ce.node;var le=T(ce),ue={name:`circle-check`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`check-circle-2`]};ue.node;var de=T(ue),fe={name:`circle-dashed`,size:24,node:[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]};fe.node;var pe=T(fe),me={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};me.node;var he=T(me),ge={name:`code-xml`,size:24,node:[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]],aliases:[`code-2`]};ge.node;var _e=T(ge),ve={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};ve.node;var ye=T(ve),be={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};be.node;var xe=T(be),k={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};k.node;var Se=T(k),Ce={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};Ce.node;var we=T(Ce),Te={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};Te.node;var Ee=T(Te),De={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};De.node;var Oe=T(De),ke={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};ke.node;var Ae=T(ke),je={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};je.node;var Me=T(je),Ne={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};Ne.node;var Pe=T(Ne),Fe={name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]};Fe.node;var Ie=T(Fe),Le={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};Le.node;var Re=T(Le),ze={name:`message-square-warning`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]};ze.node;var Be=T(ze),Ve={name:`package`,size:24,node:[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]};Ve.node;var He=T(Ve),Ue={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Ue.node;var We=T(Ue),Ge={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};Ge.node;var Ke=T(Ge),qe={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};qe.node;var Je=T(qe),Ye={name:`target`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};Ye.node;var Xe=T(Ye),Ze={name:`ticket-check`,size:24,node:[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]};Ze.node;var Qe=T(Ze),$e={name:`timer`,size:24,node:[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]};$e.node;var et=T($e),tt={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};tt.node;var nt=T(tt),rt={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};rt.node;var it=T(rt),at={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]};at.node;var ot=T(at),st=d(),ct=`0.1.2`,lt=`https://www.npmjs.com/package/open-jev`,ut=`https://github.com/nico-martin/open-jev`,dt=`https://huggingface.co/docs/transformers.js/index`,ft=`https://typesafe.ai/blog/introducing-system-one-models-and-jev`,pt=[{alias:`kev-0.6b`,name:`Kev 0.6B`,base:`Qwen3-0.6B-Base`,repo:`onnx-community/kev-0.6b-ONNX`,context:8192,dtypes:[`auto`,`q4f16`,`q4`],sizes:{q4f16:`0.34 GB`,q4:`0.38 GB`},note:`Small and fast. The default and the best place to start.`,tag:`Default`,tone:`lime`},{alias:`open-jev`,name:`open-jev`,base:`DeBERTa-v3-large`,repo:`onnx-community/open-jev-deberta-v3-large-ONNX`,context:512,dtypes:[`auto`,`fp16`,`q4f16`,`q4`,`fp32`],sizes:{q4f16:`0.35 GB`,q4:`0.48 GB`,fp16:`0.88 GB`,fp32:`1.75 GB`},note:`Encoder model with a 512-token context. Calibrated temperature.`,tag:`Encoder`,tone:`periwinkle`},{alias:`gliner2-decide`,name:`GLiNER2.5-Decide`,base:`DeBERTa-v3-large (Fastino)`,repo:`onnx-community/GLiNER2.5-Decide-ONNX`,context:512,dtypes:[`auto`,`fp16`,`q4f16`,`q4`,`fp32`],sizes:{q4f16:`0.52 GB`,q4:`0.89 GB`,fp16:`0.87 GB`,fp32:`1.74 GB`},note:`Fastino's decision model, trained on 17 operational domains. Descriptions go into the prompt.`,tag:`Trained`,tone:`periwinkle`},{alias:`julia-1`,name:`Julia 1`,base:`mmBERT-small (Supersonic Labs)`,repo:`SupersonicLabs/Julia-1-ONNX`,context:1024,dtypes:[`auto`,`fp32`],sizes:{fp32:`0.58 GB`},note:`Supersonic Labs' multilingual decision model. Scores each question on its own, 2 to 20 options.`,tag:`Multilingual`,tone:`lavender`},{alias:`kev-4b`,name:`Kev 4B`,base:`Qwen3-4B-Base`,repo:`onnx-community/kev-4b-ONNX`,context:8192,dtypes:[`auto`,`q4f16`,`q4`],sizes:{q4f16:`2.3 GB`,q4:`2.5 GB`},note:`Most accurate. Needs a capable GPU and a large download.`,tag:`Accurate`,tone:`lavender`}],mt={auto:`Auto`,q4f16:`q4f16`,q4:`q4`,fp16:`fp16`,fp32:`fp32`},A=(...e)=>e.map(e=>typeof e==`string`?e:Object.entries(e||{}).filter(([,e])=>e).map(([e])=>e).join(` `)).filter(e=>e!==``).join(` `),ht=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),j=t(((e,t)=>{t.exports=ht()}))();function gt({tone:e=`neutral`,size:t=`md`,className:n=``,children:r,...i}){return(0,j.jsx)(`span`,{className:A(`inline-flex items-center gap-1.5 rounded-full font-semibold leading-none whitespace-nowrap`,{"bg-lime text-ink":e===`lime`,"bg-periwinkle text-white":e===`periwinkle`,"bg-lavender text-white":e===`lavender`,"bg-mint text-ink":e===`mint`,"bg-rose text-ink":e===`rose`,"bg-ink text-white":e===`dark`,"bg-cream text-ink":e===`neutral`,"border border-ink/10 bg-transparent text-ink":e===`outline`,"h-6 px-2.5 text-xs":t===`sm`,"h-8 px-3.5 text-sm":t===`md`},n),...i,children:r})}function _t({value:e,className:t=``}){return(0,j.jsx)(`span`,{className:A(`inline-flex h-7 min-w-7 items-center justify-center rounded-full bg-ink px-2 text-sm font-bold text-white`,t),children:e})}function vt({variant:e=`primary`,size:t=`md`,icon:n,iconRight:r,className:i=``,children:a,disabled:o,...s}){return(0,j.jsxs)(`button`,{disabled:o,className:A(`inline-flex items-center justify-center gap-2 rounded-2xl font-semibold whitespace-nowrap transition-all duration-200 ease-out select-none`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-periwinkle focus-visible:ring-offset-2 focus-visible:ring-offset-cream`,`active:scale-95 disabled:cursor-not-allowed disabled:opacity-50 disabled:active:scale-100`,{"bg-ink text-white hover:bg-ink-muted shadow-card":e===`primary`,"bg-lime text-ink hover:bg-lime-dark shadow-card":e===`accent`,"bg-white text-ink hover:bg-cream border border-ink/5 shadow-card":e===`secondary`,"bg-transparent text-ink hover:bg-ink/5":e===`ghost`,"h-9 px-4 text-sm":t===`sm`,"h-12 px-6 text-base":t===`md`,"h-14 px-8 text-lg":t===`lg`},i),...s,children:[n&&(0,j.jsx)(`span`,{className:`shrink-0`,children:n}),a,r&&(0,j.jsx)(`span`,{className:`shrink-0`,children:r})]})}function yt({icon:e,label:t,active:n=!1,tone:r=`dark`,className:i=``,...a}){return(0,j.jsx)(`button`,{"aria-label":t,title:t,className:A(`flex h-12 w-12 items-center justify-center rounded-2xl transition-all duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-periwinkle`,`active:scale-95 disabled:cursor-not-allowed disabled:opacity-40 disabled:active:scale-100`,{"bg-white text-ink shadow-lift":n,"bg-white/10 text-white hover:bg-white/20":r===`dark`&&!n,"bg-cream text-ink hover:bg-cream-dark":r===`light`&&!n},i),...a,children:e})}function bt({variant:e=`light`,padding:t=`md`,interactive:n=!1,selected:r=!1,className:i=``,children:a,...o}){return(0,j.jsx)(`div`,{className:A(`relative rounded-3xl transition-all duration-300 ease-out`,{"bg-white text-ink shadow-card":e===`light`,"bg-ink text-white shadow-lift":e===`dark`,"bg-cream text-ink":e===`cream`,"p-0":t===`none`,"p-4":t===`sm`,"p-6":t===`md`,"p-8":t===`lg`,"cursor-pointer hover:-translate-y-0.5 hover:shadow-lift":n,"ring-2 ring-ink ring-offset-2 ring-offset-cream":r},i),...o,children:a})}function xt({children:e,count:t,action:n,className:r=``}){return(0,j.jsxs)(`div`,{className:A(`flex items-center justify-between gap-4`,r),children:[(0,j.jsxs)(`h2`,{className:`flex items-center gap-3 text-2xl font-semibold tracking-tight`,children:[e,t!==void 0&&(0,j.jsx)(_t,{value:t})]}),n]})}var St=/(\/\/[^\n]*)|("(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'|`(?:[^`\\]|\\.)*`)|\b(import|from|export|const|let|var|await|async|function|return|type|interface|new|true|false|null|if|else|for|of|as)\b|\b(\d+(?:\.\d+)?)\b/g;function Ct(e){let t=[],n=0,r=0;for(let i of e.matchAll(St)){let a=i.index??0;a>n&&t.push(e.slice(n,a));let[o,s,c,l,u]=i;t.push((0,j.jsx)(`span`,{className:A({"text-stone-light italic":!!s,"text-lime":!!c,"text-periwinkle-light":!!l,"text-mint":!!u}),children:o},r++)),n=a+o.length}return n{if(e){let e=0,t=requestAnimationFrame(()=>{l(!0),e=requestAnimationFrame(()=>d(!0))});return()=>{cancelAnimationFrame(t),cancelAnimationFrame(e)}}let t=requestAnimationFrame(()=>d(!1)),n=setTimeout(()=>l(!1),Et);return()=>{cancelAnimationFrame(t),clearTimeout(n)}},[e]),(0,S.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};document.addEventListener(`keydown`,n);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,n),document.body.style.overflow=r}},[e,t]),c?(0,Tt.createPortal)((0,j.jsxs)(`div`,{className:A(`fixed inset-0 z-50 flex items-center justify-center p-4 transition-opacity duration-200`,{"opacity-100":u,"opacity-0":!u}),onClick:t,children:[(0,j.jsx)(`div`,{className:`absolute inset-0 bg-ink/50 backdrop-blur-sm`}),(0,j.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,onClick:e=>e.stopPropagation(),className:A(`relative flex max-h-full w-full flex-col overflow-hidden rounded-3xl bg-white shadow-frame transition-all duration-300 ease-out`,{"max-w-2xl":a===`md`,"max-w-4xl":a===`lg`,"translate-y-0 scale-100 opacity-100":u,"translate-y-4 scale-95 opacity-0":!u},s),children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-ink/5 px-6 py-5`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[n&&(0,j.jsx)(`h3`,{className:`text-xl font-semibold tracking-tight`,children:n}),r&&(0,j.jsx)(`p`,{className:`mt-1 text-sm text-stone`,children:r})]}),(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[i,(0,j.jsx)(yt,{icon:(0,j.jsx)(it,{size:18}),label:`Close`,tone:`light`,onClick:t})]})]}),(0,j.jsx)(`div`,{className:`scrollbar-thin min-h-0 overflow-auto`,children:o})]})]}),document.body):null}function Ot({value:e,label:t,valueLabel:n,tone:r=`periwinkle`,animate:i=!0,className:a=``}){let o=Math.max(0,Math.min(1,e))*100;return(0,j.jsxs)(`div`,{className:A(`flex items-center gap-3`,a),children:[t&&(0,j.jsx)(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-stone`,children:t}),(0,j.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-ink/8`,children:(0,j.jsx)(`div`,{className:A(`h-full origin-left rounded-full`,{"bg-lime":r===`lime`,"bg-periwinkle":r===`periwinkle`,"bg-mint":r===`mint`,"bg-lavender":r===`lavender`,"bg-rose":r===`rose`,"bg-ink":r===`ink`,"animate-grow-x":i}),style:{width:`${o}%`}})}),n&&(0,j.jsx)(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs text-ink tabular-nums`,children:n})]})}function kt({value:e,tone:t=`periwinkle`,size:n=`md`,indeterminate:r=!1,className:i=``}){let a=Math.max(0,Math.min(1,e))*100;return(0,j.jsx)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r?void 0:Math.round(a),className:A(`relative w-full overflow-hidden rounded-full bg-ink/8`,{"h-1.5":n===`sm`,"h-3":n===`md`},i),children:(0,j.jsx)(`div`,{className:A(`h-full rounded-full transition-all duration-500 ease-out`,{"bg-lime":t===`lime`,"bg-periwinkle":t===`periwinkle`,"bg-mint":t===`mint`,"bg-lavender":t===`lavender`,"bg-rose":t===`rose`,"bg-ink":t===`ink`,"shimmer-bg animate-shimmer":r}),style:{width:r?`100%`:`${a}%`}})})}function At({progress:e,active:t=!1,done:n=!1,icon:r,trailing:i,className:a=``,children:o,disabled:s,...c}){let l=Math.max(0,Math.min(1,e))*100,u=Math.round(l);return(0,j.jsxs)(`button`,{disabled:s,"aria-busy":t,className:A(`relative isolate flex h-14 w-full items-center justify-center overflow-hidden rounded-2xl px-8 text-lg font-semibold whitespace-nowrap transition-all duration-300 ease-out select-none`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-periwinkle focus-visible:ring-offset-2 focus-visible:ring-offset-white`,`disabled:cursor-not-allowed`,{"bg-ink text-white shadow-card hover:bg-ink-muted active:scale-95":!t&&!n,"bg-ink-muted text-white shadow-card":t,"bg-lime text-ink shadow-card":n},a),...c,children:[(0,j.jsx)(`span`,{"aria-hidden":`true`,className:A(`absolute inset-y-0 left-0 -z-10 rounded-2xl transition-all duration-500 ease-out`,{"bg-periwinkle":t&&!n,"opacity-0":!t||n}),style:{width:`${l}%`}}),t&&!n&&(0,j.jsx)(`span`,{"aria-hidden":`true`,className:`shimmer-bg animate-shimmer absolute inset-0 -z-10`}),(0,j.jsxs)(`span`,{className:`flex items-center gap-3`,children:[r&&(0,j.jsx)(`span`,{className:`shrink-0`,children:r}),(0,j.jsx)(`span`,{children:o}),t&&(0,j.jsxs)(`span`,{className:`font-mono text-base tabular-nums opacity-80`,children:[u,`%`]})]}),i&&(0,j.jsx)(`span`,{className:`absolute right-5 hidden font-mono text-xs tabular-nums opacity-70 sm:inline`,children:i})]})}function jt({screen:e,demoReady:t,runtime:n,onNavigate:r,className:i=``}){return(0,j.jsxs)(`header`,{className:A(`flex flex-wrap items-center justify-between gap-4`,i),children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,j.jsxs)(`div`,{className:`relative h-10 w-10 shrink-0`,role:`img`,"aria-label":``,children:[(0,j.jsx)(`span`,{className:`animate-float absolute top-0.5 left-0.5 h-6 w-6 rounded-full bg-lime`}),(0,j.jsx)(`span`,{className:`animate-float absolute right-0.5 bottom-0.5 h-5 w-5 rounded-full bg-periwinkle`,style:{animationDelay:`-2s`}})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`open-jev`}),(0,j.jsxs)(gt,{tone:`outline`,size:`sm`,className:`font-mono`,children:[`v`,ct]}),(0,j.jsx)(`span`,{className:`hidden text-sm text-stone md:inline`,children:`typed decisions, in the browser`})]})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`animate-fade-in`,children:n?(0,j.jsxs)(gt,{tone:`lime`,children:[(0,j.jsx)(de,{size:14}),(0,j.jsxs)(`span`,{className:`font-mono`,children:[n.model.split(`/`).pop(),` · `,n.device,` ·`,` `,n.dtype]})]}):(0,j.jsxs)(gt,{tone:`neutral`,children:[(0,j.jsx)(pe,{size:14}),`No model loaded`]})},n?`ready`:`idle`),(0,j.jsxs)(`nav`,{"aria-label":`Screens`,className:`flex items-center gap-1 rounded-2xl bg-white p-1 shadow-card`,children:[(0,j.jsx)(Mt,{icon:(0,j.jsx)(Se,{size:16}),label:`Install`,active:e===`install`,onClick:()=>r(`install`)}),(0,j.jsx)(Mt,{icon:(0,j.jsx)(Pe,{size:16}),label:`Demos`,active:e===`demo`,disabled:!t,title:t?void 0:`Load a model first`,onClick:()=>r(`demo`)}),(0,j.jsx)(Mt,{icon:(0,j.jsx)(se,{size:16}),label:`Benchmark`,active:e===`benchmark`,onClick:()=>r(`benchmark`)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(Nt,{href:lt,label:`open-jev on npm`,children:(0,j.jsx)(He,{size:18})}),(0,j.jsx)(Nt,{href:ut,label:`open-jev on GitHub`,children:(0,j.jsx)(Ee,{size:18})})]})]})]})}function Mt({icon:e,label:t,active:n,disabled:r=!1,title:i,onClick:a}){return(0,j.jsxs)(`button`,{type:`button`,"aria-current":n?`page`:void 0,disabled:r,title:i,onClick:a,className:A(`flex h-10 items-center gap-2 rounded-xl px-4 text-sm font-semibold transition-all duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-periwinkle`,`active:scale-95 disabled:cursor-not-allowed disabled:opacity-40 disabled:active:scale-100`,{"bg-ink text-white shadow-card":n,"text-ink hover:bg-cream":!n}),children:[e,t]})}function Nt({href:e,label:t,children:n}){return(0,j.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,"aria-label":t,title:t,className:`flex h-12 w-12 items-center justify-center rounded-2xl bg-white text-ink shadow-card transition-all duration-200 hover:bg-ink hover:text-white active:scale-95`,children:n})}var Pt=[{alias:`julia-1`,dtype:`fp32`,choice:[426,600],score:[542,800],noul:[483,600],workflows:{agent_trace_observability:[348,500],customer_service:[352,500],invoice_processing:[398,500],security_incidents:[353,500]},medianMs:190.9},{alias:`kev-4b`,dtype:`q4f16`,choice:[360,600],score:[423,800],noul:[396,600],workflows:{agent_trace_observability:[258,500],customer_service:[346,500],invoice_processing:[267,500],security_incidents:[308,500]},medianMs:1590.9},{alias:`gliner2-decide`,dtype:`fp16`,choice:[249,600],score:[355,800],noul:[364,600],workflows:{agent_trace_observability:[289,500],customer_service:[188,500],invoice_processing:[243,500],security_incidents:[248,500]},medianMs:347.8},{alias:`kev-0.6b`,dtype:`q4f16`,choice:[219,600],score:[287,800],noul:[382,600],workflows:{agent_trace_observability:[166,500],customer_service:[247,500],invoice_processing:[242,500],security_incidents:[233,500]},medianMs:287.2},{alias:`open-jev`,dtype:`fp16`,choice:[211,600],score:[258,800],noul:[334,600],workflows:{agent_trace_observability:[182,500],customer_service:[211,500],invoice_processing:[208,500],security_incidents:[202,500]},medianMs:249.9}],Ft=`MacBook Pro M3 Pro · Chrome · WebGPU`,It=`modulepreload`,Lt=function(e){return`/`+e},Rt={},zt=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Lt(t,n),t=s(t),t in Rt)return;Rt[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:It,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Bt=n({InferenceSession:()=>Vn,TRACE:()=>Mn,TRACE_EVENT_BEGIN:()=>In,TRACE_EVENT_END:()=>Ln,TRACE_FUNC_BEGIN:()=>Pn,TRACE_FUNC_END:()=>Fn,Tensor:()=>An,default:()=>ga,env:()=>cn,registerBackend:()=>Zt}),Vt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Ut=Object.getOwnPropertyNames,Wt=Object.prototype.hasOwnProperty,Gt=(e=>typeof r<`u`?r:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof r<`u`?r:e)[t]}):e)(function(e){if(typeof r<`u`)return r.apply(this,arguments);throw Error(`Dynamic require of "`+e+`" is not supported`)}),M=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},Kt=(e,t)=>{for(var n in t)Vt(e,n,{get:t[n],enumerable:!0})},qt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of Ut(t))!Wt.call(e,i)&&i!==n&&Vt(e,i,{get:()=>t[i],enumerable:!(r=Ht(t,i))||r.enumerable});return e},Jt=e=>qt(Vt({},`__esModule`,{value:!0}),e),Yt,Xt,Zt,Qt,$t,en=M(()=>{Yt=new Map,Xt=[],Zt=(e,t,n)=>{if(t&&typeof t.init==`function`&&typeof t.createInferenceSessionHandler==`function`){let r=Yt.get(e);if(r===void 0)Yt.set(e,{backend:t,priority:n});else{if(r.priority>n)return;if(r.priority===n&&r.backend!==t)throw Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){let t=Xt.indexOf(e);t!==-1&&Xt.splice(t,1);for(let t=0;t{let t=Yt.get(e);if(!t)return`backend not found.`;if(t.initialized)return t.backend;if(t.aborted)return t.error;{let n=!!t.initPromise;try{return n||(t.initPromise=t.backend.init(e)),await t.initPromise,t.initialized=!0,t.backend}catch(e){return n||(t.error=`${e}`,t.aborted=!0),t.error}finally{delete t.initPromise}}},$t=async e=>{let t=e.executionProviders||[],n=t.map(e=>typeof e==`string`?e:e.name),r=n.length===0?Xt:n,i,a=[],o=new Set;for(let e of r){let t=await Qt(e);typeof t==`string`?a.push({name:e,err:t}):(i||=t,i===t&&o.add(e))}if(!i)throw Error(`no available backend found. ERR: ${a.map(e=>`[${e.name}] ${e.err}`).join(`, `)}`);for(let{name:e,err:t}of a)n.includes(e)&&console.warn(`removing requested execution provider "${e}" from session options because it is not available: ${t}`);let s=t.filter(e=>o.has(typeof e==`string`?e:e.name));return[i,new Proxy(e,{get:(e,t)=>t===`executionProviders`?s:Reflect.get(e,t)})]}}),tn=M(()=>{en()}),nn,rn=M(()=>{nn=`1.31.0-dev.20260911-2a43ec07e`}),an,on,sn=M(()=>{rn(),an=`warning`,on={wasm:{},webgl:{},webgpu:{},versions:{common:nn},set logLevel(e){if(e!==void 0){if(typeof e!=`string`||[`verbose`,`info`,`warning`,`error`,`fatal`].indexOf(e)===-1)throw Error(`Unsupported logging level: ${e}`);an=e}},get logLevel(){return an}},Object.defineProperty(on,"logLevel",{enumerable:!0})}),cn,ln=M(()=>{sn(),cn=on}),un,dn,fn=M(()=>{un=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext(`2d`);if(r!=null){let i,a;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[3]):(i=e.dims[3],a=e.dims[2]);let o=t?.format===void 0?`RGB`:t.format,s=t?.norm,c,l;s===void 0||s.mean===void 0?c=[255,255,255,255]:typeof s.mean==`number`?c=[s.mean,s.mean,s.mean,s.mean]:(c=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(c[3]=s.mean[3])),s===void 0||s.bias===void 0?l=[0,0,0,0]:typeof s.bias==`number`?l=[s.bias,s.bias,s.bias,s.bias]:(l=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(l[3]=s.bias[3]));let u=a*i,d=0,f=u,p=u*2,m=-1;o===`RGBA`?(d=0,f=u,p=u*2,m=u*3):o===`RGB`?(d=0,f=u,p=u*2):o===`RBG`&&(d=0,p=u,f=u*2);for(let t=0;t{let n=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):new OffscreenCanvas(1,1).getContext(`2d`),r;if(n!=null){let i,a,o;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[1],o=e.dims[3]):(i=e.dims[3],a=e.dims[2],o=e.dims[1]);let s=t!==void 0&&t.format!==void 0?t.format:`RGB`,c=t?.norm,l,u;c===void 0||c.mean===void 0?l=[255,255,255,255]:typeof c.mean==`number`?l=[c.mean,c.mean,c.mean,c.mean]:(l=[c.mean[0],c.mean[1],c.mean[2],255],c.mean[3]!==void 0&&(l[3]=c.mean[3])),c===void 0||c.bias===void 0?u=[0,0,0,0]:typeof c.bias==`number`?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(u[3]=c.bias[3]));let d=a*i;if(t!==void 0&&(t.format!==void 0&&o===4&&t.format!==`RGBA`||o===3&&t.format!==`RGB`&&t.format!==`BGR`))throw Error(`Tensor format doesn't match input tensor dims`);let f=0,p=1,m=2,h=3,g=0,_=d,v=d*2,y=-1;s===`RGBA`?(g=0,_=d,v=d*2,y=d*3):s===`RGB`?(g=0,_=d,v=d*2):s===`RBG`&&(g=0,v=d,_=d*2),r=n.createImageData(i,a);for(let t=0;t{kn(),pn=(e,t)=>{if(e===void 0)throw Error(`Image buffer must be defined`);if(t.height===void 0||t.width===void 0)throw Error(`Image height and width must be defined`);if(t.tensorLayout===`NHWC`)throw Error(`NHWC Tensor layout is not supported yet`);let{height:n,width:r}=t,i=t.norm??{mean:255,bias:0},a,o;a=typeof i.mean==`number`?[i.mean,i.mean,i.mean,i.mean]:[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],o=typeof i.bias==`number`?[i.bias,i.bias,i.bias,i.bias]:[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let s=t.format===void 0?`RGBA`:t.format,c=t.tensorFormat!==void 0&&t.tensorFormat!==void 0?t.tensorFormat:`RGB`,l=n*r,u=c===`RGBA`?new Float32Array(l*4):new Float32Array(l*3),d=4,f=0,p=1,m=2,h=3,g=0,_=l,v=l*2,y=-1;s===`RGB`&&(d=3,f=0,p=1,m=2,h=-1),c===`RGBA`?y=l*3:c===`RBG`?(g=0,v=l,_=l*2):c===`BGR`&&(v=0,_=l,g=l*2);for(let t=0;t{let n=typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement,r=typeof ImageData<`u`&&e instanceof ImageData,i=typeof ImageBitmap<`u`&&e instanceof ImageBitmap,a=typeof e==`string`,o,s=t??{},c=()=>{if(typeof document<`u`)return document.createElement(`canvas`);if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(1,1);throw Error(`Canvas is not supported`)},l=e=>typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext(`2d`):null;if(n){let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let n=e.height,i=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(n=t.resizedHeight,i=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw Error(`Image input config format must be RGBA for HTMLImageElement`);s.tensorFormat=`RGBA`,s.height=n,s.width=i}else s.tensorFormat=`RGBA`,s.height=n,s.width=i;r.drawImage(e,0,0),o=r.getImageData(0,0,i,n).data}else throw Error(`Can not access image data`)}else if(r){let n,r;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(n=t.resizedHeight,r=t.resizedWidth):(n=e.height,r=e.width),t!==void 0&&(s=t),s.format=`RGBA`,s.height=n,s.width=r,t!==void 0){let t=c();t.width=r,t.height=n;let i=l(t);if(i!=null)i.putImageData(e,0,0),o=i.getImageData(0,0,r,n).data;else throw Error(`Can not access image data`)}else o=e.data}else if(i){if(t===void 0)throw Error(`Please provide image config with format for Imagebitmap`);let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let t=e.height,n=e.width;return r.drawImage(e,0,0,n,t),o=r.getImageData(0,0,n,t).data,s.height=t,s.width=n,pn(o,s)}throw Error(`Can not access image data`)}else{if(a)return new Promise((t,n)=>{let r=c(),i=l(r);if(!e||!i)return n();let a=new Image;a.crossOrigin=`Anonymous`,a.src=e,a.onload=()=>{r.width=a.width,r.height=a.height,i.drawImage(a,0,0,r.width,r.height);let e=i.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t(pn(e.data,s))}});throw Error(`Input data provided is not supported - aborted tensor creation`)}if(o!==void 0)return pn(o,s);throw Error(`Input data provided is not supported - aborted tensor creation`)},hn=(e,t)=>{let{width:n,height:r,download:i,dispose:a}=t;return new On({location:`texture`,type:`float32`,texture:e,dims:[1,r,n,4],download:i,dispose:a})},gn=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new On({location:`gpu-buffer`,type:n??`float32`,gpuBuffer:e,dims:r,download:i,dispose:a})},_n=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new On({location:`ml-tensor`,type:n??`float32`,mlTensor:e,dims:r,download:i,dispose:a})},vn=(e,t,n)=>new On({location:`cpu-pinned`,type:e,data:t,dims:n??[t.length]})}),bn,xn,Sn,Cn,wn=M(()=>{bn=new Map([[`float32`,Float32Array],[`uint8`,Uint8Array],[`int8`,Int8Array],[`uint16`,Uint16Array],[`int16`,Int16Array],[`int32`,Int32Array],[`bool`,Uint8Array],[`float64`,Float64Array],[`uint32`,Uint32Array],[`int4`,Uint8Array],[`uint4`,Uint8Array]]),xn=new Map([[Float32Array,`float32`],[Uint8Array,`uint8`],[Int8Array,`int8`],[Uint16Array,`uint16`],[Int16Array,`int16`],[Int32Array,`int32`],[Float64Array,`float64`],[Uint32Array,`uint32`]]),Sn=!1,Cn=()=>{if(!Sn){Sn=!0;let e=typeof BigInt64Array<`u`&&BigInt64Array.from,t=typeof BigUint64Array<`u`&&BigUint64Array.from,n=globalThis.Float16Array,r=typeof n<`u`&&n.from;e&&(bn.set(`int64`,BigInt64Array),xn.set(BigInt64Array,`int64`)),t&&(bn.set(`uint64`,BigUint64Array),xn.set(BigUint64Array,`uint64`)),r?(bn.set(`float16`,n),xn.set(n,`float16`)):bn.set(`float16`,Uint16Array)}}}),Tn,En,Dn=M(()=>{kn(),Tn=e=>{let t=1;for(let n=0;n{switch(e.location){case`cpu`:return new On(e.type,e.data,t);case`cpu-pinned`:return new On({location:`cpu-pinned`,data:e.data,type:e.type,dims:t});case`texture`:return new On({location:`texture`,texture:e.texture,type:e.type,dims:t});case`gpu-buffer`:return new On({location:`gpu-buffer`,gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case`ml-tensor`:return new On({location:`ml-tensor`,mlTensor:e.mlTensor,type:e.type,dims:t});default:throw Error(`tensorReshape: tensor location ${e.location} is not supported`)}}}),On,kn=M(()=>{fn(),yn(),wn(),Dn(),On=class{constructor(e,t,n){Cn();let r,i;if(typeof e==`object`&&`location`in e)switch(this.dataLocation=e.location,r=e.type,i=e.dims,e.location){case`cpu-pinned`:{let t=bn.get(r);if(!t)throw TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case`texture`:if(r!==`float32`)throw TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case`gpu-buffer`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;case`ml-tensor`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint64`&&r!==`int8`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break;default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof e==`string`){if(r=e,o=n,e===`string`){if(!Array.isArray(t))throw TypeError(`A string tensor's data must be a string array.`);a=t}else{let n=bn.get(e);if(n===void 0)throw TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if(e===`float16`&&n===Uint16Array||e===`uint4`||e===`int4`)throw TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${n.name} as data.`);a=e===`uint64`||e===`int64`?n.from(t,BigInt):n.from(t)}else if(t instanceof n)a=t;else if(t instanceof Uint8ClampedArray){if(e===`uint8`)a=Uint8Array.from(t);else throw TypeError(`A Uint8ClampedArray tensor's data must be type of uint8`)}else if(e===`float16`&&t instanceof Uint16Array&&n!==Uint16Array)a=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw TypeError(`A ${r} tensor's data must be type of ${n}`)}}else if(o=t,Array.isArray(e)){if(e.length===0)throw TypeError(`Tensor type cannot be inferred from an empty array.`);let t=typeof e[0];if(t===`string`)r=`string`,a=e;else if(t===`boolean`)r=`bool`,a=Uint8Array.from(e);else throw TypeError(`Invalid element type of data array: ${t}.`)}else if(e instanceof Uint8ClampedArray)r=`uint8`,a=Uint8Array.from(e);else{let t=xn.get(e.constructor);if(t===void 0)throw TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,a=e}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw TypeError(`A tensor's dims must be a number array`);i=o,this.cpuData=a,this.dataLocation=`cpu`}let a=Tn(i);if(this.cpuData&&a!==this.cpuData.length&&(r!==`uint4`&&r!==`int4`||Math.ceil(a/2)!==this.cpuData.length))throw Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=a}static async fromImage(e,t){return mn(e,t)}static fromTexture(e,t){return hn(e,t)}static fromGpuBuffer(e,t){return gn(e,t)}static fromMLTensor(e,t){return _n(e,t)}static fromPinnedBuffer(e,t,n){return vn(e,t,n)}toDataURL(e){return un(this,e)}toImageData(e){return dn(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw Error(`The data is not stored as a WebGL texture.`);return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error(`The data is not stored as a WebGPU buffer.`);return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error(`The data is not stored as a WebNN MLTensor.`);return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case`cpu`:case`cpu-pinned`:return this.data;case`texture`:case`gpu-buffer`:case`ml-tensor`:if(!this.downloader)throw Error(`The current tensor is not created with a specified data downloader.`);if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);try{this.isDownloading=!0;let t=await this.downloader();return this.downloader=void 0,this.dataLocation=`cpu`,this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);this.disposer&&=(this.disposer(),void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation=`none`}ensureValid(){if(this.dataLocation===`none`)throw Error(`The tensor is disposed.`)}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw Error(`Cannot reshape a tensor that owns GPU resource.`);return En(this,e)}}}),An,jn=M(()=>{kn(),An=On}),Mn,Nn,Pn,Fn,In,Ln,Rn=M(()=>{sn(),Mn=(e,t)=>{(typeof on.trace>`u`?!on.wasm.trace:!on.trace)||console.timeStamp(`${e}::ORT::${t}`)},Nn=(e,t)=>{let n=Error().stack?.split(/\r\n|\r|\n/g)||[],r=!1;for(let i=0;i{(typeof on.trace>`u`?!on.wasm.trace:!on.trace)||Nn(`BEGIN`,e)},Fn=e=>{(typeof on.trace>`u`?!on.wasm.trace:!on.trace)||Nn(`END`,e)},In=e=>{(typeof on.trace>`u`?!on.wasm.trace:!on.trace)||console.time(`ORT::${e}`)},Ln=e=>{(typeof on.trace>`u`?!on.wasm.trace:!on.trace)||console.timeEnd(`ORT::${e}`)}}),zn,Bn=M(()=>{en(),jn(),Rn(),zn=class e{constructor(e){this.handler=e}async run(e,t,n){Pn(),In(`InferenceSession.run`);let r={},i={};if(typeof e!=`object`||!e||e instanceof An||Array.isArray(e))throw TypeError(`'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.`);let a=!0;if(typeof t==`object`){if(t===null)throw TypeError(`Unexpected argument[1]: cannot be null.`);if(t instanceof An)throw TypeError(`'fetches' cannot be a Tensor`);if(Array.isArray(t)){if(t.length===0)throw TypeError(`'fetches' cannot be an empty array.`);a=!1;for(let e of t){if(typeof e!=`string`)throw TypeError(`'fetches' must be a string array or an object.`);if(this.outputNames.indexOf(e)===-1)throw RangeError(`'fetches' contains invalid output name: ${e}.`);r[e]=null}if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else{let e=!1,o=Object.getOwnPropertyNames(t);for(let n of this.outputNames)if(o.indexOf(n)!==-1){let i=t[n];(i===null||i instanceof An)&&(e=!0,a=!1,r[n]=i)}if(e){if(typeof n==`object`&&n)i=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else i=t}}else if(typeof t<`u`)throw TypeError(`Unexpected argument[1]: must be 'fetches' or 'options'.`);for(let t of this.inputNames)if(typeof e[t]>`u`)throw Error(`input '${t}' is missing in 'feeds'.`);if(a)for(let e of this.outputNames)r[e]=null;let o=await this.handler.run(e,r,i),s={};for(let e in o)if(Object.hasOwnProperty.call(o,e)){let t=o[e];s[e]=t instanceof An?t:new An(t.type,t.data,t.dims)}return Ln(`InferenceSession.run`),Fn(),s}async release(){return this.handler.dispose()}static async create(t,n,r,i){Pn(),In(`InferenceSession.create`);let a,o={};if(typeof t==`string`){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof Uint8Array){if(a=t,typeof n==`object`&&n)o=n;else if(typeof n<`u`)throw TypeError(`'options' must be an object.`)}else if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&t instanceof SharedArrayBuffer){let e=t,s=0,c=t.byteLength;if(typeof n==`object`&&n)o=n;else if(typeof n==`number`){if(s=n,!Number.isSafeInteger(s))throw RangeError(`'byteOffset' must be an integer.`);if(s<0||s>=e.byteLength)throw RangeError(`'byteOffset' is out of range [0, ${e.byteLength}).`);if(c=t.byteLength-s,typeof r==`number`){if(c=r,!Number.isSafeInteger(c))throw RangeError(`'byteLength' must be an integer.`);if(c<=0||s+c>e.byteLength)throw RangeError(`'byteLength' is out of range (0, ${e.byteLength-s}].`);if(typeof i==`object`&&i)o=i;else if(typeof i<`u`)throw TypeError(`'options' must be an object.`)}else if(typeof r<`u`)throw TypeError(`'byteLength' must be a number.`)}else if(typeof n<`u`)throw TypeError(`'options' must be an object.`);a=new Uint8Array(e,s,c)}else throw TypeError(`Unexpected argument[0]: must be 'path' or 'buffer'.`);let[s,c]=await $t(o),l=await s.createInferenceSessionHandler(a,c);return Ln(`InferenceSession.create`),Fn(),new e(l)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),Vn,Hn=M(()=>{Bn(),Vn=zn}),Un=M(()=>{}),Wn=M(()=>{}),Gn=M(()=>{}),Kn=M(()=>{}),qn={};Kt(qn,{InferenceSession:()=>Vn,TRACE:()=>Mn,TRACE_EVENT_BEGIN:()=>In,TRACE_EVENT_END:()=>Ln,TRACE_FUNC_BEGIN:()=>Pn,TRACE_FUNC_END:()=>Fn,Tensor:()=>An,env:()=>cn,registerBackend:()=>Zt});var Jn=M(()=>{tn(),ln(),Hn(),jn(),Un(),Wn(),Rn(),Gn(),Kn()}),Yn=M(()=>{}),Xn={};Kt(Xn,{default:()=>$n});var Zn,Qn,$n,er=M(()=>{Vi(),kr(),br(),Zn=`ort-wasm-proxy-worker`,Qn=globalThis.self?.name===Zn,Qn&&(self.onmessage=e=>{let{type:t,in:n}=e.data;try{switch(t){case`init-wasm`:Dr(n.wasm).then(()=>{ki(n).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})})},e=>{postMessage({type:t,err:e})});break;case`init-ep`:{let{epName:e,env:r}=n;Ai(r,e).then(()=>{postMessage({type:t})},e=>{postMessage({type:t,err:e})});break}case`copy-from`:{let{buffer:e}=n,r=Pi(e);postMessage({type:t,out:r});break}case`create`:{let{model:e,options:r}=n;Fi(e,r).then(e=>{postMessage({type:t,out:e})},e=>{postMessage({type:t,err:e})});break}case`release`:Ii(n),postMessage({type:t});break;case`run`:{let{sessionId:e,inputIndices:r,inputs:i,outputIndices:a,options:o}=n;Ri(e,r,i,a,Array(a.length).fill(null),o).then(e=>{e.some(e=>e[3]!==`cpu`)?postMessage({type:t,err:`Proxy does not support non-cpu tensor location.`}):postMessage({type:t,out:e},Bi([...i,...e]))},e=>{postMessage({type:t,err:e})});break}case`end-profiling`:zi(n),postMessage({type:t})}}catch(e){postMessage({type:t,err:e})}}),$n=Qn?null:e=>new Worker(e??lr,{type:`module`,name:Zn})}),tr={};Kt(tr,{default:()=>rr});async function nr(e={}){var t=e,n=!!globalThis.window,r=!!globalThis.WorkerGlobalScope,i=r&&self.name?.startsWith(`em-pthread`);t.mountExternalData=(e,n)=>{e.startsWith(`./`)&&(e=e.substring(2)),(t.ed||=new Map).set(e,n)},t.unmountExternalData=()=>{delete t.ed,delete t.Te,delete t.Se,delete t.Ue},globalThis.SharedArrayBuffer??new WebAssembly.Memory({initial:0,maximum:0,shared:!0}).buffer.constructor;let a=()=>{let e=e=>(...t)=>{let n=sn;return t=e(...t),sn==n?t:new Promise((e,t)=>{mn={resolve:e,reject:t}})};(()=>{for(let n of[`_OrtAppendExecutionProvider`,`_OrtCreateSession`,`_OrtRun`,`_OrtRunWithBinding`,`_OrtBindInput`])t[n]=e(t[n])})(),typeof jsepRunAsync<`u`&&(t._OrtRun=jsepRunAsync(t._OrtRun),t._OrtRunWithBinding=jsepRunAsync(t._OrtRunWithBinding)),a=void 0};t.asyncInit=()=>{a?.()};var o,s,c=(e,t)=>{throw t},l=import.meta.url,u=``;if(n||r){try{u=new URL(`.`,l).href}catch{}r&&(s=e=>{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}),o=async e=>{if(S(e))return new Promise((t,n)=>{var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=()=>{r.status==200||r.status==0&&r.response?t(r.response):n(r.status)},r.onerror=n,r.send(null)});var t=await fetch(e,{credentials:`same-origin`});if(t.ok)return t.arrayBuffer();throw Error(t.status+` : `+t.url)}}var d,f,p,m,h,g,_=console.log.bind(console),v=console.error.bind(console),y=_,b=v,x=!1,S=e=>e.startsWith(`file://`);function C(){je.buffer!=w.buffer&&ce()}if(i){let e=function(n){try{var r=n.data,i=r.$c;if(i===`load`){let n=[];self.onmessage=e=>n.push(e),g=()=>{postMessage({$c:`loaded`});for(let t of n)e(t);self.onmessage=e};for(let e of r.ue)t[e]&&!t[e].proxy||(t[e]=(...t)=>{postMessage({$c:`callHandler`,te:e,args:t})},e==`print`&&(y=t[e]),e==`printErr`&&(b=t[e]));je=r.Me,ce(),f=r.Ne,fe(),rs()}else if(i===`run`){(function(e){var t=(C(),O)[e+52>>>2>>>0];e=(C(),O)[e+56>>>2>>>0],Sa(t,t-e),I(t)})(r.Xc),pa(r.Xc,0,0,1,0,0),Oe(),Yt(r.Xc),ee||=(Wi(),!0);try{Me(r.ze,r.kd)}catch(e){if(e!=`unwind`)throw e}}else r.target!==`setimmediate`&&(i===`checkMailbox`?ee&&Xt():i&&(b(`worker: received unknown command ${i}`),b(r)))}catch(e){throw ma(),e}};var ee=!1;self.onunhandledrejection=e=>{throw e.reason||e},self.onmessage=e}var w,T,E,te,D,O,ne,re,ie,ae,oe,se=!1;function ce(){var e=je.buffer;t.HEAP8=w=new Int8Array(e),E=new Int16Array(e),t.HEAPU8=T=new Uint8Array(e),te=new Uint16Array(e),t.HEAP32=D=new Int32Array(e),t.HEAPU32=O=new Uint32Array(e),ne=new Float32Array(e),re=new Float64Array(e),ie=new BigInt64Array(e),ae=new BigUint64Array(e)}function le(){se=!0,i?g():go.hc()}function ue(e){throw b(e=`Aborted(`+e+`)`),x=!0,e=new WebAssembly.RuntimeError(e+`. Build with -sASSERTIONS for more info.`),h?.(e),e}function de(){return{a:{qa:yo,f:Ie,K:Re,k:Ue,p:We,l:Ge,fa:Ke,b:qe,da:Je,gc:Xe,q:Ze,ea:nt,Ua:rt,cc:it,ec:at,Va:ot,Sa:st,La:ct,Ra:lt,oa:ut,dc:dt,ac:ft,Ta:pt,bc:mt,_a:A,Ba:xt,Xb:St,Vb:At,Aa:Mt,O:Nt,J:Pt,Wb:Lt,ka:Gt,Yb:M,Oa:Kt,_b:Zt,Ea:$t,Tb:en,Ca:tn,Na:Yt,Xa:nn,U:_n,n:wn,c:Tt,qb:Tn,w:En,N:Dn,A:On,j:kn,o:An,rb:jn,H:Mn,T:Nn,g:Pn,u:Fn,m:In,i:Ln,Ia:Rn,Ja:Hn,Ka:Un,Ga:Wn,Ha:Gn,Ub:Jn,ab:Yn,Za:Qn,Z:tr,pb:nr,Da:rr,Ya:Xn,X:ir,Wa:ar,$b:or,G:qn,db:sr,_:cr,pa:mr,Zb:hr,cb:pr,bb:gr,lb:Wr,z:Gr,sa:Kr,ra:qr,nb:Jr,Y:Yr,v:Xr,kb:Zr,jb:Qr,ib:$r,mb:ei,gb:ti,fb:ni,eb:ri,Pa:si,Qa:ci,fc:Se,W:li,Fa:ui,ma:di,Ma:fi,la:mi,Fb:ts,va:Yo,Gb:es,wa:Jo,E:Io,e:So,r:xo,x:bo,C:Mo,Ib:Go,ca:Wo,D:To,xa:Ko,aa:Xo,ha:Uo,Jb:V,Kb:Ho,za:Ro,Lb:Bo,ya:Vo,Mb:zo,ua:$o,ba:qo,d:B,B:wo,s:Co,Eb:ns,t:Do,y:Po,F:Eo,I:Oo,L:Fo,Nb:Lo,R:Zo,ia:jo,$:Qo,Pb:Ao,Rb:ko,Ob:No,h:hi,a:je,$a:xe,Hb:gi,V:_i,M:vi,na:yi,Db:bi,ja:xi,S:Si,Ab:Ci,Bb:wi,vb:Ti,wb:Ei,P:Di,xb:Oi,yb:ki,ta:Ai,Sb:ji,ob:Mi,Q:Ni,hb:Pi,Cb:Fi,sb:Ii,tb:Ri,ub:zi,ga:Bi,zb:Vi,Qb:Hi}}}async function fe(){function e(e,n){var r=go=e.exports;e={};for(let[t,n]of Object.entries(r))typeof n==`function`?(r=an(n),e[t]=r):e[t]=n;return go=e,go=(function(){var e=go,t=e=>t=>e(t)>>>0,n=e=>()=>e()>>>0;return(e=Object.assign({},e)).ic=t(e.ic),e.Nc=n(e.Nc),e.Pc=t(e.Pc),e.Bd=(e=>(t,n)=>e(t,n)>>>0)(e.Bd),e.Gd=t(e.Gd),e.Hd=n(e.Hd),e.Ld=t(e.Ld),e})(),Te.push(go.sd),Ui=(e=go).ic,Wi=e.jc,t._OrtInit=e.kc,t._OrtGetLastError=e.lc,t._OrtCreateSessionOptions=e.mc,t._OrtAppendExecutionProvider=e.nc,t._OrtAddFreeDimensionOverride=e.oc,t._OrtAddSessionConfigEntry=e.pc,t._OrtReleaseSessionOptions=e.qc,t._OrtCreateSession=e.rc,t._OrtReleaseSession=e.sc,t._OrtGetInputOutputCount=e.tc,t._OrtGetInputOutputMetadata=e.uc,t._OrtFree=e.vc,t._OrtCreateTensor=e.wc,t._OrtGetTensorData=e.xc,t._OrtReleaseTensor=e.yc,t._OrtCreateRunOptions=e.zc,t._OrtAddRunConfigEntry=e.Ac,t._OrtReleaseRunOptions=e.Bc,t._OrtCreateBinding=e.Cc,t._OrtBindInput=e.Dc,t._OrtBindOutput=e.Ec,t._OrtClearBoundOutputs=e.Fc,t._OrtReleaseBinding=e.Gc,t._OrtRunWithBinding=e.Hc,t._OrtRun=e.Ic,t._OrtEndProfiling=e.Jc,Gi=t._OrtCreateWebGpuInstance=e.Kc,t._wgpuCreateInstance=e.Lc,Ki=t._OrtGetWebGpuDevice=e.Mc,qi=e.Nc,Ji=t._free=e.Oc,Yi=t._malloc=e.Pc,Xi=t._wgpuBufferRelease=e.Qc,Zi=e.Rc,Qi=e.Sc,$i=e.Tc,ea=e.Uc,ta=e.Vc,na=e.Yc,ra=e.Zc,ia=e.hd,aa=e.id,oa=e.jd,sa=e.ld,ca=e.md,la=e.nd,ua=e.od,P=e.pd,da=e.qd,fa=e.rd,pa=e.ud,ma=e.vd,ha=e.wd,ga=e.xd,_a=e.yd,va=e.zd,ya=e.Ad,ba=e.Bd,F=e.Cd,xa=e.Dd,Sa=e.Ed,I=e.Fd,Ca=e.Gd,L=e.Hd,wa=e.Id,Ta=e.Jd,Ea=e.Kd,Da=e.Ld,Oa=e.Md,ka=e.Nd,Aa=e.Od,ja=e.Pd,Ma=e.Qd,Na=e.Rd,Pa=e.Sd,Fa=e.Td,Ia=e.Ud,La=e.Vd,Ra=e.Wd,za=e.Xd,Ba=e.Yd,Va=e.Zd,Ha=e._d,Ua=e.$d,Wa=e.ae,Ga=e.be,Ka=e.ce,qa=e.de,Ja=e.fe,Ya=e.ge,Xa=e.he,Za=e.ie,Qa=e.je,$a=e.ke,eo=e.le,R=e.me,to=e.Ae,no=e.Be,ro=e.Ce,io=e.De,ao=e.Ee,oo=e.Fe,so=e.Ge,co=e.He,z=e.Ie,lo=e.Je,uo=e.Ke,fo=e.nf,po=e.of,mo=e.pf,ho=e.qf,f=n,go}var n,r=de();return t.instantiateWasm?new Promise(n=>{t.instantiateWasm(r,(t,r)=>{n(e(t,r))})}):i?e(new WebAssembly.Instance(f,de()),f):(oe??=t.locateFile?t.locateFile?t.locateFile(`ort-wasm-simd-threaded.asyncify.wasm`,u):u+`ort-wasm-simd-threaded.asyncify.wasm`:new URL(`/assets/ort-wasm-simd-threaded.asyncify-CxOG5pUO.wasm`,``+import.meta.url).href,n=await(async function(e){var t=oe;if(!d&&!S(t))try{var n=fetch(t,{credentials:`same-origin`});return await WebAssembly.instantiateStreaming(n,e)}catch(e){b(`wasm streaming compile failed: ${e}`),b(`falling back to ArrayBuffer instantiation`)}return(async function(e,t){try{var n=await(async function(e){if(!d)try{var t=await o(e);return new Uint8Array(t)}catch{}if(e==oe&&d)e=new Uint8Array(d);else{if(!s)throw`both async and sync fetching of the wasm failed`;e=s(e)}return e})(e);return await WebAssembly.instantiate(n,t)}catch(e){b(`failed to asynchronously prepare wasm: ${e}`),ue(e)}})(t,e)})(r),e(n.instance,n.module))}class pe{name=`ExitStatus`;constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var me=e=>{e.terminate(),e.onmessage=()=>{}},he=[],ge=0,_e=null,ve=e=>{Ce.length==0&&(Ae(),ke(Ce[0]));var t=Ce.pop();if(!t)return 6;we.push(t),Ee[e.Xc]=t,t.Xc=e.Xc;var n={$c:`run`,ze:e.ye,kd:e.kd,Xc:e.Xc};return t.postMessage(n,e.oe),0},ye=0,be=(e,t,...n)=>{var r,i=16*n.length,a=L(),o=Ca(i),s=o>>>3;for(r of n)typeof r==`bigint`?((C(),ie)[s++>>>0]=1n,(C(),ie)[s++>>>0]=r):((C(),ie)[s++>>>0]=0n,(C(),re)[s++>>>0]=r);return e=ha(e,0,i,o,t),I(a),e};function xe(e){if(i)return be(0,1,e);if(p=e,!(0{if(p=e,i)throw k(e),`unwind`;xe(e)},Ce=[],we=[],Te=[],Ee={},De=e=>{var t=e.Xc;delete Ee[t],Ce.push(e),we.splice(we.indexOf(e),1),e.Xc=0,ga(t)};function Oe(){Te.forEach(e=>e())}var ke=e=>new Promise(n=>{e.onmessage=r=>{var i=r.data;if(r=i.$c,i.gd&&i.gd!=qi()){var a=Ee[i.gd];a?a.postMessage(i,i.oe):b(`Internal error! Worker sent a message "${r}" to target pthread ${i.gd}, but that thread no longer exists!`)}else r===`checkMailbox`?Xt():r===`spawnThread`?ve(i):r===`cleanupThread`?qt(()=>{De(Ee[i.Le])}):r===`loaded`?(e.loaded=!0,n(e)):i.target===`setimmediate`?e.postMessage(i):r===`uncaughtException`?e.onerror(i.error):r===`callHandler`?t[i.te](...i.args):r&&b(`worker sent an unknown command ${r}`)},e.onerror=e=>{throw b(`worker sent an error! ${e.filename}:${e.lineno}: ${e.message}`),e};var r,i=[];for(r of[])t.propertyIsEnumerable(r)&&i.push(r);e.postMessage({$c:`load`,ue:i,Me:je,Ne:f})});function Ae(){var e=new Worker((()=>{let e=URL;return import.meta.url>`file:`&&import.meta.url<`file;`?new e(`ort.webgpu.bundle.min.mjs`,import.meta.url):new URL(import.meta.url)})(),{type:`module`,workerData:`em-pthread`,name:`em-pthread`});Ce.push(e)}var je,Me=(e,t)=>{ye=0,e=ka(e,t),0-9007199254740992>e||9007199254740992>>=0);return(C(),w)[t.ad+12>>>0]==0&&(ze(t,!0),Pe--),Be(t,!1),Ne.push(t),Da(e)}var Le=0,Re=()=>{F(0,0);var e=Ne.pop();wa(e.td),Le=0};function ze(e,t){t=+!!t,(C(),w)[e.ad+12>>>0]=t}function Be(e,t){t=+!!t,(C(),w)[e.ad+13>>>0]=t}class Ve{constructor(e){this.td=e,this.ad=e-24}}var He=e=>{var t=Le;if(!t)return xa(0),0;var n=new Ve(t);(C(),O)[n.ad+16>>>2>>>0]=t;var r=(C(),O)[n.ad+4>>>2>>>0];if(!r)return xa(0),t;for(var i of e){if(i===0||i===r)break;if(Ea(i,r,n.ad+16))return xa(i),t}return xa(r),t};function Ue(){return He([])}function We(e){return He([e>>>0])}function Ge(e,t,n,r){return He([e>>>0,t>>>0,n>>>0,r>>>0])}var Ke=()=>{var e=Ne.pop();e||ue(`no exception to throw`);var t=e.td;throw(C(),w)[e.ad+13>>>0]==0&&(Ne.push(e),Be(e,!0),ze(e,!1),Pe++),Ta(t),Le=t};function qe(e,t,n){var r=new Ve(e>>>=0);throw t>>>=0,n>>>=0,(C(),O)[r.ad+16>>>2>>>0]=0,(C(),O)[r.ad+4>>>2>>>0]=t,(C(),O)[r.ad+8>>>2>>>0]=n,Ta(e),Pe++,Le=e}var Je=()=>Pe;function Ye(e,t,n,r){return i?be(2,1,e,t,n,r):Xe(e,t,n,r)}function Xe(e,t,n,r){if(e>>>=0,t>>>=0,n>>>=0,r>>>=0,!globalThis.SharedArrayBuffer)return 6;var a=[];return i&&a.length===0?Ye(e,t,n,r):(e={ye:n,Xc:e,kd:r,oe:a},i?(e.$c=`spawnThread`,postMessage(e,a),0):ve(e))}function Ze(e){throw Le||=e>>>0,Le}var Qe=globalThis.TextDecoder&&new TextDecoder,$e=(e,t,n,r)=>{if(n=t+n,r)return n;for(;e[t]&&!(t>=n);)++t;return t},et=(e,t=0,n,r)=>{if(16<(n=$e(e,t>>>=0,n,r))-t&&e.buffer&&Qe)return Qe.decode(e.buffer instanceof ArrayBuffer?e.subarray(t,n):e.slice(t,n));for(r=``;t(i=(240&i)==224?(15&i)<<12|a<<6|o:(7&i)<<18|a<<12|o<<6|63&e[t++])?r+=String.fromCharCode(i):(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else r+=String.fromCharCode(i)}return r},tt=(e,t,n)=>(e>>>=0)?et((C(),T),e,t,n):``;function nt(e,t,n){return i?be(3,1,e,t,n):0}function rt(e,t){if(i)return be(4,1,e,t)}function it(e,t){if(i)return be(5,1,e,t)}function at(e,t,n){if(i)return be(6,1,e,t,n)}function ot(e,t,n){return i?be(7,1,e,t,n):0}function st(e,t){if(i)return be(8,1,e,t)}function ct(e,t,n){if(i)return be(9,1,e,t,n)}function lt(e,t,n,r){if(i)return be(10,1,e,t,n,r)}function ut(e,t,n,r){if(i)return be(11,1,e,t,n,r)}function dt(e,t,n,r){if(i)return be(12,1,e,t,n,r)}function ft(e){if(i)return be(13,1,e)}function pt(e,t){if(i)return be(14,1,e,t)}function mt(e,t,n){if(i)return be(15,1,e,t,n)}var A=()=>ue(``),ht=e=>{e>>>=0;for(var t=``;;){var n=(C(),T)[e++>>>0];if(!n)return t;t+=String.fromCharCode(n)}},j={},gt={},_t={},vt=class extends Error{constructor(e){super(e),this.name=`BindingError`}};function yt(e,t,n={}){return(function(e,t,n={}){var r=t.name;if(!e)throw new vt(`type "${r}" must have a positive integer typeid pointer`);if(gt.hasOwnProperty(e)){if(n.ve)return;throw new vt(`Cannot register type '${r}' twice`)}gt[e]=t,delete _t[e],j.hasOwnProperty(e)&&(t=j[e],delete j[e],t.forEach(e=>e()))})(e,t,n)}var bt=(e,t,n)=>{switch(t){case 1:return n?e=>(C(),w)[e>>>0]:e=>(C(),T)[e>>>0];case 2:return n?e=>(C(),E)[e>>>1>>>0]:e=>(C(),te)[e>>>1>>>0];case 4:return n?e=>(C(),D)[e>>>2>>>0]:e=>(C(),O)[e>>>2>>>0];case 8:return n?e=>(C(),ie)[e>>>3>>>0]:e=>(C(),ae)[e>>>3>>>0];default:throw TypeError(`invalid integer width (${t}): ${e}`)}};function xt(e,t,n,r,i){e>>>=0,n>>>=0,t=ht(t>>>0);let a=e=>e;if(r=r===0n){let e=8*n;a=t=>BigInt.asUintN(e,t),i=a(i)}yt(e,{name:t,Wc:a,cd:(e,t)=>(typeof t==`number`&&(t=BigInt(t)),t),bd:bt(t,n,!r),dd:null})}function St(e,t,n,r){yt(e>>>=0,{name:t=ht(t>>>0),Wc:function(e){return!!e},cd:function(e,t){return t?n:r},bd:function(e){return this.Wc((C(),T)[e>>>0])},dd:null})}var Ct=[],wt=[0,1,,1,null,1,!0,1,!1,1];function Tt(e){9<(e>>>=0)&&--wt[e+1]===0&&(wt[e]=void 0,Ct.push(e))}var Et=e=>{if(!e)throw new vt(`Cannot use deleted val. handle = ${e}`);return wt[e]},Dt=e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let t=Ct.pop()||wt.length;return wt[t]=e,wt[t+1]=1,t}};function Ot(e){return this.Wc((C(),O)[e>>>2>>>0])}var kt={name:`emscripten::val`,Wc:e=>{var t=Et(e);return Tt(e),t},cd:(e,t)=>Dt(t),bd:Ot,dd:null};function At(e){return yt(e>>>0,kt)}var jt=(e,t)=>{switch(t){case 4:return function(e){return this.Wc((C(),ne)[e>>>2>>>0])};case 8:return function(e){return this.Wc((C(),re)[e>>>3>>>0])};default:throw TypeError(`invalid float width (${t}): ${e}`)}};function Mt(e,t,n){n>>>=0,yt(e>>>=0,{name:t=ht(t>>>0),Wc:e=>e,cd:(e,t)=>t,bd:jt(t,n),dd:null})}function Nt(e,t,n,r,i){e>>>=0,n>>>=0,t=ht(t>>>0);let a=e=>e;if(r===0){var o=32-8*n;a=e=>e<>>o,i=a(i)}yt(e,{name:t,Wc:a,cd:(e,t)=>t,bd:bt(t,n,r!==0),dd:null})}function Pt(e,t,n){function r(e){var t=(C(),O)[e>>>2>>>0];return e=(C(),O)[e+4>>>2>>>0],new i((C(),w).buffer,e,t)}var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][t];yt(e>>>=0,{name:n=ht(n>>>0),Wc:r,bd:r},{ve:!0})}var Ft=(e,t,n)=>{var r=(C(),T);if(t>>>=0,0=o){if(t>=n)break;r[t++>>>0]=o}else if(2047>=o){if(t+1>=n)break;r[t++>>>0]=192|o>>6,r[t++>>>0]=128|63&o}else if(65535>=o){if(t+2>=n)break;r[t++>>>0]=224|o>>12,r[t++>>>0]=128|o>>6&63,r[t++>>>0]=128|63&o}else{if(t+3>=n)break;r[t++>>>0]=240|o>>18,r[t++>>>0]=128|o>>12&63,r[t++>>>0]=128|o>>6&63,r[t++>>>0]=128|63&o,a++}}r[t>>>0]=0,e=t-i}else e=0;return e},It=e=>{for(var t=0,n=0;n=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t};function Lt(e,t){yt(e>>>=0,{name:t=ht(t>>>0),Wc(e){var t=(C(),O)[e>>>2>>>0];return t=tt(e+4,t,!0),Ji(e),t},cd(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var n=typeof t==`string`;if(!(n||ArrayBuffer.isView(t)&&t.BYTES_PER_ELEMENT==1))throw new vt(`Cannot pass non-string to std::string`);var r=n?It(t):t.length,i=Yi(4+r+1),a=i+4;return(C(),O)[i>>>2>>>0]=r,n?Ft(t,a,r+1):(C(),T).set(t,a>>>0),e!==null&&e.push(Ji,i),i},bd:Ot,dd(e){Ji(e)}})}var Rt=globalThis.TextDecoder?new TextDecoder(`utf-16le`):void 0,zt=(e,t,n)=>{if(e>>>=1,16<(t=$e((C(),te),e,t/2,n))-e&&Rt)return Rt.decode((C(),te).slice(e,t));for(n=``;e>>0];n+=String.fromCharCode(r)}return n},Bt=(e,t,n)=>{if(n??=2147483647,2>n)return 0;var r=t;n=(n-=2)<2*e.length?n/2:e.length;for(var i=0;i>>1>>>0]=a,t+=2}return(C(),E)[t>>>1>>>0]=0,t-r},Vt=e=>2*e.length,Ht=(e,t,n)=>{var r=``;e>>>=2;for(var i=0;!(i>=t/4);i++){var a=(C(),O)[e+i>>>0];if(!a&&!n)break;r+=String.fromCodePoint(a)}return r},Ut=(e,t,n)=>{if(t>>>=0,n??=2147483647,4>n)return 0;var r=t;n=r+n-4;for(var i=0;i>>2>>>0]=a,(t+=4)+4>n)break}return(C(),D)[t>>>2>>>0]=0,t-r},Wt=e=>{for(var t=0,n=0;n>>=0,t>>>=0,n=ht(n>>>=0),t===2)var r=zt,i=Bt,a=Vt;else r=Ht,i=Ut,a=Wt;yt(e,{name:n,Wc:e=>{var n=(C(),O)[e>>>2>>>0];return n=r(e+4,n*t,!0),Ji(e),n},cd:(e,r)=>{if(typeof r!=`string`)throw new vt(`Cannot pass non-string to C++ string type ${n}`);var o=a(r),s=Yi(4+o+t);return(C(),O)[s>>>2>>>0]=o/t,i(r,s+4,o+t),e!==null&&e.push(Ji,s),s},bd:Ot,dd(e){Ji(e)}})}function M(e,t){yt(e>>>=0,{we:!0,name:t=ht(t>>>0),Wc:()=>{},cd:()=>{}})}function Kt(e){pa(e>>>0,!r,1,!n,131072,!1),Oe()}var qt=e=>{if(!x)try{if(e(),!(0Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2]);function Yt(e){e>>>=0,Jt||(Atomics.waitAsync((C(),D),e>>>2,e).value.then(Xt),e+=128,Atomics.store((C(),D),e>>>2,1))}var Xt=()=>qt(()=>{var e=qi();e&&(Yt(e),ya())});function Zt(e,t){(e>>>=0)==t>>>0?setTimeout(Xt):i?postMessage({gd:e,$c:`checkMailbox`}):(e=Ee[e])&&e.postMessage({$c:`checkMailbox`})}var Qt=[];function $t(e,t,n,r,i){for(t>>>=0,i>>>=0,Qt.length=0,n=i>>>3,r=i+r>>>3;n>>0]?(C(),ie)[n++>>>0]:(C(),re)[n++>>>0];Qt.push(a)}return(t?vo[t]:_o[e])(...Qt)}var en=()=>{ye=0};function tn(e){e>>>=0,i?postMessage({$c:`cleanupThread`,Le:e}):De(Ee[e])}function nn(e){}var rn=e=>{try{e()}catch(e){ue(e)}};function an(e){var t=(...t)=>{ln.push(e);try{return e(...t)}finally{x||(ln.pop(),sn&&on===1&&ln.length===0&&(on=0,ye+=1,rn(po),typeof Fibers<`u`&&Fibers.We()))}};return fn.set(e,t),t}var on=0,sn=null,cn=0,ln=[],un=new Map,dn=new Map,fn=new Map,pn=0,mn=null,hn=[],gn=e=>(function(e){if(!x){if(on===0){var t=!1,n=!1;e((e=0)=>{if(!x&&(cn=e,t=!0,n)){on=2,rn(()=>mo(sn)),typeof MainLoop<`u`&&MainLoop.se&&MainLoop.resume(),e=!1;try{var r=(function(){var e=(C(),D)[sn+8>>>2>>>0];return e=dn.get(e),e=fn.get(e),--ye,e()})()}catch(t){r=t,e=!0}var i=!1;if(!sn){var a=mn;a&&(mn=null,(e?a.reject:a.resolve)(r),i=!0)}if(e&&!i)throw r}}),n=!0,t||(on=1,sn=(function(){var e=Yi(65548),t=e+12;if((C(),O)[e>>>2>>>0]=t,(C(),O)[e+4>>>2>>>0]=t+65536,t=ln[0],!un.has(t)){var n=pn++;un.set(t,n),dn.set(n,t)}return t=un.get(t),(C(),D)[e+8>>>2>>>0]=t,e})(),typeof MainLoop<`u`&&MainLoop.se&&MainLoop.pause(),rn(()=>fo(sn)))}else on===2?(on=0,rn(ho),Ji(sn),sn=null,hn.forEach(qt)):ue(`invalid state: ${on}`);return cn}})(t=>{e().then(t)});function _n(e){return e>>>=0,gn(async()=>Dt(await Et(e)))}var vn=[],yn=e=>{var t=vn.length;return vn.push(e),t},bn=(e,t)=>{for(var n=Array(e),r=0;r>>2>>>0],o=gt[a];if(o===void 0)throw e=`parameter ${r}`,a=Ui(a),t=ht(a),Ji(a),new vt(`${e} has unknown type ${t}`);n[i]=o}return n},xn=(e,t,n)=>{var r=[];return e=e(r,n),r.length&&((C(),O)[t>>>2>>>0]=Dt(r)),e},Sn={},Cn=e=>{var t=Sn[e];return t===void 0?ht(e):t};function wn(e,t,n){var[r,...i]=bn(e,t>>>0);t=r.cd.bind(r);var a=i.map(e=>e.bd.bind(e));e--;var o={toValue:Et};switch(e=a.map((e,t)=>{var n=`argFromPtr${t}`;return o[n]=e,`${n}(args${t?`+`+8*t:``})`}),n){case 0:var s=`toValue(handle)`;break;case 2:s=`new (toValue(handle))`;break;case 3:s=``;break;case 1:o.getStringOrSymbol=Cn,s=`toValue(handle)[getStringOrSymbol(methodName)]`}return s+=`(${e})`,r.we||(o.toReturnWire=t,o.emval_returnValue=xn,s=`return emval_returnValue(toReturnWire, destructorsRef, ${s})`),s=`return function (handle, methodName, destructorsRef, args) { + ${s} + }`,n=Function(Object.keys(o),s)(...Object.values(o)),s=`methodCaller<(${i.map(e=>e.name)}) => ${r.name}>`,yn(Object.defineProperty(n,"name",{value:s}))}function Tn(e,t){return t>>>=0,(e=Et(e>>>0))==Et(t)}function En(e){return(e>>>=0)?(e=Cn(e),Dt(globalThis[e])):Dt(globalThis)}function Dn(e){return e=Cn(e>>>0),Dt(t[e])}function On(e,t){return t>>>=0,e=Et(e>>>0),t=Et(t),Dt(e[t])}function kn(e){9<(e>>>=0)&&(wt[e+1]+=1)}function An(e,t,n,r,i){return vn[e>>>0](t>>>0,n>>>0,r>>>0,i>>>0)}function jn(e,t,n,r,i){return An(e>>>0,t>>>0,n>>>0,r>>>0,i>>>0)}function Mn(){return Dt([])}function Nn(e){e=Et(e>>>0);for(var t=Array(e.length),n=0;n>>0))}function Fn(){return Dt({})}function In(e){for(var t=Et(e>>>=0);t.length;){var n=t.pop();t.pop()(n)}Tt(e)}function Ln(e,t,n){t>>>=0,n>>>=0,e=Et(e>>>0),t=Et(t),n=Et(n),e[t]=n}function Rn(e,t){e=Fe(e),t>>>=0,e=new Date(1e3*e),(C(),D)[t>>>2>>>0]=e.getUTCSeconds(),(C(),D)[t+4>>>2>>>0]=e.getUTCMinutes(),(C(),D)[t+8>>>2>>>0]=e.getUTCHours(),(C(),D)[t+12>>>2>>>0]=e.getUTCDate(),(C(),D)[t+16>>>2>>>0]=e.getUTCMonth(),(C(),D)[t+20>>>2>>>0]=e.getUTCFullYear()-1900,(C(),D)[t+24>>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,(C(),D)[t+28>>>2>>>0]=e}var zn=e=>e%4==0&&(e%100!=0||e%400==0),Bn=[0,31,60,91,121,152,182,213,244,274,305,335],Vn=[0,31,59,90,120,151,181,212,243,273,304,334];function Hn(e,t){e=Fe(e),t>>>=0,e=new Date(1e3*e),(C(),D)[t>>>2>>>0]=e.getSeconds(),(C(),D)[t+4>>>2>>>0]=e.getMinutes(),(C(),D)[t+8>>>2>>>0]=e.getHours(),(C(),D)[t+12>>>2>>>0]=e.getDate(),(C(),D)[t+16>>>2>>>0]=e.getMonth(),(C(),D)[t+20>>>2>>>0]=e.getFullYear()-1900,(C(),D)[t+24>>>2>>>0]=e.getDay();var n=(zn(e.getFullYear())?Bn:Vn)[e.getMonth()]+e.getDate()-1|0;(C(),D)[t+28>>>2>>>0]=n,(C(),D)[t+36>>>2>>>0]=-60*e.getTimezoneOffset(),n=new Date(e.getFullYear(),6,1).getTimezoneOffset();var r=new Date(e.getFullYear(),0,1).getTimezoneOffset();e=0|(n!=r&&e.getTimezoneOffset()==Math.min(r,n)),(C(),D)[t+32>>>2>>>0]=e}function Un(e){e>>>=0;var t=new Date((C(),D)[e+20>>>2>>>0]+1900,(C(),D)[e+16>>>2>>>0],(C(),D)[e+12>>>2>>>0],(C(),D)[e+8>>>2>>>0],(C(),D)[e+4>>>2>>>0],(C(),D)[e>>>2>>>0],0),n=(C(),D)[e+32>>>2>>>0],r=t.getTimezoneOffset(),i=new Date(t.getFullYear(),6,1).getTimezoneOffset(),a=new Date(t.getFullYear(),0,1).getTimezoneOffset(),o=Math.min(a,i);return 0>n?(C(),D)[e+32>>>2>>>0]=+(i!=a&&o==r):0>>2>>>0]=t.getDay(),n=(zn(t.getFullYear())?Bn:Vn)[t.getMonth()]+t.getDate()-1|0,(C(),D)[e+28>>>2>>>0]=n,(C(),D)[e>>>2>>>0]=t.getSeconds(),(C(),D)[e+4>>>2>>>0]=t.getMinutes(),(C(),D)[e+8>>>2>>>0]=t.getHours(),(C(),D)[e+12>>>2>>>0]=t.getDate(),(C(),D)[e+16>>>2>>>0]=t.getMonth(),(C(),D)[e+20>>>2>>>0]=t.getYear(),e=t.getTime(),BigInt(isNaN(e)?-1:e/1e3)}function Wn(e,t,n,r,a,o,s){return i?be(16,1,e,t,n,r,a,o,s):-52}function Gn(e,t,n,r,a,o){if(i)return be(17,1,e,t,n,r,a,o)}var Kn={},qn=()=>performance.timeOrigin+performance.now();function Jn(e,t){return i?be(18,1,e,t):(Kn[e]&&(clearTimeout(Kn[e].id),delete Kn[e]),t&&(Kn[e]={id:setTimeout(()=>{delete Kn[e],qt(()=>va(e,performance.timeOrigin+performance.now()))},t),Ve:t}),0)}function Yn(e,t,n,r){e>>>=0,t>>>=0,n>>>=0,r>>>=0;var i=new Date().getFullYear(),a=new Date(i,0,1).getTimezoneOffset();i=new Date(i,6,1).getTimezoneOffset();var o=Math.max(a,i);(C(),O)[e>>>2>>>0]=60*o,(C(),D)[t>>>2>>>0]=+(a!=i),e=(t=e=>{var t=Math.abs(e);return`UTC${0<=e?`-`:`+`}${String(Math.floor(t/60)).padStart(2,`0`)}${String(t%60).padStart(2,`0`)}`})(a),t=t(i),iDate.now(),Zn=1;function Qn(e,t,n){if(n>>>=0,!(0<=e&&3>=e))return 28;if(e===0)e=Date.now();else{if(!Zn)return 52;e=performance.timeOrigin+performance.now()}return e=Math.round(1e6*e),(C(),ie)[n>>>3>>>0]=BigInt(e),0}var $n=[],er=(e,t)=>{$n.length=0;for(var n;n=(C(),T)[e++>>>0];){var r=n!=105;t+=(r&=n!=112)&&t%8?4:0,$n.push(n==112?(C(),O)[t>>>2>>>0]:n==106?(C(),ie)[t>>>3>>>0]:n==105?(C(),D)[t>>>2>>>0]:(C(),re)[t>>>3>>>0]),t+=r?8:4}return $n};function tr(e,t,n){return e>>>=0,t=er(t>>>0,n>>>0),vo[e](...t)}function nr(e,t,n){return e>>>=0,t=er(t>>>0,n>>>0),vo[e](...t)}var rr=()=>{};function ir(e,t){return b(tt(e>>>0,t>>>0))}var ar=()=>{throw ye+=1,`unwind`};function or(){return 4294901760}var sr=()=>1,cr=()=>navigator.hardwareConcurrency,lr={},ur=e=>{var t=It(e)+1,n=Yi(t);return n&&Ft(e,n,t),n},dr=e=>{var t;return(t=/\bwasm-function\[\d+\]:(0x[0-9a-f]+)/.exec(e))?+t[1]:(t=/:(\d+):\d+(?:\)|$)/.exec(e))?2147483648|t[1]:0},fr=e=>{for(var t of e)(e=dr(t))&&(lr[e]=t)};function pr(){var e=Error().stack.toString().split(` +`);return e[0]==`Error`&&e.shift(),fr(e),lr.ee=dr(e[3]),lr.xe=e,lr.ee}function mr(e){if(!(e=lr[e>>>0]))return 0;var t;if(t=/^\s+at .*\.wasm\.(.*) \(.*\)$/.exec(e))e=t[1];else if(t=/^\s+at (.*) \(.*\)$/.exec(e))e=t[1];else{if(!(t=/^(.+?)@/.exec(e)))return 0;e=t[1]}return Ji(mr.ne??0),mr.ne=ur(e),mr.ne}function hr(e){e>>>=0;var t=(C(),T).length;if(e<=t||4294901760=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);e:{r=(Math.min(4294901760,65536*Math.ceil(Math.max(e,r)/65536))-je.buffer.byteLength+65535)/65536|0;try{je.grow(r),ce();var i=1;break e}catch{}i=void 0}if(i)return!0}return!1}function gr(e,t,n){if(e>>>=0,t>>>=0,lr.ee==e)var r=lr.xe;else(r=Error().stack.toString().split(` +`))[0]==`Error`&&r.shift(),fr(r);for(var i=3;r[i]&&dr(r[i])!=e;)++i;for(e=0;e>>2>>>0]=dr(r[e+i]);return e}var _r=e=>{var t=It(e)+1,n=Ca(t);return Ft(e,n,t),n},vr=e=>(C(),O)[e>>>2>>>0]+4294967296*(C(),D)[e+4>>>2>>>0],yr=[],br=(e,t)=>{yr[e>>>0]=t},xr=[],Sr=[],Cr=(e,t)=>{Sr[e]=new Promise(n=>t.finally(()=>n(e)))},N=e=>{if(e)return yr[e>>>0]},wr=(e,t)=>{for(e=(C(),O)[e>>>2>>>0];e;e=(C(),O)[e>>>2>>>0])t[(C(),D)[e+4>>>2>>>0]](e)},Tr=(e,t,n)=>{(C(),O)[e>>>2>>>0]=t,(C(),O)[e+4>>>2>>>0]=n},Er=e=>{var t=(C(),O)[e>>>2>>>0];return e=(C(),O)[e+4>>>2>>>0],tt(t,e)},Dr=e=>{var t=(C(),O)[e>>>2>>>0];return e=(C(),O)[e+4>>>2>>>0],t?tt(t,e):e===0?``:void 0},Or=e=>{var t=Dr(e+4),n=(n=(C(),O)[e+12>>>2>>>0])?N(n):`auto`;if(e+=16){var r=N((C(),O)[e+4>>>2>>>0]),i=(C(),O)[e+16>>>2>>>0],a=(C(),O)[e+20>>>2>>>0];if(i){for(var o={},s=0;s>>3>>>0]}i=o}else i=void 0;e={module:r,constants:i,entryPoint:Dr(e+8)}}else e=void 0;return{label:t,layout:n,compute:e}},kr=(e,t)=>{function n(t,n,r,i=0){t=e[t]??i,(C(),O)[n+r>>>2>>>0]=t}function r(t,n,r,i=0){n+=r,t=e[t]??i,(C(),O)[n>>>2>>>0]=t,i=(C(),O)[n>>>2>>>0],(C(),O)[n+4>>>2>>>0]=(t-i)/4294967296}var i=(C(),O)[t>>>2>>>0];n(`maxTextureDimension1D`,t,4),n(`maxTextureDimension2D`,t,8),n(`maxTextureDimension3D`,t,12),n(`maxTextureArrayLayers`,t,16),n(`maxBindGroups`,t,20),n(`maxBindGroupsPlusVertexBuffers`,t,24),n(`maxBindingsPerBindGroup`,t,28),n(`maxDynamicUniformBuffersPerPipelineLayout`,t,32),n(`maxDynamicStorageBuffersPerPipelineLayout`,t,36),n(`maxSampledTexturesPerShaderStage`,t,40),n(`maxSamplersPerShaderStage`,t,44),n(`maxStorageBuffersPerShaderStage`,t,48),n(`maxStorageTexturesPerShaderStage`,t,52),n(`maxUniformBuffersPerShaderStage`,t,56),n(`minUniformBufferOffsetAlignment`,t,80),n(`minStorageBufferOffsetAlignment`,t,84),r(`maxUniformBufferBindingSize`,t,64),r(`maxStorageBufferBindingSize`,t,72),n(`maxVertexBuffers`,t,88),r(`maxBufferSize`,t,96),n(`maxVertexAttributes`,t,104),n(`maxVertexBufferArrayStride`,t,108),n(`maxInterStageShaderVariables`,t,112),n(`maxColorAttachments`,t,116),n(`maxColorAttachmentBytesPerSample`,t,120),n(`maxComputeWorkgroupStorageSize`,t,124),n(`maxComputeInvocationsPerWorkgroup`,t,128),n(`maxComputeWorkgroupSizeX`,t,132),n(`maxComputeWorkgroupSizeY`,t,136),n(`maxComputeWorkgroupSizeZ`,t,140),n(`maxComputeWorkgroupsPerDimension`,t,144),n(`maxImmediateSize`,t,148),i!==0&&(C(),n(`maxStorageBuffersInVertexStage`,i,8,e.maxStorageBuffersPerShaderStage),n(`maxStorageBuffersInFragmentStage`,i,16,e.maxStorageBuffersPerShaderStage),n(`maxStorageTexturesInVertexStage`,i,12,e.maxStorageTexturesPerShaderStage),n(`maxStorageTexturesInFragmentStage`,i,20,e.maxStorageTexturesPerShaderStage))},Ar=(e,t)=>{(C(),O)[t+52>>>2>>>0]=e.subgroupMinSize,(C(),O)[t+56>>>2>>>0]=e.subgroupMaxSize;var n=ur(e.vendor+e.architecture+e.device+e.description),r=It(e.vendor);Tr(t+4,n,r),n+=r,r=It(e.architecture),Tr(t+12,n,r),n+=r,r=It(e.device),Tr(t+20,n,r),n+=r,r=It(e.description),Tr(t+28,n,r),n+=r,(C(),D)[t+36>>>2>>>0]=2,n=e.isFallbackAdapter?3:4,(C(),D)[t+40>>>2>>>0]=n,(C(),O)[t+44>>>2>>>0]=0,(C(),O)[t+48>>>2>>>0]=0,wr(t,{327739:t=>{let n=0,r=0;if(e.subgroupMatrixConfigs){n=e.subgroupMatrixConfigs.length,r=Yi(20*n);for(let[t,n]of e.subgroupMatrixConfigs.entries()){let e=r+20*t,i=zr.indexOf(n.componentType),a=zr.indexOf(n.resultComponentType);(C(),D)[e>>>2>>>0]=i,(C(),D)[e+4>>>2>>>0]=a,(C(),O)[e+8>>>2>>>0]=n.M,(C(),O)[e+12>>>2>>>0]=n.N,(C(),O)[e+16>>>2>>>0]=n.K}}(C(),O)[t+12>>>2>>>0]=r,(C(),O)[t+8>>>2>>>0]=n}})},jr=[,,`uniform`,`storage`,`read-only-storage`],Mr=[,`validation`,`out-of-memory`,`internal`],Nr=[,`compatibility`,`core`],Pr={1:`core-features-and-limits`,2:`depth-clip-control`,3:`depth32float-stencil8`,4:`texture-compression-bc`,5:`texture-compression-bc-sliced-3d`,6:`texture-compression-etc2`,7:`texture-compression-astc`,8:`texture-compression-astc-sliced-3d`,9:`timestamp-query`,10:`indirect-first-instance`,11:`shader-f16`,12:`rg11b10ufloat-renderable`,13:`bgra8unorm-storage`,14:`float32-filterable`,15:`float32-blendable`,16:`clip-distances`,17:`dual-source-blending`,18:`subgroups`,19:`texture-formats-tier1`,20:`texture-formats-tier2`,21:`primitive-index`,22:`texture-component-swizzle`,23:`subgroup-size-control`,327692:`chromium-experimental-unorm16-texture-formats`,327729:`chromium-experimental-multi-draw-indirect`,327732:`chromium-experimental-subgroup-matrix`},Fr=[,`low-power`,`high-performance`],Ir=[,`occlusion`,`timestamp`],Lr=[,,`filtering`,`non-filtering`,`comparison`],Rr=[,,`write-only`,`read-only`,`read-write`],zr=[,`f32`,`f16`,`u32`,`i32`,`u8`,`i8`],Br=[,`r8unorm`,`r8snorm`,`r8uint`,`r8sint`,`r16unorm`,`r16snorm`,`r16uint`,`r16sint`,`r16float`,`rg8unorm`,`rg8snorm`,`rg8uint`,`rg8sint`,`r32float`,`r32uint`,`r32sint`,`rg16unorm`,`rg16snorm`,`rg16uint`,`rg16sint`,`rg16float`,`rgba8unorm`,`rgba8unorm-srgb`,`rgba8snorm`,`rgba8uint`,`rgba8sint`,`bgra8unorm`,`bgra8unorm-srgb`,`rgb10a2uint`,`rgb10a2unorm`,`rg11b10ufloat`,`rgb9e5ufloat`,`rg32float`,`rg32uint`,`rg32sint`,`rgba16unorm`,`rgba16snorm`,`rgba16uint`,`rgba16sint`,`rgba16float`,`rgba32float`,`rgba32uint`,`rgba32sint`,`stencil8`,`depth16unorm`,`depth24plus`,`depth24plus-stencil8`,`depth32float`,`depth32float-stencil8`,`bc1-rgba-unorm`,`bc1-rgba-unorm-srgb`,`bc2-rgba-unorm`,`bc2-rgba-unorm-srgb`,`bc3-rgba-unorm`,`bc3-rgba-unorm-srgb`,`bc4-r-unorm`,`bc4-r-snorm`,`bc5-rg-unorm`,`bc5-rg-snorm`,`bc6h-rgb-ufloat`,`bc6h-rgb-float`,`bc7-rgba-unorm`,`bc7-rgba-unorm-srgb`,`etc2-rgb8unorm`,`etc2-rgb8unorm-srgb`,`etc2-rgb8a1unorm`,`etc2-rgb8a1unorm-srgb`,`etc2-rgba8unorm`,`etc2-rgba8unorm-srgb`,`eac-r11unorm`,`eac-r11snorm`,`eac-rg11unorm`,`eac-rg11snorm`,`astc-4x4-unorm`,`astc-4x4-unorm-srgb`,`astc-5x4-unorm`,`astc-5x4-unorm-srgb`,`astc-5x5-unorm`,`astc-5x5-unorm-srgb`,`astc-6x5-unorm`,`astc-6x5-unorm-srgb`,`astc-6x6-unorm`,`astc-6x6-unorm-srgb`,`astc-8x5-unorm`,`astc-8x5-unorm-srgb`,`astc-8x6-unorm`,`astc-8x6-unorm-srgb`,`astc-8x8-unorm`,`astc-8x8-unorm-srgb`,`astc-10x5-unorm`,`astc-10x5-unorm-srgb`,`astc-10x6-unorm`,`astc-10x6-unorm-srgb`,`astc-10x8-unorm`,`astc-10x8-unorm-srgb`,`astc-10x10-unorm`,`astc-10x10-unorm-srgb`,`astc-12x10-unorm`,`astc-12x10-unorm-srgb`,`astc-12x12-unorm`,`astc-12x12-unorm-srgb`],Vr=[,,`float`,`unfilterable-float`,`depth`,`sint`,`uint`],Hr=[,`1d`,`2d`,`2d-array`,`cube`,`cube-array`,`3d`],Ur={undefined:1,unknown:1,destroyed:2};function Wr(e,t,n,r,i,a){t=Fe(t),n=Fe(n),r>>>=0,i>>>=0,a>>>=0;var o=N(e>>>0);if(e={},a){var s=(C(),O)[a+12>>>2>>>0];if(s){var c=(C(),O)[a+16>>>2>>>0];e.requiredFeatures=Array.from((C(),O).subarray(c>>>2>>>0,c+4*s>>>2>>>0),e=>Pr[e])}if(s=(C(),O)[a+20>>>2>>>0]){let t=function(e,t,n,r=!1){t+=n,(t=(C(),O)[t>>>2>>>0])==4294967295||r&&t==0||(l[e]=t)},n=function(e,t,n){t+=n,n=(C(),O)[t>>>2>>>0];var r=(C(),O)[t+4>>>2>>>0];n==4294967295&&r==4294967295||(l[e]=vr(t))};c=(C(),O)[s>>>2>>>0];var l={};t(`maxTextureDimension1D`,s,4),t(`maxTextureDimension2D`,s,8),t(`maxTextureDimension3D`,s,12),t(`maxTextureArrayLayers`,s,16),t(`maxBindGroups`,s,20),t(`maxBindGroupsPlusVertexBuffers`,s,24),t(`maxBindingsPerBindGroup`,s,28),t(`maxDynamicUniformBuffersPerPipelineLayout`,s,32),t(`maxDynamicStorageBuffersPerPipelineLayout`,s,36),t(`maxSampledTexturesPerShaderStage`,s,40),t(`maxSamplersPerShaderStage`,s,44),t(`maxStorageBuffersPerShaderStage`,s,48),t(`maxStorageTexturesPerShaderStage`,s,52),t(`maxUniformBuffersPerShaderStage`,s,56),t(`minUniformBufferOffsetAlignment`,s,80),t(`minStorageBufferOffsetAlignment`,s,84),n(`maxUniformBufferBindingSize`,s,64),n(`maxStorageBufferBindingSize`,s,72),t(`maxVertexBuffers`,s,88),n(`maxBufferSize`,s,96),t(`maxVertexAttributes`,s,104),t(`maxVertexBufferArrayStride`,s,108),t(`maxInterStageShaderVariables`,s,112),t(`maxColorAttachments`,s,116),t(`maxColorAttachmentBytesPerSample`,s,120),t(`maxComputeWorkgroupStorageSize`,s,124),t(`maxComputeInvocationsPerWorkgroup`,s,128),t(`maxComputeWorkgroupSizeX`,s,132),t(`maxComputeWorkgroupSizeY`,s,136),t(`maxComputeWorkgroupSizeZ`,s,140),t(`maxComputeWorkgroupsPerDimension`,s,144),t(`maxImmediateSize`,s,148,!0),c!==0&&(C(),`maxStorageBuffersInVertexStage`in GPUSupportedLimits.prototype&&(t(`maxStorageBuffersInVertexStage`,c,8),t(`maxStorageTexturesInVertexStage`,c,12),t(`maxStorageBuffersInFragmentStage`,c,16),t(`maxStorageTexturesInFragmentStage`,c,20))),e.requiredLimits=l}(s=(C(),O)[a+24>>>2>>>0])&&(s={label:Dr(s+4)},e.defaultQueue=s),e.label=Dr(a+4)}ye+=1,Cr(t,o.requestDevice(e).then(e=>{--ye,qt(()=>{yr[i>>>0]=e.queue,yr[r>>>0]=e,ye+=1,Cr(n,e.lost.then(t=>{qt(()=>{e.onuncapturederror=()=>{};var r=L(),i=_r(t.message);ca(n,Ur[t.reason],i),I(r)}),--ye})),e.onuncapturederror=e=>{var t=5;e.error instanceof GPUValidationError?t=2:e.error instanceof GPUOutOfMemoryError?t=3:e.error instanceof GPUInternalError&&(t=4);var n=L();e=_r(e.error.message),fa(r,t,e),I(n)},`adapterInfo`in e||(e.adapterInfo=o.info),da(t,1,r,0)})},e=>{--ye,qt(()=>{var i=L(),a=_r(e.message);da(t,3,r,a),n&&ca(n,4,a),I(i)})}))}function Gr(e){var t=N(e>>>=0),n=xr[e];if(n){for(var r=0;r>>=0;var r=N(e>>>=0);n==4294967295&&(n=void 0);try{var i=r.getMappedRange(t>>>0,n)}catch{return 0}var a=ba(16,i.byteLength);return(C(),T).set(new Uint8Array(i),a>>>0),xr[e].push(()=>Ji(a)),a}function qr(e,t,n){n>>>=0;var r=N(e>>>=0);n==4294967295&&(n=void 0);try{var i=r.getMappedRange(t>>>0,n)}catch{return 0}var a=ba(16,i.byteLength);return(C(),T).fill(0,a,i.byteLength),xr[e].push(()=>{new Uint8Array(i).set((C(),T).subarray(a>>>0,a+i.byteLength>>>0)),Ji(a)}),a}function Jr(e,t,n,r,i){e>>>=0,t=Fe(t),n=Fe(n),i>>>=0;var a=N(e);xr[e]=[],i==4294967295&&(i=void 0),ye+=1,Cr(t,a.mapAsync(n,r>>>0,i).then(()=>{--ye,qt(()=>{la(t,1,0)})},n=>{--ye,qt(()=>{L();var r=_r(n.message);la(t,n.name===`AbortError`?4:n.name===`OperationError`?3:0,r),delete xr[e]})}))}function Yr(e){var t=N(e>>>=0),n=xr[e];if(n){for(var r=0;r>>0]}function Zr(e,t,n){e>>>=0,t>>>=0,n>>>=0;var r=!!(C(),O)[t+32>>>2>>>0];t={label:Dr(t+4),usage:(C(),O)[t+16>>>2>>>0],size:vr(t+24),mappedAtCreation:r},e=N(e);try{var i=e.createBuffer(t)}catch{return!1}return yr[n>>>0]=i,r&&(xr[n]=[]),!0}function Qr(e,t,n,r){e>>>=0,t=Fe(t),r>>>=0,n=Or(n>>>0),e=N(e),ye+=1,Cr(t,e.createComputePipelineAsync(n).then(e=>{--ye,qt(()=>{yr[r>>>0]=e,sa(t,1,r,0)})},e=>{--ye,qt(()=>{var n=L(),i=_r(e.message);sa(t,e.reason===`validation`?3:e.reason===`internal`?4:0,r,i),I(n)})}))}function $r(e,t,n){e>>>=0,t>>>=0,n>>>=0;var r=(C(),O)[t>>>2>>>0],i=(C(),D)[r+4>>>2>>>0];t={label:Dr(t+4),code:``},i===2&&(t.code=Er(r+8)),e=N(e).createShaderModule(t),yr[n>>>0]=e}var ei=e=>{(e=N(e)).onuncapturederror=null,e.destroy()};function ti(e,t){t=Fe(t),e=N(e>>>0),ye+=1,Cr(t,e.popErrorScope().then(e=>{--ye,qt(()=>{var n=5;e?e instanceof GPUValidationError?n=2:e instanceof GPUOutOfMemoryError?n=3:e instanceof GPUInternalError&&(n=4):n=1;var r=L(),i=e?_r(e.message):0;ua(t,1,n,i),I(r)})},e=>{--ye,qt(()=>{var n=L(),r=_r(e.message);ua(t,1,5,r),I(n)})}))}function ni(e,t,n,r){if(t=Fe(t),r>>>=0,n>>>=0){var i={featureLevel:Nr[(C(),D)[n+4>>>2>>>0]],powerPreference:Fr[(C(),D)[n+8>>>2>>>0]],forceFallbackAdapter:!!(C(),O)[n+12>>>2>>>0]};(e=(C(),O)[n>>>2>>>0])!==0&&(C(),i.Ye=!!(C(),O)[e+8>>>2>>>0])}`gpu`in navigator?(ye+=1,Cr(t,navigator.gpu.requestAdapter(i).then(e=>{--ye,qt(()=>{if(e)yr[r>>>0]=e,P(t,1,r,0);else{var n=L(),i=_r(`WebGPU not available on this browser (requestAdapter returned null)`);P(t,3,r,i),I(n)}})},e=>{--ye,qt(()=>{var n=L(),i=_r(e.message);P(t,4,r,i),I(n)})}))):(i=L(),e=_r(`WebGPU not available on this browser (navigator.gpu is not available)`),P(t,3,r,e),I(i))}function ri(e,t,n){return e>>>=0,t>>>=0,n>>>=0,gn(async()=>{var r=[];if(n){var i=(C(),D)[n>>>2>>>0];r.length=t+1,r[t]=new Promise(e=>setTimeout(e,i,0))}else r.length=t;for(var a=0;a{if(!ii){var e,t={USER:`web_user`,LOGNAME:`web_user`,PATH:`/`,PWD:`/`,HOME:`/home/web_user`,LANG:(globalThis.navigator?.language??`C`).replace(`-`,`_`)+`.UTF-8`,_:`./this.program`};for(e in ai)ai[e]===void 0?delete t[e]:t[e]=ai[e];var n=[];for(e in t)n.push(`${e}=${t[e]}`);ii=n}return ii};function si(e,t){if(i)return be(19,1,e,t);e>>>=0,t>>>=0;var n,r=0,a=0;for(n of oi()){var o=t+r;(C(),O)[e+a>>>2>>>0]=o,r+=Ft(n,o,1/0)+1,a+=4}return 0}function ci(e,t){if(i)return be(20,1,e,t);e>>>=0,t>>>=0;var n=oi();for(var r of((C(),O)[e>>>2>>>0]=n.length,e=0,n))e+=It(r)+1;return(C(),O)[t>>>2>>>0]=e,0}function li(e){return i?be(21,1,e):52}function ui(e,t,n,r,a){return i?be(22,1,e,t,n,r,a):52}function di(e,t,n,r){return i?be(23,1,e,t,n,r):52}function fi(e,t,n,r){return i?be(24,1,e,t,n,r):70}var pi=[null,[],[]];function mi(e,t,n,r){if(i)return be(25,1,e,t,n,r);t>>>=0,n>>>=0,r>>>=0;for(var a=0,o=0;o>>2>>>0],c=(C(),O)[t+4>>>2>>>0];t+=8;for(var l=0;l>>0],f=pi[u];d===0||d===10?((u===1?y:b)(et(f)),f.length=0):f.push(d)}a+=c}return(C(),O)[r>>>2>>>0]=a,0}function hi(e){return e>>>0}function gi(e,t){return kr(N(e>>>0).limits,t>>>0),1}function _i(e,t){return N(e>>>0).features.has(Pr[t])}function vi(e){return BigInt(N(e>>>0).size)}function yi(e){return BigInt(N(e>>>0).usage)}function bi(e,t){if(e>>>=0,t>>>=0){var n=Dr(t+4);n={label:n,timestampWrites:t=(t=(C(),O)[t+12>>>2>>>0])===0?void 0:{querySet:N((C(),O)[t+4>>>2>>>0]),beginningOfPassWriteIndex:(C(),O)[t+8>>>2>>>0],endOfPassWriteIndex:(C(),O)[t+12>>>2>>>0]}}}return t=N(e),e=ta(0),n=t.beginComputePass(n),yr[e>>>0]=n,e}function xi(e,t,n,r){n=Fe(n),(r=Fe(r))==-1&&(r=void 0),(e=N(e>>>0)).clearBuffer(N(t>>>0),n,r)}function Si(e,t,n,r,i,a){n=Fe(n),i=Fe(i),a=Fe(a),N(e>>>0).copyBufferToBuffer(N(t>>>0),n,N(r>>>0),i,a)}function Ci(e){var t=N(e>>>0);return e=$i(0),t=t.finish(),yr[e>>>0]=t,e}function wi(e,t,n,r,i,a){a=Fe(a),N(e>>>0).resolveQuerySet(N(t>>>0),n,r,N(i>>>0),a)}function Ti(e,t,n,r){N(e>>>0).dispatchWorkgroups(t,n,r)}function Ei(e,t,n){n=Fe(n),N(e>>>0).dispatchWorkgroupsIndirect(N(t>>>0),n)}function Di(e){N(e>>>0).end()}function Oi(e,t,n,r,i){r>>>=0,i>>>=0,e=N(e>>>0),n=N(n>>>0),r==0?e.setBindGroup(t,n):e.setBindGroup(t,n,(C(),O),i>>>2,r)}function ki(e,t){N(e>>>0).setPipeline(N(t>>>0))}function Ai(e,t,n){N(e>>>0).Xe(N(t>>>0),n)}function ji(e,t){function n(e){var t=(C(),O)[e+8>>>2>>>0],n=(C(),O)[e+32>>>2>>>0],r=(C(),O)[e+36>>>2>>>0],i=0;return wr(e,{14:e=>{i=(C(),O)[e+8>>>2>>>0]}}),t?((n=vr(e+24))==-1&&(n=void 0),t={buffer:N(t),offset:vr(e+16),size:n}):t=N(n||r||i),{binding:(C(),O)[e+4>>>2>>>0],resource:t}}e>>>=0,t={label:Dr((t>>>=0)+4),layout:N((C(),O)[t+12>>>2>>>0]),entries:(function(e,t){for(var r=[],i=0;i>>2>>>0],(C(),O)[t+20>>>2>>>0])},e=N(e);var r=Zi(0);return br(r,e.createBindGroup(t)),r}function Mi(e,t){function n(e){var t=(C(),O)[e+4>>>2>>>0];if(t)return{type:jr[t],hasDynamicOffset:!!(C(),O)[e+8>>>2>>>0],minBindingSize:vr(e+16)}}function r(e){if(e=(C(),O)[e+4>>>2>>>0])return{type:Lr[e]}}function i(e){var t=(C(),O)[e+4>>>2>>>0];if(t)return{sampleType:Vr[t],viewDimension:Hr[(C(),D)[e+8>>>2>>>0]],multisampled:!!(C(),O)[e+12>>>2>>>0]}}function a(e){var t=(C(),O)[e+4>>>2>>>0];if(t)return{access:Rr[t],format:Br[(C(),D)[e+8>>>2>>>0]],viewDimension:Hr[(C(),D)[e+12>>>2>>>0]]}}function o(e){var t={binding:(C(),O)[e+4>>>2>>>0],visibility:(C(),O)[e+8>>>2>>>0],buffer:n(e+24),sampler:r(e+48),texture:i(e+56),storageTexture:a(e+72)};return wr(e,{13:()=>{t.externalTexture={}}}),t}e>>>=0,t={label:Dr((t>>>=0)+4),entries:(function(e,t){for(var n=[],r=0;r>>2>>>0],(C(),O)[t+16>>>2>>>0])},e=N(e);var s=Qi(0);return br(s,e.createBindGroupLayout(t)),s}function Ni(e,t){var n;return e>>>=0,(t>>>=0)&&(n={label:Dr(t+4)}),t=N(e),e=ea(0),n=t.createCommandEncoder(n),yr[e>>>0]=n,e}function Pi(e,t){e>>>=0,t>>>=0;for(var n=(C(),O)[t+12>>>2>>>0],r=(C(),O)[t+16>>>2>>>0],i=[],a=0;a>>2>>>0]));return t={label:Dr(t+4),bindGroupLayouts:i,immediateSize:(C(),O)[t+20>>>2>>>0]},n=N(e),e=na(0),t=n.createPipelineLayout(t),yr[e>>>0]=t,e}function Fi(e,t){e>>>=0,t>>>=0,t={type:Ir[(C(),D)[t+12>>>2>>>0]],count:(C(),O)[t+16>>>2>>>0]};var n=N(e);return e=ra(0),t=n.createQuerySet(t),yr[e>>>0]=t,e}function Ii(e,t){return Ar(N(e>>>0).adapterInfo,t>>>0),1}var Li={"core-features-and-limits":1,"depth-clip-control":2,"depth32float-stencil8":3,"texture-compression-bc":4,"texture-compression-bc-sliced-3d":5,"texture-compression-etc2":6,"texture-compression-astc":7,"texture-compression-astc-sliced-3d":8,"timestamp-query":9,"indirect-first-instance":10,"shader-f16":11,"rg11b10ufloat-renderable":12,"bgra8unorm-storage":13,"float32-filterable":14,"float32-blendable":15,"clip-distances":16,"dual-source-blending":17,subgroups:18,"texture-formats-tier1":19,"texture-formats-tier2":20,"primitive-index":21,"texture-component-swizzle":22,"subgroup-size-control":23,"chromium-experimental-unorm16-texture-formats":327692,"chromium-experimental-multi-draw-indirect":327729,"chromium-experimental-subgroup-matrix":327732};function Ri(e,t){t>>>=0;var n=N(e>>>0);e=Yi(4*n.features.size);var r=0,i=0;for(let t of n.features)0<=(n=Li[t])&&((C(),D)[e+r>>>2>>>0]=n,r+=4,i++);(C(),O)[t+4>>>2>>>0]=e,(C(),O)[t>>>2>>>0]=i}function zi(e,t){return kr(N(e>>>0).limits,t>>>0),1}function Bi(e,t){N(e>>>0).pushErrorScope(Mr[t])}function Vi(e,t,n){t>>>=0,n>>>=0,e=N(e>>>0),t=Array.from((C(),D).subarray(n>>>2>>>0,n+4*t>>>2>>>0),e=>N(e)),e.submit(t)}function Hi(e,t,n,r,i){n=Fe(n),r>>>=0,i>>>=0,e=N(e>>>0),t=N(t>>>0),r=(C(),T).subarray(r>>>0,r+i>>>0),e.writeBuffer(t,n,r,0,i)}i||(function(){for(var e=t.numThreads-1;e--;)Ae();he.push(async()=>{var e=(async function(){if(!i)return Promise.all(Ce.map(ke))})();ge++,await e,--ge==0&&_e&&(e=_e,_e=null,e())})})(),i||(je=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0}),ce()),t.wasmBinary&&(d=t.wasmBinary),t.stackSave=()=>L(),t.stackRestore=e=>I(e),t.stackAlloc=e=>Ca(e),t.setValue=function(e,t,n=`i8`){switch(n.endsWith(`*`)&&(n=`*`),n){case`i1`:case`i8`:(C(),w)[e>>>0]=t;break;case`i16`:(C(),E)[e>>>1>>>0]=t;break;case`i32`:(C(),D)[e>>>2>>>0]=t;break;case`i64`:(C(),ie)[e>>>3>>>0]=BigInt(t);break;case`float`:(C(),ne)[e>>>2>>>0]=t;break;case`double`:(C(),re)[e>>>3>>>0]=t;break;case`*`:(C(),O)[e>>>2>>>0]=t;break;default:ue(`invalid type for setValue: ${n}`)}},t.getValue=function(e,t=`i8`){switch(t.endsWith(`*`)&&(t=`*`),t){case`i1`:case`i8`:return(C(),w)[e>>>0];case`i16`:return(C(),E)[e>>>1>>>0];case`i32`:return(C(),D)[e>>>2>>>0];case`i64`:return(C(),ie)[e>>>3>>>0];case`float`:return(C(),ne)[e>>>2>>>0];case`double`:return(C(),re)[e>>>3>>>0];case`*`:return(C(),O)[e>>>2>>>0];default:ue(`invalid type for getValue: ${t}`)}},t.UTF8ToString=tt,t.stringToUTF8=Ft,t.lengthBytesUTF8=It;var Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra,ia,aa,oa,sa,ca,la,ua,P,da,fa,pa,ma,ha,ga,_a,va,ya,ba,F,xa,Sa,I,Ca,L,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,R,to,no,ro,io,ao,oo,so,co,z,lo,uo,fo,po,mo,ho,go,_o=[xe,k,Ye,nt,rt,it,at,ot,st,ct,lt,ut,dt,ft,pt,mt,Wn,Gn,Jn,si,ci,li,ui,di,fi,mi],vo={1280444:(e,n,r,i,a)=>{if(t===void 0||!t.ed)return 1;if((e=tt(Number(e>>>0))).startsWith(`./`)&&(e=e.substring(2)),!(e=t.ed.get(e)))return 2;if(n=Number(n>>>0),r=Number(r>>>0),i=Number(i>>>0),n+r>e.byteLength)return 3;try{let o=e.subarray(n,n+r);switch(a){case 0:(C(),T).set(o,i>>>0);break;case 1:t.pe?t.pe(i,o):t.Re(i,o);break;default:return 4}return 0}catch{return 4}},1281268:(e,n,r)=>{t.re(e,(C(),T).subarray(n>>>0,n+r>>>0))},1281332:()=>t.Pe(),1281374:e=>{t.qe(e)},1281411:()=>typeof wasmOffsetConverter<`u`};function yo(){return typeof wasmOffsetConverter<`u`}function bo(e,t,n,r){var i=L();try{return La(e,t,n,r)}catch(e){if(I(i),e!==e+0)throw e;F(1,0)}}function xo(e,t,n){var r=L();try{return Pa(e,t,n)}catch(e){if(I(r),e!==e+0)throw e;F(1,0)}}function B(e){var t=L();try{Aa(e)}catch(e){if(I(t),e!==e+0)throw e;F(1,0)}}function So(e,t){var n=L();try{return ka(e,t)}catch(e){if(I(n),e!==e+0)throw e;F(1,0)}}function Co(e,t,n){var r=L();try{Oa(e,t,n)}catch(e){if(I(r),e!==e+0)throw e;F(1,0)}}function wo(e,t){var n=L();try{Ra(e,t)}catch(e){if(I(n),e!==e+0)throw e;F(1,0)}}function To(e,t,n,r,i,a,o){var s=L();try{return Na(e,t,n,r,i,a,o)}catch(e){if(I(s),e!==e+0)throw e;F(1,0)}}function Eo(e,t,n,r,i,a){var o=L();try{ja(e,t,n,r,i,a)}catch(e){if(I(o),e!==e+0)throw e;F(1,0)}}function Do(e,t,n,r){var i=L();try{Ia(e,t,n,r)}catch(e){if(I(i),e!==e+0)throw e;F(1,0)}}function Oo(e,t,n,r,i,a,o){var s=L();try{Ba(e,t,n,r,i,a,o)}catch(e){if(I(s),e!==e+0)throw e;F(1,0)}}function ko(e,t,n,r,i,a,o){var s=L();try{Va(e,t,n,r,i,a,o)}catch(e){if(I(s),e!==e+0)throw e;F(1,0)}}function Ao(e,t,n,r,i,a,o,s){var c=L();try{Za(e,t,n,r,i,a,o,s)}catch(e){if(I(c),e!==e+0)throw e;F(1,0)}}function jo(e,t,n,r,i,a,o,s,c,l,u,d){var f=L();try{Ha(e,t,n,r,i,a,o,s,c,l,u,d)}catch(e){if(I(f),e!==e+0)throw e;F(1,0)}}function Mo(e,t,n,r,i){var a=L();try{return za(e,t,n,r,i)}catch(e){if(I(a),e!==e+0)throw e;F(1,0)}}function No(e,t,n,r,i,a){var o=L();try{Qa(e,t,n,r,i,a)}catch(e){if(I(o),e!==e+0)throw e;F(1,0)}}function Po(e,t,n,r,i){var a=L();try{Ma(e,t,n,r,i)}catch(e){if(I(a),e!==e+0)throw e;F(1,0)}}function Fo(e,t,n,r,i,a,o,s){var c=L();try{Fa(e,t,n,r,i,a,o,s)}catch(e){if(I(c),e!==e+0)throw e;F(1,0)}}function Io(e){var t=L();try{return $a(e)}catch(e){if(I(t),e!==e+0)throw e;F(1,0)}}function Lo(e,t,n,r,i,a,o,s,c){var l=L();try{Wa(e,t,n,r,i,a,o,s,c)}catch(e){if(I(l),e!==e+0)throw e;F(1,0)}}function Ro(e,t,n){var r=L();try{return eo(e,t,n)}catch(e){if(I(r),e!==e+0)throw e;F(1,0)}}function zo(e,t){var n=L();try{return uo(e,t)}catch(e){if(I(n),e!==e+0)throw e;return F(1,0),0n}}function Bo(e,t,n,r){var i=L();try{return R(e,t,n,r)}catch(e){if(I(i),e!==e+0)throw e;F(1,0)}}function Vo(e){var t=L();try{return Ua(e)}catch(e){if(I(t),e!==e+0)throw e;return F(1,0),0n}}function Ho(e,t,n,r){var i=L();try{return to(e,t,n,r)}catch(e){if(I(i),e!==e+0)throw e;F(1,0)}}function V(e,t,n,r,i){var a=L();try{return no(e,t,n,r,i)}catch(e){if(I(a),e!==e+0)throw e;F(1,0)}}function Uo(e,t,n,r,i,a){var o=L();try{return ro(e,t,n,r,i,a)}catch(e){if(I(o),e!==e+0)throw e;F(1,0)}}function Wo(e,t,n,r,i,a){var o=L();try{return Ya(e,t,n,r,i,a)}catch(e){if(I(o),e!==e+0)throw e;F(1,0)}}function Go(e,t,n,r,i,a){var o=L();try{return io(e,t,n,r,i,a)}catch(e){if(I(o),e!==e+0)throw e;F(1,0)}}function Ko(e,t,n,r,i,a,o,s){var c=L();try{return Xa(e,t,n,r,i,a,o,s)}catch(e){if(I(c),e!==e+0)throw e;F(1,0)}}function qo(e,t,n,r,i){var a=L();try{return ao(e,t,n,r,i)}catch(e){if(I(a),e!==e+0)throw e;return F(1,0),0n}}function Jo(e,t,n,r){var i=L();try{return oo(e,t,n,r)}catch(e){if(I(i),e!==e+0)throw e;F(1,0)}}function Yo(e,t,n,r){var i=L();try{return so(e,t,n,r)}catch(e){if(I(i),e!==e+0)throw e;F(1,0)}}function Xo(e,t,n,r,i,a,o,s,c,l,u,d){var f=L();try{return co(e,t,n,r,i,a,o,s,c,l,u,d)}catch(e){if(I(f),e!==e+0)throw e;F(1,0)}}function Zo(e,t,n,r,i,a,o,s,c,l,u){var d=L();try{z(e,t,n,r,i,a,o,s,c,l,u)}catch(e){if(I(d),e!==e+0)throw e;F(1,0)}}function Qo(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){var g=L();try{lo(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}catch(e){if(I(g),e!==e+0)throw e;F(1,0)}}function $o(e,t,n){var r=L();try{return Ka(e,t,n)}catch(e){if(I(r),e!==e+0)throw e;return F(1,0),0n}}function es(e,t,n){var r=L();try{return Ga(e,t,n)}catch(e){if(I(r),e!==e+0)throw e;F(1,0)}}function ts(e,t,n){var r=L();try{return qa(e,t,n)}catch(e){if(I(r),e!==e+0)throw e;F(1,0)}}function ns(e,t,n,r){var i=L();try{Ja(e,t,n,r)}catch(e){if(I(i),e!==e+0)throw e;F(1,0)}}function rs(){if(0{let n=new WeakMap,r,i,a=1;t.webgpuRegisterDevice=e=>{if(i!==void 0)throw Error(`another WebGPU EP inference session is being created.`);if(e){var t=n.get(e);if(!t){let r=((e,t=0)=>{var n=oa(t);return t=aa(t,n),yr[n>>>0]=e.queue,yr[t>>>0]=e,t})(e,t=Gi());t=[a++,t,r],n.set(e,t)}return r=e,i=t[0],t}r=void 0,i=0};let o=new Map;t.webgpuOnCreateSession=t=>{if(i!==void 0){var n=i;if(i=void 0,t){let i=Ki(n);o.set(t,i),n===0&&e(r??N(i))}r=void 0}},t.webgpuOnReleaseSession=e=>{o.delete(e)};let s=Symbol(`gpuBufferMetadata`);t.webgpuRegisterBuffer=(e,t,n)=>{if(n)return e[s]=[n,NaN],n;if(n=e[s])return n[1]++,n[0];if((t=o.get(t))===void 0)throw Error(`Invalid session handle passed to webgpuRegisterBuffer`);return t=((e,t=0)=>(e.mapState===`unmapped`||ue(),t=ia(t),yr[t>>>0]=e,t))(e,t),e[s]=[t,1],t},t.webgpuUnregisterBuffer=e=>{let t=e[s];if(!t)throw Error(`Buffer is not registered`);t[1]--,t[1]===0&&(Xi(t[0]),delete e[s])},t.webgpuGetBuffer=e=>N(e),t.webgpuCreateDownloader=(e,t,n)=>{if((n=o.get(n))===void 0)throw Error(`Invalid session handle passed to webgpuRegisterBuffer`);let r=N(n),i=16*Math.ceil(Number(t)/16);return async()=>{let n=r.createBuffer({size:i,usage:9});try{let a=r.createCommandEncoder();return a.copyBufferToBuffer(e,0,n,0,i),r.queue.submit([a.finish()]),await n.mapAsync(GPUMapMode.READ),n.getMappedRange().slice(0,t)}finally{n.destroy()}}},t.pe=(e,t)=>{var n=t.buffer;let a=t.byteOffset,o=t.byteLength;if(t=16*Math.ceil(Number(o)/16),e=N(e),!r){var s=Ki(i);r=N(s)}let c=(s=r.createBuffer({mappedAtCreation:!0,size:t,usage:6})).getMappedRange();new Uint8Array(c).set(new Uint8Array(n,a,o)),s.unmap(),(n=r.createCommandEncoder()).copyBufferToBuffer(s,0,e,0,t),r.queue.submit([n.finish()]),s.destroy()}},t.webnnInit=e=>{let n=e[0];[t.Pe,t.qe,t.webnnEnsureTensor,t.re,t.webnnDownloadTensor,t.Oe,t.webnnEnableTraceEvent]=e.slice(1),t.webnnReleaseTensorId=t.qe,t.webnnUploadTensor=t.re,t.webnnRegisterMLContext=t.Oe,t.webnnOnRunStart=e=>n.onRunStart(e),t.webnnOnRunEnd=n.onRunEnd.bind(n),t.webnnOnReleaseSession=e=>{n.onReleaseSession(e)},t.webnnCreateMLTensorDownloader=(e,t)=>n.createMLTensorDownloader(e,t),t.webnnRegisterMLTensor=(e,t,r,i)=>n.registerMLTensor(e,t,r,i),t.webnnCreateMLContext=e=>n.createMLContext(e),t.webnnRegisterGraphInput=n.registerGraphInput.bind(n),t.webnnIsGraphInput=n.isGraphInput.bind(n),t.webnnRegisterGraphOutput=n.registerGraphOutput.bind(n),t.webnnIsGraphOutput=n.isGraphOutput.bind(n),t.webnnCreateTemporaryTensor=n.createTemporaryTensor.bind(n),t.webnnIsGraphInputOutputTypeSupported=n.isGraphInputOutputTypeSupported.bind(n)},se?t:new Promise((e,t)=>{m=e,h=t})}var rr,ir,ar=M(()=>{rr=nr,ir=globalThis.self?.name?.startsWith(`em-pthread`),ir&&nr()}),or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br=M(()=>{Yn(),or=typeof location>`u`?void 0:location.origin,sr=import.meta.url>`file:`&&import.meta.url<`file;`,cr=()=>sr?new URL(new URL(`ort.webgpu.bundle.min.mjs`,import.meta.url).href,or).href:import.meta.url,lr=cr(),ur=()=>{if(lr&&!lr.startsWith(`blob:`))return lr.substring(0,lr.lastIndexOf(`/`)+1)},dr=(e,t)=>{try{let n=t??lr;return(n?new URL(e,n):new URL(e)).origin===or}catch{return!1}},fr=(e,t)=>{let n=t??lr;try{return(n?new URL(e,n):new URL(e)).href}catch{return}},pr=(e,t)=>`${t??`./`}${e}`,mr=async e=>{let t=await(await fetch(e,{credentials:`same-origin`})).blob();return URL.createObjectURL(t)},hr=async e=>(await zt(async()=>{let{default:t}=await import(e);return{default:t}},[])).default,gr=(er(),Jt(Xn)).default,_r=async()=>{if(!lr)throw Error(`Failed to load proxy worker: cannot determine the script source URL.`);if(dr(lr))return[void 0,gr()];let e=await mr(lr);return[e,gr(e)]},vr=(ar(),Jt(tr)).default,yr=async(e,t,n,r)=>{let i=vr&&!(e||t);if(i){if(lr)i=dr(lr)||r&&!n;else if(r&&!n)i=!0;else throw Error(`cannot determine the script source URL.`)}if(i)return[void 0,vr];{let r=`ort-wasm-simd-threaded.asyncify.mjs`,i=e??fr(r,t),a=n&&i&&!dr(i,t),o=a?await mr(i):i??pr(r,t);return[a?o:void 0,await hr(o)]}}}),xr,Sr,Cr,N,wr,Tr,Er,Dr,Or,kr=M(()=>{br(),Sr=!1,Cr=!1,N=!1,wr=()=>{if(typeof SharedArrayBuffer>`u`)return!1;try{return typeof MessageChannel<`u`&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},Tr=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},Er=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},Dr=async e=>{if(Sr)return Promise.resolve();if(Cr)throw Error(`multiple calls to 'initializeWebAssembly()' detected.`);if(N)throw Error(`previous call to 'initializeWebAssembly()' failed.`);Cr=!0;let t=e.initTimeout,n=e.numThreads;if(e.simd!==!1){if(e.simd===`relaxed`){if(!Er())throw Error(`Relaxed WebAssembly SIMD is not supported in the current environment.`)}else if(!Tr())throw Error(`WebAssembly SIMD is not supported in the current environment.`)}let r=wr();n>1&&!r&&(typeof self<`u`&&!self.crossOriginIsolated&&console.warn(`env.wasm.numThreads is set to `+n+`, but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info.`),console.warn(`WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading.`),e.numThreads=n=1);let i=e.wasmPaths,a=typeof i==`string`?i:void 0,o=i?.mjs,s=o?.href??o,c=i?.wasm,l=c?.href??c,u=e.wasmBinary,[d,f]=await yr(s,a,n>1,!!u||!!l),p=!1,m=[];if(t>0&&m.push(new Promise(e=>{setTimeout(()=>{p=!0,e()},t)})),m.push(new Promise((e,t)=>{let r={numThreads:n};if(u)r.wasmBinary=u,r.locateFile=e=>e;else if(l||a)r.locateFile=e=>l??a+e;else if(s&&s.indexOf(`blob:`)!==0)r.locateFile=e=>new URL(e,s).href;else if(d){let e=ur();e&&(r.locateFile=t=>e+t)}f(r).then(t=>{Cr=!1,Sr=!0,xr=t,e(),d&&URL.revokeObjectURL(d)},e=>{Cr=!1,N=!0,t(e)})})),await Promise.race(m),p)throw Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},Or=()=>{if(Sr&&xr)return xr;throw Error(`WebAssembly is not initialized yet.`)}}),Ar,jr,Mr,Nr=M(()=>{kr(),Ar=(e,t)=>{let n=Or(),r=n.lengthBytesUTF8(e)+1,i=n._malloc(r);return n.stringToUTF8(e,i,r),t.push(i),i},jr=(e,t,n,r)=>{if(typeof e==`object`&&e){if(n.has(e))throw Error(`Circular reference in options`);n.add(e)}Object.entries(e).forEach(([e,i])=>{let a=t?t+e:e;if(typeof i==`object`)jr(i,a+`.`,n,r);else if(typeof i==`string`||typeof i==`number`)r(a,i.toString());else if(typeof i==`boolean`)r(a,i?`1`:`0`);else throw Error(`Can't handle extra config type: ${typeof i}`)})},Mr=e=>{let t=Or(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetLastError(r,r+n);let i=Number(t.getValue(r,n===4?`i32`:`i64`)),a=t.getValue(r+n,`*`),o=a?t.UTF8ToString(a):``;throw Error(`${e} ERROR_CODE: ${i}, ERROR_MESSAGE: ${o}`)}finally{t.stackRestore(n)}}}),Pr,Fr=M(()=>{kr(),Nr(),Pr=e=>{let t=Or(),n=0,r=[],i=e||{};try{if(e?.logSeverityLevel===void 0)i.logSeverityLevel=2;else if(typeof e.logSeverityLevel!=`number`||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw Error(`log severity level is not valid: ${e.logSeverityLevel}`);if(e?.logVerbosityLevel===void 0)i.logVerbosityLevel=0;else if(typeof e.logVerbosityLevel!=`number`||!Number.isInteger(e.logVerbosityLevel))throw Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);e?.terminate===void 0&&(i.terminate=!1);let a=0;return e?.tag!==void 0&&(a=Ar(e.tag,r)),n=t._OrtCreateRunOptions(i.logSeverityLevel,i.logVerbosityLevel,!!i.terminate,a),n===0&&Mr(`Can't create run options.`),e?.extra!==void 0&&jr(e.extra,``,new WeakSet,(e,i)=>{let a=Ar(e,r),o=Ar(i,r);t._OrtAddRunConfigEntry(n,a,o)!==0&&Mr(`Can't set a run config entry: ${e} - ${i}.`)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseRunOptions(n),r.forEach(e=>t._free(e)),e}}}),Ir,Lr,Rr,zr,Br,Vr,Hr,Ur=M(()=>{kr(),Nr(),Ir=e=>{switch(e){case`disabled`:return 0;case`basic`:return 1;case`extended`:return 2;case`layout`:return 3;case`all`:return 99;default:throw Error(`unsupported graph optimization level: ${e}`)}},Lr=e=>{switch(e){case`sequential`:return 0;case`parallel`:return 1;default:throw Error(`unsupported execution mode: ${e}`)}},Rr=e=>{e.extra||={},e.extra.session||(e.extra.session={});let t=e.extra.session;t.use_ort_model_bytes_directly||=`1`,e.executionProviders&&e.executionProviders.some(e=>(typeof e==`string`?e:e.name)===`webgpu`)&&(e.enableMemPattern=!1)},zr=(e,t,n,r)=>{let i=Ar(t,r),a=Ar(n,r);Or()._OrtAddSessionConfigEntry(e,i,a)!==0&&Mr(`Can't set a session config entry: ${t} - ${n}.`)},Br=(e,t,n,r)=>{let i=Ar(t,r),a=Ar(n,r);e.push([i,a])},Vr=async(e,t,n)=>{let r=t.executionProviders;for(let i of r){let r=typeof i==`string`?i:i.name,a=[];switch(r){case`webnn`:if(r=`WEBNN`,zr(e,`session.disable_quant_qdq`,`1`,n),zr(e,`session.disable_qdq_constant_folding`,`1`,n),typeof i!=`string`){let t=i?.deviceType;t&&zr(e,`deviceType`,t,n)}break;case`webgpu`:{r=`WebGPU`;let e;if(typeof i!=`string`){let r=i;if(r.device){if(typeof GPUDevice<`u`&&r.device instanceof GPUDevice)e=r.device;else throw Error(`Invalid GPU device set in WebGPU EP options.`)}let{enableGraphCapture:o}=t;if(typeof o==`boolean`&&o&&Br(a,`enableGraphCapture`,`1`,n),typeof r.preferredLayout==`string`&&Br(a,`preferredLayout`,r.preferredLayout,n),r.forceCpuNodeNames){let e=Array.isArray(r.forceCpuNodeNames)?r.forceCpuNodeNames:[r.forceCpuNodeNames];Br(a,`forceCpuNodeNames`,e.join(` +`),n)}r.validationMode&&Br(a,`validationMode`,r.validationMode,n),typeof r.enableMatmulFp32Accumulation==`boolean`&&Br(a,`enableMatmulFp32Accumulation`,r.enableMatmulFp32Accumulation?`1`:`0`,n);for(let e of[`storageBufferCacheMode`,`uniformBufferCacheMode`,`queryResolveBufferCacheMode`,`defaultBufferCacheMode`]){let t=r[e];if(t){if(t!==`disabled`&&t!==`lazyRelease`&&t!==`simple`&&t!==`bucket`)throw Error(`${e} must be one of 'disabled', 'lazyRelease', 'simple' or 'bucket': ${t}`);Br(a,e,t,n)}}}let o=Or().webgpuRegisterDevice(e);if(o){let[e,t,r]=o;Br(a,`deviceId`,e.toString(),n),Br(a,`webgpuInstance`,t.toString(),n),Br(a,`webgpuDevice`,r.toString(),n)}}break;case`wasm`:case`cpu`:continue;default:throw Error(`not supported execution provider: ${r}`)}let o=Ar(r,n),s=a.length,c=0,l=0;if(s>0){c=Or()._malloc(s*Or().PTR_SIZE),n.push(c),l=Or()._malloc(s*Or().PTR_SIZE),n.push(l);for(let e=0;e{let t=Or(),n=0,r=[],i=e||{};Rr(i);try{let e=Ir(i.graphOptimizationLevel??`all`),a=Lr(i.executionMode??`sequential`),o=typeof i.logId==`string`?Ar(i.logId,r):0,s=i.logSeverityLevel??2;if(!Number.isInteger(s)||s<0||s>4)throw Error(`log severity level is not valid: ${s}`);let c=i.logVerbosityLevel??0;if(!Number.isInteger(c)||c<0||c>4)throw Error(`log verbosity level is not valid: ${c}`);let l=typeof i.optimizedModelFilePath==`string`?Ar(i.optimizedModelFilePath,r):0;if(n=t._OrtCreateSessionOptions(e,!!i.enableCpuMemArena,!!i.enableMemPattern,a,!!i.enableProfiling,0,o,s,c,l),n===0&&Mr(`Can't create session options.`),i.executionProviders&&await Vr(n,i,r),i.enableGraphCapture!==void 0){if(typeof i.enableGraphCapture!=`boolean`)throw Error(`enableGraphCapture must be a boolean value: ${i.enableGraphCapture}`);zr(n,`enableGraphCapture`,i.enableGraphCapture.toString(),r)}if(i.freeDimensionOverrides)for(let[e,a]of Object.entries(i.freeDimensionOverrides)){if(typeof e!=`string`)throw Error(`free dimension override name must be a string: ${e}`);if(typeof a!=`number`||!Number.isInteger(a)||a<0)throw Error(`free dimension override value must be a non-negative integer: ${a}`);let i=Ar(e,r);t._OrtAddFreeDimensionOverride(n,i,a)!==0&&Mr(`Can't set a free dimension override: ${e} - ${a}.`)}return i.extra!==void 0&&jr(i.extra,``,new WeakSet,(e,t)=>{zr(n,e,t,r)}),[n,r]}catch(e){throw n!==0&&t._OrtReleaseSessionOptions(n)!==0&&Mr(`Can't release session options.`),r.forEach(e=>t._free(e)),e}}}),Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr=M(()=>{Wr=e=>{switch(e){case`int8`:return 3;case`uint8`:return 2;case`bool`:return 9;case`int16`:return 5;case`uint16`:return 4;case`int32`:return 6;case`uint32`:return 12;case`float16`:return 10;case`float32`:return 1;case`float64`:return 11;case`string`:return 8;case`int64`:return 7;case`uint64`:return 13;case`int4`:return 22;case`uint4`:return 21;default:throw Error(`unsupported data type: ${e}`)}},Gr=e=>{switch(e){case 3:return`int8`;case 2:return`uint8`;case 9:return`bool`;case 5:return`int16`;case 4:return`uint16`;case 6:return`int32`;case 12:return`uint32`;case 10:return`float16`;case 1:return`float32`;case 11:return`float64`;case 8:return`string`;case 7:return`int64`;case 13:return`uint64`;case 22:return`int4`;case 21:return`uint4`;default:throw Error(`unsupported data type: ${e}`)}},Kr=(e,t)=>{let n=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][e],r=typeof t==`number`?t:t.reduce((e,t)=>e*t,1);return n>0?Math.ceil(r*n):void 0},qr=e=>{switch(e){case`float16`:return typeof Float16Array<`u`?Float16Array:Uint16Array;case`float32`:return Float32Array;case`uint8`:return Uint8Array;case`int8`:return Int8Array;case`uint16`:return Uint16Array;case`int16`:return Int16Array;case`int32`:return Int32Array;case`bool`:return Uint8Array;case`float64`:return Float64Array;case`uint32`:return Uint32Array;case`int64`:return BigInt64Array;case`uint64`:return BigUint64Array;default:throw Error(`unsupported type: ${e}`)}},Jr=e=>{switch(e){case`verbose`:return 0;case`info`:return 1;case`warning`:return 2;case`error`:return 3;case`fatal`:return 4;default:throw Error(`unsupported logging level: ${e}`)}},Yr=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,Xr=e=>e===`float32`||e===`float16`||e===`int32`||e===`int64`||e===`uint32`||e===`uint64`||e===`int8`||e===`uint8`||e===`bool`||e===`uint4`||e===`int4`,Zr=e=>{switch(e){case`none`:return 0;case`cpu`:return 1;case`cpu-pinned`:return 2;case`texture`:return 3;case`gpu-buffer`:return 4;case`ml-tensor`:return 5;default:throw Error(`unsupported data location: ${e}`)}}}),$r,ei=M(()=>{Yn(),$r=async e=>{if(typeof e==`string`){let t=await fetch(e);if(!t.ok)throw Error(`failed to load external data file: ${e}`);let n=t.headers.get(`Content-Length`),r=n?parseInt(n,10):0;if(r<1073741824)return new Uint8Array(await t.arrayBuffer());{if(!t.body)throw Error(`failed to load external data file: ${e}, no response body.`);let n=t.body.getReader(),i;try{i=new ArrayBuffer(r)}catch(e){if(e instanceof RangeError){let e=Math.ceil(r/65536);i=new WebAssembly.Memory({initial:e,maximum:e}).buffer}else throw e}let a=0;for(;;){let{done:e,value:t}=await n.read();if(e)break;let r=t.byteLength;new Uint8Array(i,a,r).set(t),a+=r}return new Uint8Array(i,0,r)}}return e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof Uint8Array?e:new Uint8Array(e)}}),ti,ni=M(()=>{Qr(),ti=(e,t)=>new(qr(t))(e)}),ri,ii,ai,oi,si,ci,li,ui=M(()=>{Qr(),ri=[`V`,`I`,`W`,`E`,`F`],ii=(e,t)=>{console.log(`[${ri[e]},${new Date().toISOString()}]${t}`)},si=(e,t)=>{ai=e,oi=t},ci=(e,t)=>{let n=Jr(e);n>=Jr(ai)&&ii(n,typeof t==`function`?t():t)},li=(...e)=>{oi&&ci(...e)}}),di,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si=M(()=>{Qr(),ui(),di=new Map([[`float32`,32],[`float16`,16],[`int32`,32],[`uint32`,32],[`int64`,64],[`uint64`,64],[`int8`,8],[`uint8`,8],[`int4`,4],[`uint4`,4]]),fi=(e,t)=>{if(t===`int32`)return e;let n=di.get(t);if(!n)throw Error(`WebNN backend does not support data type: ${t}`);let r=n/8;if(e.byteLength%r!==0)throw Error(`Invalid Uint8Array length - must be a multiple of ${r}.`);let i=e.byteLength/r,a=new(qr(t))(e.buffer,e.byteOffset,i);switch(t){case`int64`:case`uint64`:{let e=new Int32Array(i);for(let t=0;t2147483647n||n<-2147483648n)throw Error(`Can not convert int64 data to int32 - value out of range.`);e[t]=Number(n)}return new Uint8Array(e.buffer)}case`int8`:case`uint8`:case`uint32`:{if(t===`uint32`&&a.some(e=>e>2147483647))throw Error(`Can not convert uint32 data to int32 - value out of range.`);let e=Int32Array.from(a,Number);return new Uint8Array(e.buffer)}default:throw Error(`Unsupported data conversion from ${t} to 'int32'`)}},pi=(e,t)=>{if(t===`int32`)return e;if(e.byteLength%4!=0)throw Error(`Invalid Uint8Array length - must be a multiple of 4 (int32).`);let n=e.byteLength/4,r=new Int32Array(e.buffer,e.byteOffset,n);switch(t){case`int64`:{let e=BigInt64Array.from(r,BigInt);return new Uint8Array(e.buffer)}case`uint64`:{if(r.some(e=>e<0))throw Error(`Can not convert int32 data to uin64 - negative value found.`);let e=BigUint64Array.from(r,BigInt);return new Uint8Array(e.buffer)}case`int8`:{if(r.some(e=>e<-128||e>127))throw Error(`Can not convert int32 data to int8 - value out of range.`);let e=Int8Array.from(r,Number);return new Uint8Array(e.buffer)}case`uint8`:if(r.some(e=>e<0||e>255))throw Error(`Can not convert int32 data to uint8 - value out of range.`);return Uint8Array.from(r,Number);case`uint32`:{if(r.some(e=>e<0))throw Error(`Can not convert int32 data to uint32 - negative value found.`);let e=Uint32Array.from(r,Number);return new Uint8Array(e.buffer)}default:throw Error(`Unsupported data conversion from 'int32' to ${t}`)}},mi=1,hi=()=>mi++,gi=new Map([[`int8`,`int32`],[`uint8`,`int32`],[`uint32`,`int32`],[`int64`,`int32`]]),_i=(e,t)=>{let n=di.get(e);if(!n)throw Error(`WebNN backend does not support data type: ${e}`);return t.length>0?Math.ceil(t.reduce((e,t)=>e*t)*n/8):0},vi=class{constructor(e){this.isDataConverted=!1;let{sessionId:t,context:n,tensor:r,dataType:i,shape:a,fallbackDataType:o}=e;this.sessionId=t,this.mlContext=n,this.mlTensor=r,this.dataType=i,this.tensorShape=a,this.fallbackDataType=o}get tensor(){return this.mlTensor}get type(){return this.dataType}get fallbackType(){return this.fallbackDataType}get shape(){return this.tensorShape}get byteLength(){return _i(this.dataType,this.tensorShape)}destroy(){li(`verbose`,()=>`[WebNN] TensorWrapper.destroy`),this.mlTensor.destroy()}write(e){this.mlContext.writeTensor(this.mlTensor,e)}async read(e){if(this.fallbackDataType){let t=await this.mlContext.readTensor(this.mlTensor),n=pi(new Uint8Array(t),this.dataType);if(e){(e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).set(n);return}return new Uint8Array(n).buffer}return e?this.mlContext.readTensor(this.mlTensor,e):this.mlContext.readTensor(this.mlTensor)}canReuseTensor(e,t,n){return this.mlContext===e&&this.dataType===t&&this.tensorShape.length===n.length&&this.tensorShape.every((e,t)=>e===n[t])}setIsDataConverted(e){this.isDataConverted=e}},yi=class{constructor(e,t){this.tensorManager=e,this.wrapper=t}get tensorWrapper(){return this.wrapper}releaseTensor(){this.tensorWrapper&&(this.tensorManager.releaseTensor(this.tensorWrapper),this.wrapper=void 0)}async ensureTensor(e,t,n,r){let i=this.tensorManager.getMLContext(e),a=this.tensorManager.getMLOpSupportLimits(e),o;if(!a?.input.dataTypes.includes(t)){if(o=gi.get(t),!o||!a?.input.dataTypes.includes(o))throw Error(`WebNN backend does not support data type: ${t}`);li(`verbose`,()=>`[WebNN] TensorIdTracker.ensureTensor: fallback dataType from ${t} to ${o}`)}if(this.wrapper){if(this.wrapper.canReuseTensor(i,t,n))return this.wrapper.tensor;if(r){if(this.wrapper.byteLength!==_i(t,n))throw Error(`Unable to copy data to tensor with different size.`);this.activeUpload=new Uint8Array(await this.wrapper.read())}this.tensorManager.releaseTensor(this.wrapper)}let s=typeof MLTensorUsage>`u`?void 0:MLTensorUsage.READ|MLTensorUsage.WRITE;return this.wrapper=await this.tensorManager.getCachedTensor(e,t,n,s,!0,!0,o),r&&this.activeUpload&&(this.wrapper.write(this.activeUpload),this.activeUpload=void 0),this.wrapper.tensor}upload(e){let t=e;if(this.wrapper){if(this.wrapper.fallbackType){if(this.wrapper.fallbackType===`int32`)t=fi(e,this.wrapper.type),this.wrapper.setIsDataConverted(!0);else throw Error(`Unsupported fallback data type: ${this.wrapper.fallbackType}`)}if(e.byteLength===this.wrapper.byteLength){this.wrapper.write(t);return}li(`verbose`,()=>`Data size does not match tensor size. Releasing tensor.`),this.releaseTensor()}this.activeUpload?this.activeUpload.set(t):this.activeUpload=new Uint8Array(t)}async download(e){if(this.activeUpload){let t=this.wrapper?.isDataConverted?pi(this.activeUpload,this.wrapper?.type):this.activeUpload;if(e){e instanceof ArrayBuffer?new Uint8Array(e).set(t):new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t);return}return t.buffer}if(!this.wrapper)throw Error(`Tensor has not been created.`);return e?this.wrapper.read(e):this.wrapper.read()}},bi=class{constructor(e){this.backend=e,this.tensorTrackersById=new Map,this.freeTensors=[],this.externalTensors=new Set}getMLContext(e){let t=this.backend.getMLContext(e);if(!t)throw Error(`MLContext not found for session.`);return t}getMLOpSupportLimits(e){return this.backend.getMLOpSupportLimits(e)}reserveTensorId(){let e=hi();return this.tensorTrackersById.set(e,new yi(this)),e}releaseTensorId(e){let t=this.tensorTrackersById.get(e);t&&(this.tensorTrackersById.delete(e),t.tensorWrapper&&this.releaseTensor(t.tensorWrapper))}async ensureTensor(e,t,n,r,i){li(`verbose`,()=>`[WebNN] TensorManager.ensureTensor {tensorId: ${t}, dataType: ${n}, shape: ${r}, copyOld: ${i}}`);let a=this.tensorTrackersById.get(t);if(!a)throw Error(`Tensor not found.`);return a.ensureTensor(e,n,r,i)}upload(e,t){let n=this.tensorTrackersById.get(e);if(!n)throw Error(`Tensor not found.`);n.upload(t)}async download(e,t){li(`verbose`,()=>`[WebNN] TensorManager.download {tensorId: ${e}, dstBuffer: ${t?.byteLength}}`);let n=this.tensorTrackersById.get(e);if(!n)throw Error(`Tensor not found.`);return n.download(t)}releaseTensorsForSession(e){for(let t of this.freeTensors)t.sessionId===e&&t.destroy();this.freeTensors=this.freeTensors.filter(t=>t.sessionId!==e)}registerTensor(e,t,n,r){let i=this.getMLContext(e),a=hi(),o=new vi({sessionId:e,context:i,tensor:t,dataType:n,shape:r});return this.tensorTrackersById.set(a,new yi(this,o)),this.externalTensors.add(o),a}async getCachedTensor(e,t,n,r,i,a,o){let s=this.getMLContext(e);for(let[r,i]of this.freeTensors.entries())if(i.canReuseTensor(s,t,n)){li(`verbose`,()=>`[WebNN] Reusing tensor {dataType: ${t}, ${o?`fallbackDataType: ${o},`:``} shape: ${n}`);let i=this.freeTensors.splice(r,1)[0];return i.sessionId=e,i}li(`verbose`,()=>`[WebNN] MLContext.createTensor {dataType: ${t}, ${o?`fallbackDataType: ${o},`:``} shape: ${n}}`);let c=await s.createTensor({dataType:o??t,shape:n,dimensions:n,usage:r,writable:i,readable:a});return new vi({sessionId:e,context:s,tensor:c,dataType:t,shape:n,fallbackDataType:o})}releaseTensor(e){this.externalTensors.has(e)&&this.externalTensors.delete(e),this.freeTensors.push(e)}},xi=(...e)=>new bi(...e)}),Ci={};Kt(Ci,{WebNNBackend:()=>Ei});var wi,Ti,Ei,Di=M(()=>{Qr(),kr(),ni(),Si(),ui(),wi=new Map([[1,`float32`],[10,`float16`],[6,`int32`],[12,`uint32`],[7,`int64`],[13,`uint64`],[22,`int4`],[21,`uint4`],[3,`int8`],[2,`uint8`],[9,`uint8`]]),Ti=(e,t)=>{if(e===t)return!0;if(e===void 0||t===void 0)return!1;let n=Object.keys(e).sort(),r=Object.keys(t).sort();return n.length===r.length&&n.every((n,i)=>n===r[i]&&e[n]===t[n])},Ei=class{constructor(e){this.tensorManager=xi(this),this.mlContextBySessionId=new Map,this.sessionIdsByMLContext=new Map,this.mlContextCache=[],this.sessionGraphInputs=new Map,this.sessionGraphOutputs=new Map,this.temporaryGraphInputs=[],this.temporaryGraphOutputs=[],this.temporarySessionTensorIds=new Map,this.mlOpSupportLimitsBySessionId=new Map,si(e.logLevel,!!e.debug)}get currentSessionId(){if(this.activeSessionId===void 0)throw Error(`No active session`);return this.activeSessionId}onRunStart(e){li(`verbose`,()=>`[WebNN] onRunStart {sessionId: ${e}}`),this.activeSessionId=e}onRunEnd(e){li(`verbose`,()=>`[WebNN] onRunEnd {sessionId: ${e}}`);let t=this.temporarySessionTensorIds.get(e);if(t){for(let e of t)li(`verbose`,()=>`[WebNN] releasing temporary tensor {tensorId: ${e}}`),this.tensorManager.releaseTensorId(e);this.temporarySessionTensorIds.delete(e),this.activeSessionId=void 0}}async createMLContext(e){if(e instanceof GPUDevice){let t=this.mlContextCache.findIndex(t=>t.gpuDevice===e);if(t!==-1)return this.mlContextCache[t].mlContext;{let t=await navigator.ml.createContext(e);return this.mlContextCache.push({gpuDevice:e,mlContext:t}),t}}if(e===void 0){let e=this.mlContextCache.findIndex(e=>e.options===void 0&&e.gpuDevice===void 0);if(e!==-1)return this.mlContextCache[e].mlContext;{let e=await navigator.ml.createContext();return this.mlContextCache.push({mlContext:e}),e}}let t=this.mlContextCache.findIndex(t=>Ti(t.options,e));if(t!==-1)return this.mlContextCache[t].mlContext;{let t=await navigator.ml.createContext(e);return this.mlContextCache.push({options:e,mlContext:t}),t}}registerMLContext(e,t){this.mlContextBySessionId.set(e,t);let n=this.sessionIdsByMLContext.get(t);n||(n=new Set,this.sessionIdsByMLContext.set(t,n)),n.add(e),this.mlOpSupportLimitsBySessionId.has(e)||this.mlOpSupportLimitsBySessionId.set(e,t.opSupportLimits()),this.temporaryGraphInputs.length>0&&(this.sessionGraphInputs.set(e,this.temporaryGraphInputs),this.temporaryGraphInputs=[]),this.temporaryGraphOutputs.length>0&&(this.sessionGraphOutputs.set(e,this.temporaryGraphOutputs),this.temporaryGraphOutputs=[])}onReleaseSession(e){this.sessionGraphInputs.delete(e),this.sessionGraphOutputs.delete(e);let t=this.mlContextBySessionId.get(e);if(!t)return;this.tensorManager.releaseTensorsForSession(e),this.mlContextBySessionId.delete(e),this.mlOpSupportLimitsBySessionId.delete(e);let n=this.sessionIdsByMLContext.get(t);if(n.delete(e),n.size===0){this.sessionIdsByMLContext.delete(t);let e=this.mlContextCache.findIndex(e=>e.mlContext===t);e!==-1&&this.mlContextCache.splice(e,1)}}getMLContext(e){return this.mlContextBySessionId.get(e)}getMLOpSupportLimits(e){return this.mlOpSupportLimitsBySessionId.get(e)}reserveTensorId(){return this.tensorManager.reserveTensorId()}releaseTensorId(e){li(`verbose`,()=>`[WebNN] releaseTensorId {tensorId: ${e}}`),this.tensorManager.releaseTensorId(e)}async ensureTensor(e,t,n,r,i){let a=wi.get(n);if(!a)throw Error(`Unsupported ONNX data type: ${n}`);return this.tensorManager.ensureTensor(e??this.currentSessionId,t,a,r,i)}async createTemporaryTensor(e,t,n){li(`verbose`,()=>`[WebNN] createTemporaryTensor {onnxDataType: ${t}, shape: ${n}}`);let r=wi.get(t);if(!r)throw Error(`Unsupported ONNX data type: ${t}`);let i=this.tensorManager.reserveTensorId();await this.tensorManager.ensureTensor(e,i,r,n,!1);let a=this.temporarySessionTensorIds.get(e);return a?a.push(i):this.temporarySessionTensorIds.set(e,[i]),i}uploadTensor(e,t){if(!Or().shouldTransferToMLTensor)throw Error(`Trying to upload to a MLTensor while shouldTransferToMLTensor is false`);li(`verbose`,()=>`[WebNN] uploadTensor {tensorId: ${e}, data: ${t.byteLength}}`),this.tensorManager.upload(e,t)}async downloadTensor(e,t){return this.tensorManager.download(e,t)}createMLTensorDownloader(e,t){return async()=>{let n=await this.tensorManager.download(e);return ti(n,t)}}registerMLTensor(e,t,n,r){let i=wi.get(n);if(!i)throw Error(`Unsupported ONNX data type: ${n}`);let a=this.tensorManager.registerTensor(e,t,i,r);return li(`verbose`,()=>`[WebNN] registerMLTensor {tensor: ${t}, dataType: ${i}, dimensions: ${r}} -> {tensorId: ${a}}`),a}registerGraphInput(e){this.temporaryGraphInputs.push(e)}registerGraphOutput(e){this.temporaryGraphOutputs.push(e)}isGraphInput(e,t){let n=this.sessionGraphInputs.get(e);return n?n.includes(t):!1}isGraphOutput(e,t){let n=this.sessionGraphOutputs.get(e);return n?n.includes(t):!1}isGraphInputOutputTypeSupported(e,t,n=!0){let r=wi.get(Wr(t)),i=this.mlOpSupportLimitsBySessionId.get(e);return typeof r>`u`?!1:n?!!i?.input.dataTypes.includes(r):!!i?.output.dataTypes.includes(r)}flush(){}}}),Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi=M(()=>{Jn(),Fr(),Ur(),Qr(),kr(),Nr(),ei(),Oi=(e,t)=>{Or()._OrtInit(e,t)!==0&&Mr(`Can't initialize onnxruntime.`)},ki=async e=>{Oi(e.wasm.numThreads,Jr(e.logLevel))},Ai=async(e,t)=>{Or().asyncInit?.();let n=e.webgpu.adapter;if(t===`webgpu`){if(typeof navigator>`u`||!navigator.gpu)throw Error(`WebGPU is not supported in current environment`);if(n){if(typeof n.limits!=`object`||typeof n.features!=`object`||typeof n.requestDevice!=`function`)throw Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let t=e.webgpu.powerPreference;if(t!==void 0&&t!==`low-power`&&t!==`high-performance`)throw Error(`Invalid powerPreference setting: "${t}"`);let r=e.webgpu.forceFallbackAdapter;if(r!==void 0&&typeof r!=`boolean`)throw Error(`Invalid forceFallbackAdapter setting: "${r}"`);if(n=await navigator.gpu.requestAdapter({powerPreference:t,forceFallbackAdapter:r}),!n)throw Error(`Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.`)}}if(t===`webnn`&&(typeof navigator>`u`||!navigator.ml))throw Error(`WebNN is not supported in current environment`);if(t===`webgpu`&&Or().webgpuInit(t=>{e.webgpu.device=t}),t===`webnn`){let t=new(Di(),Jt(Ci)).WebNNBackend(e);Or().webnnInit([t,()=>t.reserveTensorId(),e=>t.releaseTensorId(e),async(e,n,r,i,a)=>t.ensureTensor(e,n,r,i,a),(e,n)=>{t.uploadTensor(e,n)},async(e,n)=>t.downloadTensor(e,n),(e,n)=>t.registerMLContext(e,n),!!e.trace])}},ji=new Map,Mi=e=>{let t=Or(),n=t.stackSave();try{let n=t.PTR_SIZE,r=t.stackAlloc(2*n);t._OrtGetInputOutputCount(e,r,r+n)!==0&&Mr(`Can't get session input/output count.`);let i=n===4?`i32`:`i64`;return[Number(t.getValue(r,i)),Number(t.getValue(r+n,i))]}finally{t.stackRestore(n)}},Ni=(e,t)=>{let n=Or(),r=n.stackSave(),i=0;try{let r=n.PTR_SIZE,a=n.stackAlloc(2*r);n._OrtGetInputOutputMetadata(e,t,a,a+r)!==0&&Mr(`Can't get session input/output metadata.`);let o=Number(n.getValue(a,`*`));i=Number(n.getValue(a+r,`*`));let s=n.HEAP32[i/4];if(s===0)return[o,0];let c=n.HEAPU32[i/4+1],l=[];for(let e=0;e{let t=Or(),n=t._malloc(e.byteLength);if(n===0)throw Error(`Can't create a session. failed to allocate a buffer of size ${e.byteLength}.`);return t.HEAPU8.set(e,n),[n,e.byteLength]},Fi=async(e,t)=>{let n,r,i=Or();Array.isArray(e)?[n,r]=e:e.buffer===i.HEAPU8.buffer?[n,r]=[e.byteOffset,e.byteLength]:[n,r]=Pi(e);let a=0,o=0,s=0,c=[],l=[],u=[];try{if([o,c]=await Hr(t),t?.externalData&&i.mountExternalData){let e=[];for(let n of t.externalData){let t=typeof n==`string`?n:n.path,r=typeof n==`string`?n:n.data;e.push($r(r).then(e=>{i.mountExternalData(t,e)}))}await Promise.all(e)}for(let e of t?.executionProviders??[])if((typeof e==`string`?e:e.name)===`webnn`){if(i.shouldTransferToMLTensor=!1,typeof e!=`string`){let t=e,n=t?.context,r=t?.gpuDevice,a=t?.deviceType,o=t?.powerPreference;i.currentContext=n||(r?await i.webnnCreateMLContext(r):await i.webnnCreateMLContext({deviceType:a,powerPreference:o}))}else i.currentContext=await i.webnnCreateMLContext();break}a=await i._OrtCreateSession(n,r,o),i.webgpuOnCreateSession?.(a),a===0&&Mr(`Can't create a session.`),i.jsepOnCreateSession?.(),i.currentContext&&(i.webnnRegisterMLContext(a,i.currentContext),i.currentContext=void 0,i.shouldTransferToMLTensor=!0);let[e,d]=Mi(a),f=!!t?.enableGraphCapture,p=[],m=[],h=[],g=[],_=[];for(let t=0;te===`gpu-buffer`||e===`ml-tensor`||e===`ml-tensor-cpu-output`)&&(s=i._OrtCreateBinding(a),s===0&&Mr(`Can't create IO binding.`),v={handle:s,outputPreferredLocations:_,outputPreferredLocationsEncoded:_.map(e=>e===`ml-tensor-cpu-output`?`ml-tensor`:e).map(e=>Zr(e))}),ji.set(a,[a,l,u,v,f,!1]),[a,p,m,h,g]}catch(e){throw l.forEach(e=>i._OrtFree(e)),u.forEach(e=>i._OrtFree(e)),s!==0&&i._OrtReleaseBinding(s)!==0&&Mr(`Can't release IO binding.`),a!==0&&i._OrtReleaseSession(a)!==0&&Mr(`Can't release session.`),e}finally{i._free(n),o!==0&&i._OrtReleaseSessionOptions(o)!==0&&Mr(`Can't release session options.`),c.forEach(e=>i._free(e)),i.unmountExternalData?.()}},Ii=e=>{let t=Or(),n=ji.get(e);if(!n)throw Error(`cannot release session. invalid session id: ${e}`);let[r,i,a,o,s]=n;o&&(s&&t._OrtClearBoundOutputs(o.handle)!==0&&Mr(`Can't clear bound outputs.`),t._OrtReleaseBinding(o.handle)!==0&&Mr(`Can't release IO binding.`)),t.jsepOnReleaseSession?.(e),t.webnnOnReleaseSession?.(e),t.webgpuOnReleaseSession?.(e),i.forEach(e=>t._OrtFree(e)),a.forEach(e=>t._OrtFree(e)),t._OrtReleaseSession(r)!==0&&Mr(`Can't release session.`),ji.delete(e)},Li=async(e,t,n,r,i,a,o=!1)=>{if(!e){t.push(0);return}let s=Or(),c=s.PTR_SIZE,l=e[0],u=e[1],d=e[3],f=d,p,m;if(l===`string`&&(d===`gpu-buffer`||d===`ml-tensor`))throw Error(`String tensor is not supported on GPU.`);if(o&&d!==`gpu-buffer`)throw Error(`External buffer must be provided for input/output index ${a} when enableGraphCapture is true.`);if(d===`gpu-buffer`){let t=e[2].gpuBuffer;m=Kr(Wr(l),u);{let e=s.webgpuRegisterBuffer;if(!e)throw Error(`Tensor location "gpu-buffer" is not supported without using WebGPU.`);p=e(t,r)}}else if(d===`ml-tensor`){let t=e[2].mlTensor;m=Kr(Wr(l),u);let n=s.webnnRegisterMLTensor;if(!n)throw Error(`Tensor location "ml-tensor" is not supported without using WebNN.`);p=n(r,t,Wr(l),u)}else{let t=e[2];if(Array.isArray(t)){m=c*t.length,p=s._malloc(m),n.push(p);for(let e=0;es.setValue(g+t*c,e,c===4?`i32`:`i64`));let e=s._OrtCreateTensor(Wr(l),p,m,g,u.length,Zr(f));e===0&&Mr(`Can't create tensor for input/output. session=${r}, index=${a}.`),t.push(e)}finally{s.stackRestore(h)}},Ri=async(e,t,n,r,i,a)=>{let o=Or(),s=o.PTR_SIZE,c=ji.get(e);if(!c)throw Error(`cannot run inference. invalid session id: ${e}`);let l=c[0],u=c[1],d=c[2],f=c[3],p=c[4],m=c[5],h=t.length,g=r.length,_=0,v=[],y=[],b=[],x=[],S=[],C=o.stackSave(),ee=o.stackAlloc(h*s),w=o.stackAlloc(h*s),T=o.stackAlloc(g*s),E=o.stackAlloc(g*s);try{[_,v]=Pr(a),In(`wasm prepareInputOutputTensor`);for(let r=0;re*t,1);u=Gr(a);let _=f?.outputPreferredLocations[r[t]];if(u===`string`){if(_===`gpu-buffer`||_===`ml-tensor`)throw Error(`String tensor is not supported on GPU.`);let e=[];for(let t=0;t0){let t=o.webgpuGetBuffer;if(!t)throw Error(`preferredLocation "gpu-buffer" is not supported without using WebGPU.`);let r=t(d),i=Kr(a,g);if(i===void 0||!Yr(u))throw Error(`Unsupported data type: ${u}`);l=!0;{o.webgpuRegisterBuffer(r,e,d);let t=o.webgpuCreateDownloader(r,i,e);C.push([u,h,{gpuBuffer:r,download:async()=>{let e=await t();return new(qr(u))(e)},dispose:()=>{o._OrtReleaseTensor(n)!==0&&Mr(`Can't release tensor.`)}},`gpu-buffer`])}}else if(_===`ml-tensor`&&g>0){let t=o.webnnEnsureTensor,r=o.webnnIsGraphInputOutputTypeSupported;if(!t||!r)throw Error(`preferredLocation "ml-tensor" is not supported without using WebNN.`);if(Kr(a,g)===void 0||!Xr(u))throw Error(`Unsupported data type: ${u}`);if(!r(e,u,!1))throw Error(`preferredLocation "ml-tensor" for ${u} output is not supported by current WebNN Context.`);let i=await t(e,d,a,h,!1);l=!0,C.push([u,h,{mlTensor:i,download:o.webnnCreateMLTensorDownloader(d,u),dispose:()=>{o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n)}},`ml-tensor`])}else if(_===`ml-tensor-cpu-output`&&g>0){let e=o.webnnCreateMLTensorDownloader(d,u)(),t=C.length;l=!0,te.push((async()=>{let r=[t,await e];return o.webnnReleaseTensorId(d),o._OrtReleaseTensor(n),r})()),C.push([u,h,[],`cpu`])}else{let e=new(qr(u))(g);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(o.HEAPU8.subarray(d,d+e.byteLength)),C.push([u,h,e,`cpu`])}}finally{o.stackRestore(a),u===`string`&&d&&o._free(d),l||o._OrtReleaseTensor(n)}}f&&!p&&(o._OrtClearBoundOutputs(f.handle)!==0&&Mr(`Can't clear bound outputs.`),ji.set(e,[l,u,d,f,p,!1]));for(let[e,t]of await Promise.all(te))C[e][2]=t;return Ln(`wasm ProcessOutputTensor`),C}finally{o.webnnOnRunEnd?.(l),o.stackRestore(C),n.forEach(e=>{e&&e[3]===`gpu-buffer`&&o.webgpuUnregisterBuffer(e[2].gpuBuffer)}),i.forEach(e=>{e&&e[3]===`gpu-buffer`&&o.webgpuUnregisterBuffer(e[2].gpuBuffer)}),y.forEach(e=>o._OrtReleaseTensor(e)),b.forEach(e=>o._OrtReleaseTensor(e)),x.forEach(e=>o._free(e)),_!==0&&o._OrtReleaseRunOptions(_),v.forEach(e=>o._free(e))}},zi=e=>{let t=Or(),n=ji.get(e);if(!n)throw Error(`invalid session id`);let r=n[0],i=t._OrtEndProfiling(r);i===0&&Mr(`Can't get an profile file name.`),t._OrtFree(i)},Bi=e=>{let t=[];for(let n of e){let e=n[2];!Array.isArray(e)&&`buffer`in e&&t.push(e.buffer)}return t}}),Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra,ia,aa,oa=M(()=>{Jn(),Vi(),kr(),br(),Hi=()=>!!cn.wasm.proxy&&typeof document<`u`,Wi=!1,Gi=!1,Ki=!1,Yi=new Map,Xi=(e,t)=>{let n=Yi.get(e);n?n.push(t):Yi.set(e,[t])},Zi=()=>{if(Wi||!Gi||Ki||!Ui)throw Error(`worker not ready`)},Qi=e=>{switch(e.data.type){case`init-wasm`:Wi=!1,e.data.err?(Ki=!0,Ji[1](e.data.err)):(Gi=!0,Ji[0]()),qi&&=(URL.revokeObjectURL(qi),void 0);break;case`init-ep`:case`copy-from`:case`create`:case`release`:case`run`:case`end-profiling`:{let t=Yi.get(e.data.type);e.data.err?t.shift()[1](e.data.err):t.shift()[0](e.data.out);break}}},$i=async()=>{if(!Gi){if(Wi)throw Error(`multiple calls to 'initWasm()' detected.`);if(Ki)throw Error(`previous call to 'initWasm()' failed.`);if(Wi=!0,Hi())return new Promise((e,t)=>{Ui?.terminate(),_r().then(([n,r])=>{try{Ui=r,Ui.onerror=e=>t(e),Ui.onmessage=Qi,Ji=[e,t];let i={type:`init-wasm`,in:cn};!i.in.wasm.wasmPaths&&(n||sr)&&(i.in.wasm.wasmPaths={wasm:new URL(`/assets/ort-wasm-simd-threaded.asyncify-CxOG5pUO.wasm`,``+import.meta.url).href}),Ui.postMessage(i),qi=n}catch(e){t(e)}},t)});try{await Dr(cn.wasm),await ki(cn),Gi=!0}catch(e){throw Ki=!0,e}finally{Wi=!1}}},ea=async e=>{if(Hi())return Zi(),new Promise((t,n)=>{Xi(`init-ep`,[t,n]);let r={type:`init-ep`,in:{epName:e,env:cn}};Ui.postMessage(r)});await Ai(cn,e)},ta=async e=>Hi()?(Zi(),new Promise((t,n)=>{Xi(`copy-from`,[t,n]);let r={type:`copy-from`,in:{buffer:e}};Ui.postMessage(r,[e.buffer])})):Pi(e),na=async(e,t)=>{if(Hi()){if(t?.preferredOutputLocation)throw Error(`session option "preferredOutputLocation" is not supported for proxy.`);return Zi(),new Promise((n,r)=>{Xi(`create`,[n,r]);let i={type:`create`,in:{model:e,options:{...t}}},a=[];e instanceof Uint8Array&&a.push(e.buffer),Ui.postMessage(i,a)})}return Fi(e,t)},ra=async e=>{if(Hi())return Zi(),new Promise((t,n)=>{Xi(`release`,[t,n]);let r={type:`release`,in:e};Ui.postMessage(r)});Ii(e)},ia=async(e,t,n,r,i,a)=>{if(Hi()){if(n.some(e=>e[3]!==`cpu`))throw Error(`input tensor on GPU is not supported for proxy.`);if(i.some(e=>e))throw Error(`pre-allocated output tensor is not supported for proxy.`);return Zi(),new Promise((i,o)=>{Xi(`run`,[i,o]);let s=n,c={type:`run`,in:{sessionId:e,inputIndices:t,inputs:s,outputIndices:r,options:a}};Ui.postMessage(c,Bi(s))})}return Ri(e,t,n,r,i,a)},aa=async e=>{if(Hi())return Zi(),new Promise((t,n)=>{Xi(`end-profiling`,[t,n]);let r={type:`end-profiling`,in:e};Ui.postMessage(r)});zi(e)}}),sa,ca,la,ua=M(()=>{Jn(),oa(),Qr(),Yn(),ei(),sa=(e,t)=>{switch(e.location){case`cpu`:return[e.type,e.dims,e.data,`cpu`];case`gpu-buffer`:return[e.type,e.dims,{gpuBuffer:e.gpuBuffer},`gpu-buffer`];case`ml-tensor`:return[e.type,e.dims,{mlTensor:e.mlTensor},`ml-tensor`];default:throw Error(`invalid data location: ${e.location} for ${t()}`)}},ca=e=>{switch(e[3]){case`cpu`:return new An(e[0],e[2],e[1]);case`gpu-buffer`:{let t=e[0];if(!Yr(t))throw Error(`not supported data type: ${t} for deserializing GPU tensor`);let{gpuBuffer:n,download:r,dispose:i}=e[2];return An.fromGpuBuffer(n,{dataType:t,dims:e[1],download:r,dispose:i})}case`ml-tensor`:{let t=e[0];if(!Xr(t))throw Error(`not supported data type: ${t} for deserializing MLTensor tensor`);let{mlTensor:n,download:r,dispose:i}=e[2];return An.fromMLTensor(n,{dataType:t,dims:e[1],download:r,dispose:i})}default:throw Error(`invalid data location: ${e[3]}`)}},la=class{async fetchModelAndCopyToWasmMemory(e){return ta(await $r(e))}async loadModel(e,t){Pn();let n;n=typeof e==`string`?await this.fetchModelAndCopyToWasmMemory(e):e,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await na(n,t),Fn()}async dispose(){return ra(this.sessionId)}async run(e,t,n){Pn();let r=[],i=[];Object.entries(e).forEach(e=>{let t=e[0],n=e[1],a=this.inputNames.indexOf(t);if(a===-1)throw Error(`invalid input '${t}'`);r.push(n),i.push(a)});let a=[],o=[];Object.entries(t).forEach(e=>{let t=e[0],n=e[1],r=this.outputNames.indexOf(t);if(r===-1)throw Error(`invalid output '${t}'`);a.push(n),o.push(r)});let s=r.map((e,t)=>sa(e,()=>`input "${this.inputNames[i[t]]}"`)),c=a.map((e,t)=>e?sa(e,()=>`output "${this.outputNames[o[t]]}"`):null),l=await ia(this.sessionId,i,s,o,c,n),u={};for(let e=0;efa,initializeFlags:()=>da,wasmBackend:()=>pa});var da,fa,pa,ma=M(()=>{Jn(),oa(),ua(),da=()=>{(typeof cn.wasm.initTimeout!=`number`||cn.wasm.initTimeout<0)&&(cn.wasm.initTimeout=0);let e=cn.wasm.simd;if(typeof e!=`boolean`&&e!==void 0&&e!==`fixed`&&e!==`relaxed`&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${e}". Reset it to \`false\` and ignore SIMD feature checking.`),cn.wasm.simd=!1),typeof cn.wasm.proxy!=`boolean`&&(cn.wasm.proxy=!1),typeof cn.wasm.trace!=`boolean`&&(cn.wasm.trace=!1),typeof cn.wasm.numThreads!=`number`||!Number.isInteger(cn.wasm.numThreads)||cn.wasm.numThreads<=0){if(typeof self<`u`&&!self.crossOriginIsolated)cn.wasm.numThreads=1;else{let e=typeof navigator>`u`?Gt(`node:os`).cpus().length:navigator.hardwareConcurrency;cn.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}}},fa=class{async init(e){da(),await $i(),await ea(e)}async createInferenceSessionHandler(e,t){let n=new la;return await n.loadModel(e,t),n}},pa=new fa});Jn(),Jn(),Jn();var ha=`1.31.0-dev.20260914-8d85527a0`,ga=qn;{let e=(ma(),Jt(P)).wasmBackend;Zt(`webgpu`,e,5),Zt(`webnn`,e,5),Zt(`cpu`,e,10),Zt(`wasm`,e,10)}Object.defineProperty(cn.versions,"web",{value:ha,enumerable:!0});var _a=`1.30.0`,va=`warning`;Object.defineProperty({wasm:{},webgl:{},webgpu:{},versions:{common:_a},set logLevel(e){if(e!==void 0){if(typeof e!=`string`||[`verbose`,`info`,`warning`,`error`,`fatal`].indexOf(e)===-1)throw Error(`Unsupported logging level: ${e}`);va=e}},get logLevel(){return va}},"logLevel",{enumerable:!0});var ya=(e,t)=>{let n=typeof document<`u`?document.createElement(`canvas`):new OffscreenCanvas(1,1);n.width=e.dims[3],n.height=e.dims[2];let r=n.getContext(`2d`);if(r!=null){let i,a;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[3]):(i=e.dims[3],a=e.dims[2]);let o=t?.format===void 0?`RGB`:t.format,s=t?.norm,c,l;s===void 0||s.mean===void 0?c=[255,255,255,255]:typeof s.mean==`number`?c=[s.mean,s.mean,s.mean,s.mean]:(c=[s.mean[0],s.mean[1],s.mean[2],0],s.mean[3]!==void 0&&(c[3]=s.mean[3])),s===void 0||s.bias===void 0?l=[0,0,0,0]:typeof s.bias==`number`?l=[s.bias,s.bias,s.bias,s.bias]:(l=[s.bias[0],s.bias[1],s.bias[2],0],s.bias[3]!==void 0&&(l[3]=s.bias[3]));let u=a*i,d=0,f=u,p=u*2,m=-1;o===`RGBA`?(d=0,f=u,p=u*2,m=u*3):o===`RGB`?(d=0,f=u,p=u*2):o===`RBG`&&(d=0,p=u,f=u*2);for(let t=0;t{let n=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):new OffscreenCanvas(1,1).getContext(`2d`),r;if(n!=null){let i,a,o;t?.tensorLayout!==void 0&&t.tensorLayout===`NHWC`?(i=e.dims[2],a=e.dims[1],o=e.dims[3]):(i=e.dims[3],a=e.dims[2],o=e.dims[1]);let s=t===void 0||t.format===void 0?`RGB`:t.format,c=t?.norm,l,u;c===void 0||c.mean===void 0?l=[255,255,255,255]:typeof c.mean==`number`?l=[c.mean,c.mean,c.mean,c.mean]:(l=[c.mean[0],c.mean[1],c.mean[2],255],c.mean[3]!==void 0&&(l[3]=c.mean[3])),c===void 0||c.bias===void 0?u=[0,0,0,0]:typeof c.bias==`number`?u=[c.bias,c.bias,c.bias,c.bias]:(u=[c.bias[0],c.bias[1],c.bias[2],0],c.bias[3]!==void 0&&(u[3]=c.bias[3]));let d=a*i;if(t!==void 0&&(t.format!==void 0&&o===4&&t.format!==`RGBA`||o===3&&t.format!==`RGB`&&t.format!==`BGR`))throw Error(`Tensor format doesn't match input tensor dims`);let f=0,p=1,m=2,h=3,g=0,_=d,v=d*2,y=-1;s===`RGBA`?(g=0,_=d,v=d*2,y=d*3):s===`RGB`?(g=0,_=d,v=d*2):s===`RBG`&&(g=0,v=d,_=d*2),r=n.createImageData(i,a);for(let t=0;t{if(e===void 0)throw Error(`Image buffer must be defined`);if(t.height===void 0||t.width===void 0)throw Error(`Image height and width must be defined`);if(t.tensorLayout===`NHWC`)throw Error(`NHWC Tensor layout is not supported yet`);let{height:n,width:r}=t,i=t.norm??{mean:255,bias:0},a,o;a=typeof i.mean==`number`?[i.mean,i.mean,i.mean,i.mean]:[i.mean[0],i.mean[1],i.mean[2],i.mean[3]??255],o=typeof i.bias==`number`?[i.bias,i.bias,i.bias,i.bias]:[i.bias[0],i.bias[1],i.bias[2],i.bias[3]??0];let s=t.format===void 0?`RGBA`:t.format,c=t.tensorFormat===void 0||t.tensorFormat===void 0?`RGB`:t.tensorFormat,l=n*r,u=c===`RGBA`?new Float32Array(l*4):new Float32Array(l*3),d=4,f=0,p=1,m=2,h=3,g=0,_=l,v=l*2,y=-1;s===`RGB`&&(d=3,f=0,p=1,m=2,h=-1),c===`RGBA`?y=l*3:c===`RBG`?(g=0,v=l,_=l*2):c===`BGR`&&(v=0,_=l,g=l*2);for(let t=0;t{let n=typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement,r=typeof ImageData<`u`&&e instanceof ImageData,i=typeof ImageBitmap<`u`&&e instanceof ImageBitmap,a=typeof e==`string`,o,s=t??{},c=()=>{if(typeof document<`u`)return document.createElement(`canvas`);if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(1,1);throw Error(`Canvas is not supported`)},l=e=>typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas?e.getContext(`2d`):null;if(n){let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let n=e.height,i=e.width;if(t!==void 0&&t.resizedHeight!==void 0&&t.resizedWidth!==void 0&&(n=t.resizedHeight,i=t.resizedWidth),t!==void 0){if(s=t,t.tensorFormat!==void 0)throw Error(`Image input config format must be RGBA for HTMLImageElement`);s.tensorFormat=`RGBA`,s.height=n,s.width=i}else s.tensorFormat=`RGBA`,s.height=n,s.width=i;r.drawImage(e,0,0),o=r.getImageData(0,0,i,n).data}else throw Error(`Can not access image data`)}else if(r){let n,r;if(t!==void 0&&t.resizedWidth!==void 0&&t.resizedHeight!==void 0?(n=t.resizedHeight,r=t.resizedWidth):(n=e.height,r=e.width),t!==void 0&&(s=t),s.format=`RGBA`,s.height=n,s.width=r,t!==void 0){let t=c();t.width=r,t.height=n;let i=l(t);if(i!=null)i.putImageData(e,0,0),o=i.getImageData(0,0,r,n).data;else throw Error(`Can not access image data`)}else o=e.data}else if(i){if(t===void 0)throw Error(`Please provide image config with format for Imagebitmap`);let n=c();n.width=e.width,n.height=e.height;let r=l(n);if(r!=null){let t=e.height,n=e.width;return r.drawImage(e,0,0,n,t),o=r.getImageData(0,0,n,t).data,s.height=t,s.width=n,F(o,s)}throw Error(`Can not access image data`)}else if(a)return new Promise((t,n)=>{let r=c(),i=l(r);if(!e||!i)return n();let a=new Image;a.crossOrigin=`Anonymous`,a.src=e,a.onload=()=>{r.width=a.width,r.height=a.height,i.drawImage(a,0,0,r.width,r.height);let e=i.getImageData(0,0,r.width,r.height);s.height=r.height,s.width=r.width,t(F(e.data,s))}});else throw Error(`Input data provided is not supported - aborted tensor creation`);if(o!==void 0)return F(o,s);throw Error(`Input data provided is not supported - aborted tensor creation`)},Sa=(e,t)=>{let{width:n,height:r,download:i,dispose:a}=t;return new Aa({location:`texture`,type:`float32`,texture:e,dims:[1,r,n,4],download:i,dispose:a})},I=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new Aa({location:`gpu-buffer`,type:n??`float32`,gpuBuffer:e,dims:r,download:i,dispose:a})},Ca=(e,t)=>{let{dataType:n,dims:r,download:i,dispose:a}=t;return new Aa({location:`ml-tensor`,type:n??`float32`,mlTensor:e,dims:r,download:i,dispose:a})},L=(e,t,n)=>new Aa({location:`cpu-pinned`,type:e,data:t,dims:n??[t.length]}),wa=new Map([[`float32`,Float32Array],[`uint8`,Uint8Array],[`int8`,Int8Array],[`uint16`,Uint16Array],[`int16`,Int16Array],[`int32`,Int32Array],[`bool`,Uint8Array],[`float64`,Float64Array],[`uint32`,Uint32Array],[`int4`,Uint8Array],[`uint4`,Uint8Array]]),Ta=new Map([[Float32Array,`float32`],[Uint8Array,`uint8`],[Int8Array,`int8`],[Uint16Array,`uint16`],[Int16Array,`int16`],[Int32Array,`int32`],[Float64Array,`float64`],[Uint32Array,`uint32`]]),Ea=!1,Da=()=>{if(!Ea){Ea=!0;let e=typeof BigInt64Array<`u`&&BigInt64Array.from,t=typeof BigUint64Array<`u`&&BigUint64Array.from,n=globalThis.Float16Array,r=n!==void 0&&n.from;e&&(wa.set(`int64`,BigInt64Array),Ta.set(BigInt64Array,`int64`)),t&&(wa.set(`uint64`,BigUint64Array),Ta.set(BigUint64Array,`uint64`)),r?(wa.set(`float16`,n),Ta.set(n,`float16`)):wa.set(`float16`,Uint16Array)}},Oa=e=>{let t=1;for(let n=0;n{switch(e.location){case`cpu`:return new Aa(e.type,e.data,t);case`cpu-pinned`:return new Aa({location:`cpu-pinned`,data:e.data,type:e.type,dims:t});case`texture`:return new Aa({location:`texture`,texture:e.texture,type:e.type,dims:t});case`gpu-buffer`:return new Aa({location:`gpu-buffer`,gpuBuffer:e.gpuBuffer,type:e.type,dims:t});case`ml-tensor`:return new Aa({location:`ml-tensor`,mlTensor:e.mlTensor,type:e.type,dims:t});default:throw Error(`tensorReshape: tensor location ${e.location} is not supported`)}},Aa=class{constructor(e,t,n){Da();let r,i;if(typeof e==`object`&&`location`in e)switch(this.dataLocation=e.location,r=e.type,i=e.dims,e.location){case`cpu-pinned`:{let t=wa.get(r);if(!t)throw TypeError(`unsupported type "${r}" to create tensor from pinned buffer`);if(!(e.data instanceof t))throw TypeError(`buffer should be of type ${t.name}`);this.cpuData=e.data;break}case`texture`:if(r!==`float32`)throw TypeError(`unsupported type "${r}" to create tensor from texture`);this.gpuTextureData=e.texture,this.downloader=e.download,this.disposer=e.dispose;break;case`gpu-buffer`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from gpu buffer`);this.gpuBufferData=e.gpuBuffer,this.downloader=e.download,this.disposer=e.dispose;break;case`ml-tensor`:if(r!==`float32`&&r!==`float16`&&r!==`int32`&&r!==`int64`&&r!==`uint32`&&r!==`uint64`&&r!==`int8`&&r!==`uint8`&&r!==`bool`&&r!==`uint4`&&r!==`int4`)throw TypeError(`unsupported type "${r}" to create tensor from MLTensor`);this.mlTensorData=e.mlTensor,this.downloader=e.download,this.disposer=e.dispose;break;default:throw Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,o;if(typeof e==`string`){if(r=e,o=n,e===`string`){if(!Array.isArray(t))throw TypeError(`A string tensor's data must be a string array.`);a=t}else{let n=wa.get(e);if(n===void 0)throw TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t)){if(e===`float16`&&n===Uint16Array||e===`uint4`||e===`int4`)throw TypeError(`Creating a ${e} tensor from number array is not supported. Please use ${n.name} as data.`);a=e===`uint64`||e===`int64`?n.from(t,BigInt):n.from(t)}else if(t instanceof n)a=t;else if(t instanceof Uint8ClampedArray){if(e===`uint8`)a=Uint8Array.from(t);else throw TypeError(`A Uint8ClampedArray tensor's data must be type of uint8`)}else if(e===`float16`&&t instanceof Uint16Array&&n!==Uint16Array)a=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw TypeError(`A ${r} tensor's data must be type of ${n}`)}}else if(o=t,Array.isArray(e)){if(e.length===0)throw TypeError(`Tensor type cannot be inferred from an empty array.`);let t=typeof e[0];if(t===`string`)r=`string`,a=e;else if(t===`boolean`)r=`bool`,a=Uint8Array.from(e);else throw TypeError(`Invalid element type of data array: ${t}.`)}else if(e instanceof Uint8ClampedArray)r=`uint8`,a=Uint8Array.from(e);else{let t=Ta.get(e.constructor);if(t===void 0)throw TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,a=e}if(o===void 0)o=[a.length];else if(!Array.isArray(o))throw TypeError(`A tensor's dims must be a number array`);i=o,this.cpuData=a,this.dataLocation=`cpu`}let a=Oa(i);if(this.cpuData&&a!==this.cpuData.length&&(r!==`uint4`&&r!==`int4`||Math.ceil(a/2)!==this.cpuData.length))throw Error(`Tensor's size(${a}) does not match data length(${this.cpuData.length}).`);this.type=r,this.dims=i,this.size=a}static async fromImage(e,t){return xa(e,t)}static fromTexture(e,t){return Sa(e,t)}static fromGpuBuffer(e,t){return I(e,t)}static fromMLTensor(e,t){return Ca(e,t)}static fromPinnedBuffer(e,t,n){return L(e,t,n)}toDataURL(e){return ya(this,e)}toImageData(e){return ba(this,e)}get data(){if(this.ensureValid(),!this.cpuData)throw Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw Error(`The data is not stored as a WebGL texture.`);return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw Error(`The data is not stored as a WebGPU buffer.`);return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw Error(`The data is not stored as a WebNN MLTensor.`);return this.mlTensorData}async getData(e){switch(this.ensureValid(),this.dataLocation){case`cpu`:case`cpu-pinned`:return this.data;case`texture`:case`gpu-buffer`:case`ml-tensor`:if(!this.downloader)throw Error(`The current tensor is not created with a specified data downloader.`);if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);try{this.isDownloading=!0;let t=await this.downloader();return this.downloader=void 0,this.dataLocation=`cpu`,this.cpuData=t,e&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}default:throw Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw Error(`The current tensor is being downloaded.`);this.disposer&&=(this.disposer(),void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation=`none`}ensureValid(){if(this.dataLocation===`none`)throw Error(`The tensor is disposed.`)}reshape(e){if(this.ensureValid(),this.downloader||this.disposer)throw Error(`Cannot reshape a tensor that owns GPU resource.`);return ka(this,e)}},ja=Aa,Ma=Object.defineProperty,Na=(e,t)=>{for(var n in t)Ma(e,n,{get:t[n],enumerable:!0})},Pa={},Fa={},Ia={},La=`4.3.0`,Ra=typeof self<`u`,za=!lo(Pa),Ba=!lo(Fa),Va=Ra&&`caches`in self,Ha=globalThis.Deno!==void 0;globalThis.Bun;var Ua=Ha&&Va&&!za,Wa=typeof process<`u`,Ga=Wa&&process?.release?.name===`node`&&!Ua,Ka=typeof window<`u`&&window.document!==void 0,qa=Ra&&[`DedicatedWorkerGlobalScope`,`ServiceWorkerGlobalScope`,`SharedWorkerGlobalScope`].includes(self.constructor?.name),Ja=Ka||qa||Ua,Ya=Ga||typeof navigator<`u`&&`gpu`in navigator,Xa=typeof navigator<`u`&&`ml`in navigator,Za=typeof crypto<`u`&&typeof crypto.getRandomValues==`function`,Qa=typeof chrome<`u`&&chrome.runtime!==void 0&&typeof chrome.runtime.id==`string`,$a=typeof ServiceWorkerGlobalScope<`u`&&Ra&&self instanceof ServiceWorkerGlobalScope,eo=(()=>{if(typeof navigator>`u`)return!1;let e=navigator.userAgent;if(!((navigator.vendor||``).indexOf(`Apple`)>-1&&!e.match(/CriOS|FxiOS|EdgiOS|OPiOS|mercury|brave/i)&&!e.includes(`Chrome`)&&!e.includes(`Android`)))return!1;let t=e.match(/Version\/(\d+)/);return t?parseInt(t[1],10)<26:!1})(),R=Object.freeze({IS_BROWSER_ENV:Ka,IS_WEBWORKER_ENV:qa,IS_WEB_ENV:Ja,IS_SERVICE_WORKER_ENV:$a,IS_DENO_WEB_RUNTIME:Ua,IS_WEB_CACHE_AVAILABLE:Va,IS_WEBGPU_AVAILABLE:Ya,IS_WEBNN_AVAILABLE:Xa,IS_SAFARI_BELOW_26:eo,IS_PROCESS_AVAILABLE:Wa,IS_NODE_ENV:Ga,IS_FS_AVAILABLE:za,IS_PATH_AVAILABLE:Ba,IS_CRYPTO_AVAILABLE:Za,IS_CHROME_AVAILABLE:Qa}),to=za&&Ba,no=`./`;if(to){let e=import.meta.url;e?no=Fa.dirname(Fa.dirname(Ia.fileURLToPath(e))):typeof __dirname<`u`&&(no=Fa.dirname(__dirname))}var ro=to?Fa.join(no,`/.cache/`):null,io=`/models/`,ao=to?Fa.join(no,io):io,oo=typeof globalThis.fetch==`function`?globalThis.fetch.bind(globalThis):void 0,so=Object.freeze({DEBUG:10,INFO:20,WARNING:30,ERROR:40,NONE:50}),co=so.WARNING,z={version:La,backends:{onnx:{}},get logLevel(){return co},set logLevel(e){co=e,z.backends.onnx?.setLogLevel?.(e)},allowRemoteModels:!0,remoteHost:`https://huggingface.co/`,remotePathTemplate:`{model}/resolve/{revision}/`,allowLocalModels:!(Ka||qa||Ua),localModelPath:ao,useFS:za,useBrowserCache:Va,useFSCache:za,cacheDir:ro,useCustomCache:!1,customCache:null,useWasmCache:Va||za,cacheKey:`transformers-cache`,experimental_useCrossOriginStorage:!1,fetch:oo};function lo(e){return Object.keys(e).length===0}var uo=class{constructor(){let e=function(...t){return e._call(...t)};return Object.setPrototypeOf(e,new.target.prototype)}_call(...e){throw Error(`Must implement _call method in subclass`)}};function fo(e,t){e&&e(t)}var po=class extends uo{constructor(e,t){super(),this.callback=e,this.files_loading=t,this.loads=new Map}_call(e){if(e.status===`progress`){this.files_loading[e.file]={loaded:e.loaded,total:e.total};let t=Object.values(this.files_loading).reduce((e,t)=>e+t.loaded,0),n=Object.values(this.files_loading).reduce((e,t)=>e+t.total,0),r=n>0?t/n*100:0;this.callback({status:`progress_total`,name:e.name,progress:r,loaded:t,total:n,files:structuredClone(this.files_loading)})}this.callback(e)}};function mo(e){return Number.isInteger(e)||typeof e==`bigint`}function ho(e){return e==null||e===-1}function go(e){let t=[],n=e;for(;Array.isArray(n);)t.push(n.length),n=n[0];return t}function _o(...e){return Array.prototype.concat.apply([],e)}function vo(...e){return e.reduce((e,t)=>e.flatMap(e=>t.map(t=>[e,t])))}function yo(e,t){return Math.abs((e+t)%(2*t)-t)}function bo(e,t){return Object.assign({},...t.map(t=>{if(e[t]!==void 0)return{[t]:e[t]}}))}function xo(e,t){let n=0;for(let r of e)r===t&&++n;return n}var B={error(...e){z.logLevel<=so.ERROR&&console.error(...e)},warn(...e){z.logLevel<=so.WARNING&&console.warn(...e)},info(...e){z.logLevel<=so.INFO&&console.log(...e)},debug(...e){z.logLevel<=so.DEBUG&&console.log(...e)},log(...e){this.info(...e)}},So=class{constructor(e){this.trie=this._build_trie(e)}_build_trie(e){let t=Object.create(null);for(let n of e){let e=t;for(let t=0;tr&&t.push(e.slice(r,i)),t.push(o),i+=o.length,r=i):++i}return r{try{return new RegExp(e,t)}catch(n){if(!(n instanceof SyntaxError))throw n;let r=new Map,i=e.replace(/(\\[pP])\{([^}=]+)\}/g,(t,n,i,a)=>{let o=0;for(let t=a-1;t>=0&&e[t]===`\\`;--t)++o;if(o%2==1)return t;let s=r.get(i);if(s===void 0){try{RegExp(`\\p{${i}}`,`u`),s=i}catch{s=`Script=${i}`}r.set(i,s)}return`${n}{${s}}`});if(i===e)throw n;try{return new RegExp(i,t)}catch{throw n}}},To=e=>e.replace(/ \./g,`.`).replace(/ \?/g,`?`).replace(/ \!/g,`!`).replace(/ ,/g,`,`).replace(/ \' /g,`'`).replace(/ n't/g,`n't`).replace(/ 'm/g,`'m`).replace(/ 's/g,`'s`).replace(/ 've/g,`'ve`).replace(/ 're/g,`'re`),Eo=(e,t=!0)=>{if(e.Regex!==void 0)return wo(ls(Zo(e.Regex)),`gu`);if(e.String!==void 0){let n=us(e.String);return new RegExp(t?n:`(${n})`,`gu`)}return console.warn(`Unknown pattern type:`,e),null},Do=`\\p{Alphabetic}\\p{M}\\p{Nd}\\p{Pc}`,Oo=`${Do}\\u00B2\\u00B3\\u00B9\\u00BC-\\u00BE`,ko=`[${Oo}]`,Ao=`[^${Oo}]`,jo=`(?:(?|[:=!>])/,V=/^\\([pPxu])\{([^}]*)\}/,Uo=/^\{(\d+(?:,\d*)?|,\d+)\}/,Wo=/^\[:(\^?)(\p{Alphabetic}+):\]/u,Go=/^\[:\^:\]/,Ko=/^\[(?:\.[^\]]*\.\]|=[^\]]*=\])/,qo=/^(?:\\x[0-9A-Fa-f]{2}|\\u[0-9A-Fa-f]{4}|\\c[A-Za-z])/,Jo=e=>e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`,Yo=(e,t)=>String.fromCodePoint(e.codePointAt(t)),Xo=e=>{if(!/^[0-9A-Fa-f]{1,8}$/.test(e))return null;let t=Number.parseInt(e,16);if(t>127)return null;let n=String.fromCharCode(t);return Jo(n)?`[${n.toLowerCase()}${n.toUpperCase()}]`:null},Zo=e=>e.replace(/\[\^\(\\s\|\[([^\]]+)\]\)\]/g,`[^()|\\s$1]`),Qo=`[\\s\\S]`,$o=256,es=()=>({fragment:``,alternatives:[],tail:null,contains_complex_set:!1}),ts=e=>{throw SyntaxError(`Unsupported range with a set-valued character-class operand at index ${e}`)},ns=(e,t,n,r=!0)=>{e.tail===`range`&&ts(n),e.alternatives.push(t),e.tail=`set`,e.contains_complex_set=e.contains_complex_set||r},rs=(e,t,n=!1,r=-1)=>{if(n&&e.tail===`range`&&ts(r),e.tail===`range`){e.fragment+=t,e.tail=`complete_range`;return}e.fragment+=t,e.tail=n?`set`:`scalar`,e.contains_complex_set=e.contains_complex_set||n},is=(e,t,n)=>{let r=V.exec(e.slice(t));if(r){let[e,i,a]=r;return i===`P`&&a===`Word`?ns(n,`[^${Do}]`,t):rs(n,i===`x`?`\\u{${a}}`:i===`p`&&a===`Word`?Do:e,i===`p`||i===`P`,t),t+e.length}let i=qo.exec(e.slice(t));if(i)return rs(n,i[0]),t+i[0].length;if(t+1>=e.length)throw SyntaxError(`Unterminated escape in character class at index ${t}`);let a=Yo(e,t+1),o=t+1+a.length,s=zo.get(a);if(s!==void 0)return rs(n,s),o;let c=Ro.get(a);if(c!==void 0)return ns(n,c,t),o;let l=Lo.get(a),u,d=!1;return l===void 0?u=/[A-Za-z0-9]/.test(a)||Vo.includes(a)||a===`-`?`\\${a}`:a:(u=l,d=a!==`a`&&a!==`e`),rs(n,u,d,t),o},as=e=>e.length===1?e[0]:`(?:(?=(?:${e.join(`|`)}))${Qo})`,os=e=>as(e.fragment.length===0?e.alternatives:[`[${e.fragment}]`,...e.alternatives]),ss=e=>{let t=wo(`^(?:${e})$`,`u`),n=``;for(let e=0;e<26;++e){let r=String.fromCharCode(65+e),i=String.fromCharCode(97+e),a=t.test(r);a!==t.test(i)&&(n+=a?i:r)}return n},cs=(e,t,n,r=!0,i=1)=>{if(i>$o)throw SyntaxError(`Maximum character-class nesting depth of ${$o} exceeded at index ${t}`);let a=t+1,o=e[a]===`^`;o&&++a;let s=a,c=[es()],l=c[0],u=!1;for(;a1?SyntaxError(`Malformed character-class intersection with an empty operand at index ${a}`):SyntaxError(`Empty character class at index ${t}`);let e=c.some(e=>e.contains_complex_set);if(o&&c.length>1&&u)throw SyntaxError(`Unsupported outer-negated character-class intersection with a nested negated class containing a Unicode property, POSIX class, or shorthand at index ${t}`);let i=os(c[0]),d=i;if(c.length>1){let e=``;for(let t=1;t0&&(f?(p+=e,d=`[${p}]`):d=as([d,`[${e}]`]))}return{atom:o?f?`[^${p}]`:`(?:(?!${d})${Qo})`:d,end:a+1,negated:o,contains_complex_set:e,contains_nested_negated_complex_set:u}}if(e.startsWith(`&&`,a)){if(l.tail===null)throw SyntaxError(`Malformed character-class intersection with an empty operand at index ${a}`);l=es(),c.push(l),a+=2;continue}if(d===`[`){let t=e.slice(a);if(Go.test(t))throw SyntaxError(`Malformed empty negated POSIX character class at index ${a}`);let r=Wo.exec(t);if(r){let[,e,t]=r,i=Bo.get(t);if(i===void 0)throw SyntaxError(`Unsupported POSIX character class "${t}" at index ${a}`);if(n&&e&&(t===`lower`||t===`upper`))throw SyntaxError(`Unsupported negated POSIX ${t} class inside an inline case-insensitive group`);e?ns(l,`[^${i}]`,a):rs(l,i,!0,a),a+=r[0].length;continue}if(Ko.test(t))throw SyntaxError(`Unsupported POSIX collating or equivalence bracket expression at index ${a}`);let o=cs(e,a,n,!1,i+1);ns(l,o.atom,a,o.contains_complex_set),u||=o.contains_nested_negated_complex_set||o.negated&&o.contains_complex_set,a=o.end;continue}if(d===`-`){let t=e[a+1]===`]`||e.startsWith(`&&`,a+1);l.tail===`set`&&!t&&ts(a),l.tail===null||l.tail===`range`||l.tail===`complete_range`||t?rs(l,`\\-`):(l.fragment+=`-`,l.tail=`range`),++a;continue}rs(l,d===`^`&&l.fragment.length===0?`\\^`:d),a+=d.length}throw SyntaxError(`${c.length>1?`Unterminated character-class intersection`:`Unterminated character class`} at index ${t}`)},ls=e=>{let t=``,n=-1,r=!1,i=!1,a=[],o=e=>{n=t.length,t+=e,r=!1};for(let s=0;s=e.length){t+=c;break}let a=Yo(e,s+1);if(s+=1+a.length,a===`G`)continue;let l=zo.get(a);if(l!==void 0){o(l);continue}let u=Io.get(a),d;d=u===void 0?/[A-Za-z0-9]/.test(a)||Vo.includes(a)?`\\${a}`:a:u,o(d);continue}switch(c){case`[`:{let t=cs(e,s,i);o(t.atom),s=t.end;continue}case`]`:o(`\\]`),++s;continue;case`.`:o(`[^\\n]`),++s;continue;case`^`:o(No),++s;continue;case`$`:o(Po),++s;continue;case`(`:{let n=e.startsWith(`(?i:`,s),o=n?`(?i:`:Ho.exec(e.slice(s))?.[0]??`(`,c=n||o===`(?>`?`(?:`:o;a.push([t.length,i]),n&&(i=!0),t+=c,r=!1,s+=o.length;continue}case`)`:t+=c,[n,i]=a.pop()??[-1,!1],r=!1,++s;continue;case`|`:t+=c,n=-1,r=!1,++s;continue;case`{`:{let i=Uo.exec(e.slice(s));if(!i||n<0){o(`\\{`),++s;continue}let a=i[1].startsWith(`,`)?`0${i[1]}`:i[1];s+=i[0].length;let c=e[s];c===`+`||c===`*`?(t=`${t.slice(0,n)}(?:${t.slice(n)}{${a}})${c}`,++s):t+=`{${a}}`,r=!0;continue}case`}`:o(`\\}`),++s;continue;case`+`:if(r){++s;continue}t+=c,r=!0,++s;continue;case`*`:case`?`:t+=c,r=!0,++s;continue;default:o(i&&Jo(c)?`[${c.toLowerCase()}${c.toUpperCase()}]`:c),s+=c.length;continue}}return t},us=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),ds=(e,t,n)=>{let r=[],i=0;for(;ie>=19968&&e<=40959||e>=13312&&e<=19903||e>=131072&&e<=173791||e>=173824&&e<=177983||e>=177984&&e<=178207||e>=178208&&e<=183983||e>=63744&&e<=64255||e>=194560&&e<=195103,ps=e=>Number.isInteger(e)||typeof e==`bigint`,ms=e=>{let t=0;for(let n of e)++t;return t},hs=e=>ys(e.toLowerCase()),gs=(...e)=>Array.prototype.concat.apply([],e),_s=e=>new Map(Object.entries(e)),vs=(e,t)=>{let n=[],r=0;for(let i of e.matchAll(t)){let t=i[0];r0&&n.push(t),r=i.index+t.length}return re.replace(/\p{M}/gu,``),bs=(e,t,n=[])=>{if(!e||Array.isArray(e)||typeof e!=`object`)return`${t} must be a valid object`;for(let r of n)if(!(r in e))return`${t} must contain a "${r}" property`;return null},xs=e=>e.match(/\S+/g)||[],Ss=class{constructor(){let e=function(...t){return e._call(...t)};return Object.setPrototypeOf(e,new.target.prototype)}},Cs=class extends Ss{constructor(e){super(),this.config=e}_call(e){return this.normalize(e)}},ws=class extends Cs{tokenize_chinese_chars(e){let t=[];for(let n=0;ne.normalize(`NFKC`)).join(`~`):e.normalize(`NFKC`),e}},Es=class extends Cs{constructor(e){super(e),this.normalizers=(e.normalizers??[]).map(e=>Rs(e))}normalize(e){return this.normalizers.reduce((e,t)=>t?t.normalize(e):e,e)}},Ds=class extends Cs{constructor(e){super(e),this.pattern=Eo(this.config.pattern??{})}normalize(e){return this.pattern===null?e:e.replaceAll(this.pattern,this.config.content??``)}},Os=class extends Cs{constructor(){super(...arguments),this.form=`NFC`}normalize(e){return e=e.normalize(this.form),e}},ks=class extends Os{constructor(){super(...arguments),this.form=`NFC`}},As=class extends Os{constructor(){super(...arguments),this.form=`NFD`}},js=class extends Os{constructor(){super(...arguments),this.form=`NFKC`}},Ms=class extends Os{constructor(){super(...arguments),this.form=`NFKD`}},Ns=class extends Cs{normalize(e){return this.config.strip_left&&this.config.strip_right?e=e.trim():(this.config.strip_left&&(e=e.trimStart()),this.config.strip_right&&(e=e.trimEnd())),e}},Ps=class extends Cs{normalize(e){return ys(e)}},Fs=class extends Cs{normalize(e){return e.toLowerCase()}},Is=class extends Cs{normalize(e){return e=this.config.prepend+e,e}};function Ls(e){if(e===null)return null;switch(e.type){case`BertNormalizer`:return new ws(e);case`Precompiled`:return new Ts(e);case`Sequence`:return new Es(e);case`Replace`:return new Ds(e);case`NFC`:return new ks(e);case`NFD`:return new As(e);case`NFKC`:return new js(e);case`NFKD`:return new Ms(e);case`Strip`:return new Ns(e);case`StripAccents`:return new Ps(e);case`Lowercase`:return new Fs(e);case`Prepend`:return new Is(e);default:throw Error(`Unknown Normalizer type: ${e.type}`)}}var Rs=Ls,zs=class extends Ss{pre_tokenize(e,t){return(Array.isArray(e)?e.map(e=>this.pre_tokenize_text(e,t)):this.pre_tokenize_text(e,t)).flat()}_call(e,t){return this.pre_tokenize(e,t)}},Bs=(()=>{let e=[...Array.from({length:94},(e,t)=>t+33),...Array.from({length:12},(e,t)=>t+161),...Array.from({length:82},(e,t)=>t+174)],t=e.slice(),n=0;for(let r=0;r<256;++r)e.includes(r)||(e.push(r),t.push(256+n),n+=1);let r=t.map(e=>String.fromCharCode(e));return Object.fromEntries(e.map((e,t)=>[e,r[t]]))})(),Vs=(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e])))(Bs),Hs=`\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E`,Us=class extends zs{constructor(e){super(),this.config=e,this.add_prefix_space=this.config.add_prefix_space??!1,this.trim_offsets=this.config.trim_offsets??!1,this.use_regex=this.config.use_regex??!0,this.pattern=/'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/gu,this.byte_encoder=Bs,this.text_encoder=new TextEncoder}pre_tokenize_text(e,t){return this.add_prefix_space&&!e.startsWith(` `)&&(e=` `+e),(this.use_regex?e.match(this.pattern)||[]:[e]).map(e=>Array.from(this.text_encoder.encode(e),e=>this.byte_encoder[e]).join(``))}},Ws=class extends zs{pre_tokenize_text(e,t){return e.match(/\w+|[^\w\s]+/g)||[]}},Gs=class extends zs{constructor(e){super(),this.replacement=e.replacement??`▁`,this.str_rep=e.str_rep||this.replacement,this.prepend_scheme=e.prepend_scheme??`always`}pre_tokenize_text(e,t){let{section_index:n=void 0}=t??{},r=e.replaceAll(` `,this.str_rep);return!r.startsWith(this.replacement)&&(this.prepend_scheme===`always`||this.prepend_scheme===`first`&&n===0)&&(r=this.str_rep+r),[r]}},Ks=class extends zs{constructor(e){super(),this.config=e,this.pattern=Eo(this.config.pattern??{},this.config.invert??!0)}pre_tokenize_text(e){return this.pattern===null?[]:this.config.invert?(e.match(this.pattern)||[]).filter(e=>e):this.config.behavior?.toLowerCase()===`removed`?e.split(this.pattern).filter(e=>e):vs(e,this.pattern)}},qs=class extends zs{constructor(e){super(),this.config=e,this.pattern=RegExp(`[^${Hs}]+|[${Hs}]+`,`gu`)}pre_tokenize_text(e){return e.match(this.pattern)||[]}},Js=class extends zs{constructor(e){super(),this.config=e;let t=`[^\\d]+|\\d${this.config.individual_digits?``:`+`}`;this.pattern=new RegExp(t,`gu`)}pre_tokenize_text(e){return e.match(this.pattern)||[]}},Ys=class extends zs{constructor(){super(),this.pattern=RegExp(`[^\\s${Hs}]+|[${Hs}]`,`gu`)}pre_tokenize_text(e,t){return e.trim().match(this.pattern)||[]}},Xs=class extends zs{constructor(e){super(),this.config=e,this.pattern=Eo(this.config.pattern??{}),this.content=this.config.content??``}pre_tokenize_text(e){return this.pattern===null?[e]:[e.replaceAll(this.pattern,this.config.content??``)]}},Zs=class extends zs{constructor(e){super(),this.tokenizers=(e.pretokenizers??[]).map(e=>tc(e))}pre_tokenize_text(e,t){return this.tokenizers.reduce((e,n)=>n?n.pre_tokenize(e,t):e,[e])}},Qs=class extends zs{pre_tokenize_text(e){return xs(e)}},$s=class extends zs{constructor(e){super(),this.config=e,this._length=e.length}pre_tokenize_text(e){let t=[];for(let n=0;nthis.max_input_chars_per_word){t.push(this.unk_token);continue}let r=!1,i=0,a=[];for(;i0&&(r=this.config.continuing_subword_prefix+r),this.tokens_to_ids.has(r)){n=r;break}--t}if(n===null){r=!0;break}a.push(n),i=t}r?t.push(this.unk_token):t.push(...a)}return t}},ic=class e{constructor(e,t){this.is_leaf=e,this.children=t}static default(){return new e(!1,new Map)}},ac=class{constructor(){this.root=ic.default()}extend(e){for(let t of e)this.push(t)}push(e){let t=this.root;for(let n of e){let e=t.children.get(n);e===void 0&&(e=ic.default(),t.children.set(n,e)),t=e}t.is_leaf=!0}*common_prefix_search(e,t=0){let n=this.root;if(n===void 0)return;let r=``;for(let i=t;i[]),this.end_nodes=Array.from({length:this.len+1},()=>[]);let r=new oc(this.bos_token_id??0,0,0,0,0),i=new oc(this.eos_token_id??0,1,this.len,0,0);this.nodes.push(r.clone()),this.nodes.push(i.clone()),this.begin_nodes[this.len].push(i),this.end_nodes[0].push(r)}insert(e,t,n,r){let i=this.nodes.length,a=new oc(r,i,e,t,n);this.begin_nodes[e].push(a),this.end_nodes[e+t].push(a),this.nodes.push(a)}viterbi(){let e=this.len,t=0;for(;t<=e;){if(this.begin_nodes[t].length==0)return[];for(let e of this.begin_nodes[t]){e.prev=null;let n=0,r=null;for(let i of this.end_nodes[t]){let t=i.backtrace_score+e.score;(r===null||t>n)&&(r=i.clone(),n=t)}if(r!==null)e.prev=r,e.backtrace_score=n;else return[]}++t}let n=[],r=this.begin_nodes[e][0].prev;if(r===null)return[];let i=r.clone();for(;i.prev!==null;)n.push(i.clone()),i=i.clone().prev.clone();return n.reverse(),n}piece(e){return this.chars.slice(e.pos,e.pos+e.length).join(``)}tokens(){return this.viterbi().map(e=>this.piece(e))}token_ids(){return this.viterbi().map(e=>e.token_id)}};function cc(e){if(e.length===0)throw Error(`Array must not be empty`);let t=e[0],n=0;for(let r=1;r[e,t])),this.bos_token=` `,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.unk_token=this.vocab[this.unk_token_id],this.min_score=cc(this.scores)[0],this.unk_score=this.min_score-10,this.scores[this.unk_token_id]=this.unk_score,this.trie=new ac,this.trie.extend(this.vocab),this.fuse_unk=!0}populate_nodes(e){let t=e.chars,n=0;for(;ne>t,t=1/0){this._heap=[],this._comparator=e,this._max_size=t}get size(){return this._heap.length}is_empty(){return this.size===0}peek(){return this._heap[0]}push(...e){return this.extend(e)}extend(e){for(let t of e)if(this.size0&&this._swap(0,t),this._heap.pop(),this._sift_down(),e}replace(e){let t=this.peek();return this._heap[0]=e,this._sift_down(),t}_parent(e){return(e+1>>>1)-1}_left(e){return(e<<1)+1}_right(e){return e+1<<1}_greater(e,t){return this._comparator(this._heap[e],this._heap[t])}_swap(e,t){let n=this._heap[e];this._heap[e]=this._heap[t],this._heap[t]=n}_sift_up(){this._sift_up_from(this.size-1)}_sift_up_from(e){for(;e>0&&this._greater(e,this._parent(e));)this._swap(e,this._parent(e)),e=this._parent(e)}_sift_down(){let e=0;for(;this._left(e)this.capacity&&this.cache.delete(this.cache.keys().next().value)}clear(){this.cache.clear()}},fc=class extends nc{constructor(e){super(e),this.tokens_to_ids=_s(e.vocab),this.unk_token_id=this.tokens_to_ids.get(e.unk_token),this.unk_token=e.unk_token,this.vocab=Array(this.tokens_to_ids.size);for(let[e,t]of this.tokens_to_ids)this.vocab[t]=e;let t=Array.isArray(e.merges[0]);this.merges=t?e.merges:e.merges.map(e=>e.split(` `,2)),this.bpe_ranks=new Map(this.merges.map((e,t)=>[JSON.stringify(e),t])),this.end_of_word_suffix=e.end_of_word_suffix,this.continuing_subword_suffix=e.continuing_subword_suffix??null,this.byte_fallback=this.config.byte_fallback??!1,this.byte_fallback&&(this.text_encoder=new TextEncoder),this.ignore_merges=this.config.ignore_merges??!1,this.max_length_to_cache=256,this.cache_capacity=1e4,this.cache=new dc(this.cache_capacity)}clear_cache(){this.cache.clear()}bpe(e){if(e.length===0)return[];let t=this.cache.get(e);if(t!==void 0)return t;let n=Array.from(e);this.end_of_word_suffix&&(n[n.length-1]+=this.end_of_word_suffix);let r=[];if(n.length>1){let e=new uc((e,t)=>e.score`<0x${e.toString(16).toUpperCase().padStart(2,`0`)}>`);e.every(e=>this.tokens_to_ids.has(e))?t.push(...e):this.unk_token!=null&&t.push(this.unk_token)}else this.unk_token!=null&&t.push(this.unk_token)}return t}},pc=class extends nc{constructor(e,t){super(e);let n=e.vocab;this.tokens_to_ids=_s(t.target_lang?n[t.target_lang]:n),this.bos_token=t.bos_token,this.bos_token_id=this.tokens_to_ids.get(this.bos_token),this.eos_token=t.eos_token,this.eos_token_id=this.tokens_to_ids.get(this.eos_token),this.pad_token=t.pad_token,this.pad_token_id=this.tokens_to_ids.get(this.pad_token),this.unk_token=t.unk_token,this.unk_token_id=this.tokens_to_ids.get(this.unk_token),this.vocab=Array(this.tokens_to_ids.size);for(let[e,t]of this.tokens_to_ids)this.vocab[t]=e}encode(e){return e}};function mc(e,t){switch(e.type){case`WordPiece`:return new rc(e);case`Unigram`:return new lc(e,t.eos_token);case`BPE`:return new fc(e);default:if(e.vocab)return Array.isArray(e.vocab)?new lc(e,t.eos_token):Object.hasOwn(e,`continuing_subword_prefix`)&&Object.hasOwn(e,`unk_token`)?Object.hasOwn(e,`merges`)?new fc(e):new rc(e):new pc(e,{target_lang:t.target_lang,bos_token:t.bos_token,eos_token:t.eos_token,pad_token:t.pad_token,unk_token:t.unk_token});throw Error(`Unknown TokenizerModel type: ${e?.type}`)}}var hc=mc,gc=class extends Ss{constructor(e){super(),this.config=e}_call(e,...t){return this.post_process(e,...t)}},_c=class extends gc{post_process(e,t=null,n=!0){let r=t===null?this.config.single:this.config.pair,i=[],a=[];for(let o of r)`SpecialToken`in o?n&&(i.push(o.SpecialToken.id),a.push(o.SpecialToken.type_id)):`Sequence`in o&&(o.Sequence.id===`A`?(i=gs(i,e),a=gs(a,Array(e.length).fill(o.Sequence.type_id))):o.Sequence.id===`B`&&(i=gs(i,t),a=gs(a,Array(t.length).fill(o.Sequence.type_id))));return{tokens:i,token_type_ids:a}}},vc=class extends gc{post_process(e,t=null){return{tokens:e,tokens_pair:t}}},yc=class extends gc{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t=null,n=!0){n&&(e=gs([this.cls[0]],e,[this.sep[0]]));let r=Array(e.length).fill(0);if(t){let i=[],a=n?[this.sep[0]]:[];e=gs(e,i,t,a),r=gs(r,Array(t.length+i.length+a.length).fill(1))}return{tokens:e,token_type_ids:r}}},bc=class extends gc{constructor(e){super(e),this.sep=e.sep,this.cls=e.cls}post_process(e,t,n=!0){n&&(e=gs([this.cls[0]],e,[this.sep[0]]));let r=Array(e.length).fill(0);if(t){let i=n?[this.sep[0]]:[],a=n?[this.sep[0]]:[];e=gs(e,i,t,a),r=gs(r,Array(t.length+i.length+a.length).fill(1))}return{tokens:e,token_type_ids:r}}},xc=class extends gc{constructor(e){super(e),this.processors=(e.processors??[]).map(e=>Cc(e))}post_process(e,t=null,n=!0){let r={tokens:e,tokens_pair:t};for(let e of this.processors)r=e.post_process(r.tokens,r.tokens_pair,n);return r}};function Sc(e){if(e===null)return null;switch(e.type){case`TemplateProcessing`:return new _c(e);case`ByteLevel`:return new vc(e);case`BertProcessing`:return new yc(e);case`RobertaProcessing`:return new bc(e);case`Sequence`:return new xc(e);default:throw Error(`Unknown PostProcessor type: ${e.type}`)}}var Cc=Sc,wc=class extends Ss{constructor(e){super(),this.config=e,this.added_tokens=[],this.end_of_word_suffix=null,this.trim_offsets=`trim_offsets`in e&&e.trim_offsets}_call(e){return this.decode(e)}decode(e){return this.decode_chain(e).join(``)}},Tc=class extends wc{constructor(e){super(e),this.byte_decoder=Vs,this.text_decoder=new TextDecoder(`utf-8`,{fatal:!1,ignoreBOM:!0}),this.end_of_word_suffix=null}convert_tokens_to_string(e){let t=e.join(``),n=new Uint8Array([...t].map(e=>this.byte_decoder[e]));return this.text_decoder.decode(n)}decode_chain(e){let t=[],n=[];for(let r of e)this.added_tokens.find(e=>e.content===r)===void 0?n.push(r):(n.length>0&&(t.push(this.convert_tokens_to_string(n)),n=[]),t.push(r));return n.length>0&&t.push(this.convert_tokens_to_string(n)),t}},Ec=class extends wc{constructor(e){super(e),this.cleanup=e.cleanup}decode_chain(e){return e.map((e,t)=>{if(t!==0){let t=this.config.prefix;e=t&&e.startsWith(t)?e.replace(t,``):` `+e}return this.cleanup&&(e=To(e)),e})}},Dc=class extends wc{constructor(e){super(e),this.replacement=e.replacement??`▁`}decode_chain(e){let t=[];for(let n=0;nt.replaceAll(this.suffix,n===e.length-1?``:` `))}},kc=class extends wc{constructor(e){super(e),this.pad_token=e.pad_token??``,this.word_delimiter_token=e.word_delimiter_token??``,this.cleanup=e.cleanup}convert_tokens_to_string(e){if(e.length===0)return``;let t=[e[0]];for(let n=1;ne!==this.pad_token).join(``);return this.cleanup&&(n=To(n).replaceAll(this.word_delimiter_token,` `).trim()),n}decode_chain(e){return[this.convert_tokens_to_string(e)]}},Ac=class extends wc{constructor(e){super(e),this.decoders=(e.decoders??[]).map(e=>Ic(e))}decode_chain(e){return this.decoders.reduce((e,t)=>t.decode_chain(e),e)}},jc=class extends wc{constructor(e){super(e),this.pattern=Eo(this.config.pattern)}decode_chain(e){let t=this.config.content??``,n=this.pattern;return n===null?e:e.map(e=>e.replaceAll(n,t))}},Mc=class extends wc{decode_chain(e){return[e.join(``)]}},Nc=class extends wc{constructor(e){super(e),this.content=e.content??``,this.start=e.start??0,this.stop=e.stop??0}decode_chain(e){return e.map(e=>{let t=0;for(let n=0;n`)){let t=parseInt(r.slice(3,5),16);isNaN(t)||(e=t)}if(e!==null)n.push(e);else{if(n.length>0){let e=this.text_decoder.decode(Uint8Array.from(n));t.push(e),n=[]}t.push(r)}}if(n.length>0){let e=this.text_decoder.decode(Uint8Array.from(n));t.push(e),n=[]}return t}};function Fc(e){if(e===null)return null;switch(e.type){case`ByteLevel`:return new Tc(e);case`WordPiece`:return new Ec(e);case`Metaspace`:return new Dc(e);case`BPEDecoder`:return new Oc(e);case`CTC`:return new kc(e);case`Sequence`:return new Ac(e);case`Replace`:return new jc(e);case`Fuse`:return new Mc(e);case`Strip`:return new Nc(e);case`ByteFallback`:return new Pc(e);default:throw Error(`Unknown Decoder type: ${e.type}`)}}var Ic=Fc,Lc=class{constructor(e,t){let n=bs(e,`Tokenizer`,[`model`,`decoder`,`post_processor`,`pre_tokenizer`,`normalizer`]);if(n)throw Error(n);let r=bs(t,`Config`);if(r)throw Error(r);this.tokenizer=e,this.config=t,this.normalizer=Rs(this.tokenizer.normalizer),this.pre_tokenizer=tc(this.tokenizer.pre_tokenizer),this.model=hc(this.tokenizer.model,this.config),this.post_processor=Cc(this.tokenizer.post_processor),this.decoder=Ic(this.tokenizer.decoder),this.special_tokens=[],this.all_special_ids=[],this.added_tokens=[];let i=[],a=[];this.added_tokens_map=new Map;for(let e of this.tokenizer.added_tokens){let t=new Co(e);if(this.added_tokens.push(t),this.model.tokens_to_ids.set(t.content,t.id),this.model.vocab[t.id]=t.content,t.special&&(this.special_tokens.push(t.content),this.all_special_ids.push(t.id)),this.added_tokens_map.set(t.content,t),t.normalized&&this.normalizer!==null){let e=this.normalizer(t.content);a.push(e),this.added_tokens_map.set(e,t)}else i.push(t.content)}(this.config.additional_special_tokens??[]).forEach(e=>{this.special_tokens.includes(e)||this.special_tokens.push(e)}),this.decoder&&(this.decoder.added_tokens=this.added_tokens,this.decoder.end_of_word_suffix=this.model.end_of_word_suffix),this.splitter_unnormalized=new So(i),this.splitter_normalized=new So(a),this.remove_space=this.config.remove_space,this.clean_up_tokenization_spaces=this.config.clean_up_tokenization_spaces??!0,this.do_lowercase_and_remove_accent=this.config.do_lowercase_and_remove_accent??!1}encode(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){let{tokens:i,token_type_ids:a}=this.tokenize_helper(e,{text_pair:t,add_special_tokens:n}),o=i.map(e=>this.added_tokens_map.get(e)?.id??this.model.tokens_to_ids.get(e)??this.model.unk_token_id),s={ids:o,tokens:i,attention_mask:Array(o.length).fill(1)};return r&&a&&(s.token_type_ids=a),s}decode(e,t={}){if(!Array.isArray(e)||e.length===0||!ps(e[0]))throw Error(`token_ids must be a non-empty array of integers.`);let n=e.map(e=>this.model.vocab[Number(e)]??this.model.unk_token);t.skip_special_tokens&&(n=n.filter(e=>!this.special_tokens.includes(e)));let r=this.decoder?this.decoder(n):n.join(` `);return this.decoder&&this.decoder.end_of_word_suffix&&(r=r.replaceAll(this.decoder.end_of_word_suffix,` `),t.skip_special_tokens&&(r=r.trim())),(t.clean_up_tokenization_spaces??this.clean_up_tokenization_spaces)&&(r=To(r)),r}tokenize(e,{text_pair:t=null,add_special_tokens:n=!1}={}){return this.tokenize_helper(e,{text_pair:t,add_special_tokens:n}).tokens}encode_text(e){if(e===null)return null;let t=this.splitter_unnormalized.split(e);return t.forEach((e,n)=>{let r=this.added_tokens_map.get(e);r&&(r.lstrip&&n>0&&(t[n-1]=t[n-1].trimEnd()),r.rstrip&&n{if(e.length===0)return[];if(this.added_tokens_map.has(e))return[e];if(this.remove_space===!0&&(e=e.trim().split(/\s+/).join(` `)),this.do_lowercase_and_remove_accent&&(e=hs(e)),this.normalizer!==null&&(e=this.normalizer(e)),e.length===0)return[];let n=this.splitter_normalized.split(e);return n.forEach((e,t)=>{let r=this.added_tokens_map.get(e);r&&(r.lstrip&&t>0&&(n[t-1]=n[t-1].trimEnd()),r.rstrip&&t{if(e.length===0)return[];if(this.added_tokens_map.has(e))return[e];let n=this.pre_tokenizer===null?[e]:this.pre_tokenizer(e,{section_index:t});return this.model(n)})})}tokenize_helper(e,{text_pair:t=null,add_special_tokens:n=!0}){let r=this.encode_text(e),i=this.encode_text(t||null);return this.post_processor?this.post_processor(r,i,n):{tokens:gs(r??[],i??[])}}token_to_id(e){return this.model.tokens_to_ids.get(e)}id_to_token(e){return this.model.vocab[e]}get_added_tokens_decoder(){let e=new Map;for(let t of this.added_tokens)e.set(t.id,t);return e}get_vocab(e=!0){let t=new Map;for(let n=0;nt in e?Rc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bc=(e,t,n)=>(zc(e,typeof t==`symbol`?t:t+``,n),n),H=Object.freeze({Text:`Text`,NumericLiteral:`NumericLiteral`,StringLiteral:`StringLiteral`,Identifier:`Identifier`,Equals:`Equals`,OpenParen:`OpenParen`,CloseParen:`CloseParen`,OpenStatement:`OpenStatement`,CloseStatement:`CloseStatement`,OpenExpression:`OpenExpression`,CloseExpression:`CloseExpression`,OpenSquareBracket:`OpenSquareBracket`,CloseSquareBracket:`CloseSquareBracket`,OpenCurlyBracket:`OpenCurlyBracket`,CloseCurlyBracket:`CloseCurlyBracket`,Comma:`Comma`,Dot:`Dot`,Colon:`Colon`,Pipe:`Pipe`,CallOperator:`CallOperator`,AdditiveBinaryOperator:`AdditiveBinaryOperator`,MultiplicativeBinaryOperator:`MultiplicativeBinaryOperator`,ExponentiationBinaryOperator:`ExponentiationBinaryOperator`,ComparisonBinaryOperator:`ComparisonBinaryOperator`,UnaryOperator:`UnaryOperator`,Comment:`Comment`}),Vc=class{constructor(e,t){this.value=e,this.type=t}};function Hc(e){return/\w/.test(e)}function Uc(e){return/[0-9]/.test(e)}function Wc(e){return/\s/.test(e)}var Gc=[[`{%`,H.OpenStatement],[`%}`,H.CloseStatement],[`{{`,H.OpenExpression],[`}}`,H.CloseExpression],[`(`,H.OpenParen],[`)`,H.CloseParen],[`{`,H.OpenCurlyBracket],[`}`,H.CloseCurlyBracket],[`[`,H.OpenSquareBracket],[`]`,H.CloseSquareBracket],[`,`,H.Comma],[`.`,H.Dot],[`:`,H.Colon],[`|`,H.Pipe],[`<=`,H.ComparisonBinaryOperator],[`>=`,H.ComparisonBinaryOperator],[`==`,H.ComparisonBinaryOperator],[`!=`,H.ComparisonBinaryOperator],[`<`,H.ComparisonBinaryOperator],[`>`,H.ComparisonBinaryOperator],[`+`,H.AdditiveBinaryOperator],[`-`,H.AdditiveBinaryOperator],[`~`,H.AdditiveBinaryOperator],[`**`,H.ExponentiationBinaryOperator],[`*`,H.MultiplicativeBinaryOperator],[`//`,H.MultiplicativeBinaryOperator],[`/`,H.MultiplicativeBinaryOperator],[`%`,H.MultiplicativeBinaryOperator],[`=`,H.Equals]],Kc=new Map([[`n`,` +`],[`t`,` `],[`r`,`\r`],[`b`,`\b`],[`f`,`\f`],[`v`,`\v`],[`'`,`'`],[`"`,`"`],[`\\`,`\\`]]);function qc(e,t={}){return e.endsWith(` +`)&&(e=e.slice(0,-1)),t.lstrip_blocks&&(e=e.replace(/^[ \t]*({[#%-])/gm,`$1`)),t.trim_blocks&&(e=e.replace(/([#%-]})\n/g,`$1`)),e.replace(/(\s*){%(-?)\s*(?:end)?generation\s*(-?)%}(\s*)/gs,(e,t,n,r,i)=>(n?``:t)+(r?``:i))}function Jc(e,t={}){let n=[],r=qc(e,t),i=0,a=0,o=e=>{let t=``;for(;e(r[i]);){if(r[i]===`\\`){if(++i,i>=r.length)throw SyntaxError(`Unexpected end of input`);let e=r[i++],n=Kc.get(e);if(n===void 0)throw SyntaxError(`Unexpected escaped character: ${e}`);t+=n;continue}if(t+=r[i++],i>=r.length)throw SyntaxError(`Unexpected end of input`)}return t},s=()=>{let e=n.at(-1);e&&e.type===H.Text&&(e.value=e.value.trimEnd(),e.value===``&&n.pop())},c=()=>{for(;i0){n.push(new Vc(e,H.Text));continue}}if(r[i]===`{`&&r[i+1]===`#`){i+=2;let e=r[i]===`-`;e&&++i;let t=``;for(;r[i]!==`#`||r[i+1]!==`}`;){if(i+2>=r.length)throw SyntaxError(`Missing end of comment tag`);t+=r[i++]}let a=t.endsWith(`-`);a&&(t=t.slice(0,-1)),e&&s(),n.push(new Vc(t,H.Comment)),i+=2,a&&c();continue}if(r.slice(i,i+3)===`{%-`){s(),n.push(new Vc(`{%`,H.OpenStatement)),i+=3;continue}if(r.slice(i,i+3)===`{{-`){s(),n.push(new Vc(`{{`,H.OpenExpression)),a=0,i+=3;continue}if(o(Wc),r.slice(i,i+3)===`-%}`){n.push(new Vc(`%}`,H.CloseStatement)),i+=3,c();continue}if(r.slice(i,i+3)===`-}}`){n.push(new Vc(`}}`,H.CloseExpression)),i+=3,c();continue}let t=r[i];if(t===`-`||t===`+`){let e=n.at(-1)?.type;if(e===H.Text||e===void 0)throw SyntaxError(`Unexpected character: ${t}`);switch(e){case H.Identifier:case H.NumericLiteral:case H.StringLiteral:case H.CloseParen:case H.CloseSquareBracket:break;default:{++i;let e=o(Uc);if(e.length>0&&r[i]===`.`&&Uc(r[i+1])){++i;let t=o(Uc);e=`${e}.${t}`}n.push(new Vc(`${t}${e}`,e.length>0?H.NumericLiteral:H.UnaryOperator));continue}}}for(let[e,t]of Gc)if(!(e===`}}`&&a>0)&&r.slice(i,i+e.length)===e){n.push(new Vc(e,t)),t===H.OpenExpression?a=0:t===H.OpenCurlyBracket?++a:t===H.CloseCurlyBracket&&--a,i+=e.length;continue main}if(t===`'`||t===`"`){++i;let e=o(e=>e!==t);n.push(new Vc(e,H.StringLiteral)),++i;continue}if(Uc(t)){let e=o(Uc);if(n.at(-1)?.type!==H.Dot&&r[i]===`.`&&Uc(r[i+1])){++i;let t=o(Uc);e=`${e}.${t}`}n.push(new Vc(e,H.NumericLiteral));continue}if(Hc(t)){let e=o(Hc);n.push(new Vc(e,H.Identifier));continue}throw SyntaxError(`Unexpected character: ${t}`)}return n}var Yc=class{type=`Statement`},Xc=class extends Yc{constructor(e){super(),this.body=e}type=`Program`},Zc=class extends Yc{constructor(e,t,n){super(),this.test=e,this.body=t,this.alternate=n}type=`If`},Qc=class extends Yc{constructor(e,t,n,r){super(),this.loopvar=e,this.iterable=t,this.body=n,this.defaultBlock=r}type=`For`},$c=class extends Yc{type=`Break`},el=class extends Yc{type=`Continue`},tl=class extends Yc{constructor(e,t,n){super(),this.assignee=e,this.value=t,this.body=n}type=`Set`},nl=class extends Yc{constructor(e,t,n){super(),this.name=e,this.args=t,this.body=n}type=`Macro`},rl=class extends Yc{constructor(e){super(),this.value=e}type=`Comment`},il=class extends Yc{type=`Expression`},al=class extends il{constructor(e,t,n){super(),this.object=e,this.property=t,this.computed=n}type=`MemberExpression`},ol=class extends il{constructor(e,t){super(),this.callee=e,this.args=t}type=`CallExpression`},sl=class extends il{constructor(e){super(),this.value=e}type=`Identifier`},cl=class extends il{constructor(e){super(),this.value=e}type=`Literal`},ll=class extends cl{type=`IntegerLiteral`},ul=class extends cl{type=`FloatLiteral`},dl=class extends cl{type=`StringLiteral`},fl=class extends cl{type=`ArrayLiteral`},pl=class extends cl{type=`TupleLiteral`},ml=class extends cl{type=`ObjectLiteral`},hl=class extends il{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}type=`BinaryExpression`},gl=class extends il{constructor(e,t){super(),this.operand=e,this.filter=t}type=`FilterExpression`},_l=class extends Yc{constructor(e,t){super(),this.filter=e,this.body=t}type=`FilterStatement`},vl=class extends il{constructor(e,t){super(),this.lhs=e,this.test=t}type=`SelectExpression`},yl=class extends il{constructor(e,t,n){super(),this.operand=e,this.negate=t,this.test=n}type=`TestExpression`},bl=class extends il{constructor(e,t){super(),this.operator=e,this.argument=t}type=`UnaryExpression`},xl=class extends il{constructor(e=void 0,t=void 0,n=void 0){super(),this.start=e,this.stop=t,this.step=n}type=`SliceExpression`},Sl=class extends il{constructor(e,t){super(),this.key=e,this.value=t}type=`KeywordArgumentExpression`},Cl=class extends il{constructor(e){super(),this.argument=e}type=`SpreadExpression`},wl=class extends il{constructor(e){super(),this.argument=e}type=`KeywordSpreadExpression`},Tl=class extends Yc{constructor(e,t,n){super(),this.call=e,this.callerArgs=t,this.body=n}type=`CallStatement`},El=class extends il{constructor(e,t,n){super(),this.condition=e,this.trueExpr=t,this.falseExpr=n}type=`Ternary`};function Dl(e){let t=new Xc([]),n=0;function r(t,r){let i=e[n++];if(!i||i.type!==t)throw Error(`Parser Error: ${r}. ${i.type} !== ${t}.`);return i}function i(e){if(!c(e))throw SyntaxError(`Expected ${e}`);++n}function a(){switch(e[n].type){case H.Comment:return new rl(e[n++].value);case H.Text:return l();case H.OpenStatement:return u();case H.OpenExpression:return d();default:throw SyntaxError(`Unexpected token type: ${e[n].type}`)}}function o(...t){return n+t.length<=e.length&&t.every((t,r)=>t===e[n+r].type)}function s(...t){return e[n]?.type===H.OpenStatement&&e[n+1]?.type===H.Identifier&&t.includes(e[n+1]?.value)}function c(...t){return n+t.length<=e.length&&t.every((t,r)=>e[n+r].type===`Identifier`&&t===e[n+r].value)}function l(){return new dl(r(H.Text,`Expected text token`).value)}function u(){if(r(H.OpenStatement,`Expected opening statement token`),e[n].type!==H.Identifier)throw SyntaxError(`Unknown statement, got ${e[n].type}`);let t=e[n].value,c;switch(t){case`set`:++n,c=f();break;case`if`:++n,c=p(),r(H.OpenStatement,`Expected {% token`),i(`endif`),r(H.CloseStatement,`Expected %} token`);break;case`macro`:++n,c=m(),r(H.OpenStatement,`Expected {% token`),i(`endmacro`),r(H.CloseStatement,`Expected %} token`);break;case`for`:++n,c=g(),r(H.OpenStatement,`Expected {% token`),i(`endfor`),r(H.CloseStatement,`Expected %} token`);break;case`call`:{++n;let e=null;o(H.OpenParen)&&(e=T(`parameters`));let t=oe();if(t.type!==`Identifier`)throw SyntaxError(`Expected identifier following call statement`);let l=T(`call`);r(H.CloseStatement,`Expected closing statement token`);let u=[];for(;!s(`endcall`);)u.push(a());r(H.OpenStatement,`Expected '{%'`),i(`endcall`),r(H.CloseStatement,`Expected closing statement token`),c=new Tl(new ol(t,l),e,u);break}case`break`:++n,r(H.CloseStatement,`Expected closing statement token`),c=new $c;break;case`continue`:++n,r(H.CloseStatement,`Expected closing statement token`),c=new el;break;case`filter`:{++n;let e=oe();e instanceof sl&&o(H.OpenParen)&&(e=w(e)),r(H.CloseStatement,`Expected closing statement token`);let t=[];for(;!s(`endfilter`);)t.push(a());r(H.OpenStatement,`Expected '{%'`),i(`endfilter`),r(H.CloseStatement,`Expected '%}'`),c=new _l(e,t);break}default:throw SyntaxError(`Unknown statement type: ${t}`)}return c}function d(){r(H.OpenExpression,`Expected opening expression token`);let e=_();return r(H.CloseExpression,`Expected closing expression token`),e}function f(){let e=h(),t=null,c=[];if(o(H.Equals))++n,t=h();else{for(r(H.CloseStatement,`Expected %} token`);!s(`endset`);)c.push(a());r(H.OpenStatement,`Expected {% token`),i(`endset`)}return r(H.CloseStatement,`Expected closing statement token`),new tl(e,t,c)}function p(){let e=_();r(H.CloseStatement,`Expected closing statement token`);let t=[],i=[];for(;!s(`elif`,`else`,`endif`);)t.push(a());if(s(`elif`)){++n,++n;let e=p();i.push(e)}else if(s(`else`))for(++n,++n,r(H.CloseStatement,`Expected closing statement token`);!s(`endif`);)i.push(a());return new Zc(e,t,i)}function m(){let e=oe();if(e.type!==`Identifier`)throw SyntaxError(`Expected identifier following macro statement`);let t=T(`parameters`);r(H.CloseStatement,`Expected closing statement token`);let n=[];for(;!s(`endmacro`);)n.push(a());return new nl(e,t,n)}function h(e=!1){let t=e?oe:_,r=[t()],i=o(H.Comma);for(;i&&(++n,r.push(t()),o(H.Comma)););return i?new pl(r):r[0]}function g(){let e=h(!0);if(!(e instanceof sl||e instanceof pl))throw SyntaxError(`Expected identifier/tuple for the loop variable, got ${e.type} instead`);if(!c(`in`))throw SyntaxError("Expected `in` keyword following loop variable");++n;let t=_();r(H.CloseStatement,`Expected closing statement token`);let i=[];for(;!s(`endfor`,`else`);)i.push(a());let o=[];if(s(`else`))for(++n,++n,r(H.CloseStatement,`Expected closing statement token`);!s(`endfor`);)o.push(a());return new Qc(e,t,i,o)}function _(){return v()}function v(){let e=y();if(c(`if`)){++n;let t=y();return c(`else`)?(++n,new El(t,e,v())):new vl(e,t)}return e}function y(){let t=b();for(;c(`or`);){let r=e[n];++n;let i=b();t=new hl(r,t,i)}return t}function b(){let t=x();for(;c(`and`);){let r=e[n];++n;let i=x();t=new hl(r,t,i)}return t}function x(){let t;for(;c(`not`);){let r=e[n];++n,t=new bl(r,x())}return t??S()}function S(){let t=C();for(;;){let r;if(c(`not`,`in`))r=new Vc(`not in`,H.Identifier),n+=2;else if(c(`in`))r=e[n++];else if(o(H.ComparisonBinaryOperator))r=e[n++];else break;let i=C();t=new hl(r,t,i)}return t}function C(){let t=O();for(;o(H.AdditiveBinaryOperator);){let r=e[n];++n;let i=O();t=new hl(r,t,i)}return t}function ee(){let e=D(oe());return o(H.OpenParen)?w(e):e}function w(e){let t=new ol(e,T(`call`));return t=D(t),o(H.OpenParen)&&(t=w(t)),t}function T(e){r(H.OpenParen,`Expected opening parenthesis for arguments list`);let t=E(e);return r(H.CloseParen,`Expected closing parenthesis for arguments list`),t}function E(t){let r=[],i=new Set,a=!1,s=!1;for(;!o(H.CloseParen);){let c=o(H.ExponentiationBinaryOperator),l=o(H.MultiplicativeBinaryOperator)&&e[n].value===`*`;if(t===`parameters`&&(c||l))throw SyntaxError(`Argument unpacking is not allowed in parameter declarations`);if(c){if(++n,r.push(new wl(_())),o(H.Comma)&&++n,!o(H.CloseParen))throw SyntaxError("Expected closing parenthesis: `**` must be applied to the final argument");break}let u;if(l){if(s)throw SyntaxError("Only one `*` argument unpacking is allowed");s=!0,++n,u=new Cl(_())}else{if(u=_(),o(H.Equals)){if(++n,!(u instanceof sl))throw SyntaxError(t===`parameters`?`Expected identifier for parameter declaration`:`Expected identifier for keyword argument`);let e=_();u=new Sl(u,e)}if(t===`parameters`){if(!(u instanceof sl||u instanceof Sl))throw SyntaxError(`Expected identifier for parameter declaration`);let e=u instanceof sl?u.value:u.key.value;if(i.has(e))throw SyntaxError(`Duplicate parameter name: ${e}`);i.add(e)}if(u instanceof Sl)a=!0;else if(a)throw SyntaxError(t===`call`?`Positional arguments must come before keyword arguments`:`Non-default argument follows default argument`);else if(s)throw SyntaxError("Positional arguments must not follow `*` argument unpacking")}r.push(u),o(H.Comma)&&++n}return r}function te(){let e=[],t=!1;for(;!o(H.CloseSquareBracket);)o(H.Colon)?(e.push(void 0),++n,t=!0):(e.push(_()),o(H.Colon)&&(++n,t=!0));if(e.length===0)throw SyntaxError(`Expected at least one argument for member/slice expression`);if(t){if(e.length>3)throw SyntaxError(`Expected 0-3 arguments for slice expression`);return new xl(...e)}return e[0]}function D(t){for(;o(H.Dot)||o(H.OpenSquareBracket);){let i=e[n];++n;let a,o=i.type===H.OpenSquareBracket;if(o)a=te(),r(H.CloseSquareBracket,`Expected closing square bracket`);else if(a=oe(),a.type!==`Identifier`&&a.type!==`IntegerLiteral`)throw SyntaxError(`Expected identifier or integer following dot operator`);t=new al(t,a,o)}return t}function O(){let t=ne();for(;o(H.MultiplicativeBinaryOperator);){let r=e[n++],i=ne();t=new hl(r,t,i)}return t}function ne(){let t=re();for(;o(H.ExponentiationBinaryOperator);){let r=e[n++],i=re();t=new hl(r,t,i)}return t}function re(){let e=ie();for(;c(`is`);){++n;let t=c(`not`);t&&++n;let r=oe();if(!(r instanceof sl))throw SyntaxError(`Expected identifier for the test`);e=new yl(e,t,r)}return e}function ie(){let e=ae();for(;o(H.Pipe);){++n;let t=oe();if(!(t instanceof sl))throw SyntaxError(`Expected identifier for the filter`);o(H.OpenParen)&&(t=w(t)),e=new gl(e,t)}return e}function ae(){let t=e[n];if(t&&(t.type===H.UnaryOperator||t.type===H.AdditiveBinaryOperator)&&(t.value===`-`||t.value===`+`)){let t=e[n++];return new bl(t,ae())}return ee()}function oe(){let t=e[n++];switch(t.type){case H.NumericLiteral:{let e=t.value;return e.includes(`.`)?new ul(Number(e)):new ll(Number(e))}case H.StringLiteral:{let r=t.value;for(;o(H.StringLiteral);)r+=e[n++].value;return new dl(r)}case H.Identifier:return new sl(t.value);case H.OpenParen:{let e=h();return r(H.CloseParen,"Expected closing parenthesis, got ${tokens[current].type} instead."),e}case H.OpenSquareBracket:{let e=[];for(;!o(H.CloseSquareBracket);)e.push(_()),o(H.Comma)&&++n;return++n,new fl(e)}case H.OpenCurlyBracket:{let e=new Map;for(;!o(H.CloseCurlyBracket);){let t=_();r(H.Colon,`Expected colon between key and value in object literal`);let i=_();e.set(t,i),o(H.Comma)&&++n}return++n,new ml(e)}default:throw SyntaxError(`Unexpected token: ${t.type}`)}}for(;n0)for(let i=e;it;i+=n)r.push(i);return r}function kl(e,t,n,r=1){let i=Math.sign(r);i>=0?(t=(t??=0)<0?Math.max(e.length+t,0):Math.min(t,e.length),n=(n??=e.length)<0?Math.max(e.length+n,0):Math.min(n,e.length)):(t=(t??=e.length-1)<0?Math.max(e.length+t,-1):Math.min(t,e.length-1),n=(n??=-1)<-1?Math.max(e.length+n,-1):Math.min(n,e.length-1));let a=[];for(let o=t;i*oe.toUpperCase())}function jl(e){return Ml(new Date,e)}function Ml(e,t){let n=new Intl.DateTimeFormat(void 0,{month:`long`}),r=new Intl.DateTimeFormat(void 0,{month:`short`}),i=e=>e<10?`0`+e:e.toString();return t.replace(/%[YmdbBHM%]/g,t=>{switch(t){case`%Y`:return e.getFullYear().toString();case`%m`:return i(e.getMonth()+1);case`%d`:return i(e.getDate());case`%b`:return r.format(e);case`%B`:return n.format(e);case`%H`:return i(e.getHours());case`%M`:return i(e.getMinutes());case`%%`:return`%`;default:return t}})}function Nl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Pl(e,t,n,r){if(r===0)return e;let i=r==null||r<0?1/0:r,a=t.length===0?RegExp(`(?=)`,`gu`):new RegExp(Nl(t),`gu`);return e.replaceAll(a,e=>i>0?(--i,n):e)}var Fl=class extends Error{},Il=class extends Error{},Ll=new Map,Rl=class{type=`RuntimeValue`;value;get builtins(){return Ll}constructor(e=void 0){this.value=e}__bool__(){return new G(!!this.value)}toString(){return String(this.value)}},U=class extends Rl{type=`IntegerValue`},zl=class extends Rl{type=`FloatValue`;toString(){return Object.is(this.value,-0)?`-0.0`:this.value%1==0?this.value.toFixed(1):this.value.toString()}},W=class extends Rl{type=`StringValue`;_builtins;get builtins(){return this._builtins??=new Map([[`upper`,new ql(()=>new W(this.value.toUpperCase()))],[`lower`,new ql(()=>new W(this.value.toLowerCase()))],[`strip`,new ql(()=>new W(this.value.trim()))],[`title`,new ql(()=>new W(Al(this.value)))],[`capitalize`,new ql(()=>new W(this.value.charAt(0).toUpperCase()+this.value.slice(1)))],[`length`,new U(this.value.length)],[`rstrip`,new ql(()=>new W(this.value.trimEnd()))],[`lstrip`,new ql(()=>new W(this.value.trimStart()))],[`startswith`,new ql(e=>{if(e.length===0)throw Error(`startswith() requires at least one argument`);let t=e[0];if(t instanceof W)return new G(this.value.startsWith(t.value));if(t instanceof K){for(let e of t.value){if(!(e instanceof W))throw Error(`startswith() tuple elements must be strings`);if(this.value.startsWith(e.value))return new G(!0)}return new G(!1)}throw Error(`startswith() argument must be a string or tuple of strings`)})],[`endswith`,new ql(e=>{if(e.length===0)throw Error(`endswith() requires at least one argument`);let t=e[0];if(t instanceof W)return new G(this.value.endsWith(t.value));if(t instanceof K){for(let e of t.value){if(!(e instanceof W))throw Error(`endswith() tuple elements must be strings`);if(this.value.endsWith(e.value))return new G(!0)}return new G(!1)}throw Error(`endswith() argument must be a string or tuple of strings`)})],[`split`,new ql(e=>{let t=e[0]??new Jl;if(!(t instanceof W||t instanceof Jl))throw Error(`sep argument must be a string or null`);let n=e[1]??new U(-1);if(!(n instanceof U))throw Error(`maxsplit argument must be a number`);let r=[];if(t instanceof Jl){let e=this.value.trimStart();for(let{0:t,index:i}of e.matchAll(/\S+/g)){if(n.value!==-1&&r.length>=n.value&&i!==void 0){r.push(t+e.slice(i+t.length));break}r.push(t)}}else{if(t.value===``)throw Error(`empty separator`);r=this.value.split(t.value),n.value!==-1&&r.length>n.value&&r.push(r.splice(n.value).join(t.value))}return new K(r.map(e=>new W(e)))})],[`replace`,new ql(e=>{if(e.length<2)throw Error(`replace() requires at least two arguments`);let t=e[0],n=e[1];if(!(t instanceof W&&n instanceof W))throw Error(`replace() arguments must be strings`);let r;if(r=e.length>2?e[2].type===`KeywordArgumentsValue`?e[2].value.get(`count`)??new Jl:e[2]:new Jl,!(r instanceof U||r instanceof Jl))throw Error(`replace() count argument must be a number or null`);return new W(Pl(this.value,t.value,n.value,r.value))})]])}},G=class extends Rl{type=`BooleanValue`},Bl=/[\x7f-\uffff]/g;function Vl(e){return e.replace(Bl,e=>`\\u`+e.charCodeAt(0).toString(16).padStart(4,`0`))}function Hl(e,t={},n=0,r=!0){let{indent:i=null,ensureAscii:a=!1,separators:o=null,sortKeys:s=!1}=t,c,l;switch(o?[c,l]=o:i?(c=`,`,l=`: `):(c=`, `,l=`: `),e.type){case`NullValue`:return`null`;case`UndefinedValue`:return r?`null`:`undefined`;case`IntegerValue`:case`FloatValue`:case`BooleanValue`:return JSON.stringify(e.value);case`StringValue`:{let t=JSON.stringify(e.value);return a&&(t=Vl(t)),t}case`ArrayValue`:case`NamespaceValue`:case`ObjectValue`:{let o=i?` `.repeat(i):``,u=` +`+o.repeat(n),d=u+o;if(e.type===`ArrayValue`){let a=e.value.map(e=>Hl(e,t,n+1,r));return i?`[${d}${a.join(`${c}${d}`)}${u}]`:`[${a.join(c)}]`}{let o=Array.from(e.value.entries());s&&(o=o.sort(([e],[t])=>e.localeCompare(t)));let f=o.map(([e,o])=>{let s=JSON.stringify(e);a&&(s=Vl(s));let c=`${s}${l}${Hl(o,t,n+1,r)}`;return i?`${d}${c}`:c});return i?`{${f.join(c)}${u}}`:`{${f.join(c)}}`}}default:throw Error(`Cannot convert to JSON: ${e.type}`)}}var Ul=class extends Rl{type=`ObjectValue`;_builtins;__bool__(){return new G(this.value.size>0)}get builtins(){return this._builtins??=new Map([[`get`,new ql(([e,t])=>{if(!(e instanceof W))throw Error(`Object key must be a string: got ${e.type}`);return this.value.get(e.value)??t??new Jl})],[`items`,new ql(()=>this.items())],[`keys`,new ql(()=>this.keys())],[`values`,new ql(()=>this.values())],[`dictsort`,new ql(e=>{let t=new Map,n=e.filter(e=>e instanceof Wl?(t=e.value,!1):!0),r=n.at(0)??t.get(`case_sensitive`)??new G(!1);if(!(r instanceof G))throw Error(`case_sensitive must be a boolean`);let i=n.at(1)??t.get(`by`)??new W(`key`);if(!(i instanceof W))throw Error(`by must be a string`);if(![`key`,`value`].includes(i.value))throw Error(`by must be either 'key' or 'value'`);let a=n.at(2)??t.get(`reverse`)??new G(!1);if(!(a instanceof G))throw Error(`reverse must be a boolean`);return new K(Array.from(this.value.entries()).map(([e,t])=>new K([new W(e),t])).sort((e,t)=>{let n=i.value===`key`?0:1,o=e.value[n],s=t.value[n],c=iu(o,s,r.value);return a.value?-c:c}))})]])}items(){return new K(Array.from(this.value.entries()).map(([e,t])=>new K([new W(e),t])))}keys(){return new K(Array.from(this.value.keys()).map(e=>new W(e)))}values(){return new K(Array.from(this.value.values()))}toString(){return Hl(this,{},0,!1)}},Wl=class extends Ul{type=`KeywordArgumentsValue`},Gl=class extends Rl{type=`NamespaceValue`;toString(){return Hl(this,{},0,!1)}},K=class extends Rl{type=`ArrayValue`;_builtins;get builtins(){return this._builtins??=new Map([[`length`,new U(this.value.length)]])}__bool__(){return new G(this.value.length>0)}toString(){return Hl(this,{},0,!1)}},Kl=class extends K{type=`TupleValue`},ql=class extends Rl{type=`FunctionValue`},Jl=class extends Rl{type=`NullValue`},Yl=class extends Rl{type=`UndefinedValue`};function Xl(e){let t;if(e instanceof K?t=e.value:e instanceof W&&(t=Array.from(e.value,e=>new W(e))),!t||t.length!==2)throw Error(`namespace expected an object or an iterable of [key, value] pairs`);let[n,r]=t;if(!(n instanceof W))throw Error(`namespace keys must be strings`);return[n,r]}var Zl=class{constructor(e){this.parent=e}variables=new Map([[`namespace`,new ql(e=>{let t=e.slice(),n;if(t.at(-1)instanceof Wl&&(n=t.pop()),t.length>1)throw Error(`namespace expected at most 1 argument, got ${t.length}`);let r=new Map;if(t.length===1){let e=t[0];if(e instanceof Ul)for(let[t,n]of e.value)r.set(t,n);else if(e instanceof K)for(let t of e.value){let[e,n]=Xl(t);r.set(e.value,n)}else throw Error(`'${e.type}' object is not iterable`)}if(n)for(let[e,t]of n.value)r.set(e,t);return new Gl(r)})]]);tests=Zl.TESTS;set(e,t){return this.declareVariable(e,lu(t))}declareVariable(e,t){if(this.variables.has(e))throw SyntaxError(`Variable already declared: ${e}`);return this.variables.set(e,t),t}setVariable(e,t){return this.variables.set(e,t),t}resolve(e){if(this.variables.has(e))return this;if(this.parent)return this.parent.resolve(e);throw Error(`Unknown variable: ${e}`)}lookupVariable(e){try{return this.resolve(e).variables.get(e)??new Yl}catch{return new Yl}}},Ql=Zl;Bc(Ql,`TESTS`,new Map([[`boolean`,e=>e.type===`BooleanValue`],[`callable`,e=>e instanceof ql],[`odd`,e=>{if(!(e instanceof U))throw Error(`cannot odd on ${e.type}`);return e.value%2!=0}],[`even`,e=>{if(!(e instanceof U))throw Error(`cannot even on ${e.type}`);return e.value%2==0}],[`false`,e=>e.type===`BooleanValue`&&!e.value],[`true`,e=>e.type===`BooleanValue`&&e.value],[`none`,e=>e.type===`NullValue`],[`string`,e=>e.type===`StringValue`],[`number`,e=>e instanceof U||e instanceof zl],[`integer`,e=>e instanceof U],[`iterable`,e=>e.type===`ArrayValue`||e.type===`StringValue`],[`mapping`,e=>e instanceof Ul],[`sequence`,e=>e instanceof K||e instanceof Ul||e instanceof W],[`lower`,e=>{let t=e.value;return e.type===`StringValue`&&t===t.toLowerCase()}],[`upper`,e=>{let t=e.value;return e.type===`StringValue`&&t===t.toUpperCase()}],[`none`,e=>e.type===`NullValue`],[`defined`,e=>e.type!==`UndefinedValue`],[`undefined`,e=>e.type===`UndefinedValue`],[`equalto`,(e,t)=>e.value===t.value],[`eq`,(e,t)=>e.value===t.value]]));function $l(e){e.set(`false`,!1),e.set(`true`,!0),e.set(`none`,null),e.set(`raise_exception`,e=>{throw Error(e)}),e.set(`range`,Ol),e.set(`strftime_now`,jl),e.set(`True`,!0),e.set(`False`,!1),e.set(`None`,null)}function eu(e){return e instanceof Ul||e instanceof Gl}function tu(e){return e instanceof U||e instanceof zl||e instanceof G}function nu(e){return e instanceof G?Number(e.value):e.value}function ru(e,t){let n=t.split(`.`),r=e;for(let e of n)if(eu(r))r=r.value.get(e)??new Yl;else if(r instanceof K){let t=parseInt(e,10);if(!isNaN(t)&&t>=0&&tr)}if(e.type!==t.type)throw Error(`Cannot compare different types: ${e.type} and ${t.type}`);switch(e.type){case`StringValue`:{let r=e.value,i=t.value;return n||(r=r.toLowerCase(),i=i.toLowerCase()),ri)}default:throw Error(`Cannot compare type: ${e.type}`)}}function au(e){if(e.type===`Identifier`)return{name:e.value};let t=e;return{name:t.key.value,defaultValue:t.value}}function ou(e){return e===`kwargs`||e===`varargs`}function su(e,t){let n=new Set,r=new Set,i=e=>{ou(e)&&n.add(e)},a=e=>{if(e.type===`Identifier`)i(e.value);else if(e.type===`TupleLiteral`)for(let t of e.value)a(t)},o=e=>{i(au(e).name)},s=e=>{for(let t of e){let e=au(t);e.defaultValue&&l(e.defaultValue)}},c=e=>{e.type===`CallExpression`&&l(e.args)},l=e=>{if(Array.isArray(e)){for(let t of e)l(t);return}if(e instanceof Map){for(let[t,n]of e)l(t),l(n);return}if(e instanceof Yc)switch(e.type){case`For`:{let t=e;if(a(t.loopvar),t.iterable.type===`SelectExpression`){let e=t.iterable;l(e.lhs),l(t.body),l(t.defaultBlock),l(e.test);return}l(t.iterable),l(t.body),l(t.defaultBlock);return}case`Set`:{let t=e;a(t.assignee),l(t.value),l(t.body);return}case`Macro`:{let t=e;for(let e of t.args)o(e);s(t.args),l(t.body);return}case`CallStatement`:{let t=e;l(t.call);for(let e of t.callerArgs??[])o(e);s(t.callerArgs??[]),l(t.body);return}case`FilterStatement`:{let t=e;l(t.body),c(t.filter);return}case`Identifier`:{let t=e.value;ou(t)&&!n.has(t)&&r.add(t);return}case`MemberExpression`:{let t=e;l(t.object),t.computed&&l(t.property);return}case`FilterExpression`:{let t=e;l(t.operand),c(t.filter);return}case`TestExpression`:l(e.operand);return;case`SelectExpression`:{let t=e;l(t.test),l(t.lhs);return}case`KeywordArgumentExpression`:l(e.value);return;default:for(let t of Object.values(e))l(t)}};for(let t of e)o(t);return l(t),r}var cu=class{global;constructor(e){this.global=e??new Ql}run(e){return this.evaluate(e,this.global)}evaluateBinaryExpression(e,t){let n=this.evaluate(e.left,t);switch(e.operator.value){case`and`:return n.__bool__().value?this.evaluate(e.right,t):n;case`or`:return n.__bool__().value?n:this.evaluate(e.right,t)}let r=this.evaluate(e.right,t);switch(e.operator.value){case`==`:return new G(n.value==r.value);case`!=`:return new G(n.value!=r.value)}if(n instanceof Yl||r instanceof Yl){if(r instanceof Yl&&[`in`,`not in`].includes(e.operator.value))return new G(e.operator.value===`not in`);throw Error(`Cannot perform operation ${e.operator.value} on undefined values`)}if(n instanceof Jl||r instanceof Jl)throw Error(`Cannot perform operation on null values`);if(e.operator.value===`~`)return new W(n.value.toString()+r.value.toString());if(e.operator.value===`**`&&tu(n)&&tu(r)){let e=nu(n),t=nu(r);if(e===0&&t<0)throw Error(`0.0 cannot be raised to a negative power`);let i=e**t;if(!Number.isFinite(i))throw Error(`Exponentiation result is not a finite real number`);return n instanceof zl||r instanceof zl||t<0?new zl(i):new U(i)}if((n instanceof U||n instanceof zl)&&(r instanceof U||r instanceof zl)){let t=n.value,i=r.value;switch(e.operator.value){case`+`:case`-`:case`*`:{let a=e.operator.value===`+`?t+i:e.operator.value===`-`?t-i:t*i;return n instanceof zl||r instanceof zl?new zl(a):new U(a)}case`/`:return new zl(t/i);case`//`:{let e=Math.floor(t/i);return n instanceof zl||r instanceof zl?new zl(e):new U(e)}case`%`:{let e=t%i;return n instanceof zl||r instanceof zl?new zl(e):new U(e)}case`<`:return new G(t`:return new G(t>i);case`>=`:return new G(t>=i);case`<=`:return new G(t<=i)}}else if(n instanceof K&&r instanceof K)switch(e.operator.value){case`+`:return new K(n.value.concat(r.value))}else if(r instanceof K){let t=r.value.find(e=>e.value===n.value)!==void 0;switch(e.operator.value){case`in`:return new G(t);case`not in`:return new G(!t)}}if(n instanceof W||r instanceof W)switch(e.operator.value){case`+`:return new W(n.value.toString()+r.value.toString())}if(n instanceof W&&r instanceof W)switch(e.operator.value){case`in`:return new G(r.value.includes(n.value));case`not in`:return new G(!r.value.includes(n.value))}if(n instanceof W&&r instanceof Ul)switch(e.operator.value){case`in`:return new G(r.value.has(n.value));case`not in`:return new G(!r.value.has(n.value))}throw SyntaxError(`Unknown operator "${e.operator.value}" between ${n.type} and ${r.type}`)}evaluateArguments(e,t){let n=[],r=new Map,i=(e,t)=>{if(r.has(e))throw Error(`Got multiple values for keyword argument '${e}'`);r.set(e,t)};for(let r of e)if(r.type===`SpreadExpression`){let e=r,i=this.evaluate(e.argument,t);if(!(i instanceof K))throw Error(`Cannot unpack non-iterable type: ${i.type}`);for(let e of i.value)n.push(e)}else r.type!==`KeywordArgumentExpression`&&r.type!==`KeywordSpreadExpression`&&n.push(this.evaluate(r,t));for(let n of e)if(n.type===`KeywordArgumentExpression`){let e=n;i(e.key.value,this.evaluate(e.value,t))}else if(n.type===`KeywordSpreadExpression`){let e=n,r=this.evaluate(e.argument,t);if(!(r instanceof Ul))throw Error(`Argument after ** must be a mapping, not ${r.type}`);for(let[e,t]of r.value)i(e,t)}return[n,r]}applyFilter(e,t,n){if(t.type===`Identifier`){let r=t;if(r.value===`safe`)return e;if(r.value===`tojson`)return new W(Hl(e,{}));if(e instanceof K)switch(r.value){case`list`:return e;case`first`:return e.value[0];case`last`:return e.value[e.value.length-1];case`length`:return new U(e.value.length);case`reverse`:return new K(e.value.slice().reverse());case`sort`:return new K(e.value.slice().sort((e,t)=>iu(e,t,!1)));case`join`:return new W(e.value.map(e=>e.value).join(``));case`string`:return new W(Hl(e,{},0,!1));case`unique`:{let t=new Set,n=[];for(let r of e.value)t.has(r.value)||(t.add(r.value),n.push(r));return new K(n)}default:throw Error(`Unknown ArrayValue filter: ${r.value}`)}else if(e instanceof W)switch(r.value){case`length`:case`upper`:case`lower`:case`title`:case`capitalize`:{let t=e.builtins.get(r.value);if(t instanceof ql)return t.value([],n);if(t instanceof U)return t;throw Error(`Unknown StringValue filter: ${r.value}`)}case`trim`:return new W(e.value.trim());case`indent`:return new W(e.value.split(` +`).map((e,t)=>t===0||e.length===0?e:` `+e).join(` +`));case`join`:case`string`:return e;case`int`:{let t=parseInt(e.value,10);return new U(isNaN(t)?0:t)}case`float`:{let t=parseFloat(e.value);return new zl(isNaN(t)?0:t)}default:throw Error(`Unknown StringValue filter: ${r.value}`)}else if(e instanceof U||e instanceof zl)switch(r.value){case`abs`:return e instanceof U?new U(Math.abs(e.value)):new zl(Math.abs(e.value));case`int`:return new U(Math.floor(e.value));case`float`:return new zl(e.value);case`string`:return new W(e.toString());default:throw Error(`Unknown NumericValue filter: ${r.value}`)}else if(e instanceof Ul)switch(r.value){case`items`:return new K(Array.from(e.value.entries()).map(([e,t])=>new K([new W(e),t])));case`length`:return new U(e.value.size);default:{let t=e.builtins.get(r.value);if(t)return t instanceof ql?t.value([],n):t;throw Error(`Unknown ObjectValue filter: ${r.value}`)}}else if(e instanceof G)switch(r.value){case`bool`:return new G(e.value);case`int`:return new U(+!!e.value);case`float`:return new zl(+!!e.value);case`string`:return new W(e.value?`true`:`false`);default:throw Error(`Unknown BooleanValue filter: ${r.value}`)}throw Error(`Cannot apply filter "${r.value}" to type: ${e.type}`)}if(t.type===`CallExpression`){let r=t;if(r.callee.type!==`Identifier`)throw Error(`Unknown filter: ${r.callee.type}`);let i=r.callee.value;if(i===`tojson`){let[,t]=this.evaluateArguments(r.args,n),i=t.get(`indent`)??new Jl;if(!(i instanceof U||i instanceof Jl))throw Error(`If set, indent must be a number`);let a=t.get(`ensure_ascii`)??new G(!1);if(!(a instanceof G))throw Error(`If set, ensure_ascii must be a boolean`);let o=t.get(`sort_keys`)??new G(!1);if(!(o instanceof G))throw Error(`If set, sort_keys must be a boolean`);let s=t.get(`separators`)??new Jl,c=null;if(s instanceof K||s instanceof Kl){if(s.value.length!==2)throw Error(`separators must be a tuple of two strings`);let[e,t]=s.value;if(!(e instanceof W)||!(t instanceof W))throw Error(`separators must be a tuple of two strings`);c=[e.value,t.value]}else if(!(s instanceof Jl))throw Error(`If set, separators must be a tuple of two strings`);return new W(Hl(e,{indent:i.value,ensureAscii:a.value,sortKeys:o.value,separators:c}))}if(i===`join`){let t;if(e instanceof W)t=Array.from(e.value);else if(e instanceof K)t=e.value.map(e=>e.value);else throw Error(`Cannot apply filter "${i}" to type: ${e.type}`);let[a,o]=this.evaluateArguments(r.args,n),s=a.at(0)??o.get(`separator`)??new W(``);if(!(s instanceof W))throw Error(`separator must be a string`);return new W(t.join(s.value))}if(i===`int`||i===`float`){let[t,a]=this.evaluateArguments(r.args,n),o=t.at(0)??a.get(`default`)??(i===`int`?new U(0):new zl(0));if(e instanceof W){let t=i===`int`?parseInt(e.value,10):parseFloat(e.value);return isNaN(t)?o:i===`int`?new U(t):new zl(t)}if(e instanceof U||e instanceof zl)return e;if(e instanceof G)return i===`int`?new U(+!!e.value):new zl(+!!e.value);throw Error(`Cannot apply filter "${i}" to type: ${e.type}`)}if(i==="default"){let[t,i]=this.evaluateArguments(r.args,n),a=t[0]??new W(``),o=t[1]??i.get(`boolean`)??new G(!1);if(!(o instanceof G))throw Error("`default` filter flag must be a boolean");return e instanceof Yl||o.value&&!e.__bool__().value?a:e}if(e instanceof K){switch(i){case`sort`:{let[t,i]=this.evaluateArguments(r.args,n),a=t.at(0)??i.get(`reverse`)??new G(!1);if(!(a instanceof G))throw Error(`reverse must be a boolean`);let o=t.at(1)??i.get(`case_sensitive`)??new G(!1);if(!(o instanceof G))throw Error(`case_sensitive must be a boolean`);let s=t.at(2)??i.get(`attribute`)??new Jl;if(!(s instanceof W||s instanceof U||s instanceof Jl))throw Error(`attribute must be a string, integer, or null`);let c=e=>s instanceof Jl?e:ru(e,s instanceof U?String(s.value):s.value);return new K(e.value.slice().sort((e,t)=>{let n=iu(c(e),c(t),o.value);return a.value?-n:n}))}case`selectattr`:case`rejectattr`:{let t=i===`selectattr`;if(e.value.some(e=>!eu(e)))throw Error(`\`${i}\` can only be applied to array of objects`);if(r.args.some(e=>e.type!==`StringLiteral`))throw Error(`arguments of \`${i}\` must be strings`);let[a,o,s]=r.args.map(e=>this.evaluate(e,n)),c;if(o){let e=n.tests.get(o.value);if(!e)throw Error(`Unknown test: ${o.value}`);c=e}else c=(...e)=>e[0].__bool__().value;return new K(e.value.filter(e=>{let n=e.value.get(a.value),r=n?c(n,s):!1;return t?r:!r}))}case`map`:{let[,t]=this.evaluateArguments(r.args,n);if(t.has(`attribute`)){let n=t.get(`attribute`);if(!(n instanceof W))throw Error(`attribute must be a string`);let r=t.get(`default`);return new K(e.value.map(e=>{if(!eu(e))throw Error(`items in map must be an object`);let t=ru(e,n.value);return t instanceof Yl?r??new Yl:t}))}throw Error("`map` expressions without `attribute` set are not currently supported.")}}throw Error(`Unknown ArrayValue filter: ${i}`)}if(e instanceof W){switch(i){case`indent`:{let[t,i]=this.evaluateArguments(r.args,n),a=t.at(0)??i.get(`width`)??new U(4);if(!(a instanceof U))throw Error(`width must be a number`);let o=t.at(1)??i.get(`first`)??new G(!1),s=t.at(2)??i.get(`blank`)??new G(!1),c=e.value.split(` +`),l=` `.repeat(a.value);return new W(c.map((e,t)=>!o.value&&t===0||!s.value&&e.length===0?e:l+e).join(` +`))}case`replace`:{let t=e.builtins.get(`replace`);if(!(t instanceof ql))throw Error(`replace filter not available`);let[i,a]=this.evaluateArguments(r.args,n);return t.value([...i,new Wl(a)],n)}}throw Error(`Unknown StringValue filter: ${i}`)}if(e instanceof Ul){let t=e.builtins.get(i);if(t&&t instanceof ql){let[e,i]=this.evaluateArguments(r.args,n);return i.size>0&&e.push(new Wl(i)),t.value(e,n)}throw Error(`Unknown ObjectValue filter: ${i}`)}throw Error(`Cannot apply filter "${i}" to type: ${e.type}`)}throw Error(`Unknown filter: ${t.type}`)}evaluateFilterExpression(e,t){let n=this.evaluate(e.operand,t);return this.applyFilter(n,e.filter,t)}evaluateTestExpression(e,t){let n=this.evaluate(e.operand,t),r=t.tests.get(e.test.value);if(!r)throw Error(`Unknown test: ${e.test.value}`);let i=r(n);return new G(e.negate?!i:i)}evaluateSelectExpression(e,t){return this.evaluate(e.test,t).__bool__().value?this.evaluate(e.lhs,t):new Yl}evaluateUnaryExpression(e,t){let n=this.evaluate(e.argument,t);switch(e.operator.value){case`not`:return new G(!n.value);case`+`:case`-`:{let t=e.operator.value===`-`?-1:1;if(n instanceof U||n instanceof zl||n instanceof G){let e=t*(n instanceof G?+!!n.value:n.value);return n instanceof zl?new zl(e):new U(e)}throw SyntaxError(`Unknown operator "${e.operator.value}" for ${n.type}`)}default:throw SyntaxError(`Unknown operator: ${e.operator.value}`)}}evaluateTernaryExpression(e,t){return this.evaluate(e.condition,t).__bool__().value?this.evaluate(e.trueExpr,t):this.evaluate(e.falseExpr,t)}evalProgram(e,t){return this.evaluateBlock(e.body,t)}evaluateBlock(e,t){let n=``;for(let r of e){let e=this.evaluate(r,t);e.type!==`NullValue`&&e.type!==`UndefinedValue`&&(n+=e.toString())}return new W(n)}evaluateIdentifier(e,t){return t.lookupVariable(e.value)}evaluateCallExpression(e,t){let[n,r]=this.evaluateArguments(e.args,t);r.size>0&&n.push(new Wl(r));let i=this.evaluate(e.callee,t);if(i.type!==`FunctionValue`)throw Error(`Cannot call something that is not a function: got ${i.type}`);return i.value(n,t)}evaluateSliceExpression(e,t,n){if(!(e instanceof K||e instanceof W))throw Error(`Slice object must be an array or string`);let r=this.evaluate(t.start,n),i=this.evaluate(t.stop,n),a=this.evaluate(t.step,n);if(!(r instanceof U||r instanceof Yl))throw Error(`Slice start must be numeric or undefined`);if(!(i instanceof U||i instanceof Yl))throw Error(`Slice stop must be numeric or undefined`);if(!(a instanceof U||a instanceof Yl))throw Error(`Slice step must be numeric or undefined`);return e instanceof K?new K(kl(e.value,r.value,i.value,a.value)):new W(kl(Array.from(e.value),r.value,i.value,a.value).join(``))}evaluateMemberExpression(e,t){let n=this.evaluate(e.object,t),r;if(e.computed){if(e.property.type===`SliceExpression`)return this.evaluateSliceExpression(n,e.property,t);r=this.evaluate(e.property,t)}else r=e.property.type===`IntegerLiteral`?new U(e.property.value):new W(e.property.value);let i;if(eu(n)){if(!(r instanceof W))throw Error(`Cannot access property with non-string: got ${r.type}`);i=n.value.get(r.value)??(n instanceof Ul?n.builtins.get(r.value):void 0)}else if(n instanceof K||n instanceof W){if(r instanceof U)i=n.value.at(r.value),n instanceof W&&(i=new W(n.value.at(r.value)));else if(r instanceof W)i=n.builtins.get(r.value);else throw Error(`Cannot access property with non-string/non-number: got ${r.type}`)}else{if(!(r instanceof W))throw Error(`Cannot access property with non-string: got ${r.type}`);i=n.builtins.get(r.value)}return i instanceof Rl?i:new Yl}evaluateSet(e,t){let n=e.value?this.evaluate(e.value,t):this.evaluateBlock(e.body,t);if(e.assignee.type===`Identifier`){let r=e.assignee.value;t.setVariable(r,n)}else if(e.assignee.type===`TupleLiteral`){let r=e.assignee;if(!(n instanceof K))throw Error(`Cannot unpack non-iterable type in set: ${n.type}`);let i=n.value;if(i.length!==r.value.length)throw Error(`Too ${r.value.length>i.length?`few`:`many`} items to unpack in set`);for(let e=0;et.setVariable(e.loopvar.value,c);else if(e.loopvar.type===`TupleLiteral`){let t=e.loopvar;if(c.type!==`ArrayValue`)throw Error(`Cannot unpack non-iterable type: ${c.type}`);let n=c;if(t.value.length!==n.value.length)throw Error(`Too ${t.value.length>n.value.length?`few`:`many`} items to unpack`);l=e=>{for(let r=0;r0?a[t-1]:new Yl],[`nextitem`,t0)throw Error(`macro ${e} takes no keyword argument '${o.keys().next().value}'`);if(n.has(`varargs`))i.setVariable(`varargs`,new K(a.slice(t.length)));else if(a.length>t.length)throw Error(`macro ${e} takes not more than ${t.length} argument(s)`);for(let[e,t]of s)i.setVariable(e,this.evaluate(t,i))}evaluateMacro(e,t){let n=su(e.args,e.body);return t.setVariable(e.name.value,new ql((t,r)=>{let i=new Ql(r);return this.bindMacroArguments(`'${e.name.value}'`,e.args,n,t,i),this.evaluateBlock(e.body,i)})),new Jl}evaluateCallStatement(e,t){let n=e.callerArgs??[],r=su(n,e.body),i=new ql(i=>{let a=new Ql(t);return this.bindMacroArguments(`None`,n,r,i,a),this.evaluateBlock(e.body,a)}),[a,o]=this.evaluateArguments(e.call.args,t);a.push(new Wl(o));let s=this.evaluate(e.call.callee,t);if(s.type!==`FunctionValue`)throw Error(`Cannot call something that is not a function: got ${s.type}`);let c=new Ql(t);return c.setVariable(`caller`,i),s.value(a,c)}evaluateFilterStatement(e,t){let n=this.evaluateBlock(e.body,t);return this.applyFilter(n,e.filter,t)}evaluate(e,t){if(!e)return new Yl;switch(e.type){case`Program`:return this.evalProgram(e,t);case`Set`:return this.evaluateSet(e,t);case`If`:return this.evaluateIf(e,t);case`For`:return this.evaluateFor(e,t);case`Macro`:return this.evaluateMacro(e,t);case`CallStatement`:return this.evaluateCallStatement(e,t);case`Break`:throw new Fl;case`Continue`:throw new Il;case`IntegerLiteral`:return new U(e.value);case`FloatLiteral`:return new zl(e.value);case`StringLiteral`:return new W(e.value);case`ArrayLiteral`:return new K(e.value.map(e=>this.evaluate(e,t)));case`TupleLiteral`:return new Kl(e.value.map(e=>this.evaluate(e,t)));case`ObjectLiteral`:{let n=new Map;for(let[r,i]of e.value){let e=this.evaluate(r,t);if(!(e instanceof W))throw Error(`Object keys must be strings: got ${e.type}`);n.set(e.value,this.evaluate(i,t))}return new Ul(n)}case`Identifier`:return this.evaluateIdentifier(e,t);case`CallExpression`:return this.evaluateCallExpression(e,t);case`MemberExpression`:return this.evaluateMemberExpression(e,t);case`UnaryExpression`:return this.evaluateUnaryExpression(e,t);case`BinaryExpression`:return this.evaluateBinaryExpression(e,t);case`FilterExpression`:return this.evaluateFilterExpression(e,t);case`FilterStatement`:return this.evaluateFilterStatement(e,t);case`TestExpression`:return this.evaluateTestExpression(e,t);case`SelectExpression`:return this.evaluateSelectExpression(e,t);case`Ternary`:return this.evaluateTernaryExpression(e,t);case`Comment`:return new Jl;default:throw SyntaxError(`Unknown node type: ${e.type}`)}}};function lu(e){switch(typeof e){case`number`:return Number.isInteger(e)?new U(e):new zl(e);case`string`:return new W(e);case`boolean`:return new G(e);case`undefined`:return new Yl;case`object`:return e===null?new Jl:Array.isArray(e)?new K(e.map(lu)):new Ul(new Map(Object.entries(e).map(([e,t])=>[e,lu(t)])));case`function`:return new ql((t,n)=>lu(e(...t.map(e=>e.value))??null));default:throw Error(`Cannot convert to runtime value: ${e}`)}}var uu=` +`,du=`{%- `,fu=` -%}`,pu=Object.freeze({CONDITIONAL:0,LOGICAL_OR:1,LOGICAL_AND:2,LOGICAL_NOT:3,COMPARISON:4,ADDITIVE:5,MULTIPLICATIVE:6,EXPONENTIATION:7,TEST:8,FILTER:9,UNARY_SIGN:10,ATOM:11});function mu(e){switch(e.operator.type){case`ExponentiationBinaryOperator`:return pu.EXPONENTIATION;case`MultiplicativeBinaryOperator`:return pu.MULTIPLICATIVE;case`AdditiveBinaryOperator`:return pu.ADDITIVE;case`ComparisonBinaryOperator`:return pu.COMPARISON;case`Identifier`:return e.operator.value===`and`?pu.LOGICAL_AND:e.operator.value===`in`||e.operator.value===`not in`?pu.COMPARISON:pu.LOGICAL_OR}return pu.LOGICAL_OR}function hu(e){switch(e.type){case`SelectExpression`:case`Ternary`:return pu.CONDITIONAL;case`BinaryExpression`:return mu(e);case`UnaryExpression`:return e.operator.value===`not`?pu.LOGICAL_NOT:pu.UNARY_SIGN;case`TestExpression`:return pu.TEST;case`FilterExpression`:return pu.FILTER;default:return pu.ATOM}}function gu(e,t){let n=Ou(e);return hu(e)xu(e,t,n)).join(uu)}function bu(e){return e.map(e=>Ou(e)).join(`, `)}function xu(e,t,n){let r=n.repeat(t);switch(e.type){case`Program`:return yu(e.body,t,n);case`If`:return Su(e,t,n);case`For`:return Cu(e,t,n);case`Set`:return wu(e,t,n);case`Macro`:return Tu(e,t,n);case`Break`:return r+vu(`break`);case`Continue`:return r+vu(`continue`);case`CallStatement`:return Eu(e,t,n);case`FilterStatement`:return Du(e,t,n);case`Comment`:return r+`{# `+e.value+` #}`;default:return r+`{{- `+Ou(e)+` -}}`}}function Su(e,t,n){let r=n.repeat(t),i=[],a=e;for(;a&&(i.push({test:a.test,body:a.body}),a.alternate.length===1&&a.alternate[0].type===`If`);)a=a.alternate[0];let o=r+vu(`if`,Ou(i[0].test))+uu+yu(i[0].body,t+1,n);for(let e=1;e0&&(o+=uu+r+vu(`else`)+uu+yu(a.alternate,t+1,n)),o+=uu+r+vu(`endif`),o}function Cu(e,t,n){let r=n.repeat(t),i=``;if(e.iterable.type===`SelectExpression`){let t=e.iterable;i=`${Ou(t.lhs)} if ${Ou(t.test)}`}else i=Ou(e.iterable);let a=r+vu(`for`,Ou(e.loopvar),`in`,i)+uu+yu(e.body,t+1,n);return e.defaultBlock.length>0&&(a+=uu+r+vu(`else`)+uu+yu(e.defaultBlock,t+1,n)),a+=uu+r+vu(`endfor`),a}function wu(e,t,n){let r=n.repeat(t),i=Ou(e.assignee),a=e.value?Ou(e.value):``,o=r+vu(`set`,`${i}${e.value?` = `+a:``}`);return e.body.length===0?o:o+uu+yu(e.body,t+1,n)+uu+r+vu(`endset`)}function Tu(e,t,n){let r=n.repeat(t),i=bu(e.args);return r+vu(`macro`,`${e.name.value}(${i})`)+uu+yu(e.body,t+1,n)+uu+r+vu(`endmacro`)}function Eu(e,t,n){let r=n.repeat(t),i=e.callerArgs&&e.callerArgs.length>0?`(${bu(e.callerArgs)})`:``,a=Ou(e.call),o=r+vu(`call${i}`,a)+uu;return o+=yu(e.body,t+1,n)+uu,o+=r+vu(`endcall`),o}function Du(e,t,n){let r=n.repeat(t),i=r+vu(`filter`,e.filter.type===`Identifier`?e.filter.value:Ou(e.filter))+uu;return i+=yu(e.body,t+1,n)+uu,i+=r+vu(`endfilter`),i}function Ou(e){switch(e.type){case`SpreadExpression`:return`*${Ou(e.argument)}`;case`KeywordSpreadExpression`:return`**${Ou(e.argument)}`;case`Identifier`:return e.value;case`IntegerLiteral`:return`${e.value}`;case`FloatLiteral`:{let t=e.value;return Object.is(t,-0)?`-0.0`:t%1==0?t.toFixed(1):t.toString()}case`StringLiteral`:return JSON.stringify(e.value);case`BinaryExpression`:{let t=e,n=mu(t),r=gu(t.left,n),i=gu(t.right,n+1);return`${r} ${t.operator.value} ${i}`}case`UnaryExpression`:{let t=e,n=t.argument.type===`UnaryExpression`?hu(t):pu.ATOM;return t.operator.value+(t.operator.value===`not`?` `:``)+gu(t.argument,n)}case`CallExpression`:{let t=e,n=bu(t.args);return`${Ou(t.callee)}(${n})`}case`MemberExpression`:{let t=e,n=gu(t.object,pu.ATOM),r=Ou(t.property);return!t.computed&&t.property.type!==`Identifier`&&t.property.type!==`IntegerLiteral`&&(r=`(${r})`),t.computed?`${n}[${r}]`:`${n}.${r}`}case`FilterExpression`:{let t=e,n=gu(t.operand,pu.FILTER);return t.filter.type===`CallExpression`?`${n} | ${Ou(t.filter)}`:`${n} | ${t.filter.value}`}case`SelectExpression`:{let t=e;return`${gu(t.lhs,pu.LOGICAL_OR)} if ${gu(t.test,pu.LOGICAL_OR)}`}case`TestExpression`:{let t=e;return`${gu(t.operand,pu.TEST)} is${t.negate?` not`:``} ${t.test.value}`}case`ArrayLiteral`:case`TupleLiteral`:{let t=bu(e.value),n=e.type===`ArrayLiteral`?`[]`:`()`;return`${n[0]}${t}${n[1]}`}case`ObjectLiteral`:return`{${Array.from(e.value.entries()).map(([e,t])=>`${Ou(e)}: ${Ou(t)}`).join(`, `)}}`;case`SliceExpression`:{let t=e;return`${t.start?Ou(t.start):``}:${t.stop?Ou(t.stop):``}${t.step?`:${Ou(t.step)}`:``}`}case`KeywordArgumentExpression`:{let t=e;return`${t.key.value}=${Ou(t.value)}`}case`Ternary`:{let t=e;return`${gu(t.trueExpr,pu.LOGICAL_OR)} if ${gu(t.condition,pu.LOGICAL_OR)} else ${gu(t.falseExpr,pu.CONDITIONAL)}`}default:throw Error(`Unknown expression type: ${e.type}`)}}var ku=class{parsed;constructor(e){let t=Jc(e,{lstrip_blocks:!0,trim_blocks:!0});this.parsed=Dl(t)}render(e){let t=new Ql;if($l(t),e)for(let[n,r]of Object.entries(e))t.set(n,r);return new cu(t).run(this.parsed).value}format(e){return _u(this.parsed,e?.indent||` `)}},Au={txt:`text/plain`,html:`text/html`,css:`text/css`,js:`text/javascript`,json:`application/json`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`},ju=class e{constructor(e){if(this.filePath=e,this.headers=new Headers,this.exists=Pa.existsSync(e),this.exists){this.status=200,this.statusText=`OK`;let t=Pa.statSync(e);this.headers.set(`content-length`,t.size.toString()),this.updateContentType();let n=Pa.createReadStream(e);this.body=new ReadableStream({start(e){n.on(`data`,t=>e.enqueue(t)),n.on(`end`,()=>e.close()),n.on(`error`,t=>e.error(t))},cancel(){n.destroy()}})}else this.status=404,this.statusText=`Not Found`,this.body=null}updateContentType(){let e=this.filePath.toString().split(`.`).pop().toLowerCase();this.headers.set(`content-type`,Au[e]??`application/octet-stream`)}clone(){let t=new e(this.filePath);return t.exists=this.exists,t.status=this.status,t.statusText=this.statusText,t.headers=new Headers(this.headers),t}async arrayBuffer(){return(await Pa.promises.readFile(this.filePath)).buffer}async blob(){let e=await Pa.promises.readFile(this.filePath);return new Blob([e],{type:this.headers.get(`content-type`)})}async text(){return await Pa.promises.readFile(this.filePath,`utf8`)}async json(){return JSON.parse(await this.text())}},Mu=class{constructor(e){this._mt=new Uint32Array(624),this._idx=625,this._gauss_next=null,this._random_fn=this.random.bind(this),this.seed(e)}seed(e){if(e==null){if(R.IS_CRYPTO_AVAILABLE){let t=new Uint32Array(1);crypto.getRandomValues(t),e=t[0]}else e=Date.now()>>>0}let t=this._mt,n=(e,t)=>Math.imul(e,t)>>>0,r=[];for(let t=e||0;t>0;t=Math.floor(t/4294967296))r.push(t&4294967295);r.length||r.push(0),t[0]=19650218;for(let e=1;e<624;++e)t[e]=n(1812433253,t[e-1]^t[e-1]>>>30)+e>>>0;let i=1,a=0;for(let e=Math.max(624,r.length);e>0;--e,++i,++a)i>=624&&(t[0]=t[623],i=1),a>=r.length&&(a=0),t[i]=(t[i]^n(t[i-1]^t[i-1]>>>30,1664525))+r[a]+a>>>0;for(let e=623;e>0;--e,++i)i>=624&&(t[0]=t[623],i=1),t[i]=(t[i]^n(t[i-1]^t[i-1]>>>30,1566083941))-i>>>0;t[0]=2147483648,this._idx=624,this._gauss_next=null}_int32(){let e=this._mt;if(this._idx>=624){for(let t=0;t<624;++t){let n=e[t]&2147483648|e[(t+1)%624]&2147483647;e[t]=(e[(t+397)%624]^n>>>1^(n&1?2567483615:0))>>>0}this._idx=0}let t=e[this._idx++];return t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0}random(){return((this._int32()>>>5)*67108864+(this._int32()>>>6))/9007199254740992}gauss(e=0,t=1){let n=this._gauss_next;if(this._gauss_next=null,n===null){let e=this.random()*2*Math.PI,t=Math.sqrt(-2*Math.log(1-this.random()));n=Math.cos(e)*t,this._gauss_next=Math.sin(e)*t}return e+n*t}shuffle(e){for(let t=e.length-1;t>0;--t){let n=32-Math.clz32(t+1),r=this._int32()>>>32-n;for(;r>t;)r=this._int32()>>>32-n;let i=e[t];e[t]=e[r],e[r]=i}}choices(e,t){return e[Nu(this._random_fn,t)]}};function Nu(e,t){let n=0;for(let e=0;eNu(Fu.random,e),Lu=new Mu,Ru=class{constructor(e){this.path=e}async match(e){let t=new ju(Fa.join(this.path,e));if(t.exists)return t}async put(e,t,n=void 0){let r=Fa.join(this.path,e),i=r+`.tmp.${R.IS_PROCESS_AVAILABLE?process.pid:Date.now()}.${Lu._int32().toString(36)}`;try{let e=t.headers.get(`Content-Length`),a=parseInt(e??`0`),o=0;await Pa.promises.mkdir(Fa.dirname(r),{recursive:!0});let s=Pa.createWriteStream(i),c=t.body.getReader();for(;;){let{done:e,value:t}=await c.read();if(e)break;await new Promise((e,n)=>{s.write(t,t=>{if(t){n(t);return}e()})}),o+=t.length;let r=a?o/a*100:0;n?.({progress:r,loaded:o,total:a})}await new Promise((e,t)=>{s.close(n=>n?t(n):e())}),await Pa.promises.rename(i,r)}catch(e){try{await Pa.promises.unlink(i)}catch{}throw e}}async delete(e){let t=Fa.join(this.path,e);try{return await Pa.promises.unlink(t),!0}catch{return!1}}},zu={400:`Bad request error occurred while trying to load file`,401:`Unauthorized access to file`,403:`Forbidden access to file`,404:`Could not locate file`,408:`Request timeout error occurred while trying to load file`,500:`Internal server error error occurred while trying to load file`,502:`Bad gateway error occurred while trying to load file`,503:`Service unavailable error occurred while trying to load file`,504:`Gateway timeout error occurred while trying to load file`},Bu=100,Vu=/^(\b[\w\-.]+\b\/)?\b[\w\-.]{1,96}\b$/;function Hu(...e){return e=e.map((t,n)=>(n&&(t=t.replace(RegExp(`^/`),``)),n!==e.length-1&&(t=t.replace(RegExp(`/$`),``)),t)),e.join(`/`)}function Uu(e,t=null,n=null){let r;try{r=new URL(e)}catch{return!1}return!(t&&!t.includes(r.protocol)||n&&!n.includes(r.hostname))}function Wu(e){return!(!Vu.test(e)||e.includes(`..`)||e.includes(`--`)||e.endsWith(`.git`)||e.endsWith(`.ipynb`))}function Gu(e,t={},...n){return JSON.stringify([e,t.revision??`main`,t.cache_dir??null,t.local_files_only??!1,...n])}var Ku=class extends Error{constructor(e,{status:t=null}={}){super(e),this.name=`ModelFileNotFoundError`,this.status=t}},qu=new Set([401,403,404]);function Ju(e,t,n){if(!n)return null;let r=`${zu[e]??`Error (${e}) occurred while trying to load file`}: "${t}".`;throw qu.has(e)?new Ku(r,{status:e}):Error(r)}async function Yu(e,t,n){let r=e.headers.get(`Content-Length`),i=r?parseInt(r,10):n??0;r===null&&!n&&B.warn(`Unable to determine content-length from response headers. Will expand buffer when needed.`);let a=new Uint8Array(i),o=0,s=e.body.getReader();async function c(){let{done:e,value:n}=await s.read();if(e)return;let r=o+n.length;if(r>i){i=r;let e=new Uint8Array(i);e.set(a),a=e}return a.set(n,o),o=r,t({progress:o/i*100,loaded:o,total:i}),c()}return await c(),a}function Xu(e){return Uu(e,[`blob:`])}function Zu(e,{allowUnresolved:t=!1}={}){let n;if(typeof location<`u`&&location.href)n=location.href;else if(import.meta.url)n=import.meta.url;else return e;try{return new URL(e,n).href}catch(n){if(!t)throw n;return e}}var Qu=`SHA-256`,$u=`experimental_transformers-hash-cache`,ed=e=>({algorithm:Qu,value:e}),td=class{#e=null;_getHashCache=()=>(this.#e??=caches.open($u),this.#e);static isAvailable=()=>typeof navigator<`u`&&`crossOriginStorage`in navigator;match=async e=>{let t=await this._getFileHash(e);if(t)try{let e=await(await navigator.crossOriginStorage.requestFileHandle(ed(t))).getFile();return new Response(e,{headers:{"Content-Length":String(e.size)}})}catch{return}};put=async(e,t)=>{let n=await this._getFileHash(e);if(n){let e=await t.blob();await this._storeBlobInCOS(e,n)}else this._processAndStore(e,t.body)};_storeBlobInCOS=async(e,t)=>{let n=await(await navigator.crossOriginStorage.requestFileHandle(ed(t),{create:!0,origins:`*`})).createWritable();await n.write(e),await n.close()};_processAndStore=async(e,t)=>{try{let n=[];for await(let e of t)n.push(e);let r=new Blob(n),i=await this._getBlobHash(r);await this._storeBlobInCOS(r,i);try{await(await this._getHashCache()).put(e,new Response(i))}catch{}}catch{}};delete=async e=>{try{return await(await this._getHashCache()).delete(e)}catch{return!1}};_getFileHash=async e=>{try{let t=await this._getHashCache(),n=await t.match(e);if(n)return n.text();let r=await this._getLfsFileHash(e);return r?(await t.put(e,new Response(r)),r):null}catch{return null}};_getLfsFileHash=async e=>{if(!e.includes(`/resolve/`))return null;let t=e.replace(`/resolve/`,`/raw/`);try{let e=(await fetch(t).then(e=>e.text())).match(/^oid sha256:([0-9a-f]+)$/m);return e?e[1]:null}catch{return null}};_getBlobHash=async e=>{let t=await e.arrayBuffer(),n=await crypto.subtle.digest(Qu,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}};async function q(e=null){let t=null;if(z.useCustomCache){if(!z.customCache)throw Error("`env.useCustomCache=true`, but `env.customCache` is not defined.");if(!z.customCache.match||!z.customCache.put)throw Error("`env.customCache` must be an object which implements the `match` and `put` functions of the Web Cache API. For more information, see https://developer.mozilla.org/en-US/docs/Web/API/Cache");t=z.customCache}if(!t&&z.experimental_useCrossOriginStorage&&td.isAvailable()&&(t=new td),!t&&z.useBrowserCache){if(typeof caches>`u`)throw Error(`Browser cache is not available in this environment.`);try{t=await caches.open(z.cacheKey)}catch(e){B.warn(`An error occurred while opening the browser cache:`,e)}}if(!t&&z.useFSCache){if(!R.IS_FS_AVAILABLE)throw Error(`File System Cache is not available in this environment.`);t=new Ru(e??z.cacheDir)}return t}async function nd(e,...t){for(let n of t)try{let t=await e.match(n);if(t)return t}catch{continue}}var rd=new class{#e;#t;constructor(e){this.#e=e,this.#t=new Map}get(e){if(!this.#t.has(e))return;let t=this.#t.get(e);return this.#t.delete(e),this.#t.set(e,t),t}put(e,t){this.#t.has(e)&&this.#t.delete(e),this.#t.set(e,t),this.#t.size>this.#e&&this.#t.delete(this.#t.keys().next().value)}delete(e){return this.#t.delete(e)}clear(){this.#t.clear()}}(100);function id(e,t){let n=rd.get(e);if(n!==void 0)return n;let r=t().then(e=>e,t=>(rd.delete(e),Promise.reject(t)));return rd.put(e,r),r}async function ad(e){if(!Uu(e,[`http:`,`https:`]))return null;let t=ld(e);return t.set(`Range`,`bytes=0-0`),z.fetch(e,{method:`GET`,headers:t,cache:`no-store`})}function od(e,t,n={}){return id(Gu(e,n,t),()=>sd(e,t,n))}async function sd(e,t,n){let r=await q(n?.cache_dir),{localPath:i,remoteURL:a,proposedCacheKey:o,validModelId:s}=ud(e,t,n,r),c=await dd(r,i,o);if(c!==void 0&&typeof c!=`string`){let e=c.headers.get(`content-length`),t=c.headers.get(`content-type`);return{exists:!0,size:e?parseInt(e,10):void 0,contentType:t||void 0,fromCache:!0}}if(z.allowLocalModels&&!Uu(i,[`http:`,`https:`]))try{let e=await cd(i);if(typeof e!=`string`&&e.status!==404){let t=e.headers.get(`content-length`),n=e.headers.get(`content-type`);return{exists:!0,size:t?parseInt(t,10):void 0,contentType:n||void 0,fromCache:!1}}}catch{}if(z.allowRemoteModels&&!n.local_files_only&&s){let e=await ad(a);if(e&&e.status>=200&&e.status<300){let t,n=e.headers.get(`content-type`);if(e.status===206){let n=e.headers.get(`content-range`);if(n){let e=n.match(/bytes \d+-\d+\/(\d+)/);e&&(t=parseInt(e[1],10))}}else if(e.status===200)try{await e.body?.cancel()}catch{}if(t===void 0){let n=e.headers.get(`content-length`);t=n?parseInt(n,10):void 0}return{exists:!0,size:t,contentType:n||void 0,fromCache:!1}}e&&e.status!==404&&e.status!==416&&Ju(e.status,a,!0)}return{exists:!1,fromCache:!1}}async function cd(e){return z.useFS&&!Uu(e,[`http:`,`https:`,`blob:`])?new ju(e instanceof URL?e.protocol===`file:`?e.pathname:e.toString():e):z.fetch(e,{headers:ld(e)})}function ld(e){let t=typeof process<`u`&&process?.release?.name===`node`,n=new Headers;if(t){let t=!!{}.TESTING_REMOTELY,r=z.version;if(n.set(`User-Agent`,`transformers.js/${r}; is_ci/${t};`),Uu(e,[`http:`,`https:`],[`huggingface.co`,`hf.co`])){let e={}.HF_TOKEN??{}.HF_ACCESS_TOKEN;e&&n.set(`Authorization`,`Bearer ${e}`)}}return n}function ud(e,t,n={},r=null){let i=n.revision??`main`,a=Hu(e,t),o=Wu(e),s=o?Hu(z.localModelPath,a):a,c=Hu(z.remoteHost,z.remotePathTemplate.replaceAll(`{model}`,e).replaceAll(`{revision}`,encodeURIComponent(i)),t);return{requestURL:a,localPath:s,remoteURL:c,proposedCacheKey:r instanceof Ru?i===`main`?a:Hu(e,i,t):c,validModelId:o}}async function dd(e,t,n){if(e)return await nd(e,t,n)}async function fd(e,t,n,r,i,a,o={}){if(await n.match(r)===void 0&&!(typeof Cache<`u`&&n instanceof Cache&&!Uu(Zu(r,{allowUnresolved:!0}),[`http:`,`https:`]))){if(!a){let a=o.progress_callback?n=>fo(o.progress_callback,{status:`progress`,name:e,file:t,...n}):void 0;await n.put(r,i,a)}else if(typeof i!=`string`){let e=new Headers(i.headers);e.set(`content-length`,a.byteLength.toString()),await n.put(r,new Response(a,{headers:e})).catch(e=>{B.warn(`Unable to add response to browser cache: ${e}.`)})}}}async function pd(e,t,n=!0,r={},i=!1,a=null){let{requestURL:o,localPath:s,remoteURL:c,proposedCacheKey:l,validModelId:u}=ud(e,t,r,a),d,f=!1,p;p=await dd(a,s,l);let m=p!==void 0;if(m)d=l;else{if(z.allowLocalModels){if(!Uu(o,[`http:`,`https:`]))try{p=await cd(s),d=s}catch(e){B.warn(`Unable to load from local path "${s}": "${e}"`)}else if(r.local_files_only)throw Error(`\`local_files_only=true\`, but attempted to load a remote file from: ${o}.`);else if(!z.allowRemoteModels)throw Error(`\`env.allowRemoteModels=false\`, but attempted to load a remote file from: ${o}.`)}if(p===void 0||typeof p!=`string`&&p.status===404){if(r.local_files_only||!z.allowRemoteModels){if(n)throw new Ku(`\`local_files_only=true\` or \`env.allowRemoteModels=false\` and file was not found locally at "${s}".`);return null}if(!u)throw new Ku(`Local file missing at "${s}" and download aborted due to invalid model ID "${e}".`);if(p=await cd(c),p.status!==200)return Ju(p.status,c,n);d=l}f=a&&typeof Response<`u`&&p instanceof Response&&p.status===200}fo(r.progress_callback,{status:`download`,name:e,file:t});let h;if(!(R.IS_NODE_ENV&&i)){let n;if(typeof p!=`string`){if(!r.progress_callback)n=new Uint8Array(await p.arrayBuffer());else if(m&&typeof navigator<`u`&&/firefox/i.test(navigator.userAgent))n=new Uint8Array(await p.arrayBuffer()),fo(r.progress_callback,{status:`progress`,name:e,file:t,progress:100,loaded:n.length,total:n.length});else{let i,a=p.headers.get(`content-length`);if(a)i=parseInt(a,10);else try{let n=await od(e,t,r);n.size&&(i=n.size)}catch{}n=await Yu(p,n=>{fo(r.progress_callback,{status:`progress`,name:e,file:t,...n})},i)}}h=n}if(f&&d&&typeof p!=`string`&&await fd(e,t,a,d,p,h,r),R.IS_NODE_ENV&&i&&r.progress_callback&&typeof p!=`string`){let n=parseInt(p.headers.get(`content-length`),10)||0;fo(r.progress_callback,{status:`progress`,name:e,file:t,progress:100,loaded:n,total:n})}if(fo(r.progress_callback,{status:`done`,name:e,file:t}),h){if(!R.IS_NODE_ENV&&i)throw Error(`Cannot return path in a browser environment.`);return h}if(p instanceof ju)return p.filePath;let g=await a?.match(d);if(g instanceof ju)return g.filePath;if(g instanceof Response)return new Uint8Array(await g.arrayBuffer());if(typeof g==`string`)return g;throw Error(`Unable to get model file path or buffer.`)}var md=new Map;async function hd(e,t,n=!0,r={},i=!1){if(!z.allowLocalModels){if(r.local_files_only)throw Error("Invalid configuration detected: local models are disabled (`env.allowLocalModels=false`) but you have requested to only use local models (`local_files_only=true`).");if(!z.allowRemoteModels)throw Error("Invalid configuration detected: both local and remote models are disabled. Fix by setting `env.allowLocalModels` or `env.allowRemoteModels` to `true`.")}let a=Gu(e,r,t,n,i),{progress_callback:o}=r,s=o instanceof po?o.loads:md,c=s.get(a);return c||(fo(o,{status:`initiate`,name:e,file:t}),c=q(r.cache_dir).then(a=>pd(e,t,n,r,i,a)),s===md&&(c=c.finally(()=>md.delete(a))),s.set(a,c)),await c}async function gd(e,t,n=!0,r={}){let i=await hd(e,t,n,r,!1);return i===null?null:new TextDecoder(`utf-8`).decode(i)}async function _d(e,t,n=!0,r={}){let i=await gd(e,t,n,r);return i===null?{}:JSON.parse(i)}function vd(e,[t,n,r],[i,a],o=`bilinear`,s=!1){let c=a/r,l=i/n,u=new e.constructor(i*a*t),d=n*r,f=i*a;for(let o=0;o=0;--e)i[e]=a,r[e]=t[n[e]],a*=r[e];let a=n.map((e,t)=>i[n.indexOf(t)]),o=new e.constructor(e.length);for(let n=0;n=0;--e)r+=i%t[e]*a[e],i=Math.floor(i/t[e]);o[r]=e[n]}return[o,r]}function bd(e){let t=Cd(e)[0],n=e.map(e=>Math.exp(e-t)),r=n.reduce((e,t)=>e+t,0);return n.map(e=>e/r)}function xd(e){let t=Cd(e)[0],n=0;for(let r=0;re-t-r)}function Sd(e){if(e.length===0)throw Error(`Array must not be empty`);let t=e[0],n=0;for(let r=1;rt&&(t=e[r],n=r);return[t,n]}function wd(e){return e>0&&!(e&e-1)}var Td=class{constructor(e){if(this.size=e|0,this.size<=1||!wd(this.size))throw Error(`FFT size must be a power of two larger than 1`);this._csize=e<<1,this.table=new Float64Array(this.size*2);for(let e=0;ee;e<<=1)++t;this._width=t%2==0?t-1:t,this._bitrev=new Int32Array(1<>>t&3)<>>1);for(let t=0;t>>1]=e[t];return n}toComplexArray(e,t){let n=t||this.createComplexArray();for(let t=0;t>>1],n[t+1]=0;return n}transform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._transform4(e,t,1)}realTransform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._realTransform4(e,t,1)}inverseTransform(e,t){if(e===t)throw Error(`Input and output buffers must be different`);this._transform4(e,t,-1);for(let t=0;t>=2;i>=2;i>>=2){a=r/i<<1;let t=a>>>2;for(o=0;o>>1,i>>>1)}else for(o=0,s=0;o>>1,i>>>1,n)}let l=this.table;for(i>>=2;i>=2;i>>=2){a=r/i<<1;let t=a>>>1,s=t>>>1,c=s>>>1;for(o=0;o>>1;for(let t=2;t>1;++t){let n=(t+1-e)**2/2,r=Math.sqrt(s**2+c**2)**n,o=n*Math.atan2(c,s),l=2*t;i[l]=r*Math.cos(o),i[l+1]=r*Math.sin(o),a[l]=i[l],a[l+1]=-i[l+1]}this._slicedChirpBuffer=i.subarray(t,n),this._f=new Td(r>>1),this._f.transform(this._chirpBuffer,a)}_transform(e,t,n){let r=this._buffer1,i=this._buffer2,a=this._outBuffer1,o=this._outBuffer2,s=this._chirpBuffer,c=this._slicedChirpBuffer,l=this._a;if(n)for(let e=0;e>1];r[e]=i*c[e],r[n]=i*c[n]}else for(let e=0;e=e.length&&(i=2*(e.length-1)-i),r[a++]=e[i]}r.sort(),n[t]=r[i]}return n}function kd(e,t){let n=10**t;return Math.round(e*n)/n}function Ad(e){let t=Math.round(e);return Math.abs(e)%1==.5?t%2==0?t:t-1:t}function jd(e){let t=e.length,n=e[0].length,r=[t+1,n+1],i=Array.from({length:r[0]},()=>Array(r[1]).fill(1/0));i[0][0]=0;let a=Array.from({length:r[0]},()=>Array(r[1]).fill(-1));for(let t=1;t0||s>0;)switch(c.push(o-1),l.push(s-1),a[o][s]){case 0:--o,--s;break;case 1:--o;break;case 2:--s;break;default:throw Error(`Internal error in dynamic time warping. Unexpected trace[${o}, ${s}]. Please file a bug report.`)}return c.reverse(),l.reverse(),[c,l]}var Md=(function(){let e=null;return function(t){if(!e){e=new Float32Array(65536);let t=new ArrayBuffer(4),n=new Uint32Array(t),r=new Float32Array(t);for(let t=0;t>10,s=t&1023;if(o===31)i=a|2139095040|s<<13;else if(o===0){if(s===0)i=a;else{let e=113;for(;!(s&1024);)s<<=1,--e;s&=-1025,i=a|e<<23|s<<13}}else i=a|o+112<<23|s<<13;n[0]=i,e[t]=r[0]}}let n=t.length,r=e,i=new Float32Array(n);for(let e=0;e[`webgpu`,`cuda`,`dml`,`webnn-gpu`].includes(e))}if(Bd.includes(e))return[Ld[e]??e];throw Error(`Unsupported device: "${e}". Should be one of: ${Bd.join(`, `)}.`)}var Kd=Promise.resolve(),qd=null;async function Jd(){if(qd)return qd;if(!(z.useWasmCache&&typeof $d?.wasm?.wasmPaths==`object`&&$d?.wasm?.wasmPaths?.wasm&&$d?.wasm?.wasmPaths?.mjs)){if(R.IS_DENO_WEB_RUNTIME)throw Error(`env.useWasmCache=false is not supported in Deno's web runtime. Remove the useWasmCache override.`);return qd=Promise.resolve(),qd}return qd=(async()=>{let e=$d.wasm.wasmPaths,t=!1;await Promise.all([e.wasm&&!Xu(e.wasm)?(async()=>{try{let n=await Fd(Zu(e.wasm));n&&($d.wasm.wasmBinary=n,t=!0)}catch(e){B.warn(`Failed to pre-load WASM binary:`,e)}})():Promise.resolve(),e.mjs&&!Xu(e.mjs)?(async()=>{try{let t=await Id(Zu(e.mjs));t&&($d.wasm.wasmPaths.mjs=t)}catch(e){B.warn(`Failed to pre-load WASM factory:`,e)}})():Promise.resolve()]),t||($d.wasm.wasmPaths.mjs=e.mjs)})(),qd}async function Yd(e,t,n){await Jd();let r=Rd(z.logLevel??so.WARNING),i=()=>Wd.create(e,{logSeverityLevel:r,...t}),a=await(R.IS_WEB_ENV?Kd=Kd.then(i):i());return a.config=n,a}var Xd=Promise.resolve();async function Zd(e,t){let n=()=>e.run(t);return R.IS_WEB_ENV?Xd=Xd.then(n):n()}function Qd(e){return e instanceof Hd.Tensor}var $d=Hd?.env;function ef(){return $d?.wasm?.proxy}if($d){let e=function(e){$d.logLevel=zd[Rd(e)]};if($d.wasm){if(!(typeof ServiceWorkerGlobalScope<`u`&&self instanceof ServiceWorkerGlobalScope)&&$d.versions?.web&&!$d.wasm.wasmPaths){let e=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${$d.versions.web}/dist/`,t=`.asyncify`;R.IS_SAFARI_BELOW_26&&!R.IS_WEBGPU_AVAILABLE&&(t=``),$d.wasm.wasmPaths={mjs:`${e}ort-wasm-simd-threaded${t}.mjs`,wasm:`${e}ort-wasm-simd-threaded${t}.wasm`}}$d.wasm.proxy=!1}$d.webgpu&&($d.webgpu.powerPreference=`high-performance`),e(z.logLevel??so.WARNING),z.backends.onnx={...$d,setLogLevel:e}}var tf=async(e,t,n)=>{let r=await Yd(new Uint8Array(e),t);return(async e=>{let t=ef(),i=Object.fromEntries(Object.entries(e).map(([e,n])=>[e,(t?n.clone():n).ort_tensor])),a=await Zd(r,i);return Array.isArray(n)?n.map(e=>new J(a[e])):new J(a[n])})},nf=class{static session_options={};static get nearest_interpolate_4d(){return this._nearest_interpolate_4d||=tf([8,10,18,0,58,129,1,10,41,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,18,10,4,109,111,100,101,34,7,110,101,97,114,101,115,116,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,21],this.session_options,`y`),this._nearest_interpolate_4d}static get bilinear_interpolate_4d(){return this._bilinear_interpolate_4d||=tf([8,9,18,0,58,128,1,10,40,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,17,10,4,109,111,100,101,34,6,108,105,110,101,97,114,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,`y`),this._bilinear_interpolate_4d}static get bicubic_interpolate_4d(){return this._bicubic_interpolate_4d||=tf([8,9,18,0,58,127,10,39,10,1,120,10,0,10,0,10,1,115,18,1,121,34,6,82,101,115,105,122,101,42,16,10,4,109,111,100,101,34,5,99,117,98,105,99,160,1,3,18,1,114,90,31,10,1,120,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,90,15,10,1,115,18,10,10,8,8,7,18,4,10,2,8,4,98,31,10,1,121,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,99,10,3,18,1,104,10,3,18,1,119,66,2,16,20],this.session_options,`y`),this._bicubic_interpolate_4d}static get matmul(){return this._matmul||=tf([8,9,18,0,58,55,10,17,10,1,97,10,1,98,18,1,99,34,6,77,97,116,77,117,108,18,1,114,90,9,10,1,97,18,4,10,2,8,1,90,9,10,1,98,18,4,10,2,8,1,98,9,10,1,99,18,4,10,2,8,1,66,2,16,20],this.session_options,`c`),this._matmul}static get stft(){return this._stft||=tf([8,7,18,0,58,148,1,10,38,10,1,115,10,1,106,10,1,119,10,1,108,18,1,111,34,4,83,84,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,115,90,26,10,1,115,18,21,10,19,8,1,18,15,10,3,18,1,98,10,3,18,1,115,10,3,18,1,99,90,11,10,1,106,18,6,10,4,8,7,18,0,90,16,10,1,119,18,11,10,9,8,1,18,5,10,3,18,1,119,90,11,10,1,108,18,6,10,4,8,7,18,0,98,31,10,1,111,18,26,10,24,8,1,18,20,10,3,18,1,98,10,3,18,1,102,10,3,18,1,100,10,3,18,1,99,66,2,16,17],this.session_options,`o`),this._stft}static get rfft(){return this._rfft||=tf([8,9,58,93,10,33,10,1,120,10,0,10,1,97,18,1,121,34,3,68,70,84,42,15,10,8,111,110,101,115,105,100,101,100,24,1,160,1,2,18,1,100,90,19,10,1,120,18,14,10,12,8,1,18,8,10,0,10,0,10,2,8,1,90,11,10,1,97,18,6,10,4,8,7,18,0,98,19,10,1,121,18,14,10,12,8,1,18,8,10,0,10,0,10,2,8,2,66,2,16,20],this.session_options,`y`),this._rfft}static get top_k(){return this._top_k||=tf([8,10,18,0,58,73,10,18,10,1,120,10,1,107,18,1,118,18,1,105,34,4,84,111,112,75,18,1,116,90,9,10,1,120,18,4,10,2,8,1,90,15,10,1,107,18,10,10,8,8,7,18,4,10,2,8,1,98,9,10,1,118,18,4,10,2,8,1,98,9,10,1,105,18,4,10,2,8,7,66,2,16,21],this.session_options,[`v`,`i`]),this._top_k}static get slice(){return this._slice||=tf([8,7,18,0,58,96,10,25,10,1,120,10,1,115,10,1,101,10,1,97,10,1,116,18,1,121,34,5,83,108,105,99,101,18,1,114,90,9,10,1,120,18,4,10,2,8,1,90,9,10,1,115,18,4,10,2,8,7,90,9,10,1,101,18,4,10,2,8,7,90,9,10,1,97,18,4,10,2,8,7,90,9,10,1,116,18,4,10,2,8,7,98,9,10,1,121,18,4,10,2,8,1,66,2,16,13],this.session_options,`y`),this._slice}},rf=Object.freeze({auto:`auto`,gpu:`gpu`,cpu:`cpu`,wasm:`wasm`,webgpu:`webgpu`,cuda:`cuda`,dml:`dml`,coreml:`coreml`,webnn:`webnn`,"webnn-npu":`webnn-npu`,"webnn-gpu":`webnn-gpu`,"webnn-cpu":`webnn-cpu`}),af=R.IS_NODE_ENV?`cpu`:`wasm`;function of(e,t,{warn:n}={}){return e?typeof e==`string`?e:e.hasOwnProperty(t)?e[t]:(n&&n(`device not specified for "${t}". Using the default device (${af}).`),af):af}var sf=(function(){let e;return async function(){if(e===void 0){if(!R.IS_WEBGPU_AVAILABLE)e=!1;else try{e=(await navigator.gpu.requestAdapter()).features.has(`shader-f16`)}catch{e=!1}}return e}})(),cf=Object.freeze({auto:`auto`,fp32:`fp32`,fp16:`fp16`,q8:`q8`,int8:`int8`,uint8:`uint8`,q4:`q4`,bnb4:`bnb4`,q4f16:`q4f16`,q2:`q2`,q2f16:`q2f16`,q1:`q1`,q1f16:`q1f16`}),lf=cf.fp32,uf=Object.freeze({[rf.wasm]:cf.q8}),df=Object.freeze({[cf.fp32]:``,[cf.fp16]:`_fp16`,[cf.int8]:`_int8`,[cf.uint8]:`_uint8`,[cf.q8]:`_quantized`,[cf.q4]:`_q4`,[cf.q2]:`_q2`,[cf.q1]:`_q1`,[cf.q4f16]:`_q4f16`,[cf.q2f16]:`_q2f16`,[cf.q1f16]:`_q1f16`,[cf.bnb4]:`_bnb4`});function ff(e,t,n,{configDtype:r=null,warn:i}={}){let a,o=!1;e&&typeof e!=`string`?e.hasOwnProperty(t)?a=e[t]:(a=null,o=!0):a=e;let s;if(a===cf.auto){if(r){let e=typeof r==`string`?r:r?.[t];if(e&&e!==cf.auto&&cf.hasOwnProperty(e))return e}s=uf[n]??lf}else s=a&&cf.hasOwnProperty(a)?a:uf[n]??lf;return o&&i&&i(`dtype not specified for "${t}". Using the default dtype (${s}) for this device (${n}).`),s}var pf=Object.freeze({float32:Float32Array,float16:typeof Float16Array<`u`?Float16Array:Uint16Array,float64:Float64Array,string:Array,int8:Int8Array,uint8:Uint8Array,int16:Int16Array,uint16:Uint16Array,int32:Int32Array,uint32:Uint32Array,int64:BigInt64Array,uint64:BigUint64Array,bool:Uint8Array,uint4:Uint8Array,int4:Int8Array}),J=class e{get dims(){return this.ort_tensor.dims}set dims(e){this.ort_tensor.dims=e}get type(){return this.ort_tensor.type}get data(){return this.ort_tensor.data}get size(){return this.ort_tensor.size}get location(){return this.ort_tensor.location}ort_tensor;constructor(...e){return this.ort_tensor=Qd(e[0])?e[0]:new ja(e[0],e[1],e[2]),new Proxy(this,{get:(e,t)=>{if(typeof t==`string`){let n=Number(t);if(Number.isInteger(n))return e._getitem(n)}return e[t]},set:(e,t,n)=>e[t]=n})}dispose(){this.ort_tensor.dispose()}*[Symbol.iterator](){let[e,...t]=this.dims;if(t.length>0){let n=t.reduce((e,t)=>e*t);for(let r=0;r0){let e=r.reduce((e,t)=>e*t);return this._subarray(t,e,r)}return new e(this.type,[this.data[t]],r)}_subarray(t,n,r){let i=t*n,a=(t+1)*n,o=`subarray`in this.data?this.data.subarray(i,a):this.data.slice(i,a);return new e(this.type,o,r)}item(){let e=this.data;if(e.length!==1)throw Error(`a Tensor with ${e.length} elements cannot be converted to Scalar`);return e[0]}tolist(){return mf(this.data,this.dims)}sigmoid(){return this.clone().sigmoid_()}sigmoid_(){let e=this.data;for(let t=0;t0||r>0&&n<0?r+n:r}return this}clone(){return new e(this.type,this.data.slice(),this.dims.slice())}slice(...t){let n=[],r=[];for(let e=0;ea)throw Error(`Invalid slice: ${i}`);let o=[Math.max(t,0),Math.min(a,this.dims[e])];r.push(o),n.push(o[1]-o[0])}else throw Error(`Invalid slice: ${i}`)}let i=r.map(([e,t])=>t-e),a=i.reduce((e,t)=>e*t),o=this.data,s=new o.constructor(a),c=this.stride(),l=!0;for(let e=1;e=0;--n){let e=i[n];t+=(a%e+r[n][0])*c[n],a=Math.floor(a/e)}s[e]=o[t]}return new e(this.type,s,n)}permute(...e){return hf(this,e)}transpose(...e){return this.permute(...e)}sum(e=null,t=!1){return this.norm(1,e,t)}norm(t=`fro`,n=null,r=!1){if(t===`fro`)t=2;else if(typeof t==`string`)throw Error(`Unsupported norm: ${t}`);let i=this.data,a=i instanceof BigInt64Array||i instanceof BigUint64Array;if(a&&t!==1)throw Error(`Expected a floating point tensor as input. Got ${this.type}`);let o,s;if(a?(o=(e,t)=>e+t,s=0n):(o=(e,n)=>e+n**t,s=0),n===null){let n=i.reduce(o,s);return t!==1&&(n**=1/t),new e(this.type,[n],[])}let[c,l,u]=Of(o,this,n,r);if(t!==1)for(let e=0;e=0;--r){let e=this.dims[r];if(r!==t){let t=i%e;n+=t*a,a*=this.dims[r]}i=Math.floor(i/e)}r[e]/=i[n]}return this}normalize(e=2,t=1){return this.clone().normalize_(e,t)}stride(){return jf(this.dims)}squeeze(t=null){return new e(this.type,this.data,Cf(this.dims,t))}squeeze_(e=null){return this.dims=Cf(this.dims,e),this}unsqueeze(t){return new e(this.type,this.data,wf(this.dims,t))}unsqueeze_(e){return this.dims=wf(this.dims,e),this}flatten_(e=0,t=-1){t=(t+this.dims.length)%this.dims.length;let n=this.dims.slice(0,e),r=this.dims.slice(e,t+1),i=this.dims.slice(t+1);return this.dims=[...n,r.reduce((e,t)=>e*t,1),...i],this}flatten(e=0,t=-1){return this.clone().flatten_(e,t)}view(...t){let n=-1;for(let e=0;er===n?e:e*t,1);t[n]=r.length/e}return new e(this.type,r,t)}neg_(){let e=this.data;for(let t=0;tt);return new e(`bool`,n,this.dims)}lt(t){let n=new Uint8Array(this.data.length),r=this.data;for(let e=0;eMath.min(e,t),this,t,n,1/0);return new e(r,i,a)}max(t=null,n=!1){if(t===null){let t=Cd(this.data)[0];return new e(this.type,[t],[])}let[r,i,a]=Of((e,t)=>Math.max(e,t),this,t,n,-1/0);return new e(r,i,a)}argmin(t=null,n=!1){if(t!==null)throw Error("`dim !== null` not yet implemented.");let r=Sd(this.data)[1];return new e(`int64`,[BigInt(r)],[])}argmax(t=null,n=!1){if(t!==null)throw Error("`dim !== null` not yet implemented.");let r=Cd(this.data)[1];return new e(`int64`,[BigInt(r)],[])}repeat(...t){if(t.lengthe===1)){if(t.length===this.dims.length)return this.clone();let n=t.length-this.dims.length,r=Array(n).fill(1).concat(this.dims);return new e(this.type,this.data.slice(),r)}let n=t.length-this.dims.length,r=Array(n).fill(1).concat(this.dims),i=r.map((e,n)=>e*t[n]),a=i.reduce((e,t)=>e*t,1),o=this.data,s=new o.constructor(a),c=jf(r),l=jf(i);for(let e=0;eBigInt(Math.floor(e)):BigInt;else if(this.type===`float16`&&t==`float32`&&this.data instanceof Uint16Array)return new e(t,Md(this.data),this.dims);return new e(t,pf[t].from(this.data,n),this.dims)}};function mf(e,t){let n=e.length;if(n!==(t.length===0?1:t.reduce((e,t)=>e*t)))throw Error(`cannot reshape array of size ${n} into shape (${t})`);let r=e;for(let e=t.length-1;e>=0;e--)r=r.reduce((n,r)=>{let i=n[n.length-1];return i.lengthnew J(`int64`,e,[e.length]);async function xf(e,t,n,r,i){return await(await nf.slice)({x:e,s:bf(t),e:bf(n),a:bf(r),t:bf(i??Array(r.length).fill(1))})}function Sf(e,t){let n=e.data,r=t.data,i=[e.dims[0],e.dims[2]],a=new n.constructor(i[0]*i[1]),[o,s,c]=e.dims,l=0;for(let e=0;ee!==1):typeof t==`number`?e[t]===1&&e.splice(t,1):Array.isArray(t)&&(e=e.filter((e,n)=>e!==1||!t.includes(n))),e}function wf(e,t){return t=Tf(t,e.length+1),e=e.slice(),e.splice(t,0,1),e}function Tf(e,t,n=null,r=!0){if(e<-t||e>=t){if(r)throw Error(`IndexError: index ${e} is out of bounds for dimension${n===null?``:` `+n} with size ${t}`);return e<-t?0:t}return e<0&&(e=(e%t+t)%t),e}function Ef(e,t=0){t=Tf(t,e[0].dims.length);let n=e[0].dims.slice();n[t]=e.reduce((e,n)=>e+n.dims[t],0);let r=n.reduce((e,t)=>e*t,1),i=new e[0].data.constructor(r),a=e[0].type;if(t===0){let t=0;for(let n of e){let e=n.data;i.set(e,t),t+=e.length}}else{let r=0;for(let a=0;a=0;--i){let e=s[i],l=o%e;i===t&&(l+=r),a+=l*c,c*=n[i],o=Math.floor(o/e)}i[a]=o[e]}r+=s[t]}}return new J(a,i,n)}function Df(e,t=0){return Ef(e.map(e=>e.unsqueeze(t)),t)}function Of(e,t,n,r=!1,i=null){let a=t.data,o=t.dims;n=Tf(n,o.length);let s=o.slice();s[n]=1;let c=new a.constructor(a.length/o[n]);i!==null&&c.fill(i);for(let t=0;t=0;--e){let t=o[e];if(e!==n){let n=i%t;r+=n*a,a*=s[e]}i=Math.floor(i/t)}c[r]=e(c[r],a[t],t,r)}return r||s.splice(n,1),[t.type,c,s]}function kf(e,t=null,n=1,r=!1){let i=e.data,a=e.dims;if(t===null){let t=i.reduce((e,t)=>e+t,0)/i.length,r=Math.sqrt(i.reduce((e,n)=>e+(n-t)**2,0)/(i.length-n)),a=new J(e.type,[t],[]);return[new J(e.type,[r],[]),a]}t=Tf(t,a.length);let o=Af(e,t,r),s=o.data,[c,l,u]=Of((e,t,n,r)=>e+(t-s[r])**2,e,t,r);for(let e=0;ee+t,0);return new J(e.type,[t/i.length],[])}t=Tf(t,r.length);let[a,o,s]=Of((e,t)=>e+t,e,t,n);if(r[t]!==1)for(let e=0;e=0;--n)t[n]=r,r*=e[n];return t}function Mf(e,t,n,r){return new J(n,new r(e.reduce((e,t)=>e*t,1)).fill(t),e)}function Nf(e,t){let n,r;if(typeof t==`number`)n=`float32`,r=Float32Array;else if(typeof t==`bigint`)n=`int64`,r=BigInt64Array;else if(typeof t==`boolean`)n=`bool`,r=Uint8Array;else throw Error(`Unsupported data type: ${typeof t}`);return Mf(e,t,n,r)}function Pf(e,t){return Nf(e.dims,t)}function Ff(e){return Mf(e,1n,`int64`,BigInt64Array)}function If(e){return Ff(e.dims)}function Lf(e){return Mf(e,0n,`int64`,BigInt64Array)}function Rf(e){return Lf(e.dims)}function zf(e){let t=e.reduce((e,t)=>e*t,1);return new J(`float32`,Float32Array.from({length:t},()=>Fu.gauss()),e)}function Bf(e,t){if(e.dims.length!==2)throw Error(`The tensor must have 2 dimensions`);if(e.dims.at(-1)%8!=0)throw Error(`The last dimension of the tensor must be a multiple of 8`);if(![`binary`,`ubinary`].includes(t))throw Error(`The precision must be either 'binary' or 'ubinary'`);let n=t===`binary`,r=n?`int8`:`uint8`,i=n?Int8Array:Uint8Array,a=e.data,o=new i(a.length/8);for(let e=0;e0),r=Math.floor(e/8),i=e%8;o[r]|=t<<7-i,n&&i===0&&(o[r]-=128)}return new J(r,o,[e.dims[0],e.dims[1]/8])}async function Vf(e){if(!e)throw Error(`modelId is required for get_tokenizer_files`);return(await od(e,`tokenizer_config.json`,{})).exists?[`tokenizer.json`,`tokenizer_config.json`]:[]}async function Hf(e,t){let n=await Vf(e);return await Promise.all(n.map(n=>_d(e,n,!0,t)))}function Uf(e){let t=e.dims;switch(t.length){case 1:return e.tolist();case 2:if(t[0]!==1)throw Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");return e.tolist()[0];default:throw Error(`Expected tensor to have 1-2 dimensions, got ${t.length}.`)}}var Wf=[`bos_token`,`eos_token`,`unk_token`,`sep_token`,`pad_token`,`cls_token`,`mask_token`];function Gf(e,t,n,r){for(let i of Object.keys(e)){let a=t-e[i].length,o=n(i),s=Array(a).fill(o);e[i]=r===`right`?_o(e[i],s):_o(s,e[i])}}function Kf(e,t){for(let n of Object.keys(e))e[n].length=t}function qf(e,...t){for(let n of t){if(!Object.hasOwn(e,n))continue;let t=e[n];if(t){if(typeof t==`object`){if(t.__type===`AddedToken`)return t.content;throw Error(`Unknown token: ${t}`)}return t}}return null}function Jf(e){let t=[];for(let n of e.get_added_tokens_decoder().values())n.special&&t.push(n);return t}var Y=class extends uo{return_token_type_ids=!1;padding_side=`right`;constructor(e,t){if(super(),this._tokenizerJSON=e,this._tokenizerConfig=t,this._tokenizer=new Lc(e,t),this.config=t,this.padding_side=t.padding_side??this.padding_side,this.mask_token=qf(t,`mask_token`),this.mask_token_id=this._tokenizer.token_to_id(this.mask_token),this.pad_token=qf(t,`pad_token`,`eos_token`),this.pad_token_id=this._tokenizer.token_to_id(this.pad_token),this.sep_token=qf(t,`sep_token`),this.sep_token_id=this._tokenizer.token_to_id(this.sep_token),this.unk_token=qf(t,`unk_token`),this.unk_token_id=this._tokenizer.token_to_id(this.unk_token),this.bos_token=qf(t,`bos_token`),this.bos_token_id=this._tokenizer.token_to_id(this.bos_token),this.eos_token=qf(t,`eos_token`),this.eos_token_id=this._tokenizer.token_to_id(this.eos_token),this.chat_template=t.chat_template??null,Array.isArray(this.chat_template)){let e=Object.create(null);for(let{name:t,template:n}of this.chat_template){if(typeof t!=`string`||typeof n!=`string`)throw Error(`Chat template must be a list of objects with "name" and "template" properties`);e[t]=n}this.chat_template=e}this._compiled_template_cache=new Map;let n=Jf(this._tokenizer);this.all_special_ids=n.map(e=>e.id),this.all_special_tokens=n.map(e=>e.content)}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`}={}){let o=await Hf(e,{progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a});return new this(...o)}get_vocab(){return this._tokenizer.get_vocab()}get model_max_length(){return this._tokenizerConfig.model_max_length??1/0}get add_eos_token(){return this._tokenizerConfig.add_eos_token}get add_bos_token(){return this._tokenizerConfig.add_bos_token}convert_tokens_to_ids(e){return typeof e==`string`?this._tokenizer.token_to_id(e):e.map(e=>this._tokenizer.token_to_id(e))}_call(e,t={}){let{text_pair:n=null,add_special_tokens:r=!0,padding:i=!1,return_token_type_ids:a=null}=t,{truncation:o=null,max_length:s=null}=t,c=t.return_tensor??!0,l=Array.isArray(e),u;if(l){if(e.length===0)throw Error(`text array must be non-empty`);if(n!==null){if(!Array.isArray(n))throw Error(`text_pair must also be an array`);if(e.length!==n.length)throw Error(`text and text_pair must have the same length`);u=e.map((e,t)=>this._encode_plus(e,{text_pair:n[t],add_special_tokens:r,return_token_type_ids:a}))}else u=e.map(e=>this._encode_plus(e,{add_special_tokens:r,return_token_type_ids:a}))}else{if(e==null)throw Error(`text may not be null or undefined`);if(Array.isArray(n))throw Error("When specifying `text_pair`, since `text` is a string, `text_pair` must also be a string (i.e., not an array).");u=[this._encode_plus(e,{text_pair:n,add_special_tokens:r,return_token_type_ids:a})]}if(s===null?s=this.model_max_length:o===null&&(i===!0?(B.warn("`max_length` is ignored when `padding: true` and there is no truncation strategy. To pad to max length, use `padding: 'max_length'`."),s=this.model_max_length):i===!1&&(B.warn("Truncation was not explicitly activated but `max_length` is provided a specific value, please use `truncation: true` to explicitly truncate examples to max length."),o=!0)),i===!0&&(s=Math.min(Cd(u.map(e=>e.input_ids.length))[0],s??1/0)),s=Math.min(s,this.model_max_length??1/0),i||o)for(let e=0;es?o&&Kf(u[e],s):i&&Gf(u[e],s,e=>e===`input_ids`?this.pad_token_id:0,this.padding_side);let d={};if(c){if(!(i&&o)&&u.some(e=>{for(let t of Object.keys(e))if(e[t].length!==u[0][t]?.length)return!0;return!1}))throw Error(`Unable to create tensor, you should probably activate truncation and/or padding with 'padding=true' and 'truncation=true' to have batched tensors with the same length.`);let e=[u.length,u[0].input_ids.length];for(let t of Object.keys(u[0]))d[t]=new J(`int64`,BigInt64Array.from(u.flatMap(e=>e[t]).map(BigInt)),e)}else{for(let e of Object.keys(u[0]))d[e]=u.map(t=>t[e]);if(!l)for(let e of Object.keys(d))d[e]=d[e][0]}return d}_encode_text(e){return e===null?null:this._tokenizer.encode(e).tokens}_encode_plus(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){let{ids:i,attention_mask:a,token_type_ids:o}=this._tokenizer.encode(e,{text_pair:t,add_special_tokens:n,return_token_type_ids:r??this.return_token_type_ids});return{input_ids:i,attention_mask:a,...o?{token_type_ids:o}:{}}}tokenize(e,{pair:t=null,add_special_tokens:n=!1}={}){return this._tokenizer.tokenize(e,{text_pair:t,add_special_tokens:n})}encode(e,{text_pair:t=null,add_special_tokens:n=!0,return_token_type_ids:r=null}={}){return this._tokenizer.encode(e,{text_pair:t,add_special_tokens:n,return_token_type_ids:r}).ids}batch_decode(e,t={}){return e instanceof J&&(e=e.tolist()),e.map(e=>this.decode(e,t))}decode(e,t={}){if(e instanceof J&&(e=Uf(e)),!Array.isArray(e)||e.length===0||!mo(e[0]))throw Error(`token_ids must be a non-empty array of integers.`);return this.decode_single(e,t)}decode_single(e,{skip_special_tokens:t=!1,clean_up_tokenization_spaces:n=null}){return this._tokenizer.decode(e,{skip_special_tokens:t,clean_up_tokenization_spaces:n})}get_chat_template({chat_template:e=null,tools:t=null}={}){if(this.chat_template&&typeof this.chat_template==`object`){let n=this.chat_template;if(e!==null&&Object.hasOwn(n,e))e=n[e];else if(e===null){if(t!==null&&`tool_use`in n)e=n.tool_use;else if(`default`in n)e=n.default;else throw Error(`This model has multiple chat templates with no default specified! Please either pass a chat template or the name of the template you wish to use to the 'chat_template' argument. Available template names are ${Object.keys(n).sort()}.`)}}else if(e===null){if(this.chat_template)e=this.chat_template;else throw Error(`Cannot use apply_chat_template() because tokenizer.chat_template is not set and no template argument was passed! For information about writing templates and setting the tokenizer.chat_template attribute, please see the documentation at https://huggingface.co/docs/transformers/main/en/chat_templating`)}return e}apply_chat_template(e,t={}){let{tools:n=null,documents:r=null,chat_template:i=null,add_generation_prompt:a=!1,tokenize:o=!0,padding:s=!1,truncation:c=!1,max_length:l=null,return_tensor:u=!0,return_dict:d=!0,tokenizer_kwargs:f={},...p}=t;if(i=this.get_chat_template({chat_template:i,tools:n}),typeof i!=`string`)throw Error(`chat_template must be a string, but got ${typeof i}`);let m=this._compiled_template_cache.get(i);m===void 0&&(m=new ku(i),this._compiled_template_cache.set(i,m));let h=Object.create(null);for(let e of Wf){let t=qf(this.config,e);t&&(h[e]=t)}let g=m.render({messages:e,add_generation_prompt:a,tools:n,documents:r,...h,...p});if(o){let e=this._call(g,{add_special_tokens:!1,padding:s,truncation:c,max_length:l,return_tensor:u,...f});return d?e:e.input_ids}return g}};function Yf(e,t,n,r){if(!(`language_codes`in e)||!Array.isArray(e.language_codes))throw Error("Tokenizer must have `language_codes` attribute set and it should be an array of language ids.");if(!(`languageRegex`in e)||!(e.languageRegex instanceof RegExp))throw Error("Tokenizer must have `languageRegex` attribute set and it should be a regular expression.");if(!(`lang_to_token`in e)||typeof e.lang_to_token!=`function`)throw Error("Tokenizer must have `lang_to_token` attribute set and it should be a function.");let i=r.src_lang,a=r.tgt_lang;if(!e.language_codes.includes(a))throw Error(`Target language code "${a}" is not valid. Must be one of: {${e.language_codes.join(`, `)}}`);if(i!==void 0){if(!e.language_codes.includes(i))throw Error(`Source language code "${i}" is not valid. Must be one of: {${e.language_codes.join(`, `)}}`);let t=e._tokenizer.post_processor?.config;if(t&&`single`in t){for(let n of t.single)if(`SpecialToken`in n&&e.languageRegex.test(n.SpecialToken.id)){n.SpecialToken.id=e.lang_to_token(i);break}}}return r.forced_bos_token_id=e._tokenizer.token_to_id(e.lang_to_token(a)),e._call(t,n)}var Xf={};Na(Xf,{AlbertTokenizer:()=>Zf,AutoTokenizer:()=>Yp,BartTokenizer:()=>Qf,BertTokenizer:()=>$f,BlenderbotSmallTokenizer:()=>ep,BlenderbotTokenizer:()=>tp,BloomTokenizer:()=>np,CLIPTokenizer:()=>ip,CamembertTokenizer:()=>rp,CodeGenTokenizer:()=>op,CodeLlamaTokenizer:()=>ap,CohereAsrTokenizer:()=>cp,CohereTokenizer:()=>sp,ConvBertTokenizer:()=>lp,DebertaTokenizer:()=>dp,DebertaV2Tokenizer:()=>up,DistilBertTokenizer:()=>fp,ElectraTokenizer:()=>pp,EsmTokenizer:()=>mp,FalconTokenizer:()=>hp,GPT2Tokenizer:()=>vp,GPTNeoXTokenizer:()=>_p,GemmaTokenizer:()=>gp,HerbertTokenizer:()=>yp,LlamaTokenizer:()=>bp,M2M100Tokenizer:()=>xp,MBart50Tokenizer:()=>wp,MBartTokenizer:()=>Cp,MPNetTokenizer:()=>Dp,MarianTokenizer:()=>Sp,MgpstrTokenizer:()=>Tp,MobileBertTokenizer:()=>Ep,NllbTokenizer:()=>Op,NougatTokenizer:()=>kp,PreTrainedTokenizer:()=>Y,Qwen2Tokenizer:()=>Ap,RoFormerTokenizer:()=>Mp,RobertaTokenizer:()=>jp,SiglipTokenizer:()=>Np,SpeechT5Tokenizer:()=>Pp,SqueezeBertTokenizer:()=>Fp,T5Tokenizer:()=>Ip,TokenizersBackend:()=>Y,VitsTokenizer:()=>Rp,Wav2Vec2CTCTokenizer:()=>zp,WhisperTokenizer:()=>Kp,XLMRobertaTokenizer:()=>qp,XLMTokenizer:()=>Jp});var Zf=class extends Y{return_token_type_ids=!0},Qf=class extends Y{},$f=class extends Y{return_token_type_ids=!0},ep=class extends Y{},tp=class extends Y{},np=class extends Y{},rp=class extends Y{},ip=class extends Y{},ap=class extends Y{},op=class extends Y{},sp=class extends Y{},cp=class extends Y{},lp=class extends Y{return_token_type_ids=!0},up=class extends Y{return_token_type_ids=!0},dp=class extends Y{return_token_type_ids=!0},fp=class extends Y{},pp=class extends Y{return_token_type_ids=!0},mp=class extends Y{},hp=class extends Y{},gp=class extends Y{},_p=class extends Y{},vp=class extends Y{},yp=class extends Y{return_token_type_ids=!0},bp=class extends Y{padding_side=`left`},xp=class extends Y{constructor(e,t){super(e,t),this.languageRegex=/^__[a-z]{2,3}__$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)).map(e=>e.slice(2,-2)),this.lang_to_token=e=>`__${e}__`}_build_translation_inputs(e,t,n){return Yf(this,e,t,n)}},Sp=class extends Y{constructor(e,t){super(e,t),this.languageRegex=/^(>>\w+<<)\s*/g,this.supported_language_codes=Array.from(this.get_vocab().keys()).filter(e=>this.languageRegex.test(e)),B.warn('WARNING: `MarianTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}_encode_text(e){if(e===null)return null;let[t,...n]=e.trim().split(this.languageRegex);if(n.length===0)return super._encode_text(t);if(n.length===2){let[e,t]=n;return this.supported_language_codes.includes(e)||B.warn(`Unsupported language code "${e}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`),_o([e],super._encode_text(t))}}},Cp=class extends Y{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{2}_[A-Z]{2}$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)).map(e=>e),this.lang_to_token=e=>e}_build_translation_inputs(e,t,n){return Yf(this,e,t,n)}},wp=class extends Cp{},Tp=class extends Y{},Ep=class extends Y{return_token_type_ids=!0},Dp=class extends Y{},Op=class extends Y{constructor(e,t){super(e,t),this.languageRegex=/^[a-z]{3}_[A-Z][a-z]{3}$/,this.language_codes=this.all_special_tokens.filter(e=>this.languageRegex.test(e)),this.lang_to_token=e=>e}_build_translation_inputs(e,t,n){return Yf(this,e,t,n)}},kp=class extends Y{},Ap=class extends Y{},jp=class extends Y{},Mp=class extends Y{return_token_type_ids=!0},Np=class extends Y{},Pp=class extends Y{},Fp=class extends Y{return_token_type_ids=!0},Ip=class extends Y{},Lp=class extends wc{decode_chain(e){let t=``;for(let n=1;n[t,e]),[`burmese`,`my`],[`valencian`,`ca`],[`flemish`,`nl`],[`haitian`,`ht`],[`letzeburgesch`,`lb`],[`pushto`,`ps`],[`panjabi`,`pa`],[`moldavian`,`ro`],[`moldovan`,`ro`],[`sinhalese`,`si`],[`castilian`,`es`]]);function Up(e){e=e.toLowerCase();let t=Hp.get(e);if(t===void 0){let n=e.match(/^<\|([a-z]{2})\|>$/);if(n&&(e=n[1]),Vp.has(e))t=e;else{let t=e.length===2?Vp.keys():Vp.values();throw Error(`Language "${e}" is not supported. Must be one of: ${JSON.stringify(Array.from(t))}`)}}return t}var Wp=RegExp(`^[\\p{P}\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E]+$`,`gu`),Gp=.1,Kp=class extends Y{get timestamp_begin(){return this._tokenizer.token_to_id(`<|notimestamps|>`)+1}_decode_asr(e,{return_timestamps:t=!1,return_language:n=!1,time_precision:r=null,force_full_sequences:i=!0}={}){if(r===null)throw Error(`Must specify time_precision`);let a=null,o=t===`word`;function s(){return{language:a,timestamp:[null,null],text:``}}let c=[],l=s(),u=0,d=this.timestamp_begin,f=d+1500,p=[],m=[],h=!1,g=null,_=new Set(this.all_special_ids);for(let n of e){let e=n.tokens,i=o?n.token_timestamps:null,v=null,y=d;if(`stride`in n){let[t,i,a]=n.stride;if(u-=i,g=t-a,i&&(y=i/r+d),a)for(let t=e.length-1;t>=0;--t){let n=Number(e[t]);if(n>=d){if(v!==null&&(n-d)*r=d&&g<=f){let e=kd((g-d)*r+u,2);if(v!==null&&g>=v)h=!0;else if(h||p.length>0&&g0&&l.timestamp[1]!==null))for(let e of l.words)e.timestamp[1]>l.timestamp[1]&&l.timestamp[1]>=e.timestamp[0]&&(e.timestamp[1]=l.timestamp[1]);c.push(l),p=[],b=[],m=[],x=[],l=s()}}else if(b.push(g),o){let e=kd(i[n]+u,2),t;if(n+10?(p.push(b),o&&m.push(x)):p.every(e=>e.length===0)&&(l=s(),p=[],b=[],m=[],x=[])}if(p.length>0){if(i&&t)throw Error(`Whisper did not predict an ending timestamp, which can happen if audio is cut off in the middle of a word. Also make sure WhisperTimeStampLogitsProcessor was used during generation.`);let[e,n]=this.findLongestCommonSequence(p,m),r=this.decode(e);l.text=r,o&&(l.words=this.collateWordTimestamps(e,n,a)),c.push(l)}let v=Object.create(null),y=c.map(e=>e.text).join(``);if(t||n){for(let e=0;e0,o=a?[]:null,s=a?t[0]:null;for(let c=1;ce===g[n]&&s[i+n][0]-Gp<=t[c][m+n][0]).length:p.filter((e,t)=>e===g[t]).length;let v=e/1e4,y=_/e+v;_>1&&y>u&&(u=y,d=[i,o,m,h])}let[p,m,h,g]=d,_=Math.floor((m+p)/2),v=Math.floor((g+h)/2);if(a&&u===0&&r>0){let e=s[r-1][0],n=t[c].findIndex(t=>t[0]>=e);v=n===-1?l.length:n}i.push(...n.slice(0,_)),n=l.slice(v),r=n.length,a&&(o.push(...s.slice(0,_)),s=t[c].slice(v))}return i.push(...n),a?(o.push(...s),[i,o]):[i,[]]}collateWordTimestamps(e,t,n){let[r,i,a]=this.combineTokensIntoWords(e,n),o=[];for(let e=0;e=r){let e=((t-r)*n).toFixed(2);i.push(`<|${e}|>`),i.push([])}else i[i.length-1].push(t);return i=i.map(e=>typeof e==`string`?e:super.decode(e,t)),i.join(``)}splitTokensOnUnicode(e){let t=this.decode(e,{decode_with_timestamps:!0}),n=[],r=[],i=[],a=[],o=[],s=0;for(let c=0;c=this._tokenizer.token_to_id(`<|endoftext|>`),d=s.startsWith(` `),f=s.trim(),p=Wp.test(f);if(u||d||p||i.length===0)i.push(s),a.push(c),o.push(l);else{let e=i.length-1;i[e]+=s,a[e].push(...c),o[e].push(...l)}}return[i,a,o]}mergePunctuations(e,t,n,r,i){let a=structuredClone(e),o=structuredClone(t),s=structuredClone(n),c=a.length-2,l=a.length-1;for(;c>=0;)a[c].startsWith(` `)&&r.includes(a[c].trim())?(a[l]=a[c]+a[l],o[l]=_o(o[c],o[l]),s[l]=_o(s[c],s[l]),a[c]=``,o[c]=[],s[c]=[]):l=c,--c;for(c=0,l=1;le),o.filter(e=>e.length>0),s.filter(e=>e.length>0)]}},qp=class extends Y{},Jp=class extends Y{return_token_type_ids=!0;constructor(e,t){super(e,t),B.warn('WARNING: `XLMTokenizer` is not yet supported by Hugging Face\'s "fast" tokenizers library. Therefore, you may experience slightly inaccurate results.')}},Yp=class{static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`}={}){let[o,s]=await Hf(e,{progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a}),c=s.tokenizer_class?.replace(/Fast$/,``)??`PreTrainedTokenizer`,l=Xf[c];return l||=(B.warn(`Unknown tokenizer class "${c}", attempting to construct from base class.`),Y),new l(o,s)}},Xp=`https://github.com/huggingface/transformers.js/issues/new/choose`,Zp=`preprocessor_config.json`,Qp=`preprocessor_config.json`,$p=`processor_config.json`,em=`chat_template.jinja`,tm=class extends uo{static classes=[`image_processor_class`,`tokenizer_class`,`feature_extractor_class`];static uses_processor_config=!1;static uses_chat_template_file=!1;constructor(e,t,n){super(),this.config=e,this.components=t,this.chat_template=n}get image_processor(){return this.components.image_processor}get tokenizer(){return this.components.tokenizer}get feature_extractor(){return this.components.feature_extractor}apply_chat_template(e,t={}){if(!this.tokenizer)throw Error(`Unable to apply chat template without a tokenizer.`);return this.tokenizer.apply_chat_template(e,{tokenize:!1,chat_template:this.chat_template??void 0,...t})}batch_decode(...e){if(!this.tokenizer)throw Error(`Unable to decode without a tokenizer.`);return this.tokenizer.batch_decode(...e)}decode(...e){if(!this.tokenizer)throw Error(`Unable to decode without a tokenizer.`);return this.tokenizer.decode(...e)}async _call(e,...t){for(let n of[this.image_processor,this.feature_extractor,this.tokenizer])if(n)return n(e,...t);throw Error(`No image processor, feature extractor, or tokenizer found.`)}static async from_pretrained(e,t={}){let[n,r,i]=await Promise.all([this.uses_processor_config?_d(e,$p,!0,t):{},Promise.all(this.classes.filter(e=>e in this).map(async n=>{let r=await this[n].from_pretrained(e,t);return[n.replace(/_class$/,``),r]})).then(Object.fromEntries),this.uses_chat_template_file?gd(e,em,!0,t):null]);return new this(n,r,i)}};Na({},{ChatterboxProcessor:()=>Ym,CohereAsrProcessor:()=>Zm,Florence2Processor:()=>zg,Gemma3Processor:()=>Bg,Gemma3nProcessor:()=>Vg,Gemma4Processor:()=>Hg,Glm46VProcessor:()=>Wg,GraniteSpeechProcessor:()=>Gg,GroundingDinoProcessor:()=>qg,Idefics3Processor:()=>Zg,JinaCLIPProcessor:()=>$g,Lfm2VlProcessor:()=>e_,LlavaProcessor:()=>t_,MgpstrProcessor:()=>r_,MoonshineProcessor:()=>i_,OwlViTProcessor:()=>a_,PaliGemmaProcessor:()=>c_,Phi3VProcessor:()=>d_,PixtralProcessor:()=>f_,Processor:()=>tm,PyAnnoteProcessor:()=>p_,Qwen2VLProcessor:()=>Ug,Qwen2_5_VLProcessor:()=>m_,Qwen3VLProcessor:()=>h_,Sam2Processor:()=>__,Sam2VideoProcessor:()=>v_,SamProcessor:()=>g_,SmolVLMProcessor:()=>Zg,SpeechT5Processor:()=>y_,UltravoxProcessor:()=>b_,VLChatProcessor:()=>Qg,VoxtralProcessor:()=>T_,VoxtralRealtimeProcessor:()=>j_,Wav2Vec2Processor:()=>M_,Wav2Vec2ProcessorWithLM:()=>N_,WhisperProcessor:()=>P_});var nm=class extends uo{constructor(e){super(),this.config=e}static async from_pretrained(e,t={}){let n=await _d(e,Zp,!0,t);return new this(n)}};function rm(e,t){if(!(e instanceof Float32Array||e instanceof Float64Array))throw Error(`${t} expects input to be a Float32Array or a Float64Array, but got ${e?.constructor?.name??typeof e} instead. If using the feature extractor directly, remember to use \`load_audio(url, sampling_rate)\` to obtain the raw audio data of the file/url.`)}var im={};Na(im,{ASTFeatureExtractor:()=>Om,ChatterboxFeatureExtractor:()=>Am,ClapFeatureExtractor:()=>jm,CohereAsrFeatureExtractor:()=>Pm,DacFeatureExtractor:()=>Fm,EncodecFeatureExtractor:()=>km,FeatureExtractor:()=>nm,Gemma3nAudioFeatureExtractor:()=>Im,Gemma4AudioFeatureExtractor:()=>Lm,GraniteSpeechFeatureExtractor:()=>Rm,MoonshineFeatureExtractor:()=>zm,ParakeetFeatureExtractor:()=>Nm,PyAnnoteFeatureExtractor:()=>Bm,SeamlessM4TFeatureExtractor:()=>Vm,SnacFeatureExtractor:()=>Hm,SpeechT5FeatureExtractor:()=>Um,VoxtralRealtimeFeatureExtractor:()=>Km,Wav2Vec2FeatureExtractor:()=>Wm,WeSpeakerFeatureExtractor:()=>Gm,WhisperFeatureExtractor:()=>qm});var am={fromWeb:()=>{}};async function om(e,t){if(R.IS_BROWSER_ENV){if(R.IS_WEBWORKER_ENV)throw Error(`Unable to save a file from a Web Worker.`);let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.click(),r.remove(),URL.revokeObjectURL(n)}else if(R.IS_FS_AVAILABLE){let n=t.stream();am.fromWeb(n),Pa.createWriteStream(e),await void 0}else throw Error(`Unable to save because filesystem is disabled in this environment.`)}async function sm(e,t){if(typeof AudioContext>`u`)throw Error("Unable to load audio from path/URL since `AudioContext` is not available in your environment. Instead, audio data should be passed directly to the pipeline/processor. For more information and some example code, see https://huggingface.co/docs/transformers.js/guides/node-audio-processing.");let n=await(await cd(e)).arrayBuffer(),r=new AudioContext({sampleRate:t});t===void 0&&B.warn(`No sampling rate provided, using default of ${r.sampleRate}Hz.`);let i=await r.decodeAudioData(n),a;if(i.numberOfChannels===2){let e=Math.sqrt(2),t=i.getChannelData(0),n=i.getChannelData(1);a=new Float32Array(t.length);for(let r=0;r2595*Math.log10(1+e/700),kaldi:e=>1127*Math.log(1+e/700),slaney:(e,t=1e3,n=15,r=27/Math.log(6.4))=>e>=t?n+Math.log(e/t)*r:3*e/200};function pm(e,t=`htk`){let n=fm[t];if(!n)throw Error(`mel_scale should be one of "htk", "slaney" or "kaldi".`);return typeof e==`number`?n(e):e.map(e=>n(e))}var mm={htk:e=>700*(10**(e/2595)-1),kaldi:e=>700*(Math.exp(e/1127)-1),slaney:(e,t=1e3,n=15,r=Math.log(6.4)/27)=>e>=n?t*Math.exp(r*(e-n)):200*e/3};function hm(e,t=`htk`){let n=mm[t];if(!n)throw Error(`mel_scale should be one of "htk", "slaney" or "kaldi".`);return typeof e==`number`?n(e):e.map(e=>n(e))}function gm(e,t){let n=Float64Array.from({length:t.length-1},(e,n)=>t[n+1]-t[n]),r=Array.from({length:e.length},()=>Array(t.length));for(let n=0;nArray(e.length));for(let t=0;te+r*n)}function vm(e,t,n,r,i,a=null,o=`htk`,s=!1){if(a!==null&&a!==`slaney`)throw Error(`norm must be one of null or "slaney"`);if(e<2)throw Error(`Require num_frequency_bins: ${e} >= 2`);if(n>r)throw Error(`Require min_frequency: ${n} <= max_frequency: ${r}`);let c=_m(pm(n,o),pm(r,o),t+2),l=hm(c,o),u;if(s){let t=i/((e-1)*2);u=pm(Float64Array.from({length:e},(e,n)=>n*t),o),l=c}else u=_m(0,Math.floor(i/2),e);let d=gm(u,l);if(a!==null&&a===`slaney`)for(let n=0;ni)throw Error(`frame_length (${n}) may not be larger than fft_length (${i})`);if(w!==n)throw Error(`Length of the window (${w}) must equal frame_length (${n})`);if(r<=0)throw Error(`hop_length must be greater than zero`);if(a===null&&d!==null)throw Error("You have provided `mel_filters` but `power` is `None`. Mel spectrogram computation is not yet supported for complex-valued spectrogram. Specify `power` to fix this issue.");if(!u)throw Error("`preemphasis_htk_flavor=false` is not currently supported.");if(o){let t=Math.floor(n/2);switch(s){case`reflect`:e=ym(e,t,t);break;case`constant`:{let n=new e.constructor(e.length+2*t);n.set(e,t),e=n;break}case`semicausal`:{let n=new e.constructor(e.length+t);n.set(e,t),e=n;break}default:throw Error(`pad_mode="${s}" not implemented yet.`)}}let T=Math.floor(1+Math.floor((e.length-n)/r));y!==null&&TT?x&&(D=b):D=te=b);let O=new Dd(i),ne=new Float64Array(i),re=new Float64Array(O.outputBufferSize),ie=new Float32Array(E*D);for(let i=0;i=1;--e)ne[e]-=l*ne[e-1];ne[0]*=1-l}for(let e=0;ee**.85);break;default:throw Error(`Unknown window type ${t}.`)}if(n&&(o=o.subarray(0,e)),r===null||e===r)return o;if(e>r)throw Error(`Length of the window (${e}) may not be larger than frame_length (${r})`);let s=new Float64Array(r),c=i?Math.floor((r-e)/2):0;return s.set(o,c),s}function Tm(e,t){let n=e.reduce((e,t)=>e+t.length,0),r=new ArrayBuffer(44),i=new DataView(r);return Em(i,0,`RIFF`),i.setUint32(4,36+n*4,!0),Em(i,8,`WAVE`),Em(i,12,`fmt `),i.setUint32(16,16,!0),i.setUint16(20,3,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*4,!0),i.setUint16(32,4,!0),i.setUint16(34,32,!0),Em(i,36,`data`),i.setUint32(40,n*4,!0),new Blob([r,...e.map(e=>e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e.slice())],{type:`audio/wav`})}function Em(e,t,n){for(let r=0;re+t.length,0),t=new Float32Array(e),n=0;for(let e of this.audio)t.set(e,n),n+=e.length;return t}return this.audio}toBlob(){let e=this.audio;return e instanceof Float32Array&&(e=[e]),Tm(e,this.sampling_rate)}async save(e){return om(e,this.toBlob())}},Om=class extends nm{constructor(e){super(e);let t=this.config.sampling_rate,n=vm(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=wm(400,`hann`,{periodic:!1}),this.mean=this.config.mean,this.std=this.config.std}async _extract_fbank_features(e,t){return Cm(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e){rm(e,`ASTFeatureExtractor`);let t=await this._extract_fbank_features(e,this.config.max_length);if(this.config.do_normalize){let e=this.std*2,n=t.data;for(let t=0;t0){if(n===`rand_trunc`){let n=Math.floor(Fu.random()*(a+1));e=e.subarray(n,n+t),i=await this._extract_fbank_features(e,this.mel_filters_slaney,this.config.nb_max_samples)}else throw Error(`Truncation strategy "${n}" not implemented`)}else{if(a<0){let n=new Float64Array(t);if(n.set(e),r===`repeat`)for(let r=e.length;r=1;--n)e[n]-=t*e[n-1];return await Cm(e,this.window,this.window.length,this.config.hop_length,{fft_length:this.config.n_fft,power:2,mel_filters:this.config.mel_filters,log_mel:`log`,mel_floor:-1/0,pad_mode:`constant`,center:!0,transpose:!0,mel_offset:2**-24})}async _call(e){rm(e,`ParakeetFeatureExtractor`);let t=await this._extract_fbank_features(e),n=Math.floor((e.length+Math.floor(this.config.n_fft/2)*2-this.config.n_fft)/this.config.hop_length),r=t.data;r.fill(0,n*t.dims[1]);let[i,a]=t.dims,o=new Float64Array(a),s=new Float64Array(a);for(let e=0;e1?n-1:1;for(let e=0;e=l){s.push(e.slice(c,l));break}let t=Math.max(c,c+a-o),n=Math.min(c+a,l),i;i=n<=t?c+a:this._find_split_point_energy(e,t,n,r),i=Math.max(c+1,Math.min(i,l)),s.push(e.slice(c,i)),c=i}return s}_find_split_point_energy(e,t,n,r){let i=n-t;if(i<=r)return Math.floor((t+n)/2);let a=1/0,o=t,s=i-r;for(let n=0;n<=s;n+=r){let i=0;for(let a=0;at&&(e=e.slice(0,t)),r&&e.length%i!==0){let t=i-e.length%i,n=new Float64Array(e.length+t);n.set(e),this.config.padding_value!==0&&n.fill(this.config.padding_value,e.length),e=n}let a=await this._extract_fbank_features(e,this.config.max_length),o=Nf([1,a.dims[0]],!0);return{input_features:a.unsqueeze_(0),input_features_mask:o}}},Lm=class extends Im{async _extract_fbank_features(e,t){let{frame_length:n,hop_length:r,fft_length:i}=this.config,a=Math.floor(n/2),o=Math.floor((e.length+a-(n+1))/r)+1;return Cm(e,this.window,n,r,{fft_length:i,center:!0,pad_mode:`semicausal`,onesided:!0,preemphasis:this.config.preemphasis,preemphasis_htk_flavor:this.config.preemphasis_htk_flavor,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:this.config.mel_floor,mel_floor_mode:`add`,remove_dc_offset:!1,transpose:!0,max_num_frames:o})}async _call(e,t={}){rm(e,`Gemma4AudioFeatureExtractor`);let n=e.length,r=await super._call(e,t),{input_features:i}=r,[,a,o]=i.dims,{frame_length:s,hop_length:c}=this.config,l=Math.floor(s/2),u=s+1,d=new Uint8Array(n+l+(t.pad_to_multiple_of??128));d.fill(1,l,l+n);let f=new Uint8Array(a);for(let e=0;e({id:e,start:t*n,end:r*n,confidence:i/(r-t)})))}return r}},Vm=class extends nm{constructor(e){super(e);let t=this.config.sampling_rate,n=vm(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=wm(400,`povey`,{periodic:!1})}async _extract_fbank_features(e,t){return e=e.map(e=>e*32768),Cm(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,max_num_frames:t,transpose:!0})}async _call(e,{padding:t=!0,pad_to_multiple_of:n=2,do_normalize_per_mel_bins:r=!0,return_attention_mask:i=!0}={}){rm(e,`SeamlessM4TFeatureExtractor`);let a=await this._extract_fbank_features(e,this.config.max_length);if(r){let[e,t]=a.dims,n=a.data;for(let r=0;r0){let n=new Float32Array(t*(e+s));n.set(r),n.fill(this.config.padding_value,r.length);let c=e+s;a=new J(a.type,n,[c,t]),i&&(o=new J(`int64`,new BigInt64Array(c),[1,c]),o.data.fill(1n,0,e))}}let[s,c]=a.dims,l=this.config.stride;if(s%l!==0)throw Error(`The number of frames (${s}) must be a multiple of the stride (${l}).`);let u=a.view(1,Math.floor(s/l),c*l),d={input_features:u};if(i){let e=u.dims[1],t=new BigInt64Array(e);if(o){let e=o.data;for(let n=1,r=0;ne+t,0)/e.length,n=e.reduce((e,n)=>e+(n-t)**2,0)/e.length;return e.map(e=>(e-t)/Math.sqrt(n+1e-7))}async _call(e){rm(e,`Wav2Vec2FeatureExtractor`),e instanceof Float64Array&&(e=new Float32Array(e));let t=e;this.config.do_normalize&&(t=this._zero_mean_unit_var_norm(t));let n=[1,t.length];return{input_values:new J(`float32`,t,n),attention_mask:new J(`int64`,new BigInt64Array(t.length).fill(1n),n)}}},Gm=class extends nm{constructor(e){super(e);let t=this.config.sampling_rate,n=vm(257,this.config.num_mel_bins,20,Math.floor(t/2),t,null,`kaldi`,!0);this.mel_filters=n,this.window=wm(400,`hamming`,{periodic:!1}),this.min_num_frames=this.config.min_num_frames}async _extract_fbank_features(e){return e=e.map(e=>e*32768),Cm(e,this.window,400,160,{fft_length:512,power:2,center:!1,preemphasis:.97,mel_filters:this.mel_filters,log_mel:`log`,mel_floor:1.192092955078125e-7,remove_dc_offset:!0,transpose:!0,min_num_frames:this.min_num_frames})}async _call(e){rm(e,`WeSpeakerFeatureExtractor`);let t=(await this._extract_fbank_features(e)).unsqueeze_(0);if(this.config.fbank_centering_span===null){let e=t.mean(1).data,n=t.data,[r,i,a]=t.dims;for(let t=0;tr?(e.length>this.config.n_samples&&B.warn("Attempting to extract features for audio longer than 30 seconds. If using a pipeline to extract transcript from a long audio clip, remember to specify `chunk_length_s` and/or `stride_length_s`."),n=e.slice(0,r)):(n=new Float32Array(r),n.set(e)),{input_features:(await this._extract_fbank_features(n)).unsqueeze_(0)}}},Jm=class{static async from_pretrained(e,t={}){let n=await _d(e,Zp,!0,t),r=n.feature_extractor_type,i=im[r];if(!i)throw Error(`Unknown feature_extractor_type: '${r}'. Please report this at ${Xp}.`);return new i(n)}},Ym=class extends tm{static tokenizer_class=Yp;static feature_extractor_class=Jm;async _call(e,t=null){let n=this.tokenizer(e),r=t?await this.feature_extractor(t):{};return{...n,...r}}},Xm=new Set([`ja`,`zh`]),Zm=class extends tm{static tokenizer_class=Yp;static feature_extractor_class=Jm;static uses_processor_config=!0;get_decoder_prompt_ids(e=`en`){let t=[`▁`,`<|startofcontext|>`,`<|startoftranscript|>`,`<|emo:undefined|>`,`<|${e}|>`,`<|${e}|>`,`<|pnc|>`,`<|noitn|>`,`<|notimestamp|>`,`<|nodiarize|>`];return this.tokenizer.convert_tokens_to_ids(t)}static join_chunks(e,t=`en`){let n=e.filter(e=>e&&e.trim());if(n.length===0)return``;let r=Xm.has(t)?``:` `;return[n[0].trimEnd(),...n.slice(1).map(e=>e.trim())].join(r)}async _call(e){return await this.feature_extractor(e)}},Qm={},$m,eh,th;if(R.IS_WEB_ENV)$m=(e,t)=>{if(!self.OffscreenCanvas)throw Error(`OffscreenCanvas not supported by this environment.`);return new self.OffscreenCanvas(e,t)},th=self.createImageBitmap,eh=self.ImageData;else if(Qm)th=async e=>{let t=(await e.metadata()).channels,{data:n,info:r}=await e.rotate().raw().toBuffer({resolveWithObject:!0}),i=new ih(new Uint8ClampedArray(n),r.width,r.height,r.channels);return t!==void 0&&t!==r.channels&&i.convert(t),i};else throw Error(`Unable to load image processing library.`);var nh={0:`nearest`,1:`lanczos`,2:`bilinear`,3:`bicubic`,4:`box`,5:`hamming`},rh=new Map([[`png`,`image/png`],[`jpg`,`image/jpeg`],[`jpeg`,`image/jpeg`],[`gif`,`image/gif`]]),ih=class e{constructor(e,t,n,r){this.data=e,this.width=t,this.height=n,this.channels=r}get size(){return[this.width,this.height]}static async read(t){if(t instanceof e)return t;if(typeof t==`string`||t instanceof URL)return await this.fromURL(t);if(t instanceof Blob)return await this.fromBlob(t);if(typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&t instanceof OffscreenCanvas)return this.fromCanvas(t);throw Error(`Unsupported input type: ${typeof t}`)}static fromCanvas(t){if(!R.IS_WEB_ENV)throw Error(`fromCanvas() is only supported in browser environments.`);let n=t.getContext(`2d`).getImageData(0,0,t.width,t.height).data;return new e(n,t.width,t.height,4)}static async fromURL(e){let t=await cd(e);if(t.status!==200)throw Error(`Unable to read image from "${e}" (${t.status} ${t.statusText})`);let n=await t.blob();return this.fromBlob(n)}static async fromBlob(e){if(R.IS_WEB_ENV){let t=await th(e),n=$m(t.width,t.height).getContext(`2d`);return n.drawImage(t,0,0),new this(n.getImageData(0,0,t.width,t.height).data,t.width,t.height,4)}{let t=Qm(await e.arrayBuffer());return await th(t)}}static fromTensor(t,n=`CHW`){if(t.dims.length!==3)throw Error(`Tensor should have 3 dimensions, but has ${t.dims.length} dimensions.`);if(n===`CHW`)t=t.permute(1,2,0);else if(n!==`HWC`)throw Error(`Unsupported channel format: ${n}`);if(!(t.data instanceof Uint8ClampedArray||t.data instanceof Uint8Array))throw Error(`Unsupported tensor type: ${t.type}`);switch(t.dims[2]){case 1:case 2:case 3:case 4:return new e(t.data,t.dims[1],t.dims[0],t.dims[2]);default:throw Error(`Unsupported number of channels: ${t.dims[2]}`)}}grayscale(){if(this.channels===1)return this;let e=new Uint8ClampedArray(this.width*this.height*1);switch(this.channels){case 3:case 4:for(let t=0,n=0;t=0?c=r:u=-r,i>=0?l=i:d=-i,s.drawImage(o,c,l,t,n,u,d,t,n),new e(s.getImageData(0,0,t,n).data,t,n,4).convert(a)}{let e=this.toSharp();if(r>=0&&i>=0)e=e.extract({left:Math.floor(r),top:Math.floor(i),width:t,height:n});else if(r<=0&&i<=0){let a=Math.floor(-i),o=Math.floor(-r);e=e.extend({top:a,left:o,right:t-this.width-o,bottom:n-this.height-a})}else{let a=[0,0],o=0;i<0?(a[0]=Math.floor(-i),a[1]=n-this.height-a[0]):o=Math.floor(i);let s=[0,0],c=0;r<0?(s[0]=Math.floor(-r),s[1]=t-this.width-s[0]):c=Math.floor(r),e=e.extend({top:a[0],bottom:a[1],left:s[0],right:s[1]}).extract({left:c,top:o,width:t,height:n})}return await th(e)}}async toBlob(e=`image/png`,t=1){if(!R.IS_WEB_ENV)throw Error(`toBlob() is only supported in browser environments.`);return await this.toCanvas().convertToBlob({type:e,quality:t})}toTensor(e=`CHW`){let t=new J(`uint8`,new Uint8Array(this.data),[this.height,this.width,this.channels]);if(e!==`HWC`){if(e===`CHW`)t=t.permute(2,0,1);else throw Error(`Unsupported channel format: ${e}`)}return t}toCanvas(){if(!R.IS_WEB_ENV)throw Error(`toCanvas() is only supported in browser environments.`);let e=this.clone().rgba(),t=$m(e.width,e.height),n=new eh(e.data,e.width,e.height);return t.getContext(`2d`).putImageData(n,0,0),t}split(){let{data:t,width:n,height:r,channels:i}=this,a=t.constructor,o=t.length/i,s=Array.from({length:i},()=>new a(o));for(let e=0;enew e(t,n,r,1))}_update(e,t,n,r=null){return this.data=e,this.width=t,this.height=n,r!==null&&(this.channels=r),this}clone(){return new e(this.data.slice(),this.width,this.height,this.channels)}convert(e){if(this.channels===e)return this;switch(e){case 1:this.grayscale();break;case 3:this.rgb();break;case 4:this.rgba();break;default:throw Error(`Conversion failed due to unsupported number of channels: ${this.channels}`)}return this}async save(e){if(R.IS_WEB_ENV){if(R.IS_WEBWORKER_ENV)throw Error(`Unable to save an image from a Web Worker.`);let t=e.split(`.`).pop().toLowerCase(),n=rh.get(t)??`image/png`;return om(e,await this.toBlob(n))}if(R.IS_FS_AVAILABLE)await this.toSharp().toFile(e);else throw Error(`Unable to save the image because filesystem is disabled in this environment.`)}toSharp(){if(R.IS_WEB_ENV)throw Error(`toSharp() is only supported in server-side environments.`);return Qm(this.data,{raw:{width:this.width,height:this.height,channels:this.channels}})}};ih.read.bind(ih);function ah(e,t,n=0,r=null){let i=e/t,a=Ad(i)*t;return r!==null&&a>r&&(a=Math.floor(i)*t),at&&i.push(e)}else{let e=Cd(n.data)[1];if(e===c-1||(a=bd(n.data),a[e]e*o[(t+1)%2])),u.boxes.push(n),u.classes.push(t),u.scores.push(a[t])}}l.push(u)}return l}function lh(e,t=null){let n=e.logits,r=n.dims[0];if(t!==null&&t.length!==r)throw Error(`Make sure that you pass in as many target sizes as the batch dimension of the logits`);let i=[];for(let e=0;el[n]&&(l[n]=t[n],u[n]=e)}let d=Array(a.dims[0]);for(let e=0;ee!==void 0);i.push({segmentation:c,labels:f})}return i}function uh(e,t,n,r){let i=[],a=[],o=[];for(let s=0;sn&&(i.push(l),a.push(d),o.push(u))}return[i,a,o]}function dh(e,t,n,r=.5,i=.8){let a=[],o=0,s=0,c=t[n].data;for(let t=0;t=r&&++s;let l=o>0&&s>0;return l&&=o/s>i,[l,a]}function fh(e,t,n,r,i,a=null,o=null){let[s,c]=o??e[0].dims,l=new J(`int32`,new Int32Array(s*c),[s,c]),u=[];if(o!==null)for(let t=0;tf[e]&&(d[e]=n,f[e]=i[e])}let p=0,m=l.data;for(let a=0;a200)throw Error(`absolute aspect ratio must be smaller than 200, got ${Math.max(e,t)/Math.min(e,t)}`);let o=Math.round(e/n)*n,s=Math.round(t/n)*n;if(a*o*s>i){let r=Math.sqrt(a*e*t/i);o=Math.max(n,Math.floor(e/r/n)*n),s=Math.max(n,Math.floor(t/r/n)*n)}else if(a*o*si?c=Math.floor(i*s/r):i>r&&(s=Math.floor(r*c/i)),await e.resize(c,s,{resample:n}))}async crop_margin(e,t=200){let n=e.clone().grayscale(),r=Sd(n.data)[0],i=Cd(n.data)[0]-r;if(i===0)return e;let a=t/255,o=n.width,s=n.height,c=0,l=0,u=n.data;for(let e=0;ethis.preprocess(e)));return{pixel_values:Df(n.map(e=>e.pixel_values),0),original_sizes:n.map(e=>e.original_size),reshaped_input_sizes:n.map(e=>e.reshaped_input_size)}}static async from_pretrained(e,t={}){let n=await _d(e,Qp,!0,t);return new this(n)}},gh={};Na(gh,{BeitFeatureExtractor:()=>_h,BitImageProcessor:()=>vh,CHMv2ImageProcessor:()=>bh,CLIPFeatureExtractor:()=>Sh,CLIPImageProcessor:()=>xh,ChineseCLIPFeatureExtractor:()=>yh,ConvNextFeatureExtractor:()=>wh,ConvNextImageProcessor:()=>Ch,DINOv3ViTImageProcessor:()=>kh,DPTFeatureExtractor:()=>Nh,DPTImageProcessor:()=>Mh,DeiTFeatureExtractor:()=>Eh,DeiTImageProcessor:()=>Th,DetrFeatureExtractor:()=>Oh,DetrImageProcessor:()=>Dh,DonutFeatureExtractor:()=>jh,DonutImageProcessor:()=>Ah,EfficientNetImageProcessor:()=>Ph,GLPNFeatureExtractor:()=>Vh,Gemma3ImageProcessor:()=>Fh,Gemma4ImageProcessor:()=>Rh,Glm46VImageProcessor:()=>Bh,GroundingDinoImageProcessor:()=>Hh,Idefics3ImageProcessor:()=>Uh,ImageFeatureExtractor:()=>X,ImageProcessor:()=>X,JinaCLIPImageProcessor:()=>Gh,Lfm2VlImageProcessor:()=>Zh,LlavaOnevisionImageProcessor:()=>Qh,Mask2FormerImageProcessor:()=>tg,MaskFormerFeatureExtractor:()=>eg,MaskFormerImageProcessor:()=>$h,MobileNetV1FeatureExtractor:()=>rg,MobileNetV1ImageProcessor:()=>ng,MobileNetV2FeatureExtractor:()=>ag,MobileNetV2ImageProcessor:()=>ig,MobileNetV3FeatureExtractor:()=>sg,MobileNetV3ImageProcessor:()=>og,MobileNetV4FeatureExtractor:()=>lg,MobileNetV4ImageProcessor:()=>cg,MobileViTFeatureExtractor:()=>dg,MobileViTImageProcessor:()=>ug,NougatImageProcessor:()=>fg,OwlViTFeatureExtractor:()=>mg,OwlViTImageProcessor:()=>pg,Owlv2ImageProcessor:()=>hg,Phi3VImageProcessor:()=>xg,PixtralImageProcessor:()=>Sg,PvtImageProcessor:()=>Cg,Qwen2VLImageProcessor:()=>zh,RTDetrImageProcessor:()=>wg,Sam2ImageProcessor:()=>Tg,Sam3ImageProcessor:()=>Tg,SamImageProcessor:()=>Tg,SapiensFeatureExtractor:()=>Dg,SapiensImageProcessor:()=>Eg,SegformerFeatureExtractor:()=>kg,SegformerImageProcessor:()=>Og,SiglipImageProcessor:()=>Ag,SmolVLMImageProcessor:()=>Uh,Swin2SRImageProcessor:()=>jg,VLMImageProcessor:()=>Wh,ViTFeatureExtractor:()=>Ng,ViTImageProcessor:()=>Mg,VitMatteImageProcessor:()=>Pg,VitPoseImageProcessor:()=>Fg,YolosFeatureExtractor:()=>Lg,YolosImageProcessor:()=>Ig});var _h=class extends X{},vh=class extends X{},yh=class extends X{},bh=class extends X{},xh=class extends X{},Sh=class extends xh{},Ch=class extends X{constructor(e){super(e),this.crop_pct=this.config.crop_pct??224/256}async resize(e){let t=this.size?.shortest_edge;if(t===void 0)throw Error(`Size dictionary must contain 'shortest_edge' key.`);if(t<384){let n=Math.floor(t/this.crop_pct),[r,i]=this.get_resize_output_image_size(e,{shortest_edge:n});e=await e.resize(r,i,{resample:this.resample}),e=await e.center_crop(t,t)}else e=await e.resize(t,t,{resample:this.resample});return e}},wh=class extends Ch{},Th=class extends X{},Eh=class extends Th{},Dh=class extends X{async _call(e){let t=await super._call(e),n=Nf([t.pixel_values.dims[0],64,64],1n);return{...t,pixel_mask:n}}post_process_object_detection(...e){return ch(...e)}post_process_panoptic_segmentation(...e){return mh(...e)}post_process_instance_segmentation(...e){return hh(...e)}},Oh=class extends Dh{},kh=class extends X{},Ah=class extends X{pad_image(e,t,n,r={}){let[i,a,o]=t,s=this.image_mean;Array.isArray(this.image_mean)||(s=Array(o).fill(s));let c=this.image_std;Array.isArray(c)||(c=Array(o).fill(s));let l=s.map((e,t)=>-e/c[t]);return super.pad_image(e,t,n,{center:!0,constant_values:l,...r})}},jh=class extends Ah{},Mh=class extends X{},Nh=class extends Mh{},Ph=class extends X{constructor(e){super(e),this.include_top=this.config.include_top??!0,this.include_top&&(this.image_std=this.image_std.map(e=>e*e))}},Fh=class extends X{};function Ih(e,t,n,r,i){let a=r*n**2,o=Math.sqrt(a/(e*t)),s=i*n,c=Math.floor(o*e/s)*s,l=Math.floor(o*t/s)*s;if(c===0&&l===0)throw Error(`Attempting to resize to a 0 x 0 image. Resized height should be divisible by \`pooling_kernel_size * patch_size\`=${s}.`);let u=Math.floor(r/i**2)*s;return c===0?(c=s,l=Math.min(Math.floor(t/e)*s,u)):l===0&&(l=s,c=Math.min(Math.floor(e/t)*s,u)),[c,l]}function Lh(e,t,n,r,i,a,o){let s=Math.floor(t/i),c=Math.floor(n/i),l=s*c,u=i*i*r,d=new Float32Array(a*u),f=0;for(let t=0;ta),0));let l=a.dims[0]/o,u=a.dims[1],d=Math.floor(a.dims[2]/c),f=Math.floor(a.dims[3]/c);return{pixel_values:a.view(l,o,u,Math.floor(d/s),s,c,Math.floor(f/s),s,c).permute(0,3,6,4,7,2,1,5,8).view(l*d*f,u*o*c*c),image_grid_thw:new J(`int64`,[l,d,f],[1,3]),original_sizes:r,reshaped_input_sizes:i}}},Bh=class extends zh{get_resize_output_image_size(e,t){let n=this.patch_size*this.merge_size,r=this.config.temporal_patch_size??2;return ph(e.height,e.width,n,this.min_pixels,this.max_pixels,r)}},Vh=class extends X{},Hh=class extends X{async _call(e){let t=await super._call(e),n=t.pixel_values.dims,r=Ff([n[0],n[2],n[3]]);return{...t,pixel_mask:r}}},Uh=class extends X{constructor(e){super(e),this.do_image_splitting=e.do_image_splitting??!0,this.max_image_size=e.max_image_size}get_resize_for_vision_encoder(e,t){let[n,r]=e.dims.slice(-2),i=r/n;return r>=n?(r=Math.ceil(r/t)*t,n=Math.floor(r/i),n=Math.ceil(n/t)*t):(n=Math.ceil(n/t)*t,r=Math.floor(n*i),r=Math.ceil(r/t)*t),{height:n,width:r}}async _call(e,{do_image_splitting:t=null,return_row_col_info:n=!1}={}){let r;if(!Array.isArray(e))r=[[e]];else{if(e.length===0||!e[0])throw Error(`No images provided.`);r=Array.isArray(e[0])?e:[e]}let i=[],a=[],o=[],s=[],c=[];for(let e of r){let n=await Promise.all(e.map(e=>this.preprocess(e)));s.push(...n.map(e=>e.original_size)),c.push(...n.map(e=>e.reshaped_input_size)),n.forEach(e=>e.pixel_values.unsqueeze_(0));let{longest_edge:r}=this.max_image_size,l;if(t??this.do_image_splitting){let e=Array(n.length),t=Array(n.length);l=await Promise.all(n.map(async(n,i)=>{let a=this.get_resize_for_vision_encoder(n.pixel_values,r),o=await _f(n.pixel_values,{size:[a.height,a.width]}),{frames:s,num_splits_h:c,num_splits_w:l}=await this.split_image(o,this.max_image_size);return e[i]=c,t[i]=l,Ef(s,0)})),a.push(e),o.push(t)}else{let e=[r,r];l=await Promise.all(n.map(t=>_f(t.pixel_values,{size:e}))),a.push(Array(n.length).fill(0)),o.push(Array(n.length).fill(0))}i.push(Ef(l,0))}let l=i.length,[u,d,f,p]=i[0].dims,m,h;if(l===1)m=i[0].unsqueeze_(0),h=Nf([l,u,f,p],!0);else{let e=Math.max(...i.map(e=>e.dims.at(0)));h=Nf([l,e,f,p],!0);let t=h.data,n=e*f*p;for(let r=0;rn||o>r){s=Math.ceil(a/n),c=Math.ceil(o/r);let t=Math.ceil(a/s),l=Math.ceil(o/c);for(let n=0;ne*this.rescale_factor)}pad_image(e,t,n,r){return super.pad_image(e,t,n,{constant_values:this.constant_values,center:!0,...r})}},Gh=class extends X{constructor(e){let{resize_mode:t,fill_color:n,interpolation:r,size:i,...a}=e,o=t===`squash`?{width:i,height:i}:t===`shortest`?{shortest_edge:i}:{longest_edge:i},s=r===`bicubic`?3:2;super({...a,size:o,resample:s,do_center_crop:!0,crop_size:i,do_normalize:!0})}};function Kh(e,t){return Math.round(e/t)*t}function qh(e,t,n,r,i){let a=1/0,o=[1,1],s=n*r;for(let n of t){let t=Math.abs(e-n[0]/n[1]);t.5*i*i*n[0]*n[1]&&(o=n)}return o}function Jh(e,t){let n=[],r=new Set;for(let i=e;i<=t;++i)for(let a=1;a<=i;++a)for(let o=1;o<=i;++o){let i=a*o;if(i>=e&&i<=t){let e=a<<16|o;r.has(e)||(r.add(e),n.push([a,o]))}}return n.sort((e,t)=>e[0]*e[1]-t[0]*t[1])}function Yh(e,t){let[n,r,i,a]=e.dims,o=Math.floor(i/t),s=Math.floor(a/t),c=t*t*r,l=e.data,u=new Float32Array(n*o*s*c),d=i*a;for(let e=0;ethis.max_image_tokens*(this.encoder_patch_size*this.downsample_factor)**2*this.max_pixels_tolerance}_get_grid_layout(e,t){let n=Jh(this.min_tiles,this.max_tiles),[r,i]=qh(t/e,n,t,e,this.tile_size);return{grid_width:r,grid_height:i,target_width:this.tile_size*r,target_height:this.tile_size*i}}async _call(e,{return_row_col_info:t=null}={}){let n;n=Array.isArray(e)?Array.isArray(e[0])?e:[e]:[[e]];let r=[],i=[],a=[],o=[],s=[],c=[];for(let e of n){let t=await Promise.all(e.map(e=>this.preprocess(e,{do_pad:!1})));for(let{pixel_values:e}of t){let[,t,n]=e.dims,l=e.unsqueeze_(0),u=this.encoder_patch_size*this.downsample_factor,d=u**2,[f,p]=ph(Math.max(u,t),Math.max(u,n),u,this.min_image_tokens*d,this.max_image_tokens*d).map(e=>Math.max(u,e)),m,h=1,g=1,_=this._is_image_too_large(t,n),v=this.do_image_splitting&&(this.min_tiles!==1||this.max_tiles!==1);if(_&&v){let{grid_width:e,grid_height:r,target_width:i,target_height:a}=this._get_grid_layout(t,n);h=r,g=e;let o=await _f(l,{size:[a,i]});m=[];for(let t=0;t(e-this.image_mean[t])/this.image_std[t]);return super.pad_image(e,t,{width:s,height:o},{center:!0,constant_values:c,...r})}async _call(e,{num_crops:t=null}={}){if(this._num_crops=t??=this.config.num_crops,t<4||bg(t)%1!=0)throw Error(`num_crops must be a square number >= 4`);Array.isArray(e)||(e=[e]);let n=e.length,r=await Promise.all(e.map(e=>this.preprocess(e))),i=r.map(e=>e.original_size),a=r.map(e=>e.reshaped_input_size),o=[];for(let{pixel_values:e}of r){e.unsqueeze_(0);let[n,r]=e.dims.slice(-2),i=await _f(e,{size:[gg,gg],mode:`bicubic`});if(t>0){let a=[],s=bg(t),c=yg(r/s),l=yg(n/s);for(let t=0;te.map(e=>gg*vg(e/gg)));return{pixel_values:s,original_sizes:i,reshaped_input_sizes:a,image_sizes:new J(`int64`,c.flat(),[n,2]),num_img_tokens:c.map(([e,t])=>this.calc_num_image_tokens_from_image_size(t,e))}}},Sg=class extends X{get_resize_output_image_size(e,t){let{longest_edge:n}=t;if(n===void 0)throw Error(`size must contain 'longest_edge'`);let[r,i]=e.size,a=Math.max(r,i)/n,o=r,s=i;a>1&&(o=Math.floor(r/a),s=Math.floor(i/a));let{patch_size:c,spatial_merge_size:l}=this.config;if(!l)throw Error(`config must contain 'spatial_merge_size'`);let u=c*l,d=Math.floor((o-1)/u)+1,f=Math.floor((s-1)/u)+1;return[d*u,f*u]}},Cg=class extends X{},wg=class extends X{post_process_object_detection(...e){return ch(...e)}},Tg=class extends X{reshape_input_points(e,t,n,r=!1){e=structuredClone(e);let i=go(e);if(i.length===3)r||(i=[1,...i]),e=[e];else if(i.length!==4)throw Error("The input_points must be a 4D tensor of shape `batch_size`, `point_batch_size`, `nb_points_per_image`, `2`.");for(let r=0;re!==t.dims[n]))throw Error(`The first ${n.length} dimensions of 'input_points' and 'input_labels' must be the same.`);return new J(`int64`,e.flat(1/0).map(BigInt),n)}async _call(e,{input_points:t=null,input_labels:n=null,input_boxes:r=null}={}){let i=await super._call(e);if(t&&(i.input_points=this.reshape_input_points(t,i.original_sizes,i.reshaped_input_sizes)),n){if(!i.input_points)throw Error("`input_points` must be provided if `input_labels` are provided.");i.input_labels=this.add_input_labels(n,i.input_points)}return r&&(i.input_boxes=this.reshape_input_points(r,i.original_sizes,i.reshaped_input_sizes,!0)),i}async post_process_masks(e,t,n,{mask_threshold:r=0,binarize:i=!0,pad_size:a=null}={}){let o=[];a=a??this.pad_size??this.size;let s=[a.height,a.width];for(let a=0;ar&&(t[n]=1);u=new J(`bool`,t,u.dims)}o.push(u)}return o}generate_crop_boxes(e,t,{crop_n_layers:n=0,overlap_ratio:r=512/1500,points_per_crop:i=32,crop_n_points_downscale_factor:a=1}={}){}},Eg=class extends X{post_process_semantic_segmentation(...e){return lh(...e)}},Dg=class extends Eg{},Og=class extends X{post_process_semantic_segmentation(...e){return lh(...e)}},kg=class extends Og{},Ag=class extends X{},jg=class extends X{pad_image(e,t,n,r={}){let[i,a,o]=t;return super.pad_image(e,t,{width:a+(n-a%n)%n,height:i+(n-i%n)%n},{mode:`symmetric`,center:!1,constant_values:-1,...r})}},Mg=class extends X{},Ng=class extends Mg{},Pg=class extends X{async _call(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);let n=await Promise.all(e.map(e=>this.preprocess(e))),r=await Promise.all(t.map(e=>this.preprocess(e,{do_normalize:!1,do_convert_rgb:!1,do_convert_grayscale:!0})));return{pixel_values:Df(n.map((e,t)=>Ef([e.pixel_values,r[t].pixel_values],0)),0),original_sizes:n.map(e=>e.original_size),reshaped_input_sizes:n.map(e=>e.reshaped_input_size)}}},Fg=class extends X{post_process_pose_estimation(e,t,{threshold:n=null}={}){let r=e.tolist(),[i,a,o,s]=e.dims,c=[];for(let e=0;e/gm,bboxes:/([^<]+)?/gm},this.size_per_bin=1e3}construct_prompts(e){typeof e==`string`&&(e=[e]);let t=[];for(let n of e)if(this.task_prompts_without_inputs.has(n))t.push(this.task_prompts_without_inputs.get(n));else{for(let[e,r]of this.task_prompts_with_input)if(n.includes(e)){t.push(r.replaceAll(`{input}`,n).replaceAll(e,``));break}t.length!==e.length&&t.push(n)}return t}post_process_generation(e,t,n){let r=this.tasks_answer_post_processing_type.get(t)??`pure_text`;e=e.replaceAll(``,``).replaceAll(``,``);let i;switch(r){case`pure_text`:i=e;break;case`description_with_bboxes`:case`bboxes`:case`phrase_grounding`:case`ocr`:let a=r===`ocr`?`quad_boxes`:`bboxes`,o=e.matchAll(this.regexes[a]),s=[],c=[];for(let[e,t,...r]of o)s.push(t?t.trim():s.at(-1)??``),c.push(r.map((e,t)=>(Number(e)+.5)/this.size_per_bin*n[t%2]));i={labels:s,[a]:c};break;default:throw Error(`Task "${t}" (of type "${r}") not yet implemented.`)}return{[t]:i}}async _call(e,t=null,n={}){if(!e&&!t)throw Error(`Either text or images must be provided`);let r=await this.image_processor(e,n),i=t?this.tokenizer(this.construct_prompts(t),n):{};return{...r,...i}}},Bg=class extends tm{static tokenizer_class=Yp;static image_processor_class=Rg;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,n){super(e,t,n),this.image_seq_length=this.config.image_seq_length;let{boi_token:r,image_token:i,eoi_token:a}=this.tokenizer.config;this.boi_token=r,this.image_token=i,this.eoi_token=a;let o=i.repeat(this.image_seq_length);this.full_image_sequence=` + +${r}${o}${a} + +`}async _call(e,t=null,n={}){typeof e==`string`&&(e=[e]);let r;return t&&(r=await this.image_processor(t,n),e=e.map(e=>e.replaceAll(this.boi_token,this.full_image_sequence))),{...this.tokenizer(e,n),...r}}},Vg=class extends tm{static image_processor_class=Rg;static feature_extractor_class=Jm;static tokenizer_class=Yp;static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,n){super(e,t,n),this.audio_seq_length=this.config.audio_seq_length,this.image_seq_length=this.config.image_seq_length;let{audio_token_id:r,boa_token:i,audio_token:a,eoa_token:o,image_token_id:s,boi_token:c,image_token:l,eoi_token:u}=this.tokenizer.config;this.audio_token_id=r,this.boa_token=i,this.audio_token=a;let d=a.repeat(this.audio_seq_length);this.full_audio_sequence=` + +${i}${d}${o} + +`,this.image_token_id=s,this.boi_token=c,this.image_token=l;let f=l.repeat(this.image_seq_length);this.full_image_sequence=` + +${c}${f}${u} + +`}async _call(e,t=null,n=null,r={}){typeof e==`string`&&(e=[e]);let i;n&&(i=await this.feature_extractor(n,r),e=e.map(e=>e.replaceAll(this.audio_token,this.full_audio_sequence)));let a;return t&&(a=await this.image_processor(t,r),e=e.map(e=>e.replaceAll(this.image_token,this.full_image_sequence))),{...this.tokenizer(e,r),...a,...i}}},Hg=class extends tm{static uses_processor_config=!0;static uses_chat_template_file=!0;constructor(e,t,n){super(e,t,n),this.audio_ms_per_token=this.config.audio_ms_per_token??40,this.audio_seq_length=this.config.audio_seq_length??750,this.image_seq_length=this.config.image_seq_length??280;let{audio_token:r,boa_token:i,eoa_token:a,image_token:o,boi_token:s,eoi_token:c}=this.tokenizer.config;this.audio_token=r,this.boa_token=i,this.eoa_token=a,this.image_token=o,this.boi_token=s,this.eoi_token=c}static async from_pretrained(e,t={}){let[n,r,i]=await Promise.all([_d(e,$p,!0,t),Yp.from_pretrained(e,t),gd(e,em,!1,t)]),a={tokenizer:r};return n.image_processor&&(a.image_processor=new Rh(n.image_processor)),n.feature_extractor&&(a.feature_extractor=new Lm(n.feature_extractor)),new this(n,a,i)}_compute_audio_num_tokens(e,t){let n=Math.round(t*20/1e3),r=Math.round(t*10/1e3),i=Math.floor(n/2),a=Math.floor((e+i-n-1)/r)+1;if(a<=0)return 0;for(let e=0;e<2;++e)a=Math.floor((a-1)/2)+1;return Math.min(a,this.audio_seq_length)}async _call(e,t=null,n=null,r={}){typeof e==`string`&&(e=[e]);let i;if(t){i=await this.image_processor(t,r);let n=i.num_soft_tokens_per_image,a=0;e=e.map(e=>e.replaceAll(this.image_token,()=>` + +${this.boi_token}${this.image_token.repeat(n[a++])}${this.eoi_token} + +`))}let a;if(n){let t=Array.isArray(n)?n:[n];a=await this.feature_extractor(t[0],r);let i=this.feature_extractor.config.sampling_rate??16e3,o=0;e=e.map(e=>e.replaceAll(this.audio_token,()=>` + +${this.boa_token}${this.audio_token.repeat(this._compute_audio_num_tokens(t[o++].length,i))}${this.eoa_token} + +`))}return{...this.tokenizer(e,r),...i,...a}}},Ug=class extends tm{static image_processor_class=Rg;static tokenizer_class=Yp;static image_token=`<|image_pad|>`;async _call(e,t=null,...n){Array.isArray(e)||(e=[e]);let r,i;if(t&&(r=await this.image_processor(t),i=r.image_grid_thw),i){let t=this.image_processor.config.merge_size**2,n=0,r=this.constructor.image_token,a=i.tolist();e=e.map(e=>{for(;e.includes(r);){let i=Number(a[n++].reduce((e,t)=>e*t,1n));e=e.replace(r,`<|placeholder|>`.repeat(Math.floor(i/t)))}return e.replaceAll(`<|placeholder|>`,r)})}return{...this.tokenizer(e),...r}}},Wg=class extends Ug{static image_token=`<|image|>`},Gg=class extends tm{static tokenizer_class=Yp;static feature_extractor_class=Jm;static uses_processor_config=!0;_get_num_audio_features(e){let{hop_length:t}=this.feature_extractor.config.melspec_kwargs,{projector_window_size:n,projector_downsample_rate:r}=this.feature_extractor.config,i=Math.floor(n/r),a=Math.floor(e/t)+1,o=Math.floor(a/2);return Math.ceil(o/n)*i}async _call(e,t=null,n={}){if(Array.isArray(e))throw Error(`Batched inputs are not supported yet.`);let r={};if(t){let{input_features:n}=await this.feature_extractor(t);r.input_features=n;let i=this._get_num_audio_features(t.length);r.input_features_mask=new J(`bool`,new Uint8Array(i).fill(1),[1,i]);let a=this.config.audio_token??`<|audio|>`;if(!e.includes(a))throw Error(`The input text does not contain the audio token ${a}.`);e=e.replaceAll(a,a.repeat(i))}return{...this.tokenizer(e,{add_special_tokens:!1,...n}),...r}}};function Kg(e,t){let n=e.dims.at(-1)-1,r=e.tolist();r.fill(!1,0,1),r.fill(!1,n);let i=t.tolist();return r.map((e,t)=>e?t:null).filter(e=>e!==null).map(e=>i[e])}var qg=class extends tm{static tokenizer_class=Yp;static image_processor_class=Rg;async _call(e,t,n={}){let r=e?await this.image_processor(e,n):{};return{...t?this.tokenizer(t,n):{},...r}}post_process_grounded_object_detection(e,t,{box_threshold:n=.25,text_threshold:r=.25,target_sizes:i=null}={}){let{logits:a,pred_boxes:o}=e,s=a.dims[0];if(i!==null&&i.length!==s)throw Error(`Make sure that you pass in as many target sizes as the batch dimension of the logits`);let c=a.dims.at(1),l=a.sigmoid(),u=l.max(-1).tolist(),d=o.tolist().map(e=>e.map(e=>sh(e))),f=[];for(let e=0;ee.map((e,t)=>e*a[(t+1)%2])));let o=u[e],s=[],p=[],m=[];for(let i=0;i`+i.repeat(e);o+=` +`}return o+=` +${r}${a}`+i.repeat(e)+`${r}`,o}function Yg(e,t,n,r){return`${t}${r}`+n.repeat(e)+`${t}`}function Xg(e,t,n,r,i,a){return e===0&&t===0?Yg(n,r,i,a):Jg(n,e,t,r,i,a)}var Zg=class extends tm{static image_processor_class=Rg;static tokenizer_class=Yp;static uses_processor_config=!0;fake_image_token=``;image_token=``;global_img_token=``;async _call(e,t=null,n={}){n.return_row_col_info??=!0;let r;t&&(r=await this.image_processor(t,n)),Array.isArray(e)||(e=[e]);let i=r.rows??[Array(e.length).fill(0)],a=r.cols??[Array(e.length).fill(0)],o=this.config.image_seq_len,s=[],c=[];for(let t=0;tXg(e,l[t],o,this.fake_image_token,this.image_token,this.global_img_token)),d=n.split(this.image_token);if(d.length===0)throw Error(`The image token should be present in the text.`);let f=d[0];for(let e=0;ee.images).flatMap(e=>e.images).map(e=>ih.read(e)));let r=this.tokenizer,i=r.apply_chat_template(e,{tokenize:!1,add_generation_prompt:!0,chat_template:n}),a=e=>r.encode(e,{add_special_tokens:!1}),o=i.split(this.image_tag),s=o.length-1;if(t.length!==s)throw Error(`Number of images provided (${t.length}) does not match number of "${this.image_tag}" image tags (${s})`);let[c,l,u]=r.convert_tokens_to_ids([this.image_tag,this.image_start_tag,this.image_end_tag]),d=a(o[0]),f=Array(d.length).fill(!1);for(let e=1;e0){let e=await this.image_processor(t);return e.pixel_values.unsqueeze_(0),{...m,...e}}return m}},$g=class extends tm{static tokenizer_class=Yp;static image_processor_class=Rg;async _call(e=null,t=null,n={}){if(!e&&!t)throw Error(`Either text or images must be provided`);let r=e?this.tokenizer(e,n):{},i=t?await this.image_processor(t,n):{};return{...r,...i}}},e_=class extends tm{static tokenizer_class=Yp;static image_processor_class=Rg;async _call(e,t=null,n={}){let{image_rows:r,image_cols:i,image_sizes:a,...o}=await this.image_processor(e,{...n,return_row_col_info:!0});if(t){let e=this.config.image_token??``,{tile_size:n=512,downsample_factor:o=2,encoder_patch_size:s=16,use_thumbnail:c=!0}=this.image_processor.config,l=e=>Math.ceil(Math.floor(e/s)/o),u=l(n)**2,d=this.config.image_start_token??`<|image_start|>`,f=this.config.image_end_token??`<|image_end|>`,p=this.config.image_thumbnail??`<|img_thumbnail|>`;Array.isArray(t)||(t=[t]);let m=0;t=t.map(t=>{let n=t.split(e);return n[0]+n.slice(1).map(t=>{let n=m++,[o,s]=a[n],h=r[n],g=i[n],_=l(o)*l(s),v=d;if(h>1||g>1){let t=e.repeat(u);for(let e=0;e`+t;c&&(v+=p+e.repeat(_))}else v+=e.repeat(_);return v+f+t}).join(``)})}return{...o,...t?this.tokenizer(t,n):{}}}},t_=class extends tm{static tokenizer_class=Yp;static image_processor_class=Rg;static uses_processor_config=!0;async _call(e,t=null,n={}){let r=await this.image_processor(e,n);if(t){let[e,n]=r.pixel_values.dims.slice(-2),{image_token:i,patch_size:a,num_additional_image_tokens:o}=this.config,s=Math.floor(e/a)*Math.floor(n/a)+o;t=structuredClone(t),Array.isArray(t)||(t=[t]);for(let e=0;e0?i.reduce((e,t)=>e*t,1):0;c.push(n),s.push(a)}return[i(c),s]}char_decode(e){return this.char_tokenizer.batch_decode(e).map(e=>e.replaceAll(` `,``))}bpe_decode(e){return this.bpe_tokenizer.batch_decode(e)}wp_decode(e){return this.wp_tokenizer.batch_decode(e).map(e=>e.replaceAll(` `,``))}batch_decode([e,t,n]){let[r,i]=this._decode_helper(e,`char`),[a,o]=this._decode_helper(t,`bpe`),[s,c]=this._decode_helper(n,`wp`),l=[],u=[];for(let e=0;e`;function s_(e,t,n,r,i){return`${r.repeat(n*i)}${t}${e} +`}var c_=class extends tm{static tokenizer_class=Yp;static image_processor_class=Rg;static uses_processor_config=!1;async _call(e,t=null,n={}){t||=(B.warn(`You are using PaliGemma without a text prefix. It will perform as a picture-captioning model.`),``),Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]);let r=this.tokenizer.bos_token,i=this.image_processor.config.image_seq_length,a;t.some(e=>e.includes(o_))?a=t.map(e=>{let t=e.replaceAll(o_,o_.repeat(i)),n=t.lastIndexOf(o_),a=n===-1?0:n+o_.length;return t.slice(0,a)+r+t.slice(a)+` +`}):(B.warn("You are passing both `text` and `images` to `PaliGemmaProcessor`. The processor expects special image tokens in the text, as many tokens as there are images per each text. It is recommended to add `` tokens in the very beginning of your text. For this call, we will infer how many images each text has and add special tokens."),a=t.map(t=>s_(t,r,i,o_,e.length)));let o=this.tokenizer(a,n);return{...await this.image_processor(e,n),...o}}},l_=`<|image|>`,u_=/<\|image_\d+\|>/g,d_=class extends tm{static image_processor_class=Rg;static tokenizer_class=Yp;async _call(e,t=null,{padding:n=!0,truncation:r=!0,num_crops:i=null}={}){Array.isArray(e)||(e=[e]);let a,o;if(t){o=await this.image_processor(t,{num_crops:i});let{num_img_tokens:s}=o,c=e.map((e,t)=>e.split(u_).join(l_.repeat(s[t])));a=this.tokenizer(c,{padding:n,truncation:r});let l=this.tokenizer._tokenizer.token_to_id(l_);a.input_ids.map_(e=>e==l?-e:e)}else a=this.tokenizer(e);return{...a,...o}}},f_=class extends tm{static tokenizer_class=Yp;static image_processor_class=Rg;static uses_processor_config=!0;async _call(e,t=null,n={}){let r=await this.image_processor(e,n);if(t){let[e,n]=r.pixel_values.dims.slice(-2),{image_token:i,image_break_token:a,image_end_token:o,patch_size:s,spatial_merge_size:c}=this.config,l=s*c,u=Math.floor(e/l),d=Math.floor(n/l);t=structuredClone(t),Array.isArray(t)||(t=[t]);for(let e=0;ew_(e,o)),c=s.map(e=>e.length),l=s.flat(),u=(await Promise.all(l.map(e=>this.feature_extractor(e,n)))).map(e=>e.input_features);r.audio_values=u.length>1?Ef(u,0):u[0];let d=i[0];for(let e=0;e0){if(l>Bu)throw Error(`The number of external data chunks (${l}) exceeds the maximum allowed value (${Bu}).`);let t=H_(o,l);for(let n of t){let t=`${r.subfolder??``}/${n}`;c.push(new Promise(async(i,a)=>{let o=await hd(e,t,!0,r,s);i(o instanceof Uint8Array?{path:n,data:o}:n)}))}}else a.externalData!==void 0&&(c=a.externalData.map(async t=>{if(typeof t.data==`string`){let n=await hd(e,t.data,!0,r);return{...t,data:n}}return t}));return Promise.all(c)}async function G_(e,t,n,r=!1,i=void 0){let a=n.config?.[`transformers.js_config`]??{},o=of(n.device??a.device,t,{warn:e=>B.info(e)}),s=Gd(o),c=a.device_config??{};c.hasOwnProperty(o)&&(a={...a,...c[o]});let l=ff(n.dtype??a.dtype,t,o,{configDtype:a.dtype,warn:e=>B.info(e)});if(!df.hasOwnProperty(l))throw Error(`Invalid dtype: ${l}. Should be one of: ${Object.keys(cf).join(`, `)}`);if(o===`webgpu`&&!R.IS_NODE_ENV&&l===cf.fp16&&!await sf())throw Error(`The device (${o}) does not support fp16.`);let u=df[l],d={...n.session_options};d.executionProviders??=s;let f=a.free_dimension_overrides;f?d.freeDimensionOverrides??=f:o.startsWith(`webnn`)&&!d.freeDimensionOverrides&&B.warn(`WebNN does not currently support dynamic shapes and requires 'free_dimension_overrides' to be set in config.json, preferably as a field within config["transformers.js_config"]["device_config"]["${o}"]. When 'free_dimension_overrides' is not set, you may experience significant performance degradation.`);let p=U_(e,t,n,u),m=await W_(e,t,u,n,n.use_external_data_format??a.use_external_data_format,d);if(m.length>0&&(!R.IS_NODE_ENV||m.some(e=>typeof e!=`string`))&&(d.externalData=m),r&&o===`webgpu`){let e=L_(n.config,{prefix:`present`,session_name:i});if(e.size>0&&!ef()){let t={};for(let n of e)t[n]=`gpu-buffer`;d.preferredOutputLocation=t}}return{buffer_or_path:await p,session_options:d,session_config:{dtype:l,device:o}}}async function K_(e,t,n,r=void 0){return Object.fromEntries(await Promise.all(Object.keys(t).map(async i=>{let a=r?.[i]??!1,{buffer_or_path:o,session_options:s,session_config:c}=await G_(e,t[i],n,a,i);return[i,await Yd(o,s,c)]})))}function q_(e){for(let t in e)Qd(e[t])?e[t]=new J(e[t]):typeof e[t]==`object`&&q_(e[t]);return e}async function J_(e,t){let n=Y_(e,t);try{return q_(await Zd(e,Object.fromEntries(Object.entries(n).map(([e,t])=>{let n=t.ort_tensor;return R.IS_NODE_ENV&&typeof Float16Array<`u`&&n.cpuData instanceof Float16Array&&(n.cpuData=new Uint16Array(n.cpuData.buffer)),[e,n]}))))}catch(e){let t=Object.fromEntries(Object.entries(n).map(([e,t])=>{let n={type:t.type,dims:t.dims,location:t.location};return n.location!==`gpu-buffer`&&(n.data=t.data),[e,n]}));throw B.error(`An error occurred during model execution: "${e}".`),B.error(`Inputs given to model:`,t),e}}function Y_(e,t){let n=Object.create(null),r=[];for(let i of e.inputNames){let e=t[i];if(!(e instanceof J)){r.push(i);continue}n[i]=ef()?e.clone():e}if(r.length>0)throw Error(`An error occurred during model execution: "Missing the following inputs: ${r.join(`, `)}.`);let i=Object.keys(t).length,a=e.inputNames.length;if(i>a){let n=Object.keys(t).filter(t=>!e.inputNames.includes(t));B.warn(`WARNING: Too many inputs were provided (${i} > ${a}). The following inputs will be ignored: "${n.join(`, `)}".`)}return n}var X_=class{},Z_=class extends X_{constructor({last_hidden_state:e,hidden_states:t=null,attentions:n=null}){super(),this.last_hidden_state=e,this.hidden_states=t,this.attentions=n}},Z=class extends X_{constructor({logits:e,...t}){super(),this.logits=e;let n=Object.values(t);n.length>0&&(this.attentions=n)}},Q_=class extends X_{constructor({logits:e}){super(),this.logits=e}},$_=class extends X_{constructor({logits:e}){super(),this.logits=e}},ev=class extends X_{constructor({start_logits:e,end_logits:t}){super(),this.start_logits=e,this.end_logits=t}},tv=class extends X_{constructor({logits:e}){super(),this.logits=e}},nv=class extends X_{constructor({logits:e,past_key_values:t}){super(),this.logits=e,this.past_key_values=t}},rv=class extends X_{constructor({logits:e,past_key_values:t,encoder_outputs:n,decoder_attentions:r=null,cross_attentions:i=null}){super(),this.logits=e,this.past_key_values=t,this.encoder_outputs=n,this.decoder_attentions=r,this.cross_attentions=i}},iv=class extends X_{constructor({alphas:e}){super(),this.alphas=e}},av=class extends uo{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},ov=class extends uo{_call(e,t){throw Error("`_call` should be implemented in a subclass")}},sv=class extends uo{constructor(){super(),this.processors=[]}push(e){this.processors.push(e)}extend(e){this.processors.push(...e)}_call(e,t){let n=t;for(let t of this.processors)n=t(e,n);return n}[Symbol.iterator](){return this.processors.values()}},cv=class extends av{constructor(e){super(),this.bos_token_id=e}_call(e,t){for(let n=0;n=1&&i[i.length-1]>=this.timestamp_begin,o=i.length<2||i[i.length-2]>=this.timestamp_begin;if(a&&(o?r.subarray(this.timestamp_begin).fill(-1/0):r.subarray(0,this.eos_token_id).fill(-1/0)),e[n].length===this.begin_index&&this.max_initial_timestamp_index!==null){let e=this.timestamp_begin+this.max_initial_timestamp_index;r.subarray(e+1).fill(-1/0)}let s=xd(r);Math.log(s.subarray(this.timestamp_begin).map(Math.exp).reduce((e,t)=>e+t))>Cd(s.subarray(0,this.timestamp_begin))[0]&&r.subarray(0,this.timestamp_begin).fill(-1/0)}return t}},pv=class extends av{constructor(e){super(),this.no_repeat_ngram_size=e}getNgrams(e){let t=e.length,n=[];for(let r=0;r1 to use the classifier-free guidance processor, got guidance scale ${e}.`);this.guidance_scale=e}_call(e,t){if(t.dims[0]!==2*e.length)throw Error(`Logits should have twice the batch size of the input ids, the first half of batches corresponding to the conditional inputs, and the second half of batches corresponding to the unconditional inputs. Got batch size ${t.dims[0]} for the logits and ${e.length} for the input ids.`);let n=e.length,r=t.slice([0,n],null),i=t.slice([n,t.dims[0]],null);for(let e=0;ee.length>=this.max_length)}},wv=class extends xv{constructor(e){super(),Array.isArray(e)||(e=[e]),this.eos_token_id=e}_call(e,t){return e.map(e=>{let t=e.at(-1);return this.eos_token_id.some(e=>t==e)})}},Tv=class extends uo{constructor(e){super(),this.generation_config=e}async _call(e){return this.sample(e)}async sample(e){throw Error(`sample should be implemented in subclasses.`)}getLogits(e,t){let n=e.dims.at(-1),r=e.data;if(t===-1)r=r.slice(-n);else{let e=t*n;r=r.slice(e,e+n)}return r}randomSelect(e){return Iu(e)}static getSampler(e){if(e.do_sample)return new Dv(e);if(e.num_beams>1)return new Ov(e);if(e.num_return_sequences>1)throw Error(`num_return_sequences has to be 1 when doing greedy search, but is ${e.num_return_sequences}.`);return new Ev(e)}},Ev=class extends Tv{async sample(e){let t=Cd(e.data)[1];return[[BigInt(t),0]]}},Dv=class extends Tv{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));let[n,r]=await yf(e,t),i=bd(n.data);return Array.from({length:this.generation_config.num_beams},()=>{let e=this.randomSelect(i);return[r.data[e],Math.log(i[e])]})}},Ov=class extends Tv{async sample(e){let t=e.dims.at(-1);this.generation_config.top_k>0&&(t=Math.min(this.generation_config.top_k,t));let[n,r]=await yf(e,t),i=bd(n.data);return Array.from({length:this.generation_config.num_beams},(e,t)=>[r.data[t],Math.log(i[t])])}},kv=class{constructor(e){if(e)for(let t in e){if(t in this)throw TypeError(`Key "${t}" conflicts with an existing property on DynamicCache`);let n=e[t];if(!(n instanceof J))throw TypeError(`Expected a Tensor for key "${t}", got ${typeof n}`);this[t]=n}}get_seq_length(){let e=this;if(Object.keys(e).length===0)return 0;for(let t in e)if(t.startsWith(`past_key_values.`))return e[t].dims.at(-2);throw Error(`Unable to determine sequence length from the cache.`)}update(e){for(let t in e){let n=this[t],r=e[t];n&&n!==r&&n.location===`gpu-buffer`&&n.dispose(),this[t]=r}}async dispose(){let e=[];for(let t of Object.values(this))t.location===`gpu-buffer`&&e.push(t.dispose());await Promise.all(e)}},Q={EncoderOnly:0,EncoderDecoder:1,Seq2Seq:2,Vision2Seq:3,DecoderOnly:4,DecoderOnlyWithoutHead:5,MaskGeneration:6,ImageTextToText:7,Musicgen:8,MultiModality:9,Phi3V:10,AudioTextToText:11,AutoEncoder:12,ImageAudioTextToText:13,Supertonic:14,Chatterbox:15,VoxtralRealtime:16},Av={[Q.DecoderOnly]:{sessions:(e,t)=>({model:t.model_file_name??`model`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[Q.DecoderOnlyWithoutHead]:{sessions:(e,t)=>({model:t.model_file_name??`model`})},[Q.Seq2Seq]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[Q.Vision2Seq]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[Q.Musicgen]:{sessions:()=>({model:`text_encoder`,decoder_model_merged:`decoder_model_merged`,encodec_decode:`encodec_decode`}),cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[Q.EncoderDecoder]:{sessions:()=>({model:`encoder_model`,decoder_model_merged:`decoder_model_merged`}),cache_sessions:{decoder_model_merged:!0}},[Q.MaskGeneration]:{sessions:()=>({model:`vision_encoder`,prompt_encoder_mask_decoder:`prompt_encoder_mask_decoder`})},[Q.ImageTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Av[Q.ImageTextToText].text_only_sessions};return n||(r.vision_encoder=`vision_encoder`),e.is_encoder_decoder&&(r.model=`encoder_model`),r},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[Q.AudioTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Av[Q.AudioTextToText].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`),r},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[Q.ImageAudioTextToText]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Av[Q.ImageAudioTextToText].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`,r.vision_encoder=`vision_encoder`),r},cache_sessions:{decoder_model_merged:!0},optional_configs:{generation_config:`generation_config.json`}},[Q.Phi3V]:{sessions:()=>({prepare_inputs_embeds:`prepare_inputs_embeds`,model:`model`,vision_encoder:`vision_encoder`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[Q.MultiModality]:{sessions:()=>({prepare_inputs_embeds:`prepare_inputs_embeds`,model:`language_model`,lm_head:`lm_head`,gen_head:`gen_head`,gen_img_embeds:`gen_img_embeds`,image_decode:`image_decode`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[Q.AutoEncoder]:{sessions:()=>({encoder_model:`encoder_model`,decoder_model:`decoder_model`})},[Q.Supertonic]:{sessions:()=>({text_encoder:`text_encoder`,latent_denoiser:`latent_denoiser`,voice_decoder:`voice_decoder`})},[Q.Chatterbox]:{sessions:()=>({embed_tokens:`embed_tokens`,speech_encoder:`speech_encoder`,model:`language_model`,conditional_decoder:`conditional_decoder`}),cache_sessions:{model:!0},optional_configs:{generation_config:`generation_config.json`}},[Q.VoxtralRealtime]:{text_only_sessions:{embed_tokens:`embed_tokens`,decoder_model_merged:`decoder_model_merged`},sessions:(e,t,n)=>{let r={...Av[Q.VoxtralRealtime].text_only_sessions};return n||(r.audio_encoder=`audio_encoder`),r},cache_sessions:{decoder_model_merged:!0,audio_encoder:!0},optional_configs:{generation_config:`generation_config.json`}},default:{sessions:(e,t)=>({model:t.model_file_name??`model`})}};function jv(e){return Av[e]?.text_only_sessions??null}function Mv(e,t,n={}){let r=Av[e]??Av.default;return{sessions:r.sessions(t,n,n.textOnly??!1),cache_sessions:r.cache_sessions,optional_configs:r.optional_configs}}function Nv(e,{warn:t=!0}={}){let n=e.architectures||[];for(let e of n){let t=Hv.get(e);if(t!==void 0)return t}if(e.model_type){let t=Hv.get(e.model_type);if(t!==void 0)return t;for(let t of Object.values(Iv))if(t.has(e.model_type)){let n=Hv.get(t.get(e.model_type));if(n!==void 0)return n}}if(t){let t=n.length>0?n.join(`, `):`(none)`;B.warn(`[resolve_model_type] Architecture(s) not found in MODEL_TYPE_MAPPING: [${t}] for model type '${e.model_type}'. Falling back to EncoderOnly (single model.onnx file). If you encounter issues, please report at: ${Xp}`)}return Q.EncoderOnly}function Pv(e,{config:t=null,cache_dir:n=null,local_files_only:r=!1,revision:i=`main`}={}){return t===null?id(Gu(e,{cache_dir:n,local_files_only:r,revision:i}),()=>B_.from_pretrained(e,{config:t,cache_dir:n,local_files_only:r,revision:i})):B_.from_pretrained(e,{config:t,cache_dir:n,local_files_only:r,revision:i})}async function Fv(e,{config:t=null,dtype:n=null,device:r=null,model_file_name:i=null}={}){t=await Pv(e,{config:t});let a=[`config.json`],o=t[`transformers.js_config`]??{},s=o.use_external_data_format,c=`onnx`,l=r??o.device,u=n??o.dtype,d=Nv(t),f=(e,t=null)=>{t??=e;let n=of(l,e),r=df[ff(u,e,n)]??``,i=`${t}${r}.onnx`,o=`${c}/${i}`;a.push(o);let d=V_(s,i,e);for(let e of H_(i,d)){let t=`${c}/${e}`;a.push(t)}},{sessions:p,optional_configs:m}=Mv(d,t,{model_file_name:i});for(let[e,t]of Object.entries(p))f(e,t);if(m)for(let e of Object.values(m))a.push(e);return a}var Iv=null;function Lv(e){Iv=e}function Rv(e){if(e instanceof J)return e;if(e.length===0)throw Error(`items must be non-empty`);if(Array.isArray(e[0])){if(e.some(t=>t.length!==e[0].length))throw Error(`Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' and/or 'truncation=True' to have batched tensors with the same length.`);return new J(`int64`,BigInt64Array.from(e.flat().map(e=>BigInt(e))),[e.length,e[0].length])}return new J(`int64`,BigInt64Array.from(e.map(e=>BigInt(e))),[1,e.length])}function zv(e){return new J(`bool`,[e],[1])}var Bv={[Q.DecoderOnly]:{can_generate:!0,forward:$v,prepare_inputs:ay},[Q.DecoderOnlyWithoutHead]:{can_generate:!1,forward:$v,prepare_inputs:ay},[Q.Seq2Seq]:{can_generate:!0,forward:Gv,prepare_inputs:oy},[Q.Vision2Seq]:{can_generate:!0,forward:Gv,prepare_inputs:oy},[Q.Musicgen]:{can_generate:!0,forward:Gv},[Q.EncoderDecoder]:{can_generate:!1,forward:Gv},[Q.ImageTextToText]:{can_generate:!0,forward:ny,prepare_inputs:sy},[Q.AudioTextToText]:{can_generate:!0,forward:ty,prepare_inputs:sy},[Q.ImageAudioTextToText]:{can_generate:!0,prepare_inputs:sy},[Q.Phi3V]:{can_generate:!0,prepare_inputs:sy},[Q.MultiModality]:{can_generate:!0},[Q.AutoEncoder]:{can_generate:!1,forward:qv},[Q.Chatterbox]:{can_generate:!0,forward:Kv},[Q.VoxtralRealtime]:{can_generate:!0,prepare_inputs:ay},default:{can_generate:!1,forward:Kv}};function Vv(e,t){let n=Hv.get(e),r=!1,i=t?.architectures?.[0];if(i&&i!==e&&e?.endsWith(`ForCausalLM`)&&i.endsWith(`ForConditionalGeneration`)){let e=Hv.get(i);e!==void 0&&(n=e,r=!0)}let a=Bv[n]??Bv.default,o=Av[n]??Av.default;return{typeConfig:{...a,...o},textOnly:r,modelType:n}}var Hv=new Map,Uv=new Map,Wv=new Map,$=class extends uo{main_input_name=`input_ids`;forward_params=[`input_ids`,`attention_mask`];_return_dict_in_generate_keys=null;constructor(e,t,n){super(),this.config=e,this.sessions=t,this.configs=n;let{typeConfig:r}=Vv(Wv.get(this.constructor),e);this.can_generate=r.can_generate,this._forward=r.forward,this._prepare_inputs_for_generation=r.prepare_inputs,this.can_generate&&this.forward_params.push(`past_key_values`),this.custom_config=this.config[`transformers.js_config`]??{}}async dispose(){let e=[];for(let t of Object.values(this.sessions))e.push(t.release?.());return await Promise.all(e)}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`,model_file_name:o=null,subfolder:s=`onnx`,device:c=null,dtype:l=null,use_external_data_format:u=null,session_options:d={}}={}){let f={progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a,model_file_name:o,subfolder:s,device:c,dtype:l,use_external_data_format:u,session_options:d},p=Wv.get(this);n=f.config=await B_.from_pretrained(e,f);let{typeConfig:m,textOnly:h,modelType:g}=Vv(p,n);if(g===void 0){let e=p??n?.model_type;e!==`custom`&&B.warn(`Model type for '${e}' not found, assuming encoder-only architecture. Please report this at ${Xp}.`)}if(t&&!(t instanceof po)){let r={};try{let t=await Fv(e,{config:n,dtype:l,device:c,model_file_name:o});(await Promise.all(t.map(t=>od(e,t,f)))).forEach((e,n)=>{if(e.exists){let i=t[n]===`config.json`;r[t[n]]={loaded:i?e.size??0:0,total:e.size??0}}})}catch(e){B.warn(`Unable to fetch model file metadata for total progress tracking: ${e}`)}Object.keys(r).length>0&&(f.progress_callback=new po(t,r))}let _=[K_(e,m.sessions(n,f,h),f,m.cache_sessions)];m.optional_configs&&_.push(dy(e,m.optional_configs,f));let v=await Promise.all(_);return new this(n,...v)}async _call(e){return await this.forward(e)}async forward(e){return await this._forward(this,e)}get generation_config(){return this.configs?.generation_config??null}_get_logits_processor(e,t,n=null){let r=new sv;if(e.repetition_penalty!==null&&e.repetition_penalty!==1&&r.push(new mv(e.repetition_penalty)),e.no_repeat_ngram_size!==null&&e.no_repeat_ngram_size>0&&r.push(new pv(e.no_repeat_ngram_size)),e.bad_words_ids!==null&&r.push(new _v(e.bad_words_ids,e.eos_token_id)),e.min_length!==null&&e.eos_token_id!==null&&e.min_length>0&&r.push(new hv(e.min_length,e.eos_token_id)),e.min_new_tokens!==null&&e.eos_token_id!==null&&e.min_new_tokens>0&&r.push(new gv(t,e.min_new_tokens,e.eos_token_id)),e.forced_bos_token_id!==null&&r.push(new cv(e.forced_bos_token_id)),e.forced_eos_token_id!==null&&r.push(new lv(e.max_length,e.forced_eos_token_id)),e.suppress_tokens!==null&&r.push(new uv(e.suppress_tokens)),e.begin_suppress_tokens!==null){let n=t>1||e.forced_bos_token_id===null?t:t+1;r.push(new dv(e.begin_suppress_tokens,n))}return e.guidance_scale!==null&&e.guidance_scale>1&&r.push(new vv(e.guidance_scale)),e.temperature===0&&e.do_sample&&(B.warn("`do_sample` changed to false because `temperature: 0` implies greedy sampling (always selecting the most likely token), which is incompatible with `do_sample: true`."),e.do_sample=!1),e.do_sample&&e.temperature!==null&&e.temperature!==1&&r.push(new yv(e.temperature)),n!==null&&r.extend(n),r}_prepare_generation_config(e,t,n=bv){let r={...this.config};for(let e of[`decoder`,`generator`,`text_config`])e in r&&Object.assign(r,r[e]);let i=new n(r);return Object.assign(i,this.generation_config??{}),e&&Object.assign(i,e),t&&Object.assign(i,bo(t,Object.getOwnPropertyNames(i))),i}_get_stopping_criteria(e,t=null){let n=new Sv;return e.max_length!==null&&n.push(new Cv(e.max_length,this.config.max_position_embeddings??null)),e.eos_token_id!==null&&n.push(new wv(e.eos_token_id)),t&&n.extend(t),n}_validate_model_class(){if(!this.can_generate){let e=[Iv.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES,Iv.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES,Iv.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES,Iv.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES].filter(Boolean),t=Wv.get(this.constructor),n=new Set,r=this.config.model_type;for(let t of e){let e=t?.get(r);e&&n.add(e)}let i=`The current model class (${t}) is not compatible with \`.generate()\`, as it doesn't have a language model head.`;throw n.size>0&&(i+=` Please use the following class instead: ${[...n].join(`, `)}`),Error(i)}}prepare_inputs_for_generation(...e){if(!this._prepare_inputs_for_generation)throw Error(`prepare_inputs_for_generation is not implemented for this model.`);return this._prepare_inputs_for_generation(this,...e)}_update_model_kwargs_for_generation({generated_input_ids:e,outputs:t,model_inputs:n,is_encoder_decoder:r}){return n.past_key_values=Jv(t,n.past_key_values),n.input_ids=new J(`int64`,e.flat(),[e.length,1]),r?`decoder_attention_mask`in n&&(n.decoder_attention_mask=Ef([n.decoder_attention_mask,Ff([n.decoder_attention_mask.dims[0],1])],1)):n.attention_mask=Ef([n.attention_mask,Ff([n.attention_mask.dims[0],1])],1),n.position_ids=null,n}_prepare_model_inputs({inputs:e,bos_token_id:t,model_kwargs:n}){let r=bo(n,this.forward_params),i=this.main_input_name;if(i in r){if(e)throw Error("`inputs`: {inputs}` were passed alongside {input_name} which is not allowed. Make sure to either pass {inputs} or {input_name}=...")}else r[i]=e;return{inputs_tensor:r[i],model_inputs:r,model_input_name:i}}async _prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:e,model_inputs:t,model_input_name:n,generation_config:r}){if(this.sessions.model.inputNames.includes(`inputs_embeds`)&&!t.inputs_embeds&&`_prepare_inputs_embeds`in this){let{input_ids:e,pixel_values:n,attention_mask:r,...i}=t,a=await this._prepare_inputs_embeds(t);t={...i,...bo(a,[`inputs_embeds`,`attention_mask`])}}let{last_hidden_state:i}=await Kv(this,t);if(r.guidance_scale!==null&&r.guidance_scale>1)i=Ef([i,Pf(i,0)],0),`attention_mask`in t&&(t.attention_mask=Ef([t.attention_mask,Rf(t.attention_mask)],0));else if(t.decoder_input_ids){let e=Rv(t.decoder_input_ids).dims[0];if(e!==i.dims[0]){if(i.dims[0]!==1)throw Error(`The encoder outputs have a different batch size (${i.dims[0]}) than the decoder inputs (${e}).`);i=Ef(Array.from({length:e},()=>i),0)}}return t.encoder_outputs=i,t}_prepare_decoder_input_ids_for_generation({batch_size:e,model_input_name:t,model_kwargs:n,decoder_start_token_id:r,bos_token_id:i,generation_config:a}){let{decoder_input_ids:o,...s}=n;if(!(o instanceof J)){if(o)Array.isArray(o[0])||(o=Array.from({length:e},()=>o));else if(r??=i,this.config.model_type===`musicgen`)o=Array.from({length:e*this.config.decoder.num_codebooks},()=>[r]);else if(Array.isArray(r)){if(r.length!==e)throw Error(`\`decoder_start_token_id\` expected to have length ${e} but got ${r.length}`);o=r}else o=Array.from({length:e},()=>[r]);o=Rv(o)}return s.decoder_attention_mask=If(o),{input_ids:o,model_inputs:s}}async generate({inputs:e=null,generation_config:t=null,logits_processor:n=null,stopping_criteria:r=null,streamer:i=null,...a}){this._validate_model_class(),t=this._prepare_generation_config(t,a);let{inputs_tensor:o,model_inputs:s,model_input_name:c}=this._prepare_model_inputs({inputs:e,model_kwargs:a}),l=this.config.is_encoder_decoder;l&&(`encoder_outputs`in s||(s=await this._prepare_encoder_decoder_kwargs_for_generation({inputs_tensor:o,model_inputs:s,model_input_name:c,generation_config:t})));let u;l?{input_ids:u,model_inputs:s}=this._prepare_decoder_input_ids_for_generation({batch_size:s[c].dims.at(0),model_input_name:c,model_kwargs:s,decoder_start_token_id:t.decoder_start_token_id,bos_token_id:t.bos_token_id,generation_config:t}):u=s[c];let d=u.dims.at(-1);t.max_new_tokens!==null&&(t.max_length=d+t.max_new_tokens);let f=this._get_logits_processor(t,d,n),p=this._get_stopping_criteria(t,r),m=s[c].dims.at(0),h=Tv.getSampler(t),g=Array(m).fill(0),_=u.tolist();i&&i.put(_);let v,y={},b={};for(;;){if(s=this.prepare_inputs_for_generation(_,s,t),v=await this.forward(s),t.return_dict_in_generate){if(t.output_attentions){let e=Yv(v);for(let t in e)t in y||(y[t]=[]),y[t].push(e[t])}else this._return_dict_in_generate_keys&&Object.assign(b,bo(v,this._return_dict_in_generate_keys))}let e=f(_,v.logits.slice(null,-1,null).to(`float32`)),n=[];for(let t=0;te))break;s=this._update_model_kwargs_for_generation({generated_input_ids:n,outputs:v,model_inputs:s,is_encoder_decoder:l})}i&&i.end();let x=new J(`int64`,_.flat(),[_.length,_[0].length]),S=Jv(v,s.past_key_values),C=new Set(Object.values(S));for(let e of Object.values(v))e.location===`gpu-buffer`&&!C.has(e)&&e.dispose();return`past_key_values`in a||t.return_dict_in_generate||await S.dispose(),t.return_dict_in_generate?{sequences:x,past_key_values:S,...y,...b}:x}async _encode_input(e,t,n){if(!Object.hasOwn(this.sessions,e))throw Error(`Model does not have a ${e} session.`);let r=this.sessions[e];return(await J_(r,bo(t,r.inputNames)))[n]}async encode_image(e){return this._encode_input(`vision_encoder`,e,`image_features`)}async encode_text(e){return this._encode_input(`embed_tokens`,e,`inputs_embeds`)}async encode_audio(e){return this._encode_input(`audio_encoder`,e,`audio_features`)}};async function Gv(e,t){let{encoder_outputs:n,input_ids:r,decoder_input_ids:i,decoder_attention_mask:a,...o}=t;return n||=(await Kv(e,bo(t,e.sessions.model.inputNames))).last_hidden_state,o.input_ids=i,o.encoder_hidden_states=n,e.sessions.decoder_model_merged.inputNames.includes(`encoder_attention_mask`)&&(o.encoder_attention_mask=t.attention_mask),a&&!o.attention_mask&&(o.attention_mask=a),await $v(e,o,!0)}async function Kv(e,t){let n=e.sessions.model,r=bo(t,n.inputNames);if(n.inputNames.includes(`inputs_embeds`)&&!r.inputs_embeds){if(!t.input_ids)throw Error("Both `input_ids` and `inputs_embeds` are missing in the model inputs.");r.inputs_embeds=await e.encode_text({input_ids:t.input_ids})}if(n.inputNames.includes(`token_type_ids`)&&!r.token_type_ids){if(!r.input_ids)throw Error("Both `input_ids` and `token_type_ids` are missing in the model inputs.");r.token_type_ids=Rf(r.input_ids)}if(n.inputNames.includes(`pixel_mask`)&&!r.pixel_mask){if(!r.pixel_values)throw Error("Both `pixel_values` and `pixel_mask` are missing in the model inputs.");let e=r.pixel_values.dims;r.pixel_mask=Ff([e[0],e[2],e[3]])}return await J_(n,r)}async function qv(e,t){let n=await e.encode(t);return await e.decode(n)}function Jv(e,t){let n=Object.create(null);for(let r in e)if(r.startsWith(`present`)){let i=r.replace(`present_ssm`,`past_ssm`).replace(`present_conv`,`past_conv`).replace(`present_recurrent`,`past_recurrent`).replace(`present_compressor`,`past_compressor`).replace(`present_indexer`,`past_indexer`).replace(`present`,`past_key_values`);n[i]=r.includes(`encoder`)&&t?t[i]:e[r]}return t?(t.update(n),t):new kv(n)}function Yv(e){let t={};for(let n of[`cross_attentions`,`encoder_attentions`,`decoder_attentions`])for(let r in e)r.startsWith(n)&&(n in t||(t[n]=[]),t[n].push(e[r]));return t}function Xv(e,t){return e.map(e=>typeof e==`number`?e:t[e]??0)}function Zv(e,t,n){if(n&&Object.keys(n).length>0)return Object.assign(t,n),n;let r=e.sessions.decoder_model_merged??e.sessions.model,i=(t[e.main_input_name]??t.attention_mask)?.dims?.[0]??1,a=L_(e.config),o=e.config?.normalized_config?.num_heads,s={batch_size:i};typeof o==`number`&&(s[`batch_size x num_heads`]=i*o);let c=Object.create(null);for(let e of r.inputMetadata){if(!a.has(e.name))continue;let n=Xv(e.shape,s),r=n.reduce((e,t)=>e*t,1),i=pf[e.type],o=new J(e.type,new i(r),n);t[e.name]=o,c[e.name]=o}return n?(n.update(c),n):new kv(c)}function Qv(e,t,n){t.num_logits_to_keep||(e.sessions.decoder_model_merged??e.sessions.model)?.inputNames.includes(`num_logits_to_keep`)&&(t.num_logits_to_keep=new J(`int64`,[n],[]))}async function $v(e,t,n=!1){let r=e.sessions[n?`decoder_model_merged`:`model`],{past_key_values:i,...a}=t;return r.inputNames.includes(`use_cache_branch`)&&(a.use_cache_branch=zv(i!=null&&Object.keys(i).length>0)),r.inputNames.includes(`position_ids`)&&a.attention_mask&&!a.position_ids&&(a.position_ids=iy(a,i,+!![`paligemma`,`gemma3_text`,`gemma3`].includes(e.config.model_type))),Qv(e,a,0n),Zv(e,a,i),await J_(r,bo(a,r.inputNames))}async function ey(e,{encode_function:t,merge_function:n,modality_input_names:r,modality_output_name:i,input_ids:a=null,attention_mask:o=null,position_ids:s=null,inputs_embeds:c=null,past_key_values:l=null,generation_config:u=null,logits_processor:d=null,num_logits_to_keep:f=null,...p}){if(!c){c=await e.encode_text({input_ids:a,...p});let s=bo(p,r);if(Object.keys(s).length>0){if(a.dims[1]!==1){let e=await t({...s,...p});({inputs_embeds:c,attention_mask:o}=n({[i]:e,inputs_embeds:c,input_ids:a,attention_mask:o}))}else if(l&&a.dims[1]===1){let e=a.dims[1],t=l.get_seq_length();o=Ef([Ff([a.dims[0],t]),o.slice(null,[o.dims[1]-e,o.dims[1]])],1)}}}if(!s&&[`qwen2_vl`,`qwen2_vl_text`,`qwen2_5_vl`,`qwen2_5_vl_text`,`qwen3_vl`,`qwen3_vl_text`,`qwen3_vl_moe`,`qwen3_vl_moe_text`,`qwen3_5`,`qwen3_5_text`,`qwen3_5_moe`,`qwen3_5_moe_text`,`glm_ocr`,`glm_ocr_text`].includes(e.config.model_type)){let{image_grid_thw:t,video_grid_thw:n}=p;[s]=e.get_rope_index(a,t,n,o)}return await $v(e,{inputs_embeds:c,past_key_values:l,attention_mask:o,position_ids:s,generation_config:u,logits_processor:d,num_logits_to_keep:f},!0)}async function ty(e,t){return await ey(e,{...t,modality_input_names:[`audio_values`,`input_features`],modality_output_name:`audio_features`,encode_function:e.encode_audio.bind(e),merge_function:e._merge_input_ids_with_audio_features.bind(e)})}async function ny(e,t){return await ey(e,{...t,modality_input_names:[`pixel_values`],modality_output_name:`image_features`,encode_function:e.encode_image.bind(e),merge_function:e._merge_input_ids_with_image_features.bind(e)})}function ry(e,t=0){let[n,r]=e.dims,i=e.data,a=new BigInt64Array(i.length);for(let e=0;ee.dims[1]||i[e.at(-1)])),Qv(e,n,1n),{...n,decoder_input_ids:Rv(t)}}function sy(e,...t){return e.config.is_encoder_decoder?oy(e,...t):ay(e,...t)}function cy({modality_token_id:e,inputs_embeds:t,modality_features:n,input_ids:r,attention_mask:i}){let a=r.tolist().map(t=>t.reduce((t,n,r)=>(n==e&&t.push(r),t),[])),o=a.reduce((e,t)=>e+t.length,0),s=n.dims[0];if(o!==s)throw Error(`Number of tokens and features do not match: tokens: ${o}, features ${s}`);let c=0;for(let e=0;e[r,await _d(e,t[r],!1,n)])))}var fy={};Na(fy,{ASTForAudioClassification:()=>ky,ASTModel:()=>Oy,ASTPreTrainedModel:()=>Dy,AfmoeForCausalLM:()=>Cy,AfmoeModel:()=>Sy,AfmoePreTrainedModel:()=>xy,AlbertForMaskedLM:()=>_y,AlbertForQuestionAnswering:()=>gy,AlbertForSequenceClassification:()=>hy,AlbertModel:()=>my,AlbertPreTrainedModel:()=>py,ApertusForCausalLM:()=>by,ApertusModel:()=>yy,ApertusPreTrainedModel:()=>vy,ArceeForCausalLM:()=>Ey,ArceeModel:()=>Ty,ArceePreTrainedModel:()=>wy,BartForConditionalGeneration:()=>My,BartForSequenceClassification:()=>Ny,BartModel:()=>jy,BartPretrainedModel:()=>Ay,BaseModelOutput:()=>Z_,BeitForImageClassification:()=>Iy,BeitModel:()=>Fy,BeitPreTrainedModel:()=>Py,BertForMaskedLM:()=>zy,BertForQuestionAnswering:()=>Hy,BertForSequenceClassification:()=>By,BertForTokenClassification:()=>Vy,BertModel:()=>Ry,BertPreTrainedModel:()=>Ly,BlenderbotForConditionalGeneration:()=>Gy,BlenderbotModel:()=>Wy,BlenderbotPreTrainedModel:()=>Uy,BlenderbotSmallForConditionalGeneration:()=>Jy,BlenderbotSmallModel:()=>qy,BlenderbotSmallPreTrainedModel:()=>Ky,BloomForCausalLM:()=>Zy,BloomModel:()=>Xy,BloomPreTrainedModel:()=>Yy,CHMv2ForDepthEstimation:()=>db,CHMv2PreTrainedModel:()=>ub,CLIPModel:()=>_b,CLIPPreTrainedModel:()=>gb,CLIPSegForImageSegmentation:()=>wb,CLIPSegModel:()=>Cb,CLIPSegPreTrainedModel:()=>Sb,CLIPTextModel:()=>vb,CLIPTextModelWithProjection:()=>yb,CLIPVisionModel:()=>bb,CLIPVisionModelWithProjection:()=>xb,CamembertForMaskedLM:()=>eb,CamembertForQuestionAnswering:()=>rb,CamembertForSequenceClassification:()=>tb,CamembertForTokenClassification:()=>nb,CamembertModel:()=>$y,CamembertPreTrainedModel:()=>Qy,CausalLMOutput:()=>tv,CausalLMOutputWithPast:()=>nv,ChatterboxModel:()=>sb,ChatterboxPreTrainedModel:()=>ob,ChineseCLIPModel:()=>lb,ChineseCLIPPreTrainedModel:()=>cb,ClapAudioModelWithProjection:()=>hb,ClapModel:()=>pb,ClapPreTrainedModel:()=>fb,ClapTextModelWithProjection:()=>mb,CodeGenForCausalLM:()=>Db,CodeGenModel:()=>Eb,CodeGenPreTrainedModel:()=>Tb,Cohere2ForCausalLM:()=>Nb,Cohere2Model:()=>Mb,Cohere2PreTrainedModel:()=>jb,CohereAsrForConditionalGeneration:()=>Ib,CohereAsrModel:()=>Fb,CohereAsrPreTrainedModel:()=>Pb,CohereForCausalLM:()=>Ab,CohereModel:()=>kb,CoherePreTrainedModel:()=>Ob,ConvBertForMaskedLM:()=>zb,ConvBertForQuestionAnswering:()=>Hb,ConvBertForSequenceClassification:()=>Bb,ConvBertForTokenClassification:()=>Vb,ConvBertModel:()=>Rb,ConvBertPreTrainedModel:()=>Lb,ConvNextForImageClassification:()=>Gb,ConvNextModel:()=>Wb,ConvNextPreTrainedModel:()=>Ub,ConvNextV2ForImageClassification:()=>Jb,ConvNextV2Model:()=>qb,ConvNextV2PreTrainedModel:()=>Kb,DFineForObjectDetection:()=>tx,DFineModel:()=>ex,DFinePreTrainedModel:()=>$b,DINOv3ConvNextModel:()=>Jx,DINOv3ConvNextPreTrainedModel:()=>qx,DINOv3ViTModel:()=>Xx,DINOv3ViTPreTrainedModel:()=>Yx,DPTForDepthEstimation:()=>sS,DPTModel:()=>oS,DPTPreTrainedModel:()=>aS,DacDecoderModel:()=>sx,DacDecoderOutput:()=>rx,DacEncoderModel:()=>ox,DacEncoderOutput:()=>nx,DacModel:()=>ax,DacPreTrainedModel:()=>ix,DebertaForMaskedLM:()=>ux,DebertaForQuestionAnswering:()=>px,DebertaForSequenceClassification:()=>dx,DebertaForTokenClassification:()=>fx,DebertaModel:()=>lx,DebertaPreTrainedModel:()=>cx,DebertaV2ForMaskedLM:()=>Sx,DebertaV2ForQuestionAnswering:()=>Tx,DebertaV2ForSequenceClassification:()=>Cx,DebertaV2ForTokenClassification:()=>wx,DebertaV2Model:()=>xx,DebertaV2PreTrainedModel:()=>bx,DecisionTransformerModel:()=>Dx,DecisionTransformerPreTrainedModel:()=>Ex,DeepseekV3ForCausalLM:()=>gx,DeepseekV3Model:()=>hx,DeepseekV3PreTrainedModel:()=>mx,DeepseekV4ForCausalLM:()=>yx,DeepseekV4Model:()=>vx,DeepseekV4PreTrainedModel:()=>_x,DeiTForImageClassification:()=>Ax,DeiTModel:()=>kx,DeiTPreTrainedModel:()=>Ox,DepthAnythingForDepthEstimation:()=>Mx,DepthAnythingPreTrainedModel:()=>jx,DepthProForDepthEstimation:()=>Px,DepthProPreTrainedModel:()=>Nx,DetrForObjectDetection:()=>Lx,DetrForSegmentation:()=>Rx,DetrModel:()=>Ix,DetrObjectDetectionOutput:()=>zx,DetrPreTrainedModel:()=>Fx,DetrSegmentationOutput:()=>Bx,Dinov2ForImageClassification:()=>Ux,Dinov2Model:()=>Hx,Dinov2PreTrainedModel:()=>Vx,Dinov2WithRegistersForImageClassification:()=>Kx,Dinov2WithRegistersModel:()=>Gx,Dinov2WithRegistersPreTrainedModel:()=>Wx,DistilBertForMaskedLM:()=>nS,DistilBertForQuestionAnswering:()=>tS,DistilBertForSequenceClassification:()=>$x,DistilBertForTokenClassification:()=>eS,DistilBertModel:()=>Qx,DistilBertPreTrainedModel:()=>Zx,DonutSwinModel:()=>iS,DonutSwinPreTrainedModel:()=>rS,EdgeTamModel:()=>JO,EfficientNetForImageClassification:()=>uS,EfficientNetModel:()=>lS,EfficientNetPreTrainedModel:()=>cS,ElectraForMaskedLM:()=>pS,ElectraForQuestionAnswering:()=>gS,ElectraForSequenceClassification:()=>mS,ElectraForTokenClassification:()=>hS,ElectraModel:()=>fS,ElectraPreTrainedModel:()=>dS,Ernie4_5ForCausalLM:()=>yS,Ernie4_5Model:()=>vS,Ernie4_5PretrainedModel:()=>_S,EsmForMaskedLM:()=>SS,EsmForSequenceClassification:()=>CS,EsmForTokenClassification:()=>wS,EsmModel:()=>xS,EsmPreTrainedModel:()=>bS,EuroBertForMaskedLM:()=>DS,EuroBertForSequenceClassification:()=>OS,EuroBertForTokenClassification:()=>kS,EuroBertModel:()=>ES,EuroBertPreTrainedModel:()=>TS,ExaoneForCausalLM:()=>MS,ExaoneModel:()=>jS,ExaonePreTrainedModel:()=>AS,FalconForCausalLM:()=>FS,FalconH1ForCausalLM:()=>RS,FalconH1Model:()=>LS,FalconH1PreTrainedModel:()=>IS,FalconModel:()=>PS,FalconPreTrainedModel:()=>NS,FastViTForImageClassification:()=>VS,FastViTModel:()=>BS,FastViTPreTrainedModel:()=>zS,Florence2ForConditionalGeneration:()=>US,Florence2PreTrainedModel:()=>HS,GLPNForDepthEstimation:()=>CC,GLPNModel:()=>SC,GLPNPreTrainedModel:()=>xC,GPT2LMHeadModel:()=>RC,GPT2Model:()=>LC,GPT2PreTrainedModel:()=>IC,GPTBigCodeForCausalLM:()=>EC,GPTBigCodeModel:()=>TC,GPTBigCodePreTrainedModel:()=>wC,GPTJForCausalLM:()=>VC,GPTJModel:()=>BC,GPTJPreTrainedModel:()=>zC,GPTNeoForCausalLM:()=>kC,GPTNeoModel:()=>OC,GPTNeoPreTrainedModel:()=>DC,GPTNeoXForCausalLM:()=>MC,GPTNeoXModel:()=>jC,GPTNeoXPreTrainedModel:()=>AC,Gemma2ForCausalLM:()=>YS,Gemma2Model:()=>JS,Gemma2PreTrainedModel:()=>qS,Gemma3ForCausalLM:()=>rC,Gemma3ForConditionalGeneration:()=>nC,Gemma3Model:()=>tC,Gemma3PreTrainedModel:()=>eC,Gemma3nForCausalLM:()=>oC,Gemma3nForConditionalGeneration:()=>aC,Gemma3nPreTrainedModel:()=>iC,Gemma4ForCausalLM:()=>cC,Gemma4ForConditionalGeneration:()=>sC,GemmaForCausalLM:()=>KS,GemmaModel:()=>GS,GemmaPreTrainedModel:()=>WS,GlmForCausalLM:()=>dC,GlmModel:()=>uC,GlmMoeDsaForCausalLM:()=>mC,GlmMoeDsaModel:()=>pC,GlmMoeDsaPreTrainedModel:()=>fC,GlmOcrForConditionalGeneration:()=>bC,GlmPreTrainedModel:()=>lC,GptOssForCausalLM:()=>FC,GptOssModel:()=>PC,GptOssPreTrainedModel:()=>NC,GraniteForCausalLM:()=>WC,GraniteModel:()=>UC,GraniteMoeHybridForCausalLM:()=>qC,GraniteMoeHybridModel:()=>KC,GraniteMoeHybridPreTrainedModel:()=>GC,GranitePreTrainedModel:()=>HC,GraniteSpeechForConditionalGeneration:()=>XC,GroundingDinoForObjectDetection:()=>QC,GroundingDinoPreTrainedModel:()=>ZC,GroupViTModel:()=>ew,GroupViTPreTrainedModel:()=>$C,HeliumForCausalLM:()=>rw,HeliumModel:()=>nw,HeliumPreTrainedModel:()=>tw,HieraForImageClassification:()=>ow,HieraModel:()=>aw,HieraPreTrainedModel:()=>iw,HrmTextForCausalLM:()=>lw,HrmTextModel:()=>cw,HrmTextPreTrainedModel:()=>sw,HubertForCTC:()=>_w,HubertForSequenceClassification:()=>vw,HubertModel:()=>gw,HubertPreTrainedModel:()=>hw,HunYuanDenseV1ForCausalLM:()=>xw,HunYuanDenseV1Model:()=>bw,HunYuanDenseV1PreTrainedModel:()=>yw,IJepaForImageClassification:()=>Tw,IJepaModel:()=>ww,IJepaPreTrainedModel:()=>Cw,Idefics3ForConditionalGeneration:()=>Sw,ImageMattingOutput:()=>iv,JAISLMHeadModel:()=>Ow,JAISModel:()=>Dw,JAISPreTrainedModel:()=>Ew,JinaCLIPModel:()=>Aw,JinaCLIPPreTrainedModel:()=>kw,JinaCLIPTextModel:()=>jw,JinaCLIPVisionModel:()=>Mw,Lfm2ForCausalLM:()=>Fw,Lfm2Model:()=>Pw,Lfm2MoeForCausalLM:()=>zw,Lfm2MoeModel:()=>Rw,Lfm2MoePreTrainedModel:()=>Lw,Lfm2PreTrainedModel:()=>Nw,Lfm2VlForConditionalGeneration:()=>Bw,LightOnOcrForConditionalGeneration:()=>Iw,LiteWhisperForConditionalGeneration:()=>rj,Llama4ForCausalLM:()=>Gw,Llama4PreTrainedModel:()=>Ww,LlamaForCausalLM:()=>Uw,LlamaModel:()=>Hw,LlamaPreTrainedModel:()=>Vw,LlavaForConditionalGeneration:()=>ZS,LlavaOnevisionForConditionalGeneration:()=>ZS,LlavaPreTrainedModel:()=>XS,LlavaQwen2ForCausalLM:()=>$S,LongT5ForConditionalGeneration:()=>Jw,LongT5Model:()=>qw,LongT5PreTrainedModel:()=>Kw,M2M100ForConditionalGeneration:()=>Zw,M2M100Model:()=>Xw,M2M100PreTrainedModel:()=>Yw,MBartForCausalLM:()=>cT,MBartForConditionalGeneration:()=>oT,MBartForSequenceClassification:()=>sT,MBartModel:()=>aT,MBartPreTrainedModel:()=>iT,MPNetForMaskedLM:()=>wE,MPNetForQuestionAnswering:()=>DE,MPNetForSequenceClassification:()=>TE,MPNetForTokenClassification:()=>EE,MPNetModel:()=>CE,MPNetPreTrainedModel:()=>SE,MT5ForConditionalGeneration:()=>NE,MT5Model:()=>ME,MT5PreTrainedModel:()=>jE,MarianMTModel:()=>eT,MarianModel:()=>$w,MarianPreTrainedModel:()=>Qw,MaskFormerForInstanceSegmentation:()=>rT,MaskFormerModel:()=>nT,MaskFormerPreTrainedModel:()=>tT,MaskedLMOutput:()=>$_,Metric3DForDepthEstimation:()=>uT,Metric3DPreTrainedModel:()=>lT,Metric3Dv2ForDepthEstimation:()=>fT,Metric3Dv2PreTrainedModel:()=>dT,MgpstrForSceneTextRecognition:()=>hT,MgpstrModelOutput:()=>pT,MgpstrPreTrainedModel:()=>mT,MimiDecoderModel:()=>xT,MimiDecoderOutput:()=>_T,MimiEncoderModel:()=>bT,MimiEncoderOutput:()=>gT,MimiModel:()=>yT,MimiPreTrainedModel:()=>vT,Ministral3ForCausalLM:()=>DT,Ministral3Model:()=>ET,Ministral3PreTrainedModel:()=>TT,MinistralForCausalLM:()=>wT,MinistralModel:()=>CT,MinistralPreTrainedModel:()=>ST,Mistral3ForConditionalGeneration:()=>jT,Mistral4ForCausalLM:()=>PT,Mistral4Model:()=>NT,Mistral4PreTrainedModel:()=>MT,MistralForCausalLM:()=>AT,MistralModel:()=>kT,MistralPreTrainedModel:()=>OT,MobileBertForMaskedLM:()=>LT,MobileBertForQuestionAnswering:()=>zT,MobileBertForSequenceClassification:()=>RT,MobileBertModel:()=>IT,MobileBertPreTrainedModel:()=>FT,MobileLLMForCausalLM:()=>HT,MobileLLMModel:()=>VT,MobileLLMPreTrainedModel:()=>BT,MobileNetV1ForImageClassification:()=>GT,MobileNetV1ForSemanticSegmentation:()=>KT,MobileNetV1Model:()=>WT,MobileNetV1PreTrainedModel:()=>UT,MobileNetV2ForImageClassification:()=>YT,MobileNetV2ForSemanticSegmentation:()=>XT,MobileNetV2Model:()=>JT,MobileNetV2PreTrainedModel:()=>qT,MobileNetV3ForImageClassification:()=>$T,MobileNetV3ForSemanticSegmentation:()=>eE,MobileNetV3Model:()=>QT,MobileNetV3PreTrainedModel:()=>ZT,MobileNetV4ForImageClassification:()=>rE,MobileNetV4ForSemanticSegmentation:()=>iE,MobileNetV4Model:()=>nE,MobileNetV4PreTrainedModel:()=>tE,MobileViTForImageClassification:()=>sE,MobileViTModel:()=>oE,MobileViTPreTrainedModel:()=>aE,MobileViTV2ForImageClassification:()=>uE,MobileViTV2Model:()=>lE,MobileViTV2PreTrainedModel:()=>cE,ModelOutput:()=>X_,ModernBertDecoderForCausalLM:()=>vE,ModernBertDecoderModel:()=>_E,ModernBertDecoderPreTrainedModel:()=>gE,ModernBertForMaskedLM:()=>pE,ModernBertForSequenceClassification:()=>mE,ModernBertForTokenClassification:()=>hE,ModernBertModel:()=>fE,ModernBertPreTrainedModel:()=>dE,Moondream1ForConditionalGeneration:()=>QS,MoonshineForConditionalGeneration:()=>xE,MoonshineModel:()=>bE,MoonshinePreTrainedModel:()=>yE,MptForCausalLM:()=>AE,MptModel:()=>kE,MptPreTrainedModel:()=>OE,MultiModalityCausalLM:()=>FE,MultiModalityPreTrainedModel:()=>PE,MusicgenForCausalLM:()=>RE,MusicgenForConditionalGeneration:()=>zE,MusicgenModel:()=>LE,MusicgenPreTrainedModel:()=>IE,NanoChatForCausalLM:()=>HE,NanoChatModel:()=>VE,NanoChatPreTrainedModel:()=>BE,NemotronHForCausalLM:()=>GE,NemotronHModel:()=>WE,NemotronHPreTrainedModel:()=>UE,NeoBertForMaskedLM:()=>JE,NeoBertForQuestionAnswering:()=>ZE,NeoBertForSequenceClassification:()=>YE,NeoBertForTokenClassification:()=>XE,NeoBertModel:()=>qE,NeoBertPreTrainedModel:()=>KE,NomicBertModel:()=>$E,NomicBertPreTrainedModel:()=>QE,OPTForCausalLM:()=>bD,OPTModel:()=>yD,OPTPreTrainedModel:()=>vD,Olmo2ForCausalLM:()=>aD,Olmo2Model:()=>iD,Olmo2PreTrainedModel:()=>rD,Olmo3ForCausalLM:()=>cD,Olmo3Model:()=>sD,Olmo3PreTrainedModel:()=>oD,OlmoForCausalLM:()=>nD,OlmoHybridForCausalLM:()=>dD,OlmoHybridModel:()=>uD,OlmoHybridPreTrainedModel:()=>lD,OlmoModel:()=>tD,OlmoPreTrainedModel:()=>eD,OpenAIPrivacyFilterForTokenClassification:()=>mD,OpenAIPrivacyFilterModel:()=>pD,OpenAIPrivacyFilterPreTrainedModel:()=>fD,OpenELMForCausalLM:()=>_D,OpenELMModel:()=>gD,OpenELMPreTrainedModel:()=>hD,OwlViTForObjectDetection:()=>ED,OwlViTModel:()=>TD,OwlViTPreTrainedModel:()=>wD,Owlv2ForObjectDetection:()=>CD,Owlv2Model:()=>SD,Owlv2PreTrainedModel:()=>xD,PaliGemmaForConditionalGeneration:()=>DD,ParakeetForCTC:()=>kD,ParakeetPreTrainedModel:()=>OD,PatchTSMixerForPrediction:()=>MD,PatchTSMixerModel:()=>jD,PatchTSMixerPreTrainedModel:()=>AD,PatchTSTForPrediction:()=>FD,PatchTSTModel:()=>PD,PatchTSTPreTrainedModel:()=>ND,Phi3ForCausalLM:()=>VD,Phi3Model:()=>BD,Phi3PreTrainedModel:()=>zD,Phi3VForCausalLM:()=>UD,Phi3VPreTrainedModel:()=>HD,PhiForCausalLM:()=>RD,PhiModel:()=>LD,PhiPreTrainedModel:()=>ID,PreTrainedModel:()=>$,PvtForImageClassification:()=>KD,PvtModel:()=>GD,PvtPreTrainedModel:()=>WD,PyAnnoteForAudioFrameClassification:()=>YD,PyAnnoteModel:()=>JD,PyAnnotePreTrainedModel:()=>qD,QuestionAnsweringModelOutput:()=>ev,Qwen2ForCausalLM:()=>QD,Qwen2Model:()=>ZD,Qwen2MoeForCausalLM:()=>tO,Qwen2MoeModel:()=>eO,Qwen2MoePreTrainedModel:()=>$D,Qwen2PreTrainedModel:()=>XD,Qwen2VLForCausalLM:()=>_C,Qwen2VLForConditionalGeneration:()=>gC,Qwen2VLPreTrainedModel:()=>hC,Qwen2_5_VLForCausalLM:()=>yC,Qwen2_5_VLForConditionalGeneration:()=>vC,Qwen3ForCausalLM:()=>iO,Qwen3Model:()=>rO,Qwen3MoeForCausalLM:()=>sO,Qwen3MoeModel:()=>oO,Qwen3MoePreTrainedModel:()=>aO,Qwen3NextForCausalLM:()=>uO,Qwen3NextModel:()=>lO,Qwen3NextPreTrainedModel:()=>cO,Qwen3PreTrainedModel:()=>nO,Qwen3VLForCausalLM:()=>fO,Qwen3VLForConditionalGeneration:()=>dO,Qwen3VLMoeForCausalLM:()=>mO,Qwen3VLMoeForConditionalGeneration:()=>pO,Qwen3_5ForCausalLM:()=>gO,Qwen3_5ForConditionalGeneration:()=>hO,Qwen3_5MoeForCausalLM:()=>vO,Qwen3_5MoeForConditionalGeneration:()=>_O,RFDetrForObjectDetection:()=>wO,RFDetrModel:()=>CO,RFDetrObjectDetectionOutput:()=>TO,RFDetrPreTrainedModel:()=>SO,RTDetrForObjectDetection:()=>Zb,RTDetrModel:()=>Xb,RTDetrObjectDetectionOutput:()=>Qb,RTDetrPreTrainedModel:()=>Yb,RTDetrV2ForObjectDetection:()=>BO,RTDetrV2Model:()=>zO,RTDetrV2ObjectDetectionOutput:()=>VO,RTDetrV2PreTrainedModel:()=>RO,ResNetForImageClassification:()=>xO,ResNetModel:()=>bO,ResNetPreTrainedModel:()=>yO,RoFormerForMaskedLM:()=>PO,RoFormerForQuestionAnswering:()=>LO,RoFormerForSequenceClassification:()=>FO,RoFormerForTokenClassification:()=>IO,RoFormerModel:()=>NO,RoFormerPreTrainedModel:()=>MO,RobertaForMaskedLM:()=>OO,RobertaForQuestionAnswering:()=>jO,RobertaForSequenceClassification:()=>kO,RobertaForTokenClassification:()=>AO,RobertaModel:()=>DO,RobertaPreTrainedModel:()=>EO,Sam2ImageSegmentationOutput:()=>GO,Sam2Model:()=>qO,Sam2PreTrainedModel:()=>KO,Sam3TrackerModel:()=>YO,SamImageSegmentationOutput:()=>HO,SamModel:()=>WO,SamPreTrainedModel:()=>UO,SapiensForDepthEstimation:()=>QO,SapiensForNormalEstimation:()=>$O,SapiensForSemanticSegmentation:()=>ZO,SapiensPreTrainedModel:()=>XO,SegformerForImageClassification:()=>nk,SegformerForSemanticSegmentation:()=>rk,SegformerModel:()=>tk,SegformerPreTrainedModel:()=>ek,Seq2SeqLMOutput:()=>rv,SequenceClassifierOutput:()=>Z,SiglipModel:()=>ak,SiglipPreTrainedModel:()=>ik,SiglipTextModel:()=>ok,SiglipVisionModel:()=>sk,SmolLM3ForCausalLM:()=>uk,SmolLM3Model:()=>lk,SmolLM3PreTrainedModel:()=>ck,SmolVLMForConditionalGeneration:()=>dk,SnacDecoderModel:()=>hk,SnacEncoderModel:()=>mk,SnacModel:()=>pk,SnacPreTrainedModel:()=>fk,SolarOpenForCausalLM:()=>vk,SolarOpenModel:()=>_k,SolarOpenPreTrainedModel:()=>gk,SpeechT5ForSpeechToText:()=>xk,SpeechT5ForTextToSpeech:()=>Sk,SpeechT5HifiGan:()=>Ck,SpeechT5Model:()=>bk,SpeechT5PreTrainedModel:()=>yk,SqueezeBertForMaskedLM:()=>Ek,SqueezeBertForQuestionAnswering:()=>Ok,SqueezeBertForSequenceClassification:()=>Dk,SqueezeBertModel:()=>Tk,SqueezeBertPreTrainedModel:()=>wk,StableLmForCausalLM:()=>jk,StableLmModel:()=>Ak,StableLmPreTrainedModel:()=>kk,Starcoder2ForCausalLM:()=>Pk,Starcoder2Model:()=>Nk,Starcoder2PreTrainedModel:()=>Mk,StyleTextToSpeech2Model:()=>Ik,StyleTextToSpeech2PreTrainedModel:()=>Fk,SupertonicForConditionalGeneration:()=>Rk,SupertonicPreTrainedModel:()=>Lk,Swin2SRForImageSuperResolution:()=>Gk,Swin2SRModel:()=>Wk,Swin2SRPreTrainedModel:()=>Uk,SwinForImageClassification:()=>Vk,SwinForSemanticSegmentation:()=>Hk,SwinModel:()=>Bk,SwinPreTrainedModel:()=>zk,T5ForConditionalGeneration:()=>Jk,T5Model:()=>qk,T5PreTrainedModel:()=>Kk,TableTransformerForObjectDetection:()=>Zk,TableTransformerModel:()=>Xk,TableTransformerObjectDetectionOutput:()=>Qk,TableTransformerPreTrainedModel:()=>Yk,TokenClassifierOutput:()=>Q_,TrOCRForCausalLM:()=>eA,TrOCRPreTrainedModel:()=>$k,UltravoxModel:()=>YC,UltravoxPreTrainedModel:()=>JC,UniSpeechForCTC:()=>rA,UniSpeechForSequenceClassification:()=>iA,UniSpeechModel:()=>nA,UniSpeechPreTrainedModel:()=>tA,UniSpeechSatForAudioFrameClassification:()=>lA,UniSpeechSatForCTC:()=>sA,UniSpeechSatForSequenceClassification:()=>cA,UniSpeechSatModel:()=>oA,UniSpeechSatPreTrainedModel:()=>aA,VaultGemmaForCausalLM:()=>fA,VaultGemmaModel:()=>dA,VaultGemmaPreTrainedModel:()=>uA,ViTForImageClassification:()=>gA,ViTMAEModel:()=>vA,ViTMAEPreTrainedModel:()=>_A,ViTMSNForImageClassification:()=>xA,ViTMSNModel:()=>bA,ViTMSNPreTrainedModel:()=>yA,ViTModel:()=>hA,ViTPreTrainedModel:()=>mA,VisionEncoderDecoderModel:()=>pA,VitMatteForImageMatting:()=>CA,VitMattePreTrainedModel:()=>SA,VitPoseForPoseEstimation:()=>TA,VitPosePreTrainedModel:()=>wA,VitsModel:()=>OA,VitsModelOutput:()=>EA,VitsPreTrainedModel:()=>DA,VoxtralForConditionalGeneration:()=>kA,VoxtralRealtimeForConditionalGeneration:()=>zA,VoxtralRealtimePreTrainedModel:()=>RA,Wav2Vec2BertForCTC:()=>HA,Wav2Vec2BertForSequenceClassification:()=>UA,Wav2Vec2BertModel:()=>VA,Wav2Vec2BertPreTrainedModel:()=>BA,Wav2Vec2ForAudioFrameClassification:()=>mw,Wav2Vec2ForCTC:()=>fw,Wav2Vec2ForSequenceClassification:()=>pw,Wav2Vec2Model:()=>dw,Wav2Vec2PreTrainedModel:()=>uw,WavLMForAudioFrameClassification:()=>XA,WavLMForCTC:()=>qA,WavLMForSequenceClassification:()=>JA,WavLMForXVector:()=>YA,WavLMModel:()=>KA,WavLMPreTrainedModel:()=>GA,WeSpeakerResNetModel:()=>QA,WeSpeakerResNetPreTrainedModel:()=>ZA,WhisperForConditionalGeneration:()=>nj,WhisperModel:()=>tj,WhisperPreTrainedModel:()=>ej,XLMForQuestionAnswering:()=>lj,XLMForSequenceClassification:()=>sj,XLMForTokenClassification:()=>cj,XLMModel:()=>aj,XLMPreTrainedModel:()=>ij,XLMRobertaForMaskedLM:()=>fj,XLMRobertaForQuestionAnswering:()=>hj,XLMRobertaForSequenceClassification:()=>pj,XLMRobertaForTokenClassification:()=>mj,XLMRobertaModel:()=>dj,XLMRobertaPreTrainedModel:()=>uj,XLMWithLMHeadModel:()=>oj,XVectorOutput:()=>WA,YolosForObjectDetection:()=>vj,YolosModel:()=>_j,YolosObjectDetectionOutput:()=>yj,YolosPreTrainedModel:()=>gj,YoutuForCausalLM:()=>Sj,YoutuModel:()=>xj,YoutuPreTrainedModel:()=>bj,ZayaForCausalLM:()=>Tj,ZayaModel:()=>wj,ZayaPreTrainedModel:()=>Cj});var py=class extends ${},my=class extends py{},hy=class extends py{async _call(e){return new Z(await super._call(e))}},gy=class extends py{async _call(e){return new ev(await super._call(e))}},_y=class extends py{async _call(e){return new $_(await super._call(e))}},vy=class extends ${},yy=class extends vy{},by=class extends vy{},xy=class extends ${},Sy=class extends xy{},Cy=class extends xy{},wy=class extends ${},Ty=class extends wy{},Ey=class extends wy{},Dy=class extends ${},Oy=class extends Dy{},ky=class extends Dy{},Ay=class extends ${},jy=class extends Ay{},My=class extends Ay{},Ny=class extends Ay{async _call(e){return new Z(await super._call(e))}},Py=class extends ${},Fy=class extends Py{},Iy=class extends Py{async _call(e){return new Z(await super._call(e))}},Ly=class extends ${},Ry=class extends Ly{},zy=class extends Ly{async _call(e){return new $_(await super._call(e))}},By=class extends Ly{async _call(e){return new Z(await super._call(e))}},Vy=class extends Ly{async _call(e){return new Q_(await super._call(e))}},Hy=class extends Ly{async _call(e){return new ev(await super._call(e))}},Uy=class extends ${},Wy=class extends Uy{},Gy=class extends Uy{},Ky=class extends ${},qy=class extends Ky{},Jy=class extends Ky{},Yy=class extends ${},Xy=class extends Yy{},Zy=class extends Yy{},Qy=class extends ${},$y=class extends Qy{},eb=class extends Qy{async _call(e){return new $_(await super._call(e))}},tb=class extends Qy{async _call(e){return new Z(await super._call(e))}},nb=class extends Qy{async _call(e){return new Q_(await super._call(e))}},rb=class extends Qy{async _call(e){return new ev(await super._call(e))}},ib=4299n,ab=6561n,ob=class extends ${forward_params=[`input_ids`,`inputs_embeds`,`attention_mask`,`position_ids`,`audio_values`,`exaggeration`,`audio_features`,`audio_tokens`,`speaker_embeddings`,`speaker_features`,`past_key_values`];main_input_name=`input_ids`;_return_dict_in_generate_keys=[`audio_tokens`,`speaker_embeddings`,`speaker_features`]},sb=class extends ob{async encode_speech(e){return J_(this.sessions.speech_encoder,{audio_values:e})}async forward({input_ids:e=null,attention_mask:t=null,audio_values:n=null,exaggeration:r=null,position_ids:i=null,inputs_embeds:a=null,past_key_values:o=null,generation_config:s=null,logits_processor:c=null,num_logits_to_keep:l=null,audio_features:u=null,audio_tokens:d=null,speaker_embeddings:f=null,speaker_features:p=null,...m}){let h;if(!a){let s=this.sessions.embed_tokens.inputNames,c={input_ids:e};if(s.includes(`exaggeration`)){if(!(r instanceof J)){let t=e.dims[0];if(r==null)r=Nf([t],.5);else if(typeof r==`number`)r=Nf([t],r);else if(Array.isArray(r))r=new J(`float32`,r,[t]);else throw Error("Unsupported type for `exaggeration` input")}c.exaggeration=r}if(s.includes(`position_ids`)&&(c.position_ids=i),{inputs_embeds:a}=await J_(this.sessions.embed_tokens,c),u&&d&&f&&p&&(h={audio_features:u,audio_tokens:d,speaker_embeddings:f,speaker_features:p}),h||n)h??=await this.encode_speech(n),a=Ef([h.audio_features,a],1),t=Ff([a.dims[0],a.dims[1]]);else{let e=a.dims[1];if(!o||e!==1)throw Error(`Incorrect state encountered during generation.`);let n=o.get_seq_length();t=Ff([a.dims[0],n+e])}}return{...await $v(this,{inputs_embeds:a,past_key_values:o,attention_mask:t,generation_config:s,logits_processor:c,num_logits_to_keep:l},!1),...h}}prepare_inputs_for_generation(e,t,n){return!t.position_ids&&this.sessions.embed_tokens.inputNames.includes(`position_ids`)&&(t.position_ids=t.input_ids.dims[1]===1?new J(`int64`,Array.from({length:e.length},(t,n)=>e[n].length-e[n].findLastIndex(e=>e==ab)-1),[e.length,1]):new J(`int64`,t.input_ids.tolist().map(e=>{let t=0;return e.map(e=>e>=ab?0:t++)}).flat(),t.input_ids.dims)),t.input_ids.dims[1]===1&&(delete t.audio_values,delete t.audio_features,delete t.audio_tokens,delete t.speaker_embeddings,delete t.speaker_features),ay(this,e,t,n)}async generate(e){let t=e.past_key_values,{sequences:n,audio_tokens:r,speaker_embeddings:i,speaker_features:a,past_key_values:o}=await super.generate({...e,return_dict_in_generate:!0});try{let t=n.slice(null,[e.input_ids.dims[1],-1]),o=Ef([r,t,Nf([t.dims[0],3],ib)],1),{waveform:s}=await J_(this.sessions.conditional_decoder,{speech_tokens:o,speaker_features:a,speaker_embeddings:i});return s}finally{o!==t&&await o?.dispose()}}},cb=class extends ${},lb=class extends cb{},ub=class extends ${},db=class extends ub{},fb=class extends ${},pb=class extends fb{},mb=class extends fb{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},hb=class extends fb{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`audio_model`})}},gb=class extends ${},_b=class extends gb{},vb=class extends gb{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},yb=class extends gb{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},bb=class extends gb{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},xb=class extends gb{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},Sb=class extends ${},Cb=class extends Sb{},wb=class extends Sb{},Tb=class extends ${},Eb=class extends Tb{},Db=class extends Tb{},Ob=class extends ${},kb=class extends Ob{},Ab=class extends Ob{},jb=class extends ${},Mb=class extends jb{},Nb=class extends jb{},Pb=class extends ${requires_attention_mask=!1;main_input_name=`input_features`;forward_params=[`input_features`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`]},Fb=class extends Pb{},Ib=class extends Pb{},Lb=class extends ${},Rb=class extends Lb{},zb=class extends Lb{async _call(e){return new $_(await super._call(e))}},Bb=class extends Lb{async _call(e){return new Z(await super._call(e))}},Vb=class extends Lb{async _call(e){return new Q_(await super._call(e))}},Hb=class extends Lb{async _call(e){return new ev(await super._call(e))}},Ub=class extends ${},Wb=class extends Ub{},Gb=class extends Ub{async _call(e){return new Z(await super._call(e))}},Kb=class extends ${},qb=class extends Kb{},Jb=class extends Kb{async _call(e){return new Z(await super._call(e))}},Yb=class extends ${},Xb=class extends Yb{},Zb=class extends Yb{async _call(e){return new Qb(await super._call(e))}},Qb=class extends X_{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},$b=class extends ${},ex=class extends $b{},tx=class extends $b{async _call(e){return new Qb(await super._call(e))}},nx=class extends X_{constructor({audio_codes:e}){super(),this.audio_codes=e}},rx=class extends X_{constructor({audio_values:e}){super(),this.audio_values=e}},ix=class extends ${main_input_name=`input_values`;forward_params=[`input_values`]},ax=class extends ix{async encode(e){return new nx(await J_(this.sessions.encoder_model,e))}async decode(e){return new rx(await J_(this.sessions.decoder_model,e))}},ox=class extends ix{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},sx=class extends ix{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},cx=class extends ${},lx=class extends cx{},ux=class extends cx{async _call(e){return new $_(await super._call(e))}},dx=class extends cx{async _call(e){return new Z(await super._call(e))}},fx=class extends cx{async _call(e){return new Q_(await super._call(e))}},px=class extends cx{async _call(e){return new ev(await super._call(e))}},mx=class extends ${},hx=class extends mx{},gx=class extends mx{},_x=class extends ${},vx=class extends _x{},yx=class extends _x{},bx=class extends ${},xx=class extends bx{},Sx=class extends bx{async _call(e){return new $_(await super._call(e))}},Cx=class extends bx{async _call(e){return new Z(await super._call(e))}},wx=class extends bx{async _call(e){return new Q_(await super._call(e))}},Tx=class extends bx{async _call(e){return new ev(await super._call(e))}},Ex=class extends ${},Dx=class extends Ex{},Ox=class extends ${},kx=class extends Ox{},Ax=class extends Ox{async _call(e){return new Z(await super._call(e))}},jx=class extends ${},Mx=class extends jx{},Nx=class extends ${},Px=class extends Nx{},Fx=class extends ${},Ix=class extends Fx{},Lx=class extends Fx{async _call(e){return new zx(await super._call(e))}},Rx=class extends Fx{async _call(e){return new Bx(await super._call(e))}},zx=class extends X_{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},Bx=class extends X_{constructor({logits:e,pred_boxes:t,pred_masks:n}){super(),this.logits=e,this.pred_boxes=t,this.pred_masks=n}},Vx=class extends ${},Hx=class extends Vx{},Ux=class extends Vx{async _call(e){return new Z(await super._call(e))}},Wx=class extends ${},Gx=class extends Wx{},Kx=class extends Wx{async _call(e){return new Z(await super._call(e))}},qx=class extends ${},Jx=class extends qx{},Yx=class extends ${},Xx=class extends Yx{},Zx=class extends ${},Qx=class extends Zx{},$x=class extends Zx{async _call(e){return new Z(await super._call(e))}},eS=class extends Zx{async _call(e){return new Q_(await super._call(e))}},tS=class extends Zx{async _call(e){return new ev(await super._call(e))}},nS=class extends Zx{async _call(e){return new $_(await super._call(e))}},rS=class extends ${},iS=class extends rS{},aS=class extends ${},oS=class extends aS{},sS=class extends aS{},cS=class extends ${},lS=class extends cS{},uS=class extends cS{async _call(e){return new Z(await super._call(e))}},dS=class extends ${},fS=class extends dS{},pS=class extends dS{async _call(e){return new $_(await super._call(e))}},mS=class extends dS{async _call(e){return new Z(await super._call(e))}},hS=class extends dS{async _call(e){return new Q_(await super._call(e))}},gS=class extends dS{async _call(e){return new ev(await super._call(e))}},_S=class extends ${},vS=class extends _S{},yS=class extends _S{},bS=class extends ${},xS=class extends bS{},SS=class extends bS{async _call(e){return new $_(await super._call(e))}},CS=class extends bS{async _call(e){return new Z(await super._call(e))}},wS=class extends bS{async _call(e){return new Q_(await super._call(e))}},TS=class extends ${},ES=class extends TS{},DS=class extends TS{async _call(e){return new $_(await super._call(e))}},OS=class extends TS{async _call(e){return new Z(await super._call(e))}},kS=class extends TS{async _call(e){return new Q_(await super._call(e))}},AS=class extends ${},jS=class extends AS{},MS=class extends AS{},NS=class extends ${},PS=class extends NS{},FS=class extends NS{},IS=class extends ${},LS=class extends IS{},RS=class extends IS{},zS=class extends ${},BS=class extends zS{},VS=class extends zS{async _call(e){return new Z(await super._call(e))}},HS=class extends ${forward_params=[`input_ids`,`inputs_embeds`,`attention_mask`,`pixel_values`,`encoder_outputs`,`decoder_input_ids`,`decoder_inputs_embeds`,`decoder_attention_mask`,`past_key_values`];main_input_name=`inputs_embeds`},US=class extends HS{_merge_input_ids_with_image_features({inputs_embeds:e,image_features:t,input_ids:n,attention_mask:r}){return{inputs_embeds:Ef([t,e],1),attention_mask:Ef([Ff(t.dims.slice(0,2)),r],1)}}async _prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:n,attention_mask:r}){if(!e&&!t)throw Error("Either `input_ids` or `pixel_values` should be provided.");let i,a;return e&&(i=await this.encode_text({input_ids:e})),t&&(a=await this.encode_image({pixel_values:t})),i&&a?{inputs_embeds:n,attention_mask:r}=this._merge_input_ids_with_image_features({inputs_embeds:i,image_features:a,input_ids:e,attention_mask:r}):n=i||a,{inputs_embeds:n,attention_mask:r}}async forward({input_ids:e,pixel_values:t,attention_mask:n,decoder_input_ids:r,decoder_attention_mask:i,encoder_outputs:a,past_key_values:o,inputs_embeds:s,decoder_inputs_embeds:c,num_logits_to_keep:l=null}){if(s||({inputs_embeds:s,attention_mask:n}=await this._prepare_inputs_embeds({input_ids:e,pixel_values:t,inputs_embeds:s,attention_mask:n})),!a){let{last_hidden_state:e}=await Kv(this,{inputs_embeds:s,attention_mask:n});a=e}if(!c){if(!r)throw Error("Either `decoder_input_ids` or `decoder_inputs_embeds` should be provided.");c=await this.encode_text({input_ids:r})}let u={inputs_embeds:c,attention_mask:i,encoder_attention_mask:n,encoder_hidden_states:a,past_key_values:o,num_logits_to_keep:l};return await $v(this,u,!0)}},WS=class extends ${},GS=class extends WS{},KS=class extends WS{},qS=class extends ${},JS=class extends qS{},YS=class extends qS{},XS=class extends ${forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`position_ids`,`past_key_values`]},ZS=class extends XS{_merge_input_ids_with_image_features(e){let t=e.image_features.dims.at(-1),n=e.image_features.view(-1,t);return ly({image_token_id:this.config.image_token_index??this.config.image_token_id,...e,image_features:n})}},QS=class extends ZS{},$S=class extends ZS{},eC=class extends ${},tC=class extends eC{},nC=class extends ZS{},rC=class extends nC{},iC=class extends ${forward_params=[`input_ids`,`attention_mask`,`inputs_embeds`,`per_layer_inputs`,`position_ids`,`pixel_values`,`input_features`,`input_features_mask`,`past_key_values`]},aC=class extends iC{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:n=null,input_features:r=null,input_features_mask:i=null,position_ids:a=null,inputs_embeds:o=null,per_layer_inputs:s=null,past_key_values:c=null,generation_config:l=null,logits_processor:u=null,num_logits_to_keep:d=null,...f}){if((!o||!s)&&({inputs_embeds:o,per_layer_inputs:s}=await J_(this.sessions.embed_tokens,{input_ids:e}),e.dims[1]!==1)){if(n){let{image_features:r}=await this._encode_vision({pixel_values:n,...f});({inputs_embeds:o,attention_mask:t}=this._merge_input_ids_with_image_features({image_features:r,inputs_embeds:o,input_ids:e,attention_mask:t}))}if(r){let{audio_features:n}=await J_(this.sessions.audio_encoder,{input_features:r,input_features_mask:i});({inputs_embeds:o,attention_mask:t}=this._merge_input_ids_with_audio_features({audio_features:n,inputs_embeds:o,input_ids:e,attention_mask:t}))}}return await $v(this,{inputs_embeds:o,per_layer_inputs:s,past_key_values:c,attention_mask:t,position_ids:a,generation_config:l,logits_processor:u,num_logits_to_keep:d},!0)}_encode_vision(e){return J_(this.sessions.vision_encoder,{pixel_values:e.pixel_values})}_merge_input_ids_with_image_features(e){let t=e.image_features.dims.at(-1),n=e.image_features.view(-1,t);return ly({image_token_id:this.config.image_token_id,...e,image_features:n})}_merge_input_ids_with_audio_features(e){let t=e.audio_features.dims.at(-1),n=e.audio_features.view(-1,t);return uy({audio_token_id:this.config.audio_token_id,...e,audio_features:n})}},oC=class extends aC{},sC=class extends aC{forward_params=[`input_ids`,`attention_mask`,`inputs_embeds`,`per_layer_inputs`,`position_ids`,`pixel_values`,`image_position_ids`,`input_features`,`input_features_mask`,`past_key_values`];_encode_vision(e){return J_(this.sessions.vision_encoder,{pixel_values:e.pixel_values,pixel_position_ids:e.image_position_ids})}},cC=class extends sC{},lC=class extends ${},uC=class extends lC{},dC=class extends lC{},fC=class extends ${},pC=class extends fC{},mC=class extends fC{},hC=class extends ${forward_params=[`input_ids`,`attention_mask`,`position_ids`,`past_key_values`,`pixel_values`,`image_grid_thw`]},gC=class extends hC{image_grid_thw_name=`grid_thw`;_get_text_only_rope_index(e,t){if(t){let{data:e,dims:n}=ry(t),r=BigInt64Array.from({length:3*e.length},(t,n)=>e[n%e.length]),i=Array.from({length:n[0]},(t,r)=>Cd(e.subarray(n[1]*r,n[1]*(r+1)))[0]+1n+BigInt(n[1]));return[new J(`int64`,r,[3,...n]),new J(`int64`,i,[i.length,1])]}{let[t,n]=e.dims;return[new J(`int64`,BigInt64Array.from({length:3*t*n},(e,r)=>BigInt(Math.floor(r%n/t))),[3,...e.dims]),Lf([t,1])]}}_reorder_and_write_positions(e,t,n,r){let i=e.reduce((e,t)=>e+t.length,0),a=Array(i),o=0;for(let t=0;t<3;++t)for(let n of e){let e=n.length/3;for(let r=t*e;r<(t+1)*e;++r)a[o++]=n[r]}let s=0;for(let e=0;e(t==s&&e.push(n),e),[]).map(e=>c[e+1]),u=l.filter(e=>e==a).length,d=l.filter(e=>e==o).length,f=[],p=0,m=u,h=d;for(let e=0;et>p&&e==a),s=c.findIndex((e,t)=>t>p&&e==o),l=m>0&&e!==-1?e:c.length+1,u=h>0&&s!==-1?s:c.length+1,d,g,_,v;l0?Cd(f.at(-1))[0]+1:0;f.push(Array.from({length:3*S},(e,t)=>C+t%S));let ee=S+C,w=y*b*x,T=Array.from({length:w},(e,t)=>ee+Math.floor(t/(b*x))),E=Array.from({length:w},(e,t)=>ee+Math.floor(t/x)%b),te=Array.from({length:w},(e,t)=>ee+t%x);f.push([T,E,te].flat()),p=d+w}if(p0?Cd(f.at(-1))[0]+1:0,t=c.length-p;f.push(Array.from({length:3*t},(n,r)=>e+r%t))}return f}get_rope_index(e,t,n,r){let{vision_config:i}=this.config,a=i.spatial_merge_size??2;if(t||n){let i=e.tolist();r||=If(e);let o=r.tolist(),s=Array.from({length:3},()=>Array.from({length:e.dims[0]},()=>Array.from({length:e.dims[1]},()=>0))),c=t?t.tolist():[],l=n?n.tolist():[],u={image_index:0,video_index:0},d=[];for(let e=0;eo[e][n]==1),n=this._get_multimodal_rope_positions({filtered_ids:t,image_grid_thw_list:c,video_grid_thw_list:l,spatial_merge_size:a,state:u}),r=this._reorder_and_write_positions(n,o[e],s,e);d.push(Cd(r)[0]+1-i[e].length)}return[new J(`int64`,s.flat(1/0),[3,e.dims[0],e.dims[1]]),new J(`int64`,d,[d.length,1])]}return this._get_text_only_rope_index(e,r)}async encode_image({pixel_values:e,image_grid_thw:t}){return(await J_(this.sessions.vision_encoder,{pixel_values:e,[this.image_grid_thw_name]:t})).image_features}_merge_input_ids_with_image_features(e){return ly({image_token_id:this.config.image_token_id,...e})}prepare_inputs_for_generation(e,t,n){if(Qv(this,t,1n),!t.attention_mask||t.position_ids||!(this.sessions.decoder_model_merged??this.sessions.model).inputNames.includes(`position_ids`))return t;if(!t.past_key_values)[t.position_ids,t.rope_deltas]=this.get_rope_index(t.input_ids,t.image_grid_thw,t.video_grid_thw,t.attention_mask);else{t.pixel_values=null;let e=t.past_key_values.get_seq_length();if(en+e);t.position_ids=Df([r,r,r],0)}}return t}},_C=class extends gC{},vC=class extends gC{image_grid_thw_name=`image_grid_thw`},yC=class extends _C{image_grid_thw_name=`image_grid_thw`},bC=class extends vC{get_vision_position_ids(e,t,n,r){let i=Math.floor(t[0]/n),a=Math.floor(t[1]/r),o=Math.floor(t[2]/r),s=a*o*i,c=Array.from({length:s},()=>e),l=Array.from({length:s},(t,n)=>e+Math.floor(n/(o*i))),u=Array.from({length:s},(t,n)=>e+n%o);return[...c,...l,...u]}_get_multimodal_rope_positions({filtered_ids:e,image_grid_thw_list:t,video_grid_thw_list:n,spatial_merge_size:r,state:i}){let{image_token_id:a}=this.config,o=[],s=0,c=+(e[0]==a);for(let t=1;t<=e.length;++t){let n=tl+n%e)),l+=e}else{let e=t[i.image_index++].map(Number),n=e[0];u.push(this.get_vision_position_ids(l,e,n,r)),l+=Math.max(e[1],e[2])/r}return u}},xC=class extends ${},SC=class extends xC{},CC=class extends xC{},wC=class extends ${},TC=class extends wC{},EC=class extends wC{},DC=class extends ${},OC=class extends DC{},kC=class extends DC{},AC=class extends ${},jC=class extends AC{},MC=class extends AC{},NC=class extends ${},PC=class extends NC{},FC=class extends NC{},IC=class extends ${},LC=class extends IC{},RC=class extends IC{},zC=class extends ${},BC=class extends zC{},VC=class extends zC{},HC=class extends ${},UC=class extends HC{},WC=class extends HC{},GC=class extends ${},KC=class extends GC{},qC=class extends GC{},JC=class extends ${forward_params=[`input_ids`,`attention_mask`,`position_ids`,`audio_values`,`past_key_values`]},YC=class extends JC{_merge_input_ids_with_audio_features(e){let t=e.audio_features.dims.at(-1),n=e.audio_features.view(-1,t);return uy({audio_token_id:this.config.ignore_index??this.config.audio_token_id??this.config.audio_token_index,...e,audio_features:n})}},XC=class extends YC{forward_params=[`input_ids`,`attention_mask`,`input_features`,`past_key_values`]},ZC=class extends ${},QC=class extends ZC{},$C=class extends ${},ew=class extends $C{},tw=class extends ${},nw=class extends tw{},rw=class extends tw{},iw=class extends ${},aw=class extends iw{},ow=class extends iw{async _call(e){return new Z(await super._call(e))}},sw=class extends ${},cw=class extends sw{},lw=class extends sw{forward_params=[`input_ids`,`attention_mask`,`token_type_ids`,`past_key_values`];prepare_inputs_for_generation(e,t,n){let r=ay(this,e,t,n);return r.token_type_ids=(r.past_key_values?Rf:If)(r.input_ids),r}},uw=class extends ${},dw=class extends uw{},fw=class extends uw{async _call(e){return new tv(await super._call(e))}},pw=class extends uw{async _call(e){return new Z(await super._call(e))}},mw=class extends uw{async _call(e){return new Q_(await super._call(e))}},hw=class extends ${},gw=class extends uw{},_w=class extends uw{async _call(e){return new tv(await super._call(e))}},vw=class extends uw{async _call(e){return new Z(await super._call(e))}},yw=class extends ${},bw=class extends yw{},xw=class extends yw{},Sw=class extends ZS{forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`pixel_attention_mask`,`position_ids`,`past_key_values`]},Cw=class extends ${},ww=class extends Cw{},Tw=class extends Cw{async _call(e){return new Z(await super._call(e))}},Ew=class extends ${},Dw=class extends Ew{},Ow=class extends Ew{},kw=class extends ${},Aw=class extends kw{async forward(e){let t=!e.input_ids,n=!e.pixel_values;if(t&&n)throw Error("Either `input_ids` or `pixel_values` should be provided.");if(t&&(e.input_ids=Ff([e.pixel_values.dims[0],1])),n){let{image_size:t}=this.config.vision_config;e.pixel_values=Nf([0,3,t,t],0)}let{text_embeddings:r,image_embeddings:i,l2norm_text_embeddings:a,l2norm_image_embeddings:o}=await super.forward(e),s={};return t||(s.text_embeddings=r,s.l2norm_text_embeddings=a),n||(s.image_embeddings=i,s.l2norm_image_embeddings=o),s}},jw=class extends kw{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},Mw=class extends kw{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},Nw=class extends ${},Pw=class extends Nw{},Fw=class extends Nw{},Iw=class extends ZS{},Lw=class extends ${},Rw=class extends Lw{},zw=class extends Lw{},Bw=class extends ZS{forward_params=[`input_ids`,`attention_mask`,`pixel_values`,`pixel_attention_mask`,`spatial_shapes`,`position_ids`,`past_key_values`]},Vw=class extends ${},Hw=class extends Vw{},Uw=class extends Vw{},Ww=class extends ${},Gw=class extends Ww{},Kw=class extends ${},qw=class extends Kw{},Jw=class extends Kw{},Yw=class extends ${},Xw=class extends Yw{},Zw=class extends Yw{},Qw=class extends ${},$w=class extends Qw{},eT=class extends Qw{},tT=class extends ${},nT=class extends tT{},rT=class extends tT{},iT=class extends ${},aT=class extends iT{},oT=class extends iT{},sT=class extends iT{async _call(e){return new Z(await super._call(e))}},cT=class extends iT{},lT=class extends ${},uT=class extends lT{},dT=class extends ${},fT=class extends dT{},pT=class extends X_{constructor({char_logits:e,bpe_logits:t,wp_logits:n}){super(),this.char_logits=e,this.bpe_logits=t,this.wp_logits=n}get logits(){return[this.char_logits,this.bpe_logits,this.wp_logits]}},mT=class extends ${},hT=class extends mT{async _call(e){return new pT(await super._call(e))}},gT=class extends X_{constructor({audio_codes:e}){super(),this.audio_codes=e}},_T=class extends X_{constructor({audio_values:e}){super(),this.audio_values=e}},vT=class extends ${main_input_name=`input_values`;forward_params=[`input_values`]},yT=class extends vT{async encode(e){return new gT(await J_(this.sessions.encoder_model,e))}async decode(e){return new _T(await J_(this.sessions.decoder_model,e))}},bT=class extends vT{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},xT=class extends vT{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},ST=class extends ${},CT=class extends ST{},wT=class extends ST{},TT=class extends ${},ET=class extends TT{},DT=class extends TT{},OT=class extends ${},kT=class extends OT{},AT=class extends OT{},jT=class extends ZS{},MT=class extends ${},NT=class extends MT{},PT=class extends MT{},FT=class extends ${},IT=class extends FT{},LT=class extends FT{async _call(e){return new $_(await super._call(e))}},RT=class extends FT{async _call(e){return new Z(await super._call(e))}},zT=class extends FT{async _call(e){return new ev(await super._call(e))}},BT=class extends ${},VT=class extends BT{},HT=class extends BT{},UT=class extends ${},WT=class extends UT{},GT=class extends UT{async _call(e){return new Z(await super._call(e))}},KT=class extends UT{},qT=class extends ${},JT=class extends qT{},YT=class extends qT{async _call(e){return new Z(await super._call(e))}},XT=class extends qT{},ZT=class extends ${},QT=class extends ZT{},$T=class extends ZT{async _call(e){return new Z(await super._call(e))}},eE=class extends ZT{},tE=class extends ${},nE=class extends tE{},rE=class extends tE{async _call(e){return new Z(await super._call(e))}},iE=class extends tE{},aE=class extends ${},oE=class extends aE{},sE=class extends aE{async _call(e){return new Z(await super._call(e))}},cE=class extends ${},lE=class extends cE{},uE=class extends cE{async _call(e){return new Z(await super._call(e))}},dE=class extends ${},fE=class extends dE{},pE=class extends dE{async _call(e){return new $_(await super._call(e))}},mE=class extends dE{async _call(e){return new Z(await super._call(e))}},hE=class extends dE{async _call(e){return new Q_(await super._call(e))}},gE=class extends ${},_E=class extends gE{},vE=class extends gE{},yE=class extends ${requires_attention_mask=!1;main_input_name=`input_values`;forward_params=[`input_values`,`decoder_input_ids`,`past_key_values`]},bE=class extends yE{},xE=class extends yE{},SE=class extends ${},CE=class extends SE{},wE=class extends SE{async _call(e){return new $_(await super._call(e))}},TE=class extends SE{async _call(e){return new Z(await super._call(e))}},EE=class extends SE{async _call(e){return new Q_(await super._call(e))}},DE=class extends SE{async _call(e){return new ev(await super._call(e))}},OE=class extends ${},kE=class extends OE{},AE=class extends OE{},jE=class extends ${},ME=class extends jE{},NE=class extends jE{},PE=class extends ${},FE=class extends PE{forward_params=[`input_ids`,`pixel_values`,`images_seq_mask`,`images_emb_mask`,`attention_mask`,`position_ids`,`past_key_values`];constructor(...e){super(...e),this._generation_mode=`text`}async forward(e){let t=this._generation_mode??`text`,n;if(t===`text`||!e.past_key_values){let t=this.sessions.prepare_inputs_embeds;n=await J_(t,bo(e,t.inputNames))}else{let t=this.sessions.gen_img_embeds;n=await J_(t,bo({image_ids:e.input_ids},t.inputNames))}let r={...e,...n},i=await $v(this,r),a=this.sessions[t===`text`?`lm_head`:`gen_head`];if(!a)throw Error(`Unable to find "${a}" generation head`);let o=await J_(a,bo(i,a.inputNames));return{...n,...i,...o}}prepare_inputs_for_generation(e,t,n){let r=!!t.past_key_values;return Qv(this,t,1n),n.guidance_scale!==null&&n.guidance_scale>1&&(r?t.input_ids=Ef([t.input_ids,t.input_ids],0):(t.input_ids=Ef([t.input_ids,Pf(t.input_ids,BigInt(n.pad_token_id))],0),t.attention_mask=Ef([t.attention_mask,Pf(t.attention_mask,0n)],0))),(r||!t.pixel_values)&&(t.pixel_values=Nf([0,0,3,384,384],1)),r&&(t.images_seq_mask=new J(`bool`,[,].fill(!0).fill(!1,0,1),[1,1]),t.images_emb_mask=new J(`bool`,[].fill(!1),[1,1,0])),t}async generate(e){return this._generation_mode=`text`,super.generate(e)}async generate_images(e){this._generation_mode=`image`;let t=(e.inputs??e[this.main_input_name]).dims[1],n=(await super.generate(e)).slice(null,[t,null]),r=this.sessions.image_decode,{decoded_image:i}=await J_(r,{generated_tokens:n}),a=i.add_(1).mul_(255/2).clamp_(0,255).to(`uint8`),o=[];for(let e of a){let t=ih.fromTensor(e);o.push(t)}return o}},IE=class extends ${},LE=class extends IE{},RE=class extends IE{},zE=class extends ${forward_params=[`input_ids`,`attention_mask`,`encoder_outputs`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`];_apply_and_filter_by_delay_pattern_mask(e){let[t,n]=e.dims,r=this.config.decoder.num_codebooks,i=n-r,a=0;for(let t=0;t0&&o<=i&&(e.data[a++]=e.data[t])}let o=Math.floor(t/r),s=a/(o*r);return new J(e.type,e.data.slice(0,a),[o,r,s])}prepare_inputs_for_generation(e,t,n){let r=BigInt(this.config.decoder.pad_token_id),i=structuredClone(e);for(let e=0;e=t&&(i[e][t]=r);return n.guidance_scale!==null&&n.guidance_scale>1&&(i=i.concat(i)),oy(this,i,t,n)}async generate(e){let t=await super.generate(e),n=this._apply_and_filter_by_delay_pattern_mask(t).unsqueeze_(0),{audio_values:r}=await J_(this.sessions.encodec_decode,{audio_codes:n});return r}},BE=class extends ${},VE=class extends BE{},HE=class extends BE{},UE=class extends ${},WE=class extends UE{},GE=class extends UE{},KE=class extends ${},qE=class extends KE{},JE=class extends KE{async _call(e){return new $_(await super._call(e))}},YE=class extends KE{async _call(e){return new Z(await super._call(e))}},XE=class extends KE{async _call(e){return new Q_(await super._call(e))}},ZE=class extends KE{async _call(e){return new ev(await super._call(e))}},QE=class extends ${},$E=class extends QE{},eD=class extends ${},tD=class extends eD{},nD=class extends eD{},rD=class extends ${},iD=class extends rD{},aD=class extends rD{},oD=class extends ${},sD=class extends oD{},cD=class extends oD{},lD=class extends ${},uD=class extends lD{},dD=class extends lD{},fD=class extends ${},pD=class extends fD{},mD=class extends fD{async _call(e){return new Z(await super._call(e))}},hD=class extends ${},gD=class extends hD{},_D=class extends hD{},vD=class extends ${},yD=class extends vD{},bD=class extends vD{},xD=class extends ${},SD=class extends xD{},CD=class extends xD{},wD=class extends ${},TD=class extends wD{},ED=class extends wD{},DD=class extends ZS{},OD=class extends ${},kD=class extends OD{async _call(e){return new tv(await super._call(e))}},AD=class extends ${},jD=class extends AD{},MD=class extends AD{},ND=class extends ${},PD=class extends ND{},FD=class extends ND{},ID=class extends ${},LD=class extends ID{},RD=class extends ID{},zD=class extends ${},BD=class extends zD{},VD=class extends zD{},HD=class extends ${forward_params=[`input_ids`,`inputs_embeds`,`attention_mask`,`position_ids`,`pixel_values`,`image_sizes`,`past_key_values`]},UD=class extends HD{async forward({input_ids:e=null,attention_mask:t=null,pixel_values:n=null,image_sizes:r=null,position_ids:i=null,inputs_embeds:a=null,past_key_values:o=null,generation_config:s=null,logits_processor:c=null,num_logits_to_keep:l=null,...u}){if(!a){let t;if(n&&e.dims[1]!==1){if(!r)throw Error("`image_sizes` must be provided when `pixel_values` is provided.");({image_features:t}=await J_(this.sessions.vision_encoder,{pixel_values:n,image_sizes:r}))}else{let e=this.config.normalized_config.hidden_size;t=new J(`float32`,[],[0,e])}({inputs_embeds:a}=await J_(this.sessions.prepare_inputs_embeds,{input_ids:e,image_features:t}))}return await $v(this,{inputs_embeds:a,past_key_values:o,attention_mask:t,position_ids:i,generation_config:s,logits_processor:c,num_logits_to_keep:l},!1)}},WD=class extends ${},GD=class extends WD{},KD=class extends WD{async _call(e){return new Z(await super._call(e))}},qD=class extends ${},JD=class extends qD{},YD=class extends qD{async _call(e){return new Q_(await super._call(e))}},XD=class extends ${},ZD=class extends XD{},QD=class extends XD{},$D=class extends ${},eO=class extends $D{},tO=class extends $D{},nO=class extends ${},rO=class extends nO{},iO=class extends nO{},aO=class extends ${},oO=class extends aO{},sO=class extends aO{},cO=class extends ${},lO=class extends cO{},uO=class extends cO{},dO=class extends vC{},fO=class extends yC{},pO=class extends dO{},mO=class extends fO{},hO=class extends dO{},gO=class extends hO{},_O=class extends hO{},vO=class extends gO{},yO=class extends ${},bO=class extends yO{},xO=class extends yO{async _call(e){return new Z(await super._call(e))}},SO=class extends ${},CO=class extends SO{},wO=class extends SO{async _call(e){return new TO(await super._call(e))}},TO=class extends Qb{},EO=class extends ${},DO=class extends EO{},OO=class extends EO{async _call(e){return new $_(await super._call(e))}},kO=class extends EO{async _call(e){return new Z(await super._call(e))}},AO=class extends EO{async _call(e){return new Q_(await super._call(e))}},jO=class extends EO{async _call(e){return new ev(await super._call(e))}},MO=class extends ${},NO=class extends MO{},PO=class extends MO{async _call(e){return new $_(await super._call(e))}},FO=class extends MO{async _call(e){return new Z(await super._call(e))}},IO=class extends MO{async _call(e){return new Q_(await super._call(e))}},LO=class extends MO{async _call(e){return new ev(await super._call(e))}},RO=class extends ${},zO=class extends RO{},BO=class extends RO{async _call(e){return new VO(await super._call(e))}},VO=class extends Qb{},HO=class extends X_{constructor({iou_scores:e,pred_masks:t}){super(),this.iou_scores=e,this.pred_masks=t}},UO=class extends ${},WO=class extends UO{async get_image_embeddings({pixel_values:e}){return await Kv(this,{pixel_values:e})}async forward(e){e=!e.image_embeddings||!e.image_positional_embeddings?{...e,...await this.get_image_embeddings(e)}:{...e},e.input_labels??=Ff(e.input_points.dims.slice(0,-1));let t={image_embeddings:e.image_embeddings,image_positional_embeddings:e.image_positional_embeddings};return e.input_points&&(t.input_points=e.input_points),e.input_labels&&(t.input_labels=e.input_labels),e.input_boxes&&(t.input_boxes=e.input_boxes),await J_(this.sessions.prompt_encoder_mask_decoder,t)}async _call(e){return new HO(await super._call(e))}},GO=class extends X_{constructor({iou_scores:e,pred_masks:t,object_score_logits:n}){super(),this.iou_scores=e,this.pred_masks=t,this.object_score_logits=n}},KO=class extends ${},qO=class extends KO{async get_image_embeddings({pixel_values:e}){return await Kv(this,{pixel_values:e})}async forward(e){let{num_feature_levels:t}=this.config.vision_config;if(e=Array.from({length:t},(e,t)=>`image_embeddings.${t}`).some(t=>!e[t])?{...e,...await this.get_image_embeddings(e)}:{...e},e.input_points){if(e.input_boxes&&e.input_boxes.dims[1]!==1)throw Error("When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.");let t=e.input_points.dims;e.input_labels??=Ff(t.slice(0,-1)),e.input_boxes??=Nf([t[0],0,4],0)}else if(e.input_boxes){let t=e.input_boxes.dims;e.input_labels=Nf([t[0],t[1],0],-1n),e.input_points=Nf([t[0],1,0,2],0)}else throw Error("At least one of `input_points` or `input_boxes` must be provided.");let n=this.sessions.prompt_encoder_mask_decoder;return await J_(n,bo(e,n.inputNames))}async _call(e){return new GO(await super._call(e))}},JO=class extends qO{},YO=class extends qO{},XO=class extends ${},ZO=class extends XO{},QO=class extends XO{},$O=class extends XO{},ek=class extends ${},tk=class extends ek{},nk=class extends ek{},rk=class extends ek{},ik=class extends ${},ak=class extends ik{},ok=class extends ik{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`text_model`})}},sk=class extends gb{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`vision_model`})}},ck=class extends ${},lk=class extends ck{},uk=class extends ck{},dk=class extends Sw{},fk=class extends ${main_input_name=`input_values`;forward_params=[`input_values`]},pk=class extends fk{async encode(e){return await J_(this.sessions.encoder_model,e)}async decode(e){return await J_(this.sessions.decoder_model,e)}},mk=class extends fk{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`encoder_model`})}},hk=class extends fk{static async from_pretrained(e,t={}){return super.from_pretrained(e,{...t,model_file_name:t.model_file_name??`decoder_model`})}},gk=class extends ${},_k=class extends gk{},vk=class extends gk{},yk=class extends ${},bk=class extends yk{},xk=class extends yk{},Sk=class extends yk{async generate_speech(e,t,{threshold:n=.5,minlenratio:r=0,maxlenratio:i=20,vocoder:a=null}={}){let o={input_ids:e},{encoder_outputs:s,encoder_attention_mask:c}=await Kv(this,o),l=s.dims[1]/this.config.reduction_factor,u=Math.floor(l*i),d=Math.floor(l*r),f=this.config.num_mel_bins,p=[],m=null,h=null,g=0;for(;;){++g;let e=zv(!!h),r;r=h?h.output_sequence_out:new J(`float32`,new Float32Array(f),[1,1,f]);let i={use_cache_branch:e,output_sequence:r,encoder_attention_mask:c,speaker_embeddings:t,encoder_hidden_states:s};Zv(this,i,m),h=await J_(this.sessions.decoder_model_merged,i),m=Jv(h,m);let{prob:a,spectrum:o}=h;if(p.push(o),g>=d&&(Array.from(a.data).filter(e=>e>=n).length>0||g>=u))break}let _=Ef(p),{waveform:v}=await J_(a.sessions.model,{spectrogram:_});return{spectrogram:_,waveform:v}}},Ck=class extends ${main_input_name=`spectrogram`},wk=class extends ${},Tk=class extends wk{},Ek=class extends wk{async _call(e){return new $_(await super._call(e))}},Dk=class extends wk{async _call(e){return new Z(await super._call(e))}},Ok=class extends wk{async _call(e){return new ev(await super._call(e))}},kk=class extends ${},Ak=class extends kk{},jk=class extends kk{},Mk=class extends ${},Nk=class extends Mk{},Pk=class extends Mk{},Fk=class extends ${},Ik=class extends Fk{},Lk=class extends ${},Rk=class extends Lk{async generate_speech({input_ids:e,attention_mask:t,style:n,num_inference_steps:r=5,speed:i=1.05}){let{sampling_rate:a,chunk_compress_factor:o,base_chunk_size:s,latent_dim:c}=this.config,{last_hidden_state:l,durations:u}=await J_(this.sessions.text_encoder,{input_ids:e,attention_mask:t,style:n}),d=u.div(i).mul_(a),f=s*o,p=d.data,m=Int32Array.from(p,e=>Math.ceil(e/f)),h=Math.max(...m),g=e.dims[0],_=new BigInt64Array(g*h);for(let e=0;ee*t,1),r=pf[e.type];c[e.name]=new J(e.type,new r(n),t)}let f=pf[d],p=new J(d,new f(s*AA),[1,s,AA]),m=t[Symbol.asyncIterator]?.()??t[Symbol.iterator]?.();if(!m)throw Error(`input_features must be iterable or async iterable`);return{encoder_session:i,enc_kv_cache:c,enc_padding_cache:p,enc_past_seq_len:0,audio_embed_queue:[],audio_embed_total_tokens:0,audio_queue_offset:0,audio_consumed:0,stream_exhausted:!1,chunks_iter:m,text_hidden_size:n.hidden_size}}async function PA(e,t){let n=t.dims[2],r=Math.floor((jA+n-3)/2)+1,i=new J(`int64`,BigInt64Array.from({length:r},(t,n)=>BigInt(e.enc_past_seq_len+n)),[1,r]),a=e.enc_past_seq_len+r,o=Ff([1,a]),{audio_embeds:s,present_padding_cache:c,...l}=await J_(e.encoder_session,{input_features:t,attention_mask:o,position_ids:i,past_padding_cache:e.enc_padding_cache,...e.enc_kv_cache});e.enc_padding_cache.location===`gpu-buffer`&&e.enc_padding_cache.dispose(),e.enc_padding_cache=c;for(let t in l)if(t.startsWith(`present.`)){let n=t.replace(`present`,`past_key_values`),r=e.enc_kv_cache[n];r?.location===`gpu-buffer`&&r.dispose(),e.enc_kv_cache[n]=l[t]}return e.enc_past_seq_len=a,s}async function FA(e,t){for(;e.audio_embed_total_tokens0&&e.audio_embed_queue.length>0;){let t=e.audio_embed_queue[0],n=t.tokens-e.audio_queue_offset,o=Math.min(a,n),s=e.audio_queue_offset*e.text_hidden_size;for(let n=0;n=t.tokens&&(e.audio_embed_queue.shift(),e.audio_queue_offset=0)}e.audio_consumed+=n-a}var LA=class extends xv{constructor(e){super(),this._s=e}_call(e){let t=this._s.stream_exhausted&&this._s.audio_embed_queue.length===0;return e.map(()=>t)}},RA=class extends ${forward_params=[`input_ids`,`attention_mask`,`position_ids`,`past_key_values`]},zA=class extends RA{async forward({input_ids:e,past_key_values:t,...n}){let r=e.dims[1],i=MA.get(this);i&&await FA(i,i.audio_consumed+r);let{inputs_embeds:a}=await J_(this.sessions.embed_tokens,{input_ids:e});i&&IA(i,a,r);let o={inputs_embeds:a,...n};Zv(this,o,t);let s=this.sessions.decoder_model_merged;return await J_(s,bo(o,s.inputNames))}async generate({input_features:e,stopping_criteria:t,...n}){if(!e)throw Error(`input_features (generator/iterable) must be provided`);let r=NA(this,e);MA.set(this,r);let i=new Sv;i.push(new LA(r)),t&&i.extend(t);try{return await super.generate({...n,stopping_criteria:i})}finally{r.enc_kv_cache.dispose(),MA.delete(this)}}},BA=class extends ${},VA=class extends BA{},HA=class extends BA{async _call(e){return new tv(await super._call(e))}},UA=class extends BA{async _call(e){return new Z(await super._call(e))}},WA=class extends X_{constructor({logits:e,embeddings:t}){super(),this.logits=e,this.embeddings=t}},GA=class extends ${},KA=class extends GA{},qA=class extends GA{async _call(e){return new tv(await super._call(e))}},JA=class extends GA{async _call(e){return new Z(await super._call(e))}},YA=class extends GA{async _call(e){return new WA(await super._call(e))}},XA=class extends GA{async _call(e){return new Q_(await super._call(e))}},ZA=class extends ${},QA=class extends ZA{},$A=class extends bv{return_timestamps=null;return_token_timestamps=null;num_frames=null;alignment_heads=null;task=null;language=null;no_timestamps_token_id=null;prompt_ids=null;is_multilingual=null;lang_to_id=null;task_to_id=null;max_initial_timestamp_index=1},ej=class extends ${requires_attention_mask=!1;main_input_name=`input_features`;forward_params=[`input_features`,`attention_mask`,`decoder_input_ids`,`decoder_attention_mask`,`past_key_values`]},tj=class extends ej{},nj=class extends ej{_prepare_generation_config(e,t){return super._prepare_generation_config(e,t,$A)}_retrieve_init_tokens(e){let t=[e.decoder_start_token_id],n=e.language,r=e.task;if(e.is_multilingual){n||=(B.warn(`No language specified - defaulting to English (en).`),`en`);let i=`<|${Up(n)}|>`;t.push(e.lang_to_id[i]),t.push(e.task_to_id[r??`transcribe`])}else if(n||r)throw Error("Cannot specify `task` or `language` for an English-only model. If the model is intended to be multilingual, pass `is_multilingual=true` to generate, or update the generation config.");return!e.return_timestamps&&e.no_timestamps_token_id&&t.at(-1)!==e.no_timestamps_token_id?t.push(e.no_timestamps_token_id):e.return_timestamps&&t.at(-1)===e.no_timestamps_token_id&&(B.warn("<|notimestamps|> prompt token is removed from generation_config since `return_timestamps` is set to `true`."),t.pop()),t.filter(e=>e!=null)}async generate({inputs:e=null,generation_config:t=null,logits_processor:n=null,stopping_criteria:r=null,...i}){t=this._prepare_generation_config(t,i);let a=i.decoder_input_ids instanceof J?Uf(i.decoder_input_ids):i.decoder_input_ids??this._retrieve_init_tokens(t);if(t.return_timestamps&&(n??=new sv,n.push(new fv(t,a))),t.begin_suppress_tokens&&(n??=new sv,n.push(new dv(t.begin_suppress_tokens,a.length))),t.return_token_timestamps){if(!t.alignment_heads)throw Error("Model generation config has no `alignment_heads`, token-level timestamps not available. See https://gist.github.com/hollance/42e32852f24243b748ae6bc1f985b13a on how to add this property to the generation config.");t.task===`translate`&&B.warn(`Token-level timestamps may not be reliable for task 'translate'.`),t.output_attentions=!0,t.return_dict_in_generate=!0}if(t.return_timestamps&&!i.max_new_tokens)return this._generate_with_seek({inputs:e,generation_config:t,logits_processor:n,init_tokens:a,kwargs:i});let o=await super.generate({inputs:e,generation_config:t,logits_processor:n,decoder_input_ids:a,...i});return t.return_token_timestamps&&(o.token_timestamps=this._extract_token_timestamps(o,t.alignment_heads,t.num_frames,.02,a.length)),o}async _generate_with_seek({inputs:e,generation_config:t,logits_processor:n,init_tokens:r,kwargs:i}){let a=t.no_timestamps_token_id+1,o=Array.isArray(t.eos_token_id)?t.eos_token_id[0]:t.eos_token_id,s=t.return_token_timestamps,c=e,l=c.dims[2],u=2*this.config.max_source_positions,d=0,f=[],p=[];for(;de+n)}if(v.length>0&&v.at(-1)===o&&v.pop(),v.length===0)break;let b=v.map(e=>e>=a),x=v.length>=2&&b[v.length-1]&&!b[v.length-2],S=[];for(let e=0;e0){if(x)C=e-d;else{let e=S.at(-1);C=(v[e-1]-a)*2,ee=e}}else C=e-d;let w=Math.floor(d/2),T=a+1500;for(let e=0;e=a&&(v[e]=Math.min(v[e]+w,T));f.push(...v.slice(0,ee)),y&&p.push(...y.slice(0,ee)),d+=C}f.push(o);let m=[...r,...f];if(s){let e=new J(`int64`,m.map(BigInt),[1,m.length]),t=[...Array(r.length).fill(0),...p,0];return{sequences:e,token_timestamps:new J(`float32`,new Float32Array(t),[1,t.length])}}return new J(`int64`,m.map(BigInt),[1,m.length])}_extract_token_timestamps(e,t,n=null,r=.02,i=0){if(!e.cross_attentions)throw Error("Model outputs must contain cross attentions to extract timestamps. This is most likely because the model was not exported with `output_attentions=True`.");n??B.warn("`num_frames` has not been set, meaning the entire audio will be analyzed. This may lead to inaccurate token-level timestamps for short audios (< 30 seconds).");let a=this.config.median_filter_width;a===void 0&&(B.warn("Model config has no `median_filter_width`, using default value of 7."),a=7);let o=e.cross_attentions,s=Array.from({length:this.config.decoder_layers},(e,t)=>Ef(o.map(e=>e[t]),2)),c=Df(t.map(([e,t])=>{if(e>=s.length)throw Error(`Layer index ${e} is out of bounds for cross attentions (length ${s.length}).`);return n?s[e].slice(null,t,null,[0,n]):s[e].slice(null,t)})).permute(1,0,2,3),[l,u]=kf(c,-2,0,!0),d=c.clone();for(let e=0;e0?d.slice(null,null,[i,d.dims[2]],null):d,1)],p=e.sequences.dims,m=new J(`float32`,new Float32Array(p[0]*p[1]),p);for(let e=0;et[n+1]-t[n])).map(e=>!!e),o=[];for(let e=0;e0&&s.push(o.at(-1)),m[e].data.set(s)}return m}},rj=class extends nj{},ij=class extends ${},aj=class extends ij{},oj=class extends ij{async _call(e){return new $_(await super._call(e))}},sj=class extends ij{async _call(e){return new Z(await super._call(e))}},cj=class extends ij{async _call(e){return new Q_(await super._call(e))}},lj=class extends ij{async _call(e){return new ev(await super._call(e))}},uj=class extends ${},dj=class extends uj{},fj=class extends uj{async _call(e){return new $_(await super._call(e))}},pj=class extends uj{async _call(e){return new Z(await super._call(e))}},mj=class extends uj{async _call(e){return new Q_(await super._call(e))}},hj=class extends uj{async _call(e){return new ev(await super._call(e))}},gj=class extends ${},_j=class extends gj{},vj=class extends gj{async _call(e){return new yj(await super._call(e))}},yj=class extends X_{constructor({logits:e,pred_boxes:t}){super(),this.logits=e,this.pred_boxes=t}},bj=class extends ${},xj=class extends bj{},Sj=class extends bj{},Cj=class extends ${},wj=class extends Cj{},Tj=class extends Cj{},Ej=new Map([[`bert`,`BertModel`],[`eurobert`,`EuroBertModel`],[`neobert`,`NeoBertModel`],[`modernbert`,`ModernBertModel`],[`nomic_bert`,`NomicBertModel`],[`roformer`,`RoFormerModel`],[`electra`,`ElectraModel`],[`esm`,`EsmModel`],[`convbert`,`ConvBertModel`],[`camembert`,`CamembertModel`],[`deberta`,`DebertaModel`],[`deberta-v2`,`DebertaV2Model`],[`mpnet`,`MPNetModel`],[`albert`,`AlbertModel`],[`distilbert`,`DistilBertModel`],[`roberta`,`RobertaModel`],[`xlm`,`XLMModel`],[`xlm-roberta`,`XLMRobertaModel`],[`clap`,`ClapModel`],[`clip`,`CLIPModel`],[`clipseg`,`CLIPSegModel`],[`chinese_clip`,`ChineseCLIPModel`],[`siglip`,`SiglipModel`],[`jina_clip`,`JinaCLIPModel`],[`mobilebert`,`MobileBertModel`],[`squeezebert`,`SqueezeBertModel`],[`wav2vec2`,`Wav2Vec2Model`],[`wav2vec2-bert`,`Wav2Vec2BertModel`],[`unispeech`,`UniSpeechModel`],[`unispeech-sat`,`UniSpeechSatModel`],[`hubert`,`HubertModel`],[`wavlm`,`WavLMModel`],[`audio-spectrogram-transformer`,`ASTModel`],[`vits`,`VitsModel`],[`pyannote`,`PyAnnoteModel`],[`wespeaker-resnet`,`WeSpeakerResNetModel`],[`detr`,`DetrModel`],[`rt_detr`,`RTDetrModel`],[`rt_detr_v2`,`RTDetrV2Model`],[`rf_detr`,`RFDetrModel`],[`d_fine`,`DFineModel`],[`table-transformer`,`TableTransformerModel`],[`vit`,`ViTModel`],[`ijepa`,`IJepaModel`],[`pvt`,`PvtModel`],[`vit_msn`,`ViTMSNModel`],[`vit_mae`,`ViTMAEModel`],[`groupvit`,`GroupViTModel`],[`fastvit`,`FastViTModel`],[`mobilevit`,`MobileViTModel`],[`mobilevitv2`,`MobileViTV2Model`],[`owlvit`,`OwlViTModel`],[`owlv2`,`Owlv2Model`],[`beit`,`BeitModel`],[`deit`,`DeiTModel`],[`hiera`,`HieraModel`],[`convnext`,`ConvNextModel`],[`convnextv2`,`ConvNextV2Model`],[`dinov2`,`Dinov2Model`],[`dinov2_with_registers`,`Dinov2WithRegistersModel`],[`dinov3_vit`,`DINOv3ViTModel`],[`dinov3_convnext`,`DINOv3ConvNextModel`],[`resnet`,`ResNetModel`],[`swin`,`SwinModel`],[`swin2sr`,`Swin2SRModel`],[`donut-swin`,`DonutSwinModel`],[`yolos`,`YolosModel`],[`dpt`,`DPTModel`],[`glpn`,`GLPNModel`],[`hifigan`,`SpeechT5HifiGan`],[`efficientnet`,`EfficientNetModel`],[`decision_transformer`,`DecisionTransformerModel`],[`patchtst`,`PatchTSTModel`],[`patchtsmixer`,`PatchTSMixerModel`],[`mobilenet_v1`,`MobileNetV1Model`],[`mobilenet_v2`,`MobileNetV2Model`],[`mobilenet_v3`,`MobileNetV3Model`],[`mobilenet_v4`,`MobileNetV4Model`],[`maskformer`,`MaskFormerModel`],[`mgp-str`,`MgpstrForSceneTextRecognition`],[`style_text_to_speech_2`,`StyleTextToSpeech2Model`],[`openai_privacy_filter`,`OpenAIPrivacyFilterModel`]]),Dj=new Map([[`t5`,`T5Model`],[`longt5`,`LongT5Model`],[`mt5`,`MT5Model`],[`bart`,`BartModel`],[`mbart`,`MBartModel`],[`marian`,`MarianModel`],[`whisper`,`WhisperModel`],[`cohere_asr`,`CohereAsrModel`],[`m2m_100`,`M2M100Model`],[`blenderbot`,`BlenderbotModel`],[`blenderbot-small`,`BlenderbotSmallModel`]]),Oj=new Map([[`mimi`,`MimiModel`],[`dac`,`DacModel`],[`snac`,`SnacModel`]]),kj=new Map([[`bloom`,`BloomModel`],[`jais`,`JAISModel`],[`gpt2`,`GPT2Model`],[`gpt_oss`,`GptOssModel`],[`gptj`,`GPTJModel`],[`gpt_bigcode`,`GPTBigCodeModel`],[`gpt_neo`,`GPTNeoModel`],[`gpt_neox`,`GPTNeoXModel`],[`codegen`,`CodeGenModel`],[`llama`,`LlamaModel`],[`apertus`,`ApertusModel`],[`nanochat`,`NanoChatModel`],[`arcee`,`ArceeModel`],[`afmoe`,`AfmoeModel`],[`lfm2`,`Lfm2Model`],[`lfm2_moe`,`Lfm2MoeModel`],[`smollm3`,`SmolLM3Model`],[`exaone`,`ExaoneModel`],[`olmo`,`OlmoModel`],[`olmo2`,`Olmo2Model`],[`olmo3`,`Olmo3Model`],[`olmo_hybrid`,`OlmoHybridModel`],[`mobilellm`,`MobileLLMModel`],[`granite`,`GraniteModel`],[`granitemoehybrid`,`GraniteMoeHybridModel`],[`cohere`,`CohereModel`],[`cohere2`,`Cohere2Model`],[`gemma`,`GemmaModel`],[`gemma2`,`Gemma2Model`],[`vaultgemma`,`VaultGemmaModel`],[`gemma3_text`,`Gemma3Model`],[`helium`,`HeliumModel`],[`glm`,`GlmModel`],[`glm_moe_dsa`,`GlmMoeDsaModel`],[`openelm`,`OpenELMModel`],[`qwen2`,`Qwen2Model`],[`qwen2_moe`,`Qwen2MoeModel`],[`qwen3`,`Qwen3Model`],[`qwen3_moe`,`Qwen3MoeModel`],[`qwen3_next`,`Qwen3NextModel`],[`phi`,`PhiModel`],[`phi3`,`Phi3Model`],[`mpt`,`MptModel`],[`opt`,`OPTModel`],[`mistral`,`MistralModel`],[`mistral4`,`Mistral4Model`],[`ministral`,`MinistralModel`],[`ministral3`,`Ministral3Model`],[`ernie4_5`,`Ernie4_5ForCausalLM`],[`starcoder2`,`Starcoder2Model`],[`deepseek_v3`,`DeepseekV3Model`],[`deepseek_v4`,`DeepseekV4Model`],[`falcon`,`FalconModel`],[`falcon_h1`,`FalconH1Model`],[`nemotron_h`,`NemotronHModel`],[`solar_open`,`SolarOpenModel`],[`stablelm`,`StableLmModel`],[`modernbert-decoder`,`ModernBertDecoderModel`],[`hunyuan_v1_dense`,`HunYuanDenseV1Model`],[`youtu`,`YoutuModel`],[`zaya`,`ZayaModel`],[`hrm_text`,`HrmTextModel`]]),Aj=new Map([[`speecht5`,`SpeechT5ForSpeechToText`],[`whisper`,`WhisperForConditionalGeneration`],[`lite-whisper`,`LiteWhisperForConditionalGeneration`],[`moonshine`,`MoonshineForConditionalGeneration`],[`cohere_asr`,`CohereAsrForConditionalGeneration`]]),jj=new Map([[`speecht5`,`SpeechT5ForTextToSpeech`]]),Mj=new Map([[`vits`,`VitsModel`],[`musicgen`,`MusicgenForConditionalGeneration`],[`supertonic`,`SupertonicForConditionalGeneration`]]),Nj=new Map([[`bert`,`BertForSequenceClassification`],[`eurobert`,`EuroBertForSequenceClassification`],[`neobert`,`NeoBertForSequenceClassification`],[`modernbert`,`ModernBertForSequenceClassification`],[`roformer`,`RoFormerForSequenceClassification`],[`electra`,`ElectraForSequenceClassification`],[`esm`,`EsmForSequenceClassification`],[`convbert`,`ConvBertForSequenceClassification`],[`camembert`,`CamembertForSequenceClassification`],[`deberta`,`DebertaForSequenceClassification`],[`deberta-v2`,`DebertaV2ForSequenceClassification`],[`mpnet`,`MPNetForSequenceClassification`],[`albert`,`AlbertForSequenceClassification`],[`distilbert`,`DistilBertForSequenceClassification`],[`roberta`,`RobertaForSequenceClassification`],[`xlm`,`XLMForSequenceClassification`],[`xlm-roberta`,`XLMRobertaForSequenceClassification`],[`bart`,`BartForSequenceClassification`],[`mbart`,`MBartForSequenceClassification`],[`mobilebert`,`MobileBertForSequenceClassification`],[`squeezebert`,`SqueezeBertForSequenceClassification`]]),Pj=new Map([[`bert`,`BertForTokenClassification`],[`eurobert`,`EuroBertForTokenClassification`],[`neobert`,`NeoBertForTokenClassification`],[`modernbert`,`ModernBertForTokenClassification`],[`roformer`,`RoFormerForTokenClassification`],[`electra`,`ElectraForTokenClassification`],[`esm`,`EsmForTokenClassification`],[`convbert`,`ConvBertForTokenClassification`],[`camembert`,`CamembertForTokenClassification`],[`deberta`,`DebertaForTokenClassification`],[`deberta-v2`,`DebertaV2ForTokenClassification`],[`mpnet`,`MPNetForTokenClassification`],[`distilbert`,`DistilBertForTokenClassification`],[`roberta`,`RobertaForTokenClassification`],[`xlm`,`XLMForTokenClassification`],[`xlm-roberta`,`XLMRobertaForTokenClassification`],[`openai_privacy_filter`,`OpenAIPrivacyFilterForTokenClassification`]]),Fj=new Map([[`t5`,`T5ForConditionalGeneration`],[`longt5`,`LongT5ForConditionalGeneration`],[`mt5`,`MT5ForConditionalGeneration`],[`bart`,`BartForConditionalGeneration`],[`mbart`,`MBartForConditionalGeneration`],[`marian`,`MarianMTModel`],[`m2m_100`,`M2M100ForConditionalGeneration`],[`blenderbot`,`BlenderbotForConditionalGeneration`],[`blenderbot-small`,`BlenderbotSmallForConditionalGeneration`]]),Ij=new Map([[`bloom`,`BloomForCausalLM`],[`gpt2`,`GPT2LMHeadModel`],[`gpt_oss`,`GptOssForCausalLM`],[`jais`,`JAISLMHeadModel`],[`gptj`,`GPTJForCausalLM`],[`gpt_bigcode`,`GPTBigCodeForCausalLM`],[`gpt_neo`,`GPTNeoForCausalLM`],[`gpt_neox`,`GPTNeoXForCausalLM`],[`codegen`,`CodeGenForCausalLM`],[`llama`,`LlamaForCausalLM`],[`nanochat`,`NanoChatForCausalLM`],[`apertus`,`ApertusForCausalLM`],[`llama4_text`,`Llama4ForCausalLM`],[`arcee`,`ArceeForCausalLM`],[`afmoe`,`AfmoeForCausalLM`],[`lfm2`,`Lfm2ForCausalLM`],[`lfm2_moe`,`Lfm2MoeForCausalLM`],[`smollm3`,`SmolLM3ForCausalLM`],[`exaone`,`ExaoneForCausalLM`],[`olmo`,`OlmoForCausalLM`],[`olmo2`,`Olmo2ForCausalLM`],[`olmo3`,`Olmo3ForCausalLM`],[`olmo_hybrid`,`OlmoHybridForCausalLM`],[`mobilellm`,`MobileLLMForCausalLM`],[`granite`,`GraniteForCausalLM`],[`granitemoehybrid`,`GraniteMoeHybridForCausalLM`],[`cohere`,`CohereForCausalLM`],[`cohere2`,`Cohere2ForCausalLM`],[`gemma`,`GemmaForCausalLM`],[`gemma2`,`Gemma2ForCausalLM`],[`vaultgemma`,`VaultGemmaForCausalLM`],[`gemma3_text`,`Gemma3ForCausalLM`],[`gemma3`,`Gemma3ForCausalLM`],[`helium`,`HeliumForCausalLM`],[`glm`,`GlmForCausalLM`],[`glm_moe_dsa`,`GlmMoeDsaForCausalLM`],[`openelm`,`OpenELMForCausalLM`],[`qwen2`,`Qwen2ForCausalLM`],[`qwen2_moe`,`Qwen2MoeForCausalLM`],[`qwen3`,`Qwen3ForCausalLM`],[`qwen3_moe`,`Qwen3MoeForCausalLM`],[`qwen3_next`,`Qwen3NextForCausalLM`],[`qwen2_vl`,`Qwen2VLForCausalLM`],[`qwen2_5_vl`,`Qwen2_5_VLForCausalLM`],[`qwen3_vl`,`Qwen3VLForCausalLM`],[`qwen3_vl_moe`,`Qwen3VLMoeForCausalLM`],[`qwen3_5`,`Qwen3_5ForCausalLM`],[`qwen3_5_text`,`Qwen3_5ForCausalLM`],[`qwen3_5_moe`,`Qwen3_5MoeForCausalLM`],[`gemma3n`,`Gemma3nForCausalLM`],[`gemma4`,`Gemma4ForCausalLM`],[`phi`,`PhiForCausalLM`],[`phi3`,`Phi3ForCausalLM`],[`mpt`,`MptForCausalLM`],[`opt`,`OPTForCausalLM`],[`mbart`,`MBartForCausalLM`],[`mistral`,`MistralForCausalLM`],[`mistral4`,`Mistral4ForCausalLM`],[`ministral`,`MinistralForCausalLM`],[`ministral3`,`Ministral3ForCausalLM`],[`ernie4_5`,`Ernie4_5ForCausalLM`],[`starcoder2`,`Starcoder2ForCausalLM`],[`deepseek_v3`,`DeepseekV3ForCausalLM`],[`deepseek_v4`,`DeepseekV4ForCausalLM`],[`falcon`,`FalconForCausalLM`],[`falcon_h1`,`FalconH1ForCausalLM`],[`nemotron_h`,`NemotronHForCausalLM`],[`trocr`,`TrOCRForCausalLM`],[`solar_open`,`SolarOpenForCausalLM`],[`stablelm`,`StableLmForCausalLM`],[`modernbert-decoder`,`ModernBertDecoderForCausalLM`],[`hunyuan_v1_dense`,`HunYuanDenseV1ForCausalLM`],[`youtu`,`YoutuForCausalLM`],[`zaya`,`ZayaForCausalLM`],[`hrm_text`,`HrmTextForCausalLM`],[`phi3_v`,`Phi3VForCausalLM`]]),Lj=new Map([[`multi_modality`,`MultiModalityCausalLM`]]),Rj=new Map([[`bert`,`BertForMaskedLM`],[`eurobert`,`EuroBertForMaskedLM`],[`neobert`,`NeoBertForMaskedLM`],[`modernbert`,`ModernBertForMaskedLM`],[`roformer`,`RoFormerForMaskedLM`],[`electra`,`ElectraForMaskedLM`],[`esm`,`EsmForMaskedLM`],[`convbert`,`ConvBertForMaskedLM`],[`camembert`,`CamembertForMaskedLM`],[`deberta`,`DebertaForMaskedLM`],[`deberta-v2`,`DebertaV2ForMaskedLM`],[`mpnet`,`MPNetForMaskedLM`],[`albert`,`AlbertForMaskedLM`],[`distilbert`,`DistilBertForMaskedLM`],[`roberta`,`RobertaForMaskedLM`],[`xlm`,`XLMWithLMHeadModel`],[`xlm-roberta`,`XLMRobertaForMaskedLM`],[`mobilebert`,`MobileBertForMaskedLM`],[`squeezebert`,`SqueezeBertForMaskedLM`]]),zj=new Map([[`bert`,`BertForQuestionAnswering`],[`neobert`,`NeoBertForQuestionAnswering`],[`roformer`,`RoFormerForQuestionAnswering`],[`electra`,`ElectraForQuestionAnswering`],[`convbert`,`ConvBertForQuestionAnswering`],[`camembert`,`CamembertForQuestionAnswering`],[`deberta`,`DebertaForQuestionAnswering`],[`deberta-v2`,`DebertaV2ForQuestionAnswering`],[`mpnet`,`MPNetForQuestionAnswering`],[`albert`,`AlbertForQuestionAnswering`],[`distilbert`,`DistilBertForQuestionAnswering`],[`roberta`,`RobertaForQuestionAnswering`],[`xlm`,`XLMForQuestionAnswering`],[`xlm-roberta`,`XLMRobertaForQuestionAnswering`],[`mobilebert`,`MobileBertForQuestionAnswering`],[`squeezebert`,`SqueezeBertForQuestionAnswering`]]),Bj=new Map([[`vision-encoder-decoder`,`VisionEncoderDecoderModel`],[`idefics3`,`Idefics3ForConditionalGeneration`],[`smolvlm`,`SmolVLMForConditionalGeneration`]]),Vj=new Map([[`llava`,`LlavaForConditionalGeneration`],[`llava_onevision`,`LlavaOnevisionForConditionalGeneration`],[`moondream1`,`Moondream1ForConditionalGeneration`],[`florence2`,`Florence2ForConditionalGeneration`],[`qwen2_vl`,`Qwen2VLForConditionalGeneration`],[`qwen2_5_vl`,`Qwen2_5_VLForConditionalGeneration`],[`qwen3_vl`,`Qwen3VLForConditionalGeneration`],[`qwen3_vl_moe`,`Qwen3VLMoeForConditionalGeneration`],[`qwen3_5`,`Qwen3_5ForConditionalGeneration`],[`qwen3_5_moe`,`Qwen3_5MoeForConditionalGeneration`],[`lfm2_vl`,`Lfm2VlForConditionalGeneration`],[`idefics3`,`Idefics3ForConditionalGeneration`],[`smolvlm`,`SmolVLMForConditionalGeneration`],[`paligemma`,`PaliGemmaForConditionalGeneration`],[`llava_qwen2`,`LlavaQwen2ForCausalLM`],[`gemma3`,`Gemma3ForConditionalGeneration`],[`gemma3n`,`Gemma3nForConditionalGeneration`],[`gemma4`,`Gemma4ForConditionalGeneration`],[`mistral3`,`Mistral3ForConditionalGeneration`],[`lighton_ocr`,`LightOnOcrForConditionalGeneration`],[`glm_ocr`,`GlmOcrForConditionalGeneration`]]),Hj=new Map([[`granite_speech`,`GraniteSpeechForConditionalGeneration`],[`ultravox`,`UltravoxModel`],[`voxtral`,`VoxtralForConditionalGeneration`],[`voxtral_realtime`,`VoxtralRealtimeForConditionalGeneration`]]),Uj=new Map([[`vision-encoder-decoder`,`VisionEncoderDecoderModel`]]),Wj=new Map([[`vit`,`ViTForImageClassification`],[`ijepa`,`IJepaForImageClassification`],[`pvt`,`PvtForImageClassification`],[`vit_msn`,`ViTMSNForImageClassification`],[`fastvit`,`FastViTForImageClassification`],[`mobilevit`,`MobileViTForImageClassification`],[`mobilevitv2`,`MobileViTV2ForImageClassification`],[`beit`,`BeitForImageClassification`],[`deit`,`DeiTForImageClassification`],[`hiera`,`HieraForImageClassification`],[`convnext`,`ConvNextForImageClassification`],[`convnextv2`,`ConvNextV2ForImageClassification`],[`dinov2`,`Dinov2ForImageClassification`],[`dinov2_with_registers`,`Dinov2WithRegistersForImageClassification`],[`resnet`,`ResNetForImageClassification`],[`swin`,`SwinForImageClassification`],[`segformer`,`SegformerForImageClassification`],[`efficientnet`,`EfficientNetForImageClassification`],[`mobilenet_v1`,`MobileNetV1ForImageClassification`],[`mobilenet_v2`,`MobileNetV2ForImageClassification`],[`mobilenet_v3`,`MobileNetV3ForImageClassification`],[`mobilenet_v4`,`MobileNetV4ForImageClassification`]]),Gj=new Map([[`detr`,`DetrForObjectDetection`],[`rt_detr`,`RTDetrForObjectDetection`],[`rt_detr_v2`,`RTDetrV2ForObjectDetection`],[`rf_detr`,`RFDetrForObjectDetection`],[`d_fine`,`DFineForObjectDetection`],[`table-transformer`,`TableTransformerForObjectDetection`],[`yolos`,`YolosForObjectDetection`]]),Kj=new Map([[`owlvit`,`OwlViTForObjectDetection`],[`owlv2`,`Owlv2ForObjectDetection`],[`grounding-dino`,`GroundingDinoForObjectDetection`]]),qj=new Map([[`detr`,`DetrForSegmentation`],[`clipseg`,`CLIPSegForImageSegmentation`]]),Jj=new Map([[`segformer`,`SegformerForSemanticSegmentation`],[`sapiens`,`SapiensForSemanticSegmentation`],[`swin`,`SwinForSemanticSegmentation`],[`mobilenet_v1`,`MobileNetV1ForSemanticSegmentation`],[`mobilenet_v2`,`MobileNetV2ForSemanticSegmentation`],[`mobilenet_v3`,`MobileNetV3ForSemanticSegmentation`],[`mobilenet_v4`,`MobileNetV4ForSemanticSegmentation`]]),Yj=new Map([[`detr`,`DetrForSegmentation`],[`maskformer`,`MaskFormerForInstanceSegmentation`]]),Xj=new Map([[`sam`,`SamModel`],[`sam2`,`Sam2Model`],[`edgetam`,`EdgeTamModel`],[`sam3_tracker`,`Sam3TrackerModel`]]),Zj=new Map([[`wav2vec2`,`Wav2Vec2ForCTC`],[`wav2vec2-bert`,`Wav2Vec2BertForCTC`],[`unispeech`,`UniSpeechForCTC`],[`unispeech-sat`,`UniSpeechSatForCTC`],[`wavlm`,`WavLMForCTC`],[`hubert`,`HubertForCTC`],[`parakeet_ctc`,`ParakeetForCTC`]]),Qj=new Map([[`wav2vec2`,`Wav2Vec2ForSequenceClassification`],[`wav2vec2-bert`,`Wav2Vec2BertForSequenceClassification`],[`unispeech`,`UniSpeechForSequenceClassification`],[`unispeech-sat`,`UniSpeechSatForSequenceClassification`],[`wavlm`,`WavLMForSequenceClassification`],[`hubert`,`HubertForSequenceClassification`],[`audio-spectrogram-transformer`,`ASTForAudioClassification`]]),$j=new Map([[`wavlm`,`WavLMForXVector`]]),eM=new Map([[`unispeech-sat`,`UniSpeechSatForAudioFrameClassification`],[`wavlm`,`WavLMForAudioFrameClassification`],[`wav2vec2`,`Wav2Vec2ForAudioFrameClassification`],[`pyannote`,`PyAnnoteForAudioFrameClassification`]]),tM=new Map([[`vitmatte`,`VitMatteForImageMatting`]]),nM=new Map([[`patchtst`,`PatchTSTForPrediction`],[`patchtsmixer`,`PatchTSMixerForPrediction`]]),rM=new Map([[`swin2sr`,`Swin2SRForImageSuperResolution`]]),iM=new Map([[`chmv2`,`CHMv2ForDepthEstimation`],[`dpt`,`DPTForDepthEstimation`],[`depth_anything`,`DepthAnythingForDepthEstimation`],[`glpn`,`GLPNForDepthEstimation`],[`sapiens`,`SapiensForDepthEstimation`],[`depth_pro`,`DepthProForDepthEstimation`],[`metric3d`,`Metric3DForDepthEstimation`],[`metric3dv2`,`Metric3Dv2ForDepthEstimation`]]),aM=new Map([[`sapiens`,`SapiensForNormalEstimation`]]),oM=new Map([[`vitpose`,`VitPoseForPoseEstimation`]]),sM=new Map([[`clip`,`CLIPVisionModelWithProjection`],[`siglip`,`SiglipVisionModel`],[`jina_clip`,`JinaCLIPVisionModel`]]),cM=[[Ej,Q.EncoderOnly],[Dj,Q.EncoderDecoder],[kj,Q.DecoderOnlyWithoutHead],[Oj,Q.AutoEncoder],[Nj,Q.EncoderOnly],[Pj,Q.EncoderOnly],[Fj,Q.Seq2Seq],[Aj,Q.Seq2Seq],[Ij,Q.DecoderOnly],[Lj,Q.MultiModality],[Rj,Q.EncoderOnly],[zj,Q.EncoderOnly],[Bj,Q.Vision2Seq],[Vj,Q.ImageTextToText],[Hj,Q.AudioTextToText],[Wj,Q.EncoderOnly],[qj,Q.EncoderOnly],[Yj,Q.EncoderOnly],[Jj,Q.EncoderOnly],[tM,Q.EncoderOnly],[nM,Q.EncoderOnly],[rM,Q.EncoderOnly],[iM,Q.EncoderOnly],[aM,Q.EncoderOnly],[oM,Q.EncoderOnly],[Gj,Q.EncoderOnly],[Kj,Q.EncoderOnly],[Xj,Q.MaskGeneration],[Zj,Q.EncoderOnly],[Qj,Q.EncoderOnly],[jj,Q.Seq2Seq],[Mj,Q.EncoderOnly],[$j,Q.EncoderOnly],[eM,Q.EncoderOnly],[sM,Q.EncoderOnly]];for(let[e,t]of cM)for(let n of e.values()){Hv.set(n,t);let e=fy[n];Wv.set(e,n),Uv.set(n,e)}var lM=[[`MusicgenForConditionalGeneration`,zE,Q.Musicgen],[`Phi3VForCausalLM`,UD,Q.Phi3V],[`CLIPTextModelWithProjection`,yb,Q.EncoderOnly],[`SiglipTextModel`,ok,Q.EncoderOnly],[`JinaCLIPTextModel`,jw,Q.EncoderOnly],[`ClapTextModelWithProjection`,mb,Q.EncoderOnly],[`ClapAudioModelWithProjection`,hb,Q.EncoderOnly],[`DacEncoderModel`,ox,Q.EncoderOnly],[`DacDecoderModel`,sx,Q.EncoderOnly],[`MimiEncoderModel`,bT,Q.EncoderOnly],[`MimiDecoderModel`,xT,Q.EncoderOnly],[`SnacEncoderModel`,mk,Q.EncoderOnly],[`SnacDecoderModel`,hk,Q.EncoderOnly],[`Gemma3nForConditionalGeneration`,aC,Q.ImageAudioTextToText],[`Gemma4ForConditionalGeneration`,sC,Q.ImageAudioTextToText],[`SupertonicForConditionalGeneration`,Rk,Q.Supertonic],[`ChatterboxModel`,sb,Q.Chatterbox],[`VoxtralRealtimeForConditionalGeneration`,zA,Q.VoxtralRealtime]];for(let[e,t,n]of lM)Hv.set(e,n),Wv.set(t,e),Uv.set(e,t);var uM=new Map([[`modnet`,qj],[`birefnet`,qj],[`isnet`,qj],[`ben`,qj]]);for(let[e,t]of uM.entries())t.set(e,`PreTrainedModel`),Hv.set(e,Q.EncoderOnly),Uv.set(e,$);var dM=new Set(uM.keys());Hv.set(`PreTrainedModel`,Q.EncoderOnly),Wv.set($,`PreTrainedModel`);var fM={MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES:Nj,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES:Pj,MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES:jj,MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES:Mj,MODEL_FOR_MASKED_LM_MAPPING_NAMES:Rj,MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES:zj,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES:Wj,MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES:qj,MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES:Jj,MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES:Yj,MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES:Gj,MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES:Kj,MODEL_FOR_MASK_GENERATION_MAPPING_NAMES:Xj,MODEL_FOR_CTC_MAPPING_NAMES:Zj,MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES:Qj,MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES:$j,MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES:eM,MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES:Uj,MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES:tM,MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES:rM,MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES:iM,MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES:aM,MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES:oM,MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES:sM,MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES:Vj,MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES:Hj,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES:Fj,MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES:Aj,MODEL_FOR_CAUSAL_LM_MAPPING_NAMES:Ij,MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES:Bj};Lv(fM);var pM=class{static MODEL_CLASS_MAPPINGS=null;static BASE_IF_FAIL=!1;static supports(e){if(!this.MODEL_CLASS_MAPPINGS)return!1;for(let t of this.MODEL_CLASS_MAPPINGS)if(t.has(e))return!0;return this.BASE_IF_FAIL}static async from_pretrained(e,{progress_callback:t=null,config:n=null,cache_dir:r=null,local_files_only:i=!1,revision:a=`main`,model_file_name:o=null,subfolder:s=`onnx`,device:c=null,dtype:l=null,use_external_data_format:u=null,session_options:d={}}={}){let f={progress_callback:t,config:n,cache_dir:r,local_files_only:i,revision:a,model_file_name:o,subfolder:s,device:c,dtype:l,use_external_data_format:u,session_options:d};if(f.config=await B_.from_pretrained(e,f),!this.MODEL_CLASS_MAPPINGS)throw Error("`MODEL_CLASS_MAPPINGS` not implemented for this type of `AutoClass`: "+this.name);let{model_type:p}=f.config;for(let t of this.MODEL_CLASS_MAPPINGS){let n=t.get(p);if(!n){for(let e of t.values())if(e[0]===p){n=e;break}if(!n)continue}return await fy[n].from_pretrained(e,f)}if(this.BASE_IF_FAIL)return dM.has(p)||B.warn(`Unknown model class "${p}", attempting to construct from base class.`),await $.from_pretrained(e,f);throw Error(`Unsupported model type: ${p}`)}},mM=class extends pM{static MODEL_CLASS_MAPPINGS=cM.map(e=>e[0]);static BASE_IF_FAIL=!0},hM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES]},gM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES]},_M=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES]},vM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES]},yM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_TEXT_TO_SPECTROGRAM_MAPPING_NAMES]},bM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_TEXT_TO_WAVEFORM_MAPPING_NAMES]},xM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_CAUSAL_LM_MAPPING_NAMES]},SM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_MASKED_LM_MAPPING_NAMES]},CM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES]},wM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_VISION_2_SEQ_MAPPING_NAMES]},TM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES]},EM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES]},DM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_SEMANTIC_SEGMENTATION_MAPPING_NAMES]},OM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_UNIVERSAL_SEGMENTATION_MAPPING_NAMES]},kM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES]},AM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING_NAMES]};(class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_MASK_GENERATION_MAPPING_NAMES]});var jM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_CTC_MAPPING_NAMES]},MM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES]};(class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_AUDIO_XVECTOR_MAPPING_NAMES]}),class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_AUDIO_FRAME_CLASSIFICATION_MAPPING_NAMES]};var NM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING_NAMES]};(class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_IMAGE_MATTING_MAPPING_NAMES]});var PM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_IMAGE_TO_IMAGE_MAPPING_NAMES]},FM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_DEPTH_ESTIMATION_MAPPING_NAMES]};(class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_NORMAL_ESTIMATION_MAPPING_NAMES]}),class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_POSE_ESTIMATION_MAPPING_NAMES]};var IM=class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_IMAGE_FEATURE_EXTRACTION_MAPPING_NAMES]};(class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES]}),class extends pM{static MODEL_CLASS_MAPPINGS=[fM.MODEL_FOR_AUDIO_TEXT_TO_TEXT_MAPPING_NAMES]};async function LM(e){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(e=>ih.read(e)))}async function RM(e,t){return Array.isArray(e)||(e=[e]),await Promise.all(e.map(e=>typeof e==`string`||e instanceof URL?cm(e,t):e instanceof Float64Array?new Float32Array(e):e))}function zM(e,t){t&&(e=e.map(e=>e|0));let[n,r,i,a]=e;return{xmin:n,ymin:r,xmax:i,ymax:a}}var BM=class extends uo{constructor({task:e,model:t,tokenizer:n=null,processor:r=null}){super(),this.task=e,this.model=t,this.tokenizer=n,this.processor=r}async dispose(){await this.model.dispose()}},VM=class extends BM{async _call(e,{top_k:t=1}={}){let n=this.tokenizer(e,{padding:!0,truncation:!0}),r=await this.model(n),{problem_type:i,id2label:a}=this.model.config,o=i===`multi_label_classification`?e=>e.sigmoid():e=>new J(`float32`,bd(e.data),e.dims),s=[];for(let e of r.logits){let n=await yf(o(e),t),r=n[0].tolist(),i=n[1].tolist().map((e,t)=>({label:a?a[e]:`LABEL_${e}`,score:r[t]}));t===1?s.push(...i):s.push(i)}return Array.isArray(e)||t===1?s:s[0]}},HM=class extends BM{async _call(e,{ignore_labels:t=[`O`],aggregation_strategy:n=`none`}={}){if(n!==`none`&&n!==`simple`)throw Error(`Invalid aggregation_strategy: "${n}". Must be one of "none" or "simple".`);let r=Array.isArray(e),i=this.tokenizer(r?e:[e],{padding:!0,truncation:!0}),a=(await this.model(i)).logits,o=this.model.config.id2label,s=[];for(let e=0;e{let o=0,s=[];for(let n=i;ne==u),i=a[e].tolist(),f=o[e].tolist();for(let n=1;ne==t[n])!==-1)&&(i[n]=-1/0,f[n]=-1/0);let p=bd(i).map((e,t)=>[e,t]),m=bd(f).map((e,t)=>[e,t]);p[0][0]=0,m[0][0]=0;let h=vo(p,m).filter(e=>e[0][1]<=e[1][1]).map(e=>[e[0][1],e[1][1],e[0][0]*e[1][0]]).sort((e,t)=>t[2]-e[2]),g=[];for(let e=0;ee==n);if(c===-1)throw Error(`Mask token (${r}) not found in text.`);let l=a[e][c],u=await yf(new J(`float32`,bd(l.data),l.dims),t),d=u[0].tolist(),f=u[1].tolist();o.push(f.map((e,t)=>{let n=i.slice();return n[c]=e,{score:d[t],token:Number(e),token_str:this.tokenizer.decode([e]),sequence:this.tokenizer.decode(n,{skip_special_tokens:!0})}}))}return Array.isArray(e)?o:o[0]}},qM=class extends BM{_default_generation_config={max_new_tokens:256};_key=`generated_text`;async _call(e,t={}){Array.isArray(e)||(e=[e]),this.model.config.prefix&&(e=e.map(e=>this.model.config.prefix+e));let n=this.model.config.task_specific_params;n&&n[this.task]&&n[this.task].prefix&&(e=e.map(e=>n[this.task].prefix+e));let r=this.tokenizer,i={padding:!0,truncation:!0},a;a=this.task===`translation`&&`_build_translation_inputs`in r?r._build_translation_inputs(e,i,t):r(e,i);let o=await this.model.generate({...a,...this._default_generation_config,...t});return r.batch_decode(o,{skip_special_tokens:!0}).map(e=>({[this._key]:e}))}},JM=class extends qM{_key=`summary_text`},YM=class extends qM{_key=`translation_text`};function XM(e){return Array.isArray(e)&&e.every(e=>`role`in e&&`content`in e)}var ZM=class extends BM{_default_generation_config={max_new_tokens:256};async _call(e,t={}){let{add_special_tokens:n,return_full_text:r,tools:i,documents:a,chat_template:o,tokenizer_encode_kwargs:s,...c}=t,l=!1,u=!1,d=n??(this.tokenizer.add_bos_token||this.tokenizer.add_eos_token)??!1,f=s,p;if(typeof e==`string`)p=e=[e];else if(Array.isArray(e)&&e.every(e=>typeof e==`string`))l=!0,p=e;else{if(XM(e))e=[e];else if(Array.isArray(e)&&e.every(XM))l=!0;else throw Error(`Input must be a string, an array of strings, a Chat, or an array of Chats`);u=!0;let t={tokenize:!1,add_generation_prompt:!0,...bo({tools:i,documents:a,chat_template:o},[`tools`,`documents`,`chat_template`]),...f};p=e.map(e=>this.tokenizer.apply_chat_template(e,t)),d=!1,f=void 0}let m=u?!1:r??!0;this.tokenizer.padding_side=`left`;let h=this.tokenizer(p,{add_special_tokens:d,padding:!0,truncation:!0,...f}),g=await this.model.generate({...h,...this._default_generation_config,...c}),_=this.tokenizer.batch_decode(g,{skip_special_tokens:!0}),v;!m&&h.input_ids.dims.at(-1)>0&&(v=this.tokenizer.batch_decode(h.input_ids,{skip_special_tokens:!0}).map(e=>e.length));let y=Array.from({length:e.length},e=>[]);for(let t=0;t<_.length;++t){let n=Math.floor(t/g.dims[0]*e.length);v&&(_[t]=_[t].slice(v[n])),y[n].push({generated_text:u?[...e[n],{role:`assistant`,content:_[t]}]:_[t]})}return!l&&y.length===1?y[0]:y}},QM=class extends BM{constructor(e){super(e),this.label2id=Object.fromEntries(Object.entries(this.model.config.label2id).map(([e,t])=>[e.toLowerCase(),t])),this.entailment_id=this.label2id.entailment,this.entailment_id===void 0&&(B.warn(`Could not find 'entailment' in label2id mapping. Using 2 as entailment_id.`),this.entailment_id=2),this.contradiction_id=this.label2id.contradiction??this.label2id.not_entailment,this.contradiction_id===void 0&&(B.warn(`Could not find 'contradiction' in label2id mapping. Using 0 as contradiction_id.`),this.contradiction_id=0)}async _call(e,t,{hypothesis_template:n=`This example is {}.`,multi_label:r=!1}={}){let i=Array.isArray(e);i||(e=[e]),Array.isArray(t)||(t=[t]);let a=t.map(e=>n.replace(`{}`,e)),o=r||t.length===1,s=[];for(let n of e){let e=[];for(let t of a){let r=this.tokenizer(n,{text_pair:t,padding:!0,truncation:!0}),i=await this.model(r);o?e.push([i.logits.data[this.contradiction_id],i.logits.data[this.entailment_id]]):e.push(i.logits.data[this.entailment_id])}let r=(o?e.map(e=>bd(e)[1]):bd(e)).map((e,t)=>[e,t]).sort((e,t)=>t[0]-e[0]);s.push({sequence:n,labels:r.map(e=>t[e[1]]),scores:r.map(e=>e[0])})}return i?s:s[0]}},$M=class extends BM{async _call(e,{top_k:t=5}={}){let n=this.processor.feature_extractor.config.sampling_rate,r=await RM(e,n),i=this.model.config.id2label,a=[];for(let e of r){let n=await this.processor(e),r=(await this.model(n)).logits[0],o=await yf(new J(`float32`,bd(r.data),r.dims),t),s=o[0].tolist(),c=o[1].tolist().map((e,t)=>({label:i?i[e]:`LABEL_${e}`,score:s[t]}));a.push(c)}return Array.isArray(e)?a:a[0]}},eN=class extends BM{async _call(e,t,{hypothesis_template:n=`This is a sound of {}.`}={}){let r=!Array.isArray(e);r&&(e=[e]);let i=t.map(e=>n.replace(`{}`,e)),a=this.tokenizer(i,{padding:!0,truncation:!0}),o=this.processor.feature_extractor.config.sampling_rate,s=await RM(e,o),c=[];for(let e of s){let n=await this.processor(e),r=bd((await this.model({...a,...n})).logits_per_audio.data);c.push([...r].map((e,n)=>({score:e,label:t[n]})))}return r?c[0]:c}},tN=class extends BM{_default_generation_config={};async _call(e,t={}){switch(t={...this._default_generation_config,...t},this.model.config.model_type){case`whisper`:case`lite-whisper`:return this._call_whisper(e,t);case`wav2vec2`:case`wav2vec2-bert`:case`unispeech`:case`unispeech-sat`:case`hubert`:case`parakeet_ctc`:return this._call_wav2vec2(e,t);case`moonshine`:return this._call_moonshine(e,t);case`cohere_asr`:return this._call_cohere_asr(e,t);default:throw Error(`AutomaticSpeechRecognitionPipeline does not support model type '${this.model.config.model_type}'.`)}}async _call_wav2vec2(e,t){t.language&&B.warn('`language` parameter is not yet supported for `wav2vec2` models, defaulting to "English".'),t.task&&B.warn('`task` parameter is not yet supported for `wav2vec2` models, defaulting to "transcribe".');let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor.config.sampling_rate,a=await RM(r,i),o=[];for(let e of a){let t=await this.processor(e),n=(await this.model(t)).logits[0],r=[];for(let e of n)r.push(Cd(e.data)[1]);let i=this.tokenizer.decode(r,{skip_special_tokens:!0}).trim();o.push({text:i})}return n?o[0]:o}async _call_whisper(e,t){let n=t.return_timestamps??!1,r=t.chunk_length_s??0,i=t.force_full_sequences??!1,a=t.stride_length_s??null,o={...t};n===`word`&&(o.return_token_timestamps=!0,o.return_timestamps=!0);let s=!Array.isArray(e),c=s?[e]:e,l=this.processor.feature_extractor.config,u=l.chunk_length/this.model.config.max_source_positions,d=l.hop_length,f=l.sampling_rate,p=await RM(c,f),m=[];for(let e of p){let t=[];if(r>0){if(a===null)a=r/6;else if(r<=a)throw Error("`chunk_length_s` must be larger than `stride_length_s`.");let n=f*r,i=f*a,o=n-2*i,s=0;for(;;){let r=s+n,a=e.subarray(s,r),c=await this.processor(a),l=s===0,u=r>=e.length;if(t.push({stride:[a.length,l?0:i,u?0:i],input_features:c.input_features,is_last:u}),u)break;s+=o}}else t=[{stride:[e.length,0,0],input_features:(await this.processor(e)).input_features,is_last:!0}];for(let e of t){o.num_frames=Math.floor(e.stride[0]/d);let t=await this.model.generate({inputs:e.input_features,...o});if(n===`word`){let n=t.sequences.tolist()[0],r=t.token_timestamps.tolist()[0],i=this.tokenizer.timestamp_begin,a=Math.max(n.findIndex(e=>Number(e)>=i),0);e.tokens=n.slice(a),e.token_timestamps=r.slice(a).map(e=>kd(e,2))}else e.tokens=t[0].tolist();e.stride=e.stride.map(e=>e/f)}let[s,c]=this.tokenizer._decode_asr(t,{time_precision:u,return_timestamps:n,force_full_sequences:i});m.push({text:s,...c})}return s?m[0]:m}async _call_moonshine(e,t){let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor.config.sampling_rate,a=await RM(r,i),o=[];for(let e of a){let n=await this.processor(e),r=Math.floor(e.length/i)*6,a=await this.model.generate({max_new_tokens:r,...t,...n}),s=this.tokenizer.batch_decode(a,{skip_special_tokens:!0})[0];o.push({text:s})}return n?o[0]:o}async _call_cohere_asr(e,t){let n=!Array.isArray(e),r=n?[e]:e,i=this.processor.feature_extractor,a=i.config.sampling_rate,o=await RM(r,a),s=t.language??`en`,c=this.processor.get_decoder_prompt_ids(s),l=[];for(let e of o){let n=i.split_audio(e),r=[];for(let e of n){let n=await this.processor(e),i=await this.model.generate({...n,decoder_input_ids:c,...t}),a=this.tokenizer.decode(i[0].tolist(),{skip_special_tokens:!0}).trim();r.push(a)}let a=this.processor.constructor.join_chunks(r,s);l.push({text:a})}return n?l[0]:l}},nN=class extends BM{DEFAULT_VOCODER_ID=`Xenova/speecht5_hifigan`;constructor(e){super(e),this.vocoder=e.vocoder??null}async _prepare_speaker_embeddings(e,t){if((typeof e==`string`||e instanceof URL)&&(e=new Float32Array(await(await z.fetch(e)).arrayBuffer())),e instanceof Float32Array)e=new J(`float32`,e,[e.length]);else if(!(e instanceof J))throw Error("Speaker embeddings must be a `Tensor`, `Float32Array`, `string`, or `URL`.");if(t>1){if(e.dims[0]===1)e=e.repeat(t,1);else if(e.dims[0]!==t)throw Error(`Expected speaker embeddings batch size to be 1 or ${t}, but got ${e.dims[0]}.`)}return e}_postprocess_waveform(e,t,n,r=null){let i=t.data,[a,o]=t.dims,s=r?r.data:null,c=[];for(let e=0;e({generated_text:e.trim()}));a.push(r)}return n?a:a[0]}},iN=class extends BM{async _call(e,{top_k:t=5}={}){let n=await LM(e),{pixel_values:r}=await this.processor(n),i=await this.model({pixel_values:r}),{id2label:a}=this.model.config,o=[];for(let e of i.logits){let n=await yf(new J(`float32`,bd(e.data),e.dims),t),r=n[0].tolist(),i=n[1].tolist().map((e,t)=>({label:a?a[e]:`LABEL_${e}`,score:r[t]}));o.push(i)}return Array.isArray(e)?o:o[0]}},aN={panoptic:`post_process_panoptic_segmentation`,instance:`post_process_instance_segmentation`,semantic:`post_process_semantic_segmentation`},oN=class extends BM{async _call(e,{threshold:t=.5,mask_threshold:n=.5,overlap_mask_area_threshold:r=.8,label_ids_to_fuse:i=null,target_sizes:a=null,subtask:o=null}={}){if(Array.isArray(e)&&e.length!==1)throw Error(`Image segmentation pipeline currently only supports a batch size of 1.`);let s=await LM(e),c=s.map(e=>[e.height,e.width]),l=await this.processor(s),{inputNames:u,outputNames:d}=this.model.sessions.model;if(!u.includes(`pixel_values`)){if(u.length!==1)throw Error(`Expected a single input name, but got ${u.length} inputs: ${u}.`);let e=u[0];if(e in l)throw Error(`Input name ${e} already exists in the inputs.`);l[e]=l.pixel_values}let f=await this.model(l),p=null;if(o!==null)p=aN[o];else if(this.processor.image_processor){for(let[e,t]of Object.entries(aN))if(t in this.processor.image_processor){p=this.processor.image_processor[t].bind(this.processor.image_processor),o=e;break}}let m=this.model.config.id2label,h=[];if(!o){let e=f[d[0]];for(let t=0;te<-1e-5||e>1.00001)&&r.sigmoid_();let i=await ih.fromTensor(r.mul_(255).to(`uint8`)).resize(n[1],n[0]);h.push({label:null,score:null,mask:i})}}else if(o===`panoptic`||o===`instance`){let e=p(f,t,n,r,i,a??c)[0],o=e.segmentation;for(let t of e.segments_info){let e=new Uint8ClampedArray(o.data.length);for(let n=0;n{let n=e.clone();return n.putAlpha(r[t].mask),n});return Array.isArray(e)?i:i[0]}},model:[EM,DM,OM],default:{model:`Xenova/modnet`},type:`image`},"zero-shot-image-classification":{pipeline:class extends BM{async _call(e,t,{hypothesis_template:n=`This is a photo of {}`}={}){let r=Array.isArray(e),i=await LM(e),a=t.map(e=>n.replace(`{}`,e)),o=this.tokenizer(a,{padding:this.model.config.model_type!==`siglip`||`max_length`,truncation:!0}),{pixel_values:s}=await this.processor(i),c=await this.model({...o,pixel_values:s}),l=this.model.config.model_type===`siglip`?e=>e.sigmoid().data:e=>bd(e.data),u=[];for(let e of c.logits_per_image){let n=[...l(e)].map((e,n)=>({score:e,label:t[n]}));n.sort((e,t)=>t.score-e.score),u.push(n)}return r?u:u[0]}},model:mM,default:{model:`Xenova/clip-vit-base-patch32`},type:`multimodal`},"object-detection":{pipeline:class extends BM{async _call(e,{threshold:t=.9,percentage:n=!1}={}){let r=Array.isArray(e);if(r&&e.length!==1)throw Error(`Object detection pipeline currently only supports a batch size of 1.`);let i=await LM(e),a=n?null:i.map(e=>[e.height,e.width]),{pixel_values:o,pixel_mask:s}=await this.processor(i),c=await this.model({pixel_values:o,pixel_mask:s}),l=this.processor.image_processor.post_process_object_detection(c,t,a),{id2label:u}=this.model.config,d=l.map(e=>e.boxes.map((t,r)=>({score:e.scores[r],label:u[e.classes[r]],box:zM(t,!n)})));return r?d:d[0]}},model:kM,default:{model:`Xenova/detr-resnet-50`},type:`multimodal`},"zero-shot-object-detection":{pipeline:class extends BM{async _call(e,t,{threshold:n=.1,top_k:r=null,percentage:i=!1}={}){let a=Array.isArray(e),o=await LM(e),s=this.tokenizer(t,{padding:!0,truncation:!0}),c=await this.processor(o),l=[];for(let e=0;e({score:e.scores[n],label:e.labels[n],box:zM(t,!i)}))}else{let e=this.processor.image_processor.post_process_object_detection(f,n,u,!0)[0];p=e.boxes.map((n,r)=>({score:e.scores[r],label:t[e.classes[r]],box:zM(n,!i)}))}p.sort((e,t)=>t.score-e.score),r!==null&&(p=p.slice(0,r)),l.push(p)}return a?l:l[0]}},model:AM,default:{model:`Xenova/owlvit-base-patch32`},type:`multimodal`},"document-question-answering":{pipeline:class extends BM{_default_generation_config={max_new_tokens:256};async _call(e,t,n={}){if(Array.isArray(e)){if(e.length!==1)throw Error(`Document Question Answering pipeline currently only supports a batch size of 1.`);e=e[0]}let r=(await LM(e))[0],{pixel_values:i}=await this.processor(r),a=`${t}`,o=this.tokenizer(a,{add_special_tokens:!1,padding:!0,truncation:!0}).input_ids,s=await this.model.generate({inputs:i,max_length:this.model.config.decoder.max_position_embeddings,decoder_input_ids:o,...this._default_generation_config,...n}),c=this.tokenizer.batch_decode(s)[0].match(/(.*?)<\/s_answer>/),l=null;return c&&c.length>=2&&(l=c[1].trim()),[{answer:l}]}},model:NM,default:{model:`Xenova/donut-base-finetuned-docvqa`},type:`multimodal`},"image-to-image":{pipeline:class extends BM{async _call(e){let t=await LM(e),n=await this.processor(t),r=await this.model(n),i=[];for(let e of r.reconstruction){let t=e.squeeze().clamp_(0,1).mul_(255).round_().to(`uint8`);i.push(ih.fromTensor(t))}return Array.isArray(e)?i:i[0]}},model:PM,default:{model:`Xenova/swin2SR-classical-sr-x2-64`},type:`image`},"depth-estimation":{pipeline:class extends BM{async _call(e){let t=await LM(e),n=await this.processor(t),{predicted_depth:r}=await this.model(n),i=[];for(let e=0;e`onnx/${e}`);return s.filter(e=>!e.startsWith(`onnx/`)||t.some(t=>e.startsWith(t)))}}return s}R.IS_PROCESS_AVAILABLE;async function fN(e,t,n={}){let r=await q(n?.cache_dir);if(!r)return{allCached:!1,files:t.map(e=>({file:e,cached:!1}))};let i=await Promise.all(t.map(async t=>{let{localPath:i,proposedCacheKey:a}=ud(e,t,n,r);return{file:t,cached:!!await dd(r,i,a)}}));return{allCached:i.every(e=>e.cached),files:i}}async function pN(e,t,n={}){let r=await q(n?.cache_dir);if(!r)return!1;let{localPath:i,proposedCacheKey:a}=ud(e,t,n,r);return!!await dd(r,i,a)}async function mN(e,t={}){if(!e)throw Error(`modelId is required`);return await pN(e,`config.json`,t)?(await fN(e,await uN(e,t),t)).allCached:!1}async function hN(e,t={}){if(!e)throw Error(`modelId is required`);return await fN(e,await uN(e,t),t)}async function gN(e,t,n={}){if(!e)throw Error(`task is required`);if(!t)throw Error(`modelId is required`);return await pN(t,`config.json`,n)?(await fN(t,await dN(e,t,n),n)).allCached:!1}async function _N(e,t,n={}){if(!e)throw Error(`task is required`);if(!t)throw Error(`modelId is required`);return await fN(t,await dN(e,t,n),n)}async function vN(e,t,n={}){let r=await q(n?.cache_dir);if(!r)return{filesDeleted:0,filesCached:0,files:t.map(e=>({file:e,deleted:!1,wasCached:!1}))};if(!r.delete)throw Error(`Cache does not support delete operation`);let i=await Promise.all(t.map(async t=>{let{localPath:i,proposedCacheKey:a}=ud(e,t,n,r),o=!!await dd(r,i,a),s=!1;if(o){let e=await r.delete(a),t=!e&&a!==i&&await r.delete(i);s=e||t}return{file:t,deleted:s,wasCached:o}}));return{filesDeleted:i.filter(e=>e.deleted).length,filesCached:i.filter(e=>e.wasCached).length,files:i}}async function yN(e,t={}){if(!e)throw Error(`modelId is required`);return await vN(e,await uN(e,t),t)}async function bN(e,t,n={}){if(!e)throw Error(`task is required`);if(!t)throw Error(`modelId is required`);return await vN(t,await dN(e,t,n),n)}var xN=Object.keys(df);async function SN(e,{config:t=null,model_file_name:n=null,revision:r=`main`,cache_dir:i=null,local_files_only:a=!1}={}){t=await Pv(e,{config:t,cache_dir:i,local_files_only:a,revision:r});let{sessions:o}=Mv(Nv(t),t,{model_file_name:n}),s=Object.values(o),c={revision:r,cache_dir:i,local_files_only:a};return(await Promise.all(xN.map(async t=>{let n=df[t]??``;return{dtype:t,available:(await Promise.all(s.map(async t=>(await od(e,`onnx/${t}${n}.onnx`,c)).exists))).every(Boolean)}}))).filter(e=>e.available).map(e=>e.dtype)}var CN=class{static async get_files(e,t={}){return uN(e,t)}static async get_pipeline_files(e,t,n={}){return dN(e,t,n)}static async get_model_files(e,t={}){return Fv(e,t)}static async get_tokenizer_files(e){return Vf(e)}static async get_processor_files(e){return lN(e)}static async get_available_dtypes(e,t={}){return SN(e,t)}static async is_cached(e,t={}){return mN(e,t)}static async is_cached_files(e,t={}){return hN(e,t)}static async is_pipeline_cached(e,t,n={}){return gN(e,t,n)}static async is_pipeline_cached_files(e,t,n={}){return _N(e,t,n)}static async get_file_metadata(e,t,n={}){return od(e,t,n)}static async clear_cache(e,t={}){return yN(e,t)}static async clear_pipeline_cache(e,t,n={}){return bN(e,t,n)}},wN=[`no`,`yes`];function TN(e,t,n){return n?{type:`choice`,instructions:e,options:t,descriptions:n}:{type:`choice`,instructions:e,options:t}}function EN(e,t){return{type:`score`,instructions:e,options:t}}function DN(e,t){return t?{type:`noul`,instructions:e,descriptions:t}:{type:`noul`,instructions:e}}function ON(e){if(e.type===`noul`)return[...wN];if(e.type===`choice`&&e.descriptions){let t=e.descriptions;return e.options.map(e=>{let n=t[e];return n?`${e}: ${n}`:e})}return[...e.options]}function kN(e,t,n){if(!e||typeof e!=`object`)throw Error(`Question ${t} must be an object.`);if(typeof e.instructions!=`string`||e.instructions.trim()===``)throw Error(`Question ${t} needs non-empty instructions.`);if(e.type===`noul`){let n=e.descriptions;if(n===void 0)return;if(!n||typeof n!=`object`)throw Error(`Question ${t} (noul) descriptions must be an object.`);for(let e of Object.keys(n)){let r=n[e];if(e!==`false`&&e!==`true`)throw Error(`Question ${t} (noul) descriptions take only "false" and "true", got "${e}".`);if(typeof r!=`string`||r.trim()===``)throw Error(`Question ${t} (noul) has an empty "${e}" description.`)}return}if(e.type!==`choice`&&e.type!==`score`)throw Error(`Question ${t} has unknown type "${String(e.type)}". Expected "choice", "score" or "noul".`);let r=e.options;if(!Array.isArray(r))throw Error(`Question ${t} needs an options array.`);let i=e.type===`choice`?n.minChoiceOptions:n.minScoreLevels,a=e.type===`choice`?n.maxChoiceOptions:n.maxScoreLevels;if(r.lengtha)throw Error(`Question ${t} (${e.type}) needs between ${i} and ${a} options for this model, got ${r.length}.`);let o=new Set;for(let e of r){if(typeof e!=`string`||e.trim()===``)throw Error(`Question ${t} has an empty or non-string option.`);if(o.has(e))throw Error(`Question ${t} has a duplicate option "${e}".`);o.add(e)}}function AN(e,t,n){return Math.max(t,Math.min(n,e))}function jN(e,t=1){if(e.length===0)return[];let n=Math.max(...e),r=e.map(e=>Math.exp((e-n)/t)),i=r.reduce((e,t)=>e+t,0);return r.map(e=>e/i)}function MN(e,t,n){let r=jN(t,n);switch(e.type){case`choice`:return NN(e.options,r);case`score`:return PN(e.options,r);case`noul`:return FN(r)}}function NN(e,t){let n=IN(t);return{type:`choice`,choice:e[n],confidence:t[n],probabilities:LN(e,t)}}function PN(e,t){let n=t.reduce((e,t,n)=>e+t*n,0),r=IN(t),i=e.length-1,a=Math.min(i,Math.max(0,Math.round(n)));return{type:`score`,score:n,normalized:i>0?n/i:0,level:e[a],confidence:t[r],probabilities:LN(e,t)}}function FN(e){let t=e[wN.indexOf(`yes`)];return{type:`noul`,answer:t>=.5,probability:t,confidence:Math.max(t,1-t)}}function IN(e){let t=0;for(let n=1;ne[t]&&(t=n);return t}function LN(e,t){let n={};return e.forEach((e,r)=>{n[e]=t[r]}),n}function RN(e){let{state:t,questions:n,markers:r,maxStateTokens:i,maxLength:a}=e,o=3;for(let e of n){o+=1+e.instructions.length;for(let t of e.options)o+=1+t.length}let s=a-o;if(s<0)throw Error(`Questions need ${o} tokens which exceeds the ${a} token context. Shorten the instructions or options, or ask fewer questions per call.`);let c=Math.min(i,s),l=t.slice(0,c),u=[r.cls,r.state,...l],d=u.map(()=>-1),f=[],p=[],m=[],h=n.reduce((e,t)=>e+t.options.length,0);return n.forEach((e,t)=>{let n=h+t;u.push(r.q,...e.instructions),d.push(-1,...e.instructions.map(()=>n));let i=[];for(let t of e.options){let e=p.length;u.push(r.opt,...t),d.push(-1,...t.map(()=>e)),f.push(n),p.push(e),i.push(e)}m.push(i)}),u.push(r.sep),d.push(-1),{inputIds:u,extraInputs:{seg:d,pair_q:f,pair_opt:p},groups:m,stateTokens:l.length,stateTruncated:l.length{let t=[r.question,...e.instructions],n=[];for(let i of e.options)t.push(r.optionStart,...i,r.optionEnd),n.push(t.length-1);return t.push(r.decide),{branch:t,ends:n}}),s=Math.max(...o.map(e=>e.branch.length)),c=a-1-s;if(c<0)throw Error(`A question needs ${s+1} tokens which exceeds the ${a} token context. Shorten the instructions or options.`);let l=Math.min(i,c),u=t.slice(0,l),d=[r.state,...u],f=[];for(let{branch:e,ends:t}of o){let n=d.length;d.push(...e),f.push(t.map(e=>n+e))}return{inputIds:d,extraInputs:{},groups:f,stateTokens:u.length,stateTruncated:u.length{t>0&&o.push(r.sepStruct),o.push(...r.open,r.p,...e.instructions),o.push(...r.open);let n=[];for(let t of e.options)n.push(s.length),s.push(o.length),o.push(r.l,...t);c.push(n),o.push(...r.close,...r.close)}),o.push(r.sepText);let l=a-o.length;if(l<0)throw Error(`Questions need ${o.length} tokens which exceeds the ${a} token context. Shorten the instructions or options, or ask fewer questions per call.`);let u=Math.min(i,l),d=t.slice(0,u);return o.push(...d),{inputIds:o,extraInputs:{marker_positions:s},groups:c,stateTokens:d.length,stateTruncated:d.length{let{input_ids:n}=e(t,{add_special_tokens:!1});return Array.from(n.data,Number)},r=e=>{let t=n(e);if(t.length!==1)throw Error(`Tokenizer does not know the token ${e}.`);return t[0]},i=e=>{let r=e.replace(//g,` `);if(r===``)return[];let i=r.startsWith(` `)?r:` ${r}`,a=[];for(let e of i.split(/(?= )/)){let r=e.slice(1);r===``?a.push(t.space):a.push(...n(r))}return a},a=e=>{if(e.type===`noul`){let[t,n]=HN;return[e.descriptions?.false??t,e.descriptions?.true??n]}if(e.type===`choice`&&e.descriptions){let t=e.descriptions;return e.options.map(e=>t[e]||e)}return[...e.options]},o=(e,n,r,o)=>{let{bos:s,eos:c,mask:l}=t,u=i(`${e.type} question: ${e.instructions}`),d=a(e).map((t,n)=>{let r=i(` ${t}`);if(r.length>WN)throw Error(`Option ${n+1} of "${e.instructions}" is ${r.length} tokens; Julia takes at most ${WN}.`);return[l,...r]}),f=GN-d.reduce((e,t)=>e+t.length,0);if(u.length>f)throw Error(`Question "${e.instructions}" and its options do not fit Julia's ${GN}-token head; shorten them.`);let p=[s,...u,c],m=[];for(let e of d)m.push(p.length),p.push(...e);p.push(c);let h=Math.min(o,r-p.length-1);if(h<0)throw Error(`Question and options leave no room for the state; raise maxLength.`);let g=n.slice(0,h);return p.push(...g,c),{ids:p,markers:m,qtype:VN[e.type],stateTokens:g.length,stateTruncated:g.lengthJN,loadModel:async(e,t)=>{let n={};return await Promise.all(qN.map(async t=>{let r=await CN.get_file_metadata(e,t);n[t]={loaded:0,total:r.size??0}})),await mM.from_pretrained(e,{config:t.config,dtype:t.dtype,device:t.device,progress_callback:e=>{let r=e.file?.replace(/^\//,``);if(e.status!==`progress`||!r||!(r in n))return;n[r]={loaded:e.loaded??0,total:e.total||n[r].total};let i=Object.values(n).reduce((e,t)=>e+t.loaded,0),a=Object.values(n).reduce((e,t)=>e+t.total,0);t.progress_callback({status:`progress_total`,progress:a>0?i/a*100:0,loaded:i,total:a})},subfolder:``,model_file_name:`model`,session_options:{externalData:[{path:`model.onnx.data`,data:`model.onnx.data`}]}})},prepare(i){e=i;let a=i;t={bos:r(a.cls_token??a.bos_token??``),eos:r(a.sep_token??a.eos_token??``),mask:r(a.mask_token??``),pad:r(a.pad_token??``),space:n(` `)[0]}},escape:e=>e.replace(//g,` `),encode(){throw Error(`Julia scores each question in its own sequence; use decide().`)},countTokens:e=>i(e).length,async decide({model:e,state:n,questions:r,maxLength:a,maxStateTokens:s}){if(!t)throw Error(`Model family not prepared.`);let c=i(n),l=r.map(e=>o(e,c,a,s)),u=l.length,d=Math.ceil(Math.max(...l.map(e=>e.ids.length))/8)*8,f=Math.max(...l.map(e=>e.markers.length)),p=new BigInt64Array(u*d).fill(BigInt(t.pad)),m=new BigInt64Array(u*d),h=new BigInt64Array(u*f),g=new Uint8Array(u*f),_=new BigInt64Array(u);l.forEach((e,t)=>{e.ids.forEach((e,n)=>{p[t*d+n]=BigInt(e),m[t*d+n]=1n}),e.markers.forEach((e,n)=>{h[t*f+n]=BigInt(e),g[t*f+n]=1}),_[t]=BigInt(e.qtype)});let{logits:v}=await e({input_ids:new J(`int64`,p,[u,d]),attention_mask:new J(`int64`,m,[u,d]),marker_pos:new J(`int64`,h,[u,f]),marker_mask:new J(`bool`,g,[u,f]),qtype:new J(`int64`,_,[u])}),y=Array.from(v.to(`float32`).data);return{logits:l.map((e,t)=>y.slice(t*f,t*f+e.markers.length)),stateTokens:l.length?Math.min(...l.map(e=>e.stateTokens)):0,stateTruncated:l.some(e=>e.stateTruncated)}}}}var ZN={"open-jev":`onnx-community/open-jev-deberta-v3-large-ONNX`,"kev-0.6b":`onnx-community/kev-0.6b-ONNX`,"kev-4b":`onnx-community/kev-4b-ONNX`,"julia-1":`SupersonicLabs/Julia-1-ONNX`,"gliner2-decide":`onnx-community/GLiNER2.5-Decide-ONNX`},QN=`kev-0.6b`;function $N(e){let t=e??QN;return ZN[t]??t}async function eP(e,t){if(KN.includes(e))return{config:YN(),family:XN()};let n=await t(e);return{config:n,family:tP(n)}}function tP(e){let t=e;if(t.kev&&typeof t.kev==`object`)return aP(t.kev);if(t.open_jev&&typeof t.open_jev==`object`)return iP(t.open_jev);if(t.gliner2&&typeof t.gliner2==`object`)return sP(t.gliner2);throw Error(`Unsupported model: config.json has no "open_jev", "kev" or "gliner2" section. Use one of ${Object.keys(ZN).join(`, `)} or a compatible ONNX conversion.`)}function nP(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function rP(e,t){let{input_ids:n}=e(t,{add_special_tokens:!1}),r=Array.from(n.data,Number);if(r.length!==1)throw Error(`Tokenizer does not know the marker token ${t}.`);return r[0]}function iP(e){let t=null;return{name:`open-jev`,webgpuDtype:`fp16`,limits:{minChoiceOptions:2,maxChoiceOptions:255,minScoreLevels:2,maxScoreLevels:10},defaults:{temperature:nP(e.temperature,1.05),maxStateTokens:nP(e.max_state_tokens,256),maxLength:nP(e.max_len,512)},loadModel:async(e,t)=>await mM.from_pretrained(e,{config:t.config,dtype:t.dtype,device:t.device,progress_callback:t.progress_callback}),prepare(e){t={cls:rP(e,`[CLS]`),sep:rP(e,`[SEP]`),state:rP(e,`[STATE]`),q:rP(e,`[Q]`),opt:rP(e,`[OPT]`)}},escape:e=>e,encode(e){if(!t)throw Error(`Model family not prepared.`);return RN({...e,markers:t})}}}function aP(e){let t=e.delimiter_ids??{},n=e.delimiters??{},r=null,i=(e,r,i)=>{let a=t[r];return typeof a==`number`?a:rP(e,typeof n[r]==`string`?n[r]:i)};return{name:`kev`,webgpuDtype:`q4f16`,limits:{minChoiceOptions:1,maxChoiceOptions:nP(e.max_options,255),minScoreLevels:2,maxScoreLevels:nP(e.max_options,255)},defaults:{temperature:1,maxStateTokens:nP(e.max_state_tokens,8192),maxLength:nP(e.max_branch_tokens,8192)},loadModel:async(e,t)=>await $.from_pretrained(e,{config:t.config,dtype:t.dtype,device:t.device,progress_callback:t.progress_callback}),prepare(e){r={state:i(e,`state`,`<|fim_prefix|>`),question:i(e,`question`,`<|fim_middle|>`),optionStart:i(e,`option_start`,`<|box_start|>`),optionEnd:i(e,`option_end`,`<|box_end|>`),decide:i(e,`decide`,`<|fim_suffix|>`)}},escape:e=>e.replace(/<\|([A-Za-z0-9_]+)\|>/g,`<¦$1¦>`),encode(e){if(!r)throw Error(`Model family not prepared.`);return zN({...e,delimiters:r})}}}var oP=/(?:https?:\/\/[^\s]+|www\.[^\s]+)|[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}|@[a-z0-9_]+|[\p{L}\p{M}\p{N}_]+(?:[-_][\p{L}\p{M}\p{N}_]+)*|\S/giu;function sP(e){let t=null;return{name:`gliner2`,webgpuDtype:`fp16`,limits:{minChoiceOptions:2,maxChoiceOptions:nP(e.max_options,64),minScoreLevels:2,maxScoreLevels:10},defaults:{temperature:nP(e.temperature,1),maxStateTokens:nP(e.max_state_tokens,384),maxLength:nP(e.max_len,512)},loadModel:async(e,t)=>await mM.from_pretrained(e,{config:t.config,dtype:t.dtype,device:t.device,progress_callback:t.progress_callback}),prepare(e){let n=t=>{let{input_ids:n}=e(t,{add_special_tokens:!1});return Array.from(n.data,Number)};t={p:rP(e,`[P]`),l:rP(e,`[L]`),sepStruct:rP(e,`[SEP_STRUCT]`),sepText:rP(e,`[SEP_TEXT]`),open:n(`(`),close:n(`)`)}},escape:e=>e,tokenize({state:e,questions:t,encode:n}){let r=e.trim();r=r===``?`.`:/[.!?]$/.test(r)?r:`${r}.`;let i=r.match(oP)??[],a=[];for(let e of i)a.push(...n(e.toLowerCase()));return{state:a,questions:t.map(e=>{let t=e.instructions,r=e.type===`noul`?wN:e.options;if(e.type===`choice`&&e.descriptions)for(let[n,i]of Object.entries(e.descriptions))i&&r.includes(n)&&(t+=` [DESCRIPTION] ${n}: ${i}`);return{instructions:n(t),options:r.map(e=>n(e))}})}},encode(e){if(!t)throw Error(`Model family not prepared.`);return BN({...e,markers:t})}}}function cP(e){return e instanceof Error?e:Error(typeof e==`string`?e:`Unknown error`)}var lP=null;function uP(){return typeof globalThis.process?.versions?.node==`string`}function dP(){return typeof navigator<`u`&&typeof navigator.gpu<`u`}function fP(){return lP||=(async()=>{if(!dP())return!1;try{return(await navigator.gpu.requestAdapter())?.features.has(`shader-f16`)??!1}catch{return!1}})(),lP}async function pP(e,t){let n=e.device??`auto`,r=e.dtype??`auto`,i;i=n===`auto`?dP()?`webgpu`:uP()?`cpu`:`wasm`:n;let a;if(a=r===`auto`?i===`webgpu`&&await fP()?t.webgpuDtype:t.fallbackDtype??`q4`:r,t.dtypes&&!t.dtypes.includes(a))throw Error(`This model ships ${t.dtypes.join(`, `)} weights only; dtype "${a}" is not available.`);return{device:i,dtype:a}}var mP=class e{constructor(e){this.queue=Promise.resolve(),this.disposed=!1,this.model=e.model,this.tokenizer=e.tokenizer,this.family=e.family,this.runtime=e.runtime,this.defaults=e.defaults,this.maxLength=e.maxLength}static async load(t={}){let n=$N(t.model),{config:r,family:i}=await eP(n,e=>B_.from_pretrained(e)),a=await pP(t,i),o=t.onProgress,s=-1,c=e=>{if(!o||e.status!==`progress_total`)return;let t=Math.round(AN(e.progress/100,0,1)*100)/100;t!==s&&(s=t,o({progress:t,loaded:e.loaded,total:e.total}))},l=await Yp.from_pretrained(n);i.prepare(l);let u=await i.loadModel(n,{config:r,dtype:a.dtype,device:a.device,progress_callback:c}),d={temperature:t.temperature??i.defaults.temperature,maxStateTokens:t.maxStateTokens??i.defaults.maxStateTokens,truncation:t.truncation??`cut`};return new e({model:u,tokenizer:l,family:i,runtime:{model:n,family:i.name,...a},defaults:d,maxLength:Math.max(8,Math.floor(t.maxLength??i.defaults.maxLength))})}static async info(e={}){let t=$N(e.model),{config:n,family:r}=await eP(t,e=>B_.from_pretrained(e)),i=await pP(e,r),a=r.files?r.files(i.dtype):await CN.get_files(t,{config:n,dtype:i.dtype,device:i.device,include_tokenizer:!0,include_processor:!1}),o=await Promise.all(a.map(e=>CN.get_file_metadata(t,e))),s=r.files?o.every(e=>e.fromCache===!0):await CN.is_cached(t,{config:n,dtype:i.dtype,device:i.device}),c=o.reduce((e,t)=>e+(t.size??0),0);return{model:t,family:r.name,...i,isCached:s,downloadSize:c,files:a}}async decide(e,t,n={}){if(this.assertNotDisposed(),typeof e!=`string`)throw Error(`OpenJev.decide() expects the state to be a string.`);let r=Array.isArray(t),i=r?t.map((e,t)=>String(t)):Object.keys(t),a=r?[...t]:Object.values(t);if(a.length===0)throw Error(`OpenJev.decide() needs at least one question.`);a.forEach((e,t)=>kN(e,r?`#${t}`:`"${i[t]}"`,this.family.limits));let o={temperature:Math.max(1e-6,n.temperature??this.defaults.temperature),maxStateTokens:Math.max(0,Math.floor(n.maxStateTokens??this.defaults.maxStateTokens)),truncation:n.truncation??this.defaults.truncation},s=await this.enqueue(()=>this.run(e,a,o));if(r)return s;let c={};return i.forEach((e,t)=>{c[e]=s[t]}),c}countTokens(e){return this.assertNotDisposed(),this.family.countTokens?this.family.countTokens(e):this.family.tokenize?this.family.tokenize({state:e,questions:[],encode:e=>this.encode(e)}).state.length:this.encode(e).length}async dispose(){if(!this.disposed){this.disposed=!0;try{await this.queue}catch{}await this.model.dispose?.()}}async run(e,t,n){try{if(this.family.decide){let r=await this.family.decide({model:this.model,state:e,questions:t,maxStateTokens:n.maxStateTokens,maxLength:this.maxLength});if(r.stateTruncated&&n.truncation===`error`)throw Error(`State was cut to ${r.stateTokens} tokens (limit ${n.maxStateTokens}, ${this.maxLength} in total). Shorten the state or the questions, or set truncation to "cut".`);return t.map((e,t)=>MN(e,r.logits[t],n.temperature))}let r=e=>this.encode(e),{state:i,questions:a}=this.family.tokenize?this.family.tokenize({state:e,questions:t,encode:r}):{state:r(e),questions:t.map(e=>({instructions:r(e.instructions),options:ON(e).map(r)}))},o=this.family.encode({state:i,questions:a,maxStateTokens:n.maxStateTokens,maxLength:this.maxLength});if(o.stateTruncated&&n.truncation===`error`)throw Error(`State was cut to ${o.stateTokens} tokens (limit ${n.maxStateTokens}, ${this.maxLength} in total). Shorten the state or the questions, or set truncation to "cut".`);let s={input_ids:hP(o.inputIds),attention_mask:hP(o.inputIds.map(()=>1))};for(let[e,t]of Object.entries(o.extraInputs))s[e]=hP(t);let{logits:c}=await this.model(s),l=Array.from(c.to(`float32`).data);return t.map((e,t)=>MN(e,o.groups[t].map(e=>l[e]),n.temperature))}catch(e){throw cP(e)}}encode(e){let{input_ids:t}=this.tokenizer(this.family.escape(e),{add_special_tokens:!1});return Array.from(t.data,Number)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.catch(()=>{}),t}assertNotDisposed(){if(this.disposed)throw Error(`OpenJev instance has been disposed.`)}};function hP(e){return new J(`int64`,BigInt64Array.from(e,BigInt),[1,e.length])}var gP=`https://huggingface.co/datasets/LocalLLaMA/typed-decisions`;async function _P(e){let t=await fetch(e);if(!t.ok)throw Error(`Benchmark data: HTTP ${t.status}`);return(await t.json()).map(e=>{let t=typeof e.questions==`string`?JSON.parse(e.questions):e.questions,n=typeof e.gold==`string`?JSON.parse(e.gold):e.gold,r={},i={};for(let[e,a]of Object.entries(t)){if(a.type===`choice`){let t=a.criteria;r[e]=TN(a.instructions,Object.keys(t),t)}else if(a.type===`score`)r[e]=EN(a.instructions,a.criteria);else{let t=a.criteria;r[e]=t?DN(a.instructions,t):DN(a.instructions)}i[e]={type:a.type,gold:String(n[e].label),levels:a.type===`score`?a.criteria:null}}return{state:e.state,workflow:e.workflow,questions:r,specs:i}})}function vP(e,t){if(e.type===`choice`)return e.choice===t.gold;if(e.type===`noul`)return String(e.answer)===t.gold;let n=Object.entries(e.probabilities).sort((e,t)=>t[1]-e[1])[0][0];return String(t.levels.indexOf(n))===t.gold}var yP={agent_trace_observability:`Agent traces`,customer_service:`Customer service`,invoice_processing:`Invoices`,security_incidents:`Security incidents`},bP=([e,t])=>t?`${(100*e/t).toFixed(1)}%`:`—`,xP=e=>[e.choice[0]+e.score[0]+e.noul[0],e.choice[1]+e.score[1]+e.noul[1]],SP=e=>{if(!e.length)return 0;let t=[...e].sort((e,t)=>e-t);return t[Math.floor(t.length/2)]},CP=e=>pt.find(t=>t.alias===e)?.name??e;function wP({jev:e,onInstall:t,className:n=``}){let[r,i]=(0,S.useState)(`idle`),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(null),l=(0,S.useRef)(0),u=e?pt.find(t=>t.repo===e.runtime.model)?.alias:void 0,d=(0,S.useCallback)(async()=>{if(!e)return;let t=++l.current;i(`running`),c(null);try{let n=await _P(`/typed-decisions-test.json`),r={done:0,total:n.length,choice:[0,0],score:[0,0],noul:[0,0],workflows:{},times:[]};o({...r}),await e.decide(n[0].state,n[0].questions);for(let i of n){if(l.current!==t)return;let n=performance.now(),a=await e.decide(i.state,i.questions);r.times.push(performance.now()-n);for(let[e,t]of Object.entries(i.specs)){let n=vP(a[e],t);r[t.type][1]++;let o=r.workflows[i.workflow]??=[0,0];o[1]++,n&&(r[t.type][0]++,o[0]++)}r.done++,(r.done%10==0||r.done===r.total)&&o({...r,workflows:{...r.workflows},times:[...r.times]})}i(`done`)}catch(e){c(e instanceof Error?e.message:String(e)),i(`error`)}},[e]),f=r===`running`;return(0,j.jsxs)(`div`,{className:A(`flex flex-col gap-8`,n),children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,j.jsx)(xt,{children:`Benchmark`}),(0,j.jsxs)(`p`,{className:`max-w-3xl text-sm text-stone`,children:[`Five System One models on the same 2,000 typed questions:`,` `,(0,j.jsx)(`a`,{className:`font-semibold text-ink underline`,href:gP,target:`_blank`,rel:`noreferrer`,children:`typed-decisions`}),` `,`(test split), 400 states from four workflows, each with 3 kinds of question. A question is correct when the model's top answer matches the annotators' label. Every state is one`,` `,(0,j.jsx)(`code`,{className:`font-mono`,children:`decide()`}),` call with its 5 questions.`]})]}),(0,j.jsxs)(bt,{padding:`lg`,className:`flex flex-col gap-5 overflow-x-auto`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,j.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Results`}),(0,j.jsx)(gt,{tone:`outline`,size:`sm`,className:`font-mono`,children:Ft})]}),(0,j.jsxs)(`table`,{className:`w-full min-w-[640px] text-left text-sm`,children:[(0,j.jsx)(`thead`,{className:`text-xs text-stone uppercase`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`py-2 pr-4 font-medium`,children:`Model`}),(0,j.jsx)(`th`,{className:`py-2 pr-4 font-medium`,children:`dtype`}),(0,j.jsx)(`th`,{className:`py-2 pr-4 text-right font-medium`,children:`choice`}),(0,j.jsx)(`th`,{className:`py-2 pr-4 text-right font-medium`,children:`score`}),(0,j.jsx)(`th`,{className:`py-2 pr-4 text-right font-medium`,children:`noul`}),(0,j.jsx)(`th`,{className:`py-2 pr-4 text-right font-medium`,children:`overall`}),(0,j.jsx)(`th`,{className:`py-2 text-right font-medium`,children:`median / state`})]})}),(0,j.jsxs)(`tbody`,{className:`font-mono`,children:[Pt.map(e=>(0,j.jsxs)(`tr`,{className:A(`border-t border-cream`,{"bg-lime/30":e.alias===u}),children:[(0,j.jsx)(`td`,{className:`py-2 pr-4 font-sans font-semibold`,children:CP(e.alias)}),(0,j.jsx)(`td`,{className:`py-2 pr-4`,children:e.dtype}),(0,j.jsx)(`td`,{className:`py-2 pr-4 text-right`,children:bP(e.choice)}),(0,j.jsx)(`td`,{className:`py-2 pr-4 text-right`,children:bP(e.score)}),(0,j.jsx)(`td`,{className:`py-2 pr-4 text-right`,children:bP(e.noul)}),(0,j.jsx)(`td`,{className:`py-2 pr-4 text-right font-bold`,children:bP(xP(e))}),(0,j.jsxs)(`td`,{className:`py-2 text-right`,children:[Math.round(e.medianMs),` ms`]})]},e.alias)),a&&a.done>0&&(0,j.jsxs)(`tr`,{className:`border-t-2 border-ink`,children:[(0,j.jsxs)(`td`,{className:`py-2 pr-4 font-sans font-semibold`,children:[`Your run · `,CP(u??``),` `,r===`running`&&`(${a.done}/${a.total})`]}),(0,j.jsx)(`td`,{className:`py-2 pr-4`,children:e?.runtime.dtype}),(0,j.jsx)(`td`,{className:`py-2 pr-4 text-right`,children:bP(a.choice)}),(0,j.jsx)(`td`,{className:`py-2 pr-4 text-right`,children:bP(a.score)}),(0,j.jsx)(`td`,{className:`py-2 pr-4 text-right`,children:bP(a.noul)}),(0,j.jsx)(`td`,{className:`py-2 pr-4 text-right font-bold`,children:bP(xP(a))}),(0,j.jsxs)(`td`,{className:`py-2 text-right`,children:[Math.round(SP(a.times)),` ms`]})]})]})]}),(0,j.jsxs)(`table`,{className:`w-full min-w-[640px] text-left text-sm`,children:[(0,j.jsx)(`thead`,{className:`text-xs text-stone uppercase`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`py-2 pr-4 font-medium`,children:`Overall by workflow`}),Object.values(yP).map(e=>(0,j.jsx)(`th`,{className:`py-2 pr-4 text-right font-medium`,children:e},e))]})}),(0,j.jsx)(`tbody`,{className:`font-mono`,children:Pt.map(e=>(0,j.jsxs)(`tr`,{className:`border-t border-cream`,children:[(0,j.jsx)(`td`,{className:`py-2 pr-4 font-sans font-semibold`,children:CP(e.alias)}),Object.keys(yP).map(t=>(0,j.jsx)(`td`,{className:`py-2 pr-4 text-right`,children:bP(e.workflows[t]??[0,0])},t))]},e.alias))})]})]}),(0,j.jsxs)(bt,{variant:`dark`,padding:`lg`,className:`flex flex-col gap-4`,children:[(0,j.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Run it on your GPU`}),e?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`p`,{className:`text-sm text-white/70`,children:[`Runs all 400 states with the loaded model (`,CP(u??e.runtime.model),` · `,e.runtime.device,` `,`· `,e.runtime.dtype,`). It takes from under a minute to about ten, depending on the model and your GPU.`]}),a&&(0,j.jsx)(kt,{value:a.total?a.done/a.total:0,tone:`lime`}),(0,j.jsx)(`div`,{children:(0,j.jsx)(vt,{variant:r===`done`?`accent`:`primary`,icon:r===`done`?(0,j.jsx)(Ke,{size:18}):(0,j.jsx)(We,{size:18}),disabled:f,onClick:d,children:f?`Running ${a?.done??0} / ${a?.total??400}`:r===`done`?`Run again`:`Run benchmark`})}),s&&(0,j.jsxs)(`p`,{className:`text-sm text-rose`,children:[`Benchmark failed: `,s]})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`text-sm text-white/70`,children:`Load a model first, then come back here to benchmark it on this device.`}),(0,j.jsx)(`div`,{children:(0,j.jsx)(vt,{variant:`accent`,icon:(0,j.jsx)(Se,{size:18}),onClick:t,children:`Choose a model`})})]})]}),(0,j.jsxs)(bt,{variant:`cream`,padding:`md`,className:`flex flex-col gap-2 text-sm text-stone`,children:[(0,j.jsx)(`h3`,{className:`text-base font-semibold text-ink`,children:`Read the numbers with care`}),(0,j.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5`,children:[(0,j.jsx)(`li`,{children:`This is Julia 1's own evaluation set, from the workflows it was built for. The other models were trained on different domains (open-jev: banking, reviews, Wikipedia yes/no; Kev: ten others; GLiNER2.5-Decide: 17 operational domains). On the demo's short messages the ranking looks different, so measure on your own questions.`}),(0,j.jsx)(`li`,{children:`The noul questions come with a description of each outcome. Only Julia 1 reads them; without them its noul score is 65.2%. The other models answer with fixed no/yes options.`}),(0,j.jsx)(`li`,{children:`States are JSON documents, median about 255 tokens. open-jev reads the first 256 state tokens and GLiNER2.5-Decide 384, so long states are cut for them.`}),(0,j.jsx)(`li`,{children:`Each model ran at its automatic dtype, once. Julia 1's row reproduces its model card's CPU numbers exactly (426/600, 542/800, 483/600).`})]})]})]})}function TP(e,t){let n=e[t];if(n?.type!==`choice`)throw Error(`${t} is not a choice`);return n}function EP(e,t){let n=e[t];if(n?.type!==`score`)throw Error(`${t} is not a score`);return n}function DP(e,t){let n=e[t];if(n?.type!==`noul`)throw Error(`${t} is not a noul`);return n}function OP(e){return e.type===`choice`?e.choice:e.type===`score`?e.level:e.answer?`Yes`:`No`}function kP(e){return e.type===`noul`?e.probability:e.confidence}var AP={approve:`mint`,"needs review":`lavender`,remove:`rose`},jP={id:`comment-moderation`,title:`Comment moderation`,tag:`Community`,tone:`periwinkle`,icon:Be,description:`Approve, flag or remove user comments and tag each one with a calibrated sentiment level.`,stateLabel:`Comment`,questions:{action:TN(`What should a moderator do with this comment?`,[`approve`,`needs review`,`remove`],{approve:`civil and on topic`,"needs review":`borderline, a human should look at it`,remove:`harassment, hate, threats or spam`}),sentiment:EN(`How positive is the sentiment of this comment?`,[`very negative`,`negative`,`neutral`,`positive`,`very positive`]),toxic:DN(`Is this comment abusive?`,{false:`The comment is civil, even if it disagrees.`,true:`The comment insults, harasses or threatens someone.`}),spam:DN(`The comment promotes a product, offer or link.`,{false:`The comment is a genuine reaction with nothing to sell.`,true:`The comment advertises a product, an offer or a link.`})},labels:{action:`Action`,sentiment:`Sentiment`,toxic:`Toxic`,spam:`Spam`},items:[{id:`c1`,label:`@maya_reads`,meta:`on "Our 2026 roadmap"`,text:`Honestly this is the best update you have shipped in years. The offline mode alone saves me hours every week. Thank you for actually listening to feedback!`},{id:`c2`,label:`@grumpy_dev`,meta:`on "Our 2026 roadmap"`,text:`Another roadmap, another year of the same bugs. I have reported the sync issue four times. Not angry, just tired. Please fix the basics before adding AI features.`},{id:`c3`,label:`@kingsley99`,meta:`on "Community guidelines"`,text:`Whoever wrote this is a clueless idiot. Get a real job, nobody asked for your worthless opinion. People like you ruin every forum.`},{id:`c4`,label:`@dealsdaily`,meta:`on "Community guidelines"`,text:`Make $500 a day from home!!! Limited spots, click the link in my profile now and use code FAST50 for a bonus. Don't miss out!!!`},{id:`c5`,label:`@renata.v`,meta:`on "Pricing changes"`,text:`I get that prices go up, but a 40% jump with two weeks notice is rough for small teams. Would a grandfathered plan be possible? Otherwise we'll probably have to look elsewhere.`}],summarize:e=>{let t=TP(e,`action`),n=EP(e,`sentiment`),r=DP(e,`toxic`);return{headline:t.choice,tone:AP[t.choice]??`periwinkle`,detail:r.answer?`Toxic`:n.level}},code:`import { OpenJev, choice, noul, score } from "open-jev"; + +const jev = await OpenJev.load({ model: "kev-0.6b" }); + +const [action, sentiment, toxic, spam] = await jev.decide(comment, [ + choice( + "What should a moderator do with this comment?", + ["approve", "needs review", "remove"], + { + approve: "civil and on topic", + "needs review": "borderline, a human should look at it", + remove: "harassment, hate, threats or spam", + } + ), + score("How positive is the sentiment of this comment?", [ + "very negative", + "negative", + "neutral", + "positive", + "very positive", + ]), + noul("Is this comment abusive?", { false: "The comment is civil, even if it disagrees.", true: "The comment insults, harasses or threatens someone." }), + noul("The comment promotes a product, offer or link.", { false: "The comment is a genuine reaction with nothing to sell.", true: "The comment advertises a product, an offer or a link." }), +]); + +action.choice; // "approve" | "needs review" | "remove" +action.probabilities; // { approve: 0.03, "needs review": 0.11, remove: 0.86 } +sentiment.normalized; // 0..1 across the five levels +toxic.answer && spam.answer; // both plain booleans`},MP={low:`mint`,medium:`periwinkle`,high:`lavender`,urgent:`rose`},NP={id:`email-triage`,title:`Email triage`,tag:`Inbox`,tone:`lime`,icon:Re,description:`Sort an inbox by category and priority, and spot which mails actually need a human reply.`,stateLabel:`Email`,questions:{category:TN(`What is this email about?`,[`billing`,`technical issue`,`sales inquiry`,`partnership`,`newsletter or spam`]),priority:EN(`How urgent is this email?`,[`low`,`medium`,`high`,`urgent`]),needsReply:DN(`The sender expects a personal reply.`,{false:`No personal answer is needed.`,true:`The sender is waiting for a personal answer.`}),isAutomated:DN(`This email was sent by an automated system.`,{false:`A person wrote this email.`,true:`A system, service or mailing list sent this email.`})},labels:{category:`Category`,priority:`Priority`,needsReply:`Needs reply`,isAutomated:`Automated`},items:[{id:`e1`,label:`Payment failed twice`,meta:`from dana@brightloop.io`,text:`Hi, our card was declined twice this morning even though it works everywhere else. We have a client demo at 2pm and the workspace is now locked. Can someone unlock it right away? Happy to pay by invoice if that is faster.`},{id:`e2`,label:`Your weekly digest is here`,meta:`from noreply@stackfeed.app`,text:`Here is what happened in your workspaces this week: 14 new comments, 3 completed projects and 2 new members. You are receiving this because you subscribed to weekly digests. Unsubscribe at any time from your notification settings.`},{id:`e3`,label:`Pricing for 40 seats`,meta:`from m.okafor@northwind.co`,text:`Hello, we are evaluating tools for our support team of about 40 people. Could you send over pricing for the business plan and let me know if you offer annual discounts? We would like to decide by the end of the quarter.`},{id:`e4`,label:`Export button does nothing`,meta:`from tom@wildoak.studio`,text:`Since yesterday's update the CSV export button just spins and never downloads anything. Tried Chrome and Firefox, cleared cache. Not blocking us today but we need the exports for month-end reporting next week.`},{id:`e5`,label:`Guest post opportunity`,meta:`from outreach@linkgrowth.biz`,text:`Hi there! I came across your blog and loved it. I would like to contribute a high-quality guest post with a do-follow link to our client. We can also offer a bulk deal for 10 articles. Let me know your rates!`}],summarize:e=>{let t=TP(e,`category`),n=EP(e,`priority`),r=DP(e,`needsReply`);return{headline:`${n.level} · ${t.choice}`,tone:MP[n.level]??`periwinkle`,detail:r.answer?`Reply needed`:`No reply needed`}},code:`import { OpenJev, choice, noul, score } from "open-jev"; + +const jev = await OpenJev.load({ model: "kev-0.6b" }); + +const triage = await jev.decide(email.body, { + category: choice("What is this email about?", [ + "billing", + "technical issue", + "sales inquiry", + "partnership", + "newsletter or spam", + ]), + priority: score("How urgent is this email?", [ + "low", + "medium", + "high", + "urgent", + ]), + needsReply: noul("The sender expects a personal reply.", { false: "No personal answer is needed.", true: "The sender is waiting for a personal answer." }), + isAutomated: noul("This email was sent by an automated system.", { false: "A person wrote this email.", true: "A system, service or mailing list sent this email." }), +}); + +triage.category.choice; // "billing" | "technical issue" | ... +triage.priority.level; // "low" | "medium" | "high" | "urgent" +triage.priority.score; // 0..3, may fall between levels +triage.needsReply.answer; // boolean +triage.isAutomated.probability; // p(yes), 0..1`};function PP(e,t,n,r){return Math.round(100*(.45*e+.25*t+.2*n+.1*r))}var FP={individual:.1,"small business":.4,"mid-market":.7,enterprise:1};function IP(e){return e>=70?`lime`:e>=40?`periwinkle`:`rose`}var LP={id:`lead-scoring`,title:`Lead scoring`,tag:`Sales`,tone:`lavender`,icon:Xe,description:`Turn inbound messages into a 0 to 100 lead score from intent, budget, authority and company size.`,stateLabel:`Inbound message`,questions:{intent:EN(`How close is this person to buying?`,[`just browsing`,`curious`,`evaluating options`,`ready to buy`]),company:TN(`What kind of organisation is the sender from?`,[`individual`,`small business`,`mid-market`,`enterprise`]),budget:DN(`The sender mentions a budget or a willingness to pay.`,{false:`Nothing about budget, price or paying.`,true:`The sender mentions a budget, pricing or being ready to pay.`}),decisionMaker:DN(`The sender can make the purchasing decision.`,{false:`Someone else decides on the purchase.`,true:`The sender can approve the purchase.`})},labels:{intent:`Buying intent`,company:`Company size`,budget:`Has budget`,decisionMaker:`Decision maker`},items:[{id:`l1`,label:`Priya S.`,meta:`VP Operations, contact form`,text:`We are a logistics company with around 1,200 employees and I lead the operations group. We have budget approved for a rollout in Q1 and are comparing three vendors. Can we schedule a technical call this week? I make the final call on this purchase.`},{id:`l2`,label:`jordan.k`,meta:`Free plan, in-app chat`,text:`hey just poking around, is there a student discount? I'm working on a side project for a class and might use this if it's cheap or free.`},{id:`l3`,label:`Luis M.`,meta:`Founder, contact form`,text:`I run a small design studio (six people). We've outgrown spreadsheets and your tool looks like a good fit. Not in a rush, but if the team plan is under $200 a month I'd probably sign up next month after our current projects wrap.`},{id:`l4`,label:`Aiko T.`,meta:`Engineer, contact form`,text:`I'm an engineer at a large bank and I tried your API in a hackathon last week. I like it a lot, but procurement here is a long process and I'd need to convince my director first. Do you have security documentation I could forward?`},{id:`l5`,label:`Nate B.`,meta:`Newsletter reply`,text:`Interesting article on decision models. Curious how this compares to fine-tuning a small classifier ourselves. Not looking to buy anything, just interested in the approach.`}],summarize:e=>{let t=EP(e,`intent`),n=TP(e,`company`),r=DP(e,`budget`),i=DP(e,`decisionMaker`),a=PP(t.normalized,r.probability,i.probability,FP[n.choice]??0);return{headline:`${a} / 100`,tone:IP(a),detail:t.level}},code:`import { OpenJev, choice, noul, score } from "open-jev"; + +const jev = await OpenJev.load({ model: "kev-0.6b" }); + +const lead = await jev.decide(message, { + intent: score("How close is this person to buying?", [ + "just browsing", + "curious", + "evaluating options", + "ready to buy", + ]), + company: choice("What kind of organisation is the sender from?", [ + "individual", + "small business", + "mid-market", + "enterprise", + ]), + budget: noul("The sender mentions a budget or a willingness to pay.", { false: "Nothing about budget, price or paying.", true: "The sender mentions a budget, pricing or being ready to pay." }), + decisionMaker: noul("The sender can make the purchasing decision.", { false: "Someone else decides on the purchase.", true: "The sender can approve the purchase." }), +}); + +// Probabilities are calibrated, so they can be combined into a score. +const companyWeight = { + individual: 0.1, + "small business": 0.4, + "mid-market": 0.7, + enterprise: 1, +}[lead.company.choice]; + +const leadScore = Math.round( + 100 * + (0.45 * lead.intent.normalized + + 0.25 * lead.budget.probability + + 0.2 * lead.decisionMaker.probability + + 0.1 * companyWeight) +);`},RP={low:`mint`,medium:`periwinkle`,high:`lavender`,critical:`rose`},zP=[NP,jP,LP,{id:`ticket-routing`,title:`Support ticket routing`,tag:`Support`,tone:`mint`,icon:Qe,description:`Send each ticket to the right team with an urgency level and an early warning for churn risk.`,stateLabel:`Ticket`,questions:{team:TN(`Which team should handle this ticket?`,[`billing`,`technical support`,`account & security`,`shipping`,`sales`],{billing:`charges, invoices, refunds and payment problems`,"technical support":`bugs, errors, integrations and outages`,"account & security":`logins, passwords, 2FA and suspicious activity`,shipping:`deliveries, tracking, damaged or missing parcels`,sales:`plans, upgrades, quotes and pre-sales questions`}),urgency:EN(`How urgent is this ticket?`,[`low`,`medium`,`high`,`critical`]),churnRisk:DN(`The customer threatens to cancel or switch to a competitor.`,{false:`The customer wants help and shows no sign of leaving.`,true:`The customer says they may cancel or move to a competitor.`}),resolved:DN(`The customer says the problem is already solved.`,{false:`The customer still has the problem.`,true:`The customer says the problem is fixed and nothing is left to do.`})},labels:{team:`Team`,urgency:`Urgency`,churnRisk:`Churn risk`,resolved:`Already solved`},items:[{id:`t1`,label:`#4821`,meta:`Pro plan · 2 min ago`,text:`I was charged twice for the same order and nobody answers my emails. This is the third time this year. If this is not refunded by tomorrow I am cancelling and moving to your competitor.`},{id:`t2`,label:`#4822`,meta:`Free plan · 9 min ago`,text:`Someone logged into my account from a country I have never been to and changed the recovery email. I cannot get back in. Please help, I have customer data in there.`},{id:`t3`,label:`#4823`,meta:`Business plan · 21 min ago`,text:`The webhook for order.created started returning 502 errors around 09:40 UTC. Our retries are piling up but nothing is lost yet. Is there a known incident?`},{id:`t4`,label:`#4824`,meta:`Starter plan · 1 h ago`,text:`My parcel shows as delivered since Monday but it never arrived. The neighbours don't have it either. Order number 88213. Could you check with the carrier?`},{id:`t5`,label:`#4825`,meta:`Starter plan · 3 h ago`,text:`Never mind my earlier message, the invoice PDF opened fine after I updated my browser. Sorry for the noise. While I have you: does the Business plan include SSO?`}],summarize:e=>{let t=TP(e,`team`),n=EP(e,`urgency`),r=DP(e,`churnRisk`),i=DP(e,`resolved`);return{headline:t.choice,tone:RP[n.level]??`periwinkle`,detail:i.answer?`Already solved`:r.answer?`${n.level} · churn risk`:n.level}},code:`import { OpenJev, choice, noul, score } from "open-jev"; + +const jev = await OpenJev.load({ model: "kev-0.6b" }); + +const ticket = await jev.decide(message, { + team: choice( + "Which team should handle this ticket?", + ["billing", "technical support", "account & security", "shipping", "sales"], + { + billing: "charges, invoices, refunds and payment problems", + "technical support": "bugs, errors, integrations and outages", + "account & security": "logins, passwords, 2FA and suspicious activity", + shipping: "deliveries, tracking, damaged or missing parcels", + sales: "plans, upgrades, quotes and pre-sales questions", + } + ), + urgency: score("How urgent is this ticket?", [ + "low", + "medium", + "high", + "critical", + ]), + churnRisk: noul("The customer threatens to cancel or switch to a competitor.", { false: "The customer wants help and shows no sign of leaving.", true: "The customer says they may cancel or move to a competitor." }), + resolved: noul("The customer says the problem is already solved.", { false: "The customer still has the problem.", true: "The customer says the problem is fixed and nothing is left to do." }), +}); + +if (ticket.resolved.answer) closeTicket(); +else assign(ticket.team.choice, { + priority: ticket.urgency.level, + escalate: ticket.churnRisk.probability > 0.7, +});`}];function BP(e){let t=zP.find(t=>t.id===e);if(!t)throw Error(`Unknown demo: ${e}`);return t}var VP=null,HP=!1;function UP(){return HP}function WP(){HP=!0}function GP(){return typeof navigator<`u`&&`gpu`in navigator}async function KP(e){return mP.info(e)}async function qP(e,t){return VP&&(await VP.dispose(),VP=null,HP=!1),VP=await mP.load({...e,onProgress:t}),VP}function JP({demo:e,open:t,onClose:n}){let[r,i]=(0,S.useState)(!1);return(0,j.jsx)(Dt,{open:t,onClose:n,title:`${e.title}: minimal implementation`,subtitle:`Everything this demo does, without the UI.`,actions:(0,j.jsx)(vt,{variant:r?`accent`:`secondary`,size:`sm`,onClick:async()=>{try{await navigator.clipboard.writeText(e.code),i(!0),setTimeout(()=>i(!1),1600)}catch{i(!1)}},icon:r?(0,j.jsx)(le,{size:16}):(0,j.jsx)(ye,{size:16}),children:r?`Copied`:`Copy`}),children:(0,j.jsxs)(`div`,{className:`flex flex-col gap-4 p-6`,children:[(0,j.jsx)(wt,{code:`npm install open-jev @huggingface/transformers`,language:`bash`,compact:!0}),(0,j.jsx)(wt,{code:e.code})]})})}function YP({value:e,onChange:t,disabled:n=!1,className:r=``}){return(0,j.jsx)(`div`,{role:`tablist`,"aria-label":`Demos`,className:A(`grid gap-4 sm:grid-cols-2 xl:grid-cols-4`,r),children:zP.map((r,i)=>{let a=r.id===e,o=r.icon;return(0,j.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,disabled:n,onClick:()=>t(r.id),style:{animationDelay:`${i*70}ms`},className:A(`group animate-fade-up relative flex flex-col gap-4 rounded-3xl p-5 text-left transition-all duration-300 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-periwinkle focus-visible:ring-offset-2 focus-visible:ring-offset-cream`,`disabled:cursor-not-allowed disabled:opacity-60`,{"bg-ink text-white shadow-lift":a,"bg-white text-ink shadow-card hover:-translate-y-1 hover:shadow-lift":!a}),children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsx)(gt,{tone:r.tone,size:`sm`,children:r.tag}),(0,j.jsx)(`span`,{className:A(`flex h-8 w-8 items-center justify-center rounded-full transition-all duration-300`,{"bg-lime text-ink":a,"bg-cream text-ink group-hover:bg-ink group-hover:text-white":!a}),children:(0,j.jsx)(o,{size:16})})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-lg font-semibold tracking-tight`,children:r.title}),(0,j.jsx)(`p`,{className:A(`mt-1 text-sm leading-snug`,{"text-white/70":a,"text-stone":!a}),children:r.description})]}),(0,j.jsxs)(`div`,{className:A(`mt-auto flex items-center gap-1.5 text-xs font-semibold`,{"text-lime":a,"text-stone group-hover:text-ink":!a}),children:[Object.keys(r.questions).length,` questions ·`,` `,r.items.length,` samples`,(0,j.jsx)(O,{size:14,className:A(`transition-transform duration-300`,{"translate-x-0.5":a,"group-hover:translate-x-0.5":!a})})]})]},r.id)})})}function XP(e){return e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function ZP(e){if(e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${(e/1024**n).toFixed(n>=2?2:0)} ${t[n]}`}function QP(e){return`${Math.round(e*100)}%`}function $P(e){if(e.type===`noul`)return[[`yes`,e.probability],[`no`,1-e.probability]];let t=Object.entries(e.probabilities);return e.type===`score`?t:t.sort((e,t)=>t[1]-e[1])}function eF(e){if(e.type===`score`){let t=Object.keys(e.probabilities).length-1;return`score ${e.score.toFixed(2)} / ${t}`}return e.type===`noul`?`p(yes) ${QP(e.probability)}`:`confidence ${QP(kP(e))}`}function tF({label:e,answer:t,className:n=``}){let r=OP(t),i=t.type===`noul`?t.answer?`mint`:`rose`:t.type===`score`?`lavender`:`periwinkle`;return(0,j.jsxs)(`div`,{className:A(`rounded-2xl bg-cream px-3 py-2.5`,n),children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-stone`,children:e}),(0,j.jsx)(`span`,{className:A(`inline-flex h-7 items-center rounded-full px-3 text-sm font-semibold capitalize`,{"bg-periwinkle text-white":i===`periwinkle`,"bg-lavender text-white":i===`lavender`,"bg-mint text-ink":i===`mint`,"bg-rose text-ink":i===`rose`}),children:r}),(0,j.jsx)(`span`,{className:`ml-auto font-mono text-xs text-stone tabular-nums`,children:eF(t)})]}),(0,j.jsx)(`div`,{className:`mt-2.5 flex flex-col gap-1.5`,children:$P(t).map(([e,t])=>(0,j.jsx)(Ot,{label:e,value:t,valueLabel:QP(t),tone:e===r.toLowerCase()?i:`ink`},e))})]})}function nF({demo:e,item:t,result:n,running:r,index:i,className:a=``}){let o=n?e.summarize(n.answers):null;return(0,j.jsxs)(bt,{padding:`none`,style:{animationDelay:`${i*60}ms`},className:A(`animate-fade-up overflow-hidden`,{"ring-2 ring-periwinkle":r},a),children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 p-5`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,j.jsx)(`div`,{className:`min-w-0`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`truncate font-semibold tracking-tight`,children:t.label}),t.meta&&(0,j.jsx)(`span`,{className:`truncate text-xs text-stone`,children:t.meta})]})}),(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[r&&(0,j.jsxs)(gt,{tone:`periwinkle`,size:`sm`,className:`animate-pulse-soft`,children:[(0,j.jsx)(Ie,{size:12,className:`animate-spin-slow`}),`Deciding`]}),o&&(0,j.jsx)(gt,{tone:o.tone,className:`animate-pop capitalize`,children:o.headline})]})]}),(0,j.jsx)(`p`,{className:`text-sm leading-relaxed text-stone`,children:t.text})]}),n&&(0,j.jsxs)(`div`,{className:`animate-fade-in flex flex-col gap-2 border-t border-ink/5 bg-white p-3`,children:[Object.entries(n.answers).map(([t,n],r)=>(0,j.jsx)(`div`,{className:`animate-fade-up`,style:{animationDelay:`${r*60}ms`},children:(0,j.jsx)(tF,{label:e.labels[t]??t,answer:n})},t)),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 px-2 pt-2 font-mono text-xs text-stone`,children:[(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(he,{size:12}),XP(n.durationMs),n.warmUp&&(0,j.jsx)(`span`,{className:`text-stone-light`,children:`incl. warm-up`})]}),(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(Ae,{size:12}),n.stateTokens,` state tokens`]}),o?.detail&&(0,j.jsx)(`span`,{className:`ml-auto capitalize text-ink`,children:o.detail})]})]})]})}var rF=140;function iF({demo:e,results:t,running:n,runtime:r,className:i=``}){let[a,o]=(0,S.useState)(null),s=t.map(e=>e.durationMs),c=s.reduce((e,t)=>e+t,0),l=t.filter(e=>!e.warmUp),u=l.reduce((e,t)=>e+t.durationMs,0),d=l.length>0?u/l.length:c/Math.max(1,t.length),f=s.length>0?Math.min(...s):0,p=s.length>0?Math.max(...s):0,m=t.length>0?Math.round(t.reduce((e,t)=>e+t.stateTokens,0)/t.length):0,h=Object.keys(e.questions).length,g=d>0?1e3/d*h:0,_=t.length>0,v=a??(_?t.length-1:null),y=v===null?null:t[v];return(0,j.jsxs)(bt,{variant:`dark`,padding:`lg`,className:A(`flex flex-col gap-6`,i),children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-2xl font-semibold tracking-tight`,children:`Timings`}),(0,j.jsxs)(`p`,{className:`mt-1 text-sm text-white/60`,children:[e.items.length,` states · `,h,` questions each`]})]}),(0,j.jsxs)(gt,{tone:`outline`,className:`border-white/15 font-mono text-white`,children:[r.device,` · `,r.dtype]})]}),(0,j.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,j.jsx)(`div`,{className:A(`animate-pop text-5xl font-semibold tracking-tight tabular-nums`,{"text-white/30":!_}),children:_?XP(c):`—`},t.length),(0,j.jsx)(`div`,{className:`mb-1.5 text-sm text-white/60`,children:n?(0,j.jsxs)(`span`,{className:`animate-pulse-soft flex items-center gap-1.5 text-lime`,children:[(0,j.jsx)(te,{size:14}),`running`]}):_?`total wall-clock`:`run the demo to measure`})]}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,j.jsx)(`div`,{className:`flex h-8 items-center justify-center`,children:y&&(0,j.jsxs)(`div`,{className:`animate-scale-in rounded-xl bg-white px-3 py-1.5 text-xs font-semibold text-ink`,children:[e.items[v??0]?.label,` ·`,` `,XP(y.durationMs),y.warmUp&&(0,j.jsx)(`span`,{className:`ml-1 font-normal text-stone`,children:`warm-up`})]},v)}),(0,j.jsx)(`div`,{className:`flex items-end gap-2`,style:{height:rF},role:`img`,"aria-label":`Decision time per state`,children:e.items.map((e,r)=>{let i=t[r],a=n&&r===t.length,s=i?Math.max(6,i.durationMs/Math.max(p,1)*rF):a?rF*.35:6,c=r===v;return(0,j.jsx)(`div`,{className:`group flex h-full flex-1 items-end`,onMouseEnter:()=>i&&o(r),onMouseLeave:()=>o(null),children:(0,j.jsx)(`div`,{className:A(`w-full origin-bottom rounded-t-lg rounded-b-sm transition-all duration-500 ease-out`,{"animate-grow-y bg-periwinkle":!!i&&c,"animate-grow-y bg-periwinkle-light":!!i&&!c,"animate-pulse-soft bg-lime/60":a,"bg-white/10":!i&&!a}),style:{height:s},title:i?`${e.label}: ${XP(i.durationMs)}`:e.label})},e.id)})}),(0,j.jsx)(`div`,{className:`flex gap-2`,children:e.items.map((e,t)=>(0,j.jsx)(`div`,{className:A(`flex-1 truncate text-center text-xs`,{"text-white":t===v,"text-white/45":t!==v}),children:t+1},e.id))})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,j.jsx)(aF,{label:`Avg per state`,value:_?XP(d):`—`,hint:l.length>0&&l.length{f.current+=1,r(e),a([]),s(`idle`),l(null)},g=(0,S.useCallback)(async()=>{let t=++f.current;a([]),s(`running`),l(null);try{for(let n of p.items){let r=!UP(),i=e.countTokens(n.text),o=performance.now(),s=await e.decide(n.text,p.questions),c=performance.now()-o;if(WP(),f.current!==t)return;a(e=>[...e,{itemId:n.id,answers:s,durationMs:c,stateTokens:i,warmUp:r}])}f.current===t&&s(`done`)}catch(e){if(f.current!==t)return;s(`error`),l(e instanceof Error?e.message:String(e))}},[p,e]),_=e=>i.find(t=>t.itemId===e),v=m?i.length:-1;return(0,j.jsxs)(`div`,{className:A(`flex flex-col gap-8`,t),children:[(0,j.jsxs)(`div`,{className:`animate-fade-up`,children:[(0,j.jsx)(xt,{count:zP.length,children:`Demos`}),(0,j.jsx)(`p`,{className:`mt-2 max-w-xl text-stone`,children:`Each demo is one call to decide() with a handful of typed questions. Pick one, run it over the sample states and inspect the distributions.`})]}),(0,j.jsx)(YP,{value:n,onChange:h,disabled:m}),(0,j.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-12`,children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-4 xl:col-span-7`,children:[(0,j.jsxs)(`div`,{className:`animate-fade-up flex flex-wrap items-center justify-between gap-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-xl font-semibold tracking-tight`,children:p.title}),(0,j.jsxs)(`p`,{className:`text-sm text-stone`,children:[p.items.length,` sample `,p.stateLabel.toLowerCase(),`s`]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(vt,{variant:`secondary`,icon:(0,j.jsx)(_e,{size:18}),onClick:()=>d(!0),children:`Code`}),(0,j.jsx)(vt,{variant:o===`done`?`accent`:`primary`,icon:o===`done`?(0,j.jsx)(Ke,{size:18}):(0,j.jsx)(We,{size:18}),disabled:m,onClick:g,children:m?`Running ${i.length+1} / ${p.items.length}`:o===`done`?`Run again`:`Run demo`})]})]}),o===`error`&&c&&(0,j.jsxs)(`div`,{className:`animate-fade-in rounded-2xl bg-rose-soft p-4 text-sm`,children:[(0,j.jsx)(`span`,{className:`font-semibold`,children:`Decision failed. `}),(0,j.jsx)(`span`,{className:`text-stone`,children:c})]}),(0,j.jsx)(`div`,{className:`flex flex-col gap-4`,children:p.items.map((e,t)=>(0,j.jsx)(nF,{demo:p,item:e,result:_(e.id),running:t===v,index:t},e.id))})]}),(0,j.jsx)(`div`,{className:`xl:col-span-5`,children:(0,j.jsx)(iF,{demo:p,results:i,running:m,runtime:e.runtime,className:`animate-fade-up xl:sticky xl:top-6`})})]},n),(0,j.jsx)(JP,{demo:p,open:u,onClose:()=>d(!1)})]})}var sF={julia:`julia-1`,gliner2:`gliner2-decide`,gliner:`gliner2-decide`,decide:`gliner2-decide`,kev:`kev-0.6b`};function cF(e=window.location.search){let t=new URLSearchParams(e),n=[t.get(`model`),...t.keys()].filter(e=>!!e);for(let e of n){let t=e.toLowerCase(),n=pt.find(e=>e.alias===t)?.alias??sF[t];if(n)return n}return null}function lF(){let e=new URLSearchParams(window.location.search);return window.location.hash===`#benchmark`||e.get(`page`)===`benchmark`||e.has(`benchmark`)?`benchmark`:null}function uF({options:e,value:t,sizes:n,onChange:r,disabled:i=!1,className:a=``}){return(0,j.jsx)(`div`,{role:`radiogroup`,"aria-label":`Weight variant`,className:A(`flex flex-wrap gap-2`,a),children:e.map(e=>{let a=e===t,o=n[e];return(0,j.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":a,disabled:i,onClick:()=>r(e),className:A(`flex h-10 items-center gap-2 rounded-full border px-4 text-sm font-semibold transition-all duration-200 ease-out active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-periwinkle focus-visible:ring-offset-2`,`disabled:cursor-not-allowed disabled:opacity-60 disabled:active:scale-100`,{"border-ink bg-ink text-white":a,"border-ink/10 bg-white text-ink hover:border-ink/30":!a}),children:[mt[e],o&&(0,j.jsx)(`span`,{className:A(`font-mono text-xs font-normal`,{"text-white/60":a,"text-stone":!a}),children:o})]},e)})})}var dF=[{icon:ae,title:`Typed, never generated`,text:`You pass the options. The answer is always one of them, so there is nothing to parse and no schema errors.`},{icon:we,title:`Calibrated probabilities`,text:`Every answer comes with a probability that means what it says. Higher confidence really is higher accuracy.`},{icon:Me,title:`One pass, many questions`,text:`The state is read once and every question is scored in parallel, so extra questions are almost free.`}];function fF({className:e=``}){return(0,j.jsxs)(bt,{variant:`dark`,padding:`lg`,className:A(`flex flex-col gap-6`,e),children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(gt,{tone:`lime`,size:`sm`,children:`Background`}),(0,j.jsx)(`h3`,{className:`mt-3 text-2xl font-semibold tracking-tight`,children:`What is Jev?`})]}),(0,j.jsx)(`a`,{href:ft,target:`_blank`,rel:`noreferrer`,className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20`,"aria-label":`Read the TypeSafe AI announcement`,children:(0,j.jsx)(re,{size:18})})]}),(0,j.jsxs)(`p`,{className:`text-sm leading-relaxed text-white/75`,children:[`Jev is a `,(0,j.jsx)(`span`,{className:`text-white`,children:`System One model`}),` by TypeSafe AI. Instead of chatting, it makes fast, calibrated decisions: one piece of text (the`,` `,(0,j.jsx)(`span`,{className:`font-mono text-lime`,children:`state`}),`) plus a set of typed questions go in, and a probability distribution per question comes out. Think of it as a frontier-quality function call for classify, route, score and branch, rather than a text generator.`]}),(0,j.jsx)(`ul`,{className:`flex flex-col gap-4`,children:dF.map(({icon:e,title:t,text:n},r)=>(0,j.jsxs)(`li`,{style:{animationDelay:`${150+r*80}ms`},className:`animate-fade-up flex gap-3`,children:[(0,j.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-white/10 text-lime`,children:(0,j.jsx)(e,{size:18})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`font-semibold`,children:t}),(0,j.jsx)(`div`,{className:`mt-0.5 text-sm text-white/65`,children:n})]})]},t))}),(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 rounded-2xl bg-white/5 p-4 text-center`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-lg font-semibold text-lime`,children:`choice`}),(0,j.jsx)(`div`,{className:`text-xs text-white/60`,children:`pick one option`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-lg font-semibold text-periwinkle-light`,children:`score`}),(0,j.jsx)(`div`,{className:`text-xs text-white/60`,children:`rate on a scale`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-lg font-semibold text-mint`,children:`noul`}),(0,j.jsx)(`div`,{className:`text-xs text-white/60`,children:`yes or no`})]})]})]})}function pF({info:e,infoLoading:t,status:n,progress:r,loadedBytes:i,totalBytes:a,error:o,webGpu:s,onLoad:c,className:l=``}){let u=n===`loading`,d=n===`ready`;return(0,j.jsxs)(`div`,{className:A(`flex flex-col gap-5`,l),children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,j.jsxs)(gt,{tone:s?`lime`:`neutral`,children:[(0,j.jsx)(ot,{size:14}),s?`WebGPU available`:`WebGPU unavailable, using WASM`]}),e&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(gt,{tone:`outline`,children:[(0,j.jsx)(Oe,{size:14}),e.isCached?`Cached in browser`:`Download ${ZP(e.downloadSize)}`]}),(0,j.jsxs)(gt,{tone:`outline`,children:[(0,j.jsx)(`span`,{className:`font-mono`,children:e.device}),(0,j.jsx)(`span`,{className:`text-stone`,children:`·`}),(0,j.jsx)(`span`,{className:`font-mono`,children:e.dtype})]})]}),t&&!e&&(0,j.jsxs)(gt,{tone:`outline`,className:`animate-pulse-soft`,children:[(0,j.jsx)(Ie,{size:14,className:`animate-spin-slow`}),`Checking cache`]})]}),e&&(0,j.jsxs)(`p`,{className:`text-sm text-stone`,children:[`Resolved to `,(0,j.jsx)(`span`,{className:`font-mono text-ink`,children:e.model}),`. Files are fetched once and kept in the browser cache.`]}),n===`error`&&o&&(0,j.jsxs)(`div`,{className:`animate-fade-in flex items-start gap-3 rounded-2xl bg-rose-soft p-4 text-sm text-ink`,children:[(0,j.jsx)(nt,{size:18,className:`mt-0.5 shrink-0`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`font-semibold`,children:`Could not load the model`}),(0,j.jsx)(`div`,{className:`mt-0.5 break-words text-stone`,children:o})]})]}),(0,j.jsx)(At,{progress:d?1:r,active:u,done:d,disabled:u||d,onClick:c,icon:u?(0,j.jsx)(Ie,{size:20,className:`animate-spin-slow`}):d?(0,j.jsx)(de,{size:20}):(0,j.jsx)(Se,{size:20}),trailing:u&&a>0?`${ZP(i)} / ${ZP(a)}`:void 0,children:u?a>0?`Loading model`:`Preparing session`:d?`Loaded, opening demo`:e?.isCached?`Load from cache`:`Download and load`})]})}function mF({value:e,onChange:t,disabled:n=!1,className:r=``}){return(0,j.jsx)(`div`,{role:`radiogroup`,"aria-label":`Model`,className:A(`grid gap-3 sm:grid-cols-3`,r),children:pt.map((r,i)=>{let a=r.alias===e;return(0,j.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":a,disabled:n,onClick:()=>t(r.alias),style:{animationDelay:`${i*70}ms`},className:A(`group animate-fade-up relative flex flex-col items-start gap-3 rounded-3xl border-2 p-5 text-left transition-all duration-300 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-periwinkle focus-visible:ring-offset-2`,`disabled:cursor-not-allowed disabled:opacity-60`,{"border-ink bg-ink text-white shadow-lift":a,"border-transparent bg-cream text-ink hover:-translate-y-0.5 hover:bg-cream-dark":!a}),children:[(0,j.jsxs)(`div`,{className:`flex w-full items-center justify-between`,children:[(0,j.jsx)(gt,{tone:r.tone,size:`sm`,children:r.tag}),(0,j.jsx)(`span`,{className:A(`flex h-6 w-6 items-center justify-center rounded-full transition-all duration-300`,{"animate-pop bg-lime text-ink":a,"bg-ink/10 text-transparent":!a}),children:(0,j.jsx)(le,{size:14,strokeWidth:3})})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`text-lg font-semibold tracking-tight`,children:r.name}),(0,j.jsxs)(`div`,{className:A(`mt-0.5 flex items-center gap-1.5 text-xs`,{"text-white/60":a,"text-stone":!a}),children:[(0,j.jsx)(xe,{size:12}),r.base]})]}),(0,j.jsx)(`p`,{className:A(`text-sm leading-snug`,{"text-white/75":a,"text-stone":!a}),children:r.note}),(0,j.jsxs)(`div`,{className:A(`mt-auto flex flex-wrap gap-1.5 text-xs`,{"text-white/60":a,"text-stone":!a}),children:[(0,j.jsxs)(`span`,{className:`font-mono`,children:[r.sizes.q4f16,` q4f16`]}),(0,j.jsx)(`span`,{children:`·`}),(0,j.jsxs)(`span`,{className:`font-mono`,children:[r.context.toLocaleString(),` ctx`]})]})]},r.alias)})})}var hF=`npm install open-jev @huggingface/transformers`,gF=`import { OpenJev, choice, noul, score } from "open-jev"; + +const jev = await OpenJev.load({ model: "kev-0.6b" }); + +const [area, mood, refund] = await jev.decide(text, [ + choice("Which area?", ["billing", "shipping", "other"]), + score("How positive?", ["negative", "neutral", "positive"]), + noul("The customer asks for a refund."), +]); + +area.choice; // "billing" | "shipping" | "other" +mood.level; // "negative" | "neutral" | "positive" +refund.answer; // boolean, with refund.probability`;function _F({className:e=``}){let[t,n]=(0,S.useState)(!1);return(0,j.jsxs)(bt,{padding:`lg`,className:A(`flex flex-col gap-5`,e),children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(gt,{tone:`periwinkle`,size:`sm`,children:[(0,j.jsx)(He,{size:12}),`npm`]}),(0,j.jsx)(`h3`,{className:`mt-3 text-2xl font-semibold tracking-tight`,children:`The open-jev package`})]}),(0,j.jsxs)(gt,{tone:`outline`,className:`font-mono`,children:[`v`,ct]})]}),(0,j.jsxs)(`p`,{className:`text-sm leading-relaxed text-stone`,children:[(0,j.jsx)(`span`,{className:`font-mono text-ink`,children:`open-jev`}),` is an open reproduction of the Jev shape that runs fully in the browser via`,` `,(0,j.jsx)(`a`,{href:dt,target:`_blank`,rel:`noreferrer`,className:`font-medium text-ink underline decoration-periwinkle decoration-2 underline-offset-2 transition-colors hover:text-periwinkle`,children:`Transformers.js`}),`. It ships five ONNX models, uses WebGPU when available and falls back to WebAssembly. Everything stays on the device, and the answers are fully typed from the options you pass in.`]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 rounded-2xl bg-cream p-2 pl-4`,children:[(0,j.jsxs)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-sm text-ink`,children:[(0,j.jsx)(`span`,{className:`text-stone`,children:`$ `}),hF]}),(0,j.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(hF),n(!0),setTimeout(()=>n(!1),1600)}catch{n(!1)}},"aria-label":`Copy install command`,className:A(`flex h-9 w-9 shrink-0 items-center justify-center rounded-xl transition-all duration-200 active:scale-95`,{"bg-lime text-ink":t,"bg-white text-ink hover:bg-ink hover:text-white":!t}),children:t?(0,j.jsx)(le,{size:16}):(0,j.jsx)(ye,{size:16})})]}),(0,j.jsx)(wt,{code:gF,compact:!0}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,j.jsxs)(`a`,{href:lt,target:`_blank`,rel:`noreferrer`,className:`inline-flex h-9 items-center gap-1.5 rounded-full bg-cream px-4 text-sm font-semibold text-ink transition-colors hover:bg-cream-dark`,children:[`npmjs.com`,(0,j.jsx)(re,{size:14})]}),(0,j.jsxs)(`a`,{href:ut,target:`_blank`,rel:`noreferrer`,className:`inline-flex h-9 items-center gap-1.5 rounded-full bg-cream px-4 text-sm font-semibold text-ink transition-colors hover:bg-cream-dark`,children:[`GitHub`,(0,j.jsx)(re,{size:14})]})]})]})}var vF=700;function yF({onLoaded:e,className:t=``}){let[n,r]=(0,S.useState)(()=>cF()??`kev-0.6b`),[i,a]=(0,S.useState)(`auto`),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(`idle`),[u,d]=(0,S.useState)(0),[f,p]=(0,S.useState)(0),[m,h]=(0,S.useState)(0),[g,_]=(0,S.useState)(null),v=(0,S.useMemo)(()=>GP(),[]),y=(0,S.useMemo)(()=>pt.find(e=>e.alias===n)??pt[0],[n]),b=`${n}:${i}`,x=o?.key===b?o.info:null,C=o?.key!==b;(0,S.useEffect)(()=>{let e=!1;return KP({model:n,dtype:i,device:`auto`}).then(t=>{e||s({key:b,info:t})}).catch(()=>{e||s({key:b,info:null})}),()=>{e=!0}},[n,i,b]);let ee=e=>{r(e),a(`auto`),l(`idle`),_(null)},w=(0,S.useCallback)(async()=>{l(`loading`),_(null),d(0),p(0),h(0);try{let t=await qP({model:n,dtype:i,device:`auto`},({progress:e,loaded:t,total:n})=>{d(e),p(t),h(n)});d(1),l(`ready`),setTimeout(()=>e(t),vF)}catch(e){l(`error`),_(e instanceof Error?e.message:String(e))}},[n,i,e]),T=c===`loading`||c===`ready`;return(0,j.jsxs)(`div`,{className:A(`grid gap-6 xl:grid-cols-12`,t),children:[(0,j.jsxs)(`div`,{className:`flex flex-col gap-6 xl:col-span-7`,children:[(0,j.jsxs)(`div`,{className:`animate-fade-up`,children:[(0,j.jsx)(xt,{children:`Install`}),(0,j.jsx)(`p`,{className:`mt-2 max-w-xl text-stone`,children:`Pick a model and a weight variant, then load it into this tab. The download happens once. After that, every decision runs locally on your GPU.`})]}),(0,j.jsxs)(bt,{padding:`lg`,className:`animate-fade-up flex flex-col gap-6`,children:[(0,j.jsx)(bF,{step:1,title:`Pick a model`}),(0,j.jsx)(mF,{value:n,onChange:ee,disabled:T})]}),(0,j.jsxs)(bt,{padding:`lg`,className:`animate-fade-up flex flex-col gap-5`,style:{animationDelay:`80ms`},children:[(0,j.jsx)(bF,{step:2,title:`Weight variant`,hint:`Auto picks the best variant for your GPU.`}),(0,j.jsx)(uF,{options:y.dtypes,value:i,sizes:y.sizes,onChange:a,disabled:T})]}),(0,j.jsxs)(bt,{padding:`lg`,className:`animate-fade-up flex flex-col gap-5`,style:{animationDelay:`160ms`},children:[(0,j.jsx)(bF,{step:3,title:`Load into the browser`}),(0,j.jsx)(pF,{info:x,infoLoading:C,status:c,progress:u,loadedBytes:f,totalBytes:m,error:g,webGpu:v,onLoad:w})]})]}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-6 xl:col-span-5`,children:[(0,j.jsxs)(`div`,{className:`animate-fade-up flex items-center gap-2 text-stone`,children:[(0,j.jsx)(Je,{size:18,className:`text-periwinkle`}),(0,j.jsx)(`span`,{className:`text-sm font-medium`,children:`Two things worth knowing`})]}),(0,j.jsx)(fF,{className:`animate-fade-up`}),(0,j.jsx)(_F,{className:`animate-fade-up`})]})]})}function bF({step:e,title:t,hint:n}){return(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(`span`,{className:`flex h-8 w-8 items-center justify-center rounded-full bg-lime text-sm font-bold text-ink`,children:e}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`text-lg font-semibold tracking-tight`,children:t}),n&&(0,j.jsx)(`p`,{className:`text-sm text-stone`,children:n})]})]})}function xF(){let[e,t]=(0,S.useState)(()=>lF()??`install`),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(`demo`),o=(0,S.useCallback)(e=>{r(e),t(i)},[i]),s=(0,S.useCallback)(e=>{a(e===`benchmark`?`benchmark`:`demo`),t(e)},[]);return(0,j.jsx)(`div`,{className:`min-h-screen p-3 sm:p-6 lg:p-8`,children:(0,j.jsxs)(`main`,{className:`mx-auto flex max-w-screen-2xl flex-col gap-8 rounded-4xl bg-cream p-5 shadow-frame sm:p-8`,children:[(0,j.jsx)(jt,{screen:e,demoReady:n!==null,runtime:n?.runtime??null,onNavigate:s}),(0,j.jsx)(`div`,{className:`animate-scale-in`,children:e===`benchmark`?(0,j.jsx)(wP,{jev:n,onInstall:()=>t(`install`)}):e===`demo`&&n?(0,j.jsx)(oF,{jev:n}):(0,j.jsx)(yF,{onLoaded:o})},e)]})})}(0,st.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(S.StrictMode,{children:(0,j.jsx)(xF,{})})); \ No newline at end of file