objs-core 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/objs.built.js +667 -187
- package/objs.built.min.js +48 -38
- package/objs.d.ts +56 -5
- package/objs.js +818 -260
- package/package.json +1 -1
package/objs.built.min.js
CHANGED
|
@@ -1,66 +1,76 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Objs-core library
|
|
3
|
-
* @version 2.
|
|
3
|
+
* @version 2.2
|
|
4
4
|
* @author Roman Torshin
|
|
5
5
|
* @license Apache-2.0
|
|
6
|
-
*/const ee=!0,t=n=>{let e={els:[],ie:{},delegated:{},parented:{},store:{},refs:{},_refsByIndex:[],states:[],isDebug:!1,currentState:"",savedStates:{},isRoot:!1,_parent:null},o=1,s=2,c=3,w="boolean",a="object",p="function",S="string",N="number",l="notEmptyString",T="undefined",h="dangerouslySetInnerHTML",k,f=t.D,E=-1,g=0,m=0,v=typeof process<"u"||t.D===t.DocumentMVP,b=0,D=0;const M=e,C=r=>typeof r,O=(r,i)=>{for(const d in r)Object.hasOwn(r,d)&&i(d,r)},H=t.onError,L=r=>t.verify(r),$=(r,i="")=>(...d)=>{(t.debug||e.isDebug)&&console.log(i?`${i}()`:r,d.length?"with "+d.join(", "):"without parameters");try{const y=r(d[0],d[o],d[s],d[c]);return y!==k?y:e}catch(y){H(y,i)}},I=r=>{for(b=g;b<=E;b++)r()},U=r=>r?.els?r.el:(C(r)!==a&&(r=t.first(r).el),r),J=(r=!0,i=e.els)=>{const d=i.length;if(e.length=d,E=d-o,g=0,e.el=d?i[0]:k,e.last=d?i[E]:k,r&&(O(e.states,(y,u)=>{delete e[u[y]]}),e.states=[],e.ie={}),Array.isArray(e._refsByIndex)){const y=e._refsByIndex.length;if(y>d)O(e._refsByIndex,u=>{const x=+u;x>=d&&delete e._refsByIndex[x]}),e._refsByIndex.length=d;else if(y<d)for(let u=y;u<d;u++)e._refsByIndex[u]={}}};e.reset=t;const G=r=>{if(v||!r.querySelectorAll)return;const i=r.querySelectorAll("[data-o-init]"),d={};i.forEach(y=>{const u=y.getAttribute("data-o-init");u!==null&&(d[u]||(d[u]=[]),d[u].push(y))}),O(d,y=>{const u=t.inits[y];u&&u.getSSR(Number(y),d[y])})},X=(r,i,d)=>{O(i,y=>{let u=i[y];C(u)===p&&(u=u(d)),y==="append"&&C(u)===a&&(u.els&&(u=[u]),u[0]?.els&&(valueBuff=[],O(u,x=>{valueBuff.push(...u[x].els)}),u=valueBuff)),u!==k&&r.getAttribute(y)!==u&&!["tag","tagName","name","sample","state","events","ssr","nodeName","revertChildren","root","ref"].includes(y)&&(["html","innerHTML"].includes(y)?(r.innerHTML=u,!v&&G(r)):y==="className"?r.setAttribute("class",u):y==="dataset"&&C(u)===a?O(u,x=>{r.dataset[x]=u[x]}):y==="toggleClass"?r.classList.toggle(u):y==="addClass"?C(u)===a?r.classList.add(...u):r.classList.add(u):y==="removeClass"?r.classList.remove(u):y==="style"&&C(u)===a?O(u,x=>{r.style[x]=u[x]}):(y==="append"||y==="children"||y==="childNodes")&&C(u)===a?O(u.length?u:[u],x=>{y==="append"||!r.childNodes[x]?r.appendChild(u[x]):r.childNodes[x]!==u[x]&&r.childNodes[x].replaceWith(u[x])}):r.setAttribute(y,u))}),r.dataset.oState=i.state,t.autotag&&i.name&&(r.dataset[t.autotag]=t.camelToKebab(i.name))};e.debug=$(()=>{e.isDebug=!0},"debug ON"),e.saveAs=$(r=>{L([[r,[l]]]),t.getSaved[r]?(t.debug||e.isDebug)&&console.warn("the key exists (not saved):"+r):t.getSaved[r]=e},"saveAs"),e.unmount=()=>((t.debug||e.isDebug)&&console.log("unmount() for initID:"+e.initID),C(e.remove)===p?e.remove():e.els?.length&&e.els.forEach(r=>{r?.parentNode&&r.parentNode.removeChild(r)}),t.inits[e.initID]=void 0,e={},!0),e.init=$(r=>{L([[r,[a,p]]]);const i=e.initID||t.inits.length||0;if(e.initID=i,J(),t.inits[e.initID]=e,C(r)==="function"){e.render=$(x=>{const A=f.createElement("div");setTimeout(()=>{t.reactRender(r,A,x)}),e.add(A)});return}(C(r)!==a||r.render===k)&&(r={render:r}),O(r,x=>{e?.render&&x==="render"||(e.states.push(x),e[x]=$((A=[{}])=>{e.currentState=x;const R=r[x]||{tag:"div"},_=Array.isArray(e.els)?e.els.slice(g,E+o):[],P=_.length?_:e.els||[];C(R)===a&&(R.state=x,R["data-o-init"]=i);const z=(B,q={})=>{const j=C(R)===p?R(q):R;if(C(j)===a)return f.createElement(j.tag||j.tagName||"div");const F=f.createElement("div");return F.innerHTML=j,F.children.length>o||!F.firstElementChild?(F.dataset.oInit=B,F):(F.firstElementChild.dataset.oInit=B,F.firstElementChild)},W=A;Array.isArray(A)||(A=[A]),A.length||(A=[A]);const Y=!P[0]&&x==="render";A=A.map((B,q)=>{const j=Object.assign({},C(B)===a?B:{},{self:e,o:t,i:B.i===k?q:B.i,parent:e._parent,data:Array.isArray(W)?W[q]:W});return Y&&(!R.ssr||v)&&P.push(z(i,j)),j}),Y&&(e.els=P,J(!1));const Q=()=>{O(R.events,B=>{e.on(B,R.events[B])})};P&&(D=P.length===A.length,P.map((B,q)=>{A[D?q:0].i=q+g;const j=C(R)===p?R(A[D?q:0]):R;C(j)===a&&(j.state=x,Y&&(j["data-o-init"]=i,j["data-o-init-i"]=q,j.events&&(e._hydrateEvents=e._hydrateEvents||[],e._hydrateEvents[q]=j.events)),X(B,j,A[D?q:0]))}),Y&&(e._refsByIndex=[],e.refs={},e.els.forEach((B,q)=>{if(!B.querySelectorAll)return;const j={};B.querySelectorAll("[ref]").forEach(F=>{const Z=F.getAttribute("ref"),K=t(F);j[Z]=K,q===0&&(e.refs[Z]=K)}),e._refsByIndex[q]=j}),!v&&e._hydrateEvents&&(e._hydrateEvents.forEach((B,q)=>{B&&(e.select(q),O(B,j=>{const F=B[j];if(C(F)===a&&F.targetRef&&C(F.handler)===p){const K=(e._refsByIndex?.[q]??e.refs)?.[F.targetRef];K&&K.on(j,F.handler)}else C(F)===p&&e.on(j,F)}))}),e.all()))),Y&&C(R)===a&&R.events&&!v&&!R.ssr&&Q()}))});const d=r.render||r,y=!v&&C(d)===a&&d.events,u=!v&&e._hydrateEvents&&e._hydrateEvents.length;(y||u)&&(e.initSSRAfterGettingSSR=()=>{e._refsByIndex=[],e.refs={},e.els.forEach((x,A)=>{if(!x.querySelectorAll)return;const R={};x.querySelectorAll("[ref]").forEach(_=>{const P=_.getAttribute("ref"),z=t(_);R[P]=z,A===0&&(e.refs[P]=z),_.removeAttribute("ref")}),e._refsByIndex[A]=R,A===0&&(e.refs=R)}),y&&O(d.events,x=>{e.on(x,d.events[x])}),e._hydrateEvents&&(e._hydrateEvents.forEach((x,A)=>{x&&(e.select(A),O(x,R=>{const _=x[R];if(C(_)===a&&_.targetRef&&C(_.handler)===p){const z=(e._refsByIndex?.[A]??e.refs)?.[_.targetRef];z&&z.on(R,_.handler)}else C(_)===p&&e.on(R,_)}))}),e.all())})},"init"),e.connect=$((r,i="render",d)=>{L([[r,[a]],[i,[l]],[d,[S,T]]]),r.connect(M,i,d)},"connect"),e.getSSR=$((r,i)=>{L([[r,[N,T]]]);const d=r!==void 0?r:e.initID;if(v||C(r)===T&&C(e.initID)===T)return;const y=i&&i.length?i:t.D.querySelectorAll(`[data-o-init="${d}"]`);y.length&&(e.els=Array.from(y),r!==void 0&&(e.initID=r,t.inits[r]=e),J(!1),C(e.initSSRAfterGettingSSR)===p?e.initSSRAfterGettingSSR():i&&i.length&&(e._refsByIndex=[],e.refs={},e.els.forEach((u,x)=>{if(!u.querySelectorAll)return;const A={};u.querySelectorAll("[ref]").forEach(R=>{const _=R.getAttribute("ref");A[_]=t(R),x===0&&(e.refs[_]=A[_]),R.removeAttribute("ref")}),e._refsByIndex[x]=A,x===0&&(e.refs=A)})))},"getSSR"),e.initState=$((r,i)=>{L([[r,[a]],[i,[a,T]]]),e.init(r).render(i)},"initState");const V=(r,i,d)=>{const y=r.attributes,u={tagName:r.tagName.toLowerCase()};for(const x of y)u[x.nodeName]=x.value;if(d){u.innerHTML=r.innerHTML,u.revertChildren=[];const x=r.querySelectorAll("[data-o-init]");for(const A of x){const R=A.getAttribute("data-o-init");u.revertChildren.push(R),t.inits[R]?.saveState(i,!1)}}return u};return e.saveState=$((r,i=!0)=>{if(L([[r,[l,T]],[i,[w]]]),!e.el)throw Error("saveState(): There are no elements to save");const d=r||"fastSavedState",y={els:[],parentNode:e.el.parentNode,root:i};I(()=>{y.els.push(V(e.els[b],d,i))}),y.ie=Object.assign({},e.ie),y.delegated=Object.assign({},e.delegated),y.store=Object.assign({},e.store),e.isRoot=e.isRoot||i,e.savedStates[d]=y},"saveState"),e.revertState=$(r=>{L([[r,[l,T]]]);const i=r||"fastSavedState";if(!e.savedStates[i])throw Error(`revertState(): The state "${i}" should have been saved by saveState()`);const d=e.savedStates[i];e.offAll(),e.offDelegate(),e.store=Object.assign({},d.store),d.els.forEach((y,u)=>{if(!e.els[u]){const x=t.D.createElement(y.tagName);d.parentNode&&(u?e.els[u-1].after(x):d.parentNode.append(x)),e.add(x)}X(e.els[u],y)}),e.delegated=Object.assign({},d.delegated),e.ie=Object.assign({},d.ie),e.onAll(),O(d.delegated,y=>{d.delegated[y].forEach(u=>{I(()=>{e.els[b].addEventListener(y,u)})})}),e.currentState=i,d.root&&d.els.forEach(({rootElement:y})=>{y.revertChildren.forEach(u=>{t.inits[u]?.revertState(i),t('[data-o-init="'+u+'"]').els.forEach((x,A)=>{x.replaceWith(t.inits[u]?.els[A])})})})},"revertState"),e.loseState=$(r=>{L([[r,[l]]]),e.savedStates[r]&&(delete e.savedStates[r],I(()=>{const i=e.els[b].querySelectorAll("[data-o-init]");for(const d of i){const y=d.getAttribute("data-o-init");t.inits[y]?.loseState(r)}}))},"sample"),e.sample=$((r="render")=>(L([[r,[l]]]),{[r]:V(e.els[g])}),"sample"),e.select=$(r=>{let i=r;i!=null&&C(i)===a&&i.target&&e.els.length&&(i=e.els.findIndex(d=>d===i.target||d.contains(i.target)),i<0&&(i=0)),L([[i,[N,T]]]),i===k&&(i=e.length-o),E=i,g=i,e.el=e.els[i],m=o,Array.isArray(e._refsByIndex)&&e._refsByIndex[i]&&(e.refs=e._refsByIndex[i])},"select"),e.all=$(()=>{E=e.length-o,g=0,e.el=e.els[0],m=0,Array.isArray(e._refsByIndex)&&e._refsByIndex.length&&(e.refs=e._refsByIndex[0]||{})},"all"),e.remove=$(r=>{if(L([[r,[N,T]]]),r===k&&m&&(r=g),r!==k){const i=e.els[r];i?.parentNode?i.parentNode.removeChild(i):i===void 0&&r>=e.els.length&&t.onError&&t.onError("remove("+r+"): index out of bounds","remove")}else I(()=>{const i=e.els[b];i?.parentNode&&i.parentNode.removeChild(i)});J(!1)},"remove"),e.skip=$(r=>{L([[r,[N,T]]]),r===k&&(r=g),e.els.splice(r,o),Array.isArray(e._refsByIndex)&&e._refsByIndex.splice(r,o),J()},"skip"),e.add=$(r=>{L([[r,[S,a,N]]]),e.initID===k&&(C(r)==="string"&&r!==""?e.els.push(...Array.from(f.querySelectorAll(r))):C(r)===a?r.tagName?e.els.push(r):r.els?e.els.push(...r.els):r.length&&r[0].tagName&&e.els.push(...r):C(r)==="number"&&t.inits[r]&&(e=t.inits[r]),J(!1),e.initID!==k&&e.dataset({oInit:e.initID}))},"add"),e.appendInside=$(r=>{L([[r,[a,l]]]),r?.els&&(e._parent=r),I(()=>{U(r).appendChild(e.els[b])})},"appendInside"),e.appendBefore=$(r=>{L([[r,[a,l]]]),I(()=>{U(r).parentNode.insertBefore(e.els[b],U(r))})},"appendBefore"),e.appendAfter=$(r=>{L([[r,[a,l]]]),I(()=>{U(r).after(...e.els)})},"appendAfter"),e.find=$((r="")=>{L([[r,S]]);const i=[];return I(()=>{i.push(...Array.from(e.els[b].querySelectorAll(":scope "+r)))}),t(i)},"find"),e.first=$((r="")=>{L([[r,S]]);let i=k;const d=[];return I(()=>{i=e.els[b].querySelector(r),i&&d.push(i)}),t(d)},"first"),e.attr=$((r,i)=>{if(i!==null&&L([[r,S],[i,[S,T]]]),i===k){const d=[];return I(()=>{d[b]=e.els[b].getAttribute(r)}),m?d[0]:d}else I(i!==null?()=>{e.els[b].setAttribute(r,i)}:()=>{e.els[b].removeAttribute(r)})},"attr"),e.attrs=$(()=>{const r=[];return I(()=>{const i={};[...e.els[b].attributes].forEach(d=>{i[d.nodeName]=d.nodeValue}),r.push(i)}),m?r[0]:r},"attrs"),e.dataset=$(r=>{if(L([[r,[a,T]]]),typeof r===a)I(()=>{O(r,i=>{e.els[b].dataset[i]=r[i]})});else{const i=[];return I(()=>{i.push({...e.els[b].dataset})}),m?i[0]:i}},"dataset"),e.style=$(r=>{r!==null&&L([[r,[S,T]]]),e.attr("style",r)},"style"),e.css=$((r={})=>{if(r===null){e.style(null);return}L([[r,a]]);let i="";O(r,d=>{i+=d+":"+r[d].replace('"',"'")+";"}),e.style(i||null)},"css"),e.setClass=$(r=>{L([[r,S]]),I(()=>{e.els[b].setAttribute("class",r)})},"setClass"),e.addClass=$((...r)=>{I(()=>{e.els[b].classList.add(...r)})},"addClass"),e.removeClass=$((...r)=>{I(()=>{e.els[b].classList.remove(...r)})},"removeClass"),e.toggleClass=$((r,i)=>{L([[r,l],[i,[w,T]]]),I(()=>{e.els[b].classList.toggle(r,i)})},"toggleClass"),e.haveClass=r=>{L([[r,l]]);let i=!0;return I(()=>{e.els[b].classList.contains(r)||(i=!1)}),(e.isDebug||t.debug)&&console.log("haveClass() with",r),i},e.innerHTML=$(r=>{if(L([[r,[S,T]]]),r!==k)I(()=>{e.els[b].innerHTML=r});else{let i="";return I(()=>{i+=v&&e.els[b].innerHTML.length===0?t.D.parseElement(e.els[b],!1):e.els[b].innerHTML}),i}},"innerHTML"),e.innerText=$(r=>{L([[r,[S]]]),I(()=>{e.els[b].innerText=r})},"innerText"),e.textContent=$(r=>{L([[r,[S]]]),I(()=>{e.els[b].textContent=r})},"textContent"),e.html=$(r=>{if(L([[r,[S,T]]]),r!==void 0)e.innerHTML(r);else{let i="";return I(()=>{i+=v?e.els[b].outerHTML():e.els[b].outerHTML}),i}},"html"),e.val=$(r=>{if(r===void 0)return e.el?.value;I(()=>{e.els[b].value=r})},"val"),e.forEach=$(r=>{L([[r,[p]]]),I(()=>{r({self:e,i:b,o:t,el:e.els[b]})})},"forEach"),e.prepareFor=$((r,i)=>{L([[r,[a,p,T]],[i,[p,T]]]);const d=r&&C(r)===a&&r.createElement;if(!d&&C(r)!==p)throw Error("prepareFor(): pass React (full object) or React.createElement as first argument");const y=d?r.createElement:r,u=d?r.useEffect:void 0;return x=>{if(x.ref===k)throw Error("No ref property to convert Objs to React");const A=Object.assign({},x),R=y("div",{ref:x.ref});return delete A.ref,u(()=>{O(A,_=>{if(_.substring(0,1)==="on"){const P=t.camelToKebab(_).split("-")[1];e.on(P,A[_]),delete A[_]}}),e.render(A),e.appendInside(R.ref.current)},[]),R}},"prepareFor"),e.on=$((r,i,d,y)=>{L([[r,[l]],[i,[p]],[d,[a,T]],[y,[w,T]]]),r.split(", ").forEach(u=>{I(()=>{e.els[b].addEventListener(u,i,d,y)}),e.ie[u]||(e.ie[u]=[]),e.ie[u].push([i,d,y])})},"on"),e.off=$((r,i,d)=>{L([[r,[l]],[i,[p]],[d,[a,T]]]),r.split(", ").forEach(y=>{I(()=>{e.els[b].removeEventListener(y,i,d)}),e.ie[y]&&(e.ie[y]=e.ie[y].filter(u=>u[0]!==i))})},"off"),e.onDelegate=$((r,i,d)=>{L([[r,[l]],[i,[l]],[d,[p]]]),r.split(", ").forEach(y=>{const u=x=>{const A=x.target.closest(i);A&&(x.delegate=A,x.objs=e,d(x))};I(()=>{e.els[b].addEventListener(y,u)}),e.delegated[y]||(e.delegated[y]=[]),e.delegated[y].push(u)})},"onDelegate"),e.offDelegate=$(r=>{L([[r,[l]]]),O(e.delegated,i=>{if(!r||r===i)for(;e.delegated[i].length;){const d=e.delegated[i].pop();I(()=>{e.els[b].removeEventListener(i,d)})}}),e.delegated={}},"offDelegate"),e.onParent=$((r,i,d)=>{L([[r,[l]],[i,[l,a]],[d,[p]]]);const y=C(i)===a?i:t.D.querySelector(i);r.split(", ").forEach(u=>{const x=A=>{A.objs=e,d(A)};y.addEventListener(u,x),e.parented[u]||(e.parented[u]=[]),e.parented[u].push(x)})},"onParent"),e.offParent=$((r,i)=>{L([[r,[l]],[i,[l,a]]]);const d=C(i)===a?i:t.D.querySelector(i);O(e.parented,y=>{(!r||r===y)&&(e.parented[y].forEach(u=>{d.removeEventListener(y,u)}),delete e.parented[y])})},"offParent"),e.onAll=$((r,i)=>{L([[r,[l,T]],[i,[w,T]]]),O(e.ie,(d,y)=>{(!r||r===d)&&y[d].forEach(u=>{I(()=>{i?e.els[b].removeEventListener(d,u[0]):e.els[b].addEventListener(d,u[0],u[o],u[s])})})})},"onAll"),e.offAll=$(r=>{L([[r,[l]]]),e.onAll(r,o)},"offAll"),n&&e.add(n),e.take=r=>{if(L([[r,[S,a,N]]]),e.add(r),e.el){const i=e.el.dataset.oInit;if(i!==k&&t.inits[i])return e.length===o?(D=e.els[0],Object.assign(e,t.inits[i]),e.els=[D]):e=t.inits[i],J(!1,e.els),e}},e};t.first=n=>(t.verify([[n,["notEmptyString"]]]),t.debug&&console.log(n," -> ","o.first()"),t(t.D.querySelector(n)).select(0)),t.inits=[],t.getSaved={},t.errors=[],t.showErrors=!1,t.logErrors=()=>{t.errors.length?t.errors.forEach(n=>console.error(n)):console.log("No errors")},t.onError=(n,e)=>{t.showErrors?console.error(n,e):(t.errors.push(n),e&&t.errors.push(e))},t.reactRender=()=>new Error("React render function is not defined"),t.autotag=void 0,t.reactQA=n=>({["data-"+(t.autotag||"qa")]:n.replace(/([A-Z])/g,(e,o)=>"-"+o.toLowerCase()).replace(/^-/,"")}),t.specialTypes={notEmptyString:(n,e)=>e==="string"&&n.length,array:n=>Array.isArray(n),promise:n=>n instanceof Promise||!!(n&&typeof n.then=="function")},t.verify=(n,e=!1)=>{for(const o of n){const s=typeof o[0];let c=Array.isArray(o[1])?o[1]:[o[1]],w=!1;if(c.includes(s))return!0;c=c.filter(a=>!!t.specialTypes[a]);for(const a of c)if(w=t.specialTypes[a](o[0],s),w)return!0}return e?!1:new Error("Type verification failed")},t.safeVerify=n=>t.verify(n,!0),t.init=(n,e)=>t().init(n,e),t.initState=(n,e)=>t().init(n).render(e),t.take=n=>t().take(n),t.getStates=()=>t.inits.reduce((n,e)=>(n.push(e?.states),n),[]),t.getStores=()=>t.inits.reduce((n,e)=>(n.push(e?.store),n),[]),t.getListeners=()=>t.inits.reduce((n,e)=>(n.push(e?.ie),n),[]),t.createStore=n=>{const e=Object.assign({},n);return e._defaults=Object.assign({},n),e._listeners=[],e.subscribe=function(o,s){return this._listeners.push(c=>o[s]?.(c)),this},e.notify=function(){this._listeners.forEach(o=>o(this))},e.reset=function(){const o={_listeners:1,subscribe:1,notify:1,_defaults:1,reset:1};for(const s of Object.keys(this._defaults))o[s]||(this[s]=this._defaults[s])},e},t.U=void 0,t.W=2,t.H=100,t.F=!1,t.C=(n,e)=>Object.hasOwn(n,e),t.kebabToCamel=n=>n.replace(/-./g,e=>e.toUpperCase()[1]),t.camelToKebab=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),t.route=(n,e)=>{t.verify([[n,["notEmptyString","function","boolean"]],[e,["function","object"]]]);const o=typeof n=="function"?n(window.location.pathname):n;return o===!0||window.location.pathname===o?e?typeof e=="function"?(e(),!0):e:t:typeof e=="function"?!1:{}},t.router=(n={})=>{t.verify([[n,["object"]]]);for(const e in n)if(t.C(n,e)&&window.location.pathname===e)return typeof n[e]=="function"?(n[e](),!0):n[e];return!1},t.DocumentMVP={addEventListener:()=>{},parseElement:(n,e=!0)=>{t.verify([[n,["object","string"]],[e,["boolean"]]]);const o=(s,c="")=>{let w="";for(const a in s)t.C(s,a)&&(w+=` ${c}${t.camelToKebab(a)}="${typeof s[a]!="object"?s[a]:Object.entries(s[a]).map(p=>`${p[0]}: ${p[1]};`).join(" ")}"`);return w};if(typeof n=="string")return n;if(e){const s=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],c=n.tagName.toLowerCase(),w=n.attributes["data-o-init"],a=w!==void 0?` data-o-init="${w}"`:"";return`<${c}${n.className?` class="${n.className}"`:""}${o(n.attributes)}${a}${o(n.dataset,"data-")}${s.includes(c)?"/":""}>${s.includes(c)?"":n.innerHTML.length?n.innerHTML:n.children.map(p=>t.D.parseElement(p)).join("")}${s.includes(c)?"":`</${c}>`}`}return n.innerHTML.length?n.innerHTML:n.children.map(s=>t.D.parseElement(s)).join("")},createElement:n=>{t.verify([[n,["notEmptyString"]]]);const e={tagName:n.toUpperCase(),attributes:{},innerHTML:"",children:[],dataset:{},className:"",classArray:[],style:{},addEventListener:()=>{},removeEventListener:()=>{}};return e.classList={add:(...o)=>{t.verify([[o,["array"]]]),e.classArray.push(o),e.className=e.classArray.join(" ")},has:o=>(t.verify([[o,["notEmptyString"]]]),e.classArray.includes(o)),remove:o=>{t.verify([[o,["notEmptyString"]]]),e.classArray=e.classArray.filter(s=>o!==s),e.className=e.classArray.join(" ")}},e.classList.toggle=o=>{t.verify([[o,["notEmptyString"]]]),e.classList.has(o)?e.classList.remove(o):e.classList.add(o)},e.setAttribute=(o,s)=>{t.verify([[o,["notEmptyString"]],[s,["string","number","boolean","undefined"]]]),e.attributes[o]=s},e.getAttribute=o=>(t.verify([[o,["notEmptyString"]]]),e.attributes[o]),e.removeAttribute=o=>{t.verify([[o,["notEmptyString"]]]),delete e.attributes[o]},e.appendChild=o=>{t.verify([[o,["object"]]]),e.children.push(o),e.firstElementChild=e.children[0]},e.outerHTML=()=>t.D.parseElement(e),e}},t.D=typeof document<"u"&&typeof process>"u"?document:t.DocumentMVP,t.setCookie=(n,e="",o={})=>{if(t.verify([[n,["notEmptyString"]],[e,["string","number","boolean"]],[o,["object"]]]),t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}let s=encodeURIComponent(n)+"="+encodeURIComponent(e);o={path:"/",...o},o.expires instanceof Date?o.expires=o.expires.toUTCString():typeof o.expires=="number"&&(o.expires=new Date(o.expires).toUTCString());for(const c in o){s+="; "+c;const w=o[c];w!==!0&&(s+="="+w)}t.D.cookie=s},t.getCookie=n=>{if(t.verify([[n,["notEmptyString"]]]),t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}const e=t.D.cookie.match(RegExp("(?:^|; )"+n.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0},t.deleteCookie=n=>{t.verify([[n,["notEmptyString"]]]),t.setCookie(n,"",{"max-age":0})},t.clearCookies=()=>{if(t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}const n=t.D.cookie.split(";");for(;n.length;){let e=n.pop();for(;e.charAt(0)===" ";)e=e.substring(1);const o=e.split("=")[0];t.deleteCookie(o)}},t.clearLocalStorage=n=>{if(t.verify([[n,["boolean","undefined"]]]),!(typeof localStorage>"u"))if(n)localStorage.clear();else for(let e=localStorage.length-1;e>=0;e--){const o=localStorage.key(e);o.indexOf("oInc-")===-1&&o.indexOf("oTest-")===-1&&localStorage.removeItem(o)}},t.clearSessionStorage=n=>{if(t.verify([[n,["boolean","undefined"]]]),!(typeof sessionStorage>"u"))if(!n)sessionStorage.clear();else for(let e=sessionStorage.length-1;e>=0;e--){const o=sessionStorage.key(e);o&&o.indexOf("oTest-")===0&&sessionStorage.removeItem(o)}},t.clearTestsStorage=()=>{t.clearSessionStorage(1)},t.clearAfterTests=()=>{t.clearCookies(),t.clearLocalStorage(!1),t.clearTestsStorage()},t.ajax=(n,e={})=>{t.verify([[n,["notEmptyString"]],[e,["object"]]]);const o=new URLSearchParams;if(e.data&&typeof e.data=="object"){for(const s in e.data)t.C(e.data,s)&&(typeof e.data[s]=="object"?o.set(s,encodeURIComponent(JSON.stringify(e.data[s]))):o.set(s,e.data[s]));e.method.toLowerCase()==="get"?n+="?"+o.toString():e.body||(e.body=o),delete e.data}return e.headers||(e.headers={"X-Requested-With":"XMLHttpRequest"}),fetch(n,e)},t.get=(n,e={})=>(t.verify([[n,["notEmptyString"]],[e,["object"]]]),t.ajax(n,{...e,method:"GET"})),t.post=(n,e={})=>(t.verify([[n,["notEmptyString"]],[e,["object"]]]),t.ajax(n,{...e,method:"POST"})),t.newLoader=n=>{t.verify([[n,["promise","undefined"]]]);let e=[],o=null,s=!1,c=!1;const w=a=>{s=!1,c=!1,o=null,setTimeout(()=>{a.then(p=>{s=!0,!p.ok&&typeof p.ok<"u"?(c=!0,e.forEach(([S,N,l])=>{l&&S[l](p)})):typeof p.json=="function"?p.json().then(S=>{o=S,e.forEach(([N,l])=>{N[l](o)})}):(o=p,e.forEach(([S,N])=>{S[N](o)}))}).catch(p=>{c=!0,e.forEach(([S,N,l])=>{l&&S[l](p)})})},33)};return n&&w(n),{reload:w,isObjsLoader:!0,listeners:e,isFinished:()=>s,getStore:()=>o,connect:(a,p="render",S)=>{t.verify([[a,["object"]],[p,["notEmptyString"]],[S,["string","undefined"]]]),s?c?S&&a[S]():typeof a[p]=="function"&&a[p](o):e.push([a,p,S])},disconnect:a=>{t.verify([[a,["object"]]]),e=e.filter(([p])=>p!==a)}}},t.getParams=n=>{t.verify([[n,["string","undefined"]]]);const e={},o=new URLSearchParams(window.location.search).entries();for(const s of o)e[s[0]]=s[1];return n?e[n]:e},t.incCache=!0,t.incCacheExp=1e3*60*60*24,t.incTimeout=6e3,t.incSource="",t.incForce=t.F,t.incAsync=!0,t.incCors=t.F,t.incSeparator="?",t.incFns={},t.incSet=[0],t.incReady=[0],t.incN=0,t.incGetHash=n=>n.split(t.incSeparator)[1]||"",t.incCheck=(n=0,e,o=0)=>(t.verify([[n,["number"]],[e,["number","undefined"]],[o,["number"]]]),!o&&n&&e===t.U&&t.incReady[n]?t.incSet[n]===1:t.incReady[n]===t.U||t.incReady[n][e]===t.U?t.F:(t.incReady[n][e].loaded=o,t.incFns[t.incReady[n][e].name]=o,t.incReady[n][0]+=o,n&&t.incReady[n].length===t.incReady[n][0]&&(typeof t.incSet[n]=="function"&&t.incSet[n](n),t.incSet[n]=1),t.incSet[n]===1)),t.incCacheClear=(n=t.F)=>{t.verify([[n,["boolean"]]]);for(const e in t.incFns)t.C(t.incFns,e)&&(localStorage.removeItem("oInc-"+e),localStorage.removeItem("oInc-"+e+"-expires"));return n&&(t.incReady.forEach((e,o)=>{o&&e.forEach((s,c)=>{c&&t("#oInc-"+o+"-"+c).remove()})}),t.incN=0,t.incFns={},t.incSet=[0],t.incReady=[0]),!0},t.inc=(n,e,o)=>{if(t.verify([[n,["object","undefined"]],[e,["function","undefined"]],[o,["function","undefined"]]]),typeof localStorage>"u")return;let s=0,c=0,w="",a=!1;const p="function",S=-1;if(typeof n!="object"||!n)return t.incSet[0];t.incSet[0]++;const N=t.incSet[0];t.incSet[N]=e||0,t.incReady[N]=[];const l=t.incReady[N];l[0]=1;const T={};for(const h in n)if(t.C(n,h)){if(h==="preload"){a=!0;continue}w=t.incGetHash(n[h]),s++,t.incN++;const k=n[h].indexOf(".css")>S?"style":"script";if(n[h]=(t.incSource?t.incSource+"/":"")+n[h],Number.isNaN(Number(h))&&t.C(t.incFns,h)&&t.incFns[h]&&!t.incForce){l[s]={name:h,loaded:1},c++;continue}if(l[s]={name:h,loaded:0},Number.isNaN(Number(h))&&(t.incFns[h]=0),Number.isNaN(Number(h))&&t.incCache&&(n[h].substring(0,4)!=="http"||!t.incCors)&&window.location.protocol!=="file:"&&(n[h].indexOf(".css")>S||n[h].indexOf(".js")>S)){const f=localStorage,E=f.getItem("oInc-"+h),g=f.getItem("oInc-"+h+"-expires"),m=f.getItem("oInc-"+h+"-hash");E&&g&&Date.now()<g&&m===w?(a||t.initState({tag:k,id:"oInc-"+N+"-"+s,innerHTML:E,"data-o-inc":N}).appendInside("head"),l[s].loaded=1,t.incFns[h]=1,c++):(T[h]=s,t.get(n[h],{mode:t.incCors?"cors":"same-origin"}).then(v=>{if(v.status!==200){t.onError&&t.onError({message:t.incSource+n[h]+" was not loaded"});return}v.text().then(b=>{f.setItem("oInc-"+h,b),f.setItem("oInc-"+h+"-expires",Date.now()+t.incCacheExp),f.setItem("oInc-"+h+"-hash",w),a||t.initState({tag:k,id:"oInc-"+N+"-"+T[h],innerHTML:b,"data-o-inc":N}).appendInside("head"),t.incCheck(N,T[h],1)})}))}else{const f={tag:k,id:"oInc-"+N+"-"+s,"data-o-inc":N,async:t.incAsync,onload:"o.incCheck("+N+","+s+",1)"};n[h].indexOf(".css")>S?(f.tag="link",f.rel="stylesheet",f.href=n[h]):(n[h].indexOf(".js")>S||(f.tag="img",f.style="display:none;"),f.src=n[h]),t.initState(f).appendInside(f.style?"body":"head")}}return l[0]+=c,s!==0&&(c===s?typeof e===p&&e(N):setTimeout(h=>{t.incReady[h]&&t.incReady[h].length<t.incReady[h][0]&&(t.incSet[h]=0,typeof o===p&&o(N))},t.incTimeout,N)),t.incSet[0]},t.connectRedux=(n,e,o,s="render")=>{t.verify([[n,["object"]],[e,["function"]],[o,["object"]],[s,["notEmptyString"]]]);const c=()=>{if(typeof o[s]=="function"){const w=e(n.getState());o[s](w!==null&&typeof w=="object"?w:{value:w})}};return c(),n.subscribe(c)},t.connectMobX=(n,e,o,s,c="render")=>(t.verify([[n,["object"]],[e,["object"]],[o,["function"]],[s,["object"]],[c,["notEmptyString"]]]),n.autorun(()=>{if(typeof s[c]=="function"){const w=o(e);s[c](w!==null&&typeof w=="object"?w:{value:w})}})),t.ObjsContext=null,t.withReactContext=(n,e,o,s,c="render")=>function(){const a=n.useContext(e);return n.useEffect(()=>{if(typeof s[c]=="function"){const p=o(a);s[c](p!==null&&typeof p=="object"?p:{value:p})}},[a]),null},t.debug=!1,t.tLog=[],t.tRes=[],t.tStatus=[],t.tFns=[],t.tShowOk=t.F,t.tStyled=t.F,t.tTime=2e3,t.tests=[],t.tAutolog=t.F,t.tBeforeEach=void 0,t.tAfterEach=void 0,t.addTest=(n,...e)=>{t.verify([[n,["notEmptyString"]],[e,["array"]]]);let o={};e.length&&typeof e[e.length-1]=="object"&&!Array.isArray(e[e.length-1])&&(o=e.pop());const s=t.tests.length;return t.tests[s]={title:n,tests:e,hooks:o},{run:()=>{typeof o.before=="function"&&(t.tBeforeEach=o.before),typeof o.after=="function"&&(t.tAfterEach=o.after),t.runTest(s)},autorun:()=>{typeof o.before=="function"&&(t.tBeforeEach=o.before),typeof o.after=="function"&&(t.tAfterEach=o.after),t.runTest(s,!0)},testId:s}},t.updateLogs=()=>{for(let n=0;n<t.tests.length;n++)t.tLog[n]=t.tLog[testN]=sessionStorage.getItem(`oTest-Log-${testN}`)||"";return t.tLog},t.runTest=(n=0,e,o)=>{if(t.verify([[n,["number"]],[e,["boolean","undefined"]],[o,["boolean","undefined"]]]),!t.tests[n])return;o||(sessionStorage?.removeItem(`oTest-Log-${n}`),sessionStorage?.removeItem(`oTest-Res-${n}`),sessionStorage?.removeItem(`oTest-Status-${n}`)),sessionStorage?.setItem("oTest-Run",n),e?sessionStorage?.setItem("oTest-Autorun",e):sessionStorage?.removeItem("oTest-Autorun");const s=t.tests[n];let c=s.tests.pop();typeof c!="function"&&(s.tests.push(c),c=()=>{}),s.tests.push(w=>{c(w),sessionStorage.setItem("dddd",1),sessionStorage?.removeItem("oTest-Run"),e&&t.runTest(n+1,e)}),t.test(s.title,...s.tests)},t.tPre='<div style="font-family:monospace;text-align:left;">',t.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',t.tXx='<div style="background:#fcc;padding:3px;">',t.tDc="</div>",t.test=(n="",...e)=>{t.verify([[n,["notEmptyString"]],[e,["array"]]]);const o=sessionStorage?.getItem("oTest-Run"),s=o||t.tLog.length;let c=0,w="\u251C OK: ",a="\u251C \u2718 ",p=`
|
|
7
|
-
`,
|
|
8
|
-
`,
|
|
9
|
-
`,t.tRes[
|
|
10
|
-
`,
|
|
11
|
-
`,
|
|
12
|
-
|
|
13
|
-
`)
|
|
14
|
-
|
|
15
|
-
`:s.type==="input"||s.type==="change"?c=(s.value!==void 0?` el.value = ${JSON.stringify(s.value)};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
*/const ee=!0,t=n=>{let e={els:[],ie:{},delegated:{},parented:{},store:{},refs:{},_refsByIndex:[],states:[],isDebug:!1,currentState:"",savedStates:{},isRoot:!1,_parent:null},i=1,r=2,d=3,w="boolean",u="object",x="function",v="string",I="number",f="notEmptyString",S="undefined",m="dangerouslySetInnerHTML",O,y=t.D,C=-1,s=0,c=0,g=typeof process<"u"||t.D===t.DocumentMVP,a=0,L=0;const k=e,p=o=>typeof o,D=(o,l)=>{for(const h in o)Object.hasOwn(o,h)&&l(h,o)},N=t.onError,$=o=>t.verify(o),T=(o,l="")=>(...h)=>{(t.debug||e.isDebug)&&console.log(l?`${l}()`:o,h.length?"with "+h.join(", "):"without parameters");try{const E=o(h[0],h[i],h[r],h[d]);return E!==O?E:e}catch(E){N(E,l)}},R=o=>{for(a=s;a<=C;a++)o()},U=o=>o?.els?o.el:(p(o)!==u&&(o=t.first(o).el),o),J=(o=!0,l=e.els)=>{const h=l.length;if(e.length=h,C=h-i,s=0,e.el=h?l[0]:O,e.last=h?l[C]:O,o&&(D(e.states,(E,b)=>{delete e[b[E]]}),e.states=[],e.ie={}),Array.isArray(e._refsByIndex)){const E=e._refsByIndex.length;if(E>h)D(e._refsByIndex,b=>{const A=+b;A>=h&&delete e._refsByIndex[A]}),e._refsByIndex.length=h;else if(E<h)for(let b=E;b<h;b++)e._refsByIndex[b]={}}};e.reset=t;const G=o=>{if(g||!o.querySelectorAll)return;const l=o.querySelectorAll("[data-o-init]"),h={};l.forEach(E=>{const b=E.getAttribute("data-o-init");b!==null&&(h[b]||(h[b]=[]),h[b].push(E))}),D(h,E=>{const b=t.inits[E];b&&b.getSSR(Number(E),h[E])})},V=(o,l,h)=>{D(l,E=>{let b=l[E];p(b)===x&&(b=b(h)),E==="append"&&p(b)===u&&(b.els&&(b=[b]),b[0]?.els&&(valueBuff=[],D(b,A=>{valueBuff.push(...b[A].els)}),b=valueBuff)),b!==O&&o.getAttribute(E)!==b&&!["tag","tagName","name","sample","state","events","ssr","nodeName","revertChildren","root","ref"].includes(E)&&(["html","innerHTML"].includes(E)?(o.innerHTML=b,!g&&G(o)):E==="className"?o.setAttribute("class",b):E==="dataset"&&p(b)===u?D(b,A=>{o.dataset[A]=b[A]}):E==="toggleClass"?o.classList.toggle(b):E==="addClass"?p(b)===u?o.classList.add(...b):o.classList.add(b):E==="removeClass"?o.classList.remove(b):E==="style"&&p(b)===u?D(b,A=>{o.style[A]=b[A]}):(E==="append"||E==="children"||E==="childNodes")&&p(b)===u?D(b.length?b:[b],A=>{E==="append"||!o.childNodes[A]?o.appendChild(b[A]):o.childNodes[A]!==b[A]&&o.childNodes[A].replaceWith(b[A])}):o.setAttribute(E,b))}),o.dataset.oState=l.state,t.autotag&&l.name&&(o.dataset[t.autotag]=t.camelToKebab(l.name))};e.debug=T(()=>{e.isDebug=!0},"debug ON"),e.saveAs=T(o=>{$([[o,[f]]]),t.getSaved[o]?(t.debug||e.isDebug)&&console.warn("the key exists (not saved):"+o):t.getSaved[o]=e},"saveAs"),e.unmount=()=>((t.debug||e.isDebug)&&console.log("unmount() for initID:"+e.initID),p(e.remove)===x?e.remove():e.els?.length&&e.els.forEach(o=>{o?.parentNode&&o.parentNode.removeChild(o)}),t.inits[e.initID]=void 0,e={},!0),e.init=T(o=>{$([[o,[u,x]]]);const l=e.initID||t.inits.length||0;if(e.initID=l,J(),t.inits[e.initID]=e,p(o)==="function"){e.render=T(A=>{const _=y.createElement("div");setTimeout(()=>{t.reactRender(o,_,A)}),e.add(_)});return}(p(o)!==u||o.render===O)&&(o={render:o}),D(o,A=>{e?.render&&A==="render"||(e.states.push(A),e[A]=T((_=[{}])=>{e.currentState=A;const F=o[A]||{tag:"div"},j=Array.isArray(e.els)?e.els.slice(s,C+i):[],H=j.length?j:e.els||[];p(F)===u&&(F.state=A,F["data-o-init"]=l);const z=(q,P={})=>{const B=p(F)===x?F(P):F;if(p(B)===u)return y.createElement(B.tag||B.tagName||"div");const M=y.createElement("div");return M.innerHTML=B,M.children.length>i||!M.firstElementChild?(M.dataset.oInit=q,M):(M.firstElementChild.dataset.oInit=q,M.firstElementChild)},W=_;Array.isArray(_)||(_=[_]),_.length||(_=[_]);const K=!H[0]&&A==="render";_=_.map((q,P)=>{const B=Object.assign({},p(q)===u?q:{},{self:e,o:t,i:q.i===O?P:q.i,parent:e._parent,data:Array.isArray(W)?W[P]:W});return K&&(!F.ssr||g)&&H.push(z(l,B)),B}),K&&(e.els=H,J(!1));const Q=()=>{D(F.events,q=>{e.on(q,F.events[q])})};H&&(L=H.length===_.length,H.map((q,P)=>{_[L?P:0].i=P+s;const B=p(F)===x?F(_[L?P:0]):F;p(B)===u&&(B.state=A,K&&(B["data-o-init"]=l,B["data-o-init-i"]=P,B.events&&(e._hydrateEvents=e._hydrateEvents||[],e._hydrateEvents[P]=B.events)),V(q,B,_[L?P:0]))}),K&&(e._refsByIndex=[],e.refs={},e.els.forEach((q,P)=>{if(!q.querySelectorAll)return;const B={};q.querySelectorAll("[ref]").forEach(M=>{const Z=M.getAttribute("ref"),Y=t(M);B[Z]=Y,P===0&&(e.refs[Z]=Y)}),e._refsByIndex[P]=B}),!g&&e._hydrateEvents&&(e._hydrateEvents.forEach((q,P)=>{q&&(e.select(P),D(q,B=>{const M=q[B];if(p(M)===u&&M.targetRef&&p(M.handler)===x){const Y=(e._refsByIndex?.[P]??e.refs)?.[M.targetRef];Y&&Y.on(B,M.handler)}else p(M)===x&&e.on(B,M)}))}),e.all()))),K&&p(F)===u&&F.events&&!g&&!F.ssr&&Q()}))});const h=o.render||o,E=!g&&p(h)===u&&h.events,b=!g&&e._hydrateEvents&&e._hydrateEvents.length;(E||b)&&(e.initSSRAfterGettingSSR=()=>{e._refsByIndex=[],e.refs={},e.els.forEach((A,_)=>{if(!A.querySelectorAll)return;const F={};A.querySelectorAll("[ref]").forEach(j=>{const H=j.getAttribute("ref"),z=t(j);F[H]=z,_===0&&(e.refs[H]=z),j.removeAttribute("ref")}),e._refsByIndex[_]=F,_===0&&(e.refs=F)}),E&&D(h.events,A=>{e.on(A,h.events[A])}),e._hydrateEvents&&(e._hydrateEvents.forEach((A,_)=>{A&&(e.select(_),D(A,F=>{const j=A[F];if(p(j)===u&&j.targetRef&&p(j.handler)===x){const z=(e._refsByIndex?.[_]??e.refs)?.[j.targetRef];z&&z.on(F,j.handler)}else p(j)===x&&e.on(F,j)}))}),e.all())})},"init"),e.connect=T((o,l="render",h)=>{$([[o,[u]],[l,[f]],[h,[v,S]]]),o.connect(k,l,h)},"connect"),e.getSSR=T((o,l)=>{$([[o,[I,S]]]);const h=o!==void 0?o:e.initID;if(g||p(o)===S&&p(e.initID)===S)return;const E=l&&l.length?l:t.D.querySelectorAll(`[data-o-init="${h}"]`);E.length&&(e.els=Array.from(E),o!==void 0&&(e.initID=o,t.inits[o]=e),J(!1),p(e.initSSRAfterGettingSSR)===x?e.initSSRAfterGettingSSR():l&&l.length&&(e._refsByIndex=[],e.refs={},e.els.forEach((b,A)=>{if(!b.querySelectorAll)return;const _={};b.querySelectorAll("[ref]").forEach(F=>{const j=F.getAttribute("ref");_[j]=t(F),A===0&&(e.refs[j]=_[j]),F.removeAttribute("ref")}),e._refsByIndex[A]=_,A===0&&(e.refs=_)})))},"getSSR"),e.initState=T((o,l)=>{$([[o,[u]],[l,[u,S]]]),e.init(o).render(l)},"initState");const X=(o,l,h)=>{const E=o.attributes,b={tagName:o.tagName.toLowerCase()};for(const A of E)b[A.nodeName]=A.value;if(h){b.innerHTML=o.innerHTML,b.revertChildren=[];const A=o.querySelectorAll("[data-o-init]");for(const _ of A){const F=_.getAttribute("data-o-init");b.revertChildren.push(F),t.inits[F]?.saveState(l,!1)}}return b};return e.saveState=T((o,l=!0)=>{if($([[o,[f,S]],[l,[w]]]),!e.el)throw Error("saveState(): There are no elements to save");const h=o||"fastSavedState",E={els:[],parentNode:e.el.parentNode,root:l};R(()=>{E.els.push(X(e.els[a],h,l))}),E.ie=Object.assign({},e.ie),E.delegated=Object.assign({},e.delegated),E.store=Object.assign({},e.store),e.isRoot=e.isRoot||l,e.savedStates[h]=E},"saveState"),e.revertState=T(o=>{$([[o,[f,S]]]);const l=o||"fastSavedState";if(!e.savedStates[l])throw Error(`revertState(): The state "${l}" should have been saved by saveState()`);const h=e.savedStates[l];e.offAll(),e.offDelegate(),e.store=Object.assign({},h.store),h.els.forEach((E,b)=>{if(!e.els[b]){const A=t.D.createElement(E.tagName);h.parentNode&&(b?e.els[b-1].after(A):h.parentNode.append(A)),e.add(A)}V(e.els[b],E)}),e.delegated=Object.assign({},h.delegated),e.ie=Object.assign({},h.ie),e.onAll(),D(h.delegated,E=>{h.delegated[E].forEach(b=>{R(()=>{e.els[a].addEventListener(E,b)})})}),e.currentState=l,h.root&&h.els.forEach(({rootElement:E})=>{E.revertChildren.forEach(b=>{t.inits[b]?.revertState(l),t('[data-o-init="'+b+'"]').els.forEach((A,_)=>{A.replaceWith(t.inits[b]?.els[_])})})})},"revertState"),e.loseState=T(o=>{$([[o,[f]]]),e.savedStates[o]&&(delete e.savedStates[o],R(()=>{const l=e.els[a].querySelectorAll("[data-o-init]");for(const h of l){const E=h.getAttribute("data-o-init");t.inits[E]?.loseState(o)}}))},"sample"),e.sample=T((o="render")=>($([[o,[f]]]),{[o]:X(e.els[s])}),"sample"),e.select=T(o=>{let l=o;l!=null&&p(l)===u&&l.target&&e.els.length&&(l=e.els.findIndex(h=>h===l.target||h.contains(l.target)),l<0&&(l=0)),$([[l,[I,S]]]),l===O&&(l=e.length-i),C=l,s=l,e.el=e.els[l],c=i,Array.isArray(e._refsByIndex)&&e._refsByIndex[l]&&(e.refs=e._refsByIndex[l])},"select"),e.all=T(()=>{C=e.length-i,s=0,e.el=e.els[0],c=0,Array.isArray(e._refsByIndex)&&e._refsByIndex.length&&(e.refs=e._refsByIndex[0]||{})},"all"),e.remove=T(o=>{if($([[o,[I,S]]]),o===O&&c&&(o=s),o!==O){const l=e.els[o];l?.parentNode?l.parentNode.removeChild(l):l===void 0&&o>=e.els.length&&t.onError&&t.onError("remove("+o+"): index out of bounds","remove")}else R(()=>{const l=e.els[a];l?.parentNode&&l.parentNode.removeChild(l)});J(!1)},"remove"),e.skip=T(o=>{$([[o,[I,S]]]),o===O&&(o=s),e.els.splice(o,i),Array.isArray(e._refsByIndex)&&e._refsByIndex.splice(o,i),J()},"skip"),e.add=T(o=>{$([[o,[v,u,I]]]),e.initID===O&&(p(o)==="string"&&o!==""?e.els.push(...Array.from(y.querySelectorAll(o))):p(o)===u?o.tagName?e.els.push(o):o.els?e.els.push(...o.els):o.length&&o[0].tagName&&e.els.push(...o):p(o)==="number"&&t.inits[o]&&(e=t.inits[o]),J(!1),e.initID!==O&&e.dataset({oInit:e.initID}))},"add"),e.appendInside=T(o=>{$([[o,[u,f]]]),o?.els&&(e._parent=o),R(()=>{U(o).appendChild(e.els[a])})},"appendInside"),e.appendBefore=T(o=>{$([[o,[u,f]]]),R(()=>{U(o).parentNode.insertBefore(e.els[a],U(o))})},"appendBefore"),e.appendAfter=T(o=>{$([[o,[u,f]]]),R(()=>{U(o).after(...e.els)})},"appendAfter"),e.find=T((o="")=>{$([[o,v]]);const l=[];return R(()=>{l.push(...Array.from(e.els[a].querySelectorAll(":scope "+o)))}),t(l)},"find"),e.first=T((o="")=>{$([[o,v]]);let l=O;const h=[];return R(()=>{l=e.els[a].querySelector(o),l&&h.push(l)}),t(h)},"first"),e.attr=T((o,l)=>{if(l!==null&&$([[o,v],[l,[v,S]]]),l===O){const h=[];return R(()=>{h[a]=e.els[a].getAttribute(o)}),c?h[0]:h}else R(l!==null?()=>{e.els[a].setAttribute(o,l)}:()=>{e.els[a].removeAttribute(o)})},"attr"),e.attrs=T(()=>{const o=[];return R(()=>{const l={};[...e.els[a].attributes].forEach(h=>{l[h.nodeName]=h.nodeValue}),o.push(l)}),c?o[0]:o},"attrs"),e.dataset=T(o=>{if($([[o,[u,S]]]),typeof o===u)R(()=>{D(o,l=>{e.els[a].dataset[l]=o[l]})});else{const l=[];return R(()=>{l.push({...e.els[a].dataset})}),c?l[0]:l}},"dataset"),e.style=T(o=>{o!==null&&$([[o,[v,S]]]),e.attr("style",o)},"style"),e.css=T((o={})=>{if(o===null){e.style(null);return}$([[o,u]]);let l="";D(o,h=>{l+=h+":"+o[h].replace('"',"'")+";"}),e.style(l||null)},"css"),e.setClass=T(o=>{$([[o,v]]),R(()=>{e.els[a].setAttribute("class",o)})},"setClass"),e.addClass=T((...o)=>{R(()=>{e.els[a].classList.add(...o)})},"addClass"),e.removeClass=T((...o)=>{R(()=>{e.els[a].classList.remove(...o)})},"removeClass"),e.toggleClass=T((o,l)=>{$([[o,f],[l,[w,S]]]),R(()=>{e.els[a].classList.toggle(o,l)})},"toggleClass"),e.haveClass=o=>{$([[o,f]]);let l=!0;return R(()=>{e.els[a].classList.contains(o)||(l=!1)}),(e.isDebug||t.debug)&&console.log("haveClass() with",o),l},e.innerHTML=T(o=>{if($([[o,[v,S]]]),o!==O)R(()=>{e.els[a].innerHTML=o});else{let l="";return R(()=>{l+=g&&e.els[a].innerHTML.length===0?t.D.parseElement(e.els[a],!1):e.els[a].innerHTML}),l}},"innerHTML"),e.innerText=T(o=>{$([[o,[v]]]),R(()=>{e.els[a].innerText=o})},"innerText"),e.textContent=T(o=>{$([[o,[v]]]),R(()=>{e.els[a].textContent=o})},"textContent"),e.html=T(o=>{if($([[o,[v,S]]]),o!==void 0)e.innerHTML(o);else{let l="";return R(()=>{l+=g?e.els[a].outerHTML():e.els[a].outerHTML}),l}},"html"),e.toString=function(){return e.html()},e[Symbol.toPrimitive]=function(o){return o==="string"||o==="default"?e.html():o==="number"?e.els?.length??0:e.html()},e.val=T(o=>{if(o===void 0)return e.el?.value;R(()=>{e.els[a].value=o})},"val"),e.forEach=T(o=>{$([[o,[x]]]),R(()=>{o({self:e,i:a,o:t,el:e.els[a]})})},"forEach"),e.prepareFor=T((o,l)=>{$([[o,[u,x,S]],[l,[x,S]]]);const h=o&&p(o)===u&&o.createElement;if(!h&&p(o)!==x)throw Error("prepareFor(): pass React (full object) or React.createElement as first argument");const E=h?o.createElement:o,b=h?o.useEffect:void 0;return A=>{if(A.ref===O)throw Error("No ref property to convert Objs to React");const _=Object.assign({},A),F=E("div",{ref:A.ref});return delete _.ref,b(()=>{D(_,j=>{if(j.substring(0,1)==="on"){const H=t.camelToKebab(j).split("-")[1];e.on(H,_[j]),delete _[j]}}),e.render(_),e.appendInside(F.ref.current)},[]),F}},"prepareFor"),e.on=T((o,l,h,E)=>{$([[o,[f]],[l,[x]],[h,[u,S]],[E,[w,S]]]),o.split(", ").forEach(b=>{R(()=>{e.els[a].addEventListener(b,l,h,E)}),e.ie[b]||(e.ie[b]=[]),e.ie[b].push([l,h,E])})},"on"),e.off=T((o,l,h)=>{$([[o,[f]],[l,[x]],[h,[u,S]]]),o.split(", ").forEach(E=>{R(()=>{e.els[a].removeEventListener(E,l,h)}),e.ie[E]&&(e.ie[E]=e.ie[E].filter(b=>b[0]!==l))})},"off"),e.onDelegate=T((o,l,h)=>{$([[o,[f]],[l,[f]],[h,[x]]]),o.split(", ").forEach(E=>{const b=A=>{const _=A.target.closest(l);_&&(A.delegate=_,A.objs=e,h(A))};R(()=>{e.els[a].addEventListener(E,b)}),e.delegated[E]||(e.delegated[E]=[]),e.delegated[E].push(b)})},"onDelegate"),e.offDelegate=T(o=>{$([[o,[f]]]),D(e.delegated,l=>{if(!o||o===l)for(;e.delegated[l].length;){const h=e.delegated[l].pop();R(()=>{e.els[a].removeEventListener(l,h)})}}),e.delegated={}},"offDelegate"),e.onParent=T((o,l,h)=>{$([[o,[f]],[l,[f,u]],[h,[x]]]);const E=p(l)===u?l:t.D.querySelector(l);o.split(", ").forEach(b=>{const A=_=>{_.objs=e,h(_)};E.addEventListener(b,A),e.parented[b]||(e.parented[b]=[]),e.parented[b].push(A)})},"onParent"),e.offParent=T((o,l)=>{$([[o,[f]],[l,[f,u]]]);const h=p(l)===u?l:t.D.querySelector(l);D(e.parented,E=>{(!o||o===E)&&(e.parented[E].forEach(b=>{h.removeEventListener(E,b)}),delete e.parented[E])})},"offParent"),e.onAll=T((o,l)=>{$([[o,[f,S]],[l,[w,S]]]),D(e.ie,(h,E)=>{(!o||o===h)&&E[h].forEach(b=>{R(()=>{l?e.els[a].removeEventListener(h,b[0]):e.els[a].addEventListener(h,b[0],b[i],b[r])})})})},"onAll"),e.offAll=T(o=>{$([[o,[f]]]),e.onAll(o,i)},"offAll"),n&&e.add(n),e.take=o=>{if($([[o,[v,u,I]]]),e.add(o),e.el){const l=e.el.dataset.oInit;if(l!==O&&t.inits[l])return e.length===i?(L=e.els[0],Object.assign(e,t.inits[l]),e.els=[L]):e=t.inits[l],J(!1,e.els),e}},e};t.first=n=>(t.verify([[n,["notEmptyString"]]]),t.debug&&console.log(n," -> ","o.first()"),t(t.D.querySelector(n)).select(0)),t.inits=[],t.getSaved={},t.errors=[],t.showErrors=!1,t.logErrors=()=>{t.errors.length?t.errors.forEach(n=>console.error(n)):console.log("No errors")},t.onError=(n,e)=>{t.showErrors?console.error(n,e):(t.errors.push(n),e&&t.errors.push(e))},t.reactRender=()=>new Error("React render function is not defined"),t.autotag=void 0,t.reactQA=n=>({["data-"+(t.autotag||"qa")]:n.replace(/([A-Z])/g,(e,i)=>"-"+i.toLowerCase()).replace(/^-/,"")}),t.specialTypes={notEmptyString:(n,e)=>e==="string"&&n.length,array:n=>Array.isArray(n),promise:n=>n instanceof Promise||!!(n&&typeof n.then=="function")},t.verify=(n,e=!1)=>{for(const i of n){const r=typeof i[0];let d=Array.isArray(i[1])?i[1]:[i[1]],w=!1;if(d.includes(r))return!0;d=d.filter(u=>!!t.specialTypes[u]);for(const u of d)if(w=t.specialTypes[u](i[0],r),w)return!0}return e?!1:new Error("Type verification failed")},t.safeVerify=n=>t.verify(n,!0),t.init=(n,e)=>t().init(n,e),t.initState=(n,e)=>t().init(n).render(e),t.take=n=>t().take(n),t.getStates=()=>t.inits.reduce((n,e)=>(n.push(e?.states),n),[]),t.getStores=()=>t.inits.reduce((n,e)=>(n.push(e?.store),n),[]),t.getListeners=()=>t.inits.reduce((n,e)=>(n.push(e?.ie),n),[]),t.createStore=n=>{const e=Object.assign({},n);return e._defaults=Object.assign({},n),e._listeners=[],e.subscribe=function(i,r){return this._listeners.push(d=>i[r]?.(d)),this},e.notify=function(){this._listeners.forEach(i=>i(this))},e.reset=function(){const i={_listeners:1,subscribe:1,notify:1,_defaults:1,reset:1};for(const r of Object.keys(this._defaults))i[r]||(this[r]=this._defaults[r])},e},t.U=void 0,t.W=2,t.H=100,t.F=!1,t.C=(n,e)=>Object.hasOwn(n,e),t.kebabToCamel=n=>n.replace(/-./g,e=>e.toUpperCase()[1]),t.camelToKebab=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),t.route=(n,e)=>{t.verify([[n,["notEmptyString","function","boolean"]],[e,["function","object"]]]);const i=typeof n=="function"?n(window.location.pathname):n;return i===!0||window.location.pathname===i?e?typeof e=="function"?(e(),!0):e:t:typeof e=="function"?!1:{}},t.router=(n={})=>{t.verify([[n,["object"]]]);for(const e in n)if(t.C(n,e)&&window.location.pathname===e)return typeof n[e]=="function"?(n[e](),!0):n[e];return!1},t.DocumentMVP={addEventListener:()=>{},parseElement:(n,e=!0)=>{t.verify([[n,["object","string"]],[e,["boolean"]]]);const i=(r,d="")=>{let w="";for(const u in r)t.C(r,u)&&(w+=` ${d}${t.camelToKebab(u)}="${typeof r[u]!="object"?r[u]:Object.entries(r[u]).map(x=>`${x[0]}: ${x[1]};`).join(" ")}"`);return w};if(typeof n=="string")return n;if(e){const r=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],d=n.tagName.toLowerCase(),w=n.attributes["data-o-init"],u=w!==void 0?` data-o-init="${w}"`:"";return`<${d}${n.className?` class="${n.className}"`:""}${i(n.attributes)}${u}${i(n.dataset,"data-")}${r.includes(d)?"/":""}>${r.includes(d)?"":n.innerHTML.length?n.innerHTML:n.children.map(x=>t.D.parseElement(x)).join("")}${r.includes(d)?"":`</${d}>`}`}return n.innerHTML.length?n.innerHTML:n.children.map(r=>t.D.parseElement(r)).join("")},createElement:n=>{t.verify([[n,["notEmptyString"]]]);const e={tagName:n.toUpperCase(),attributes:{},innerHTML:"",children:[],dataset:{},className:"",classArray:[],style:{},addEventListener:()=>{},removeEventListener:()=>{}};return e.classList={add:(...i)=>{t.verify([[i,["array"]]]),e.classArray.push(i),e.className=e.classArray.join(" ")},has:i=>(t.verify([[i,["notEmptyString"]]]),e.classArray.includes(i)),remove:i=>{t.verify([[i,["notEmptyString"]]]),e.classArray=e.classArray.filter(r=>i!==r),e.className=e.classArray.join(" ")}},e.classList.toggle=i=>{t.verify([[i,["notEmptyString"]]]),e.classList.has(i)?e.classList.remove(i):e.classList.add(i)},e.setAttribute=(i,r)=>{t.verify([[i,["notEmptyString"]],[r,["string","number","boolean","undefined"]]]),e.attributes[i]=r},e.getAttribute=i=>(t.verify([[i,["notEmptyString"]]]),e.attributes[i]),e.removeAttribute=i=>{t.verify([[i,["notEmptyString"]]]),delete e.attributes[i]},e.appendChild=i=>{t.verify([[i,["object"]]]),e.children.push(i),e.firstElementChild=e.children[0]},e.outerHTML=()=>t.D.parseElement(e),e}},t.D=typeof document<"u"&&typeof process>"u"?document:t.DocumentMVP,t.setCookie=(n,e="",i={})=>{if(t.verify([[n,["notEmptyString"]],[e,["string","number","boolean"]],[i,["object"]]]),t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}let r=encodeURIComponent(n)+"="+encodeURIComponent(e);i={path:"/",...i},i.expires instanceof Date?i.expires=i.expires.toUTCString():typeof i.expires=="number"&&(i.expires=new Date(i.expires).toUTCString());for(const d in i){r+="; "+d;const w=i[d];w!==!0&&(r+="="+w)}t.D.cookie=r},t.getCookie=n=>{if(t.verify([[n,["notEmptyString"]]]),t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}const e=t.D.cookie.match(RegExp("(?:^|; )"+n.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0},t.deleteCookie=n=>{t.verify([[n,["notEmptyString"]]]),t.setCookie(n,"",{"max-age":0})},t.clearCookies=()=>{if(t.D.cookie===void 0){console.log("Cookies are not supported on server side");return}const n=t.D.cookie.split(";");for(;n.length;){let e=n.pop();for(;e.charAt(0)===" ";)e=e.substring(1);const i=e.split("=")[0];t.deleteCookie(i)}},t.clearLocalStorage=n=>{if(t.verify([[n,["boolean","undefined"]]]),!(typeof localStorage>"u"))if(n)localStorage.clear();else for(let e=localStorage.length-1;e>=0;e--){const i=localStorage.key(e);i.indexOf("oInc-")===-1&&i.indexOf("oTest-")===-1&&localStorage.removeItem(i)}},t.clearSessionStorage=n=>{if(t.verify([[n,["boolean","undefined"]]]),!(typeof sessionStorage>"u"))if(!n)sessionStorage.clear();else for(let e=sessionStorage.length-1;e>=0;e--){const i=sessionStorage.key(e);i&&i.indexOf("oTest-")===0&&sessionStorage.removeItem(i)}},t.clearTestsStorage=()=>{t.clearSessionStorage(1)},t.clearAfterTests=()=>{t.clearCookies(),t.clearLocalStorage(!1),t.clearTestsStorage()},t.ajax=(n,e={})=>{t.verify([[n,["notEmptyString"]],[e,["object"]]]);const i=new URLSearchParams;if(e.data&&typeof e.data=="object"){for(const r in e.data)t.C(e.data,r)&&(typeof e.data[r]=="object"?i.set(r,encodeURIComponent(JSON.stringify(e.data[r]))):i.set(r,e.data[r]));e.method.toLowerCase()==="get"?n+="?"+i.toString():e.body||(e.body=i),delete e.data}return e.headers||(e.headers={"X-Requested-With":"XMLHttpRequest"}),fetch(n,e)},t.get=(n,e={})=>(t.verify([[n,["notEmptyString"]],[e,["object"]]]),t.ajax(n,{...e,method:"GET"})),t.post=(n,e={})=>(t.verify([[n,["notEmptyString"]],[e,["object"]]]),t.ajax(n,{...e,method:"POST"})),t.newLoader=n=>{t.verify([[n,["promise","undefined"]]]);let e=[],i=null,r=!1,d=!1;const w=u=>{r=!1,d=!1,i=null,setTimeout(()=>{u.then(x=>{r=!0,!x.ok&&typeof x.ok<"u"?(d=!0,e.forEach(([v,I,f])=>{f&&v[f](x)})):typeof x.json=="function"?x.json().then(v=>{i=v,e.forEach(([I,f])=>{I[f](i)})}):(i=x,e.forEach(([v,I])=>{v[I](i)}))}).catch(x=>{d=!0,e.forEach(([v,I,f])=>{f&&v[f](x)})})},33)};return n&&w(n),{reload:w,isObjsLoader:!0,listeners:e,isFinished:()=>r,getStore:()=>i,connect:(u,x="render",v)=>{t.verify([[u,["object"]],[x,["notEmptyString"]],[v,["string","undefined"]]]),r?d?v&&u[v]():typeof u[x]=="function"&&u[x](i):e.push([u,x,v])},disconnect:u=>{t.verify([[u,["object"]]]),e=e.filter(([x])=>x!==u)}}},t.getParams=n=>{t.verify([[n,["string","undefined"]]]);const e={},i=new URLSearchParams(window.location.search).entries();for(const r of i)e[r[0]]=r[1];return n?e[n]:e},t.incCache=!0,t.incCacheExp=1e3*60*60*24,t.incTimeout=6e3,t.incSource="",t.incForce=t.F,t.incAsync=!0,t.incCors=t.F,t.incSeparator="?",t.incFns={},t.incSet=[0],t.incReady=[0],t.incN=0,t.incGetHash=n=>n.split(t.incSeparator)[1]||"",t.incCheck=(n=0,e,i=0)=>(t.verify([[n,["number"]],[e,["number","undefined"]],[i,["number"]]]),!i&&n&&e===t.U&&t.incReady[n]?t.incSet[n]===1:t.incReady[n]===t.U||t.incReady[n][e]===t.U?t.F:(t.incReady[n][e].loaded=i,t.incFns[t.incReady[n][e].name]=i,t.incReady[n][0]+=i,n&&t.incReady[n].length===t.incReady[n][0]&&(typeof t.incSet[n]=="function"&&t.incSet[n](n),t.incSet[n]=1),t.incSet[n]===1)),t.incCacheClear=(n=t.F)=>{t.verify([[n,["boolean"]]]);for(const e in t.incFns)t.C(t.incFns,e)&&(localStorage.removeItem("oInc-"+e),localStorage.removeItem("oInc-"+e+"-expires"));return n&&(t.incReady.forEach((e,i)=>{i&&e.forEach((r,d)=>{d&&t("#oInc-"+i+"-"+d).remove()})}),t.incN=0,t.incFns={},t.incSet=[0],t.incReady=[0]),!0},t.inc=(n,e,i)=>{if(t.verify([[n,["object","undefined"]],[e,["function","undefined"]],[i,["function","undefined"]]]),typeof localStorage>"u")return;let r=0,d=0,w="",u=!1;const x="function",v=-1;if(typeof n!="object"||!n)return t.incSet[0];t.incSet[0]++;const I=t.incSet[0];t.incSet[I]=e||0,t.incReady[I]=[];const f=t.incReady[I];f[0]=1;const S={};for(const m in n)if(t.C(n,m)){if(m==="preload"){u=!0;continue}w=t.incGetHash(n[m]),r++,t.incN++;const O=n[m].indexOf(".css")>v?"style":"script";if(n[m]=(t.incSource?t.incSource+"/":"")+n[m],Number.isNaN(Number(m))&&t.C(t.incFns,m)&&t.incFns[m]&&!t.incForce){f[r]={name:m,loaded:1},d++;continue}if(f[r]={name:m,loaded:0},Number.isNaN(Number(m))&&(t.incFns[m]=0),Number.isNaN(Number(m))&&t.incCache&&(n[m].substring(0,4)!=="http"||!t.incCors)&&window.location.protocol!=="file:"&&(n[m].indexOf(".css")>v||n[m].indexOf(".js")>v)){const y=localStorage,C=y.getItem("oInc-"+m),s=y.getItem("oInc-"+m+"-expires"),c=y.getItem("oInc-"+m+"-hash");C&&s&&Date.now()<s&&c===w?(u||t.initState({tag:O,id:"oInc-"+I+"-"+r,innerHTML:C,"data-o-inc":I}).appendInside("head"),f[r].loaded=1,t.incFns[m]=1,d++):(S[m]=r,t.get(n[m],{mode:t.incCors?"cors":"same-origin"}).then(g=>{if(g.status!==200){t.onError&&t.onError({message:t.incSource+n[m]+" was not loaded"});return}g.text().then(a=>{y.setItem("oInc-"+m,a),y.setItem("oInc-"+m+"-expires",Date.now()+t.incCacheExp),y.setItem("oInc-"+m+"-hash",w),u||t.initState({tag:O,id:"oInc-"+I+"-"+S[m],innerHTML:a,"data-o-inc":I}).appendInside("head"),t.incCheck(I,S[m],1)})}))}else{const y={tag:O,id:"oInc-"+I+"-"+r,"data-o-inc":I,async:t.incAsync,onload:"o.incCheck("+I+","+r+",1)"};n[m].indexOf(".css")>v?(y.tag="link",y.rel="stylesheet",y.href=n[m]):(n[m].indexOf(".js")>v||(y.tag="img",y.style="display:none;"),y.src=n[m]),t.initState(y).appendInside(y.style?"body":"head")}}return f[0]+=d,r!==0&&(d===r?typeof e===x&&e(I):setTimeout(m=>{t.incReady[m]&&t.incReady[m].length<t.incReady[m][0]&&(t.incSet[m]=0,typeof i===x&&i(I))},t.incTimeout,I)),t.incSet[0]},t.connectRedux=(n,e,i,r="render")=>{t.verify([[n,["object"]],[e,["function"]],[i,["object"]],[r,["notEmptyString"]]]);const d=()=>{if(typeof i[r]=="function"){const w=e(n.getState());i[r](w!==null&&typeof w=="object"?w:{value:w})}};return d(),n.subscribe(d)},t.connectMobX=(n,e,i,r,d="render")=>(t.verify([[n,["object"]],[e,["object"]],[i,["function"]],[r,["object"]],[d,["notEmptyString"]]]),n.autorun(()=>{if(typeof r[d]=="function"){const w=i(e);r[d](w!==null&&typeof w=="object"?w:{value:w})}})),t.ObjsContext=null,t.withReactContext=(n,e,i,r,d="render")=>function(){const u=n.useContext(e);return n.useEffect(()=>{if(typeof r[d]=="function"){const x=i(u);r[d](x!==null&&typeof x=="object"?x:{value:x})}},[u]),null},t.debug=!1,t.sleep=n=>new Promise(e=>setTimeout(e,n)),t.tLog=[],t.tRes=[],t.tStatus=[],t.tFns=[],t.tShowOk=t.F,t.tStyled=t.F,t.tTime=2e3,t.tests=[],t.tExpectedSteps={},t.tFinalized={},t.tAutolog=t.F,t.tBeforeEach=void 0,t.tAfterEach=void 0,t.addTest=(n,...e)=>{t.verify([[n,["notEmptyString"]],[e,["array"]]]);let i={};e.length&&typeof e[e.length-1]=="object"&&!Array.isArray(e[e.length-1])&&(i=e.pop());const r=t.tests.length;return t.tests[r]={title:n,tests:e,hooks:i},{run:()=>{typeof i.before=="function"&&(t.tBeforeEach=i.before),typeof i.after=="function"&&(t.tAfterEach=i.after),t.runTest(r)},autorun:()=>{typeof i.before=="function"&&(t.tBeforeEach=i.before),typeof i.after=="function"&&(t.tAfterEach=i.after),t.runTest(r,!0)},testId:r}},t.updateLogs=()=>{for(let n=0;n<t.tests.length;n++)t.tLog[n]=t.tLog[testN]=sessionStorage.getItem(`oTest-Log-${testN}`)||"";return t.tLog},t.runTest=(n=0,e,i)=>{if(t.verify([[n,["number"]],[e,["boolean","undefined"]],[i,["boolean","undefined"]]]),!t.tests[n])return;i||(sessionStorage?.removeItem(`oTest-Log-${n}`),sessionStorage?.removeItem(`oTest-Res-${n}`),sessionStorage?.removeItem(`oTest-Status-${n}`)),sessionStorage?.setItem("oTest-Run",n),e?sessionStorage?.setItem("oTest-Autorun",e):sessionStorage?.removeItem("oTest-Autorun");const r=t.tests[n];let d=r.tests.pop();typeof d!="function"&&(r.tests.push(d),d=()=>{}),r.tests.push(w=>{d(w),sessionStorage.setItem("dddd",1),sessionStorage?.removeItem("oTest-Run"),e&&t.runTest(n+1,e)}),t.test(r.title,...r.tests)},t.tPre='<div style="font-family:monospace;text-align:left;">',t.tOk='<span style="background:#cfc;padding: 0 15px;">OK</span> ',t.tXx='<div style="background:#fcc;padding:3px;">',t.tDc="</div>",t.test=(n="",...e)=>{t.verify([[n,["notEmptyString"]],[e,["array"]]]);const i=sessionStorage?.getItem("oTest-Run"),r=i||t.tLog.length;let d=0,w="\u251C OK: ",u="\u251C \u2718 ",x=`
|
|
7
|
+
`,v=`
|
|
8
|
+
`,I="",f=e.length,S=0;const m=(s="",c=!1,g=!1)=>{t.tAutolog&&(c?console.error(s):(t.tShowOk||g)&&console.log(s))};let O={};if(typeof e[f-1]=="function"&&(t.tFns[r]=e[f-1],f--),f>0&&typeof e[f-1]=="object"&&!Array.isArray(e[f-1])&&(e[f-1].sync!==void 0||e[f-1].confirmOnFailure!==void 0)&&(O=e[f-1],f--),i){t.tLog[r]=sessionStorage.getItem(`oTest-Log-${r}`)||"",t.tRes[r]=sessionStorage.getItem(`oTest-Res-${r}`)||!1,t.tStatus[r]=JSON.parse(sessionStorage.getItem(`oTest-Status-${r}`)||"[]");for(let s=0;s<t.tStatus[r].length;s++){const c=t.tStatus[r][s];(c===!0||c===!1)&&S++}}t.tStyled&&(w=t.tPre+t.tOk,u=t.tPre+t.tXx,x=t.tDc,v=x+x),(!i||t.tLog[r].length===0)&&(m("\u2552 "+n+" #"+r,!1,!0),t.tStyled?t.tLog[r]="<div><b>"+n+" #"+r+"</b></div>":t.tLog[r]="\u2552 "+n+" #"+r+`
|
|
9
|
+
`,t.tRes[r]=t.F,t.tStatus[r]=[]),t.tExpectedSteps[r]=f,t.tFinalized[r]=!1;const y=(s,c)=>new Promise(g=>{const a=t.overlay({innerHTML:`<div style="display:flex;flex-direction:column;gap:8px;"><div style="cursor:grab;">Step ${s+1} failed: ${c||"error"}. Continue testing?</div><div style="display:flex;gap:8px;"><button class="o-cf-continue" style="padding:6px 12px;background:#2563eb;color:#fff;border:none;border-radius:6px;cursor:pointer;">Continue</button><button class="o-cf-stop" style="padding:6px 12px;background:#dc2626;color:#fff;border:none;border-radius:6px;cursor:pointer;">Stop</button></div></div>`,timeout:O.confirmOnFailureTimeout||void 0,onClose:L=>g(L||{continue:!1}),excludeDragSelector:".o-cf-continue, .o-cf-stop"});a.first(".o-cf-continue").on("click",()=>{a._overlayCleanup(),g({continue:!0})}),a.first(".o-cf-stop").on("click",()=>{a._overlayCleanup(),g({continue:!1})})}),C=()=>{if(t.tFinalized[r])return;t.tFinalized[r]=!0;const s=t.tStatus[r].some(c=>c===!1);t.tRes[r]=!s&&S===f,I=d?"\u251C ":"\u2558 ",I+="DONE "+S+"/"+f+(d?", waiting: "+d:""),m(I,S+d!==f),d||m(),t.tStyled?t.tLog[r]+=t.tPre+'<div style="color:'+(S+d!==f?"red":"green")+';"><b>DONE '+S+"/"+f+(d?", waiting: "+d:"")+"</b>"+t.tDc+t.tDc:t.tLog[r]+=I+`
|
|
10
|
+
`,i&&(sessionStorage.setItem(`oTest-Log-${r}`,t.tLog[r]),sessionStorage.setItem(`oTest-Res-${r}`,t.tRes[r]),sessionStorage.setItem(`oTest-Status-${r}`,JSON.stringify(t.tStatus[r]))),!d&&typeof t.tFns[r]=="function"&&t.tFns[r](r)};if(O.sync||O.confirmOnFailure)return(async()=>{for(let s=t.tStatus[r].length;s<f;s++){const c={n:r,i:s,title:e[s][0],tShowOk:t.tShowOk,tStyled:t.tStyled};let g=e[s][1];if(typeof g>"u"){t.tStyled?t.tLog[r]+="<div>"+c.title+"</div>":t.tLog[r]+=c.title+`
|
|
11
|
+
`,m("\u251C "+c.title,!1,!0),t.tStatus[r][s]=!0,S++;continue}if(typeof t.tBeforeEach=="function"&&t.tBeforeEach(c),typeof g=="function")try{g=g(c)}catch(a){g=a.message,t.onError&&t.onError(a)}if(typeof t.tAfterEach=="function"&&t.tAfterEach(c,g),g&&typeof g.then=="function"){try{const a=await g,L=a===!0||a==null||a&&typeof a=="object"&&a.ok===!0,k=a&&a.errors&&a.errors.length?a.errors.join("; "):typeof a=="string"?a:"";if(t.testUpdate(c,L,L?"":k?": "+k:""),S++,!L&&O.confirmOnFailure&&!(await y(s,k)).continue)break}catch(a){if(t.testUpdate(c,!1,a.message||"Promise rejected"),O.confirmOnFailure&&!(await y(s,a.message||"Promise rejected")).continue)break}continue}if(typeof t.tStatus[r][s]>"u")t.tStatus[r][s]=typeof g=="string"?t.F:g;else{sessionStorage.setItem(`oTest-Status-${r}`,JSON.stringify(t.tStatus[r]));return}if(g===!0)S++,t.tShowOk&&(t.tLog[r]+=w+e[s][0]+x,m("\u251C OK: "+e[s][0]));else if(g!==t.U){if(t.tLog[r]+=u+e[s][0]+(g!==t.F?": "+g:"")+v,m("\u251C \u2718 "+e[s][0]+(g!==t.F?": "+g:""),!0),O.confirmOnFailure&&!(await y(s,typeof g=="string"?g:"")).continue)break}else{d++,setTimeout(a=>{a.title+=" (timeout)",t.testUpdate(a)},t.tTime,c);return}}C()})(),r;for(let s=t.tStatus[r].length;s<f;s++){const c={n:r,i:s,title:e[s][0],tShowOk:t.tShowOk,tStyled:t.tStyled};let g=e[s][1];if(typeof g>"u"){t.tStyled?t.tLog[r]+="<div>"+c.title+"</div>":t.tLog[r]+=c.title+`
|
|
12
|
+
`,m("\u251C "+c.title,!1,!0),t.tStatus[r][s]=!0,S++;continue}if(typeof t.tBeforeEach=="function"&&t.tBeforeEach(c),typeof g=="function")try{g=g(c)}catch(a){g=a.message,t.onError&&t.onError(a)}if(typeof t.tAfterEach=="function"&&t.tAfterEach(c,g),g&&typeof g.then=="function"){d++;const a=setTimeout(()=>{c.title+=" (timeout)",t.testUpdate(c)},t.tTime);g.then(L=>{clearTimeout(a);const k=L===!0||L&&L.ok===!0,p=L&&L.errors&&L.errors.length?L.errors.join("; "):typeof L=="string"?L:"";t.testUpdate(c,k,k?"":p?": "+p:"")}).catch(L=>{clearTimeout(a),t.testUpdate(c,!1,L.message||"Promise rejected")});continue}if(typeof t.tStatus[r][s]>"u")t.tStatus[r][s]=typeof g=="string"?t.F:g;else{sessionStorage.setItem(`oTest-Status-${r}`,JSON.stringify(t.tStatus[r]));return}g===!0?(S++,t.tShowOk&&(t.tLog[r]+=w+e[s][0]+x,m("\u251C OK: "+e[s][0]))):g!==t.U?(t.tLog[r]+=u+e[s][0]+(g!==t.F?": "+g:"")+v,m("\u251C \u2718 "+e[s][0]+(g!==t.F?": "+g:""),!0)):(d++,setTimeout(a=>{a.title+=" (timeout)",t.testUpdate(a)},t.tTime,c))}return C(),r},t.testUpdate=(n,e=t.F,i="")=>{t.verify([[n,["object"]],[e,["boolean","string"]],[i,["string"]]]);let r="";const d=n.n,w=(u="",x=!1)=>{t.tAutolog&&(x?console.error(u):console.log(u))};if(t.tStatus[d][n.i]===t.U||t.tStatus[d][n.i]===null){t.tStatus[d][n.i]=e===!0,e===!0?n.tShowOk&&(r="\u251C OK: "+n.title+i,w(r),n.tStyled?t.tLog[d]+=t.tPre+t.tOk+n.title+i+t.tDc:t.tLog[d]+=r+`
|
|
13
|
+
`):(t.tRes[d]=t.F,r="\u251C \u2718 "+n.title+(e?": "+e:"")+i,w(r,!0),n.tStyled?t.tLog[d]+=t.tPre+t.tXx+n.title+i+(e?": "+e:"")+t.tDc+t.tDc:t.tLog[d]+=r+`
|
|
14
|
+
`);let u=0,x=0;for(const I of t.tStatus[d]){if(I===t.U||I===null)return;I||u++,x++}const v=t.tests[d]?.tests?.length??t.tExpectedSteps[d]??Number.MAX_SAFE_INTEGER;if(x<v){sessionStorage?.getItem("oTest-Run")===d&&(sessionStorage.setItem(`oTest-Log-${d}`,t.tLog[d]),sessionStorage.setItem(`oTest-Res-${d}`,t.tRes[d]),sessionStorage.setItem(`oTest-Status-${d}`,JSON.stringify(t.tStatus[d])));return}if(t.tFinalized[d])return;t.tFinalized[d]=!0,sessionStorage?.getItem("oTest-Run")===d&&(sessionStorage.setItem(`oTest-Log-${d}`,t.tLog[d]),sessionStorage.setItem(`oTest-Res-${d}`,t.tRes[d]),sessionStorage.setItem(`oTest-Status-${d}`,JSON.stringify(t.tStatus[d]))),t.tRes[d]=!u,r=u?"FAILED "+u+"/"+x:"DONE "+x+"/"+x,w("\u2558 "+r,!!u),w(),n.tStyled?t.tLog[d]+=t.tPre+'<b style="color:'+(u?"red":"green")+';">'+r+"</b>"+t.tDc:t.tLog[d]+="\u2558 "+r+`
|
|
15
|
+
`,typeof t.tFns[d]=="function"&&t.tFns[d](d)}},sessionStorage?.getItem("oTest-Run")&&window?.addEventListener("load",()=>{t.runTest(sessionStorage?.getItem("oTest-Run"),sessionStorage?.getItem("oTest-Autorun")||t.F,!0)},!1),t.measure=n=>{if(!n)return{};const e=n.getBoundingClientRect(),i=window.getComputedStyle(n);return{width:e.width,height:e.height,top:e.top,left:e.left,visible:i.display!=="none"&&i.visibility!=="hidden"&&e.width>0,opacity:i.opacity,zIndex:i.zIndex}},t.assertVisible=n=>!!t.measure(n).visible,t.assertSize=(n,e={})=>{if(!n)return"element is null";const i=t.measure(n);if(e.w!==void 0&&Math.round(i.width)!==e.w)return`width: expected ${e.w}, got ${Math.round(i.width)}`;if(e.h!==void 0&&Math.round(i.height)!==e.h)return`height: expected ${e.h}, got ${Math.round(i.height)}`;const r=d=>{const w=window.getComputedStyle(n).getPropertyValue(d);return w?parseFloat(w):0};return e.padding!==void 0&&r("padding-top")!==e.padding?`padding: expected ${e.padding}, got ${r("padding-top")}`:e.paddingTop!==void 0&&r("padding-top")!==e.paddingTop?`paddingTop: expected ${e.paddingTop}, got ${r("padding-top")}`:e.paddingRight!==void 0&&r("padding-right")!==e.paddingRight?`paddingRight: expected ${e.paddingRight}, got ${r("padding-right")}`:e.paddingBottom!==void 0&&r("padding-bottom")!==e.paddingBottom?`paddingBottom: expected ${e.paddingBottom}, got ${r("padding-bottom")}`:e.paddingLeft!==void 0&&r("padding-left")!==e.paddingLeft?`paddingLeft: expected ${e.paddingLeft}, got ${r("padding-left")}`:e.margin!==void 0&&r("margin-top")!==e.margin?`margin: expected ${e.margin}, got ${r("margin-top")}`:e.marginTop!==void 0&&r("margin-top")!==e.marginTop?`marginTop: expected ${e.marginTop}, got ${r("margin-top")}`:e.marginRight!==void 0&&r("margin-right")!==e.marginRight?`marginRight: expected ${e.marginRight}, got ${r("margin-right")}`:e.marginBottom!==void 0&&r("margin-bottom")!==e.marginBottom?`marginBottom: expected ${e.marginBottom}, got ${r("margin-bottom")}`:e.marginLeft!==void 0&&r("margin-left")!==e.marginLeft?`marginLeft: expected ${e.marginLeft}, got ${r("margin-left")}`:!0},t.recorder={active:!1,actions:[],mocks:{},initialData:{},assertions:[],observeRoot:null,_originalFetch:null,_listeners:[],_observer:null},t.recordingAssertionDebug=!1,t.startRecording=(n,e,i)=>{if(t.recorder.active)return;const r=["click","mouseover","scroll","input","change"],d={click:100,mouseover:50,scroll:30,input:50,change:50},w=e||r,u=Object.assign({},d,i||{}),x={scroll:30,mouseover:50},v=t.recorder;v.active=!0,v.actions=[],v.mocks={},v.stepDelays=u,v.initialData={url:window.location.href,timestamp:Date.now()},v.observeRoot=n||null,v.assertions=[],v.removedElements=[],t.inits.forEach((y,C)=>{y?.store&&(v.initialData["init_"+C]=JSON.parse(JSON.stringify(y.store)))}),v._originalFetch=window.fetch,window.fetch=async(y,C={})=>{const s=(C.method||"GET").toUpperCase();let c;try{c=C.body?JSON.parse(C.body):void 0}catch{c=C.body}const g=await v._originalFetch(y,C),a=g.clone();let L;try{L=await a.json()}catch{L=await a.text().catch(()=>null)}const k=s+":"+y;return v.mocks[k]={url:y,method:s,request:c,response:L,status:g.status},g};const I={"data-o-init":1,"data-o-init-i":1,"data-o-state":1},f=(y,C)=>{if(t.D.querySelectorAll(y).length<=1)return y;let s=C;for(;s&&s!==t.D.body;){let c=s.id?"#"+s.id:null;if(!c&&s.attributes){const g=t.autotag?"data-"+t.autotag:null;if(g){const a=s.getAttribute(g);a!=null&&(c=`[${g}="${a}"]`)}if(!c){for(const a of s.attributes)if(a.name.startsWith("data-")&&!I[a.name]){c=`[${a.name}="${a.value}"]`;break}}}if(c){const g=c+" "+y;if(t.D.querySelectorAll(g).length===1)return g}s=s.parentElement}return y},S=y=>{if(!y||y.nodeType!==1)return"";let C="";if(y.dataset){const s=t.autotag&&y.dataset[t.autotag];s&&(C=f(`[data-${t.autotag}="${s}"]`,y.parentElement))}if(!C&&y.tagName){const s=y.id?"#"+y.id:y.className?y.tagName.toLowerCase()+"."+[...y.classList].join("."):y.tagName.toLowerCase();C=y.id?s:f(s,y.parentElement)}return C},m=n&&t.D.querySelector(n)||t.D.body;v._observer=new MutationObserver(y=>{const C=v.actions.length-1;if(C<0)return;const s=v.actions[C];t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] MutationObserver batch:",{actionIdx:C,lastAction:s?{type:s.type,target:s.target}:null,mutationTypes:y.map(c=>c.type),addedCount:y.reduce((c,g)=>c+(g.addedNodes?.length||0),0),removedCount:y.reduce((c,g)=>c+(g.removedNodes?.length||0),0)}),y.forEach(c=>{const g=(a,L)=>{let k,p;if(a&&m&&m.querySelectorAll(a).length>1){let N=L;for(;N&&N!==m&&N.nodeType===1;){const $=t.autotag&&N.dataset&&N.dataset[t.autotag];if($){const T=`[data-${t.autotag}="${$}"]`,R=m.querySelectorAll(T);if(R.length>1){const U=[...R].indexOf(N);if(U!==-1){k=T,p=U;break}}}N=N.parentElement}}return{listSelector:k,index:p}};if(c.type==="childList"&&(c.addedNodes.forEach(a=>{if(a.nodeType!==1||!a.offsetParent)return;const L=S(a);if(!L||v.assertions.some($=>$.actionIdx===C&&$.selector===L&&$.type==="visible"))return;const k=(a.textContent?.trim()||"").slice(0,80)||void 0,{listSelector:p,index:D}=g(L,a),N={actionIdx:C,type:"visible",selector:L,text:k};p!=null&&(N.listSelector=p),D!=null&&(N.index=D),v.assertions.push(N),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +visible assertion:",{actionIdx:C,lastAction:s?.type+" "+s?.target,selector:L,text:(k||"").slice(0,40),index:D,listSelector:p})}),c.removedNodes.forEach(a=>{if(a.nodeType!==1)return;const L=S(a);if(!L)return;const k=(a.textContent?.trim()||"").slice(0,80)||void 0,p=c.target;let D;a.previousSibling?D=Array.from(p.children).indexOf(a.previousSibling)+1:a.nextSibling?D=Array.from(p.children).indexOf(a.nextSibling):D=0;let N;if(t.autotag&&a.dataset?.[t.autotag]){const T=a.dataset[t.autotag];N=`[data-${t.autotag}="${T}"]`}const $={actionIdx:C,type:"removed",selector:L,text:k};N&&($.listSelector=N),$.index=D,v.removedElements.push($),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +removed element:",{actionIdx:C,lastAction:s?.type+" "+s?.target,selector:L,text:(k||"").slice(0,40),index:D,listSelector:N})})),c.type==="attributes"){const a=S(c.target);if(!a||v.assertions.some(D=>D.actionIdx===C&&D.selector===a&&D.type==="class"))return;const{listSelector:L,index:k}=g(a,c.target),p={actionIdx:C,type:"class",selector:a,className:c.target.className};L!=null&&(p.listSelector=L),k!=null&&(p.index=k),v.assertions.push(p),t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[recording] +class assertion:",{actionIdx:C,lastAction:s?.type+" "+s?.target,selector:a,className:c.target.className,index:k,listSelector:L})}})}),v._observer.observe(m,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","disabled","aria-expanded","aria-checked"]});const O={};w.forEach(y=>{const C=s=>{const c=s.target;if(n&&m&&c?.nodeType===1&&!m.contains(c))return;let g="";if(c?.dataset){const R=t.autotag&&c.dataset[t.autotag];R&&(g=f(`[data-${t.autotag}="${R}"]`,c.parentElement))}if(!g&&c?.tagName){const R=c.id?"#"+c.id:c.className?c.tagName.toLowerCase()+"."+[...c.classList].join("."):c.tagName.toLowerCase();g=c.id?R:f(R,c.parentElement)}let a,L;if(g&&m&&m.querySelectorAll(g).length>1){let U=c;for(;U&&U!==m&&U.nodeType===1;){const J=t.autotag&&U.dataset&&U.dataset[t.autotag];if(J){const G=`[data-${t.autotag}="${J}"]`,V=m.querySelectorAll(G);if(V.length>1){const X=[...V].indexOf(U);if(X!==-1){a=G,L=X;break}}}U=U.parentElement}}const k=c?.tagName?c.tagName.toLowerCase()+(c.type?":"+c.type:""):void 0,p=y==="scroll"?window.scrollY:void 0,D=y==="input"||y==="change"?c?.value:void 0,N=y==="change"&&(c?.type==="checkbox"||c?.type==="radio")?c?.checked:void 0,$=y==="click"||y==="change"?0:u[y]!==void 0?u[y]:x[y]??0,T=()=>{const R={type:y,target:g,time:Date.now()};k&&(R.targetType=k),p!==void 0&&(R.scrollY=p),D!==void 0&&(R.value=D),N!==void 0&&(R.checked=N),a!=null&&(R.listSelector=a),L!=null&&(R.targetIndex=L),v.actions.push(R)};$===0?T():(clearTimeout(O[y]),O[y]=setTimeout(T,$))};t.D.addEventListener(y,C,!0),v._listeners.push({ev:y,handler:C})})},t.stopRecording=()=>{const n=t.recorder;return n.active=!1,n._originalFetch&&(window.fetch=n._originalFetch,n._originalFetch=null),n._listeners.forEach(({ev:e,handler:i})=>{t.D.removeEventListener(e,i,!0)}),n._listeners=[],n._observer&&(n._observer.disconnect(),n._observer=null),{actions:[...n.actions],mocks:{...n.mocks},initialData:{...n.initialData},stepDelays:{...n.stepDelays},assertions:[...n.assertions||[]],removedElements:[...n.removedElements||[]],observeRoot:n.observeRoot||null}},t.clearRecording=n=>{if(n!==void 0)sessionStorage?.removeItem("oTest-Recording-"+n);else for(let e=sessionStorage?.length-1;e>=0;e--){const i=sessionStorage?.key(e);i&&i.indexOf("oTest-Recording-")===0&&sessionStorage?.removeItem(i)}},t.runRecordingAssertions=(n,e,i,r)=>{const d=r&&r.assertions,w=d??(n.assertions||[]).filter(s=>i==null||s.actionIdx===i);t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[runRecordingAssertions] run:",{actionIdx:i,scope:i==null?"teardown (all)":"per-action",assertionsCount:w.length,assertions:w.map(s=>({actionIdx:s.actionIdx,type:s.type,selector:s.selector,index:s.index,text:(s.text||"").slice(0,40)}))});const u=new Set,x=w.filter(s=>{const c=`${s.selector}|${s.type}|${s.actionIdx}|${s.index??""}`;return u.has(c)?!1:(u.add(c),!0)}),I=(()=>{if(e!=null)return typeof e=="string"?t.D.querySelector(e)||t.D.body:e;const s=n.observeRoot;return s&&t.D.querySelector(s)||t.D.body})(),f=s=>(s||"").trim().replace(/\s+/g," "),S=s=>s?f(s.textContent||""):"",m=r?.removedElements||[],O=s=>{if(!m.length||i==null)return!1;const c=f(s.text||"");for(const g of m)if(!(g.actionIdx>i)&&f(g.text||"")===c&&g.selector===s.selector&&!(s.listSelector!=null&&g.listSelector!==s.listSelector)&&!(s.index!=null&&g.index!==s.index))return!0;return!1};let y=0;const C=[];for(const s of x){if(O(s)){y+=1,t.recordingAssertionDebug&&typeof console<"u"&&console.log&&console.log("[runRecordingAssertions] skip (explicit removed):",{actionIdx:s.actionIdx,selector:s.selector,text:(s.text||"").slice(0,40)});continue}let c=null,g=!1;if(s.listSelector!=null&&s.index!=null){const a=I.querySelectorAll(s.listSelector),L=f(s.text||""),k=D=>{const N=a[D];return N?(s.selector!==s.listSelector?N.querySelector(s.selector):N)||(s.selector!==s.listSelector?N:null):null};let p=a[s.index];if(!p&&s.index>0&&(p=a[s.index-1]),p){if(c=k(s.index)||(s.index>0?k(s.index-1):null),!c&&s.selector!==s.listSelector&&(c=p),s.type==="visible"&&L&&c){const D=S(c);if(D.indexOf(L)===-1&&L.indexOf(D)===-1)for(let $=0;$<a.length;$++){const T=k($);if(T&&S(T).indexOf(L)!==-1){c=T,p=a[$];break}}}}else g=!0}else{const a=I.querySelectorAll(s.selector);c=a.length>0?a[0]:t.D.querySelector(s.selector)}if(s.type==="visible"){const a=c&&c.nodeType===1&&(c.offsetParent!==null||c.getBoundingClientRect&&c.getBoundingClientRect().width>0),L=f(s.text||""),k=S(c),p=k,D=!L||k.indexOf(L)!==-1||p.indexOf(L)!==-1||L.length>0&&L.indexOf(k)!==-1;if(a&&D)y+=1;else{const N=g?`index out of bounds (list has ${I.querySelectorAll(s.listSelector||s.selector).length} items, assertion expected index ${s.index})`:c?a?D?"fail":"text mismatch":"not visible":"element not found";C.push({selector:s.selector,message:N}),typeof console<"u"&&console.warn&&console.warn("[runRecordingAssertions] visible failed:",{actionIdx:s.actionIdx,selector:s.selector,listSelector:s.listSelector,index:s.index,expectedText:s.text||"(any)",actualText:k.slice(0,80),message:N})}}else if(s.type==="class"){const a=(s.className||"").trim().split(/\s+/).filter(Boolean);if(c&&(a.length===0||a.every(k=>c.classList?.contains(k))))y+=1;else{const k=g?`index out of bounds (list has ${I.querySelectorAll(s.listSelector).length} items, expected index ${s.index})`:c?`expected class "${s.className}"`:"element not found";C.push({selector:s.selector,message:k}),typeof console<"u"&&console.warn&&console.warn("[runRecordingAssertions] failed:",{type:s.type,selector:s.selector,actionIdx:s.actionIdx,listSelector:s.listSelector,index:s.index,itemsInRoot:s.listSelector?I.querySelectorAll(s.listSelector).length:"-",message:k})}}}return{passed:y,total:x.length,failures:C}},t.exportTest=(n,e={})=>{const i=e.delay!==void 0?e.delay:16,r={actions:n.actions,assertions:n.assertions||[],observeRoot:n.observeRoot||null},d=n.observeRoot?`(o.D.querySelector('${n.observeRoot.replace(/'/g,"\\'")}') || o.D.body)`:"o.D.body",w=f=>{if(f.listSelector!=null&&f.targetIndex!=null){const S=JSON.stringify(f.listSelector),m=f.target===f.listSelector,O=m?S:JSON.stringify(f.target);return` const items = o.D.querySelectorAll(${S});
|
|
16
|
+
const item = items[${f.targetIndex}];
|
|
17
|
+
let el = null;
|
|
18
|
+
if (item) { el = ${m?"item":`item.querySelector(${O}) || item`}; }`}return` const el = o.D.querySelector(${JSON.stringify(f.target)});`},u=i>0?`
|
|
19
|
+
await o.sleep(${i});
|
|
20
|
+
return true;
|
|
21
|
+
`:` return true;
|
|
22
|
+
`,x=i>0?"async () =>":"() =>",v=[];for(let f=0;f<n.actions.length;f++){const S=n.actions[f];let m;S.type==="scroll"?m=` window.scrollTo(0, ${S.scrollY||0});${u}`:S.type==="input"||S.type==="change"?m=(S.value!==void 0?` el.value = ${JSON.stringify(S.value)};
|
|
23
|
+
`:"")+(S.checked!==void 0?` el.checked = ${S.checked};
|
|
24
|
+
`:"")+` el.dispatchEvent(new Event('${S.type}', {bubbles:true}));${u}`:m=S.type==="click"?` el.click();${u}`:` el.dispatchEvent(new MouseEvent('${S.type}', {bubbles:true,cancelable:true}));${u}`,v.push(` ['${S.type} on ${S.target}', ${x} {
|
|
25
|
+
`+w(S)+`
|
|
26
|
+
if (!el && '${S.type}' !== 'scroll') return 'element not found: ${S.target.replace(/'/g,"\\'")}';
|
|
27
|
+
`+m+" }]"),(n.assertions||[]).filter(y=>y.actionIdx===f).length>0&&v.push(` ['assert after ${S.type}', () => {
|
|
28
|
+
const r = o.runRecordingAssertions(recordingData, ${d}, ${f});
|
|
29
|
+
return r.passed === r.total ? true : r.failures.map(f => f.selector + ': ' + f.message).join('; ');
|
|
30
|
+
}]`)}return`// Auto-generated by o.exportTest() \u2014 review and anonymize mocks before committing
|
|
31
|
+
const recordingMocks = ${Object.keys(n.mocks||{}).length?JSON.stringify(n.mocks,null,2):"{}"};
|
|
32
|
+
const recordingData = { actions: ${JSON.stringify(n.actions)}, assertions: ${JSON.stringify(n.assertions||[])}, observeRoot: ${JSON.stringify(n.observeRoot||null)} };
|
|
26
33
|
|
|
27
34
|
o.addTest('Recorded test', [
|
|
28
|
-
${
|
|
35
|
+
${v.join(`,
|
|
36
|
+
`)}
|
|
37
|
+
// Add manual checks: ['Manual: label', () => o.testConfirm('label', ['item1'])],
|
|
29
38
|
], () => {
|
|
30
39
|
// teardown
|
|
31
40
|
});
|
|
32
|
-
`},t.exportPlaywrightTest=(n,e={})=>{const
|
|
33
|
-
await route.fulfill({ status: ${
|
|
34
|
-
body: JSON.stringify(${
|
|
41
|
+
`},t.exportPlaywrightTest=(n,e={})=>{const i=e.testName||"Recorded session",r=n.initialData?.url??"/";let d="/";try{d=new URL(r).pathname||"/"}catch{d=r}const w=e.baseUrl||d,u=Object.values(n.mocks).map(f=>{const S=f.url.startsWith("/")?f.url:"/"+f.url,m=JSON.stringify(f.response);return` await page.route('**${S}', async route => {
|
|
42
|
+
await route.fulfill({ status: ${f.status||200}, contentType: 'application/json',
|
|
43
|
+
body: JSON.stringify(${m}) });
|
|
35
44
|
});`}).join(`
|
|
36
|
-
`),
|
|
45
|
+
`),x=Object.assign({click:100,mouseover:50,scroll:30,input:50,change:50},n.stepDelays||{}),v=n.actions.map((f,S)=>{const m=f.listSelector!=null&&f.targetIndex!=null?f.target!==f.listSelector?`page.locator(${JSON.stringify(f.listSelector)}).nth(${f.targetIndex}).locator(${JSON.stringify(f.target)})`:`page.locator(${JSON.stringify(f.listSelector)}).nth(${f.targetIndex})`:`page.locator(${JSON.stringify(f.target)})`,O=` await page.waitForTimeout(${x[f.type]||50});`;let y;if(f.type==="scroll")y=` await page.evaluate(() => window.scrollTo(0, ${f.scrollY||0}));`;else if(f.type==="mouseover")y=` await ${m}.hover();
|
|
37
46
|
// Pure CSS :hover \u2014 no DOM mutation to assert.
|
|
38
|
-
// Fix: toggle a class in a mouseover handler, or add a page.screenshot() visual check.`;else if(
|
|
39
|
-
await expect(${
|
|
40
|
-
`);return
|
|
41
|
-
`+
|
|
42
|
-
`+
|
|
43
|
-
`),
|
|
47
|
+
// Fix: toggle a class in a mouseover handler, or add a page.screenshot() visual check.`;else if(f.type==="input")y=` await ${m}.fill(${JSON.stringify(f.value||"")});`;else if(f.type==="change"){const s=f.targetType||"";if(s.indexOf(":checkbox")!==-1||s.indexOf(":radio")!==-1){const c=f.checked!==void 0?f.checked:f.value==="true"||f.value==="on";y=` await ${m}.${c?"check":"uncheck"}();`}else s.indexOf("select")!==-1?y=` await ${m}.selectOption(${JSON.stringify(f.value||"")});`:y=` await ${m}.fill(${JSON.stringify(f.value||"")});`}else y=` await ${m}.click();`;const C=(n.assertions||[]).filter(s=>s.actionIdx===S).filter((s,c,g)=>g.findIndex(a=>a.selector===s.selector&&a.type===s.type&&a.index===s.index)===c).map(s=>{const c=s.listSelector!=null&&s.index!=null?s.selector!==s.listSelector?`page.locator(${JSON.stringify(s.listSelector)}).nth(${s.index}).locator(${JSON.stringify(s.selector)})`:`page.locator(${JSON.stringify(s.listSelector)}).nth(${s.index})`:`page.locator(${JSON.stringify(s.selector)})`;if(s.type==="visible"){let g=` await expect(${c}).toBeVisible();`;return s.text&&(g+=`
|
|
48
|
+
await expect(${c}).toContainText(${JSON.stringify(s.text)});`),g}return s.type==="class"?` // class on ${s.selector} changed to: "${s.className}"`:""}).filter(Boolean).join(`
|
|
49
|
+
`);return y+`
|
|
50
|
+
`+O+(C?`
|
|
51
|
+
`+C:"")}).join(`
|
|
52
|
+
`),I=(n.assertions||[]).length>0;return`// Auto-generated by o.exportPlaywrightTest() \u2014 review and anonymize mocks before committing
|
|
44
53
|
// Prerequisites: npm install @playwright/test && npx playwright install chromium
|
|
45
54
|
// Run: npx playwright test recorded.spec.ts
|
|
46
55
|
import { test, expect } from '@playwright/test';
|
|
47
56
|
|
|
48
|
-
test(${JSON.stringify(
|
|
49
|
-
`+(
|
|
50
|
-
`+
|
|
57
|
+
test(${JSON.stringify(i)}, async ({ page }) => {
|
|
58
|
+
`+(u?` // Network mocks \u2014 edit/anonymize before committing
|
|
59
|
+
`+u+`
|
|
51
60
|
|
|
52
61
|
`:"")+` // Set baseURL in playwright.config.ts: { use: { baseURL: 'https://staging.example.com' } }
|
|
53
62
|
await page.goto(${JSON.stringify(w)});
|
|
54
63
|
|
|
55
|
-
`+(
|
|
64
|
+
`+(v?v+`
|
|
56
65
|
|
|
57
|
-
`:"")+(
|
|
66
|
+
`:"")+(I?` // Auto-generated assertions above \u2014 review for correctness before committing
|
|
58
67
|
`:` // TODO: Add assertions before committing, e.g.:
|
|
59
68
|
// await expect(page.locator('[data-qa="success-panel"]')).toBeVisible();
|
|
60
69
|
// await expect(page).toHaveURL(/\\/confirmation/);
|
|
61
70
|
// await expect(page.locator('[data-qa="error-banner"]')).not.toBeVisible();
|
|
62
71
|
`)+`});
|
|
63
|
-
`},t.playRecording=(n,e={})=>{const
|
|
72
|
+
`},t.playRecording=(n,e={})=>{const i=e&&typeof e=="object"&&(e.runAssertions!==void 0||e.root!==void 0||e.manualChecks!==void 0||e.actionDelay!==void 0),r=i?e.mockOverrides||{}:e,d=i&&e.runAssertions,w=i?e.root:void 0,u=i&&e.manualChecks||[],x=i&&e.actionDelay!==void 0?e.actionDelay:16,v=Object.assign({},n.mocks,r),I=window.fetch;window.fetch=(k,p={})=>{const N=(p.method||"GET").toUpperCase()+":"+k;if(v[N]){const $=v[N],T=typeof $.response=="string"?$.response:JSON.stringify($.response);return Promise.resolve(new Response(T,{status:$.status||200}))}return I(k,p)};const f=()=>{if(w!=null)return typeof w=="string"?t.D.querySelector(w)||t.D.body:w;const k=n.observeRoot;return k&&t.D.querySelector(k)||t.D.body},S=d?f():null,m=w!=null?f():t.D,O=n.actions,y=n.assertions||[],C={};for(const k of y){const p=k.actionIdx;C[p]||(C[p]=[]),C[p].push(k)}if(t.recordingAssertionDebug&&d&&typeof console<"u"&&console.log){const k=O.map((p,D)=>({i:D,action:p.type+" "+(p.target||""),assertions:(C[D]||[]).length,assertionDetails:(C[D]||[]).map(N=>({type:N.type,index:N.index,text:(N.text||"").slice(0,30)}))}));console.log("[playRecording] assertions by action:",k)}const s={};for(const k of u){const p=k.afterAction;s[p]||(s[p]=[]),s[p].push(k)}const c=[];let g={passed:0,total:0,failures:[]};for(let k=0;k<O.length;k++){const p=O[k];c.push([`${p.type} on ${p.target}`,async()=>{let N=null;const $=m;if(p.target)if(p.listSelector!=null&&p.targetIndex!=null){const R=$.querySelectorAll(p.listSelector)[p.targetIndex];R&&(N=p.target!==p.listSelector?R.querySelector(p.target):R,!N&&p.target!==p.listSelector&&(N=R))}else N=$.querySelector(p.target);return!N&&p.type!=="scroll"?`element not found: ${p.target}`:(p.type==="scroll"?window.scrollTo(0,p.scrollY||0):p.type==="input"||p.type==="change"?(p.value!==void 0&&(N.value=p.value),p.checked!==void 0&&(N.checked=p.checked),N.dispatchEvent(new Event(p.type,{bubbles:!0}))):p.type==="click"?N.click():N.dispatchEvent(new MouseEvent(p.type,{bubbles:!0,cancelable:!0})),x>0&&await t.sleep(x),!0)}]);const D=C[k];d&&D&&D.length>0&&c.push([`assert after ${p.type}`,()=>new Promise(N=>{const $=()=>{const T=t.runRecordingAssertions(n,S,k,{assertions:D,removedElements:n.removedElements});g.passed+=T.passed,g.total+=T.total,g.failures.push(...T.failures),N(T.passed===T.total?!0:T.failures.map(R=>R.selector+": "+R.message).join("; "))};requestAnimationFrame(()=>requestAnimationFrame($))})]);for(const N of s[k]||[])c.push([`Manual: ${N.label}`,()=>typeof t.testConfirm=="function"?t.testConfirm(N.label,N.items||[]):{ok:!0}])}for(const k of s.end||[])c.push([`Manual: ${k.label}`,()=>typeof t.testConfirm=="function"?t.testConfirm(k.label,k.items||[]):{ok:!0}]);const a=i&&e.onComplete,L=t.test("Recorded playback",...c,{sync:!0},k=>{window.fetch=I;const p=d&&y.length>0?g:void 0;if(p?.failures?.length>0){t.tRes[k]=!1;const D=p.failures.map($=>`${$.selector}: ${$.message}`).join("; "),N=t.tStyled?t.tPre+t.tXx+"Assertions failed: "+D+t.tDc:`
|
|
73
|
+
\u2718 Assertions failed: `+D;t.tLog[k]=(t.tLog[k]||"")+N}typeof a=="function"&&a(p)});return d?{testId:L}:L},t.testOverlay=()=>{const n="o-test-overlay-btn",e="o-test-overlay-panel";if(t("#"+n).el)return;const i=()=>{const u=t("#"+e);if(!u.el)return;const x=t.tRes.length;let I=`<b>Tests: ${t.tRes.filter(Boolean).length}/${x}</b><hr style="margin:4px 0">`;t.tLog.forEach((f,S)=>{const m=t.tRes[S];I+=`<div style="margin:2px 0;padding:2px 4px;border-radius:3px;background:${m?"#d4edda":"#f8d7da"};color:${m?"#155724":"#721c24"};font-size:11px;white-space:pre-wrap">${f||"Test #"+S}</div>`}),I+='<button id="o-test-export" style="margin-top:6px;padding:4px 8px;font-size:11px;cursor:pointer">Export results</button>',u.html(I),t("#o-test-export").on("click",()=>{const f=JSON.stringify({results:t.tRes,logs:t.tLog},null,2),S=new Blob([f],{type:"application/json"}),m=t.D.createElement("a");m.href=URL.createObjectURL(S),m.download="objs-test-results.json",m.click()})},r=`<div style="display:flex;align-items:center;gap:12px;"><span class="o-test-overlay-summary" style="flex:1;font-size:13px;cursor:grab;">Tests: 0/0</span><button type="button" class="o-test-overlay-toggle" style="padding:6px 10px;background:#334155;color:#e2e8f0;border:none;border-radius:6px;cursor:pointer;font-size:12px;">List</button><button type="button" class="o-test-overlay-close" style="padding:4px 8px;background:transparent;color:#94a3b8;border:none;border-radius:4px;cursor:pointer;font-size:16px;line-height:1;" title="Close">\xD7</button></div><div id="${e}" style="display:none;margin-top:4px;padding:8px;background:#fff;border:1px solid #334155;border-radius:6px;max-height:240px;overflow-y:auto;box-shadow:0 2px 8px rgba(0,0,0,.15);font-size:11px;user-select:text;cursor:text;"></div>`,d=t.overlay({innerHTML:r,removeExisting:!1,className:"o-test-overlay",id:n,excludeDragSelector:".o-test-overlay-close, .o-test-overlay-toggle, #"+e}),w=()=>{const u=t(".o-test-overlay-summary");u.els.length&&u.innerText(`Tests: ${t.tRes.filter(Boolean).length}/${t.tRes.length}`)};d.first(".o-test-overlay-toggle").on("click",()=>{const u=t("#"+e);if(!u.el)return;const x=u.el.style.display!=="none";u.css({display:x?"none":"block"}),x||i()}),d.first(".o-test-overlay-close").on("click",()=>{d._overlayCleanup()}),t.testOverlay.showPanel=()=>{const u=t("#"+e);u.el&&(u.css({display:"block"}),i(),w())},t._testOverlayBase||(t._testOverlayBase=t.test),t.test=(...u)=>{const x=t._testOverlayBase(...u),v=t.tFns[x];return t.tFns[x]=I=>{typeof v=="function"&&v(I);const f=t("#"+e);f.el&&f.el.style.display!=="none"&&i(),w()},x}},t.overlay=(n={})=>{const{innerHTML:e,onClose:i,timeout:r,excludeDragSelector:d,removeExisting:w=!0,className:u="o-overlay-common",id:x}=n;if(w)t("."+u).remove();else if(x&&t("#"+x).el)return t("#"+x);const v={position:"fixed",left:"50%",bottom:"50px",transform:"translateX(-50%)","z-index":"999999",width:"fit-content","max-width":"min(90vw, 420px)","font-family":"system-ui,sans-serif","user-select":"text"},I="o-overlay-countdown",f='<div class="o-overlay-bar" style="display:flex;flex-direction:column;align-items:stretch;padding:10px 14px;background:#1e293b;color:#e2e8f0;border:1px solid #334155;border-radius:8px;font-size:14px;min-width:200px;max-height:90vh;overflow-y:auto;">'+e+(r?`<div id="${I}" style="margin-top:6px;font-size:11px;color:#94a3b8;"></div>`:"")+"</div>",S=t.initState({tag:"div",className:u,id:x||void 0,style:"position:fixed;left:50%;bottom:50px;transform:translateX(-50%);z-index:999999;width:fit-content;max-width:min(90vw,420px);font-family:system-ui,sans-serif;user-select:text;",html:f}).appendInside("body"),m=()=>S.css(v);let O=null;const y=g=>{O&&(v.left=O.left+(g.clientX-O.startX)+"px",v.top=O.top+(g.clientY-O.startY)+"px",delete v.bottom,v.transform="none",m())},C=()=>{O&&(delete v.cursor,m()),O=null};S.on("mousedown",g=>{if(d&&g.target.closest(d))return;const a=S.el.getBoundingClientRect();O={startX:g.clientX,startY:g.clientY,left:a.left,top:a.top},v.cursor="grabbing",m()}),t.D.addEventListener("mousemove",y),t.D.addEventListener("mouseup",C);let s;const c=()=>{t.D.removeEventListener("mousemove",y),t.D.removeEventListener("mouseup",C),s&&clearInterval(s),S.remove()};if(r&&r>0){let g=Math.ceil(r/1e3);const a=t("#"+I);a.el&&(a.el.textContent=g?`Continue in ${g}s`:""),s=setInterval(()=>{g-=1,a.el&&(a.el.textContent=g>0?`Continue in ${g}s`:""),g<=0&&(clearInterval(s),s=null,c(),typeof i=="function"&&i({ok:!1,errors:["timeout"]}))},1e3)}return S._overlayCleanup=c,S._overlayOnClose=i,S},t.testConfirm=(n,e=[],i={})=>new Promise(r=>{const d=i.confirm||"Continue",w=e.length>0,u=w?"#dc2626":"#2563eb",x=e.map((O,y)=>"o-tc-cb-"+y),I=w?`<style>.o-tc-item-cb{appearance:none;-webkit-appearance:none;width:16px;height:16px;border:2px solid #ef4444;border-radius:3px;background:#fef2f2;flex-shrink:0;cursor:pointer;}.o-tc-item-cb:checked{border-color:#22c55e;background:#22c55e;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");background-size:12px 12px;background-position:center;}</style><ul class="o-tc-list" style="margin:8px 0 0;padding:0;list-style:none;font-size:13px;color:#cbd5e1;cursor:grab;">`+e.map((O,y)=>`<li style="margin-bottom:4px;"><label for="${x[y]}" style="display:flex;align-items:center;gap:8px;cursor:pointer;user-select:none;"><input type="checkbox" id="${x[y]}" class="o-tc-item-cb"> <span>${O}</span></label></li>`).join("")+"</ul>":"",f=`<div style="display:flex;align-items:center;gap:12px;"><span class="o-tc-label" style="flex:1;cursor:grab;">${n}: Paused</span><button type="button" class="o-tc-ok" style="padding:6px 14px;background:${u};color:#fff;border:none;border-radius:6px;font-weight:600;cursor:pointer;font-size:13px;flex-shrink:0;">${d}</button></div>`+I,S=t.overlay({innerHTML:f,timeout:i.timeout,excludeDragSelector:".o-tc-ok",onClose:O=>r(O||{ok:!0})}),m={padding:"6px 14px",background:w?"#dc2626":"#2563eb",color:"#fff",border:"none","border-radius":"6px","font-weight":"600",cursor:"pointer","font-size":"13px","flex-shrink":"0"};if(w){const O=S.first(".o-tc-ok"),y=t(".o-overlay-common .o-tc-item-cb"),C=()=>{const s=y.length>0&&y.els.every(c=>c.checked);O.css({...m,background:s?"#16a34a":"#dc2626"})};y.on("change",C)}S.first(".o-tc-ok").on("click",()=>{let O=[];if(w){const y=t(".o-overlay-common .o-tc-item-cb");y.els.length&&y.els.forEach((C,s)=>{!C.checked&&e[s]!==void 0&&O.push(e[s])})}S._overlayCleanup(),r(O.length===0?{ok:!0}:{ok:!1,errors:O})})});
|
|
64
74
|
|
|
65
75
|
export { o };
|
|
66
76
|
export default o;
|
package/objs.d.ts
CHANGED
|
@@ -198,6 +198,8 @@ export interface ObjsInstance {
|
|
|
198
198
|
|
|
199
199
|
// DOM manipulation
|
|
200
200
|
html(html?: string): string | ObjsInstance;
|
|
201
|
+
toString(): string;
|
|
202
|
+
[Symbol.toPrimitive](hint: string): string | number;
|
|
201
203
|
innerHTML(html?: string): string[] | ObjsInstance;
|
|
202
204
|
innerText(text: string): ObjsInstance;
|
|
203
205
|
textContent(content: string): ObjsInstance;
|
|
@@ -272,7 +274,7 @@ declare namespace o {
|
|
|
272
274
|
// Element selection
|
|
273
275
|
function first(query: string): ObjsInstance;
|
|
274
276
|
function take(query: QueryArg): ObjsInstance;
|
|
275
|
-
|
|
277
|
+
|
|
276
278
|
// State
|
|
277
279
|
function init(states: StatesMap | StateFunction | string): ObjsInstance;
|
|
278
280
|
function initState(state: StateObject, props?: Record<string, unknown>): ObjsInstance;
|
|
@@ -391,13 +393,25 @@ declare namespace o {
|
|
|
391
393
|
function startRecording(observe?: string, events?: string[], timeouts?: Record<string, number>): void;
|
|
392
394
|
function stopRecording(): Recording;
|
|
393
395
|
function clearRecording(id?: number): void;
|
|
394
|
-
function exportTest(recording: Recording): string;
|
|
396
|
+
function exportTest(recording: Recording, options?: { delay?: number }): string;
|
|
397
|
+
/**
|
|
398
|
+
* Run recording assertions against the current DOM.
|
|
399
|
+
* @param recording Recording with assertions
|
|
400
|
+
* @param root Root element or selector (default: document)
|
|
401
|
+
* @param actionIdx When provided, run only assertions for this action index
|
|
402
|
+
*/
|
|
403
|
+
function runRecordingAssertions(
|
|
404
|
+
recording: Recording,
|
|
405
|
+
root?: Element | string,
|
|
406
|
+
actionIdx?: number
|
|
407
|
+
): { passed: number; total: number; failures: Array<{ selector: string; message: string }> };
|
|
395
408
|
function exportPlaywrightTest(
|
|
396
409
|
recording: Recording,
|
|
397
410
|
options?: { testName?: string; baseUrl?: string }
|
|
398
411
|
): string;
|
|
399
412
|
|
|
400
413
|
// Test framework
|
|
414
|
+
function sleep(ms: number): Promise<void>;
|
|
401
415
|
let tLog: string[];
|
|
402
416
|
let tRes: boolean[];
|
|
403
417
|
let tStatus: Array<Array<boolean | undefined>>;
|
|
@@ -410,7 +424,16 @@ declare namespace o {
|
|
|
410
424
|
let tBeforeEach: ((info: TestInfo) => void) | undefined;
|
|
411
425
|
let tAfterEach: ((info: TestInfo, result: unknown) => void) | undefined;
|
|
412
426
|
|
|
413
|
-
|
|
427
|
+
/** Options for o.test when sync or confirmOnFailure is needed */
|
|
428
|
+
interface TestOptions {
|
|
429
|
+
sync?: boolean;
|
|
430
|
+
confirmOnFailure?: boolean;
|
|
431
|
+
confirmOnFailureTimeout?: number;
|
|
432
|
+
}
|
|
433
|
+
function test(
|
|
434
|
+
title: string,
|
|
435
|
+
...cases: Array<TestCase | TestOptions | (() => void)>
|
|
436
|
+
): number;
|
|
414
437
|
function addTest(title: string, ...cases: Array<TestCase | { before?: Function; after?: Function }>): TestHandle;
|
|
415
438
|
function runTest(testId?: number, autoRun?: boolean, savePrev?: boolean): void;
|
|
416
439
|
function testUpdate(info: TestInfo, result?: boolean | string, suffix?: string): void;
|
|
@@ -439,8 +462,36 @@ declare namespace o {
|
|
|
439
462
|
): boolean | string;
|
|
440
463
|
|
|
441
464
|
// Dev-only replay + overlay (depend on o.test framework)
|
|
442
|
-
|
|
465
|
+
/** Manual check inserted after an action or at end of playback */
|
|
466
|
+
interface ManualCheck {
|
|
467
|
+
afterAction: number | 'end';
|
|
468
|
+
label: string;
|
|
469
|
+
items: string[];
|
|
470
|
+
}
|
|
471
|
+
/** Options for o.playRecording when runAssertions is used */
|
|
472
|
+
interface PlayRecordingOptions {
|
|
473
|
+
runAssertions?: boolean;
|
|
474
|
+
root?: string;
|
|
475
|
+
actionDelay?: number;
|
|
476
|
+
manualChecks?: ManualCheck[];
|
|
477
|
+
mockOverrides?: Recording['mocks'];
|
|
478
|
+
onComplete?: (assertionResult?: { passed: number; total: number; failures: Array<{ selector: string; message: string }> }) => void;
|
|
479
|
+
}
|
|
480
|
+
function playRecording(
|
|
481
|
+
recording: Recording,
|
|
482
|
+
opts?: Recording['mocks'] | PlayRecordingOptions
|
|
483
|
+
): number | { testId: number };
|
|
443
484
|
function testOverlay(): void;
|
|
485
|
+
/** Common draggable overlay; used by testConfirm, testOverlay, confirmOnFailure */
|
|
486
|
+
function overlay(opts: {
|
|
487
|
+
innerHTML: string;
|
|
488
|
+
onClose?: (result?: { ok?: boolean; errors?: string[]; continue?: boolean }) => void;
|
|
489
|
+
timeout?: number;
|
|
490
|
+
excludeDragSelector?: string;
|
|
491
|
+
removeExisting?: boolean;
|
|
492
|
+
className?: string;
|
|
493
|
+
id?: string;
|
|
494
|
+
}): ObjsInstance;
|
|
444
495
|
/**
|
|
445
496
|
* Pause an Objs browser test; shows a draggable bar with "Test title: Paused", optional checklist (labels + checkboxes), and Continue.
|
|
446
497
|
* Dev-only. Returns ok: true if all items checked; ok: false with errors = list of unchecked item texts.
|
|
@@ -448,7 +499,7 @@ declare namespace o {
|
|
|
448
499
|
function testConfirm(
|
|
449
500
|
label: string,
|
|
450
501
|
items?: string[],
|
|
451
|
-
opts?: { confirm?: string }
|
|
502
|
+
opts?: { confirm?: string; timeout?: number }
|
|
452
503
|
): Promise<{ ok: boolean; errors?: string[] }>;
|
|
453
504
|
}
|
|
454
505
|
|