@joystick.js/ui-canary 0.0.0-canary.54 → 0.0.0-canary.56
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.
|
@@ -18,4 +18,4 @@ var Jt=Object.create;var oe=Object.defineProperty;var Qt=Object.getOwnPropertyDe
|
|
|
18
18
|
@media screen and (max-height: ${v}px) {
|
|
19
19
|
${typeof f=="function"?f(e):f}
|
|
20
20
|
}
|
|
21
|
-
`}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var sr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!_(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},G=(t={},e={})=>{try{return l(e)?sr(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var ie={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var at=(t={},e={})=>{try{return e?Object.entries({...ie,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ie}catch(r){n("component.lifecycle.compile",r)}};var K=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{n("component.methods.compile")}};var ne=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>C(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){n("component.url.compile",e)}};var S=()=>typeof window=="undefined";var P=null,W=0,dt=(t={},e=null)=>{try{let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);P&&(clearInterval(P),P=null);let i={client:o,send:(s={})=>o.send(JSON.stringify(s))};return o.addEventListener("open",()=>{t?.options?.logging&&console.log(`[joystick.websockets] Connected to ${t?.url}`),t?.events?.onOpen&&t.events.onOpen(i),W=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&t.events.onMessage(JSON.parse(s.data||{}),i)}),o.addEventListener("close",s=>{t?.options?.logging&&console.log(`[joystick.websockets] Disconnected from ${t?.url}`),t?.events?.onClose&&t.events.onClose(s?.code,s?.reason,i),o=null;let c=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!P&&!c&&(P=setInterval(()=>{o=null,W<(t?.options?.reconnectAttempts||12)?(dt(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${W+1}/12)...`),W+=1):clearInterval(P)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},ct=dt;var ar=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!_(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},lt=(t={},e={})=>{try{return l(e)?ar(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var mt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=U(8),t.ssrId=e?._ssrId||null,t.css=st(),t.data=B(e?.dataFromSSR,e?._componentId),t.defaultProps=lt(t,e?.defaultProps),t.props=nt(t?.defaultProps,e?.props),t.state=G(t,e?.state),t.events=e?.events||{},t.lifecycle=at(t,e?.lifecycle),t.methods=K(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=it,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=ne(e?.url)),r&&window.__joystick_url__&&(t.url=ne(window.__joystick_url__)),r&&e?.websockets&&l(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[c,a]=i[s];ct({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(m={})=>{t.websockets={...t.websockets||{},[c]:m}})}}}catch(r){n("component.registerOptions",r)}};var I=(t="",e=[])=>{try{console.error(`${t} failed with the following errors:`),e.forEach(r=>{console.log(r.message),r.stack&&console.log(r.stack)})}catch(r){n(t,r)}};var J=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var pt=(t={})=>Object.entries(t).map(([e,r])=>`${e}=${r}`)?.join("; ");var dr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.get.handleParseResponse",e)}},ut=(t="",e={})=>{try{return typeof window.fetch!="undefined"&&!e?.skip?new Promise((r,o)=>{let i=e.input?JSON.stringify(e.input):null,s=e.output?JSON.stringify(e.output):null,c=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content"),m={...e?.headers||{},"x-joystick-csrf":a};return window?.__joystick_test__&&(m.Cookie=pt({joystickLoginToken:window.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expires_at__})),fetch(c,{method:"GET",mode:"cors",headers:m,credentials:"include"}).then(async y=>{let w=await dr(y);return w?.errors?(I("get request",w.errors),o(w)):r(w)}).catch(y=>(I("get request",[y]),o({errors:[y]})))}):Promise.resolve()}catch(r){n("get request",r)}};var cr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.set.handleParseResponse",e)}},lr=(t={})=>{try{return JSON.stringify(t)}catch(e){n("api.set.getBody",e)}},ft=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=lr(e),c=document.querySelector('[name="csrf"]')?.getAttribute("content"),a={...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":c};return window?.__joystick_test__&&(a.Cookie=generateCookieHeader({joystickLoginToken:window?.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expirs_at__})),fetch(i,{method:"POST",mode:"cors",headers:a,body:s,credentials:"include"}).then(async m=>{let y=await cr(m);return y?.errors?(I("set request",y.errors),o(y)):r(y)}).catch(m=>(I("set request",[m]),o({errors:[m]})))}):Promise.resolve()}catch(r){n("set request",r)}};var ht={get:ut,set:ft};var mr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("addToQueue.getQueue",e)}},q=(t="",e=null)=>{try{S()||(mr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Q=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&l(o.options.data)){let i=await o.options.data(t,e,r,o);return Promise.resolve(i)}return Promise.resolve()}catch(i){n("component.data.fetch",i)}};var wt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let i=await Q(ht,e,o,r);return r.data=wt(i,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=i),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){n("component.data.compile",o)}},yt=wt;var gt=(t={})=>{try{if(!S()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return yt(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var Ft=ir(xt());var bt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(u(t)&&o){let i=Object.keys(t);for(let s=0;s<i.length;s+=1){let c=i[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let m=0;m<a.length;m+=1){let y=a[m],w=bt(y,e,r);if(w!==null)return w}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},R=bt;var $t=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var pr=(t={},e={},r=null)=>{try{let o=N(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){n("component.renderMethods.component.renderForClient",o)}},ur=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){n("component.renderMethods.component.renderToHTMLForSSR",e)}},fr=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){n("component.renderMethods.component.collectDataFunctionsForSSR",e)}},hr=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};$t(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){n("component.renderMethods.component.handleAddComponentToParent",e)}},wr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&q("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&q("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},yr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Ft.diff)(e?.existingPropsMap,r)?.length>0&&q("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t)})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},gr=function(){return function(e=null,r={},o={}){let i=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[i.id]||{},c=o.children[i.id]||[],a=s[c?.length];return i.state=a?.state||i.state,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,yr(i,o,r),q("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),wr(this,i),i.parent&&hr(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?fr(i):i.parent&&i.parent.ssrTree?ur(i):pr(i,this,a?.children)}},xr=function(e,r){try{let o=this;return new gr().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},se=xr;var br=function(e=[],r=null){try{return l(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},ae=br;var $r=(t="",e=[])=>{try{return e.reduce((r,[o,i])=>r.replace(`{{${o}}}`,i),t)}catch(r){n("component.renderMethods.i18n.replacePlaceholdersInString",r)}},de=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),i=typeof t=="object"&&!o;if(r)return $r(t,e);if(o)return t?.map(s=>de(s,e));if(i)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=de(a,e),s),{})}catch(r){n("component.renderMethods.i18n.handleTranslationReplacement",r)}},Fr=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>(console.log({key:t,objectToTraverse:r,keyToMatch:o}),r[o]),e)}catch(r){n("component.renderMethods.i18n.getTranslationAtPath",r)}},Er=function(t="",e={}){try{let r=S()?this.translations:window.__joystick_i18n__,i=t?.includes(".")?Fr(t,r):r[t];if(t?.includes("creatorDashboard")&&console.log({key:t,replacements:e,translation:i,translations:r}),!r||!i)return"";let s=Object.entries(e);return de(i,s)}catch(r){n("component.renderMethods.i18n",r)}},ce=Er;var Mr=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},le=Mr;var Et={c:se,component:se,e:ae,each:ae,i:ce,i18n:ce,w:le,when:le};var Mt=(t={},e={})=>{try{return Object.entries(Et).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var kt=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,children:kt(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},St=(t={})=>{try{return kt(t)}catch(e){n("component.render.getExistingStateMap",e)}};var Ot=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),kr=new RegExp(/\n/g);var Sr=(t="")=>{try{return(t.match(Ot)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},Tt=(t="")=>{try{let e=`${t}`;return e=Sr(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var vt=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:i=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${i}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Ct=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,c]=o[i];for(let a=0;a<c?.length;a+=1){let m=c[a];Object.entries(m?.timers)?.length>0&&r.push(...Object.values(m?.timers)),Object.entries(m?.children)?.length>0&&Ct(m?.children,r)}}if(r?.length>0)for(let i=0;i<r?.length;i+=1)clearTimeout(r[i])}catch(r){n("component.render.clearTimersOnChildren",r)}},Rt=Ct;var X=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=B(e.dataFromSSR,t.id)||{}),Rt(t?.children);let r=St(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Mt({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=K(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=Tt(o),s=vt(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Or=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},At=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?At(e):me(e)):me(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},me=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Or(t.attributes),children:[].flatMap.call(t.childNodes,o=>At(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},H=me;var Tr=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},Lt=(t="")=>{try{let e=Tr(t);return H(e)}catch(e){n("component.virtualDOM.build",e)}};var Dt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var vr=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[i,s]=r[o];Dt(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=_t(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},_t=(t=null)=>{try{return C(t)?document.createTextNode(t):vr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},V=_t;var N=(t={},e={})=>{try{let r=X(t,{existingChildren:e?.existingChildren}),o=Lt(r.wrapped,t),i=e.includeActual&&o?V(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var jt=(t={},e={})=>{try{let r=N(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Cr=(t={},e={})=>{let r=[];for(let[o,i]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,i),s));for(let o in t)o in e||r.push(i=>(i&&i.removeAttribute&&i.removeAttribute(o),i));return o=>{for(let i of r)i&&typeof i=="function"&&i(o)}},ee=Cr;var Rr=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],c=e[i];r.push([s,c])}return r},Pt=Rr;var Ar=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Lr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Dr=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=c=>{let a=V(i);return c.appendChild(a),c};r.push(s)}),r},_r=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=re(o,e[i]);r.push(s)}),r},jr=(t=[],e=[])=>{let r=_r(t,e),o=Dr(t,e);return i=>{if(i){let s=Pt(r,i.childNodes);Lr(s),Ar(o,i)}return i}},te=jr;var It={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ee(t.attributes,e.attributes)(r),te([],e.children)(r);let i=r.querySelector(`option[value="${o}"]`);if(i&&(r.value=o),!i){let s=r.querySelector("option");r.value=s?.value||""}return r}};var pe=(t,e)=>r=>{let o=t?V(t):null;return r&&r.replaceWith(o),o},Pr=()=>t=>{t&&t.remove()},Ir=(t=void 0,e=void 0)=>t===void 0||e===void 0?Pr():typeof t=="string"||typeof e=="string"?pe(e,t):t.tagName!==e.tagName?pe(e):e.tagName==="select"?It.select(t,e):["pre","code"].includes(e.tagName)?pe(e,t):i=>(ee(t.attributes,e.attributes)(i),te(t.children,e.children)(i),i),re=Ir;var Nr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("processQueue.getQueue",e)}},z=(t="",e=null)=>{try{S()||(Nr(t)||{}).process(e)}catch(r){n("processQueue",r)}};var Nt=(t="",e=null)=>{let r=R(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var Vt=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Ut=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(u(i)&&i.attributes&&i.attributes["js-i"]&&i.attributes["js-i"]===e){t.children[o]=r;break}u(i)&&Ut(i,e,r)}},qt=Ut;var Ht=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...i]=e.split(" ");return{type:o.toLowerCase(),selector:i.join(" "),handler:r}})}catch(e){n("component.events.serialize",e)}};var zt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Ht(t?.events):[];for(let i=0;i<o?.length;i+=1){let s=o[i];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<i?.length;s+=1){let c=i[s];zt(c,e,r)}}return r}catch(o){n("component.eve!nts.registerListenersFix.getListeners",o)}},Vr=(t={},e={})=>{try{let o=zt(t,e,[])?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:c=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:c,elementSelector:a,type:m,handler:y}=o[i];c.addEventListener(m,y),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:m,handler:y}]}}catch(r){n("component.events.registerListenersFix",r)}},Zt=Vr;var Bt=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Bt(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},Ur=(t={})=>{try{let e=Bt(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:c}=e[r];i.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Gt=Ur;var Kt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},ve(e),mt(this,e),this.data=gt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Q(e,r,o,i);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=H(this.DOMNode);this.dom.virtual=r}let e=this.parent?R(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!S())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return jt(this,e);let r=this.onBeforeRender();Gt(this),Nt(this.instanceId);let o=N(this,{}),i=re(this.dom.virtual,o.virtual);i&&l(i)&&z("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,Zt(this,this.renderMethods),this.setDOMNodeOnInstance(),z("domNodes",()=>{z("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return X(this,e)}onAfterRender(e={},r={}){S()||(Vt(e.instanceId,this),window.joystick._internal.css.update(),z("lifecycle.onUpdateProps"),r?.afterSetStateRender&&l(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&l(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=G(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&l(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[U()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[U()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=R(window.joystick._internal.tree,this.instanceId,"instanceId"),i=R(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=H(i?.instance?.DOMNode);qt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},rd=Kt;export{rd as default};
|
|
21
|
+
`}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var sr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!_(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},G=(t={},e={})=>{try{return l(e)?sr(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var ie={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var at=(t={},e={})=>{try{return e?Object.entries({...ie,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ie}catch(r){n("component.lifecycle.compile",r)}};var K=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{n("component.methods.compile")}};var ne=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>C(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){n("component.url.compile",e)}};var S=()=>typeof window=="undefined";var P=null,W=0,dt=(t={},e=null)=>{try{let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);P&&(clearInterval(P),P=null);let i={client:o,send:(s={})=>o.send(JSON.stringify(s))};return o.addEventListener("open",()=>{t?.options?.logging&&console.log(`[joystick.websockets] Connected to ${t?.url}`),t?.events?.onOpen&&t.events.onOpen(i),W=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&t.events.onMessage(JSON.parse(s.data||{}),i)}),o.addEventListener("close",s=>{t?.options?.logging&&console.log(`[joystick.websockets] Disconnected from ${t?.url}`),t?.events?.onClose&&t.events.onClose(s?.code,s?.reason,i),o=null;let c=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!P&&!c&&(P=setInterval(()=>{o=null,W<(t?.options?.reconnectAttempts||12)?(dt(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${W+1}/12)...`),W+=1):clearInterval(P)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},ct=dt;var ar=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!_(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},lt=(t={},e={})=>{try{return l(e)?ar(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var mt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=U(8),t.ssrId=e?._ssrId||null,t.css=st(),t.data=B(e?.dataFromSSR,e?._componentId),t.defaultProps=lt(t,e?.defaultProps),t.props=nt(t?.defaultProps,e?.props),t.state=G(t,e?.state),t.events=e?.events||{},t.lifecycle=at(t,e?.lifecycle),t.methods=K(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=it,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=ne(e?.url)),r&&window.__joystick_url__&&(t.url=ne(window.__joystick_url__)),r&&e?.websockets&&l(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[c,a]=i[s];ct({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(m={})=>{t.websockets={...t.websockets||{},[c]:m}})}}}catch(r){n("component.registerOptions",r)}};var I=(t="",e=[])=>{try{console.error(`${t} failed with the following errors:`),e.forEach(r=>{console.log(r.message),r.stack&&console.log(r.stack)})}catch(r){n(t,r)}};var J=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var pt=(t={})=>Object.entries(t).map(([e,r])=>`${e}=${r}`)?.join("; ");var dr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.get.handleParseResponse",e)}},ut=(t="",e={})=>{try{return typeof window.fetch!="undefined"&&!e?.skip?new Promise((r,o)=>{let i=e.input?JSON.stringify(e.input):null,s=e.output?JSON.stringify(e.output):null,c=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content"),m={...e?.headers||{},"x-joystick-csrf":a};return window?.__joystick_test__&&(m.Cookie=pt({joystickLoginToken:window.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expires_at__})),fetch(c,{method:"GET",mode:"cors",headers:m,credentials:"include"}).then(async y=>{let w=await dr(y);return w?.errors?(I("get request",w.errors),o(w)):r(w)}).catch(y=>(I("get request",[y]),o({errors:[y]})))}):Promise.resolve()}catch(r){n("get request",r)}};var cr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.set.handleParseResponse",e)}},lr=(t={})=>{try{return JSON.stringify(t)}catch(e){n("api.set.getBody",e)}},ft=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=lr(e),c=document.querySelector('[name="csrf"]')?.getAttribute("content"),a={...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":c};return window?.__joystick_test__&&(a.Cookie=generateCookieHeader({joystickLoginToken:window?.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expirs_at__})),fetch(i,{method:"POST",mode:"cors",headers:a,body:s,credentials:"include"}).then(async m=>{let y=await cr(m);return y?.errors?(I("set request",y.errors),o(y)):r(y)}).catch(m=>(I("set request",[m]),o({errors:[m]})))}):Promise.resolve()}catch(r){n("set request",r)}};var ht={get:ut,set:ft};var mr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("addToQueue.getQueue",e)}},q=(t="",e=null)=>{try{S()||(mr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Q=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&l(o.options.data)){let i=await o.options.data(t,e,r,o);return Promise.resolve(i)}return Promise.resolve()}catch(i){n("component.data.fetch",i)}};var wt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let i=await Q(ht,e,o,r);return r.data=wt(i,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=i),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){n("component.data.compile",o)}},yt=wt;var gt=(t={})=>{try{if(!S()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return yt(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var Ft=ir(xt());var bt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(u(t)&&o){let i=Object.keys(t);for(let s=0;s<i.length;s+=1){let c=i[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let m=0;m<a.length;m+=1){let y=a[m],w=bt(y,e,r);if(w!==null)return w}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},R=bt;var $t=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var pr=(t={},e={},r=null)=>{try{let o=N(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){n("component.renderMethods.component.renderForClient",o)}},ur=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){n("component.renderMethods.component.renderToHTMLForSSR",e)}},fr=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){n("component.renderMethods.component.collectDataFunctionsForSSR",e)}},hr=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};$t(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){n("component.renderMethods.component.handleAddComponentToParent",e)}},wr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&q("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&q("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},yr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Ft.diff)(e?.existingPropsMap,r)?.length>0&&q("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t)})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},gr=function(){return function(e=null,r={},o={}){let i=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[i.id]||{},c=o.children[i.id]||[],a=s[c?.length];return i.state=a?.state||i.state,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,yr(i,o,r),q("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),wr(this,i),i.parent&&hr(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?fr(i):i.parent&&i.parent.ssrTree?ur(i):pr(i,this,a?.children)}},xr=function(e,r){try{let o=this;return new gr().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},se=xr;var br=function(e=[],r=null){try{return l(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},ae=br;var $r=(t="",e=[])=>{try{return e.reduce((r,[o,i])=>r.replace(`{{${o}}}`,i),t)}catch(r){n("component.renderMethods.i18n.replacePlaceholdersInString",r)}},de=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),i=typeof t=="object"&&!o;if(r)return $r(t,e);if(o)return t?.map(s=>de(s,e));if(i)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=de(a,e),s),{})}catch(r){n("component.renderMethods.i18n.handleTranslationReplacement",r)}},Fr=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>(console.log({key:t,objectToTraverse:r,keyToMatch:o}),r[o]),e)}catch(r){n("component.renderMethods.i18n.getTranslationAtPath",r)}},Er=function(t="",e={}){try{let r=S()?this.translations:window.__joystick_i18n__,i=t?.includes(".")?Fr(t,r):r[t];if(t?.includes("creatorDashboard")&&console.log({key:t,replacements:e,translation:i,translations:r}),!r||!i)return"";let s=Object.entries(e);return de(i,s)}catch(r){n("component.renderMethods.i18n",r)}},ce=Er;var Mr=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},le=Mr;var Et={c:se,component:se,e:ae,each:ae,i:ce,i18n:ce,w:le,when:le};var Mt=(t={},e={})=>{try{return Object.entries(Et).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var kt=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,children:kt(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},St=(t={})=>{try{return kt(t)}catch(e){n("component.render.getExistingStateMap",e)}};var Ot=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),kr=new RegExp(/\n/g);var Sr=(t="")=>{try{return(t.match(Ot)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},Tt=(t="")=>{try{let e=`${t}`;return e=Sr(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var vt=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:i=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${i}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Ct=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,c]=o[i];for(let a=0;a<c?.length;a+=1){let m=c[a];Object.entries(m?.timers)?.length>0&&r.push(...Object.values(m?.timers)),Object.entries(m?.children)?.length>0&&Ct(m?.children,r)}}if(r?.length>0)for(let i=0;i<r?.length;i+=1)clearTimeout(r[i])}catch(r){n("component.render.clearTimersOnChildren",r)}},Rt=Ct;var X=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=B(e.dataFromSSR,t.id)||{}),Rt(t?.children);let r=St(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Mt({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=K(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=Tt(o),s=vt(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Or=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},At=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?At(e):me(e)):me(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},me=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Or(t.attributes),children:[].flatMap.call(t.childNodes,o=>At(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},H=me;var Tr=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},Lt=(t="")=>{try{let e=Tr(t);return H(e)}catch(e){n("component.virtualDOM.build",e)}};var Dt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var vr=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[i,s]=r[o];Dt(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=_t(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},_t=(t=null)=>{try{return C(t)?document.createTextNode(t):vr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},V=_t;var N=(t={},e={})=>{try{let r=X(t,{existingChildren:e?.existingChildren}),o=Lt(r.wrapped,t),i=e.includeActual&&o?V(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var jt=(t={},e={})=>{try{let r=N(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Cr=(t={},e={})=>{let r=[];for(let[o,i]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,i),s));for(let o in t)o in e||r.push(i=>(i&&i.removeAttribute&&i.removeAttribute(o),i));return o=>{for(let i of r)i&&typeof i=="function"&&i(o)}},ee=Cr;var Rr=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],c=e[i];r.push([s,c])}return r},Pt=Rr;var Ar=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Lr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},Dr=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=c=>{let a=V(i);return c.appendChild(a),c};r.push(s)}),r},_r=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=re(o,e[i]);r.push(s)}),r},jr=(t=[],e=[])=>{let r=_r(t,e),o=Dr(t,e);return i=>{if(i){let s=Pt(r,i.childNodes);Lr(s),Ar(o,i)}return i}},te=jr;var It={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ee(t.attributes,e.attributes)(r),te([],e.children)(r);let i=r.querySelector(`option[value="${o}"]`);if(i&&(r.value=o),!i){let s=r.querySelector("option");r.value=s?.value||""}return r}};var pe=(t,e)=>r=>{let o=t?V(t):null;return r&&r.replaceWith(o),o},Pr=()=>t=>{t&&t.remove()},Ir=(t=void 0,e=void 0)=>t===void 0||e===void 0?Pr():typeof t=="string"||typeof e=="string"?pe(e,t):t.tagName!==e.tagName?pe(e):e.tagName==="select"?It.select(t,e):["pre","code"].includes(e.tagName)?pe(e,t):i=>(ee(t.attributes,e.attributes)(i),te(t.children,e.children)(i),i),re=Ir;var Nr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("processQueue.getQueue",e)}},z=(t="",e=null)=>{try{S()||(Nr(t)||{}).process(e)}catch(r){n("processQueue",r)}};var Nt=(t="",e=null)=>{let r=R(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var Vt=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Ut=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(u(i)&&i.attributes&&i.attributes["js-i"]&&i.attributes["js-i"]===e){t.children[o]=r;break}u(i)&&Ut(i,e,r)}},qt=Ut;var Ht=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...i]=e.split(" ");return{type:o.toLowerCase(),selector:i.join(" "),handler:r}})}catch(e){n("component.events.serialize",e)}};var zt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Ht(t?.events):[];for(let i=0;i<o?.length;i+=1){let s=o[i];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<i?.length;s+=1){let c=i[s];zt(c,e,r)}}return r}catch(o){n("component.eve!nts.registerListenersFix.getListeners",o)}},Vr=(t={},e={})=>{try{let o=zt(t,e,[])?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:c=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:c,elementSelector:a,type:m,handler:y}=o[i];c.addEventListener(m,y),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:m,handler:y}]}}catch(r){n("component.events.registerListenersFix",r)}},Zt=Vr;var Bt=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Bt(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},Ur=(t={})=>{try{let e=Bt(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:c}=e[r];i.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Gt=Ur;var Kt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},ve(e),mt(this,e),this.data=gt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Q(e,r,o,i);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=H(this.DOMNode);this.dom.virtual=r}let e=this.parent?R(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!S())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return jt(this,e);let r=this.onBeforeRender();Gt(this),Nt(this.instanceId);let o=N(this,{}),i=re(this.dom.virtual,o.virtual);i&&l(i)&&z("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,Zt(this,this.renderMethods),this.setDOMNodeOnInstance(),z("domNodes",()=>{z("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return console.log("RENDER TO HTML",e),X(this,e)}onAfterRender(e={},r={}){S()||(Vt(e.instanceId,this),window.joystick._internal.css.update(),z("lifecycle.onUpdateProps"),r?.afterSetStateRender&&l(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&l(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=G(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&l(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[U()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[U()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=R(window.joystick._internal.tree,this.instanceId,"instanceId"),i=R(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=H(i?.instance?.DOMNode);qt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},rd=Kt;export{rd as default};
|
package/dist/component/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var Qt=Object.create;var oe=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty;var rr=t=>oe(t,"__esModule",{value:!0});var or=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ir=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Xt(e))!tr.call(t,o)&&o!=="default"&&oe(t,o,{get:()=>e[o],enumerable:!(r=Yt(e,o))||r.enumerable});return t},nr=t=>ir(rr(oe(t!=null?Qt(er(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var gt=or(Y=>{(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof Y!="undefined")e(Y);else{var r={exports:{}};e(r.exports),t.index=r.exports}})(Y,function(t){"use strict";function e(m){return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e(m)}function r(m,d){return d&&(e(d)==="object"||typeof d=="function")?d:o(m)}function o(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function i(m){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},i(m)}function s(m,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");m.prototype=Object.create(d&&d.prototype,{constructor:{value:m,writable:!0,configurable:!0}}),d&&c(m,d)}function c(m,d){return c=Object.setPrototypeOf||function(b,O){return b.__proto__=O,b},c(m,d)}function a(m,d){if(!(m instanceof d))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.diff=void 0;var p=function m(d,b){a(this,m),this.type=d,this.path=b?b.toString():""},y=function(m){function d(b,O,h){var A;return a(this,d),A=r(this,i(d).call(this,"E",b)),A.lhs=O,A.rhs=h,A}return s(d,m),d}(p),w=function(m){function d(b,O,h,A){var $;return a(this,d),$=r(this,i(d).call(this,"M",b)),$.item=O,$.lhsIndex=h,$.rhsIndex=A,$}return s(d,m),d}(p),x=function(m){function d(b,O){var h;return a(this,d),h=r(this,i(d).call(this,"D",b)),h.lhs=O,h}return s(d,m),d}(p),v=function(m){function d(b,O){var h;return a(this,d),h=r(this,i(d).call(this,"A",b)),h.rhs=O,h}return s(d,m),d}(p),f=function(m,d){return m?"".concat(m,".").concat(d):d};t.diff=function(d,b){var O=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},h=[],A=O.matchKey,$=O.types||["E","A","D","M"],Jt=function(F,g,E,D){F.forEach(function(L,k){var T=g.findIndex(function(M){return M[D]===L[D]});-1<T?(-1<$.indexOf("M")&&k!==T&&h.push(new w(E,L,k,T)),Z(L,g[T],f(E,T))):-1<$.indexOf("D")&&h.push(new x(E,L))}),g.forEach(function(L,k){var T=F.findIndex(function(M){return L[D]===M[D]});-1<$.indexOf("A")&&T===-1&&h.push(new v(f(E,k),L))})},Z=function(F,g,E){var D=Object.prototype.toString.call(F),L=Object.prototype.toString.call(g);if(-1<$.indexOf("E")&&D!==L)return h.push(new y(E,F,g)),!1;if(D==="[object Object]")Object.getOwnPropertyNames(F).forEach(function(M){Object.prototype.hasOwnProperty.call(g,M)?Z(F[M],g[M],f(E,M)):-1<$.indexOf("D")&&h.push(new x(f(E,M),F[M]))}),Object.getOwnPropertyNames(g).forEach(function(M){-1<$.indexOf("A")&&!Object.prototype.hasOwnProperty.call(F,M)&&h.push(new v(f(E,M),g[M]))});else if(D!=="[object Array]")-1<$.indexOf("E")&&F!==g&&h.push(new y(E,F,g));else if(A)Jt(F,g,E,A);else{var k=F.length-1,T=g.length-1;if(-1<$.indexOf("D"))for(;k>T;)h.push(new x(f(E,k),F[k--]));if(-1<$.indexOf("A"))for(;T>k;)h.push(new v(f(E,T),g[T--]));for(;0<=k;--k)Z(F[k],g[k],f(E,k))}};return Z(d,b),h}})});var n=(t="",e={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${e.message||e.reason||e}`)};var ue=["render"];var fe=(t={})=>{try{return ue.every(e=>Object.keys(t).includes(e))}catch(e){n("component.hasAllRequiredOptions",e)}};var he=["_componentId","_ssrId","api","dataFromSSR","existingProps","existingState","instanceId","parent","req","css","data","defaultProps","events","id","lifecycle","methods","name","props","render","state","translations","url","websockets","wrapper"];var we=t=>{try{return typeof t=="undefined"}catch(e){n("types.isUndefined",e)}},ye=t=>{try{return t===null}catch(e){n("types.isNull",e)}};var _=t=>{try{return!!Array.isArray(t)}catch(e){n("types.isArray",e)}};var l=t=>{try{return typeof t=="function"}catch(e){n("types.isFunction",e)}};var u=t=>{try{return!!(t&&typeof t=="object"&&!Array.isArray(t))}catch(e){n("types.isObject",e)}};var C=t=>{try{return typeof t=="string"}catch(e){n("types.isString",e)}};var xe=(t=null)=>{try{!C(t)&&!l(t)&&!u(t)&&n("component.optionValidators.css","options.css must be a string, function returning a string, or an object returning breakpoints.")}catch(e){n("component.optionValidators.css",e)}};var ge=["readystatechange","pointerlockchange","pointerlockerror","beforecopy","beforecut","beforepaste","freeze","resume","search","securitypolicyviolation","visibilitychange","fullscreenchange","fullscreenerror","webkitfullscreenchange","webkitfullscreenerror","beforexrselect","abort","blur","cancel","canplay","canplaythrough","change","click","close","contextmenu","cuechange","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","formdata","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","pause","play","playing","progress","ratechange","reset","resize","scroll","seeked","seeking","select","stalled","submit","suspend","timeupdate","toggle","volumechange","waiting","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend","wheel","auxclick","gotpointercapture","lostpointercapture","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerout","pointerenter","pointerleave","selectstart","selectionchange","animationend","animationiteration","animationstart","transitionrun","transitionstart","transitionend","transitioncancel","copy","cut","paste","pointerrawupdate"];var be=(t=null)=>{try{u(t)||n("component.optionValidators.events","options.events must be an object.");for(let e of Object.keys(t)){let[r]=e.split(" ");ge.includes(r)||n("component.optionValidators.events",`${r} is not a supported JavaScript event type.`)}for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.events",`options.events.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.events",e)}};var $e=["onBeforeMount","onMount","onUpdateProps","onBeforeUnmount","onRefetchData"];var Fe=(t=null)=>{try{u(t)||n("component.optionValidators.lifecycle","options.lifecycle must be an object.");for(let[e,r]of Object.entries(t))$e.includes(e)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} is not supported.`),l(r)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.lifecycle",e)}};var Ee=(t=null)=>{try{u(t)||n("component.optionValidators.methods","options.methods must be an object.");for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.methods",`options.methods.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.methods",e)}};var ke=(t=null)=>{typeof t!="string"&&n("component.optionValidators.name","options.name must be a string.")};var Me=(t=null)=>{try{l(t)||n("component.optionValidators.render","options.render must be a function returning a string.")}catch(e){n("component.optionValidators.render",e)}};var Se=(t=null)=>{try{l(t)||n("component.optionValidators.websockets","options.websockets must be a function returning an object.")}catch(e){n("component.optionValidators.websockets",e)}};var Oe=(t=null)=>{try{u(t)||n("component.optionValidators.wrapper","options.wrapper must be an object.");for(let[e,r]of Object.entries(t))e==="id"&&!C(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned a string.`),e==="classList"&&!_(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned an array of strings.`)}catch(e){n("component.optionValidators.wrapper",e)}};var Te={css:xe,events:be,lifecycle:Fe,methods:Ee,name:ke,render:Me,websockets:Se,wrapper:Oe};var ve=(t={})=>{try{fe(t)||n("component.validateOptions",`component options must include ${required.options.join(",")}.`);for(let[e,r]of Object.entries(t)){he.includes(e)||n("component.validateOptions",`${e} is not supported by joystick.component.`);let o=Te[e];o&&l(o)&&o(r)}}catch(e){n("component.validateOptions",e)}};var Ce="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),U=(t=16)=>{let e="",r=0;for(;r<t;)e+=Ce[Math.floor(Math.random()*(Ce.length-1))],r+=1;return e};var B=(t=[],e="")=>{try{return(_(t)&&t.find(o=>o?.componentId===e))?.data||{}}catch(r){n("findComponentDataFromSSR",r)}};var Re=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var j=t=>!!(t&&typeof t=="object"&&!Array.isArray(t));var Ae=t=>typeof t=="string";var Le=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,De=(t,e="")=>{if(!e)return!0;if(e&&!Ae(e))return!1;let r=e?e.replace(/[- ]+/g,""):"";return t===!0?r.match(new RegExp(Le)):!r.match(new RegExp(Le))};var _e=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))$/,je=(t,e="")=>t===!0?!!e.match(_e):!e.match(_e);var Pe=(t,e="")=>t===e;var Ie=(t,e="")=>t===e;var Ne=(t,e="")=>e.length<=t;var Ve=(t,e="")=>e.length>=t;var Ue=/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/,qe=(t,e="")=>t===!0?!!e.match(Ue):!e.match(Ue);var He={AF:/^\d{4}$/,AX:/^\d{5}$/,AL:/^\d{4}$/,DZ:/^\d{5}$/,AS:/^\d{5}(-{1}\d{4,6})$/,AD:/^[Aa][Dd]\d{3}$/,AI:/^[Aa][I][-][2][6][4][0]$/,AR:/^\d{4}|[A-Za-z]\d{4}[a-zA-Z]{3}$/,AM:/^\d{4}$/,AC:/^[Aa][Ss][Cc][Nn]\s{0,1}[1][Zz][Zz]$/,AU:/^\d{4}$/,AT:/^\d{4}$/,AZ:/^[Aa][Zz]\d{4}$/,BH:/^\d{3,4}$/,BD:/^\d{4}$/,BB:/^[Aa][Zz]\d{5}$/,BY:/^\d{6}$/,BE:/^\d{4}$/,BM:/^[A-Za-z]{2}\s([A-Za-z]{2}|\d{2})$/,BT:/^\d{5}$/,BO:/^\d{4}$/,BA:/^\d{5}$/,BR:/^\d{5}-\d{3}$/,"":/^[Bb][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,IO:/^[Bb]{2}[Nn][Dd]\s{0,1}[1][Zz]{2}$/,VG:/^[Vv][Gg]\d{4}$/,BN:/^[A-Za-z]{2}\d{4}$/,BG:/^\d{4}$/,KH:/^\d{5}$/,CA:/^(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\d(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\s{0,1}\d(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\d$/,CV:/^\d{4}$/,KY:/^[Kk][Yy]\d[-\s]{0,1}\d{4}$/,TD:/^\d{5}$/,CL:/^\d{7}\s\(\d{3}-\d{4}\)$/,CN:/^\d{6}$/,CX:/^\d{4}$/,CC:/^\d{4}$/,CO:/^\d{6}$/,CD:/^[Cc][Dd]$/,CR:/^\d{4,5}$/,HR:/^\d{5}$/,CU:/^\d{5}$/,CY:/^\d{4}$/,CZ:/^\d{5}\s\(\d{3}\s\d{2}\)$/,DK:/^\d{4}$/,DO:/^\d{5}$/,EC:/^\d{6}$/,SV:/^1101$/,EG:/^\d{5}$/,EE:/^\d{5}$/,ET:/^\d{4}$/,FK:/^[Ff][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,FO:/^\d{3}$/,FI:/^\d{5}$/,FR:/^\d{5}$/,GF:/^973\d{2}$/,PF:/^987\d{2}$/,GA:/^\d{2}\s[a-zA-Z-_ ]\s\d{2}$/,GE:/^\d{4}$/,DE:/^\d{2}$/,GI:/^[Gg][Xx][1]{2}\s{0,1}[1][Aa]{2}$/,GR:/^\d{3}\s{0,1}\d{2}$/,GL:/^\d{4}$/,GP:/^971\d{2}$/,GU:/^\d{5}$/,GT:/^\d{5}$/,GG:/^[A-Za-z]{2}\d\s{0,1}\d[A-Za-z]{2}$/,GW:/^\d{4}$/,HT:/^\d{4}$/,HM:/^\d{4}$/,HN:/^\d{5}$/,HU:/^\d{4}$/,IS:/^\d{3}$/,IN:/^\d{6}$/,ID:/^\d{5}$/,IR:/^\d{5}-\d{5}$/,IQ:/^\d{5}$/,IM:/^[Ii[Mm]\d{1,2}\s\d\[A-Z]{2}$/,IL:/^\b\d{5}(\d{2})?$/,IT:/^\d{5}$/,JM:/^\d{2}$/,JP:/^\d{7}\s\(\d{3}-\d{4}\)$/,JE:/^[Jj][Ee]\d\s{0,1}\d[A-Za-z]{2}$/,JO:/^\d{5}$/,KZ:/^\d{6}$/,KE:/^\d{5}$/,KR:/^\d{6}\s\(\d{3}-\d{3}\)$/,XK:/^\d{5}$/,KW:/^\d{5}$/,KG:/^\d{6}$/,LV:/^[Ll][Vv][- ]{0,1}\d{4}$/,LA:/^\d{5}$/,LB:/^\d{4}\s{0,1}\d{4}$/,LS:/^\d{3}$/,LR:/^\d{4}$/,LY:/^\d{5}$/,LI:/^\d{4}$/,LT:/^[Ll][Tt][- ]{0,1}\d{5}$/,LU:/^\d{4}$/,MK:/^\d{4}$/,MG:/^\d{3}$/,MV:/^\d{4,5}$/,MY:/^\d{5}$/,MT:/^[A-Za-z]{3}\s{0,1}\d{4}$/,MH:/^\d{5}$/,MQ:/^972\d{2}$/,YT:/^976\d{2}$/,FM:/^\d{5}(-{1}\d{4})$/,MX:/^\d{5}$/,MD:/^[Mm][Dd][- ]{0,1}\d{4}$/,MC:/^980\d{2}$/,MN:/^\d{5}$/,ME:/^\d{5}$/,MS:/^[Mm][Ss][Rr]\s{0,1}\d{4}$/,MA:/^\d{5}$/,MZ:/^\d{4}$/,MM:/^\d{5}$/,NA:/^\d{5}$/,NP:/^\d{5}$/,NL:/^\d{4}\s{0,1}[A-Za-z]{2}$/,NC:/^988\d{2}$/,NZ:/^\d{4}$/,NI:/^\d{5}$/,NE:/^\d{4}$/,NG:/^\d{6}$/,NF:/^\d{4}$/,MP:/^\d{5}$/,NO:/^\d{4}$/,OM:/^\d{3}$/,PK:/^\d{5}$/,PW:/^\d{5}$/,PA:/^\d{6}$/,PG:/^\d{3}$/,PY:/^\d{4}$/,PE:/^\d{5}$/,PH:/^\d{4}$/,PN:/^[Pp][Cc][Rr][Nn]\s{0,1}[1][Zz]{2}$/,PL:/^\d{2}[- ]{0,1}\d{3}$/,PT:/^\d{4}$/,PR:/^\d{5}$/,RE:/^974\d{2}$/,RO:/^\d{6}$/,RU:/^\d{6}$/,BL:/^97133$/,SH:/^[Ss][Tt][Hh][Ll]\s{0,1}[1][Zz]{2}$/,MF:/^97150$/,PM:/^97500$/,VC:/^[Vv][Cc]\d{4}$/,SM:/^4789\d$/,SA:/^\d{5}(-{1}\d{4})?$/,SN:/^\d{5}$/,RS:/^\d{5}$/,SG:/^\d{2}$/,SK:/^\d{5}\s\(\d{3}\s\d{2}\)$/,SI:/^([Ss][Ii][- ]{0,1}){0,1}\d{4}$/,ZA:/^\d{4}$/,GS:/^[Ss][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,ES:/^\d{5}$/,LK:/^\d{5}$/,SD:/^\d{5}$/,SZ:/^[A-Za-z]\d{3}$/,SE:/^\d{3}\s*\d{2}$/,CH:/^\d{4}$/,SJ:/^\d{4}$/,TW:/^\d{5}$/,TJ:/^\d{6}$/,TH:/^\d{5}$/,TT:/^\d{6}$/,TN:/^\d{4}$/,TR:/^\d{5}$/,TM:/^\d{6}$/,TC:/^[Tt][Kk][Cc][Aa]\s{0,1}[1][Zz]{2}$/,UA:/^\d{5}$/,GB:/^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-[CIKMOV]]{2}/,US:/^\b\d{5}\b(?:[- ]{1}\d{4})?$/,UY:/^\d{5}$/,VI:/^\d{5}$/,UZ:/^\d{3} \d{3}$/,VA:/^120$/,VE:/^\d{4}(\s[a-zA-Z]{1})?$/,VN:/^\d{6}$/,WF:/^986\d{2}$/,ZM:/^\d{5}$/},ze=(t,e="")=>{let r=j(t)&&t.iso?He[t.iso||"US"]:He.US;return j(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var Ze=(t,e="",r={isChecked:!1})=>{if(!r.isChecked)return t===!0?e&&e.trim()!=="":e&&e.trim()==="";if(r.isChecked)return t===!0?e:!e};var Be=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,Ge=(t,e="")=>t===!0?!!e.match(Be):!e.match(Be);var Ke=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,We=(t,e="")=>t===!0?!!e.match(Ke):!e.match(Ke);var Je=/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/,Qe=(t,e="")=>t===!0?!!e.match(Je):!e.match(Je);var Ye=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,Xe=(t,e="")=>t===!0?!!e.match(Ye):!e.match(Ye);var et={AT:/^(AT)(U\d{8}$)/i,BE:/^(BE)(\d{10}$)/i,BG:/^(BG)(\d{9,10}$)/i,CY:/^(CY)([0-5|9]\d{7}[A-Z]$)/i,CZ:/^(CZ)(\d{8,10})?$/i,DE:/^(DE)([1-9]\d{8}$)/i,DK:/^(DK)(\d{8}$)/i,EE:/^(EE)(10\d{7}$)/i,EL:/^(EL)(\d{9}$)/i,ES:/^(ES)([0-9A-Z][0-9]{7}[0-9A-Z]$)/i,EU:/^(EU)(\d{9}$)/i,FI:/^(FI)(\d{8}$)/i,FR:/^(FR)([0-9A-Z]{2}[0-9]{9}$)/i,GB:/^(GB)((?:[0-9]{12}|[0-9]{9}|(?:GD|HA)[0-9]{3})$)/i,GR:/^(GR)(\d{8,9}$)/i,HR:/^(HR)(\d{11}$)/i,HU:/^(HU)(\d{8}$)/i,IE:/^(IE)([0-9A-Z\*\+]{7}[A-Z]{1,2}$)/i,IT:/^(IT)(\d{11}$)/i,LV:/^(LV)(\d{11}$)/i,LT:/^(LT)(\d{9}$|\d{12}$)/i,LU:/^(LU)(\d{8}$)/i,MT:/^(MT)([1-9]\d{7}$)/i,NL:/^(NL)(\d{9}B\d{2}$)/i,NO:/^(NO)(\d{9}$)/i,PL:/^(PL)(\d{10}$)/i,PT:/^(PT)(\d{9}$)/i,RO:/^(RO)([1-9]\d{1,9}$)/i,RU:/^(RU)(\d{10}$|\d{12}$)/i,RS:/^(RS)(\d{9}$)/i,SI:/^(SI)([1-9]\d{7}$)/i,SK:/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7}$)/i,SE:/^(SE)(\d{10}01$)/i},tt=(t,e="")=>{let r=j(t)&&t.iso?et[t.iso||"EU"]:et.EU;return j(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var rt={creditCard:De,email:je,equals:Pe,matches:Ie,maxLength:Ne,minLength:Ve,phone:qe,postalCode:ze,required:Ze,semVer:Ge,slug:We,strongPassword:Qe,url:Xe,vat:tt};var ot=class{constructor(e,r={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={required:()=>"This field is required.",email:()=>"Must be a valid email.",creditCard:()=>"Must be a valid credit card number.",equals:o=>`Value must equal ${o}.`,matches:o=>`Field must match ${o}.`,maxLength:o=>`Field value can be no greater than ${o}.`,minLength:o=>`Field value can be no less than ${o}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},e||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=e,this.setOptions(r),this.attachEventListeners()}setOptions(e={}){this.rules=e.rules||{},this.messages=e.messages||{},this.onSubmit=e.onSubmit,this.fields=this.serialize()}updateOptions(e={}){this.setOptions(e)}serialize(){if(this.form)return Object.keys(this.rules).map(r=>{let o=this.form.querySelector(`[name="${r}"]`),i=o?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(i),type:i,name:r,element:o,validations:Object.entries(this.rules[r]).map(([c,a])=>({name:c,rule:a,valid:!1})).sort((c,a)=>c.name>a.name?1:-1),errorMessages:this.messages[r]?Object.keys(this.messages[r]):{}}})}attachEventListeners(){if(this.form){let e=r=>{r.stopPropagation(),r.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let r=0;r<this.form.listeners.length;r+=1){let o=this.form.listeners[r];this.form.removeEventListener("submit",o)}this.form.addEventListener("submit",e),this.form.listeners=[...this.form.listeners||[],e]}this.fields.forEach(e=>{if(e?.element&&e?.listenForChanges){let r=()=>{Re(()=>{this.validate(e.name)},100)};e.element.removeEventListener("input",r),e.element.addEventListener("input",r),e.element.removeEventListener("change",r),e.element.addEventListener("change",r)}})}validate(e=null){if(e){this.clearExistingErrors();let r=this.fields.find(o=>o.name===e);return this.validateField(r),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(r=>{this.validateField(r)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(r=>r.validations.some(o=>!o.valid)).includes(!0)}validateField(e){let r=this.form.querySelector(`[name="${e.name}"]`),o=["checkbox","radio"].includes(e.type),i=o?null:e?.element?.value?.trim(),s=o?e?.element?.checked:null;e.validations.forEach(a=>{if(this.isValidValue(o,o?s:i,a))this.markValidationAsValid(e,a.name);else{let p=this.messages[e.name]&&this.messages[e.name][a.name];this.markValidationAsInvalid(e,a.name),this.renderError(e.element,p||this.defaultValidationErrors[a.name](a.rule,i))}});let c=e.validations.some(a=>!a.valid);return c&&(r.classList.add("error"),r.focus()),c||(r.classList.remove("error"),this.clearExistingError(e.name)),!c}markValidationAsInvalid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!1}markValidationAsValid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!0}isValidValue(e,r,o){let i=rt[o.name];return i?i(o.rule,r,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.remove())}clearExistingError(e=""){let r=document.getElementById(`error-${e}`);r&&r.remove()}renderError(e,r=""){if(e){this.clearExistingError(e.name);let o=document.createElement("p");o.classList.add("input-hint"),o.classList.add("error"),o.setAttribute("id",`error-${e.name}`),o.innerText=r,e.after(o)}}},sr=(t,e)=>new Promise((r,o)=>{try{new ot(t,e).validate()?r():o()}catch(i){console.warn(i)}}),it=sr;var nt=(t={},e={})=>{try{return[...Object.keys(e),...Object.keys(t)].filter((o,i,s)=>s.indexOf(o)===i).reduce((o,i)=>{let s=e[i],c=t[i]||null,a=!we(s)&&!ye(s);return o[i]=a?s:c,o},{})}catch(r){n("component.props.compile",r)}};var st=(t="",e={})=>{try{let r="";if(t&&C(t))return r=t,r;if(t&&l(t))return r=t(e),r;if(t&&u(t)){let o=t?.print&&(C(t?.print)||l(t?.print)),i=t?.min&&u(t?.min),s=t?.min?.width&&u(t?.min?.width),c=t?.min?.height&&u(t?.min?.height),a=t?.max&&u(t?.max),p=t?.max?.width&&u(t?.max?.width),y=t?.max?.height&&u(t?.max?.height);if(o&&(r+=`
|
|
1
|
+
var Qt=Object.create;var oe=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty;var rr=t=>oe(t,"__esModule",{value:!0});var or=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ir=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Xt(e))!tr.call(t,o)&&o!=="default"&&oe(t,o,{get:()=>e[o],enumerable:!(r=Yt(e,o))||r.enumerable});return t},nr=t=>ir(rr(oe(t!=null?Qt(er(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var xt=or(Y=>{(function(t,e){if(typeof define=="function"&&define.amd)define(["exports"],e);else if(typeof Y!="undefined")e(Y);else{var r={exports:{}};e(r.exports),t.index=r.exports}})(Y,function(t){"use strict";function e(p){return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e(p)}function r(p,d){return d&&(e(d)==="object"||typeof d=="function")?d:o(p)}function o(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function i(p){return i=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)},i(p)}function s(p,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(d&&d.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),d&&c(p,d)}function c(p,d){return c=Object.setPrototypeOf||function(b,O){return b.__proto__=O,b},c(p,d)}function a(p,d){if(!(p instanceof d))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.diff=void 0;var m=function p(d,b){a(this,p),this.type=d,this.path=b?b.toString():""},y=function(p){function d(b,O,h){var A;return a(this,d),A=r(this,i(d).call(this,"E",b)),A.lhs=O,A.rhs=h,A}return s(d,p),d}(m),w=function(p){function d(b,O,h,A){var $;return a(this,d),$=r(this,i(d).call(this,"M",b)),$.item=O,$.lhsIndex=h,$.rhsIndex=A,$}return s(d,p),d}(m),g=function(p){function d(b,O){var h;return a(this,d),h=r(this,i(d).call(this,"D",b)),h.lhs=O,h}return s(d,p),d}(m),v=function(p){function d(b,O){var h;return a(this,d),h=r(this,i(d).call(this,"A",b)),h.rhs=O,h}return s(d,p),d}(m),f=function(p,d){return p?"".concat(p,".").concat(d):d};t.diff=function(d,b){var O=2<arguments.length&&arguments[2]!==void 0?arguments[2]:{},h=[],A=O.matchKey,$=O.types||["E","A","D","M"],Jt=function(F,x,E,D){F.forEach(function(L,M){var T=x.findIndex(function(k){return k[D]===L[D]});-1<T?(-1<$.indexOf("M")&&M!==T&&h.push(new w(E,L,M,T)),Z(L,x[T],f(E,T))):-1<$.indexOf("D")&&h.push(new g(E,L))}),x.forEach(function(L,M){var T=F.findIndex(function(k){return L[D]===k[D]});-1<$.indexOf("A")&&T===-1&&h.push(new v(f(E,M),L))})},Z=function(F,x,E){var D=Object.prototype.toString.call(F),L=Object.prototype.toString.call(x);if(-1<$.indexOf("E")&&D!==L)return h.push(new y(E,F,x)),!1;if(D==="[object Object]")Object.getOwnPropertyNames(F).forEach(function(k){Object.prototype.hasOwnProperty.call(x,k)?Z(F[k],x[k],f(E,k)):-1<$.indexOf("D")&&h.push(new g(f(E,k),F[k]))}),Object.getOwnPropertyNames(x).forEach(function(k){-1<$.indexOf("A")&&!Object.prototype.hasOwnProperty.call(F,k)&&h.push(new v(f(E,k),x[k]))});else if(D!=="[object Array]")-1<$.indexOf("E")&&F!==x&&h.push(new y(E,F,x));else if(A)Jt(F,x,E,A);else{var M=F.length-1,T=x.length-1;if(-1<$.indexOf("D"))for(;M>T;)h.push(new g(f(E,M),F[M--]));if(-1<$.indexOf("A"))for(;T>M;)h.push(new v(f(E,T),x[T--]));for(;0<=M;--M)Z(F[M],x[M],f(E,M))}};return Z(d,b),h}})});var n=(t="",e={})=>{throw new Error(`[joystick${t?`.${t}`:""}] ${e.message||e.reason||e}`)};var ue=["render"];var fe=(t={})=>{try{return ue.every(e=>Object.keys(t).includes(e))}catch(e){n("component.hasAllRequiredOptions",e)}};var he=["_componentId","_ssrId","api","dataFromSSR","existingProps","existingState","instanceId","parent","req","css","data","defaultProps","events","id","lifecycle","methods","name","props","render","state","translations","url","websockets","wrapper"];var we=t=>{try{return typeof t=="undefined"}catch(e){n("types.isUndefined",e)}},ye=t=>{try{return t===null}catch(e){n("types.isNull",e)}};var _=t=>{try{return!!Array.isArray(t)}catch(e){n("types.isArray",e)}};var l=t=>{try{return typeof t=="function"}catch(e){n("types.isFunction",e)}};var u=t=>{try{return!!(t&&typeof t=="object"&&!Array.isArray(t))}catch(e){n("types.isObject",e)}};var C=t=>{try{return typeof t=="string"}catch(e){n("types.isString",e)}};var ge=(t=null)=>{try{!C(t)&&!l(t)&&!u(t)&&n("component.optionValidators.css","options.css must be a string, function returning a string, or an object returning breakpoints.")}catch(e){n("component.optionValidators.css",e)}};var xe=["readystatechange","pointerlockchange","pointerlockerror","beforecopy","beforecut","beforepaste","freeze","resume","search","securitypolicyviolation","visibilitychange","fullscreenchange","fullscreenerror","webkitfullscreenchange","webkitfullscreenerror","beforexrselect","abort","blur","cancel","canplay","canplaythrough","change","click","close","contextmenu","cuechange","dblclick","drag","dragend","dragenter","dragleave","dragover","dragstart","drop","durationchange","emptied","ended","error","focus","formdata","input","invalid","keydown","keypress","keyup","load","loadeddata","loadedmetadata","loadstart","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","pause","play","playing","progress","ratechange","reset","resize","scroll","seeked","seeking","select","stalled","submit","suspend","timeupdate","toggle","volumechange","waiting","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend","wheel","auxclick","gotpointercapture","lostpointercapture","pointerdown","pointermove","pointerup","pointercancel","pointerover","pointerout","pointerenter","pointerleave","selectstart","selectionchange","animationend","animationiteration","animationstart","transitionrun","transitionstart","transitionend","transitioncancel","copy","cut","paste","pointerrawupdate"];var be=(t=null)=>{try{u(t)||n("component.optionValidators.events","options.events must be an object.");for(let e of Object.keys(t)){let[r]=e.split(" ");xe.includes(r)||n("component.optionValidators.events",`${r} is not a supported JavaScript event type.`)}for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.events",`options.events.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.events",e)}};var $e=["onBeforeMount","onMount","onUpdateProps","onBeforeUnmount","onRefetchData"];var Fe=(t=null)=>{try{u(t)||n("component.optionValidators.lifecycle","options.lifecycle must be an object.");for(let[e,r]of Object.entries(t))$e.includes(e)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} is not supported.`),l(r)||n("component.optionValidators.lifecycle",`options.lifecycle.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.lifecycle",e)}};var Ee=(t=null)=>{try{u(t)||n("component.optionValidators.methods","options.methods must be an object.");for(let[e,r]of Object.entries(t))l(r)||n("component.optionValidators.methods",`options.methods.${e} must be assigned a function.`)}catch(e){n("component.optionValidators.methods",e)}};var Me=(t=null)=>{typeof t!="string"&&n("component.optionValidators.name","options.name must be a string.")};var ke=(t=null)=>{try{l(t)||n("component.optionValidators.render","options.render must be a function returning a string.")}catch(e){n("component.optionValidators.render",e)}};var Se=(t=null)=>{try{l(t)||n("component.optionValidators.websockets","options.websockets must be a function returning an object.")}catch(e){n("component.optionValidators.websockets",e)}};var Oe=(t=null)=>{try{u(t)||n("component.optionValidators.wrapper","options.wrapper must be an object.");for(let[e,r]of Object.entries(t))e==="id"&&!C(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned a string.`),e==="classList"&&!_(r)&&n("component.optionValidators.wrapper",`options.wrapper.${e} must be assigned an array of strings.`)}catch(e){n("component.optionValidators.wrapper",e)}};var Te={css:ge,events:be,lifecycle:Fe,methods:Ee,name:Me,render:ke,websockets:Se,wrapper:Oe};var ve=(t={})=>{try{fe(t)||n("component.validateOptions",`component options must include ${required.options.join(",")}.`);for(let[e,r]of Object.entries(t)){he.includes(e)||n("component.validateOptions",`${e} is not supported by joystick.component.`);let o=Te[e];o&&l(o)&&o(r)}}catch(e){n("component.validateOptions",e)}};var Ce="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),U=(t=16)=>{let e="",r=0;for(;r<t;)e+=Ce[Math.floor(Math.random()*(Ce.length-1))],r+=1;return e};var B=(t=[],e="")=>{try{return(_(t)&&t.find(o=>o?.componentId===e))?.data||{}}catch(r){n("findComponentDataFromSSR",r)}};var Re=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var j=t=>!!(t&&typeof t=="object"&&!Array.isArray(t));var Ae=t=>typeof t=="string";var Le=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,De=(t,e="")=>{if(!e)return!0;if(e&&!Ae(e))return!1;let r=e?e.replace(/[- ]+/g,""):"";return t===!0?r.match(new RegExp(Le)):!r.match(new RegExp(Le))};var _e=/^((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))$/,je=(t,e="")=>t===!0?!!e.match(_e):!e.match(_e);var Pe=(t,e="")=>t===e;var Ie=(t,e="")=>t===e;var Ne=(t,e="")=>e.length<=t;var Ve=(t,e="")=>e.length>=t;var Ue=/^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/,qe=(t,e="")=>t===!0?!!e.match(Ue):!e.match(Ue);var He={AF:/^\d{4}$/,AX:/^\d{5}$/,AL:/^\d{4}$/,DZ:/^\d{5}$/,AS:/^\d{5}(-{1}\d{4,6})$/,AD:/^[Aa][Dd]\d{3}$/,AI:/^[Aa][I][-][2][6][4][0]$/,AR:/^\d{4}|[A-Za-z]\d{4}[a-zA-Z]{3}$/,AM:/^\d{4}$/,AC:/^[Aa][Ss][Cc][Nn]\s{0,1}[1][Zz][Zz]$/,AU:/^\d{4}$/,AT:/^\d{4}$/,AZ:/^[Aa][Zz]\d{4}$/,BH:/^\d{3,4}$/,BD:/^\d{4}$/,BB:/^[Aa][Zz]\d{5}$/,BY:/^\d{6}$/,BE:/^\d{4}$/,BM:/^[A-Za-z]{2}\s([A-Za-z]{2}|\d{2})$/,BT:/^\d{5}$/,BO:/^\d{4}$/,BA:/^\d{5}$/,BR:/^\d{5}-\d{3}$/,"":/^[Bb][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,IO:/^[Bb]{2}[Nn][Dd]\s{0,1}[1][Zz]{2}$/,VG:/^[Vv][Gg]\d{4}$/,BN:/^[A-Za-z]{2}\d{4}$/,BG:/^\d{4}$/,KH:/^\d{5}$/,CA:/^(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\d(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\s{0,1}\d(?=[^DdFfIiOoQqUu\d\s])[A-Za-z]\d$/,CV:/^\d{4}$/,KY:/^[Kk][Yy]\d[-\s]{0,1}\d{4}$/,TD:/^\d{5}$/,CL:/^\d{7}\s\(\d{3}-\d{4}\)$/,CN:/^\d{6}$/,CX:/^\d{4}$/,CC:/^\d{4}$/,CO:/^\d{6}$/,CD:/^[Cc][Dd]$/,CR:/^\d{4,5}$/,HR:/^\d{5}$/,CU:/^\d{5}$/,CY:/^\d{4}$/,CZ:/^\d{5}\s\(\d{3}\s\d{2}\)$/,DK:/^\d{4}$/,DO:/^\d{5}$/,EC:/^\d{6}$/,SV:/^1101$/,EG:/^\d{5}$/,EE:/^\d{5}$/,ET:/^\d{4}$/,FK:/^[Ff][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,FO:/^\d{3}$/,FI:/^\d{5}$/,FR:/^\d{5}$/,GF:/^973\d{2}$/,PF:/^987\d{2}$/,GA:/^\d{2}\s[a-zA-Z-_ ]\s\d{2}$/,GE:/^\d{4}$/,DE:/^\d{2}$/,GI:/^[Gg][Xx][1]{2}\s{0,1}[1][Aa]{2}$/,GR:/^\d{3}\s{0,1}\d{2}$/,GL:/^\d{4}$/,GP:/^971\d{2}$/,GU:/^\d{5}$/,GT:/^\d{5}$/,GG:/^[A-Za-z]{2}\d\s{0,1}\d[A-Za-z]{2}$/,GW:/^\d{4}$/,HT:/^\d{4}$/,HM:/^\d{4}$/,HN:/^\d{5}$/,HU:/^\d{4}$/,IS:/^\d{3}$/,IN:/^\d{6}$/,ID:/^\d{5}$/,IR:/^\d{5}-\d{5}$/,IQ:/^\d{5}$/,IM:/^[Ii[Mm]\d{1,2}\s\d\[A-Z]{2}$/,IL:/^\b\d{5}(\d{2})?$/,IT:/^\d{5}$/,JM:/^\d{2}$/,JP:/^\d{7}\s\(\d{3}-\d{4}\)$/,JE:/^[Jj][Ee]\d\s{0,1}\d[A-Za-z]{2}$/,JO:/^\d{5}$/,KZ:/^\d{6}$/,KE:/^\d{5}$/,KR:/^\d{6}\s\(\d{3}-\d{3}\)$/,XK:/^\d{5}$/,KW:/^\d{5}$/,KG:/^\d{6}$/,LV:/^[Ll][Vv][- ]{0,1}\d{4}$/,LA:/^\d{5}$/,LB:/^\d{4}\s{0,1}\d{4}$/,LS:/^\d{3}$/,LR:/^\d{4}$/,LY:/^\d{5}$/,LI:/^\d{4}$/,LT:/^[Ll][Tt][- ]{0,1}\d{5}$/,LU:/^\d{4}$/,MK:/^\d{4}$/,MG:/^\d{3}$/,MV:/^\d{4,5}$/,MY:/^\d{5}$/,MT:/^[A-Za-z]{3}\s{0,1}\d{4}$/,MH:/^\d{5}$/,MQ:/^972\d{2}$/,YT:/^976\d{2}$/,FM:/^\d{5}(-{1}\d{4})$/,MX:/^\d{5}$/,MD:/^[Mm][Dd][- ]{0,1}\d{4}$/,MC:/^980\d{2}$/,MN:/^\d{5}$/,ME:/^\d{5}$/,MS:/^[Mm][Ss][Rr]\s{0,1}\d{4}$/,MA:/^\d{5}$/,MZ:/^\d{4}$/,MM:/^\d{5}$/,NA:/^\d{5}$/,NP:/^\d{5}$/,NL:/^\d{4}\s{0,1}[A-Za-z]{2}$/,NC:/^988\d{2}$/,NZ:/^\d{4}$/,NI:/^\d{5}$/,NE:/^\d{4}$/,NG:/^\d{6}$/,NF:/^\d{4}$/,MP:/^\d{5}$/,NO:/^\d{4}$/,OM:/^\d{3}$/,PK:/^\d{5}$/,PW:/^\d{5}$/,PA:/^\d{6}$/,PG:/^\d{3}$/,PY:/^\d{4}$/,PE:/^\d{5}$/,PH:/^\d{4}$/,PN:/^[Pp][Cc][Rr][Nn]\s{0,1}[1][Zz]{2}$/,PL:/^\d{2}[- ]{0,1}\d{3}$/,PT:/^\d{4}$/,PR:/^\d{5}$/,RE:/^974\d{2}$/,RO:/^\d{6}$/,RU:/^\d{6}$/,BL:/^97133$/,SH:/^[Ss][Tt][Hh][Ll]\s{0,1}[1][Zz]{2}$/,MF:/^97150$/,PM:/^97500$/,VC:/^[Vv][Cc]\d{4}$/,SM:/^4789\d$/,SA:/^\d{5}(-{1}\d{4})?$/,SN:/^\d{5}$/,RS:/^\d{5}$/,SG:/^\d{2}$/,SK:/^\d{5}\s\(\d{3}\s\d{2}\)$/,SI:/^([Ss][Ii][- ]{0,1}){0,1}\d{4}$/,ZA:/^\d{4}$/,GS:/^[Ss][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,ES:/^\d{5}$/,LK:/^\d{5}$/,SD:/^\d{5}$/,SZ:/^[A-Za-z]\d{3}$/,SE:/^\d{3}\s*\d{2}$/,CH:/^\d{4}$/,SJ:/^\d{4}$/,TW:/^\d{5}$/,TJ:/^\d{6}$/,TH:/^\d{5}$/,TT:/^\d{6}$/,TN:/^\d{4}$/,TR:/^\d{5}$/,TM:/^\d{6}$/,TC:/^[Tt][Kk][Cc][Aa]\s{0,1}[1][Zz]{2}$/,UA:/^\d{5}$/,GB:/^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-[CIKMOV]]{2}/,US:/^\b\d{5}\b(?:[- ]{1}\d{4})?$/,UY:/^\d{5}$/,VI:/^\d{5}$/,UZ:/^\d{3} \d{3}$/,VA:/^120$/,VE:/^\d{4}(\s[a-zA-Z]{1})?$/,VN:/^\d{6}$/,WF:/^986\d{2}$/,ZM:/^\d{5}$/},ze=(t,e="")=>{let r=j(t)&&t.iso?He[t.iso||"US"]:He.US;return j(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var Ze=(t,e="",r={isChecked:!1})=>{if(!r.isChecked)return t===!0?e&&e.trim()!=="":e&&e.trim()==="";if(r.isChecked)return t===!0?e:!e};var Be=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,Ge=(t,e="")=>t===!0?!!e.match(Be):!e.match(Be);var Ke=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,We=(t,e="")=>t===!0?!!e.match(Ke):!e.match(Ke);var Je=/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/,Qe=(t,e="")=>t===!0?!!e.match(Je):!e.match(Je);var Ye=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,Xe=(t,e="")=>t===!0?!!e.match(Ye):!e.match(Ye);var et={AT:/^(AT)(U\d{8}$)/i,BE:/^(BE)(\d{10}$)/i,BG:/^(BG)(\d{9,10}$)/i,CY:/^(CY)([0-5|9]\d{7}[A-Z]$)/i,CZ:/^(CZ)(\d{8,10})?$/i,DE:/^(DE)([1-9]\d{8}$)/i,DK:/^(DK)(\d{8}$)/i,EE:/^(EE)(10\d{7}$)/i,EL:/^(EL)(\d{9}$)/i,ES:/^(ES)([0-9A-Z][0-9]{7}[0-9A-Z]$)/i,EU:/^(EU)(\d{9}$)/i,FI:/^(FI)(\d{8}$)/i,FR:/^(FR)([0-9A-Z]{2}[0-9]{9}$)/i,GB:/^(GB)((?:[0-9]{12}|[0-9]{9}|(?:GD|HA)[0-9]{3})$)/i,GR:/^(GR)(\d{8,9}$)/i,HR:/^(HR)(\d{11}$)/i,HU:/^(HU)(\d{8}$)/i,IE:/^(IE)([0-9A-Z\*\+]{7}[A-Z]{1,2}$)/i,IT:/^(IT)(\d{11}$)/i,LV:/^(LV)(\d{11}$)/i,LT:/^(LT)(\d{9}$|\d{12}$)/i,LU:/^(LU)(\d{8}$)/i,MT:/^(MT)([1-9]\d{7}$)/i,NL:/^(NL)(\d{9}B\d{2}$)/i,NO:/^(NO)(\d{9}$)/i,PL:/^(PL)(\d{10}$)/i,PT:/^(PT)(\d{9}$)/i,RO:/^(RO)([1-9]\d{1,9}$)/i,RU:/^(RU)(\d{10}$|\d{12}$)/i,RS:/^(RS)(\d{9}$)/i,SI:/^(SI)([1-9]\d{7}$)/i,SK:/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7}$)/i,SE:/^(SE)(\d{10}01$)/i},tt=(t,e="")=>{let r=j(t)&&t.iso?et[t.iso||"EU"]:et.EU;return j(t)?t.rule===!0?!!e.match(r):!e.match(r):t===!0?!!e.match(r):!e.match(r)};var rt={creditCard:De,email:je,equals:Pe,matches:Ie,maxLength:Ne,minLength:Ve,phone:qe,postalCode:ze,required:Ze,semVer:Ge,slug:We,strongPassword:Qe,url:Xe,vat:tt};var ot=class{constructor(e,r={}){this.fieldsToListenToForChanges=["checkbox","color","date","datetime-local","email","file","hidden","month","number","password","radio","range","search","tel","text","time","url","week"],this.defaultValidationErrors={required:()=>"This field is required.",email:()=>"Must be a valid email.",creditCard:()=>"Must be a valid credit card number.",equals:o=>`Value must equal ${o}.`,matches:o=>`Field must match ${o}.`,maxLength:o=>`Field value can be no greater than ${o}.`,minLength:o=>`Field value can be no less than ${o}.`,phone:()=>"Field value must be a valid telephone number.",postalCode:()=>"Field value must be a valid postal code.",semVer:()=>"Field value must be a valid semantic version.",slug:()=>"Field value must be a valid URL slug.",strongPassword:()=>"Field value must be a valid password.",url:()=>"Field value must be a valid URL.",vat:()=>"Field value must be a valid VAT code."},e||console.warn("[validateForm] Must pass an HTML <form></form> element to validate."),this.form=e,this.setOptions(r),this.attachEventListeners()}setOptions(e={}){this.rules=e.rules||{},this.messages=e.messages||{},this.onSubmit=e.onSubmit,this.fields=this.serialize()}updateOptions(e={}){this.setOptions(e)}serialize(){if(this.form)return Object.keys(this.rules).map(r=>{let o=this.form.querySelector(`[name="${r}"]`),i=o?.type;return{listenForChanges:this.fieldsToListenToForChanges.includes(i),type:i,name:r,element:o,validations:Object.entries(this.rules[r]).map(([c,a])=>({name:c,rule:a,valid:!1})).sort((c,a)=>c.name>a.name?1:-1),errorMessages:this.messages[r]?Object.keys(this.messages[r]):{}}})}attachEventListeners(){if(this.form){let e=r=>{r.stopPropagation(),r.preventDefault(),this.validate()&&this.onSubmit&&this.onSubmit()};if(this.form.listeners?.length>0)for(let r=0;r<this.form.listeners.length;r+=1){let o=this.form.listeners[r];this.form.removeEventListener("submit",o)}this.form.addEventListener("submit",e),this.form.listeners=[...this.form.listeners||[],e]}this.fields.forEach(e=>{if(e?.element&&e?.listenForChanges){let r=()=>{Re(()=>{this.validate(e.name)},100)};e.element.removeEventListener("input",r),e.element.addEventListener("input",r),e.element.removeEventListener("change",r),e.element.addEventListener("change",r)}})}validate(e=null){if(e){this.clearExistingErrors();let r=this.fields.find(o=>o.name===e);return this.validateField(r),this.checkIfValid()}else return this.clearExistingErrors(),this.fields.forEach(r=>{this.validateField(r)}),this.checkIfValid()}checkIfValid(){return!this.fields.map(r=>r.validations.some(o=>!o.valid)).includes(!0)}validateField(e){let r=this.form.querySelector(`[name="${e.name}"]`),o=["checkbox","radio"].includes(e.type),i=o?null:e?.element?.value?.trim(),s=o?e?.element?.checked:null;e.validations.forEach(a=>{if(this.isValidValue(o,o?s:i,a))this.markValidationAsValid(e,a.name);else{let m=this.messages[e.name]&&this.messages[e.name][a.name];this.markValidationAsInvalid(e,a.name),this.renderError(e.element,m||this.defaultValidationErrors[a.name](a.rule,i))}});let c=e.validations.some(a=>!a.valid);return c&&(r.classList.add("error"),r.focus()),c||(r.classList.remove("error"),this.clearExistingError(e.name)),!c}markValidationAsInvalid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!1}markValidationAsValid(e,r){let i=[...e.validations].find(s=>s.name===r);i.valid=!0}isValidValue(e,r,o){let i=rt[o.name];return i?i(o.rule,r,{isChecked:e}):!0}clearExistingErrors(){this.form&&this.form.querySelectorAll(".input-hint.error").forEach(e=>e.remove())}clearExistingError(e=""){let r=document.getElementById(`error-${e}`);r&&r.remove()}renderError(e,r=""){if(e){this.clearExistingError(e.name);let o=document.createElement("p");o.classList.add("input-hint"),o.classList.add("error"),o.setAttribute("id",`error-${e.name}`),o.innerText=r,e.after(o)}}},sr=(t,e)=>new Promise((r,o)=>{try{new ot(t,e).validate()?r():o()}catch(i){console.warn(i)}}),it=sr;var nt=(t={},e={})=>{try{return[...Object.keys(e),...Object.keys(t)].filter((o,i,s)=>s.indexOf(o)===i).reduce((o,i)=>{let s=e[i],c=t[i]||null,a=!we(s)&&!ye(s);return o[i]=a?s:c,o},{})}catch(r){n("component.props.compile",r)}};var st=(t="",e={})=>{try{let r="";if(t&&C(t))return r=t,r;if(t&&l(t))return r=t(e),r;if(t&&u(t)){let o=t?.print&&(C(t?.print)||l(t?.print)),i=t?.min&&u(t?.min),s=t?.min?.width&&u(t?.min?.width),c=t?.min?.height&&u(t?.min?.height),a=t?.max&&u(t?.max),m=t?.max?.width&&u(t?.max?.width),y=t?.max?.height&&u(t?.max?.height);if(o&&(r+=`
|
|
2
2
|
@media print {
|
|
3
3
|
${typeof t?.print=="function"?t?.print(e):t.print}
|
|
4
4
|
}
|
|
5
|
-
`),i&&s){let w=Object.entries(t?.min?.width);for(let
|
|
5
|
+
`),i&&s){let w=Object.entries(t?.min?.width);for(let g=0;g<w.length;g+=1){let[v,f]=w[g];r+=`
|
|
6
6
|
@media screen and (min-width: ${v}px) {
|
|
7
7
|
${typeof f=="function"?f(e):f}
|
|
8
8
|
}
|
|
9
|
-
`}}if(i&&c){let w=Object.entries(t?.min?.height);for(let
|
|
9
|
+
`}}if(i&&c){let w=Object.entries(t?.min?.height);for(let g=0;g<w.length;g+=1){let[v,f]=w[g];r+=`
|
|
10
10
|
@media screen and (min-height: ${v}px) {
|
|
11
11
|
${typeof f=="function"?f(e):f}
|
|
12
12
|
}
|
|
13
|
-
`}}if(a&&
|
|
13
|
+
`}}if(a&&m){let w=Object.entries(t?.max?.width);for(let g=0;g<w.length;g+=1){let[v,f]=w[g];r+=`
|
|
14
14
|
@media screen and (max-width: ${v}px) {
|
|
15
15
|
${typeof f=="function"?f(e):f}
|
|
16
16
|
}
|
|
17
|
-
`}}if(a&&y){let w=Object.entries(t?.max?.height);for(let
|
|
17
|
+
`}}if(a&&y){let w=Object.entries(t?.max?.height);for(let g=0;g<w.length;g+=1){let[v,f]=w[g];r+=`
|
|
18
18
|
@media screen and (max-height: ${v}px) {
|
|
19
19
|
${typeof f=="function"?f(e):f}
|
|
20
20
|
}
|
|
21
|
-
`}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var ar=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!_(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},G=(t={},e={})=>{try{return l(e)?ar(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var ie={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var at=(t={},e={})=>{try{return e?Object.entries({...ie,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ie}catch(r){n("component.lifecycle.compile",r)}};var K=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{n("component.methods.compile")}};var ne=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>C(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){n("component.url.compile",e)}};var S=()=>typeof window=="undefined";var P=null,W=0,dt=(t={},e=null)=>{try{let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);P&&(clearInterval(P),P=null);let i={client:o,send:(s={})=>o.send(JSON.stringify(s))};return o.addEventListener("open",()=>{t?.options?.logging&&console.log(`[joystick.websockets] Connected to ${t?.url}`),t?.events?.onOpen&&t.events.onOpen(i),W=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&t.events.onMessage(JSON.parse(s.data||{}),i)}),o.addEventListener("close",s=>{t?.options?.logging&&console.log(`[joystick.websockets] Disconnected from ${t?.url}`),t?.events?.onClose&&t.events.onClose(s?.code,s?.reason,i),o=null;let c=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!P&&!c&&(P=setInterval(()=>{o=null,W<(t?.options?.reconnectAttempts||12)?(dt(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${W+1}/12)...`),W+=1):clearInterval(P)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},ct=dt;var dr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!_(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},lt=(t={},e={})=>{try{return l(e)?dr(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var pt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=U(8),t.ssrId=e?._ssrId||null,t.css=st(),t.data=B(e?.dataFromSSR,e?._componentId),t.defaultProps=lt(t,e?.defaultProps),t.props=nt(t?.defaultProps,e?.props),t.state=G(t,e?.state),t.events=e?.events||{},t.lifecycle=at(t,e?.lifecycle),t.methods=K(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=it,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=ne(e?.url)),r&&window.__joystick_url__&&(t.url=ne(window.__joystick_url__)),r&&e?.websockets&&l(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[c,a]=i[s];ct({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(p={})=>{t.websockets={...t.websockets||{},[c]:p}})}}}catch(r){n("component.registerOptions",r)}};var I=(t="",e=[])=>{try{console.error(`${t} failed with the following errors:`),e.forEach(r=>{console.log(r.message),r.stack&&console.log(r.stack)})}catch(r){n(t,r)}};var J=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var mt=(t={})=>Object.entries(t).map(([e,r])=>`${e}=${r}`)?.join("; ");var cr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.get.handleParseResponse",e)}},ut=(t="",e={})=>{try{return typeof window.fetch!="undefined"&&!e?.skip?new Promise((r,o)=>{let i=e.input?JSON.stringify(e.input):null,s=e.output?JSON.stringify(e.output):null,c=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content"),p={...e?.headers||{},"x-joystick-csrf":a};return window?.__joystick_test__&&(p.Cookie=mt({joystickLoginToken:window.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expires_at__})),fetch(c,{method:"GET",mode:"cors",headers:p,credentials:"include"}).then(async y=>{let w=await cr(y);return w?.errors?(I("get request",w.errors),o(w)):r(w)}).catch(y=>(I("get request",[y]),o({errors:[y]})))}):Promise.resolve()}catch(r){n("get request",r)}};var lr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.set.handleParseResponse",e)}},pr=(t={})=>{try{return JSON.stringify(t)}catch(e){n("api.set.getBody",e)}},ft=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=pr(e),c=document.querySelector('[name="csrf"]')?.getAttribute("content"),a={...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":c};return window?.__joystick_test__&&(a.Cookie=generateCookieHeader({joystickLoginToken:window?.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expirs_at__})),fetch(i,{method:"POST",mode:"cors",headers:a,body:s,credentials:"include"}).then(async p=>{let y=await lr(p);return y?.errors?(I("set request",y.errors),o(y)):r(y)}).catch(p=>(I("set request",[p]),o({errors:[p]})))}):Promise.resolve()}catch(r){n("set request",r)}};var ht={get:ut,set:ft};var mr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("addToQueue.getQueue",e)}},q=(t="",e=null)=>{try{S()||(mr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Q=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&l(o.options.data)){let i=await o.options.data(t,e,r,o);return Promise.resolve(i)}return Promise.resolve()}catch(i){n("component.data.fetch",i)}};var wt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let i=await Q(ht,e,o,r);return r.data=wt(i,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=i),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){n("component.data.compile",o)}},yt=wt;var xt=(t={})=>{try{if(!S()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return yt(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var Ft=nr(gt());var bt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(u(t)&&o){let i=Object.keys(t);for(let s=0;s<i.length;s+=1){let c=i[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let p=0;p<a.length;p+=1){let y=a[p],w=bt(y,e,r);if(w!==null)return w}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},R=bt;var $t=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var ur=(t={},e={},r=null)=>{try{let o=N(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){n("component.renderMethods.component.renderForClient",o)}},fr=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){n("component.renderMethods.component.renderToHTMLForSSR",e)}},hr=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){n("component.renderMethods.component.collectDataFunctionsForSSR",e)}},wr=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};$t(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){n("component.renderMethods.component.handleAddComponentToParent",e)}},yr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&q("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&q("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},xr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Ft.diff)(e?.existingPropsMap,r)?.length>0&&q("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t)})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},gr=function(){return function(e=null,r={},o={}){let i=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[i.id]||{},c=o.children[i.id]||[],a=s[c?.length];return i.state=a?.state||i.state,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,xr(i,o,r),q("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),yr(this,i),i.parent&&wr(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?hr(i):i.parent&&i.parent.ssrTree?fr(i):ur(i,this,a?.children)}},br=function(e,r){try{let o=this;return new gr().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},se=br;var $r=function(e=[],r=null){try{return l(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},ae=$r;var Fr=(t="",e=[])=>{try{return e.reduce((r,[o,i])=>r.replace(`{{${o}}}`,i),t)}catch(r){n("component.renderMethods.i18n.replacePlaceholdersInString",r)}},de=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),i=typeof t=="object"&&!o;if(r)return Fr(t,e);if(o)return t?.map(s=>de(s,e));if(i)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=de(a,e),s),{})}catch(r){n("component.renderMethods.i18n.handleTranslationReplacement",r)}},Er=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>(console.log({key:t,objectToTraverse:r,keyToMatch:o}),r[o]),e)}catch(r){n("component.renderMethods.i18n.getTranslationAtPath",r)}},kr=function(t="",e={}){try{let r=S()?this.translations:window.__joystick_i18n__,i=t?.includes(".")?Er(t,r):r[t];if(t?.includes("creatorDashboard")&&console.log({key:t,replacements:e,translation:i,translations:r}),!r||!i)return"";let s=Object.entries(e);return de(i,s)}catch(r){n("component.renderMethods.i18n",r)}},ce=kr;var Mr=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},le=Mr;var Et={c:se,component:se,e:ae,each:ae,i:ce,i18n:ce,w:le,when:le};var kt=(t={},e={})=>{try{return Object.entries(Et).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var Mt=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,children:Mt(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},St=(t={})=>{try{return Mt(t)}catch(e){n("component.render.getExistingStateMap",e)}};var Ot=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),Sr=new RegExp(/\n/g);var Or=(t="")=>{try{return(t.match(Ot)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},Tt=(t="")=>{try{let e=`${t}`;return e=Or(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var vt=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:i=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${i}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Ct=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,c]=o[i];for(let a=0;a<c?.length;a+=1){let p=c[a];Object.entries(p?.timers)?.length>0&&r.push(...Object.values(p?.timers)),Object.entries(p?.children)?.length>0&&Ct(p?.children,r)}}if(r?.length>0)for(let i=0;i<r?.length;i+=1)clearTimeout(r[i])}catch(r){n("component.render.clearTimersOnChildren",r)}},Rt=Ct;var X=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=B(e.dataFromSSR,t.id)||{}),Rt(t?.children);let r=St(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=kt({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=K(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=Tt(o),s=vt(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Tr=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},At=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?At(e):pe(e)):pe(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},pe=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Tr(t.attributes),children:[].flatMap.call(t.childNodes,o=>At(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},H=pe;var vr=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},Lt=(t="")=>{try{let e=vr(t);return H(e)}catch(e){n("component.virtualDOM.build",e)}};var Dt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var Cr=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[i,s]=r[o];Dt(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=_t(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},_t=(t=null)=>{try{return C(t)?document.createTextNode(t):Cr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},V=_t;var N=(t={},e={})=>{try{let r=X(t,{existingChildren:e?.existingChildren}),o=Lt(r.wrapped,t),i=e.includeActual&&o?V(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var jt=(t={},e={})=>{try{let r=N(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Rr=(t={},e={})=>{let r=[];for(let[o,i]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,i),s));for(let o in t)o in e||r.push(i=>(i&&i.removeAttribute&&i.removeAttribute(o),i));return o=>{for(let i of r)i&&typeof i=="function"&&i(o)}},ee=Rr;var Ar=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],c=e[i];r.push([s,c])}return r},Pt=Ar;var Lr=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Dr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},_r=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=c=>{let a=V(i);return c.appendChild(a),c};r.push(s)}),r},jr=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=re(o,e[i]);r.push(s)}),r},Pr=(t=[],e=[])=>{let r=jr(t,e),o=_r(t,e);return i=>{if(i){let s=Pt(r,i.childNodes);Dr(s),Lr(o,i)}return i}},te=Pr;var It={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ee(t.attributes,e.attributes)(r),te([],e.children)(r);let i=r.querySelector(`option[value="${o}"]`);if(i&&(r.value=o),!i){let s=r.querySelector("option");r.value=s?.value||""}return r}};var me=(t,e)=>r=>{let o=t?V(t):null;return r&&r.replaceWith(o),o},Ir=()=>t=>{t&&t.remove()},Nr=(t=void 0,e=void 0)=>t===void 0||e===void 0?Ir():typeof t=="string"||typeof e=="string"?me(e,t):t.tagName!==e.tagName?me(e):e.tagName==="select"?It.select(t,e):["pre","code"].includes(e.tagName)?me(e,t):i=>(ee(t.attributes,e.attributes)(i),te(t.children,e.children)(i),i),re=Nr;var Vr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("processQueue.getQueue",e)}},z=(t="",e=null)=>{try{S()||(Vr(t)||{}).process(e)}catch(r){n("processQueue",r)}};var Nt=(t="",e=null)=>{let r=R(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var Vt=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Ut=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(u(i)&&i.attributes&&i.attributes["js-i"]&&i.attributes["js-i"]===e){t.children[o]=r;break}u(i)&&Ut(i,e,r)}},qt=Ut;var Ht=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...i]=e.split(" ");return{type:o.toLowerCase(),selector:i.join(" "),handler:r}})}catch(e){n("component.events.serialize",e)}};var zt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Ht(t?.events):[];for(let i=0;i<o?.length;i+=1){let s=o[i];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<i?.length;s+=1){let c=i[s];zt(c,e,r)}}return r}catch(o){n("component.eve!nts.registerListenersFix.getListeners",o)}},Ur=(t={},e={})=>{try{let o=zt(t,e,[])?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:c=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:c,elementSelector:a,type:p,handler:y}=o[i];c.addEventListener(p,y),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:p,handler:y}]}}catch(r){n("component.events.registerListenersFix",r)}},Zt=Ur;var Bt=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Bt(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},qr=(t={})=>{try{let e=Bt(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:c}=e[r];i.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Gt=qr;var Kt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},ve(e),pt(this,e),this.data=xt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Q(e,r,o,i);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=H(this.DOMNode);this.dom.virtual=r}let e=this.parent?R(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!S())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return jt(this,e);let r=this.onBeforeRender();Gt(this),Nt(this.instanceId);let o=N(this,{}),i=re(this.dom.virtual,o.virtual);i&&l(i)&&z("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,Zt(this,this.renderMethods),this.setDOMNodeOnInstance(),z("domNodes",()=>{z("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return X(this,e)}onAfterRender(e={},r={}){S()||(Vt(e.instanceId,this),window.joystick._internal.css.update(),z("lifecycle.onUpdateProps"),r?.afterSetStateRender&&l(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&l(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=G(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&l(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[U()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[U()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=R(window.joystick._internal.tree,this.instanceId,"instanceId"),i=R(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=H(i?.instance?.DOMNode);qt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},Wt=Kt;var sd=(t={})=>{try{return(e={})=>new Wt({...t,props:e?.props,url:e?.url,translations:e?.translations,api:e?.api,req:e?.req,parent:e?.parent})}catch(e){n("component",e)}};export{sd as default};
|
|
21
|
+
`}}return r}return""}catch(r){n("component.css.compileCSS",r)}};var ar=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!_(r)?Object.assign({},r):{}}catch(r){n("component.state.compile.compileState",r)}},G=(t={},e={})=>{try{return l(e)?ar(t,e):Object.assign({},e)}catch(r){n("component.state.compile",r)}};var ie={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var at=(t={},e={})=>{try{return e?Object.entries({...ie,...e||{}}).reduce((r={},[o,i])=>(r[o]=()=>i({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):ie}catch(r){n("component.lifecycle.compile",r)}};var K=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,i])=>(r[o]=(...s)=>i(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{n("component.methods.compile")}};var ne=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>C(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){n("component.url.compile",e)}};var S=()=>typeof window=="undefined";var P=null,W=0,dt=(t={},e=null)=>{try{let r=t?.url;t?.query&&(r=`${r}?${new URLSearchParams(t.query).toString()}`);let o=new WebSocket(r);P&&(clearInterval(P),P=null);let i={client:o,send:(s={})=>o.send(JSON.stringify(s))};return o.addEventListener("open",()=>{t?.options?.logging&&console.log(`[joystick.websockets] Connected to ${t?.url}`),t?.events?.onOpen&&t.events.onOpen(i),W=0}),o.addEventListener("message",s=>{s?.data&&t?.events?.onMessage&&t.events.onMessage(JSON.parse(s.data||{}),i)}),o.addEventListener("close",s=>{t?.options?.logging&&console.log(`[joystick.websockets] Disconnected from ${t?.url}`),t?.events?.onClose&&t.events.onClose(s?.code,s?.reason,i),o=null;let c=[1e3,1001].includes(s?.code);t?.options?.autoReconnect&&!P&&!c&&(P=setInterval(()=>{o=null,W<(t?.options?.reconnectAttempts||12)?(dt(t,e),t?.options?.logging&&console.log(`[joystick.websockets] Attempting to reconnect (${W+1}/12)...`),W+=1):clearInterval(P)},t?.options?.reconnectDelayInSeconds*1e3||5e3))}),e&&e(i),i}catch(r){n("websockets.client",r)}},ct=dt;var dr=(t={},e=null)=>{try{let r=e(t);return r&&u(r)&&!_(r)?Object.assign({},r):{}}catch(r){n("component.props.compileDefaultProps.compile",r)}},lt=(t={},e={})=>{try{return l(e)?dr(t,e):Object.assign({},e)}catch(r){n("component.props.compileDefaultProps",r)}};var mt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=U(8),t.ssrId=e?._ssrId||null,t.css=st(),t.data=B(e?.dataFromSSR,e?._componentId),t.defaultProps=lt(t,e?.defaultProps),t.props=nt(t?.defaultProps,e?.props),t.state=G(t,e?.state),t.events=e?.events||{},t.lifecycle=at(t,e?.lifecycle),t.methods=K(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=it,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=ne(e?.url)),r&&window.__joystick_url__&&(t.url=ne(window.__joystick_url__)),r&&e?.websockets&&l(e?.websockets)){let o=e.websockets(t),i=u(o)&&Object.entries(o);for(let s=0;s<i?.length;s+=1){let[c,a]=i[s];ct({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(m={})=>{t.websockets={...t.websockets||{},[c]:m}})}}}catch(r){n("component.registerOptions",r)}};var I=(t="",e=[])=>{try{console.error(`${t} failed with the following errors:`),e.forEach(r=>{console.log(r.message),r.stack&&console.log(r.stack)})}catch(r){n(t,r)}};var J=(t="{}")=>{try{return JSON.parse(t)}catch{return t}};var pt=(t={})=>Object.entries(t).map(([e,r])=>`${e}=${r}`)?.join("; ");var cr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.get.handleParseResponse",e)}},ut=(t="",e={})=>{try{return typeof window.fetch!="undefined"&&!e?.skip?new Promise((r,o)=>{let i=e.input?JSON.stringify(e.input):null,s=e.output?JSON.stringify(e.output):null,c=`${window.location.origin}/api/_getters/${t}?input=${i}&output=${s}`,a=document.querySelector('[name="csrf"]')?.getAttribute("content"),m={...e?.headers||{},"x-joystick-csrf":a};return window?.__joystick_test__&&(m.Cookie=pt({joystickLoginToken:window.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expires_at__})),fetch(c,{method:"GET",mode:"cors",headers:m,credentials:"include"}).then(async y=>{let w=await cr(y);return w?.errors?(I("get request",w.errors),o(w)):r(w)}).catch(y=>(I("get request",[y]),o({errors:[y]})))}):Promise.resolve()}catch(r){n("get request",r)}};var lr=async(t={})=>{try{let e=await t.text();return J(e)}catch(e){n("api.set.handleParseResponse",e)}},mr=(t={})=>{try{return JSON.stringify(t)}catch(e){n("api.set.getBody",e)}},ft=(t="",e={})=>{try{return typeof window.fetch!="undefined"?new Promise((r,o)=>{let i=`${window.location.origin}/api/_setters/${t}`,s=mr(e),c=document.querySelector('[name="csrf"]')?.getAttribute("content"),a={...e?.headers||{},"Content-Type":"application/json","x-joystick-csrf":c};return window?.__joystick_test__&&(a.Cookie=generateCookieHeader({joystickLoginToken:window?.__joystick_test_login_token__,joystickLoginTokenExpiresAt:window.__joystick_test_login_token_expirs_at__})),fetch(i,{method:"POST",mode:"cors",headers:a,body:s,credentials:"include"}).then(async m=>{let y=await lr(m);return y?.errors?(I("set request",y.errors),o(y)):r(y)}).catch(m=>(I("set request",[m]),o({errors:[m]})))}):Promise.resolve()}catch(r){n("set request",r)}};var ht={get:ut,set:ft};var pr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("addToQueue.getQueue",e)}},q=(t="",e=null)=>{try{S()||(pr(t)||{}).array.push({callback:e})}catch(r){n("addToQueue",r)}};var Q=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&l(o.options.data)){let i=await o.options.data(t,e,r,o);return Promise.resolve(i)}return Promise.resolve()}catch(i){n("component.data.fetch",i)}};var wt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let i=await Q(ht,e,o,r);return r.data=wt(i,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=i),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){n("component.data.compile",o)}},yt=wt;var gt=(t={})=>{try{if(!S()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return yt(e,r,t)}return t?.data||{}}catch(e){n("component.loadDataFromWindow",e)}};var Ft=nr(xt());var bt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(u(t)&&o){let i=Object.keys(t);for(let s=0;s<i.length;s+=1){let c=i[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let m=0;m<a.length;m+=1){let y=a[m],w=bt(y,e,r);if(w!==null)return w}}}return null}catch(o){n("component.findComponentInTreeByField",o)}},R=bt;var $t=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var ur=(t={},e={},r=null)=>{try{let o=N(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){n("component.renderMethods.component.renderForClient",o)}},fr=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){n("component.renderMethods.component.renderToHTMLForSSR",e)}},hr=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){n("component.renderMethods.component.collectDataFunctionsForSSR",e)}},wr=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};$t(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){n("component.renderMethods.component.handleAddComponentToParent",e)}},yr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&q("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&q("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){n("component.renderMethods.component.handleLifecycle",r)}},gr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Ft.diff)(e?.existingPropsMap,r)?.length>0&&q("lifecycle.onUpdateProps",()=>{let i=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(i||{},r,t)})}catch(o){n("component.renderMethods.component.handleOnChangeProps",o)}},xr=function(){return function(e=null,r={},o={}){let i=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[i.id]||{},c=o.children[i.id]||[],a=s[c?.length];return i.state=a?.state||i.state,o.children[i.id]=[...o.children[i.id]||[],i],i.parent=o,gr(i,o,r),q("lifecycle.onMount",()=>{i.setDOMNodeOnInstance()}),yr(this,i),i.parent&&wr(i),i.options.data&&i.parent.walkingTreeForSSR&&i.parent.ssrTree.dataFunctions?hr(i):i.parent&&i.parent.ssrTree?fr(i):ur(i,this,a?.children)}},br=function(e,r){try{let o=this;return new xr().bind({})(e,r,o)}catch(o){n("component.renderMethods.component",o)}},se=br;var $r=function(e=[],r=null){try{return l(r)&&e&&Array.isArray(e)?e.map((o,i)=>r(o,i)).join(""):""}catch(o){n("component.renderMethods.each",o)}},ae=$r;var Fr=(t="",e=[])=>{try{return e.reduce((r,[o,i])=>r.replace(`{{${o}}}`,i),t)}catch(r){n("component.renderMethods.i18n.replacePlaceholdersInString",r)}},de=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),i=typeof t=="object"&&!o;if(r)return Fr(t,e);if(o)return t?.map(s=>de(s,e));if(i)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=de(a,e),s),{})}catch(r){n("component.renderMethods.i18n.handleTranslationReplacement",r)}},Er=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>(console.log({key:t,objectToTraverse:r,keyToMatch:o}),r[o]),e)}catch(r){n("component.renderMethods.i18n.getTranslationAtPath",r)}},Mr=function(t="",e={}){try{let r=S()?this.translations:window.__joystick_i18n__,i=t?.includes(".")?Er(t,r):r[t];if(t?.includes("creatorDashboard")&&console.log({key:t,replacements:e,translation:i,translations:r}),!r||!i)return"";let s=Object.entries(e);return de(i,s)}catch(r){n("component.renderMethods.i18n",r)}},ce=Mr;var kr=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){n("component.renderMethods.when",o)}},le=kr;var Et={c:se,component:se,e:ae,each:ae,i:ce,i18n:ce,w:le,when:le};var Mt=(t={},e={})=>{try{return Object.entries(Et).reduce((r,[o,i])=>(r[o]=i.bind({...t,...e}),r),{})}catch(r){n("component.renderMethods.compile",r)}};var kt=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((i={})=>({state:i?.state,children:kt(i?.children)})),e),{})}catch(e){n("component.render.getExistingStateMap.buildMapForChildren",e)}},St=(t={})=>{try{return kt(t)}catch(e){n("component.render.getExistingStateMap",e)}};var Ot=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),Sr=new RegExp(/\n/g);var Or=(t="")=>{try{return(t.match(Ot)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){n("component.render.sanitizeHTML.removeCommentedCode",e)}},Tt=(t="")=>{try{let e=`${t}`;return e=Or(e),e}catch(e){n("component.render.sanitizeHTML",e)}};var vt=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:i=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${i}">${e}</div>`}catch(r){n("component.render.wrapHTML",r)}};var Ct=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let i=0;i<o?.length;i+=1){let[s,c]=o[i];for(let a=0;a<c?.length;a+=1){let m=c[a];Object.entries(m?.timers)?.length>0&&r.push(...Object.values(m?.timers)),Object.entries(m?.children)?.length>0&&Ct(m?.children,r)}}if(r?.length>0)for(let i=0;i<r?.length;i+=1)clearTimeout(r[i])}catch(r){n("component.render.clearTimersOnChildren",r)}},Rt=Ct;var X=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=B(e.dataFromSSR,t.id)||{}),Rt(t?.children);let r=St(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Mt({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=K(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),i=Tt(o),s=vt(t,i);return{unwrapped:i,wrapped:s}}catch(r){n("component.render.toHTML",r)}};var Tr=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){n("component.virtualDOM.build.parseAttributeMap",e)}},At=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?At(e):me(e)):me(t)}catch(e){n("component.virtualDOM.build.flattenWhenTags",e)}},me=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:Tr(t.attributes),children:[].flatMap.call(t.childNodes,o=>At(o))};return e==="text"&&(r=t.textContent),r}catch(e){n("component.virtualDOM.build",e)}},H=me;var vr=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){n("component.virtualDOM.build.convertHTMLToDOM",e)}},Lt=(t="")=>{try{let e=vr(t);return H(e)}catch(e){n("component.virtualDOM.build",e)}};var Dt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var Cr=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[i,s]=r[o];Dt(i)&&e.setAttribute(i,s)}for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(i){let s=_t(i);e.appendChild(s)}}return e}catch(e){n("component.virtualDOM.renderTreeToDOM.renderElement",e)}},_t=(t=null)=>{try{return C(t)?document.createTextNode(t):Cr(t)}catch(e){n("component.virtualDOM.renderTreeToDOM",e)}},V=_t;var N=(t={},e={})=>{try{let r=X(t,{existingChildren:e?.existingChildren}),o=Lt(r.wrapped,t),i=e.includeActual&&o?V(o):null;return{html:r,virtual:o,actual:i}}catch(r){n("component.render.getUpdatedDOM",r)}};var jt=(t={},e={})=>{try{let r=N(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){n("component.render.forMount",r)}};var Rr=(t={},e={})=>{let r=[];for(let[o,i]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,i),s));for(let o in t)o in e||r.push(i=>(i&&i.removeAttribute&&i.removeAttribute(o),i));return o=>{for(let i of r)i&&typeof i=="function"&&i(o)}},ee=Rr;var Ar=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let i=0;i<o;i+=1){let s=t[i],c=e[i];r.push([s,c])}return r},Pt=Ar;var Lr=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},Dr=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},_r=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(i=>{let s=c=>{let a=V(i);return c.appendChild(a),c};r.push(s)}),r},jr=(t=[],e=[])=>{let r=[];return t.forEach((o,i)=>{let s=re(o,e[i]);r.push(s)}),r},Pr=(t=[],e=[])=>{let r=jr(t,e),o=_r(t,e);return i=>{if(i){let s=Pt(r,i.childNodes);Dr(s),Lr(o,i)}return i}},te=Pr;var It={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ee(t.attributes,e.attributes)(r),te([],e.children)(r);let i=r.querySelector(`option[value="${o}"]`);if(i&&(r.value=o),!i){let s=r.querySelector("option");r.value=s?.value||""}return r}};var pe=(t,e)=>r=>{let o=t?V(t):null;return r&&r.replaceWith(o),o},Ir=()=>t=>{t&&t.remove()},Nr=(t=void 0,e=void 0)=>t===void 0||e===void 0?Ir():typeof t=="string"||typeof e=="string"?pe(e,t):t.tagName!==e.tagName?pe(e):e.tagName==="select"?It.select(t,e):["pre","code"].includes(e.tagName)?pe(e,t):i=>(ee(t.attributes,e.attributes)(i),te(t.children,e.children)(i),i),re=Nr;var Vr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){n("processQueue.getQueue",e)}},z=(t="",e=null)=>{try{S()||(Vr(t)||{}).process(e)}catch(r){n("processQueue",r)}};var Nt=(t="",e=null)=>{let r=R(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var Vt=(t="",e={},r=null)=>{let o=R(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var Ut=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let i=t?.children[o];if(u(i)&&i.attributes&&i.attributes["js-i"]&&i.attributes["js-i"]===e){t.children[o]=r;break}u(i)&&Ut(i,e,r)}},qt=Ut;var Ht=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...i]=e.split(" ");return{type:o.toLowerCase(),selector:i.join(" "),handler:r}})}catch(e){n("component.events.serialize",e)}};var zt=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?Ht(t?.events):[];for(let i=0;i<o?.length;i+=1){let s=o[i];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let i=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<i?.length;s+=1){let c=i[s];zt(c,e,r)}}return r}catch(o){n("component.eve!nts.registerListenersFix.getListeners",o)}},Ur=(t={},e={})=>{try{let o=zt(t,e,[])?.flatMap((i={})=>[].flatMap.call(i?.elements||[],s=>{let{elements:c=[],...a}=i||{};return{...a,element:s}}));for(let i=0;i<o?.length;i+=1){let{instance:s,element:c,elementSelector:a,type:m,handler:y}=o[i];c.addEventListener(m,y),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:m,handler:y}]}}catch(r){n("component.events.registerListenersFix",r)}},Zt=Ur;var Bt=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((i=[],s=[])=>[...i,...s],[])).flatMap((i={})=>Bt(i));e=[...e,...o]}return e}catch(e){n("component.events.unregisterListenersFix.getListeners",e)}},qr=(t={})=>{try{let e=Bt(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:i,type:s,handler:c}=e[r];i.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){n("component.events.unregisterListenersFix",e)}},Gt=qr;var Kt=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},ve(e),mt(this,e),this.data=gt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},i=this){let s=await Q(e,r,o,i);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=H(this.DOMNode);this.dom.virtual=r}let e=this.parent?R(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!S())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return jt(this,e);let r=this.onBeforeRender();Gt(this),Nt(this.instanceId);let o=N(this,{}),i=re(this.dom.virtual,o.virtual);i&&l(i)&&z("lifecycle.onBeforeMount",()=>{let s=i(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,Zt(this,this.renderMethods),this.setDOMNodeOnInstance(),z("domNodes",()=>{z("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return console.log("RENDER TO HTML",e),X(this,e)}onAfterRender(e={},r={}){S()||(Vt(e.instanceId,this),window.joystick._internal.css.update(),z("lifecycle.onUpdateProps"),r?.afterSetStateRender&&l(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&l(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=G(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&l(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[U()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[U()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=R(window.joystick._internal.tree,this.instanceId,"instanceId"),i=R(window.joystick._internal.tree,r,"instanceId");if(i?.instance?.DOMNode){let s=H(i?.instance?.DOMNode);qt(o?.instance?.dom?.virtual,i?.instanceId,s)}}},Wt=Kt;var sd=(t={})=>{try{return(e={})=>new Wt({...t,props:e?.props,url:e?.url,translations:e?.translations,api:e?.api,req:e?.req,parent:e?.parent})}catch(e){n("component",e)}};export{sd as default};
|
package/dist/index.js
CHANGED
|
@@ -18,4 +18,4 @@ var Mr=Object.create;var de=Object.defineProperty;var Sr=Object.getOwnPropertyDe
|
|
|
18
18
|
@media screen and (max-height: ${_}px) {
|
|
19
19
|
${typeof f=="function"?f(e):f}
|
|
20
20
|
}
|
|
21
|
-
`}}return r}return""}catch(r){i("component.css.compileCSS",r)}};var Vr=(t={},e=null)=>{try{let r=e(t);return r&&p(r)&&!I(r)?Object.assign({},r):{}}catch(r){i("component.state.compile.compileState",r)}},ee=(t={},e={})=>{try{return u(e)?Vr(t,e):Object.assign({},e)}catch(r){i("component.state.compile",r)}};var le={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var Rt=(t={},e={})=>{try{return e?Object.entries({...le,...e||{}}).reduce((r={},[o,n])=>(r[o]=()=>n({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):le}catch(r){i("component.lifecycle.compile",r)}};var te=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,n])=>(r[o]=(...s)=>n(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{i("component.methods.compile")}};var ue=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>O(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){i("component.url.compile",e)}};var Hr=(t={},e=null)=>{try{let r=e(t);return r&&p(r)&&!I(r)?Object.assign({},r):{}}catch(r){i("component.props.compileDefaultProps.compile",r)}},jt=(t={},e={})=>{try{return u(e)?Hr(t,e):Object.assign({},e)}catch(r){i("component.props.compileDefaultProps",r)}};var At=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=L(8),t.ssrId=e?._ssrId||null,t.css=X(),t.data=Y(e?.dataFromSSR,e?._componentId),t.defaultProps=jt(t,e?.defaultProps),t.props=_t(t?.defaultProps,e?.props),t.state=ee(t,e?.state),t.events=e?.events||{},t.lifecycle=Rt(t,e?.lifecycle),t.methods=te(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=Ct,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!F();if(r||(t.url=ue(e?.url)),r&&window.__joystick_url__&&(t.url=ue(window.__joystick_url__)),r&&e?.websockets&&u(e?.websockets)){let o=e.websockets(t),n=p(o)&&Object.entries(o);for(let s=0;s<n?.length;s+=1){let[a,c]=n[s];Q({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${a}`,options:c?.options||{},query:c?.query||{},events:c?.events||{}},(l={})=>{t.websockets={...t.websockets||{},[a]:l}})}}}catch(r){i("component.registerOptions",r)}};var Ur=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("addToQueue.getQueue",e)}},G=(t="",e=null)=>{try{F()||(Ur(t)||{}).array.push({callback:e})}catch(r){i("addToQueue",r)}};var re=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&u(o.options.data)){let n=await o.options.data(t,e,r,o);return Promise.resolve(n)}return Promise.resolve()}catch(n){i("component.data.fetch",n)}};var Dt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let n=await re(Z,e,o,r);return r.data=Dt(n,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=n),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){i("component.data.compile",o)}},Lt=Dt;var Pt=(t={})=>{try{if(!F()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return Lt(e,r,t)}return t?.data||{}}catch(e){i("component.loadDataFromWindow",e)}};var Vt=jr(It());var qt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(p(t)&&o){let n=Object.keys(t);for(let s=0;s<n.length;s+=1){let a=n[s],c=t[a];if(a===r&&c===e)return t;if(a==="children"&&Array.isArray(c))for(let l=0;l<c.length;l+=1){let y=c[l],w=qt(y,e,r);if(w!==null)return w}}}return null}catch(o){i("component.findComponentInTreeByField",o)}},j=qt;var Nt=(t="",e={},r=null)=>{let o=j(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var zr=(t={},e={},r=null)=>{try{let o=z(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){i("component.renderMethods.component.renderForClient",o)}},Br=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){i("component.renderMethods.component.renderToHTMLForSSR",e)}},Zr=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){i("component.renderMethods.component.collectDataFunctionsForSSR",e)}},Gr=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};Nt(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){i("component.renderMethods.component.handleAddComponentToParent",e)}},Wr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&G("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&G("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){i("component.renderMethods.component.handleLifecycle",r)}},Kr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Vt.diff)(e?.existingPropsMap,r)?.length>0&&G("lifecycle.onUpdateProps",()=>{let n=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(n||{},r,t)})}catch(o){i("component.renderMethods.component.handleOnChangeProps",o)}},Jr=function(){return function(e=null,r={},o={}){let n=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[n.id]||{},a=o.children[n.id]||[],c=s[a?.length];return n.state=c?.state||n.state,o.children[n.id]=[...o.children[n.id]||[],n],n.parent=o,Kr(n,o,r),G("lifecycle.onMount",()=>{n.setDOMNodeOnInstance()}),Wr(this,n),n.parent&&Gr(n),n.options.data&&n.parent.walkingTreeForSSR&&n.parent.ssrTree.dataFunctions?Zr(n):n.parent&&n.parent.ssrTree?Br(n):zr(n,this,c?.children)}},Qr=function(e,r){try{let o=this;return new Jr().bind({})(e,r,o)}catch(o){i("component.renderMethods.component",o)}},pe=Qr;var Yr=function(e=[],r=null){try{return u(r)&&e&&Array.isArray(e)?e.map((o,n)=>r(o,n)).join(""):""}catch(o){i("component.renderMethods.each",o)}},me=Yr;var Xr=(t="",e=[])=>{try{return e.reduce((r,[o,n])=>r.replace(`{{${o}}}`,n),t)}catch(r){i("component.renderMethods.i18n.replacePlaceholdersInString",r)}},fe=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),n=typeof t=="object"&&!o;if(r)return Xr(t,e);if(o)return t?.map(s=>fe(s,e));if(n)return Object.entries(t)?.reduce((s={},[a,c])=>(s[a]=fe(c,e),s),{})}catch(r){i("component.renderMethods.i18n.handleTranslationReplacement",r)}},eo=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>(console.log({key:t,objectToTraverse:r,keyToMatch:o}),r[o]),e)}catch(r){i("component.renderMethods.i18n.getTranslationAtPath",r)}},to=function(t="",e={}){try{let r=F()?this.translations:window.__joystick_i18n__,n=t?.includes(".")?eo(t,r):r[t];if(t?.includes("creatorDashboard")&&console.log({key:t,replacements:e,translation:n,translations:r}),!r||!n)return"";let s=Object.entries(e);return fe(n,s)}catch(r){i("component.renderMethods.i18n",r)}},he=to;var ro=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){i("component.renderMethods.when",o)}},we=ro;var Ht={c:pe,component:pe,e:me,each:me,i:he,i18n:he,w:we,when:we};var Ut=(t={},e={})=>{try{return Object.entries(Ht).reduce((r,[o,n])=>(r[o]=n.bind({...t,...e}),r),{})}catch(r){i("component.renderMethods.compile",r)}};var zt=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((n={})=>({state:n?.state,children:zt(n?.children)})),e),{})}catch(e){i("component.render.getExistingStateMap.buildMapForChildren",e)}},Bt=(t={})=>{try{return zt(t)}catch(e){i("component.render.getExistingStateMap",e)}};var Zt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),oo=new RegExp(/\n/g);var no=(t="")=>{try{return(t.match(Zt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){i("component.render.sanitizeHTML.removeCommentedCode",e)}},Gt=(t="")=>{try{let e=`${t}`;return e=no(e),e}catch(e){i("component.render.sanitizeHTML",e)}};var Wt=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:n=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${n}">${e}</div>`}catch(r){i("component.render.wrapHTML",r)}};var Kt=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let n=0;n<o?.length;n+=1){let[s,a]=o[n];for(let c=0;c<a?.length;c+=1){let l=a[c];Object.entries(l?.timers)?.length>0&&r.push(...Object.values(l?.timers)),Object.entries(l?.children)?.length>0&&Kt(l?.children,r)}}if(r?.length>0)for(let n=0;n<r?.length;n+=1)clearTimeout(r[n])}catch(r){i("component.render.clearTimersOnChildren",r)}},Jt=Kt;var ne=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=Y(e.dataFromSSR,t.id)||{}),Jt(t?.children);let r=Bt(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Ut({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=te(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),n=Gt(o),s=Wt(t,n);return{unwrapped:n,wrapped:s}}catch(r){i("component.render.toHTML",r)}};var io=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){i("component.virtualDOM.build.parseAttributeMap",e)}},Qt=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Qt(e):ye(e)):ye(t)}catch(e){i("component.virtualDOM.build.flattenWhenTags",e)}},ye=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:io(t.attributes),children:[].flatMap.call(t.childNodes,o=>Qt(o))};return e==="text"&&(r=t.textContent),r}catch(e){i("component.virtualDOM.build",e)}},W=ye;var so=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){i("component.virtualDOM.build.convertHTMLToDOM",e)}},Yt=(t="")=>{try{let e=so(t);return W(e)}catch(e){i("component.virtualDOM.build",e)}};var Xt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var ao=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[n,s]=r[o];Xt(n)&&e.setAttribute(n,s)}for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(n){let s=er(n);e.appendChild(s)}}return e}catch(e){i("component.virtualDOM.renderTreeToDOM.renderElement",e)}},er=(t=null)=>{try{return O(t)?document.createTextNode(t):ao(t)}catch(e){i("component.virtualDOM.renderTreeToDOM",e)}},B=er;var z=(t={},e={})=>{try{let r=ne(t,{existingChildren:e?.existingChildren}),o=Yt(r.wrapped,t),n=e.includeActual&&o?B(o):null;return{html:r,virtual:o,actual:n}}catch(r){i("component.render.getUpdatedDOM",r)}};var tr=(t={},e={})=>{try{let r=z(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){i("component.render.forMount",r)}};var co=(t={},e={})=>{let r=[];for(let[o,n]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,n),s));for(let o in t)o in e||r.push(n=>(n&&n.removeAttribute&&n.removeAttribute(o),n));return o=>{for(let n of r)n&&typeof n=="function"&&n(o)}},ie=co;var lo=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let n=0;n<o;n+=1){let s=t[n],a=e[n];r.push([s,a])}return r},rr=lo;var uo=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},po=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},mo=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(n=>{let s=a=>{let c=B(n);return a.appendChild(c),a};r.push(s)}),r},fo=(t=[],e=[])=>{let r=[];return t.forEach((o,n)=>{let s=ae(o,e[n]);r.push(s)}),r},ho=(t=[],e=[])=>{let r=fo(t,e),o=mo(t,e);return n=>{if(n){let s=rr(r,n.childNodes);po(s),uo(o,n)}return n}},se=ho;var or={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ie(t.attributes,e.attributes)(r),se([],e.children)(r);let n=r.querySelector(`option[value="${o}"]`);if(n&&(r.value=o),!n){let s=r.querySelector("option");r.value=s?.value||""}return r}};var ge=(t,e)=>r=>{let o=t?B(t):null;return r&&r.replaceWith(o),o},wo=()=>t=>{t&&t.remove()},yo=(t=void 0,e=void 0)=>t===void 0||e===void 0?wo():typeof t=="string"||typeof e=="string"?ge(e,t):t.tagName!==e.tagName?ge(e):e.tagName==="select"?or.select(t,e):["pre","code"].includes(e.tagName)?ge(e,t):n=>(ie(t.attributes,e.attributes)(n),se(t.children,e.children)(n),n),ae=yo;var go=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("processQueue.getQueue",e)}},q=(t="",e=null)=>{try{F()||(go(t)||{}).process(e)}catch(r){i("processQueue",r)}};var nr=(t="",e=null)=>{let r=j(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var ir=(t="",e={},r=null)=>{let o=j(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var sr=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(p(n)&&n.attributes&&n.attributes["js-i"]&&n.attributes["js-i"]===e){t.children[o]=r;break}p(n)&&sr(n,e,r)}},ar=sr;var cr=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...n]=e.split(" ");return{type:o.toLowerCase(),selector:n.join(" "),handler:r}})}catch(e){i("component.events.serialize",e)}};var dr=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?cr(t?.events):[];for(let n=0;n<o?.length;n+=1){let s=o[n];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(c){s.handler(c,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let n=Object.entries(t?.children)?.flatMap(([s,a])=>a);for(let s=0;s<n?.length;s+=1){let a=n[s];dr(a,e,r)}}return r}catch(o){i("component.eve!nts.registerListenersFix.getListeners",o)}},xo=(t={},e={})=>{try{let o=dr(t,e,[])?.flatMap((n={})=>[].flatMap.call(n?.elements||[],s=>{let{elements:a=[],...c}=n||{};return{...c,element:s}}));for(let n=0;n<o?.length;n+=1){let{instance:s,element:a,elementSelector:c,type:l,handler:y}=o[n];a.addEventListener(l,y),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:a,elementSelector:c,type:l,handler:y}]}}catch(r){i("component.events.registerListenersFix",r)}},ce=xo;var lr=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((n=[],s=[])=>[...n,...s],[])).flatMap((n={})=>lr(n));e=[...e,...o]}return e}catch(e){i("component.events.unregisterListenersFix.getListeners",e)}},bo=(t={})=>{try{let e=lr(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:n,type:s,handler:a}=e[r];n.removeEventListener(s,a),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){i("component.events.unregisterListenersFix",e)}},ur=bo;var pr=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},rt(e),At(this,e),this.data=Pt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},n=this){let s=await re(e,r,o,n);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=W(this.DOMNode);this.dom.virtual=r}let e=this.parent?j(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!F())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return tr(this,e);let r=this.onBeforeRender();ur(this),nr(this.instanceId);let o=z(this,{}),n=ae(this.dom.virtual,o.virtual);n&&u(n)&&q("lifecycle.onBeforeMount",()=>{let s=n(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,ce(this,this.renderMethods),this.setDOMNodeOnInstance(),q("domNodes",()=>{q("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return ne(this,e)}onAfterRender(e={},r={}){F()||(ir(e.instanceId,this),window.joystick._internal.css.update(),q("lifecycle.onUpdateProps"),r?.afterSetStateRender&&u(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&u(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=ee(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&u(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[L()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[L()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=j(window.joystick._internal.tree,this.instanceId,"instanceId"),n=j(window.joystick._internal.tree,r,"instanceId");if(n?.instance?.DOMNode){let s=W(n?.instance?.DOMNode);ar(o?.instance?.dom?.virtual,n?.instanceId,s)}}},mr=pr;var fr=(t={})=>{try{return(e={})=>new mr({...t,props:e?.props,url:e?.url,translations:e?.translations,api:e?.api,req:e?.req,parent:e?.parent})}catch(e){i("component",e)}};var hr=(t={})=>{try{window.joystick._internal.tree={id:t?.id||null,instanceId:t?.instanceId||null,instance:t,children:[]}}catch(e){i("mount.initializeJoystickComponentTree",e)}};var wr=(t={},e=null)=>{try{return t.innerHTML="",t.appendChild(e),e}catch(r){i("mount.appendToDOM",r)}};var yr=(t=null,e={},r=null)=>{try{u(t)||i("mount","Component to mount must be a function."),p(e)||i("mount","props must be an object."),ve(r)||i("mount","target must be a DOM node.");let o=t({props:e});hr(o);let n=o.render({mounting:!0,existingChildren:window.__joystick_childrenBeforeHMRUpdate__||null});return n&&(n.setAttribute("js-c",o.id),n.setAttribute("js-i",o.instanceId)),o.lifecycle.onBeforeMount(),q("lifecycle.onBeforeMount"),wr(r,n),o.setDOMNodeOnInstance(),window.joystick._internal.css.update(),ce(o,o.renderMethods),o.lifecycle.onMount(),q("lifecycle.onMount"),o}catch(o){i("mount",o)}};var gr=class{constructor(e=[]){this.array=[...e],this.array.push=function(){Array.prototype.push.apply(this,arguments)}}async process(e=null){if(this.array.length>0){let r=this.array.shift();r&&r.callback&&(await r.callback(),this.process(e))}else e&&e()}},N=gr;var Eo=new RegExp(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g),$o=new RegExp(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g),Fo=(t,e)=>(e||"").replace(Eo,()=>"").replace($o,r=>["@",": "].some(o=>r?.includes(o))?r:`[js-c="${t}"] ${r.trim()}`)?.trim(),xr=(t={},e=[])=>{if(t.instance&&t.instance.options&&t.instance.options.css){let r=t.instance.id,o=t.instance.options.css,n=X(o,t.instance),s=Fo(r,n);e.push(s)}if(t.children&&t.children.length>0){let r=t?.children?.length||0;for(;r--;)xr(t.children[r],e)}return e},br=xr;var Er=()=>{try{let t=document.head.querySelector("style[js-styles]"),r=br(window.joystick?._internal?.tree).reverse().join("").trim();if(t?.innerText===r)return;if(t&&(t.innerHTML=r),!t){let o=document.createElement("style");o.setAttribute("js-styles",""),o.innerHTML=r,document.head.appendChild(o)}}catch(t){i("css.update",t)}};var ko=Se,Mo=Re,So=Z.get,To=je,Oo=Ae,vo=Z.set,Co=Pe,$r=()=>typeof window!="undefined"?window.__joystick_env__:typeof process!="undefined"?"production":null,Fr={_external:{},_internal:{css:{update:Er},queues:{domNodes:new N([]),eventListeners:new N([]),lifecycle:{onBeforeMount:new N([]),onMount:new N([]),onUpdateProps:new N([])},render:new N([])},tree:{},eventListeners:[]},accounts:ko,cache:Mo,component:fr,env:{development:$r()==="development",test:$r()==="test"},get:So,html:To,id:L,mount:yr,renderComponentToHTML:Oo,set:vo,upload:Co,timers:{}};Ie(Fr);var gl=Fr;export{ko as accounts,Mo as cache,gl as default,So as get,To as html,Oo as renderComponentToHTML,vo as set,Co as upload};
|
|
21
|
+
`}}return r}return""}catch(r){i("component.css.compileCSS",r)}};var Vr=(t={},e=null)=>{try{let r=e(t);return r&&p(r)&&!I(r)?Object.assign({},r):{}}catch(r){i("component.state.compile.compileState",r)}},ee=(t={},e={})=>{try{return u(e)?Vr(t,e):Object.assign({},e)}catch(r){i("component.state.compile",r)}};var le={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var Rt=(t={},e={})=>{try{return e?Object.entries({...le,...e||{}}).reduce((r={},[o,n])=>(r[o]=()=>n({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):le}catch(r){i("component.lifecycle.compile",r)}};var te=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,n])=>(r[o]=(...s)=>n(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{})}catch{i("component.methods.compile")}};var ue=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>O(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){i("component.url.compile",e)}};var Hr=(t={},e=null)=>{try{let r=e(t);return r&&p(r)&&!I(r)?Object.assign({},r):{}}catch(r){i("component.props.compileDefaultProps.compile",r)}},jt=(t={},e={})=>{try{return u(e)?Hr(t,e):Object.assign({},e)}catch(r){i("component.props.compileDefaultProps",r)}};var At=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=L(8),t.ssrId=e?._ssrId||null,t.css=X(),t.data=Y(e?.dataFromSSR,e?._componentId),t.defaultProps=jt(t,e?.defaultProps),t.props=_t(t?.defaultProps,e?.props),t.state=ee(t,e?.state),t.events=e?.events||{},t.lifecycle=Rt(t,e?.lifecycle),t.methods=te(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=Ct,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!F();if(r||(t.url=ue(e?.url)),r&&window.__joystick_url__&&(t.url=ue(window.__joystick_url__)),r&&e?.websockets&&u(e?.websockets)){let o=e.websockets(t),n=p(o)&&Object.entries(o);for(let s=0;s<n?.length;s+=1){let[a,c]=n[s];Q({url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${a}`,options:c?.options||{},query:c?.query||{},events:c?.events||{}},(l={})=>{t.websockets={...t.websockets||{},[a]:l}})}}}catch(r){i("component.registerOptions",r)}};var Ur=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("addToQueue.getQueue",e)}},G=(t="",e=null)=>{try{F()||(Ur(t)||{}).array.push({callback:e})}catch(r){i("addToQueue",r)}};var re=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&u(o.options.data)){let n=await o.options.data(t,e,r,o);return Promise.resolve(n)}return Promise.resolve()}catch(n){i("component.data.fetch",n)}};var Dt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{let n=await re(Z,e,o,r);return r.data=Dt(n,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=n),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){i("component.data.compile",o)}},Lt=Dt;var Pt=(t={})=>{try{if(!F()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return Lt(e,r,t)}return t?.data||{}}catch(e){i("component.loadDataFromWindow",e)}};var Vt=jr(It());var qt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(p(t)&&o){let n=Object.keys(t);for(let s=0;s<n.length;s+=1){let a=n[s],c=t[a];if(a===r&&c===e)return t;if(a==="children"&&Array.isArray(c))for(let l=0;l<c.length;l+=1){let y=c[l],w=qt(y,e,r);if(w!==null)return w}}}return null}catch(o){i("component.findComponentInTreeByField",o)}},j=qt;var Nt=(t="",e={},r=null)=>{let o=j(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var zr=(t={},e={},r=null)=>{try{let o=z(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){i("component.renderMethods.component.renderForClient",o)}},Br=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){i("component.renderMethods.component.renderToHTMLForSSR",e)}},Zr=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){i("component.renderMethods.component.collectDataFunctionsForSSR",e)}},Gr=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};Nt(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){i("component.renderMethods.component.handleAddComponentToParent",e)}},Wr=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&G("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e)}),!t.renderedComponent&&e.options.lifecycle.onMount&&G("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e)}))}catch(r){i("component.renderMethods.component.handleLifecycle",r)}},Kr=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Vt.diff)(e?.existingPropsMap,r)?.length>0&&G("lifecycle.onUpdateProps",()=>{let n=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(n||{},r,t)})}catch(o){i("component.renderMethods.component.handleOnChangeProps",o)}},Jr=function(){return function(e=null,r={},o={}){let n=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[n.id]||{},a=o.children[n.id]||[],c=s[a?.length];return n.state=c?.state||n.state,o.children[n.id]=[...o.children[n.id]||[],n],n.parent=o,Kr(n,o,r),G("lifecycle.onMount",()=>{n.setDOMNodeOnInstance()}),Wr(this,n),n.parent&&Gr(n),n.options.data&&n.parent.walkingTreeForSSR&&n.parent.ssrTree.dataFunctions?Zr(n):n.parent&&n.parent.ssrTree?Br(n):zr(n,this,c?.children)}},Qr=function(e,r){try{let o=this;return new Jr().bind({})(e,r,o)}catch(o){i("component.renderMethods.component",o)}},pe=Qr;var Yr=function(e=[],r=null){try{return u(r)&&e&&Array.isArray(e)?e.map((o,n)=>r(o,n)).join(""):""}catch(o){i("component.renderMethods.each",o)}},me=Yr;var Xr=(t="",e=[])=>{try{return e.reduce((r,[o,n])=>r.replace(`{{${o}}}`,n),t)}catch(r){i("component.renderMethods.i18n.replacePlaceholdersInString",r)}},fe=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),n=typeof t=="object"&&!o;if(r)return Xr(t,e);if(o)return t?.map(s=>fe(s,e));if(n)return Object.entries(t)?.reduce((s={},[a,c])=>(s[a]=fe(c,e),s),{})}catch(r){i("component.renderMethods.i18n.handleTranslationReplacement",r)}},eo=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>(console.log({key:t,objectToTraverse:r,keyToMatch:o}),r[o]),e)}catch(r){i("component.renderMethods.i18n.getTranslationAtPath",r)}},to=function(t="",e={}){try{let r=F()?this.translations:window.__joystick_i18n__,n=t?.includes(".")?eo(t,r):r[t];if(t?.includes("creatorDashboard")&&console.log({key:t,replacements:e,translation:n,translations:r}),!r||!n)return"";let s=Object.entries(e);return fe(n,s)}catch(r){i("component.renderMethods.i18n",r)}},he=to;var ro=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){i("component.renderMethods.when",o)}},we=ro;var Ht={c:pe,component:pe,e:me,each:me,i:he,i18n:he,w:we,when:we};var Ut=(t={},e={})=>{try{return Object.entries(Ht).reduce((r,[o,n])=>(r[o]=n.bind({...t,...e}),r),{})}catch(r){i("component.renderMethods.compile",r)}};var zt=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((n={})=>({state:n?.state,children:zt(n?.children)})),e),{})}catch(e){i("component.render.getExistingStateMap.buildMapForChildren",e)}},Bt=(t={})=>{try{return zt(t)}catch(e){i("component.render.getExistingStateMap",e)}};var Zt=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),oo=new RegExp(/\n/g);var no=(t="")=>{try{return(t.match(Zt)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){i("component.render.sanitizeHTML.removeCommentedCode",e)}},Gt=(t="")=>{try{let e=`${t}`;return e=no(e),e}catch(e){i("component.render.sanitizeHTML",e)}};var Wt=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:n=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${n}">${e}</div>`}catch(r){i("component.render.wrapHTML",r)}};var Kt=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let n=0;n<o?.length;n+=1){let[s,a]=o[n];for(let c=0;c<a?.length;c+=1){let l=a[c];Object.entries(l?.timers)?.length>0&&r.push(...Object.values(l?.timers)),Object.entries(l?.children)?.length>0&&Kt(l?.children,r)}}if(r?.length>0)for(let n=0;n<r?.length;n+=1)clearTimeout(r[n])}catch(r){i("component.render.clearTimersOnChildren",r)}},Jt=Kt;var ne=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=Y(e.dataFromSSR,t.id)||{}),Jt(t?.children);let r=Bt(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Ut({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=te(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),n=Gt(o),s=Wt(t,n);return{unwrapped:n,wrapped:s}}catch(r){i("component.render.toHTML",r)}};var io=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){i("component.virtualDOM.build.parseAttributeMap",e)}},Qt=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?Qt(e):ye(e)):ye(t)}catch(e){i("component.virtualDOM.build.flattenWhenTags",e)}},ye=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:io(t.attributes),children:[].flatMap.call(t.childNodes,o=>Qt(o))};return e==="text"&&(r=t.textContent),r}catch(e){i("component.virtualDOM.build",e)}},W=ye;var so=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){i("component.virtualDOM.build.convertHTMLToDOM",e)}},Yt=(t="")=>{try{let e=so(t);return W(e)}catch(e){i("component.virtualDOM.build",e)}};var Xt=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var ao=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[n,s]=r[o];Xt(n)&&e.setAttribute(n,s)}for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(n){let s=er(n);e.appendChild(s)}}return e}catch(e){i("component.virtualDOM.renderTreeToDOM.renderElement",e)}},er=(t=null)=>{try{return O(t)?document.createTextNode(t):ao(t)}catch(e){i("component.virtualDOM.renderTreeToDOM",e)}},B=er;var z=(t={},e={})=>{try{let r=ne(t,{existingChildren:e?.existingChildren}),o=Yt(r.wrapped,t),n=e.includeActual&&o?B(o):null;return{html:r,virtual:o,actual:n}}catch(r){i("component.render.getUpdatedDOM",r)}};var tr=(t={},e={})=>{try{let r=z(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){i("component.render.forMount",r)}};var co=(t={},e={})=>{let r=[];for(let[o,n]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,n),s));for(let o in t)o in e||r.push(n=>(n&&n.removeAttribute&&n.removeAttribute(o),n));return o=>{for(let n of r)n&&typeof n=="function"&&n(o)}},ie=co;var lo=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let n=0;n<o;n+=1){let s=t[n],a=e[n];r.push([s,a])}return r},rr=lo;var uo=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},po=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},mo=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(n=>{let s=a=>{let c=B(n);return a.appendChild(c),a};r.push(s)}),r},fo=(t=[],e=[])=>{let r=[];return t.forEach((o,n)=>{let s=ae(o,e[n]);r.push(s)}),r},ho=(t=[],e=[])=>{let r=fo(t,e),o=mo(t,e);return n=>{if(n){let s=rr(r,n.childNodes);po(s),uo(o,n)}return n}},se=ho;var or={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),ie(t.attributes,e.attributes)(r),se([],e.children)(r);let n=r.querySelector(`option[value="${o}"]`);if(n&&(r.value=o),!n){let s=r.querySelector("option");r.value=s?.value||""}return r}};var ge=(t,e)=>r=>{let o=t?B(t):null;return r&&r.replaceWith(o),o},wo=()=>t=>{t&&t.remove()},yo=(t=void 0,e=void 0)=>t===void 0||e===void 0?wo():typeof t=="string"||typeof e=="string"?ge(e,t):t.tagName!==e.tagName?ge(e):e.tagName==="select"?or.select(t,e):["pre","code"].includes(e.tagName)?ge(e,t):n=>(ie(t.attributes,e.attributes)(n),se(t.children,e.children)(n),n),ae=yo;var go=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("processQueue.getQueue",e)}},q=(t="",e=null)=>{try{F()||(go(t)||{}).process(e)}catch(r){i("processQueue",r)}};var nr=(t="",e=null)=>{let r=j(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var ir=(t="",e={},r=null)=>{let o=j(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var sr=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(p(n)&&n.attributes&&n.attributes["js-i"]&&n.attributes["js-i"]===e){t.children[o]=r;break}p(n)&&sr(n,e,r)}},ar=sr;var cr=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...n]=e.split(" ");return{type:o.toLowerCase(),selector:n.join(" "),handler:r}})}catch(e){i("component.events.serialize",e)}};var dr=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?cr(t?.events):[];for(let n=0;n<o?.length;n+=1){let s=o[n];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(c){s.handler(c,{...t||{},setState:t?.setState.bind(t),...e||{}})}})}if(t?.children){let n=Object.entries(t?.children)?.flatMap(([s,a])=>a);for(let s=0;s<n?.length;s+=1){let a=n[s];dr(a,e,r)}}return r}catch(o){i("component.eve!nts.registerListenersFix.getListeners",o)}},xo=(t={},e={})=>{try{let o=dr(t,e,[])?.flatMap((n={})=>[].flatMap.call(n?.elements||[],s=>{let{elements:a=[],...c}=n||{};return{...c,element:s}}));for(let n=0;n<o?.length;n+=1){let{instance:s,element:a,elementSelector:c,type:l,handler:y}=o[n];a.addEventListener(l,y),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:a,elementSelector:c,type:l,handler:y}]}}catch(r){i("component.events.registerListenersFix",r)}},ce=xo;var lr=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((n=[],s=[])=>[...n,...s],[])).flatMap((n={})=>lr(n));e=[...e,...o]}return e}catch(e){i("component.events.unregisterListenersFix.getListeners",e)}},bo=(t={})=>{try{let e=lr(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:n,type:s,handler:a}=e[r];n.removeEventListener(s,a),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){i("component.events.unregisterListenersFix",e)}},ur=bo;var pr=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},rt(e),At(this,e),this.data=Pt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},n=this){let s=await re(e,r,o,n);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=W(this.DOMNode);this.dom.virtual=r}let e=this.parent?j(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!F())return{instanceId:this.instanceId}}render(e={}){if(e?.mounting)return tr(this,e);let r=this.onBeforeRender();ur(this),nr(this.instanceId);let o=z(this,{}),n=ae(this.dom.virtual,o.virtual);n&&u(n)&&q("lifecycle.onBeforeMount",()=>{let s=n(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,ce(this,this.renderMethods),this.setDOMNodeOnInstance(),q("domNodes",()=>{q("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return console.log("RENDER TO HTML",e),ne(this,e)}onAfterRender(e={},r={}){F()||(ir(e.instanceId,this),window.joystick._internal.css.update(),q("lifecycle.onUpdateProps"),r?.afterSetStateRender&&u(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&u(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){this.state=ee(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&u(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[L()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[L()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=j(window.joystick._internal.tree,this.instanceId,"instanceId"),n=j(window.joystick._internal.tree,r,"instanceId");if(n?.instance?.DOMNode){let s=W(n?.instance?.DOMNode);ar(o?.instance?.dom?.virtual,n?.instanceId,s)}}},mr=pr;var fr=(t={})=>{try{return(e={})=>new mr({...t,props:e?.props,url:e?.url,translations:e?.translations,api:e?.api,req:e?.req,parent:e?.parent})}catch(e){i("component",e)}};var hr=(t={})=>{try{window.joystick._internal.tree={id:t?.id||null,instanceId:t?.instanceId||null,instance:t,children:[]}}catch(e){i("mount.initializeJoystickComponentTree",e)}};var wr=(t={},e=null)=>{try{return t.innerHTML="",t.appendChild(e),e}catch(r){i("mount.appendToDOM",r)}};var yr=(t=null,e={},r=null)=>{try{u(t)||i("mount","Component to mount must be a function."),p(e)||i("mount","props must be an object."),ve(r)||i("mount","target must be a DOM node.");let o=t({props:e});hr(o);let n=o.render({mounting:!0,existingChildren:window.__joystick_childrenBeforeHMRUpdate__||null});return n&&(n.setAttribute("js-c",o.id),n.setAttribute("js-i",o.instanceId)),o.lifecycle.onBeforeMount(),q("lifecycle.onBeforeMount"),wr(r,n),o.setDOMNodeOnInstance(),window.joystick._internal.css.update(),ce(o,o.renderMethods),o.lifecycle.onMount(),q("lifecycle.onMount"),o}catch(o){i("mount",o)}};var gr=class{constructor(e=[]){this.array=[...e],this.array.push=function(){Array.prototype.push.apply(this,arguments)}}async process(e=null){if(this.array.length>0){let r=this.array.shift();r&&r.callback&&(await r.callback(),this.process(e))}else e&&e()}},N=gr;var Eo=new RegExp(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g),$o=new RegExp(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g),Fo=(t,e)=>(e||"").replace(Eo,()=>"").replace($o,r=>["@",": "].some(o=>r?.includes(o))?r:`[js-c="${t}"] ${r.trim()}`)?.trim(),xr=(t={},e=[])=>{if(t.instance&&t.instance.options&&t.instance.options.css){let r=t.instance.id,o=t.instance.options.css,n=X(o,t.instance),s=Fo(r,n);e.push(s)}if(t.children&&t.children.length>0){let r=t?.children?.length||0;for(;r--;)xr(t.children[r],e)}return e},br=xr;var Er=()=>{try{let t=document.head.querySelector("style[js-styles]"),r=br(window.joystick?._internal?.tree).reverse().join("").trim();if(t?.innerText===r)return;if(t&&(t.innerHTML=r),!t){let o=document.createElement("style");o.setAttribute("js-styles",""),o.innerHTML=r,document.head.appendChild(o)}}catch(t){i("css.update",t)}};var ko=Se,Mo=Re,So=Z.get,To=je,Oo=Ae,vo=Z.set,Co=Pe,$r=()=>typeof window!="undefined"?window.__joystick_env__:typeof process!="undefined"?"production":null,Fr={_external:{},_internal:{css:{update:Er},queues:{domNodes:new N([]),eventListeners:new N([]),lifecycle:{onBeforeMount:new N([]),onMount:new N([]),onUpdateProps:new N([])},render:new N([])},tree:{},eventListeners:[]},accounts:ko,cache:Mo,component:fr,env:{development:$r()==="development",test:$r()==="test"},get:So,html:To,id:L,mount:yr,renderComponentToHTML:Oo,set:vo,upload:Co,timers:{}};Ie(Fr);var gl=Fr;export{ko as accounts,Mo as cache,gl as default,So as get,To as html,Oo as renderComponentToHTML,vo as set,Co as upload};
|
package/package.json
CHANGED