var i,n,r,t=require("preact"),e=require("preact/hooks"),o=require("@preact/signals-core"),f="undefined"!=typeof window&&!!window.__PREACT_SIGNALS_DEVTOOLS__,u=[],a=[];o.effect(function(){i=this.N})();function c(i,n){t.options[i]=n.bind(null,t.options[i]||function(){})}function v(i){if(r){var n=r;r=void 0;n()}r=i&&i.S()}function s(i){var n=this,r=i.data,f=useSignal(r);f.value=r;var u=e.useMemo(function(){var i=n,r=n.__v;while(r=r.__)if(r.__c){r.__c.__$f|=4;break}var e=o.computed(function(){var i=f.value.value;return 0===i?0:!0===i?"":i||""}),u=o.computed(function(){return!Array.isArray(e.value)&&!t.isValidElement(e.value)}),a=o.effect(function(){this.N=m;if(u.value){var n=e.value;if(i.__v&&i.__v.__e&&3===i.__v.__e.nodeType)i.__v.__e.data=n}}),c=n.__$u.d;n.__$u.d=function(){a();c.call(this)};return[u,e]},[]),a=u[0],c=u[1];return a.value?c.peek():c.value}s.displayName="ReactiveTextNode";Object.defineProperties(o.Signal.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:s},props:{configurable:!0,get:function(){var i=this;return{data:{get value(){return i.value}}}}},__b:{configurable:!0,value:1}});c("__b",function(i,n){if("string"==typeof n.type){var r,t=n.props;for(var e in t)if("children"!==e){var f=t[e];if(f instanceof o.Signal){if(!r)n.__np=r={};r[e]=f;t[e]=f.peek()}}}i(n)});c("__r",function(i,r){i(r);if(r.type!==t.Fragment){v();var e,u=r.__c;if(u){u.__$f&=-2;if(void 0===(e=u.__$u))u.__$u=e=function(i,n){var r;o.effect(function(){r=this},{name:n});r.c=i;return r}(function(){var i;if(f)null==(i=e.y)||i.call(e);u.__$f|=1;u.setState({})},"function"==typeof r.type?r.type.displayName||r.type.name:"")}n=u;v(e)}});c("__e",function(i,r,t,e){v();n=void 0;i(r,t,e)});c("diffed",function(i,r){v();n=void 0;var t;if("string"==typeof r.type&&(t=r.__e)){var e=r.__np,o=r.props,f=t.U;if(f)for(var u in f){var a=f[u];if(!(void 0===a||e&&u in e)){a.d();f[u]=void 0}}if(e){if(!f){f={};t.U=f}for(var c in e){var s=f[c],l=e[c];if(void 0===s){s=h(t,c,l,o);f[c]=s}else s.o(l,o)}}}i(r)});function h(i,n,r,t){var e=n in i&&void 0===i.ownerSVGElement,f=o.signal(r);return{o:function(i,n){f.value=i;t=n},d:o.effect(function(){this.N=m;var r=f.value.value;if(t[n]!==r){t[n]=r;if(e)i[n]=r;else if(null!=r&&(!1!==r||"-"===n[4]))i.setAttribute(n,r);else i.removeAttribute(n)}})}}c("unmount",function(i,n){if("string"==typeof n.type){var r=n.__e;if(r){var t=r.U;if(t){r.U=void 0;for(var e in t){var o=t[e];if(o)o.d()}}}var f=n.__np;if(f){var u=n.props;for(var a in f)u[a]=f[a]}n.__np=void 0}else{var c=n.__c;if(c){var v=c.__$u;if(v){c.__$u=void 0;v.d()}}}i(n)});c("__h",function(i,n,r,t){if(t<3||9===t)n.__$f|=2;i(n,r,t)});t.Component.prototype.shouldComponentUpdate=function(i,n){if(this.__R)return!0;var r=this.__$u,t=r&&void 0!==r.s;for(var e in n)return!0;if(this.__f||"boolean"==typeof this.u&&!0===this.u){var o=2&this.__$f;if(!(t||o||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(t||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var f in i)if("__source"!==f&&i[f]!==this.props[f])return!0;for(var u in this.props)if(!(u in i))return!0;return!1};function useSignal(i,n){return e.useMemo(function(){return o.signal(i,n)},[])}var l="undefined"==typeof requestAnimationFrame?setTimeout:function(i){var n=function(){clearTimeout(r);cancelAnimationFrame(t);i()},r=setTimeout(n,35),t=requestAnimationFrame(n)},p=function(i){queueMicrotask(function(){queueMicrotask(i)})};function d(){o.batch(function(){var n;while(n=u.shift())i.call(n)})}function _(){if(1===u.push(this))(t.options.requestAnimationFrame||l)(d)}function x(){o.batch(function(){var n;while(n=a.shift())i.call(n)})}function m(){if(1===a.push(this))(t.options.requestAnimationFrame||p)(x)}exports.Signal=o.Signal;exports.action=o.action;exports.batch=o.batch;exports.computed=o.computed;exports.createModel=o.createModel;exports.effect=o.effect;exports.signal=o.signal;exports.untracked=o.untracked;exports.useComputed=function(i,r){var t=e.useRef(i);t.current=i;n.__$f|=4;return e.useMemo(function(){return o.computed(function(){return t.current()},r)},[])};exports.useModel=function(i){var n=e.useMemo(function(){return i()},[]);e.useEffect(function(){return n[Symbol.dispose]},[n]);return n};exports.useSignal=useSignal;exports.useSignalEffect=function(i,n){var r=e.useRef(i);r.current=i;e.useEffect(function(){return o.effect(function(){this.N=_;return r.current()},n)},[])};//# sourceMappingURL=signals.js.map
