mettle
Version:
A approachable, fast, flexible JavaScript library for building user interfaces.
7 lines (6 loc) • 20.2 kB
JavaScript
/*!
* Mettle.js v1.7.6
* (c) 2021-2025 maomincoding
* Released under the MIT License.
*/
const t=Symbol.for("signals"),e=32;function n(){if(c>1)return void c--;let t,e=!1;for(;void 0!==i;){let n=i;for(i=void 0,a++;void 0!==n;){const o=n._nextBatchedEffect;if(n._nextBatchedEffect=void 0,n._flags&=-3,!(8&n._flags)&&h(n))try{n._callback()}catch(n){e||(t=n,e=!0)}n=o}}if(a=0,c--,e)throw t}function o(t){if(c>0)return t();c++;try{return t()}finally{n()}}let r,i;function s(t){const e=r;r=void 0;try{return t()}finally{r=e}}let c=0,a=0,u=0;function f(t){if(void 0===r)return;let n=t._node;return void 0===n||n._target!==r?(n={_version:0,_source:t,_prevSource:r._sources,_nextSource:void 0,_target:r,_prevTarget:void 0,_nextTarget:void 0,_rollbackNode:n},void 0!==r._sources&&(r._sources._nextSource=n),r._sources=n,t._node=n,r._flags&e&&t._subscribe(n),n):-1===n._version?(n._version=0,void 0!==n._nextSource&&(n._nextSource._prevSource=n._prevSource,void 0!==n._prevSource&&(n._prevSource._nextSource=n._nextSource),n._prevSource=r._sources,n._nextSource=void 0,r._sources._nextSource=n,r._sources=n),n):void 0}function l(t,e){this._value=t,this._version=0,this._node=void 0,this._targets=void 0,this._watched=e?.watched,this._unwatched=e?.unwatched,this.name=e?.name}function _(t,e){return new l(t,e)}function h(t){for(let e=t._sources;void 0!==e;e=e._nextSource)if(e._source._version!==e._version||!e._source._refresh()||e._source._version!==e._version)return!0;return!1}function p(t){for(let e=t._sources;void 0!==e;e=e._nextSource){const n=e._source._node;if(void 0!==n&&(e._rollbackNode=n),e._source._node=e,e._version=-1,void 0===e._nextSource){t._sources=e;break}}}function d(t){let e,n=t._sources;for(;void 0!==n;){const t=n._prevSource;-1===n._version?(n._source._unsubscribe(n),void 0!==t&&(t._nextSource=n._nextSource),void 0!==n._nextSource&&(n._nextSource._prevSource=t)):e=n,n._source._node=n._rollbackNode,void 0!==n._rollbackNode&&(n._rollbackNode=void 0),n=t}t._sources=e}function y(t,e){l.call(this,void 0),this._fn=t,this._sources=void 0,this._globalVersion=u-1,this._flags=4,this._watched=e?.watched,this._unwatched=e?.unwatched,this.name=e?.name}function g(t,e){return new y(t,e)}function v(t){const e=t._cleanup;if(t._cleanup=void 0,"function"==typeof e){c++;const o=r;r=void 0;try{e()}catch(e){throw t._flags&=-2,t._flags|=8,b(t),e}finally{r=o,n()}}}function b(t){for(let e=t._sources;void 0!==e;e=e._nextSource)e._source._unsubscribe(e);t._fn=void 0,t._sources=void 0,v(t)}function m(t){if(r!==this)throw new Error("Out-of-order effect");d(this),r=t,this._flags&=-2,8&this._flags&&b(this),n()}function w(t,n){this._fn=t,this._cleanup=void 0,this._sources=void 0,this._nextBatchedEffect=void 0,this._flags=e,this.name=n?.name}function S(t,e){const n=new w(t,e);try{n._callback()}catch(t){throw n._dispose(),t}const o=n._dispose.bind(n);return o[Symbol.dispose]=o,o}l.prototype.brand=t,l.prototype._refresh=function(){return!0},l.prototype._subscribe=function(t){const e=this._targets;e!==t&&void 0===t._prevTarget&&(t._nextTarget=e,this._targets=t,void 0!==e?e._prevTarget=t:s((()=>{this._watched?.call(this)})))},l.prototype._unsubscribe=function(t){if(void 0!==this._targets){const e=t._prevTarget,n=t._nextTarget;void 0!==e&&(e._nextTarget=n,t._prevTarget=void 0),void 0!==n&&(n._prevTarget=e,t._nextTarget=void 0),t===this._targets&&(this._targets=n,void 0===n&&s((()=>{this._unwatched?.call(this)})))}},l.prototype.subscribe=function(t){return S((()=>{const e=this.value,n=r;r=void 0;try{t(e)}finally{r=n}}),{name:"sub"})},l.prototype.valueOf=function(){return this.value},l.prototype.toString=function(){return this.value+""},l.prototype.toJSON=function(){return this.value},l.prototype.peek=function(){const t=r;r=void 0;try{return this.value}finally{r=t}},Object.defineProperty(l.prototype,"value",{get(){const t=f(this);return void 0!==t&&(t._version=this._version),this._value},set(t){if(t!==this._value){if(a>100)throw new Error("Cycle detected");this._value=t,this._version++,u++,c++;try{for(let t=this._targets;void 0!==t;t=t._nextTarget)t._target._notify()}finally{n()}}}}),y.prototype=new l,y.prototype._refresh=function(){if(this._flags&=-3,1&this._flags)return!1;if((36&this._flags)===e)return!0;if(this._flags&=-5,this._globalVersion===u)return!0;if(this._globalVersion=u,this._flags|=1,this._version>0&&!h(this))return this._flags&=-2,!0;const t=r;try{p(this),r=this;const t=this._fn();(16&this._flags||this._value!==t||0===this._version)&&(this._value=t,this._flags&=-17,this._version++)}catch(t){this._value=t,this._flags|=16,this._version++}return r=t,d(this),this._flags&=-2,!0},y.prototype._subscribe=function(t){if(void 0===this._targets){this._flags|=36;for(let t=this._sources;void 0!==t;t=t._nextSource)t._source._subscribe(t)}l.prototype._subscribe.call(this,t)},y.prototype._unsubscribe=function(t){if(void 0!==this._targets&&(l.prototype._unsubscribe.call(this,t),void 0===this._targets)){this._flags&=-33;for(let t=this._sources;void 0!==t;t=t._nextSource)t._source._unsubscribe(t)}},y.prototype._notify=function(){if(!(2&this._flags)){this._flags|=6;for(let t=this._targets;void 0!==t;t=t._nextTarget)t._target._notify()}},Object.defineProperty(y.prototype,"value",{get(){if(1&this._flags)throw new Error("Cycle detected");const t=f(this);if(this._refresh(),void 0!==t&&(t._version=this._version),16&this._flags)throw this._value;return this._value}}),w.prototype._callback=function(){const t=this._start();try{if(8&this._flags)return;if(void 0===this._fn)return;const t=this._fn();"function"==typeof t&&(this._cleanup=t)}finally{t()}},w.prototype._start=function(){if(1&this._flags)throw new Error("Cycle detected");this._flags|=1,this._flags&=-9,v(this),p(this),c++;const t=r;return r=this,m.bind(this,t)},w.prototype._notify=function(){2&this._flags||(this._flags|=2,this._nextBatchedEffect=i,i=this)},w.prototype._dispose=function(){this._flags|=8,1&this._flags||b(this)},w.prototype.dispose=function(){this._dispose()};function x(t){const e=Object.create(null),n=t.split(",");for(let t=0;t<n.length;t++)e[n[t]]=!0;return function(t){return e[t]}}const k=x("svg,animate,circle,clippath,cursor,image,defs,desc,ellipse,filter,font-face,foreignobject,g,glyph,line,marker,mask,missing-glyph,path,pattern,polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feFlood,feGaussianBlur,feImage,feMerge,feMorphology,feOffset,feSpecularLighting,feTile,feTurbulence,feDistantLight,fePointLight,feSpotLight,linearGradient,stop,radialGradient,animateTransform,animateMotion"),O={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};const A=Object.prototype.hasOwnProperty,P=(t,e)=>A.call(t,e),j=t=>null!==t&&"object"==typeof t,M=t=>null==t,z=(t,e)=>t.tag===e.tag&&t.key===e.key,C=t=>null!=t&&"object"==typeof t&&"tag"in t,E=t=>!C(t)&&!Array.isArray(t);function T(t){console.warn(`[Mettle.js warn]: ${t}`)}function F(t,e){Object.assign(t.style,e)}function N(t,e,n){if("function"!=typeof n)return;const o=e.slice(2).toLowerCase();t.addEventListener(o,n)}function D(t,e,n){if("function"!=typeof n)return;const o=e.slice(2).toLowerCase();t.removeEventListener(o,n)}const L="http://www.w3.org/1999/xlink",W=new Set(["checked","disabled","readonly","selected","multiple","hidden"]);function B(t,e,n){W.has(e)?n?t.setAttribute(e,""):t.removeAttribute(e):e.startsWith("xlink:")?t.setAttributeNS(L,e,n):t.setAttribute(e,n)}function R(t,e){e.startsWith("xlink:")?t.removeAttributeNS(L,e):t.removeAttribute(e)}const $=document.createElement.bind(document),K=document.createDocumentFragment.bind(document),G=document.createComment.bind(document);function U(t){return"fragment"===t?K():"comment"===t||"null"===t?G(""):k(t)?(e=function(t){return k(t)?"svg":"math"===t?"math":void 0}(t),n=t,document.createElementNS(O[e],n)):$(t);var e,n}function V(t,e){const n=t.children,o=e.children;if(Array.isArray(o))for(let t=0;t<o.length;t++){const e=o[t],r=n[t];C(e)&&(e.el=r.el,V(r,e))}else j(o)&&(o.el=n.el)}const H="1.7.6",I=x("$ref,$once,$memo");let q=new WeakMap;const J=new WeakMap;let Q=new WeakMap;function X(t,e){e.textContent=t}function Y(t,e,n){const{tag:o,props:r,children:i}=t;if(!M(o))if("string"==typeof o){const s=U(o);if(t.el=s,!M(r)){const t=Object.keys(r);for(let e=0;e<t.length;e++){const n=t[e],o=r[n],i=j(o);n.startsWith("on")&&N(s,n,o),"function"==typeof o||"key"===n||I(n)||B(s,n,o),"style"===n&&i&&F(s,o),"$ref"===n&&i&&J.set(o,s)}}if(!M(i))if(E(i))s&&X(i,s);else{const t=j(i);if(Array.isArray(i))for(let t=0;t<i.length;t++){const e=i[t];C(e)&&Y(e,s)}else t&&Y(i,s)}if(n)e.insertBefore(s,n);else{if(!e)return s;e.appendChild(s)}}else if("function"==typeof o){const t=et(o.call(o,r,o,tt.bind(o)),o);q.set(o,t),Y(t,e)}}function Z(t,e,n){const o=t.props||{};if(!P(o,"$once")&&((t,e)=>"function"!=typeof t.tag&&"function"!=typeof e.tag)(t,e))if(z(t,e)){const o=e.el=t.el,r=t.props||{},i=e.props||{},s={},c=Object.keys(i),a=Object.keys(r),u=new Set(c);for(let t=0;t<c.length;t++)s[c[t]]=!0;for(let t=0;t<a.length;t++)s[a[t]]=!0;const f=Object.keys(s);for(let t=0;t<f.length;t++){const e=f[t],n=i[e],s=r[e];if(n===s)continue;if(M(n)){R(o,e);continue}const c=j(n),a="function"==typeof n,u="style"===e;if(a){n.toString()!==s.toString()&&(D(o,e,s),N(o,e,n));continue}if(u&&c){F(o,n);continue}"key"!==e&&!I(e)&&!a&&B(o,e,n)}for(let t=0;t<a.length;t++){const e=a[t];u.has(e)||R(o,e)}if(P(r,"$memo")){const o=r.$memo;if(n===o[1]&&!o[0])return void(o[2]&&V(t,e))}const l=t.children,_=e.children;Array.isArray(l)&&Array.isArray(_)?function(t,e,n,o){const r=e.length;let i=0,s=t.length-1,c=r-1;for(;i<=s&&i<=c&&z(t[i],e[i]);)Z(t[i],e[i],o),i++;for(;i<=s&&i<=c&&z(t[s],e[c]);)Z(t[s],e[c],o),s--,c--;if(i>s){if(i<=c){const t=c+1,o=t<r?e[t].el:null;for(;i<=c;)n.insertBefore(Y(e[i]),o),i++}}else if(i>c)for(;i<=s;)n.removeChild(t[i].el),i++;else{const a=i,u=i,f=new Map;for(i=u;i<=c;i++){const t=e[i];null!=t.key&&f.set(t.key,i)}let l,_=0;const h=c-u+1;let p=!1,d=0;const y=new Array(h);for(i=0;i<h;i++)y[i]=0;for(let r=a;r<=s;r++){if(_>=h){n.removeChild(t[r].el);continue}let i;if(null!==t[r].key)i=f.get(t[r].key);else for(l=u;l<=c;l++)if(0===y[l-u]&&z(t[r],e[l])){i=l;break}void 0===i?n.removeChild(t[r].el):(y[i-u]=r+1,i>d?d=i:p=!0,Z(t[r],e[i],o),_++)}const g=p?function(t){const e=t.slice(),n=[0];let o,r,i,s,c;const a=t.length;for(o=0;o<a;o++){const a=t[o];if(0!==a){if(r=n[n.length-1],t[r]<a){e[o]=r,n.push(o);continue}for(i=0,s=n.length-1;i<s;)c=(i+s)/2|0,t[n[c]]<a?i=c+1:s=c;a<t[n[i]]&&(i>0&&(e[o]=n[i-1]),n[i]=o)}}for(i=n.length,s=n[i-1];i-- >0;)n[i]=s,s=e[s];return n}(y):[];l=g.length-1;for(let t=h-1;t>=0;t--){const o=t+u,i=o+1<r?e[o+1].el:null;0===y[t]?n.insertBefore(Y(e[o]),i):p&&(l<0||t!==g[l]?n.insertBefore(e[o].el,i):l--)}}}(l,_,o,n):C(l)&&C(_)?Z(l,_,n):E(l)&&E(_)&&l!==_&&X(_,o)}else{const n=t.el.parentNode,o=t.el.nextSibling;n.removeChild(t.el),Y(e,n,o)}}function tt(t,e){Q.set(this,e),"function"==typeof t&&t()}function et(t,e){let n=!0;return S((()=>{e.template=t;const o=t();if(n)n=null;else{const t=Q.get(e);!function(t,e,n){try{Z(q.get(t),e,n),q.set(t,e)}catch(t){T(t)}}(e,o,t),Q.has(e)&&(Q=new WeakMap)}})),t()}function nt(t){if("string"==typeof t){const e=document.querySelector(t);if(!e){let e=null;return t.startsWith("#")?(e=document.createElement("div"),e.setAttribute("id",t.substring(1,t.length))):t.startsWith(".")?(e=document.createElement("div"),e.setAttribute("class",t.substring(1,t.length))):T(`Failed to mount app: mount target selector "${t}" returned null.`),document.body.insertAdjacentElement("afterbegin",e),e}return e}return t instanceof HTMLElement?t:window.ShadowRoot&&t instanceof window.ShadowRoot&&"closed"===t.mode?(T('mounting on a ShadowRoot with `{mode: "closed"}` may lead to unpredictable bugs.'),null):null}let ot=Object.create(null);function rt(t,e){const n=t.tag,o=et(n.call(n,t.props,n,tt.bind(n)),n),r=nt(e);Y(o,r),q.set(n,o),ot=r,ut()}let it=[],st=0,ct=0;function at(t=null){null!==t&&("function"==typeof t?it.push(t):T("The parameter of onMounted is not a function!"))}function ut(){if(it.length>0)for(let t=0,e=it.length;t<e;t++)it[t]&&it[t]();ct=st,st=0,it=[]}let ft=[];function lt(t=null){null!==t&&("function"==typeof t?(st+=1,ft.push(t)):T("The parameter of onUnmounted is not a function!"))}function _t(t,e){!function(){if(ft.length>0){for(let t=0;t<ct;t++)ft[t]&&ft[t]();ft.splice(0,ct)}ct=st}();const n=e?nt(e):ot;n.innerHTML="";const o=et(t.call(t,t,tt.bind(t)),t);Y(o,n),q.set(t,o),ut()}var ht=Symbol.for("immer-nothing"),pt=Symbol.for("immer-draftable"),dt=Symbol.for("immer-state");function yt(t,...e){throw new Error("Error")}var gt=Object.getPrototypeOf;function vt(t){return!!t&&!!t[dt]}function bt(t){return!!t&&(wt(t)||Array.isArray(t)||!!t[pt]||!!t.constructor?.[pt]||At(t)||Pt(t))}var mt=Object.prototype.constructor.toString();function wt(t){if(!t||"object"!=typeof t)return!1;const e=gt(t);if(null===e)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===mt}function St(t,e){0===xt(t)?Reflect.ownKeys(t).forEach((n=>{e(n,t[n],t)})):t.forEach(((n,o)=>e(o,n,t)))}function xt(t){const e=t[dt];return e?e.type_:Array.isArray(t)?1:At(t)?2:Pt(t)?3:0}function kt(t,e){return 2===xt(t)?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Ot(t,e,n){const o=xt(t);2===o?t.set(e,n):3===o?t.add(n):t[e]=n}function At(t){return t instanceof Map}function Pt(t){return t instanceof Set}function jt(t){return t.copy_||t.base_}function Mt(t,e){if(At(t))return new Map(t);if(Pt(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=wt(t);if(!0===e||"class_only"===e&&!n){const e=Object.getOwnPropertyDescriptors(t);delete e[dt];let n=Reflect.ownKeys(e);for(let o=0;o<n.length;o++){const r=n[o],i=e[r];!1===i.writable&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(e[r]={configurable:!0,writable:!0,enumerable:i.enumerable,value:t[r]})}return Object.create(gt(t),e)}{const e=gt(t);if(null!==e&&n)return{...t};const o=Object.create(e);return Object.assign(o,t)}}function zt(t,e=!1){return Et(t)||vt(t)||!bt(t)||(xt(t)>1&&(t.set=t.add=t.clear=t.delete=Ct),Object.freeze(t),e&&Object.entries(t).forEach((([t,e])=>zt(e,!0)))),t}function Ct(){yt()}function Et(t){return Object.isFrozen(t)}var Tt,Ft={};function Nt(t){const e=Ft[t];return e||yt(0),e}function Dt(){return Tt}function Lt(t,e){e&&(Nt("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Wt(t){Bt(t),t.drafts_.forEach($t),t.drafts_=null}function Bt(t){t===Tt&&(Tt=t.parent_)}function Rt(t){return Tt={drafts_:[],parent_:Tt,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function $t(t){const e=t[dt];0===e.type_||1===e.type_?e.revoke_():e.revoked_=!0}function Kt(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return void 0!==t&&t!==n?(n[dt].modified_&&(Wt(e),yt()),bt(t)&&(t=Gt(e,t),e.parent_||Vt(e,t)),e.patches_&&Nt("Patches").generateReplacementPatches_(n[dt].base_,t,e.patches_,e.inversePatches_)):t=Gt(e,n,[]),Wt(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==ht?t:void 0}function Gt(t,e,n){if(Et(e))return e;const o=e[dt];if(!o)return St(e,((r,i)=>Ut(t,o,e,r,i,n))),e;if(o.scope_!==t)return e;if(!o.modified_)return Vt(t,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;const e=o.copy_;let r=e,i=!1;3===o.type_&&(r=new Set(e),e.clear(),i=!0),St(r,((r,s)=>Ut(t,o,e,r,s,n,i))),Vt(t,e,!1),n&&t.patches_&&Nt("Patches").generatePatches_(o,n,t.patches_,t.inversePatches_)}return o.copy_}function Ut(t,e,n,o,r,i,s){if(vt(r)){const s=Gt(t,r,i&&e&&3!==e.type_&&!kt(e.assigned_,o)?i.concat(o):void 0);if(Ot(n,o,s),!vt(s))return;t.canAutoFreeze_=!1}else s&&n.add(r);if(bt(r)&&!Et(r)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;Gt(t,r),e&&e.scope_.parent_||"symbol"==typeof o||!Object.prototype.propertyIsEnumerable.call(n,o)||Vt(t,r)}}function Vt(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&zt(e,n)}var Ht={get(t,e){if(e===dt)return t;const n=jt(t);if(!kt(n,e))return function(t,e,n){const o=Jt(e,n);return o?"value"in o?o.value:o.get?.call(t.draft_):void 0}(t,n,e);const o=n[e];return t.finalized_||!bt(o)?o:o===qt(t.base_,e)?(Xt(t),t.copy_[e]=Yt(o,t)):o},has:(t,e)=>e in jt(t),ownKeys:t=>Reflect.ownKeys(jt(t)),set(t,e,n){const o=Jt(jt(t),e);if(o?.set)return o.set.call(t.draft_,n),!0;if(!t.modified_){const o=qt(jt(t),e),s=o?.[dt];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(((r=n)===(i=o)?0!==r||1/r==1/i:r!=r&&i!=i)&&(void 0!==n||kt(t.base_,e)))return!0;Xt(t),Qt(t)}var r,i;return t.copy_[e]===n&&(void 0!==n||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty:(t,e)=>(void 0!==qt(t.base_,e)||e in t.base_?(t.assigned_[e]=!1,Xt(t),Qt(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0),getOwnPropertyDescriptor(t,e){const n=jt(t),o=Reflect.getOwnPropertyDescriptor(n,e);return o?{writable:!0,configurable:1!==t.type_||"length"!==e,enumerable:o.enumerable,value:n[e]}:o},defineProperty(){yt()},getPrototypeOf:t=>gt(t.base_),setPrototypeOf(){yt()}},It={};function qt(t,e){const n=t[dt];return(n?jt(n):t)[e]}function Jt(t,e){if(!(e in t))return;let n=gt(t);for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t)return t;n=gt(n)}}function Qt(t){t.modified_||(t.modified_=!0,t.parent_&&Qt(t.parent_))}function Xt(t){t.copy_||(t.copy_=Mt(t.base_,t.scope_.immer_.useStrictShallowCopy_))}St(Ht,((t,e)=>{It[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}})),It.deleteProperty=function(t,e){return It.set.call(this,t,e,void 0)},It.set=function(t,e,n){return Ht.set.call(this,t[0],e,n,t[0])};function Yt(t,e){const n=At(t)?Nt("MapSet").proxyMap_(t,e):Pt(t)?Nt("MapSet").proxySet_(t,e):function(t,e){const n=Array.isArray(t),o={type_:n?1:0,scope_:e?e.scope_:Dt(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=o,i=Ht;n&&(r=[o],i=It);const{revoke:s,proxy:c}=Proxy.revocable(r,i);return o.draft_=c,o.revoke_=s,c}(t,e);return(e?e.scope_:Dt()).drafts_.push(n),n}function Zt(t){if(!bt(t)||Et(t))return t;const e=t[dt];let n;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=Mt(t,e.scope_.immer_.useStrictShallowCopy_)}else n=Mt(t,!0);return St(n,((t,e)=>{Ot(n,t,Zt(e))})),e&&(e.finalized_=!1),n}var te=new class{autoFreeze_;useStrictShallowCopy_;produce;produceWithPatches;constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,e,n)=>{if("function"==typeof t&&"function"!=typeof e){const n=e;e=t;const o=this;return function(t=n,...r){return o.produce(t,(t=>e.call(this,t,...r)))}}let o;if("function"!=typeof e&&yt(),void 0!==n&&"function"!=typeof n&&yt(),bt(t)){const r=Rt(this),i=Yt(t,void 0);let s=!0;try{o=e(i),s=!1}finally{s?Wt(r):Bt(r)}return Lt(r,n),Kt(o,r)}if(!t||"object"!=typeof t){if(o=e(t),void 0===o&&(o=t),o===ht&&(o=void 0),this.autoFreeze_&&zt(o,!0),n){const e=[],r=[];Nt("Patches").generateReplacementPatches_(t,o,e,r),n(e,r)}return o}yt(0)},this.produceWithPatches=(t,e)=>{if("function"==typeof t)return(e,...n)=>this.produceWithPatches(e,(e=>t(e,...n)));let n,o;return[this.produce(t,e,((t,e)=>{n=t,o=e})),n,o]},"boolean"==typeof t?.autoFreeze&&this.setAutoFreeze(t.autoFreeze),"boolean"==typeof t?.useStrictShallowCopy&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){bt(t)||yt(),vt(t)&&(t=function(t){vt(t)||yt(0);return Zt(t)}(t));const e=Rt(this),n=Yt(t,void 0);return n[dt].isManual_=!0,Bt(e),n}finishDraft(t,e){const n=t&&t[dt];n&&n.isManual_||yt();const{scope_:o}=n;return Lt(o,e),Kt(void 0,o)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const o=e[n];if(0===o.path.length&&"replace"===o.op){t=o.value;break}}n>-1&&(e=e.slice(n+1));const o=Nt("Patches").applyPatches_;return vt(t)?o(t,e):this.produce(t,(t=>o(t,e)))}},ee=te.produce;export{o as batch,g as computed,rt as createApp,J as domInfo,S as effect,at as onMounted,lt as onUnmounted,ee as produce,_t as resetView,_ as signal,s as untracked,H as version};