objs-core 2.0.2 → 2.1.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/EXAMPLES.md +59 -58
- package/README.md +51 -27
- package/SKILL.md +53 -4
- package/objs.built.js +154 -37
- package/objs.built.min.js +26 -26
- package/objs.d.ts +3 -2
- package/objs.js +171 -47
- package/package.json +1 -1
package/objs.built.min.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Objs-core library
|
|
3
|
-
* @version 2.
|
|
3
|
+
* @version 2.1
|
|
4
4
|
* @author Roman Torshin
|
|
5
5
|
* @license Apache-2.0
|
|
6
|
-
*/const Y=!0,t=n=>{let e={els:[],ie:{},delegated:{},parented:{},store:{},refs:{},states:[],isDebug:!1,currentState:"",savedStates:{},isRoot:!1,_parent:null},o=1,r=2,c=3,w="boolean",a="object",h="function",S="string",C="number",l="notEmptyString",k="undefined",m="dangerouslySetInnerHTML",E,f=t.D,v=-1,u=0,y=0,x=typeof process<"u"||t.D===t.DocumentMVP,b=0,D=0;const I=e,O=s=>typeof s,R=(s,i)=>{for(const g in s)Object.hasOwn(s,g)&&i(g,s)},U=t.onError,L=s=>t.verify(s),$=(s,i="")=>(...g)=>{(t.debug||e.isDebug)&&console.log(i?`${i}()`:s,g.length?"with "+g.join(", "):"without parameters");try{const p=s(g[0],g[o],g[r],g[c]);return p!==E?p:e}catch(p){U(p,i)}},N=s=>{for(b=u;b<=v;b++)s()},M=s=>s?.els?s.el:(O(s)!==a&&(s=t.first(s).el),s),P=(s=!0,i=e.els)=>{const g=i.length;e.length=g,v=g-o,u=0,e.el=g?i[0]:E,e.last=g?i[v]:E,s&&(R(e.states,(p,d)=>{delete e[d[p]]}),e.states=[],e.ie={})};e.reset=t;const H=(s,i,g)=>{R(i,p=>{let d=i[p];O(d)===h&&(d=d(g)),p==="append"&&O(d)===a&&(d.els&&(d=[d]),d[0]?.els&&(valueBuff=[],R(d,T=>{valueBuff.push(...d[T].els)}),d=valueBuff)),d!==E&&s.getAttribute(p)!==d&&!["tag","tagName","name","sample","state","events","ssr","nodeName","revertChildren","root","ref"].includes(p)&&(["html","innerHTML"].includes(p)?s.innerHTML=d:p==="className"?s.setAttribute("class",d):p==="dataset"&&O(d)===a?R(d,T=>{s.dataset[T]=d[T]}):p==="toggleClass"?s.classList.toggle(d):p==="addClass"?O(d)===a?s.classList.add(...d):s.classList.add(d):p==="removeClass"?s.classList.remove(d):p==="style"&&O(d)===a?R(d,T=>{s.style[T]=d[T]}):(p==="append"||p==="children"||p==="childNodes")&&O(d)===a?R(d.length?d:[d],T=>{p==="append"||!s.childNodes[T]?s.appendChild(d[T]):s.childNodes[T]!==d[T]&&s.childNodes[T].replaceWith(d[T])}):s.setAttribute(p,d))}),s.dataset.oState=i.state,t.autotag&&i.name&&(s.dataset[t.autotag]=t.camelToKebab(i.name))};e.debug=$(()=>{e.isDebug=!0},"debug ON"),e.saveAs=$(s=>{L([[s,[l]]]),t.getSaved[s]?(t.debug||e.isDebug)&&console.warn("the key exists (not saved):"+s):t.getSaved[s]=e},"saveAs"),e.unmount=()=>((t.debug||e.isDebug)&&console.log("unmount() for initID:"+e.initID),O(e.remove)===h?e.remove():e.els?.length&&e.els.forEach(s=>{s?.parentNode&&s.parentNode.removeChild(s)}),t.inits[e.initID]=void 0,e={},!0),e.init=$(s=>{L([[s,[a,h]]]);const i=e.initID||t.inits.length||0;if(e.initID=i,P(),t.inits[e.initID]=e,O(s)==="function"){e.render=$(p=>{const d=f.createElement("div");setTimeout(()=>{t.reactRender(s,d,p)}),e.add(d)});return}(O(s)!==a||s.render===E)&&(s={render:s}),R(s,p=>{e?.render&&p==="render"||(e.states.push(p),e[p]=$((d=[{}])=>{e.currentState=p;const T=s[p]||{tag:"div"},A=Array.isArray(e.els)?e.els.slice(u,v+o):[],B=A.length?A:e.els||[];O(T)===a&&(T.state=p,T["data-o-init"]=i);const q=(_,F={})=>{if(O(T)===a)return f.createElement(T.tag||T.tagName||"div");{const j=f.createElement("div");return j.innerHTML=O(T)===h?T(F):T,j.children.length>o||!j.firstElementChild?(j.dataset.oInit=_,j):(j.firstElementChild.dataset.oInit=_,j.firstElementChild)}},z=d;d.length||(d=[d]);const X=!B[0]&&p==="render";d=d.map((_,F)=>{const j=Object.assign({},O(_)===a?_:{},{self:e,o:t,i:_.i===E?F:_.i,parent:e._parent,data:Array.isArray(z)?z[F]:z});return X&&(!T.ssr||x)&&B.push(q(i,j)),j}),X&&(e.els=B,P(!1));const V=()=>{R(T.events,_=>{e.on(_,T.events[_])})};B&&(D=B.length===d.length,B.map((_,F)=>{d[D?F:0].i=F+u;const j=O(T)===h?T(d[D?F:0]):T;O(j)===a&&(j.state=p,X&&(j["data-o-init"]=i,j["data-o-init-i"]=F),H(_,j,d[D?F:0]))}),X&&(e.refs={},e.els.forEach(_=>{_.querySelectorAll&&_.querySelectorAll("[ref]").forEach(F=>{e.refs[F.getAttribute("ref")]=t(F),F.removeAttribute("ref")})}))),X&&O(T)===a&&T.events&&!x&&!T.ssr&&V()}))});const g=s.render||s;!x&&O(g)===a&&g.events&&g.ssr&&(e.initSSRAfterGettingSSR=()=>{e.refs={},e.els.forEach(p=>{p.querySelectorAll&&p.querySelectorAll("[ref]").forEach(d=>{e.refs[d.getAttribute("ref")]=t(d),d.removeAttribute("ref")})}),R(g.events,p=>{e.on(p,g.events[p])})})},"init"),e.connect=$((s,i="render",g)=>{L([[s,[a]],[i,[l]],[g,[S,k]]]),s.connect(I,i,g)},"connect"),e.getSSR=$(s=>{L([[s,[C,k]]]);const i=s!==void 0?s:e.initID;if(x||O(s)===k&&O(e.initID)===k)return;const g=t.D.querySelectorAll(`[data-o-init="${i}"]`);g.length&&!e.els.length&&(e.els=Array.from(g),e.initID=s,t.inits[s]=e,P(!1),O(e.initSSRAfterGettingSSR)===h&&(e.initSSRAfterGettingSSR(),delete e.initSSRAfterGettingSSR))},"getSSR"),e.initState=$((s,i)=>{L([[s,[a]],[i,[a,k]]]),e.init(s).render(i)},"initState");const J=(s,i,g)=>{const p=s.attributes,d={tagName:s.tagName.toLowerCase()};for(const T of p)d[T.nodeName]=T.value;if(g){d.innerHTML=s.innerHTML,d.revertChildren=[];const T=s.querySelectorAll("[data-o-init]");for(const A of T){const B=A.getAttribute("data-o-init");d.revertChildren.push(B),t.inits[B]?.saveState(i,!1)}}return d};return e.saveState=$((s,i=!0)=>{if(L([[s,[l,k]],[i,[w]]]),!e.el)throw Error("saveState(): There are no elements to save");const g=s||"fastSavedState",p={els:[],parentNode:e.el.parentNode,root:i};N(()=>{p.els.push(J(e.els[b],g,i))}),p.ie=Object.assign({},e.ie),p.delegated=Object.assign({},e.delegated),p.store=Object.assign({},e.store),e.isRoot=e.isRoot||i,e.savedStates[g]=p},"saveState"),e.revertState=$(s=>{L([[s,[l,k]]]);const i=s||"fastSavedState";if(!e.savedStates[i])throw Error(`revertState(): The state "${i}" should have been saved by saveState()`);const g=e.savedStates[i];e.offAll(),e.offDelegate(),e.store=Object.assign({},g.store),g.els.forEach((p,d)=>{if(!e.els[d]){const T=t.D.createElement(p.tagName);g.parentNode&&(d?e.els[d-1].after(T):g.parentNode.append(T)),e.add(T)}H(e.els[d],p)}),e.delegated=Object.assign({},g.delegated),e.ie=Object.assign({},g.ie),e.onAll(),R(g.delegated,p=>{g.delegated[p].forEach(d=>{N(()=>{e.els[b].addEventListener(p,d)})})}),e.currentState=i,g.root&&g.els.forEach(({rootElement:p})=>{p.revertChildren.forEach(d=>{t.inits[d]?.revertState(i),t('[data-o-init="'+d+'"]').els.forEach((T,A)=>{T.replaceWith(t.inits[d]?.els[A])})})})},"revertState"),e.loseState=$(s=>{L([[s,[l]]]),e.savedStates[s]&&(delete e.savedStates[s],N(()=>{const i=e.els[b].querySelectorAll("[data-o-init]");for(const g of i){const p=g.getAttribute("data-o-init");t.inits[p]?.loseState(s)}}))},"sample"),e.sample=$((s="render")=>(L([[s,[l]]]),{[s]:J(e.els[u])}),"sample"),e.select=$(s=>{L([[s,[C,k]]]),s===E&&(s=e.length-o),v=s,u=s,e.el=e.els[s],y=o},"select"),e.all=$(()=>{v=e.length-o,u=0,e.el=e.els[0],y=0},"all"),e.remove=$(s=>{if(L([[s,[C,k]]]),s===E&&y&&(s=u),s!==E){const i=e.els[s];i?.parentNode?i.parentNode.removeChild(i):i===void 0&&s>=e.els.length&&t.onError&&t.onError("remove("+s+"): index out of bounds","remove")}else N(()=>{const i=e.els[b];i?.parentNode&&i.parentNode.removeChild(i)});P(!1)},"remove"),e.skip=$(s=>{L([[s,[C,k]]]),s===E&&(s=u),e.els.splice(b,o),P()},"skip"),e.add=$(s=>{L([[s,[S,a,C]]]),e.initID===E&&(O(s)==="string"&&s!==""?e.els.push(...Array.from(f.querySelectorAll(s))):O(s)===a?s.tagName?e.els.push(s):s.els?e.els.push(...s.els):s.length&&s[0].tagName&&e.els.push(...s):O(s)==="number"&&t.inits[s]&&(e=t.inits[s]),P(!1),e.initID!==E&&e.dataset({oInit:e.initID}))},"add"),e.appendInside=$(s=>{L([[s,[a,l]]]),s?.els&&(e._parent=s),N(()=>{M(s).appendChild(e.els[b])})},"appendInside"),e.appendBefore=$(s=>{L([[s,[a,l]]]),N(()=>{M(s).parentNode.insertBefore(e.els[b],M(s))})},"appendBefore"),e.appendAfter=$(s=>{L([[s,[a,l]]]),N(()=>{M(s).after(...e.els)})},"appendAfter"),e.find=$((s="")=>{L([[s,S]]);const i=[];return N(()=>{i.push(...Array.from(e.els[b].querySelectorAll(":scope "+s)))}),t(i)},"find"),e.first=$((s="")=>{L([[s,S]]);let i=E;const g=[];return N(()=>{i=e.els[b].querySelector(s),i&&g.push(i)}),t(g)},"first"),e.attr=$((s,i)=>{if(i!==null&&L([[s,S],[i,[S,k]]]),i===E){const g=[];return N(()=>{g[b]=e.els[b].getAttribute(s)}),y?g[0]:g}else N(i!==null?()=>{e.els[b].setAttribute(s,i)}:()=>{e.els[b].removeAttribute(s)})},"attr"),e.attrs=$(()=>{const s=[];return N(()=>{const i={};[...e.els[b].attributes].forEach(g=>{i[g.nodeName]=g.nodeValue}),s.push(i)}),y?s[0]:s},"attrs"),e.dataset=$(s=>{if(L([[s,[a,k]]]),typeof s===a)N(()=>{R(s,i=>{e.els[b].dataset[i]=s[i]})});else{const i=[];return N(()=>{i.push({...e.els[b].dataset})}),y?i[0]:i}},"dataset"),e.style=$(s=>{s!==null&&L([[s,[S,k]]]),e.attr("style",s)},"style"),e.css=$((s={})=>{if(s===null){e.style(null);return}L([[s,a]]);let i="";R(s,g=>{i+=g+":"+s[g].replace('"',"'")+";"}),e.style(i||null)},"css"),e.setClass=$(s=>{L([[s,S]]),N(()=>{e.els[b].setAttribute("class",s)})},"setClass"),e.addClass=$((...s)=>{N(()=>{e.els[b].classList.add(...s)})},"addClass"),e.removeClass=$((...s)=>{N(()=>{e.els[b].classList.remove(...s)})},"removeClass"),e.toggleClass=$((s,i)=>{L([[s,l],[i,[w,k]]]),N(()=>{e.els[b].classList.toggle(s,i)})},"toggleClass"),e.haveClass=s=>{L([[s,l]]);let i=!0;return N(()=>{e.els[b].classList.contains(s)||(i=!1)}),(e.isDebug||t.debug)&&console.log("haveClass() with",s),i},e.innerHTML=$(s=>{if(L([[s,[S,k]]]),s!==E)N(()=>{e.els[b].innerHTML=s});else{let i="";return N(()=>{i+=x&&e.els[b].innerHTML.length===0?t.D.parseElement(e.els[b],!1):e.els[b].innerHTML}),i}},"innerHTML"),e.innerText=$(s=>{L([[s,[S]]]),N(()=>{e.els[b].innerText=s})},"innerText"),e.textContent=$(s=>{L([[s,[S]]]),N(()=>{e.els[b].textContent=s})},"textContent"),e.html=$(s=>{if(L([[s,[S,k]]]),s!==void 0)e.innerHTML(s);else{let i="";return N(()=>{i+=x?e.els[b].outerHTML():e.els[b].outerHTML}),i}},"html"),e.val=$(s=>{if(s===void 0)return e.el?.value;N(()=>{e.els[b].value=s})},"val"),e.forEach=$(s=>{L([[s,[h]]]),N(()=>{s({self:e,i:b,o:t,el:e.els[b]})})},"forEach"),e.prepareFor=$((s,i)=>{L([[s,[a,h,k]],[i,[h,k]]]);const g=s&&O(s)===a&&s.createElement;if(!g&&O(s)!==h)throw Error("prepareFor(): pass React (full object) or React.createElement as first argument");const p=g?s.createElement:s,d=g?s.useEffect:void 0;return T=>{if(T.ref===E)throw Error("No ref property to convert Objs to React");const A=Object.assign({},T),B=p("div",{ref:T.ref});return delete A.ref,d(()=>{R(A,q=>{if(q.substring(0,1)==="on"){const z=t.camelToKebab(q).split("-")[1];e.on(z,A[q]),delete A[q]}}),e.render(A),e.appendInside(B.ref.current)},[]),B}},"prepareFor"),e.on=$((s,i,g,p)=>{L([[s,[l]],[i,[h]],[g,[a,k]],[p,[w,k]]]),s.split(", ").forEach(d=>{N(()=>{e.els[b].addEventListener(d,i,g,p)}),e.ie[d]||(e.ie[d]=[]),e.ie[d].push([i,g,p])})},"on"),e.off=$((s,i,g)=>{L([[s,[l]],[i,[h]],[g,[a,k]]]),s.split(", ").forEach(p=>{N(()=>{e.els[b].removeEventListener(p,i,g)}),e.ie[p]&&(e.ie[p]=e.ie[p].filter(d=>d[0]!==i))})},"off"),e.onDelegate=$((s,i,g)=>{L([[s,[l]],[i,[l]],[g,[h]]]),s.split(", ").forEach(p=>{const d=T=>{const A=T.target.closest(i);A&&(T.delegate=A,T.objs=e,g(T))};N(()=>{e.els[b].addEventListener(p,d)}),e.delegated[p]||(e.delegated[p]=[]),e.delegated[p].push(d)})},"onDelegate"),e.offDelegate=$(s=>{L([[s,[l]]]),R(e.delegated,i=>{if(!s||s===i)for(;e.delegated[i].length;){const g=e.delegated[i].pop();N(()=>{e.els[b].removeEventListener(i,g)})}}),e.delegated={}},"offDelegate"),e.onParent=$((s,i,g)=>{L([[s,[l]],[i,[l,a]],[g,[h]]]);const p=O(i)===a?i:t.D.querySelector(i);s.split(", ").forEach(d=>{const T=A=>{A.objs=e,g(A)};p.addEventListener(d,T),e.parented[d]||(e.parented[d]=[]),e.parented[d].push(T)})},"onParent"),e.offParent=$((s,i)=>{L([[s,[l]],[i,[l,a]]]);const g=O(i)===a?i:t.D.querySelector(i);R(e.parented,p=>{(!s||s===p)&&(e.parented[p].forEach(d=>{g.removeEventListener(p,d)}),delete e.parented[p])})},"offParent"),e.onAll=$((s,i)=>{L([[s,[l,k]],[i,[w,k]]]),R(e.ie,(g,p)=>{(!s||s===g)&&p[g].forEach(d=>{N(()=>{i?e.els[b].removeEventListener(g,d[0]):e.els[b].addEventListener(g,d[0],d[o],d[r])})})})},"onAll"),e.offAll=$(s=>{L([[s,[l]]]),e.onAll(s,o)},"offAll"),n&&e.add(n),e.take=s=>{if(L([[s,[S,a,C]]]),e.add(s),e.el){const i=e.el.dataset.oInit;if(i!==E&&t.inits[i])return e.length===o?(D=e.els[0],Object.assign(e,t.inits[i]),e.els=[D]):e=t.inits[i],P(!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 r=typeof o[0];let c=Array.isArray(o[1])?o[1]:[o[1]],w=!1;if(c.includes(r))return!0;c=c.filter(a=>!!t.specialTypes[a]);for(const a of c)if(w=t.specialTypes[a](o[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(o,r){return this._listeners.push(c=>o[r]?.(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 r of Object.keys(this._defaults))o[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 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=(r,c="")=>{let w="";for(const a in r)t.C(r,a)&&(w+=` ${c}${t.camelToKebab(a)}="${typeof r[a]!="object"?r[a]:Object.entries(r[a]).map(h=>`${h[0]}: ${h[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"],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-")}${r.includes(c)?"/":""}>${r.includes(c)?"":n.innerHTML.length?n.innerHTML:n.children.map(h=>t.D.parseElement(h)).join("")}${r.includes(c)?"":`</${c}>`}`}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:(...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(r=>o!==r),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,r)=>{t.verify([[o,["notEmptyString"]],[r,["string","number","boolean","undefined"]]]),e.attributes[o]=r},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 r=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){r+="; "+c;const w=o[c];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 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 r in e.data)t.C(e.data,r)&&(typeof e.data[r]=="object"?o.set(r,encodeURIComponent(JSON.stringify(e.data[r]))):o.set(r,e.data[r]));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,r=!1,c=!1;const w=a=>{r=!1,c=!1,o=null,setTimeout(()=>{a.then(h=>{r=!0,!h.ok&&typeof h.ok<"u"?(c=!0,e.forEach(([S,C,l])=>{l&&S[l](h)})):typeof h.json=="function"?h.json().then(S=>{o=S,e.forEach(([C,l])=>{C[l](o)})}):(o=h,e.forEach(([S,C])=>{S[C](o)}))}).catch(h=>{c=!0,e.forEach(([S,C,l])=>{l&&S[l](h)})})},33)};return n&&w(n),{reload:w,isObjsLoader:!0,listeners:e,isFinished:()=>r,getStore:()=>o,connect:(a,h="render",S)=>{t.verify([[a,["object"]],[h,["notEmptyString"]],[S,["string","undefined"]]]),r?c?S&&a[S]():typeof a[h]=="function"&&a[h](o):e.push([a,h,S])},disconnect:a=>{t.verify([[a,["object"]]]),e=e.filter(([h])=>h!==a)}}},t.getParams=n=>{t.verify([[n,["string","undefined"]]]);const e={},o=new URLSearchParams(window.location.search).entries();for(const r of o)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,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((r,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 r=0,c=0,w="",a=!1;const h="function",S=-1;if(typeof n!="object"||!n)return t.incSet[0];t.incSet[0]++;const C=t.incSet[0];t.incSet[C]=e||0,t.incReady[C]=[];const l=t.incReady[C];l[0]=1;const k={};for(const m in n)if(t.C(n,m)){if(m==="preload"){a=!0;continue}w=t.incGetHash(n[m]),r++,t.incN++;const E=n[m].indexOf(".css")>S?"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){l[r]={name:m,loaded:1},c++;continue}if(l[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")>S||n[m].indexOf(".js")>S)){const f=localStorage,v=f.getItem("oInc-"+m),u=f.getItem("oInc-"+m+"-expires"),y=f.getItem("oInc-"+m+"-hash");v&&u&&Date.now()<u&&y===w?(a||t.initState({tag:E,id:"oInc-"+C+"-"+r,innerHTML:v,"data-o-inc":C}).appendInside("head"),l[r].loaded=1,t.incFns[m]=1,c++):(k[m]=r,t.get(n[m],{mode:t.incCors?"cors":"same-origin"}).then(x=>{if(x.status!==200){t.onError&&t.onError({message:t.incSource+n[m]+" was not loaded"});return}x.text().then(b=>{f.setItem("oInc-"+m,b),f.setItem("oInc-"+m+"-expires",Date.now()+t.incCacheExp),f.setItem("oInc-"+m+"-hash",w),a||t.initState({tag:E,id:"oInc-"+C+"-"+k[m],innerHTML:b,"data-o-inc":C}).appendInside("head"),t.incCheck(C,k[m],1)})}))}else{const f={tag:E,id:"oInc-"+C+"-"+r,"data-o-inc":C,async:t.incAsync,onload:"o.incCheck("+C+","+r+",1)"};n[m].indexOf(".css")>S?(f.tag="link",f.rel="stylesheet",f.href=n[m]):(n[m].indexOf(".js")>S||(f.tag="img",f.style="display:none;"),f.src=n[m]),t.initState(f).appendInside(f.style?"body":"head")}}return l[0]+=c,r!==0&&(c===r?typeof e===h&&e(C):setTimeout(m=>{t.incReady[m]&&t.incReady[m].length<t.incReady[m][0]&&(t.incSet[m]=0,typeof o===h&&o(C))},t.incTimeout,C)),t.incSet[0]},t.connectRedux=(n,e,o,r="render")=>{t.verify([[n,["object"]],[e,["function"]],[o,["object"]],[r,["notEmptyString"]]]);const c=()=>{if(typeof o[r]=="function"){const w=e(n.getState());o[r](w!==null&&typeof w=="object"?w:{value:w})}};return c(),n.subscribe(c)},t.connectMobX=(n,e,o,r,c="render")=>(t.verify([[n,["object"]],[e,["object"]],[o,["function"]],[r,["object"]],[c,["notEmptyString"]]]),n.autorun(()=>{if(typeof r[c]=="function"){const w=o(e);r[c](w!==null&&typeof w=="object"?w:{value:w})}})),t.ObjsContext=null,t.withReactContext=(n,e,o,r,c="render")=>function(){const a=n.useContext(e);return n.useEffect(()=>{if(typeof r[c]=="function"){const h=o(a);r[c](h!==null&&typeof h=="object"?h:{value:h})}},[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 r=t.tests.length;return t.tests[r]={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(r)},autorun:()=>{typeof o.before=="function"&&(t.tBeforeEach=o.before),typeof o.after=="function"&&(t.tAfterEach=o.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,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 r=t.tests[n];let c=r.tests.pop();typeof c!="function"&&(r.tests.push(c),c=()=>{}),r.tests.push(w=>{c(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 o=sessionStorage?.getItem("oTest-Run"),r=o||t.tLog.length;let c=0,w="\u251C OK: ",a="\u251C \u2718 ",h=`
|
|
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
7
|
`,S=`
|
|
8
|
-
`,
|
|
9
|
-
`,t.tRes[
|
|
10
|
-
`,
|
|
11
|
-
`,o&&(sessionStorage.setItem(`oTest-Log-${
|
|
12
|
-
`):(t.tRes[c]=t.F,
|
|
13
|
-
`);let a=0,
|
|
14
|
-
`,typeof t.tFns[c]=="function"&&t.tFns[c](c)}},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(),o=window.getComputedStyle(n);return{width:e.width,height:e.height,top:e.top,left:e.left,visible:o.display!=="none"&&o.visibility!=="hidden"&&e.width>0,opacity:o.opacity,zIndex:o.zIndex}},t.assertVisible=n=>!!t.measure(n).visible,t.assertSize=(n,e={})=>{if(!n)return"element is null";const o=t.measure(n);if(e.w!==void 0&&Math.round(o.width)!==e.w)return`width: expected ${e.w}, got ${Math.round(o.width)}`;if(e.h!==void 0&&Math.round(o.height)!==e.h)return`height: expected ${e.h}, got ${Math.round(o.height)}`;const
|
|
15
|
-
`:
|
|
16
|
-
`:"")+(
|
|
17
|
-
`:"")+` el.dispatchEvent(new Event('${
|
|
18
|
-
`:c=
|
|
19
|
-
`:` el.dispatchEvent(new MouseEvent('${
|
|
20
|
-
`,` ['${
|
|
21
|
-
const el = document.querySelector('${
|
|
8
|
+
`,N="",l=e.length,T=0;const h=(k="",f=!1,E=!1)=>{t.tAutolog&&(f?console.error(k):(t.tShowOk||E)&&console.log(k))};if(typeof e[l-1]=="function"&&(t.tFns[s]=e[l-1],l--),o){t.tLog[s]=sessionStorage.getItem(`oTest-Log-${s}`)||"",t.tRes[s]=sessionStorage.getItem(`oTest-Res-${s}`)||!1,t.tStatus[s]=JSON.parse(sessionStorage.getItem(`oTest-Status-${s}`)||"[]");for(let k=0;k<t.tStatus[s].length;k++){const f=t.tStatus[s][k];(f===!0||f===!1)&&T++}}t.tStyled&&(w=t.tPre+t.tOk,a=t.tPre+t.tXx,p=t.tDc,S=p+p),(!o||t.tLog[s].length===0)&&(h("\u2552 "+n+" #"+s,!1,!0),t.tStyled?t.tLog[s]="<div><b>"+n+" #"+s+"</b></div>":t.tLog[s]="\u2552 "+n+" #"+s+`
|
|
9
|
+
`,t.tRes[s]=t.F,t.tStatus[s]=[]);for(let k=t.tStatus[s].length;k<l;k++){const f={n:s,i:k,title:e[k][0],tShowOk:t.tShowOk,tStyled:t.tStyled};let E=e[k][1];if(typeof E>"u"){t.tStyled?t.tLog[s]+="<div>"+f.title+"</div>":t.tLog[s]+=f.title+`
|
|
10
|
+
`,h("\u251C "+f.title,!1,!0),t.tStatus[s][k]=!0,T++;continue}if(typeof t.tBeforeEach=="function"&&t.tBeforeEach(f),typeof E=="function")try{E=E(f)}catch(g){E=g.message,t.onError&&t.onError(g)}if(typeof t.tAfterEach=="function"&&t.tAfterEach(f,E),E&&typeof E.then=="function"){c++;const g=setTimeout(()=>{f.title+=" (timeout)",t.testUpdate(f)},t.tTime);E.then(m=>{clearTimeout(g);const v=m===!0||m&&m.ok===!0,b=m&&m.errors&&m.errors.length?m.errors.join("; "):typeof m=="string"?m:"";t.testUpdate(f,v,v?"":b?": "+b:"")}).catch(m=>{clearTimeout(g),t.testUpdate(f,!1,m.message||"Promise rejected")});continue}if(typeof t.tStatus[s][k]>"u")t.tStatus[s][k]=typeof E=="string"?t.F:E;else{sessionStorage.setItem(`oTest-Status-${s}`,JSON.stringify(t.tStatus[s]));return}E===!0?(T++,t.tShowOk&&(t.tLog[s]+=w+e[k][0]+p,h("\u251C OK: "+e[k][0]))):E!==t.U?(t.tLog[s]+=a+e[k][0]+(E!==t.F?": "+E:"")+S,h("\u251C \u2718 "+e[k][0]+(E!==t.F?": "+E:""),!0)):(c++,setTimeout(g=>{g.title+=" (timeout)",t.testUpdate(g)},t.tTime,f))}return t.tRes[s]=T===l,N=c?"\u251C ":"\u2558 ",N+="DONE "+T+"/"+l+(c?", waiting: "+c:""),h(N,T+c!==l),c||h(),t.tStyled?t.tLog[s]+=t.tPre+'<div style="color:'+(T+c!==l?"red":"green")+';"><b>DONE '+T+"/"+l+(c?", waiting: "+c:"")+"</b>"+t.tDc+t.tDc:t.tLog[s]+=N+`
|
|
11
|
+
`,o&&(sessionStorage.setItem(`oTest-Log-${s}`,t.tLog[s]),sessionStorage.setItem(`oTest-Res-${s}`,t.tRes[s]),sessionStorage.setItem(`oTest-Status-${s}`,JSON.stringify(t.tStatus[s]))),!c&&typeof t.tFns[s]=="function"&&t.tFns[s](s),s},t.testUpdate=(n,e=t.F,o="")=>{t.verify([[n,["object"]],[e,["boolean","string"]],[o,["string"]]]);let s="";const c=n.n,w=(a="",p=!1)=>{t.tAutolog&&(p?console.error(a):console.log(a))};if(t.tStatus[c][n.i]===t.U||t.tStatus[c][n.i]===null){t.tStatus[c][n.i]=e===!0,e===!0?n.tShowOk&&(s="\u251C OK: "+n.title+o,w(s),n.tStyled?t.tLog[c]+=t.tPre+t.tOk+n.title+o+t.tDc:t.tLog[c]+=s+`
|
|
12
|
+
`):(t.tRes[c]=t.F,s="\u251C \u2718 "+n.title+(e?": "+e:"")+o,w(s,!0),n.tStyled?t.tLog[c]+=t.tPre+t.tXx+n.title+o+(e?": "+e:"")+t.tDc+t.tDc:t.tLog[c]+=s+`
|
|
13
|
+
`);let a=0,p=0;for(const S of t.tStatus[c]){if(S===t.U||S===null)return;S||a++,p++}if(sessionStorage?.getItem("oTest-Run")===c&&(sessionStorage.setItem(`oTest-Log-${c}`,t.tLog[c]),sessionStorage.setItem(`oTest-Res-${c}`,t.tRes[c]),sessionStorage.setItem(`oTest-Status-${c}`,JSON.stringify(t.tStatus[c])),p<t.tests[c].tests.length))return;t.tRes[c]=!a,s=a?"FAILED "+a+"/"+p:"DONE "+p+"/"+p,w("\u2558 "+s,!!a),w(),n.tStyled?t.tLog[c]+=t.tPre+'<b style="color:'+(a?"red":"green")+';">'+s+"</b>"+t.tDc:t.tLog[c]+="\u2558 "+s+`
|
|
14
|
+
`,typeof t.tFns[c]=="function"&&t.tFns[c](c)}},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(),o=window.getComputedStyle(n);return{width:e.width,height:e.height,top:e.top,left:e.left,visible:o.display!=="none"&&o.visibility!=="hidden"&&e.width>0,opacity:o.opacity,zIndex:o.zIndex}},t.assertVisible=n=>!!t.measure(n).visible,t.assertSize=(n,e={})=>{if(!n)return"element is null";const o=t.measure(n);if(e.w!==void 0&&Math.round(o.width)!==e.w)return`width: expected ${e.w}, got ${Math.round(o.width)}`;if(e.h!==void 0&&Math.round(o.height)!==e.h)return`height: expected ${e.h}, got ${Math.round(o.height)}`;const s=c=>{const w=window.getComputedStyle(n).getPropertyValue(c);return w?parseFloat(w):0};return e.padding!==void 0&&s("padding-top")!==e.padding?`padding: expected ${e.padding}, got ${s("padding-top")}`:e.paddingTop!==void 0&&s("padding-top")!==e.paddingTop?`paddingTop: expected ${e.paddingTop}, got ${s("padding-top")}`:e.paddingRight!==void 0&&s("padding-right")!==e.paddingRight?`paddingRight: expected ${e.paddingRight}, got ${s("padding-right")}`:e.paddingBottom!==void 0&&s("padding-bottom")!==e.paddingBottom?`paddingBottom: expected ${e.paddingBottom}, got ${s("padding-bottom")}`:e.paddingLeft!==void 0&&s("padding-left")!==e.paddingLeft?`paddingLeft: expected ${e.paddingLeft}, got ${s("padding-left")}`:e.margin!==void 0&&s("margin-top")!==e.margin?`margin: expected ${e.margin}, got ${s("margin-top")}`:e.marginTop!==void 0&&s("margin-top")!==e.marginTop?`marginTop: expected ${e.marginTop}, got ${s("margin-top")}`:e.marginRight!==void 0&&s("margin-right")!==e.marginRight?`marginRight: expected ${e.marginRight}, got ${s("margin-right")}`:e.marginBottom!==void 0&&s("margin-bottom")!==e.marginBottom?`marginBottom: expected ${e.marginBottom}, got ${s("margin-bottom")}`:e.marginLeft!==void 0&&s("margin-left")!==e.marginLeft?`marginLeft: expected ${e.marginLeft}, got ${s("margin-left")}`:!0},t.recorder={active:!1,actions:[],mocks:{},initialData:{},assertions:[],observeRoot:null,_originalFetch:null,_listeners:[],_observer:null},t.startRecording=(n,e,o)=>{if(t.recorder.active)return;const s=["click","mouseover","scroll","input","change"],c={click:100,mouseover:50,scroll:30,input:50,change:50},w=e||s,a=Object.assign({},c,o||{}),p={scroll:30,mouseover:50},S=t.recorder;S.active=!0,S.actions=[],S.mocks={},S.stepDelays=a,S.initialData={url:window.location.href,timestamp:Date.now()},S.observeRoot=n||null,S.assertions=[],t.inits.forEach((f,E)=>{f?.store&&(S.initialData["init_"+E]=JSON.parse(JSON.stringify(f.store)))}),S._originalFetch=window.fetch,window.fetch=async(f,E={})=>{const g=(E.method||"GET").toUpperCase();let m;try{m=E.body?JSON.parse(E.body):void 0}catch{m=E.body}const v=await S._originalFetch(f,E),b=v.clone();let D;try{D=await b.json()}catch{D=await b.text().catch(()=>null)}const M=g+":"+f;return S.mocks[M]={url:f,method:g,request:m,response:D,status:v.status},v};const N={"data-o-init":1,"data-o-init-i":1,"data-o-state":1},l=(f,E)=>{if(t.D.querySelectorAll(f).length<=1)return f;let g=E;for(;g&&g!==t.D.body;){let m=g.id?"#"+g.id:null;if(!m&&g.attributes){const v=t.autotag?"data-"+t.autotag:null;if(v){const b=g.getAttribute(v);b!=null&&(m=`[${v}="${b}"]`)}if(!m){for(const b of g.attributes)if(b.name.startsWith("data-")&&!N[b.name]){m=`[${b.name}="${b.value}"]`;break}}}if(m){const v=m+" "+f;if(t.D.querySelectorAll(v).length===1)return v}g=g.parentElement}return f},T=f=>{if(!f||f.nodeType!==1)return"";let E="";if(f.dataset){const g=t.autotag&&f.dataset[t.autotag];g&&(E=l(`[data-${t.autotag}="${g}"]`,f.parentElement))}if(!E&&f.tagName){const g=f.id?"#"+f.id:f.className?f.tagName.toLowerCase()+"."+[...f.classList].join("."):f.tagName.toLowerCase();E=f.id?g:l(g,f.parentElement)}return E},h=n&&t.D.querySelector(n)||t.D.body;S._observer=new MutationObserver(f=>{const E=S.actions.length-1;E<0||f.forEach(g=>{const m=(v,b)=>{let D,M;if(v&&h&&h.querySelectorAll(v).length>1){let O=b;for(;O&&O!==h&&O.nodeType===1;){const H=t.autotag&&O.dataset&&O.dataset[t.autotag];if(H){const L=`[data-${t.autotag}="${H}"]`,$=h.querySelectorAll(L);if($.length>1){const I=[...$].indexOf(O);if(I!==-1){D=L,M=I;break}}}O=O.parentElement}}return{listSelector:D,index:M}};if(g.type==="childList"&&g.addedNodes.forEach(v=>{if(v.nodeType!==1||!v.offsetParent)return;const b=T(v);if(!b||S.assertions.some(L=>L.actionIdx===E&&L.selector===b&&L.type==="visible"))return;const M=((v.querySelector?.(".task-text")||v).textContent?.trim()||v.textContent?.trim()||"").slice(0,80)||void 0,{listSelector:C,index:O}=m(b,v),H={actionIdx:E,type:"visible",selector:b,text:M};C!=null&&(H.listSelector=C),O!=null&&(H.index=O),S.assertions.push(H)}),g.type==="attributes"){const v=T(g.target);if(!v||S.assertions.some(C=>C.actionIdx===E&&C.selector===v&&C.type==="class"))return;const{listSelector:b,index:D}=m(v,g.target),M={actionIdx:E,type:"class",selector:v,className:g.target.className};b!=null&&(M.listSelector=b),D!=null&&(M.index=D),S.assertions.push(M)}})}),S._observer.observe(h,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden","disabled","aria-expanded","aria-checked"]});const k={};w.forEach(f=>{const E=g=>{const m=g.target;if(n&&h&&m?.nodeType===1&&!h.contains(m))return;let v="";if(m?.dataset){const I=t.autotag&&m.dataset[t.autotag];I&&(v=l(`[data-${t.autotag}="${I}"]`,m.parentElement))}if(!v&&m?.tagName){const I=m.id?"#"+m.id:m.className?m.tagName.toLowerCase()+"."+[...m.classList].join("."):m.tagName.toLowerCase();v=m.id?I:l(I,m.parentElement)}let b,D;if(v&&h&&h.querySelectorAll(v).length>1){let U=m;for(;U&&U!==h&&U.nodeType===1;){const J=t.autotag&&U.dataset&&U.dataset[t.autotag];if(J){const G=`[data-${t.autotag}="${J}"]`,X=h.querySelectorAll(G);if(X.length>1){const V=[...X].indexOf(U);if(V!==-1){b=G,D=V;break}}}U=U.parentElement}}const M=m?.tagName?m.tagName.toLowerCase()+(m.type?":"+m.type:""):void 0,C=f==="scroll"?window.scrollY:void 0,O=f==="input"||f==="change"?m?.value:void 0,H=f==="change"&&(m?.type==="checkbox"||m?.type==="radio")?m?.checked:void 0,L=a[f]!==void 0?a[f]:p[f]??0,$=()=>{const I={type:f,target:v,time:Date.now()};M&&(I.targetType=M),C!==void 0&&(I.scrollY=C),O!==void 0&&(I.value=O),H!==void 0&&(I.checked=H),b!=null&&(I.listSelector=b),D!=null&&(I.targetIndex=D),S.actions.push(I)};L===0?$():(clearTimeout(k[f]),k[f]=setTimeout($,L))};t.D.addEventListener(f,E,!0),S._listeners.push({ev:f,handler:E})})},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:o})=>{t.D.removeEventListener(e,o,!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||[]],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 o=sessionStorage?.key(e);o&&o.indexOf("oTest-Recording-")===0&&sessionStorage?.removeItem(o)}},t.exportTest=n=>{const e=n.actions.map(s=>{let c;return s.type==="scroll"?c=` window.scrollTo(0, ${s.scrollY||0}); return true;
|
|
15
|
+
`:s.type==="input"||s.type==="change"?c=(s.value!==void 0?` el.value = ${JSON.stringify(s.value)};
|
|
16
|
+
`:"")+(s.checked!==void 0?` el.checked = ${s.checked};
|
|
17
|
+
`:"")+` el.dispatchEvent(new Event('${s.type}', {bubbles:true})); return true;
|
|
18
|
+
`:c=s.type==="click"?` el.click(); return true;
|
|
19
|
+
`:` el.dispatchEvent(new MouseEvent('${s.type}', {bubbles:true,cancelable:true})); return true;
|
|
20
|
+
`,` ['${s.type} on ${s.target}', () => {
|
|
21
|
+
const el = document.querySelector('${s.target}');
|
|
22
22
|
if (!el) return 'element not found';
|
|
23
23
|
`+c+" }],"}).join(`
|
|
24
24
|
`);return`// Auto-generated by o.exportTest() \u2014 review and anonymize mocks before committing
|
|
@@ -29,18 +29,18 @@ ${e}
|
|
|
29
29
|
], () => {
|
|
30
30
|
// teardown
|
|
31
31
|
});
|
|
32
|
-
`},t.exportPlaywrightTest=(n,e={})=>{const o=e.testName||"Recorded session",
|
|
32
|
+
`},t.exportPlaywrightTest=(n,e={})=>{const o=e.testName||"Recorded session",s=n.initialData?.url??"/";let c="/";try{c=new URL(s).pathname||"/"}catch{c=s}const w=e.baseUrl||c,a=Object.values(n.mocks).map(l=>{const T=l.url.startsWith("/")?l.url:"/"+l.url,h=JSON.stringify(l.response);return` await page.route('**${T}', async route => {
|
|
33
33
|
await route.fulfill({ status: ${l.status||200}, contentType: 'application/json',
|
|
34
|
-
body: JSON.stringify(${
|
|
34
|
+
body: JSON.stringify(${h}) });
|
|
35
35
|
});`}).join(`
|
|
36
|
-
`),
|
|
36
|
+
`),p=Object.assign({click:100,mouseover:50,scroll:30,input:50,change:50},n.stepDelays||{}),S=n.actions.map((l,T)=>{const h=l.listSelector!=null&&l.targetIndex!=null?l.target!==l.listSelector?`page.locator(${JSON.stringify(l.listSelector)}).nth(${l.targetIndex}).locator(${JSON.stringify(l.target)})`:`page.locator(${JSON.stringify(l.listSelector)}).nth(${l.targetIndex})`:`page.locator(${JSON.stringify(l.target)})`,k=` await page.waitForTimeout(${p[l.type]||50});`;let f;if(l.type==="scroll")f=` await page.evaluate(() => window.scrollTo(0, ${l.scrollY||0}));`;else if(l.type==="mouseover")f=` await ${h}.hover();
|
|
37
37
|
// 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(l.type==="input")f=` await ${
|
|
39
|
-
await expect(${
|
|
38
|
+
// Fix: toggle a class in a mouseover handler, or add a page.screenshot() visual check.`;else if(l.type==="input")f=` await ${h}.fill(${JSON.stringify(l.value||"")});`;else if(l.type==="change"){const g=l.targetType||"";if(g.indexOf(":checkbox")!==-1||g.indexOf(":radio")!==-1){const m=l.checked!==void 0?l.checked:l.value==="true"||l.value==="on";f=` await ${h}.${m?"check":"uncheck"}();`}else g.indexOf("select")!==-1?f=` await ${h}.selectOption(${JSON.stringify(l.value||"")});`:f=` await ${h}.fill(${JSON.stringify(l.value||"")});`}else f=` await ${h}.click();`;const E=(n.assertions||[]).filter(g=>g.actionIdx===T).filter((g,m,v)=>v.findIndex(b=>b.selector===g.selector&&b.type===g.type&&b.index===g.index)===m).map(g=>{const m=g.listSelector!=null&&g.index!=null?g.selector!==g.listSelector?`page.locator(${JSON.stringify(g.listSelector)}).nth(${g.index}).locator(${JSON.stringify(g.selector)})`:`page.locator(${JSON.stringify(g.listSelector)}).nth(${g.index})`:`page.locator(${JSON.stringify(g.selector)})`;if(g.type==="visible"){let v=` await expect(${m}).toBeVisible();`;return g.text&&(v+=`
|
|
39
|
+
await expect(${m}).toContainText(${JSON.stringify(g.text)});`),v}return g.type==="class"?` // class on ${g.selector} changed to: "${g.className}"`:""}).filter(Boolean).join(`
|
|
40
40
|
`);return f+`
|
|
41
|
-
`+
|
|
42
|
-
`+
|
|
43
|
-
`),
|
|
41
|
+
`+k+(E?`
|
|
42
|
+
`+E:"")}).join(`
|
|
43
|
+
`),N=(n.assertions||[]).length>0;return`// Auto-generated by o.exportPlaywrightTest() \u2014 review and anonymize mocks before committing
|
|
44
44
|
// Prerequisites: npm install @playwright/test && npx playwright install chromium
|
|
45
45
|
// Run: npx playwright test recorded.spec.ts
|
|
46
46
|
import { test, expect } from '@playwright/test';
|
|
@@ -54,13 +54,13 @@ test(${JSON.stringify(o)}, async ({ page }) => {
|
|
|
54
54
|
|
|
55
55
|
`+(S?S+`
|
|
56
56
|
|
|
57
|
-
`:"")+(
|
|
57
|
+
`:"")+(N?` // Auto-generated assertions above \u2014 review for correctness before committing
|
|
58
58
|
`:` // TODO: Add assertions before committing, e.g.:
|
|
59
59
|
// await expect(page.locator('[data-qa="success-panel"]')).toBeVisible();
|
|
60
60
|
// await expect(page).toHaveURL(/\\/confirmation/);
|
|
61
61
|
// await expect(page.locator('[data-qa="error-banner"]')).not.toBeVisible();
|
|
62
62
|
`)+`});
|
|
63
|
-
`},t.playRecording=(n,e={})=>{const o=Object.assign({},n.mocks,e),
|
|
63
|
+
`},t.playRecording=(n,e={})=>{const o=Object.assign({},n.mocks,e),s=window.fetch;window.fetch=(a,p={})=>{const N=(p.method||"GET").toUpperCase()+":"+a;if(o[N]){const l=o[N],T=typeof l.response=="string"?l.response:JSON.stringify(l.response);return Promise.resolve(new Response(T,{status:l.status||200}))}return s(a,p)};const c=n.actions.map(a=>[`${a.type} on ${a.target}`,()=>{let p=null;if(a.target)if(a.listSelector!=null&&a.targetIndex!=null){const N=t.D.querySelectorAll(a.listSelector)[a.targetIndex];N&&(p=a.target!==a.listSelector?N.querySelector(a.target):N,!p&&a.target!==a.listSelector&&(p=N))}else p=t.D.querySelector(a.target);return!p&&a.type!=="scroll"?`element not found: ${a.target}`:(a.type==="scroll"?window.scrollTo(0,a.scrollY||0):a.type==="input"||a.type==="change"?(a.value!==void 0&&(p.value=a.value),a.checked!==void 0&&(p.checked=a.checked),p.dispatchEvent(new Event(a.type,{bubbles:!0}))):a.type==="click"?p.click():p.dispatchEvent(new MouseEvent(a.type,{bubbles:!0,cancelable:!0})),!0)}]);return t.test("Recorded playback",...c,()=>{window.fetch=s})},t.testOverlay=()=>{const n="o-test-overlay-btn",e="o-test-overlay-panel";if(t("#"+n).el)return;const o=()=>{const l=t("#"+e);if(!l.el)return;const T=t.tRes.length;let k=`<b>Tests: ${t.tRes.filter(Boolean).length}/${T}</b><hr style="margin:4px 0">`;t.tLog.forEach((f,E)=>{const g=t.tRes[E];k+=`<div style="margin:2px 0;padding:2px 4px;border-radius:3px;background:${g?"#d4edda":"#f8d7da"};color:${g?"#155724":"#721c24"};font-size:11px;white-space:pre-wrap">${f||"Test #"+E}</div>`}),k+='<button id="o-test-export" style="margin-top:6px;padding:4px 8px;font-size:11px;cursor:pointer">Export results</button>',l.html(k),t("#o-test-export").on("click",()=>{const f=JSON.stringify({results:t.tRes,logs:t.tLog},null,2),E=new Blob([f],{type:"application/json"}),g=t.D.createElement("a");g.href=URL.createObjectURL(E),g.download="objs-test-results.json",g.click()})},s={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",cursor:"grab","user-select":"text"},c=t.initState({tag:"div",id:n,className:"o-test-overlay",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;cursor:grab;user-select:text;",html:`<div class="o-test-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;cursor:grab;min-width:200px;"><div style="display:flex;align-items:center;gap:12px;"><span class="o-test-overlay-summary" style="flex:1;font-size:13px;">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><div id="${e}" style="display:none;margin-top:4px;padding:8px;background:#fff;border:1px solid #334155;border-radius:6px;max-height:60vh;overflow-y:auto;box-shadow:0 2px 8px rgba(0,0,0,.15);font-size:11px;user-select:text;cursor:text;"></div>`}).appendInside("body"),w=()=>{c.css(s)};let a=null;const p=l=>{a&&(s.left=a.left+(l.clientX-a.startX)+"px",s.top=a.top+(l.clientY-a.startY)+"px",delete s.bottom,s.transform="none",w())},S=()=>{a&&(s.cursor="grab",w()),a=null};c.on("mousedown",l=>{if(l.target.closest(".o-test-overlay-close")||l.target.closest(".o-test-overlay-toggle")||l.target.closest("#"+e))return;const T=c.el.getBoundingClientRect();a={startX:l.clientX,startY:l.clientY,left:T.left,top:T.top},s.cursor="grabbing",w()}),t.D.addEventListener("mousemove",p),t.D.addEventListener("mouseup",S);const N=()=>{const l=t(".o-test-overlay-summary");l.els.length&&l.innerText(`Tests: ${t.tRes.filter(Boolean).length}/${t.tRes.length}`)};c.first(".o-test-overlay-toggle").on("click",()=>{const l=t("#"+e);if(!l.el)return;const T=l.el.style.display!=="none";l.css({display:T?"none":"block"}),T||o()}),c.first(".o-test-overlay-close").on("click",()=>{t.D.removeEventListener("mousemove",p),t.D.removeEventListener("mouseup",S),c.remove()}),t.testOverlay.showPanel=()=>{const l=t("#"+e);l.el&&(l.css({display:"block"}),o(),N())},t._testOverlayBase||(t._testOverlayBase=t.test),t.test=(...l)=>{const T=t._testOverlayBase(...l),h=t.tFns[T];return t.tFns[T]=k=>{typeof h=="function"&&h(k);const f=t("#"+e);f.el&&f.el.style.display!=="none"&&o(),N()},T}},t.testConfirm=(n,e=[],o={})=>new Promise(s=>{t(".o-tc-overlay").remove();const c=o.confirm||"Continue",w=e.length>0,a=w?"#dc2626":"#2563eb",p=e.map((m,v)=>"o-tc-cb-"+v),N=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;">`+e.map((m,v)=>`<li style="margin-bottom:4px;"><label for="${p[v]}" style="display:flex;align-items:center;gap:8px;cursor:pointer;user-select:none;"><input type="checkbox" id="${p[v]}" class="o-tc-item-cb"> <span>${m}</span></label></li>`).join("")+"</ul>":"",l=t.initState({tag:"div",className:"o-tc-overlay",style:"position:fixed;left:50%;bottom:50px;transform:translateX(-50%);z-index:999999;width:fit-content;max-width:min(90vw,400px);font-family:system-ui,sans-serif;cursor:grab;user-select:text;",html:`<div class="o-tc-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;cursor:grab;min-width:280px;"><div style="display:flex;align-items:center;gap:12px;"><span class="o-tc-label" style="flex:1;">${n}: Paused</span><button type="button" class="o-tc-ok" style="padding:6px 14px;background:${a};color:#fff;border:none;border-radius:6px;font-weight:600;cursor:pointer;font-size:13px;flex-shrink:0;">${c}</button></div>`+N+"</div>"}).appendInside("body"),T={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 m=l.first(".o-tc-ok"),v=t(".o-tc-overlay .o-tc-item-cb"),b=()=>{const D=v.length>0&&v.els.every(M=>M.checked);m.css({...T,background:D?"#16a34a":"#dc2626"})};v.on("change",b)}let h=null;const k={position:"fixed",left:"50%",bottom:"50px",transform:"translateX(-50%)","z-index":"999999",width:"fit-content","max-width":"min(90vw, 400px)","font-family":"system-ui,sans-serif",cursor:"grab","user-select":"text"},f=()=>{l.css(k)},E=m=>{h&&(k.left=h.left+(m.clientX-h.startX)+"px",k.top=h.top+(m.clientY-h.startY)+"px",delete k.bottom,k.transform="none",f())},g=()=>{h&&(k.cursor="grab",f()),h=null};l.on("mousedown",m=>{if(m.target.closest(".o-tc-ok"))return;const v=l.el.getBoundingClientRect();h={startX:m.clientX,startY:m.clientY,left:v.left,top:v.top},k.cursor="grabbing",f()}),t.D.addEventListener("mousemove",E),t.D.addEventListener("mouseup",g),l.first(".o-tc-ok").on("click",()=>{t.D.removeEventListener("mousemove",E),t.D.removeEventListener("mouseup",g);let m=[];w&&t(".o-tc-overlay .o-tc-item-cb").els.forEach((b,D)=>{!b.checked&&e[D]!==void 0&&m.push(e[D])}),l.remove(),m.length===0?s({ok:!0}):s({ok:!1,errors:m})})});
|
|
64
64
|
|
|
65
65
|
export { o };
|
|
66
66
|
export default o;
|
package/objs.d.ts
CHANGED
|
@@ -179,7 +179,8 @@ export interface ObjsInstance {
|
|
|
179
179
|
|
|
180
180
|
// Selection
|
|
181
181
|
reset(query: QueryArg): ObjsInstance;
|
|
182
|
-
select(
|
|
182
|
+
/** Select by index or by event: select(e) selects the element in this instance that contains e.target. */
|
|
183
|
+
select(i?: number | Event): ObjsInstance;
|
|
183
184
|
all(): ObjsInstance;
|
|
184
185
|
find(query: string): ObjsInstance;
|
|
185
186
|
first(query?: string): ObjsInstance;
|
|
@@ -271,7 +272,7 @@ declare namespace o {
|
|
|
271
272
|
// Element selection
|
|
272
273
|
function first(query: string): ObjsInstance;
|
|
273
274
|
function take(query: QueryArg): ObjsInstance;
|
|
274
|
-
|
|
275
|
+
|
|
275
276
|
// State
|
|
276
277
|
function init(states: StatesMap | StateFunction | string): ObjsInstance;
|
|
277
278
|
function initState(state: StateObject, props?: Record<string, unknown>): ObjsInstance;
|