@kizenapps/cli 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/electron/main.js +9 -8
- package/dist/electron/main.js.map +1 -1
- package/dist/index.js +293 -58
- package/dist/index.js.map +1 -1
- package/dist/viewer/assets/index-B09qenTV.js +17 -0
- package/dist/viewer/assets/{index-C_6izRRh.js → index-CVd4BLit.js} +2 -2
- package/dist/viewer/assets/{index-CBBwr2o_.js → index-C_gRcfsL.js} +2 -2
- package/dist/viewer/assets/index-CcvbGL5I.js +17 -0
- package/dist/viewer/assets/index-Ci5up9QD.js +17 -0
- package/dist/viewer/assets/index-DOiSISo1.css +2 -0
- package/dist/viewer/assets/{index-DcGGXuA3.js → index-DSJAwx9Y.js} +2 -2
- package/dist/viewer/assets/index-WnCF0zx3.js +17 -0
- package/dist/viewer/assets/{index--m1PKX6N.js → index-_K33TupM.js} +2 -2
- package/dist/viewer/assets/index-dPV4go8k.js +17 -0
- package/dist/viewer/assets/index-xFuxlPJA.js +17 -0
- package/dist/viewer/index.html +2 -2
- package/package.json +1 -1
- package/dist/viewer/assets/index-2OcBnmZB.js +0 -17
- package/dist/viewer/assets/index-7ah1RuPy.js +0 -17
- package/dist/viewer/assets/index-B3gNsKTt.js +0 -17
- package/dist/viewer/assets/index-B40AtXqk.js +0 -17
- package/dist/viewer/assets/index-B4ikC-wc.js +0 -17
- package/dist/viewer/assets/index-BKOfPpLS.js +0 -17
- package/dist/viewer/assets/index-BM3JrC-1.js +0 -17
- package/dist/viewer/assets/index-BUnK11-F.js +0 -17
- package/dist/viewer/assets/index-Bc7IZVr6.js +0 -17
- package/dist/viewer/assets/index-C1KzcpVj.js +0 -17
- package/dist/viewer/assets/index-CHtXWYIY.js +0 -17
- package/dist/viewer/assets/index-CN9NvJkQ.js +0 -17
- package/dist/viewer/assets/index-CNKPBxhv.js +0 -17
- package/dist/viewer/assets/index-CgzK6zig.js +0 -17
- package/dist/viewer/assets/index-Cw2cxYy2.js +0 -17
- package/dist/viewer/assets/index-D06uhGtQ.js +0 -17
- package/dist/viewer/assets/index-DAHWT-g0.js +0 -17
- package/dist/viewer/assets/index-DAxJgHat.js +0 -17
- package/dist/viewer/assets/index-DF_geUaW.js +0 -17
- package/dist/viewer/assets/index-DlVmY-nR.js +0 -17
- package/dist/viewer/assets/index-FZw9Ev_R.js +0 -17
- package/dist/viewer/assets/index-M1Obm_99.js +0 -17
- package/dist/viewer/assets/index-_kM1Ri7v.js +0 -17
- package/dist/viewer/assets/index-aTt_sTlu.js +0 -17
- package/dist/viewer/assets/index-vYFGGFc2.js +0 -17
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,t}from"./rolldown-runtime-DF2fYuay.js";import{C as n,S as r,_ as i,a,b as o,c as s,d as c,f as l,g as u,h as d,i as f,l as p,m,n as h,o as g,p as _,r as v,s as y,t as b,u as x,v as S,x as C,y as w}from"./fa-core-BU3ZZt7W.js";import{n as T,t as E}from"./react-C90crogl.js";import{$ as D,$i as O,$n as k,$r as A,$t as j,A as M,Ai as N,An as P,Ar as F,At as I,B as L,Bi as R,Bn as z,Br as B,Bt as V,C as ee,Ci as te,Cn as H,Cr as ne,Ct as re,D as ie,Di as ae,Dn as oe,Dr as se,Dt as ce,E as le,Ei as ue,En as de,Er as fe,Et as pe,F as me,Fi as he,Fn as ge,Fr as _e,Ft as ve,G as ye,Gi as be,Gn as xe,Gr as Se,Gt as Ce,H as we,Hi as Te,Hn as Ee,Hr as De,Ht as Oe,I as ke,Ii as Ae,In as je,Ir as Me,It as Ne,J as Pe,Ji as Fe,Jn as Ie,Jr as U,Jt as Le,K as Re,Ki as ze,Kn as Be,Kr as Ve,Kt as He,L as Ue,Li as We,Ln as Ge,Lr as Ke,Lt as qe,M as Je,Mi as Ye,Mn as Xe,Mr as Ze,Mt as Qe,N as $e,Ni as et,Nn as tt,Nr as nt,Nt as rt,O as it,Oi as at,On as ot,Or as st,Ot as ct,P as lt,Pi as ut,Pn as dt,Pr as ft,Pt as pt,Q as mt,Qi as ht,Qn as gt,Qr as _t,Qt as vt,R as yt,Ri as bt,Rn as xt,Rr as St,Rt as Ct,S as wt,Sa as Tt,Si as Et,Sn as Dt,Sr as Ot,St as kt,T as At,Ti as jt,Tn as Mt,Tr as Nt,Tt as Pt,U as Ft,Ui as It,Un as Lt,Ur as Rt,Ut as zt,V as Bt,Vi as Vt,Vn as Ht,Vr as Ut,Vt as Wt,W as Gt,Wi as Kt,Wn as qt,Wr as Jt,Wt as Yt,X as Xt,Xi as Zt,Xn as Qt,Xr as $t,Xt as en,Y as tn,Yi as nn,Yn as rn,Yr as an,Yt as on,Z as sn,Zi as cn,Zn as ln,Zr as un,Zt as dn,_ as fn,_a as pn,_i as mn,_n as hn,_r as gn,_t as _n,a as vn,aa as yn,ai as bn,an as xn,ar as Sn,at as Cn,b as wn,ba as Tn,bi as En,bn as Dn,br as On,bt as kn,c as An,ca as jn,ci as Mn,cn as Nn,cr as Pn,ct as Fn,d as In,da as Ln,di as Rn,dn as zn,dr as Bn,dt as Vn,ea as Hn,ei as Un,en as Wn,er as Gn,et as Kn,f as qn,fa as Jn,fi as Yn,fn as Xn,fr as Zn,ft as Qn,g as $n,ga as er,gi as tr,gn as nr,gr as rr,gt as ir,h as ar,ha as or,hi as sr,hn as cr,hr as lr,ht as ur,i as dr,ia as fr,ii as pr,in as mr,ir as hr,it as gr,j as _r,ji as vr,jn as yr,jr as br,jt as xr,k as Sr,ki as Cr,kn as wr,kr as Tr,kt as Er,l as Dr,la as Or,li as kr,ln as Ar,lr as jr,lt as Mr,m as Nr,ma as Pr,mi as Fr,mn as Ir,mr as Lr,mt as Rr,n as zr,na as Br,ni as Vr,nn as Hr,nr as Ur,nt as Wr,o as Gr,oa as Kr,oi as qr,on as Jr,or as Yr,ot as Xr,p as Zr,pa as Qr,pi as $r,pn as ei,pr as ti,pt as ni,q as ri,qi as ii,qn as ai,qr as oi,qt as si,r as ci,ra as li,ri as ui,rn as di,rr as fi,rt as pi,s as mi,sa as hi,si as gi,sn as _i,sr as vi,st as yi,t as bi,ta as xi,ti as Si,tn as Ci,tr as wi,tt as Ti,u as Ei,ua as Di,ui as Oi,un as ki,ur as Ai,ut as ji,v as Mi,va as Ni,vi as Pi,vn as Fi,vr as Ii,vt as Li,w as Ri,wi as zi,wn as Bi,wr as Vi,wt as Hi,x as Ui,xa as Wi,xi as Gi,xn as Ki,xr as qi,xt as Ji,y as Yi,ya as Xi,yi as Zi,yn as Qi,yr as $i,yt as ea,z as ta,zi as na,zn as ra,zr as ia,zt as aa}from"./fa-pro-icons-D4afj0tU.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var W=e(n(),1);W.use;var oa=typeof window<`u`?W.useLayoutEffect:W.useEffect;function sa(e){let t=W.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function ca(e,t,n={},r={}){W.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function la(e){let t=W.useRef(null);return W.useImperativeHandle(e,()=>t.current,[]),t}function ua(e){return e[e.length-1]}function da(e){return typeof e==`function`}function fa(e,t){return da(e)?e(t):e}var pa=Object.prototype.hasOwnProperty,ma=Object.prototype.propertyIsEnumerable,ha=()=>Object.create(null),ga=(e,t)=>_a(e,t,ha);function _a(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=xa(e)&&xa(i);if(!a&&!(ya(e)&&ya(i)))return i;let o=a?e:va(e);if(!o)return i;let s=a?i:va(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:pa.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=_a(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function va(e){let t=Object.getOwnPropertyNames(e);for(let n of t)if(!ma.call(e,n))return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;let r=t;for(let t of n){if(!ma.call(e,t))return!1;r.push(t)}return r}function ya(e){if(!ba(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ba(n)||!n.hasOwnProperty(`isPrototypeOf`))}function ba(e){return Object.prototype.toString.call(e)===`[object Object]`}function xa(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Sa(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!Sa(e[r],t[r],n))return!1;return!0}if(ya(e)&&ya(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!Sa(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!Sa(e[o],t[o],n)))return!1;return i===a}return!1}function Ca(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function wa(e){return!!(e&&typeof e==`object`&&typeof e.then==`function`)}function Ta(e){return e.replace(/[\x00-\x1f\x7f]/g,``)}function Ea(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return Ta(t)}var Da=[`http:`,`https:`,`mailto:`,`tel:`];function Oa(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function ka(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=Ea(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=Ea(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function Aa(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function ja(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ma(){throw Error(`Invariant failed`)}function Na(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var Pa=4,Fa=5;function Ia(e){let t=e.indexOf(`{`);if(t===-1)return null;let n=e.indexOf(`}`,t);return n===-1||t+1>=e.length?null:[t,n]}function La(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=Ia(a);if(o){let[r,s]=o,c=a.charCodeAt(r+1);if(c===45){if(r+2<a.length&&a.charCodeAt(r+2)===36){let e=r+3,a=s;if(e<a)return n[0]=3,n[1]=t+r,n[2]=t+e,n[3]=t+a,n[4]=t+s+1,n[5]=i,n}}else if(c===36){let a=r+1,o=r+2;return o===s?(n[0]=2,n[1]=t+r,n[2]=t+a,n[3]=t+o,n[4]=t+s+1,n[5]=e.length,n):(n[0]=1,n[1]=t+r,n[2]=t+o,n[3]=t+s,n[4]=t+s+1,n[5]=i,n)}}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function Ra(e,t,n,r,i,a,o){o?.(n);let s=r;{let r=n.fullPath??n.from,o=r.length,c=n.options?.caseSensitive??e,l=!!(n.options?.params?.parse&&n.options?.skipRouteOnParseError?.params);for(;s<o;){let e=La(r,s,t),o,u=s,d=e[5];switch(s=d+1,a++,e[0]){case 0:{let t=r.substring(e[2],e[3]);if(c){let e=i.static?.get(t);if(e)o=e;else{i.static??=new Map;let e=Va(n.fullPath??n.from);e.parent=i,e.depth=a,o=e,i.static.set(t,e)}}else{let e=t.toLowerCase(),r=i.staticInsensitive?.get(e);if(r)o=r;else{i.staticInsensitive??=new Map;let t=Va(n.fullPath??n.from);t.parent=i,t.depth=a,o=t,i.staticInsensitive.set(e,t)}}break}case 1:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.dynamic?.find(e=>!e.skipOnParamError&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=Ha(1,n.fullPath??n.from,f,p,m);o=e,e.depth=a,e.parent=i,i.dynamic??=[],i.dynamic.push(e)}break}case 3:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.optional?.find(e=>!e.skipOnParamError&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=Ha(3,n.fullPath??n.from,f,p,m);o=e,e.parent=i,e.depth=a,i.optional??=[],i.optional.push(e)}break}case 2:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),l=c&&!!(t||s),f=t?l?t:t.toLowerCase():void 0,p=s?l?s:s.toLowerCase():void 0,m=Ha(2,n.fullPath??n.from,l,f,p);o=m,m.parent=i,m.depth=a,i.wildcard??=[],i.wildcard.push(m)}}i=o}if(l&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf(`/`)+1)===95){let e=Va(n.fullPath??n.from);e.kind=Fa,e.parent=i,a++,e.depth=a,i.pathless??=[],i.pathless.push(e),i=e}let u=(n.path||!n.children)&&!n.isRoot;if(u&&r.endsWith(`/`)){let e=Va(n.fullPath??n.from);e.kind=Pa,e.parent=i,a++,e.depth=a,i.index=e,i=e}i.parse=n.options?.params?.parse??null,i.skipOnParamError=l,i.parsingPriority=n.options?.skipRouteOnParseError?.priority??0,u&&!i.route&&(i.route=n,i.fullPath=n.fullPath??n.from)}if(n.children)for(let r of n.children)Ra(e,t,r,s,i,a,o)}function za(e,t){if(e.skipOnParamError&&!t.skipOnParamError)return-1;if(!e.skipOnParamError&&t.skipOnParamError)return 1;if(e.skipOnParamError&&t.skipOnParamError&&(e.parsingPriority||t.parsingPriority))return t.parsingPriority-e.parsingPriority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function Ba(e){if(e.pathless)for(let t of e.pathless)Ba(t);if(e.static)for(let t of e.static.values())Ba(t);if(e.staticInsensitive)for(let t of e.staticInsensitive.values())Ba(t);if(e.dynamic?.length){e.dynamic.sort(za);for(let t of e.dynamic)Ba(t)}if(e.optional?.length){e.optional.sort(za);for(let t of e.optional)Ba(t)}if(e.wildcard?.length){e.wildcard.sort(za);for(let t of e.wildcard)Ba(t)}}function Va(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0}}function Ha(e,t,n,r,i){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0,caseSensitive:n,prefix:r,suffix:i}}function Ua(e,t){let n=Va(`/`),r=new Uint16Array(6);for(let t of e)Ra(!1,r,t,1,n,0);Ba(n),t.masksTree=n,t.flatCache=Na(1e3)}function Wa(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=Ya(e,t.masksTree);return t.flatCache.set(e,r),r}function Ga(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=Va(`/`),Ra(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),Ya(r,o,n)}function Ka(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=Ya(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=Za(a.route)),t.matchCache.set(r,a),a}function qa(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function Ja(e,t=!1,n){let r=Va(e.fullPath),i=new Uint16Array(6),a={},o={},s=0;return Ra(t,i,e,1,r,0,e=>{if(n?.(e,s),e.id in a&&Ma(),a[e.id]=e,s!==0&&e.path){let t=qa(e.fullPath);(!o[t]||e.fullPath.endsWith(`/`))&&(o[t]=e)}s++}),Ba(r),{processedTree:{segmentTree:r,singleCache:Na(1e3),matchCache:Na(1e3),flatCache:null,masksTree:null},routesById:a,routesByPath:o}}function Ya(e,t,n=!1){let r=e.split(`/`),i=$a(e,r,t,n);if(!i)return null;let[a]=Xa(e,r,i);return{route:i.node.route,rawParams:a,parsedParams:i.parsedParams}}function Xa(e,t,n){let r=Qa(n.node),i=null,a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.segment??0;for(;s<r.length;o++,s++,c++,l++){let u=r[s];if(u.kind===Pa)break;if(u.kind===Fa){l--,o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1){i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0;if(e.charCodeAt(t)===123){let n=u.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=d.substring(t,d.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(d)}}else if(u.kind===3){if(n.skipped&1<<s){o--,c=f-1;continue}i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0,r=u.suffix?.length??0,p=e.substring(t+3,e.length-r-1),m=u.suffix||u.prefix?d.substring(t,d.length-r):d;m&&(a[p]=decodeURIComponent(m))}else if(u.kind===2){let t=u,n=e.substring(f+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,segment:l}]}function Za(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Qa(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function $a(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!ua(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,depth:1,statics:1,dynamics:0,optionals:0}],c=null,l=null,u=null;for(;s.length;){let n=s.pop(),{node:i,index:d,skipped:f,depth:p,statics:m,dynamics:h,optionals:g}=n,{extract:_,rawParams:v,parsedParams:y}=n;if(i.skipOnParamError){if(!eo(e,t,n))continue;v=n.rawParams,_=n.extract,y=n.parsedParams}r&&i.route&&i.kind!==Pa&&to(l,n)&&(l=n);let b=d===o;if(b&&(i.route&&!a&&to(u,n)&&(u=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let x=b?void 0:t[d],S;if(b&&i.index){let n={node:i.index,index:d,skipped:f,depth:p+1,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y},r=!0;if(i.index.skipOnParamError&&(eo(e,t,n)||(r=!1)),r){if(m===o&&!h&&!g&&!f)return n;to(u,n)&&(u=n)}}if(i.wildcard&&to(c,n))for(let n of i.wildcard){let{prefix:r,suffix:i}=n;if(r&&(b||!(n.caseSensitive?x:S??=x.toLowerCase()).startsWith(r)))continue;if(i){if(b)continue;let e=t.slice(d).join(`/`).slice(-i.length);if((n.caseSensitive?e:e.toLowerCase())!==i)continue}let a={node:n,index:o,skipped:f,depth:p,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y};if(!(n.skipOnParamError&&!eo(e,t,a))){c=a;break}}if(i.optional){let e=f|1<<p,t=p+1;for(let n=i.optional.length-1;n>=0;n--){let r=i.optional[n];s.push({node:r,index:d,skipped:e,depth:t,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b)for(let e=i.optional.length-1;e>=0;e--){let n=i.optional[e],{prefix:r,suffix:a}=n;if(r||a){let e=n.caseSensitive?x:S??=x.toLowerCase();if(r&&!e.startsWith(r)||a&&!e.endsWith(a))continue}s.push({node:n,index:d+1,skipped:f,depth:t,statics:m,dynamics:h,optionals:g+1,extract:_,rawParams:v,parsedParams:y})}}if(!b&&i.dynamic&&x)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?x:S??=x.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:d+1,skipped:f,depth:p+1,statics:m,dynamics:h+1,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b&&i.staticInsensitive){let e=i.staticInsensitive.get(S??=x.toLowerCase());e&&s.push({node:e,index:d+1,skipped:f,depth:p+1,statics:m+1,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b&&i.static){let e=i.static.get(x);e&&s.push({node:e,index:d+1,skipped:f,depth:p+1,statics:m+1,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(i.pathless){let e=p+1;for(let t=i.pathless.length-1;t>=0;t--){let n=i.pathless[t];s.push({node:n,index:d,skipped:f,depth:e,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}}}if(u&&c)return to(c,u)?u:c;if(u)return u;if(c)return c;if(r&&l){let n=l.index;for(let e=0;e<l.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return l.rawParams??=Object.create(null),l.rawParams[`**`]=decodeURIComponent(r),l}return null}function eo(e,t,n){try{let[r,i]=Xa(e,t,n);n.rawParams=r,n.extract=i;let a=n.node.parse(r);return n.parsedParams=Object.assign(Object.create(null),n.parsedParams,a),!0}catch{return null}}function to(e,t){return e?t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===Pa)>(e.node.kind===Pa)||t.node.kind===Pa==(e.node.kind===Pa)&&t.depth>e.depth))):!0}function no(e){return ro(e.filter(e=>e!==void 0).join(`/`))}function ro(e){return e.replace(/\/{2,}/g,`/`)}function io(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function ao(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function oo(e){return ao(io(e))}function so(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function co(e,t,n){return so(e,n)===so(t,n)}function lo({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t.startsWith(`/`),a=!i&&t===`.`,o;if(r){o=i?t:a?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(a)s=e.split(`/`);else if(i)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&&ua(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.pop():r===`.`||s.push(r)}}s.length>1&&(ua(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c,l=``;for(let e=0;e<s.length;e++){e>0&&(l+=`/`);let t=s[e];if(!t)continue;c=La(t,0,c);let n=c[0];if(n===0){l+=t;continue}let r=c[5],i=t.substring(0,c[1]),a=t.substring(c[4],r),o=t.substring(c[2],c[3]);n===1?l+=i||a?`${i}{$${o}}${a}`:`$${o}`:n===2?l+=i||a?`${i}{$}${a}`:`$`:l+=`${i}{-$${o}}${a}`}l=ro(l);let u=l||`/`;return o&&r&&r.set(o,u),u}function uo(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=Array.from(t.keys()).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),r=new RegExp(n,`g`);return e=>e.replace(r,e=>t.get(e)??e)}function fo(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split(`/`).map(e=>mo(e,n)).join(`/`):mo(r,n):r}function po({path:e,params:t,decoder:n,...r}){let i=!1,a=Object.create(null);if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:a,isMissingParams:i};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:a,isMissingParams:i};let o=e.length,s=0,c,l=``;for(;s<o;){let r=s;c=La(e,r,c);let o=c[5];if(s=o+1,r===o)continue;let u=c[0];if(u===0){l+=`/`+e.substring(r,o);continue}if(u===2){let s=t._splat;a._splat=s,a[`*`]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o);if(!s){i=!0,(u||d)&&(l+=`/`+u+d);continue}let f=fo(`_splat`,t,n);l+=`/`+u+f+d;continue}if(u===1){let s=e.substring(c[2],c[3]);!i&&!(s in t)&&(i=!0),a[s]=t[s];let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=fo(s,t,n)??`undefined`;l+=`/`+u+f+d;continue}if(u===3){let i=e.substring(c[2],c[3]),s=t[i];if(s==null)continue;a[i]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=fo(i,t,n)??``;l+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(l+=`/`),{usedParams:a,interpolatedPath:l||`/`,isMissingParams:i}}function mo(e,t){let n=encodeURIComponent(e);return t?.(n)??n}function ho(e){return!!e?.isNotFound}function go(){try{return typeof window<`u`&&typeof window.sessionStorage==`object`?window.sessionStorage:void 0}catch{return}}var _o=`tsr-scroll-restoration-v1_3`;function vo(){let e=go();if(!e)return null;let t={};try{let n=JSON.parse(e.getItem(`tsr-scroll-restoration-v1_3`)||`{}`);ya(n)&&(t=n)}catch{}return{get state(){return t},set:e=>{t=fa(e,t)||t},persist:()=>{try{e.setItem(_o,JSON.stringify(t))}catch{}}}}var yo=vo(),bo=e=>e.state.__TSR_key||e.href;function xo(e){let t=[],n;for(;n=e.parentNode;)t.push(`${e.tagName}:nth-child(${Array.prototype.indexOf.call(n.children,e)+1})`),e=n;return`${t.reverse().join(` > `)}`.toLowerCase()}var So=!1,Co=`window`,wo=`data-scroll-restoration-id`;function To(e,t){if(!yo)return;let n=yo;if((t??e.options.scrollRestoration??!1)&&(e.isScrollRestoring=!0),e.isScrollRestorationSetup||!n)return;e.isScrollRestorationSetup=!0,So=!1;let r=e.options.getScrollRestorationKey||bo,i=new Map;window.history.scrollRestoration=`manual`;let a=t=>{if(!(So||!e.isScrollRestoring))if(t.target===document||t.target===window)i.set(Co,{scrollX:window.scrollX||0,scrollY:window.scrollY||0});else{let e=t.target;i.set(e,{scrollX:e.scrollLeft||0,scrollY:e.scrollTop||0})}},o=t=>{if(!e.isScrollRestoring||!t||i.size===0||!n)return;let r=n.state[t]||={};for(let[e,t]of i){let n;if(e===Co)n=Co;else if(e.isConnected){let t=e.getAttribute(wo);n=t?`[${wo}="${t}"]`:xo(e)}n&&(r[n]=t)}};document.addEventListener(`scroll`,a,!0),e.subscribe(`onBeforeLoad`,e=>{o(e.fromLocation?r(e.fromLocation):void 0),i.clear()}),window.addEventListener(`pagehide`,()=>{o(r(e.stores.resolvedLocation.state??e.stores.location.state)),n.persist()}),e.subscribe(`onRendered`,t=>{let a=r(t.toLocation),o=e.options.scrollRestorationBehavior,s=e.options.scrollToTopSelectors;if(i.clear(),!e.resetNextScroll){e.resetNextScroll=!0;return}if(!(typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))){So=!0;try{let t=e.isScrollRestoring?n.state[a]:void 0,r=!1;if(t)for(let e in t){let n=t[e];if(!ya(n))continue;let{scrollX:i,scrollY:a}=n;if(!(!Number.isFinite(i)||!Number.isFinite(a))){if(e===Co)window.scrollTo({top:a,left:i,behavior:o}),r=!0;else if(e){let t;try{t=document.querySelector(e)}catch{continue}t&&(t.scrollLeft=i,t.scrollTop=a,r=!0)}}}if(!r){let t=e.history.location.hash.slice(1);if(t){let e=window.history.state?.__hashScrollIntoViewOptions??!0;if(e){let n=document.getElementById(t);n&&n.scrollIntoView(e)}}else{let e={top:0,left:0,behavior:o};if(window.scrollTo(e),s)for(let t of s){if(t===Co)continue;let n=typeof t==`function`?t():document.querySelector(t);n&&n.scrollTo(e)}}}}finally{So=!1}e.isScrollRestoring&&n.set(e=>(e[a]||={},e))}})}function Eo(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function Do(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function Oo(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=Do(r):Array.isArray(t)?t.push(Do(r)):n[e]=[t,Do(r)]}return n}var ko=jo(JSON.parse),Ao=Mo(JSON.stringify,JSON.parse);function jo(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=Oo(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function Mo(e,t){let n=typeof t==`function`;function r(r){if(typeof r==`object`&&r)try{return e(r)}catch{}else if(n&&typeof r==`string`)try{return t(r),e(r)}catch{}return r}return e=>{let t=Eo(e,r);return t?`?${t}`:``}}var No=`__root__`;function Po(e){if(e.statusCode=e.statusCode||e.code||307,!e._builtLocation&&!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function Fo(e){return e instanceof Response&&!!e.options}function Io(e){return{input:({url:t})=>{for(let n of e)t=Ro(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=zo(e[n],t);return t}}}function Lo(e){let t=oo(e.basepath),n=`/${t}`,r=`${n}/`,i=e.caseSensitive?n:n.toLowerCase(),a=e.caseSensitive?r:r.toLowerCase();return{input:({url:t})=>{let r=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return r===i?t.pathname=`/`:r.startsWith(a)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=no([`/`,t,e.pathname]),e)}}function Ro(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function zo(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Bo(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i,init:a}=t,o=new Map,s=new Map,c=new Map,l=n(e.status),u=n(e.loadedAt),d=n(e.isLoading),f=n(e.isTransitioning),p=n(e.location),m=n(e.resolvedLocation),h=n(e.statusCode),g=n(e.redirect),_=n([]),v=n([]),y=n([]),b=r(()=>Vo(o,_.state)),x=r(()=>Vo(s,v.state)),S=r(()=>Vo(c,y.state)),C=r(()=>_.state[0]),w=r(()=>_.state.some(e=>o.get(e)?.state.status===`pending`)),T=r(()=>({locationHref:p.state.href,resolvedLocationHref:m.state?.href,status:l.state})),E=r(()=>({status:l.state,loadedAt:u.state,isLoading:d.state,isTransitioning:f.state,matches:b.state,location:p.state,resolvedLocation:m.state,statusCode:h.state,redirect:g.state})),D=Na(64);function O(e){let t=D.get(e);return t||(t=r(()=>{let t=_.state;for(let n of t){let t=o.get(n);if(t&&t.routeId===e)return t.state}}),D.set(e,t)),t}let k={status:l,loadedAt:u,isLoading:d,isTransitioning:f,location:p,resolvedLocation:m,statusCode:h,redirect:g,matchesId:_,pendingMatchesId:v,cachedMatchesId:y,activeMatchesSnapshot:b,pendingMatchesSnapshot:x,cachedMatchesSnapshot:S,firstMatchId:C,hasPendingMatches:w,matchRouteReactivity:T,activeMatchStoresById:o,pendingMatchStoresById:s,cachedMatchStoresById:c,__store:E,getMatchStoreByRouteId:O,setActiveMatches:A,setPendingMatches:j,setCachedMatches:M};A(e.matches),a?.(k);function A(e){Ho(e,o,_,n,i)}function j(e){Ho(e,s,v,n,i)}function M(e){Ho(e,c,y,n,i)}return k}function Vo(e,t){let n=[];for(let r of t){let t=e.get(r);t&&n.push(t.state)}return n}function Ho(e,t,n,r,i){let a=e.map(e=>e.id),o=new Set(a);i(()=>{for(let e of t.keys())o.has(e)||t.delete(e);for(let n of e){let e=t.get(n.id);if(!e){let e=r(n);e.routeId=n.routeId,t.set(n.id,e);continue}e.routeId=n.routeId,e.state!==n&&e.setState(()=>n)}ja(n.state,a)||n.setState(()=>a)})}var Uo=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},Wo=e=>e.stores.matchesId.state.some(t=>e.stores.activeMatchStoresById.get(t)?.state._forcePending),Go=(e,t)=>!!(e.preload&&!e.router.stores.activeMatchStoresById.has(t)),Ko=(e,t,n=!0)=>{let r={...e.router.options.context??{}},i=n?t:t-1;for(let t=0;t<=i;t++){let n=e.matches[t];if(!n)continue;let i=e.router.getMatch(n.id);i&&Object.assign(r,i.__routeContext,i.__beforeLoadContext)}return r},qo=(e,t)=>{if(!e.matches.length)return;let n=t.routeId,r=e.matches.findIndex(t=>t.routeId===e.router.routeTree.id),i=r>=0?r:0,a=n?e.matches.findIndex(e=>e.routeId===n):e.firstBadMatchIndex??e.matches.length-1;a<0&&(a=i);for(let t=a;t>=0;t--){let n=e.matches[t];if(e.router.looseRoutesById[n.routeId].options.notFoundComponent)return t}return n?a:i},Jo=(e,t,n)=>{if(!(!Fo(n)&&!ho(n)))throw Fo(n)&&n.redirectHandled&&!n.options.reloadDocument?n:(t&&(t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0,t._nonReactive.error=n,e.updateMatch(t.id,r=>({...r,status:Fo(n)?`redirected`:r.status===`pending`?`success`:r.status,context:Ko(e,t.index),isFetching:!1,error:n})),ho(n)&&!n.routeId&&(n.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()),Fo(n)&&(e.rendered=!0,n.options._fromLocation=e.location,n.redirectHandled=!0,n=e.router.resolveRedirect(n)),n)},Yo=(e,t)=>{let n=e.router.getMatch(t);return!!(!n||n._nonReactive.dehydrated)},Xo=(e,t,n)=>{let r=Ko(e,n);e.updateMatch(t,e=>({...e,context:r}))},Zo=(e,t,n,r)=>{let{id:i,routeId:a}=e.matches[t],o=e.router.looseRoutesById[a];if(n instanceof Promise)throw n;n.routerCode=r,e.firstBadMatchIndex??=t,Jo(e,e.router.getMatch(i),n);try{o.options.onError?.(n)}catch(t){n=t,Jo(e,e.router.getMatch(i),n)}e.updateMatch(i,e=>(e._nonReactive.beforeLoadPromise?.resolve(),e._nonReactive.beforeLoadPromise=void 0,e._nonReactive.loadPromise?.resolve(),{...e,error:n,status:`error`,isFetching:!1,updatedAt:Date.now(),abortController:new AbortController})),!e.preload&&!Fo(n)&&!ho(n)&&(e.serialError??=n)},Qo=(e,t,n,r)=>{if(r._nonReactive.pendingTimeout!==void 0)return;let i=n.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!Go(e,t)&&(n.options.loader||n.options.beforeLoad||ls(n))&&typeof i==`number`&&i!==1/0&&(n.options.pendingComponent??e.router.options?.defaultPendingComponent)){let t=setTimeout(()=>{Uo(e)},i);r._nonReactive.pendingTimeout=t}},$o=(e,t,n)=>{let r=e.router.getMatch(t);if(!r._nonReactive.beforeLoadPromise&&!r._nonReactive.loaderPromise)return;Qo(e,t,n,r);let i=()=>{let n=e.router.getMatch(t);n.preload&&(n.status===`redirected`||n.status===`notFound`)&&Jo(e,n,n.error)};return r._nonReactive.beforeLoadPromise?r._nonReactive.beforeLoadPromise.then(i):i()},es=(e,t,n,r)=>{let i=e.router.getMatch(t),a=i._nonReactive.loadPromise;i._nonReactive.loadPromise=Ca(()=>{a?.resolve(),a=void 0});let{paramsError:o,searchError:s}=i;o&&Zo(e,n,o,`PARSE_PARAMS`),s&&Zo(e,n,s,`VALIDATE_SEARCH`),Qo(e,t,r,i);let c=new AbortController,l=!1,u=()=>{l||(l=!0,e.updateMatch(t,e=>({...e,isFetching:`beforeLoad`,fetchCount:e.fetchCount+1,abortController:c})))},d=()=>{i._nonReactive.beforeLoadPromise?.resolve(),i._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,e=>({...e,isFetching:!1}))};if(!r.options.beforeLoad){e.router.batch(()=>{u(),d()});return}i._nonReactive.beforeLoadPromise=Ca();let f={...Ko(e,n,!1),...i.__routeContext},{search:p,params:m,cause:h}=i,g=Go(e,t),_={search:p,abortController:c,params:m,preload:g,context:f,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:g?`preload`:h,matches:e.matches,routeId:r.id,...e.router.options.additionalContext},v=r=>{if(r===void 0){e.router.batch(()=>{u(),d()});return}(Fo(r)||ho(r))&&(u(),Zo(e,n,r,`BEFORE_LOAD`)),e.router.batch(()=>{u(),e.updateMatch(t,e=>({...e,__beforeLoadContext:r})),d()})},y;try{if(y=r.options.beforeLoad(_),wa(y))return u(),y.catch(t=>{Zo(e,n,t,`BEFORE_LOAD`)}).then(v)}catch(t){u(),Zo(e,n,t,`BEFORE_LOAD`)}v(y)},ts=(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=e.router.looseRoutesById[r],a=()=>s(),o=()=>es(e,n,t,i),s=()=>{if(Yo(e,n))return;let t=$o(e,n,i);return wa(t)?t.then(o):o()};return a()},ns=(e,t,n)=>{let r=e.router.getMatch(t);if(!r||!n.options.head&&!n.options.scripts&&!n.options.headers)return;let i={ssr:e.router.options.ssr,matches:e.matches,match:r,params:r.params,loaderData:r.loaderData};return Promise.all([n.options.head?.(i),n.options.scripts?.(i),n.options.headers?.(i)]).then(([e,t,n])=>({meta:e?.meta,links:e?.links,headScripts:e?.scripts,headers:n,scripts:t,styles:e?.styles}))},rs=(e,t,n,r,i)=>{let a=t[r-1],{params:o,loaderDeps:s,abortController:c,cause:l}=e.router.getMatch(n),u=Ko(e,r),d=Go(e,n);return{params:o,deps:s,preload:!!d,parentMatchPromise:a,abortController:c,context:u,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),cause:d?`preload`:l,route:i,...e.router.options.additionalContext}},is=async(e,t,n,r,i)=>{try{let a=e.router.getMatch(n);try{cs(i);let o=i.options.loader,s=typeof o==`function`?o:o?.handler,c=s?.(rs(e,t,n,r,i)),l=!!s&&wa(c);if((l||i._lazyPromise||i._componentsPromise||i.options.head||i.options.scripts||i.options.headers||a._nonReactive.minPendingPromise)&&e.updateMatch(n,e=>({...e,isFetching:`loader`})),s){let t=l?await c:c;Jo(e,e.router.getMatch(n),t),t!==void 0&&e.updateMatch(n,e=>({...e,loaderData:t}))}i._lazyPromise&&await i._lazyPromise;let u=a._nonReactive.minPendingPromise;u&&await u,i._componentsPromise&&await i._componentsPromise,e.updateMatch(n,t=>({...t,error:void 0,context:Ko(e,r),status:`success`,isFetching:!1,updatedAt:Date.now()}))}catch(t){let o=t;if(o?.name===`AbortError`){if(a.abortController.signal.aborted){a._nonReactive.loaderPromise?.resolve(),a._nonReactive.loaderPromise=void 0;return}e.updateMatch(n,t=>({...t,status:t.status===`pending`?`success`:t.status,isFetching:!1,context:Ko(e,r)}));return}let s=a._nonReactive.minPendingPromise;s&&await s,ho(t)&&await i.options.notFoundComponent?.preload?.(),Jo(e,e.router.getMatch(n),t);try{i.options.onError?.(t)}catch(t){o=t,Jo(e,e.router.getMatch(n),t)}!Fo(o)&&!ho(o)&&await cs(i,[`errorComponent`]),e.updateMatch(n,t=>({...t,error:o,context:Ko(e,r),status:`error`,isFetching:!1}))}}catch(t){let r=e.router.getMatch(n);r&&(r._nonReactive.loaderPromise=void 0),Jo(e,r,t)}},as=async(e,t,n)=>{async function r(r,a,c,l,d){let f=Date.now()-a.updatedAt,p=r?d.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:d.options.staleTime??e.router.options.defaultStaleTime??0,m=d.options.shouldReload,h=typeof m==`function`?m(rs(e,t,i,n,d)):m,{status:g,invalid:_}=l,v=f>=p&&(!!e.forceStaleReload||l.cause===`enter`||c!==void 0&&c!==l.id);o=g===`success`&&(_||(h??v)),r&&d.options.preload===!1||(o&&!e.sync&&u?(s=!0,(async()=>{try{await is(e,t,i,n,d);let r=e.router.getMatch(i);r._nonReactive.loaderPromise?.resolve(),r._nonReactive.loadPromise?.resolve(),r._nonReactive.loaderPromise=void 0,r._nonReactive.loadPromise=void 0}catch(t){Fo(t)&&await e.router.navigate(t.options)}})()):g!==`success`||o?await is(e,t,i,n,d):Xo(e,i,n))}let{id:i,routeId:a}=e.matches[n],o=!1,s=!1,c=e.router.looseRoutesById[a],l=c.options.loader,u=((typeof l==`function`?void 0:l?.staleReloadMode)??e.router.options.defaultStaleReloadMode)!==`blocking`;if(Yo(e,i)){if(!e.router.getMatch(i))return e.matches[n];Xo(e,i,n)}else{let t=e.router.getMatch(i),o=e.router.stores.matchesId.state[n],s=(o&&e.router.stores.activeMatchStoresById.get(o)||null)?.routeId===a?o:e.router.stores.activeMatchesSnapshot.state.find(e=>e.routeId===a)?.id,l=Go(e,i);if(t._nonReactive.loaderPromise){if(t.status===`success`&&!e.sync&&!t.preload&&u)return t;await t._nonReactive.loaderPromise;let n=e.router.getMatch(i),a=n._nonReactive.error||n.error;a&&Jo(e,n,a),n.status===`pending`&&await r(l,t,s,n,c)}else{let n=l&&!e.router.stores.activeMatchStoresById.has(i),a=e.router.getMatch(i);a._nonReactive.loaderPromise=Ca(),n!==a.preload&&e.updateMatch(i,e=>({...e,preload:n})),await r(l,t,s,a,c)}}let d=e.router.getMatch(i);s||(d._nonReactive.loaderPromise?.resolve(),d._nonReactive.loadPromise?.resolve(),d._nonReactive.loadPromise=void 0),clearTimeout(d._nonReactive.pendingTimeout),d._nonReactive.pendingTimeout=void 0,s||(d._nonReactive.loaderPromise=void 0),d._nonReactive.dehydrated=void 0;let f=s?d.isFetching:!1;return f!==d.isFetching||d.invalid!==!1?(e.updateMatch(i,e=>({...e,isFetching:f,invalid:!1})),e.router.getMatch(i)):d};async function os(e){let t=e,n=[];Wo(t.router)&&Uo(t);let r;for(let e=0;e<t.matches.length;e++){try{let n=ts(t,e);wa(n)&&await n}catch(e){if(Fo(e))throw e;if(ho(e))r=e;else if(!t.preload)throw e;break}if(t.serialError||t.firstBadMatchIndex!=null)break}let i=t.firstBadMatchIndex??t.matches.length,a=r&&!t.preload?qo(t,r):void 0,o=r&&t.preload?0:a===void 0?i:Math.min(a+1,i),s,c;for(let e=0;e<o;e++)n.push(as(t,n,e));try{await Promise.all(n)}catch{let e=await Promise.allSettled(n);for(let t of e){if(t.status!==`rejected`)continue;let e=t.reason;if(Fo(e))throw e;ho(e)?s??=e:c??=e}if(c!==void 0)throw c}let l=s??(r&&!t.preload?r:void 0),u=t.firstBadMatchIndex===void 0?t.matches.length-1:t.firstBadMatchIndex;if(!l&&r&&t.preload)return t.matches;if(l){let e=qo(t,l);e===void 0&&Ma();let n=t.matches[e],r=t.router.looseRoutesById[n.routeId],i=t.router.options?.defaultNotFoundComponent;!r.options.notFoundComponent&&i&&(r.options.notFoundComponent=i),l.routeId=n.routeId;let a=n.routeId===t.router.routeTree.id;t.updateMatch(n.id,e=>({...e,...a?{status:`success`,globalNotFound:!0,error:void 0}:{status:`notFound`,error:l},isFetching:!1})),u=e,await cs(r,[`notFoundComponent`])}else if(!t.preload){let e=t.matches[0];e.globalNotFound||t.router.getMatch(e.id)?.globalNotFound&&t.updateMatch(e.id,e=>({...e,globalNotFound:!1,error:void 0}))}if(t.serialError&&t.firstBadMatchIndex!==void 0){let e=t.router.looseRoutesById[t.matches[t.firstBadMatchIndex].routeId];await cs(e,[`errorComponent`])}for(let e=0;e<=u;e++){let{id:n,routeId:r}=t.matches[e],i=t.router.looseRoutesById[r];try{let e=ns(t,n,i);if(e){let r=await e;t.updateMatch(n,e=>({...e,...r}))}}catch(e){console.error(`Error executing head for route ${r}:`,e)}}let d=Uo(t);if(wa(d)&&await d,l)throw l;if(t.serialError&&!t.preload&&!t.onReady)throw t.serialError;return t.matches}function ss(e,t){let n=t.map(t=>e.options[t]?.preload?.()).filter(Boolean);if(n.length!==0)return Promise.all(n)}function cs(e,t=us){!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(t=>{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0);let n=()=>e._componentsLoaded?void 0:t===us?(()=>{if(e._componentsPromise===void 0){let t=ss(e,us);t?e._componentsPromise=t.then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0}):e._componentsLoaded=!0}return e._componentsPromise})():ss(e,t);return e._lazyPromise?e._lazyPromise.then(n):n()}function ls(e){for(let t of us)if(e.options[t]?.preload)return!0;return!1}var us=[`component`,`errorComponent`,`pendingComponent`,`notFoundComponent`],ds=`__TSR_index`,fs=`popstate`,ps=`beforeunload`;function ms(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=vs(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[ds];i=hs(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[ds];i=hs(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[ds]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function hs(e,t){t||={};let n=ys();return{...t,key:n,__TSR_key:n,[ds]:e}}function gs(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>vs(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=ys();t.history.replaceState({[ds]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_,v=()=>{g&&(C._ignoreSubscribers=!0,(g.isPush?t.history.pushState:t.history.replaceState)(g.state,``,g.href),C._ignoreSubscribers=!1,g=void 0,_=void 0,u=void 0)},y=(e,t,n)=>{let r=s(t);_||(u=l),l=vs(t,n),g={href:r,state:n,isPush:g?.isPush||e===`push`},_||=Promise.resolve().then(()=>v())},b=e=>{l=c(),C.notify({type:e})},x=async()=>{if(f){f=!1;return}let e=c(),n=e.state[ds]-l.state[ds],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),C.notify(u);return}}}l=c(),C.notify(u)},S=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},C=ms({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>y(`push`,e,t),replaceState:(e,t)=>y(`replace`,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:v,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(ps,S,{capture:!0}),t.removeEventListener(fs,x)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(ps,S,{capture:!0}),t.addEventListener(fs,x),t.history.pushState=function(...e){let r=n.apply(t.history,e);return C._ignoreSubscribers||b(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return C._ignoreSubscribers||b(`REPLACE`),n},C}function _s(e){let t=e.replace(/[\x00-\x1f\x7f]/g,``);return t.startsWith(`//`)&&(t=`/`+t.replace(/^\/+/,``)),t}function vs(e,t){let n=_s(e),r=n.indexOf(`#`),i=n.indexOf(`?`),a=ys();return{href:n,pathname:n.substring(0,r>0?i>0?Math.min(r,i):r:i>0?i:n.length),hash:r>-1?n.substring(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t||{[ds]:0,key:a,__TSR_key:a}}}function ys(){return(Math.random()+1).toString(36).substring(7)}function bs(e,t){let n=t,r=e;return{fromLocation:n,toLocation:r,pathChanged:n?.pathname!==r.pathname,hrefChanged:n?.href!==r.href,hashChanged:n?.hash!==r.hash}}var xs=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.isScrollRestoring=!1,this.isScrollRestorationSetup=!1,this.startTransition=e=>e(),this.update=e=>{let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;if(this.options={...t,...e},this.isServer=this.options.isServer??typeof document>`u`,this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=uo(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=gs()),this.origin=this.options.origin,this.origin||(window?.origin&&window.origin!==`null`?this.origin=window.origin:this.origin=`http://localhost`),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;this.resolvePathCache=Na(1e3),e=this.buildRouteTree(),this.setRoutes(e)}if(!this.stores&&this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=Bo(ws(this.latestLocation),e),To(this)}let a=!1,o=this.options.basepath??`/`,s=this.options.rewrite;if(r||n!==o||i!==s){this.basepath=o;let e=[],t=oo(o);t&&t!==`/`&&e.push(Lo({basepath:o})),s&&e.push(s),this.rewrite=e.length===0?void 0:e.length===1?e[0]:Io(e),this.history&&this.updateLatestLocation(),a=!0}a&&this.stores&&this.stores.location.setState(()=>this.latestLocation),typeof window<`u`&&`CSS`in window&&typeof window.CSS?.supports==`function`&&(this.isViewTransitionTypesSupported=window.CSS.supports(`selector(:active-view-transition-type(a)`))},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=Ja(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});return this.options.routeMasks&&Ua(this.options.routeMasks,e.processedTree),e},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{this.subscribers.forEach(t=>{t.eventType===e.type&&t.fn(e)})},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i,state:a})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:ka(e).path,external:!1,searchStr:o,search:ga(t?.search,i),hash:ka(r.slice(1)).path,state:_a(t?.state,a)}}let o=new URL(i,this.origin),s=Ro(this.rewrite,o),c=this.options.parseSearch(s.search),l=this.options.stringifySearch(c);return s.search=l,{href:s.href.replace(s.origin,``),publicHref:i,pathname:ka(s.pathname).path,external:!!this.rewrite&&s.origin!==this.origin,searchStr:l,search:ga(t?.search,c),hash:ka(s.hash.slice(1)).path,state:_a(t?.state,a)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathWithBase=(e,t)=>lo({base:e,to:ro(t),trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>Es({pathname:e,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=e=>{let t=this.getMatch(e);t&&(t.abortController.abort(),clearTimeout(t._nonReactive.pendingTimeout),t._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{this.stores.pendingMatchesId.state.forEach(e=>{this.cancelMatch(e)}),this.stores.matchesId.state.forEach(e=>{if(this.stores.pendingMatchStoresById.has(e))return;let t=this.stores.activeMatchStoresById.get(e)?.state;t&&(t.status===`pending`||t.isFetching===`loader`)&&this.cancelMatch(e)})},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this.pendingBuiltLocation||this.latestLocation,r=this.matchRoutesLightweight(n);t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r.fullPath,a=this.resolvePathWithBase(i,`.`),o=r.search,s=Object.assign(Object.create(null),r.params),c=t.to?this.resolvePathWithBase(a,`${t.to}`):this.resolvePathWithBase(a,`.`),l=t.params===!1||t.params===null?Object.create(null):(t.params??!0)===!0?s:Object.assign(s,fa(t.params,s)),u=this.getMatchedRoutes(c),d=u.matchedRoutes;if((!u.foundRoute||u.foundRoute.path!==`/`&&u.routeParams[`**`])&&this.options.notFoundRoute&&(d=[...d,this.options.notFoundRoute]),Object.keys(l).length>0)for(let e of d){let t=e.options.params?.stringify??e.options.stringifyParams;if(t)try{Object.assign(l,t(l))}catch{}}let f=e.leaveParams?c:ka(po({path:c,params:l,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path,p=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};d.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,Ts(t.options.validateSearch,{...e,...p}))}catch{}}),p=e}p=Ds({search:p,dest:t,destRoutes:d,_includeValidateSearch:e._includeValidateSearch}),p=ga(o,p);let m=this.options.stringifySearch(p),h=t.hash===!0?n.hash:t.hash?fa(t.hash,n.hash):void 0,g=h?`#${h}`:``,_=t.state===!0?n.state:t.state?fa(t.state,n.state):{};_=_a(n.state,_);let v=`${f}${m}${g}`,y,b,x=!1;if(this.rewrite){let e=new URL(v,this.origin),t=zo(this.rewrite,e);y=e.href.replace(e.origin,``),t.origin===this.origin?b=t.pathname+t.search+t.hash:(b=t.href,x=!0)}else y=Aa(v),b=y;return{publicHref:b,href:y,pathname:f,search:p,searchStr:m,state:_,hash:h??``,external:x,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n=Object.create(null);if(this.options.routeMasks){let o=Wa(i.pathname,this.processedTree);if(o){Object.assign(n,o.rawParams);let{from:i,params:s,...c}=o.route,l=s===!1||s===null?Object.create(null):(s??!0)===!0?n:Object.assign(n,fa(s,n));r={from:e.from,...c,params:l},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r=()=>{let e=[`key`,`__TSR_key`,`__TSR_index`,`__hashScrollIntoViewOptions`];e.forEach(e=>{n.state[e]=this.latestLocation.state[e]});let t=Sa(n.state,this.latestLocation.state);return e.forEach(e=>{delete n.state[e]}),t},i=ao(this.latestLocation.href)===ao(n.href),a=this.commitLocationPromise;if(this.commitLocationPromise=Ca(()=>{a?.resolve(),a=void 0}),i&&r())this.load();else{let{maskedLocation:r,hashScrollIntoView:i,...a}=n;r&&(a={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...a,search:a.searchStr,state:{...a.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(a.unmaskOnReload??this.options.unmaskOnReload??!1)&&(a.state.__tempKey=this.tempLocationKey)),a.state.__hashScrollIntoViewOptions=i??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,this.history[n.replace?`replace`:`push`](a.publicHref,a.state,{ignoreBlocker:t})}return this.resetNextScroll=n.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,href:a,...o}={})=>{if(a){let t=this.history.location.state.__TSR_index,n=vs(a,{__TSR_index:e?t:t+1}),r=new URL(n.pathname,this.origin);o.to=Ro(this.rewrite,r).pathname,o.search=this.options.parseSearch(n.search),o.hash=n.hash.slice(1)}let s=this.buildLocation({...o,_includeValidateSearch:!0});this.pendingBuiltLocation=s;let c=this.commitLocation({...s,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return Promise.resolve().then(()=>{this.pendingBuiltLocation===s&&(this.pendingBuiltLocation=void 0)}),c},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=!1;if(n)try{new URL(`${n}`),a=!0}catch{}if(a&&!t&&(t=!0),t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i});n??=t.publicHref,r??=t.publicHref}let t=!a&&r?r:n;if(Oa(t,this.protocolAllowlist))return Promise.resolve();if(!i.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return Promise.resolve()}return i.replace?window.location.replace(t):window.location.href=t,Promise.resolve()}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.beforeLoad=()=>{this.cancelMatches(),this.updateLatestLocation();let e=this.matchRoutes(this.latestLocation),t=this.stores.cachedMatchesSnapshot.state.filter(t=>!e.some(e=>e.id===t.id));this.batch(()=>{this.stores.status.setState(()=>`pending`),this.stores.statusCode.setState(()=>200),this.stores.isLoading.setState(()=>!0),this.stores.location.setState(()=>this.latestLocation),this.stores.setPendingMatches(e),this.stores.setCachedMatches(t)})},this.load=async e=>{let t,n,r,i=this.stores.resolvedLocation.state??this.stores.location.state;for(r=new Promise(a=>{this.startTransition(async()=>{try{this.beforeLoad();let t=this.latestLocation,n=this.stores.resolvedLocation.state,r=bs(t,n);this.stores.redirect.state||this.emit({type:`onBeforeNavigate`,...r}),this.emit({type:`onBeforeLoad`,...r}),await os({router:this,sync:e?.sync,forceStaleReload:i.href===t.href,matches:this.stores.pendingMatchesSnapshot.state,location:t,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let e=null,t=null,n=null,r=null;this.batch(()=>{let i=this.stores.pendingMatchesSnapshot.state,a=i.length,o=this.stores.activeMatchesSnapshot.state;e=a?o.filter(e=>!this.stores.pendingMatchStoresById.has(e.id)):null;let s=new Set;for(let e of this.stores.pendingMatchStoresById.values())e.routeId&&s.add(e.routeId);let c=new Set;for(let e of this.stores.activeMatchStoresById.values())e.routeId&&c.add(e.routeId);t=a?o.filter(e=>!s.has(e.routeId)):null,n=a?i.filter(e=>!c.has(e.routeId)):null,r=a?i.filter(e=>c.has(e.routeId)):o,this.stores.isLoading.setState(()=>!1),this.stores.loadedAt.setState(()=>Date.now()),a&&(this.stores.setActiveMatches(i),this.stores.setPendingMatches([]),this.stores.setCachedMatches([...this.stores.cachedMatchesSnapshot.state,...e.filter(e=>e.status!==`error`&&e.status!==`notFound`&&e.status!==`redirected`)]),this.clearExpiredCache())});for(let[e,i]of[[t,`onLeave`],[n,`onEnter`],[r,`onStay`]])if(e)for(let t of e)this.looseRoutesById[t.routeId].options[i]?.(t)})})}})}catch(e){Fo(e)?(t=e,this.navigate({...t.options,replace:!0,ignoreBlocker:!0})):ho(e)&&(n=e);let r=t?t.status:n?404:this.stores.activeMatchesSnapshot.state.some(e=>e.status===`error`)?500:200;this.batch(()=>{this.stores.statusCode.setState(()=>r),this.stores.redirect.setState(()=>t)})}this.latestLoadPromise===r&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),a()})}),this.latestLoadPromise=r,await r;this.latestLoadPromise&&r!==this.latestLoadPromise;)await this.latestLoadPromise;let a;this.hasNotFoundMatch()?a=404:this.stores.activeMatchesSnapshot.state.some(e=>e.status===`error`)&&(a=500),a!==void 0&&this.stores.statusCode.setState(()=>a)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document<`u`&&`startViewTransition`in document&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&this.isViewTransitionTypesSupported){let r=this.latestLocation,i=this.stores.resolvedLocation.state,a=typeof t.types==`function`?t.types(bs(r,i)):t.types;if(a===!1){e();return}n={update:e,types:a}}else n=e;document.startViewTransition(n)}else e()},this.updateMatch=(e,t)=>{this.startTransition(()=>{let n=this.stores.pendingMatchStoresById.get(e);if(n){n.setState(t);return}let r=this.stores.activeMatchStoresById.get(e);if(r){r.setState(t);return}let i=this.stores.cachedMatchStoresById.get(e);if(i){let n=t(i.state);n.status===`redirected`?this.stores.cachedMatchStoresById.delete(e)&&this.stores.cachedMatchesId.setState(t=>t.filter(t=>t!==e)):i.setState(()=>n)}})},this.getMatch=e=>this.stores.cachedMatchStoresById.get(e)?.state??this.stores.pendingMatchStoresById.get(e)?.state??this.stores.activeMatchStoresById.get(e)?.state,this.invalidate=e=>{let t=t=>e?.filter?.(t)??!0?{...t,invalid:!0,...e?.forcePending||t.status===`error`||t.status===`notFound`?{status:`pending`,error:void 0}:void 0}:t;return this.batch(()=>{this.stores.setActiveMatches(this.stores.activeMatchesSnapshot.state.map(t)),this.stores.setCachedMatches(this.stores.cachedMatchesSnapshot.state.map(t)),this.stores.setPendingMatches(this.stores.pendingMatchesSnapshot.state.map(t))}),this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.getParsedLocationHref=e=>e.publicHref||`/`,this.resolveRedirect=e=>{let t=e.headers.get(`Location`);if(!e.options.href||e.options._builtLocation){let t=e.options._builtLocation??this.buildLocation(e.options),n=this.getParsedLocationHref(t);e.options.href=n,e.headers.set(`Location`,n)}else if(t)try{let n=new URL(t);if(this.origin&&n.origin===this.origin){let t=n.pathname+n.search+n.hash;e.options.href=t,e.headers.set(`Location`,t)}}catch{}if(e.options.href&&!e.options._builtLocation&&Oa(e.options.href,this.protocolAllowlist))throw Error(`Redirect blocked: unsafe protocol`);return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=e?.filter;t===void 0?this.stores.setCachedMatches([]):this.stores.setCachedMatches(this.stores.cachedMatchesSnapshot.state.filter(e=>!t(e)))},this.clearExpiredCache=()=>{let e=Date.now();this.clearCache({filter:t=>{let n=this.looseRoutesById[t.routeId];if(!n.options.loader)return!0;let r=(t.preload?n.options.preloadGcTime??this.options.defaultPreloadGcTime:n.options.gcTime??this.options.defaultGcTime)??300*1e3;return t.status===`error`?!0:e-t.updatedAt>=r}})},this.loadRouteChunk=cs,this.preloadRoute=async e=>{let t=e._builtLocation??this.buildLocation(e),n=this.matchRoutes(t,{throwOnError:!0,preload:!0,dest:e}),r=new Set([...this.stores.matchesId.state,...this.stores.pendingMatchesId.state]),i=new Set([...r,...this.stores.cachedMatchesId.state]),a=n.filter(e=>!i.has(e.id));if(a.length){let e=this.stores.cachedMatchesSnapshot.state;this.stores.setCachedMatches([...e,...a])}try{return n=await os({router:this,matches:n,location:t,preload:!0,updateMatch:(e,t)=>{r.has(e)?n=n.map(n=>n.id===e?t(n):n):this.updateMatch(e,t)}}),n}catch(e){if(Fo(e))return e.options.reloadDocument?void 0:await this.preloadRoute({...e.options,_fromLocation:t});ho(e)||console.error(e);return}},this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n);if(t?.pending&&this.stores.status.state!==`pending`)return!1;let i=(t?.pending===void 0?!this.stores.isLoading.state:t.pending)?this.latestLocation:this.stores.resolvedLocation.state||this.stores.location.state,a=Ga(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,i.pathname,this.processedTree);return!a||e.params&&!Sa(a.rawParams,e.params,{partial:!0})?!1:t?.includeSearch??!0?Sa(i.search,r.search,{partial:!0})?a.rawParams:!1:a.rawParams},this.hasNotFoundMatch=()=>this.stores.activeMatchesSnapshot.state.some(e=>e.status===`notFound`||e.globalNotFound),this.getStoreConfig=t,this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??Ao,parseSearch:e.parseSearch??ko,protocolAllowlist:e.protocolAllowlist??Da}),typeof document<`u`&&(self.__TSR_ROUTER__=this)}isShell(){return!!this.options.isShell}isPrerendering(){return!!this.options.isPrerendering}get state(){return this.stores.__store.state}setRoutes({routesById:e,routesByPath:t,processedTree:n}){this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)}get looseRoutesById(){return this.routesById}getParentContext(e){return e?.id?e.context??this.options.context??void 0:this.options.context??void 0}matchRoutesInternal(e,t){let n=this.getMatchedRoutes(e.pathname),{foundRoute:r,routeParams:i,parsedParams:a}=n,{matchedRoutes:o}=n,s=!1;(r?r.path!==`/`&&i[`**`]:ao(e.pathname))&&(this.options.notFoundRoute?o=[...o,this.options.notFoundRoute]:s=!0);let c=s?ks(this.options.notFoundMode,o):void 0,l=Array(o.length),u=new Map;for(let e of this.stores.activeMatchStoresById.values())e.routeId&&u.set(e.routeId,e.state);for(let n=0;n<o.length;n++){let r=o[n],s=l[n-1],d,f,p;{let n=s?.search??e.search,i=s?._strictSearch??void 0;try{let e=Ts(r.options.validateSearch,{...n})??void 0;d={...n,...e},f={...i,...e},p=void 0}catch(e){let r=e;if(e instanceof Ss||(r=new Ss(e.message,{cause:e})),t?.throwOnError)throw r;d=n,f={},p=r}}let m=r.options.loaderDeps?.({search:d})??``,h=m?JSON.stringify(m):``,{interpolatedPath:g,usedParams:_}=po({path:r.fullPath,params:i,decoder:this.pathParamsDecoder,server:this.isServer}),v=r.id+g+h,y=this.getMatch(v),b=u.get(r.id),x=y?._strictParams??_,S;if(!y)try{As(r,_,a,x)}catch(e){if(S=ho(e)||Fo(e)?e:new Cs(e.message,{cause:e}),t?.throwOnError)throw S}Object.assign(i,x);let C=b?`stay`:`enter`,w;if(y)w={...y,cause:C,params:b?.params??i,_strictParams:x,search:ga(b?b.search:y.search,d),_strictSearch:f};else{let e=r.options.loader||r.options.beforeLoad||r.lazyFn||ls(r)?`pending`:`success`;w={id:v,ssr:r.options.ssr,index:n,routeId:r.id,params:b?.params??i,_strictParams:x,pathname:g,updatedAt:Date.now(),search:b?ga(b.search,d):d,_strictSearch:f,searchError:void 0,status:e,isFetching:!1,error:void 0,paramsError:S,__routeContext:void 0,_nonReactive:{loadPromise:Ca()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:C,loaderDeps:b?_a(b.loaderDeps,m):m,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:r.options.staticData||{},fullPath:r.fullPath}}t?.preload||(w.globalNotFound=c===r.id),w.searchError=p;let T=this.getParentContext(s);w.context={...T,...w.__routeContext,...w.__beforeLoadContext},l[n]=w}for(let t=0;t<l.length;t++){let n=l[t],r=this.looseRoutesById[n.routeId],a=this.getMatch(n.id),o=u.get(n.routeId);if(n.params=o?ga(o.params,i):i,!a){let i=l[t-1],a=this.getParentContext(i);if(r.options.context){let t={deps:n.loaderDeps,params:n.params,context:a??{},location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:n.cause,abortController:n.abortController,preload:!!n.preload,matches:l,routeId:r.id};n.__routeContext=r.options.context(t)??void 0}n.context={...a,...n.__routeContext,...n.__beforeLoadContext}}}return l}matchRoutesLightweight(e){let{matchedRoutes:t,routeParams:n,parsedParams:r}=this.getMatchedRoutes(e.pathname),i=ua(t),a={...e.search};for(let e of t)try{Object.assign(a,Ts(e.options.validateSearch,a))}catch{}let o=ua(this.stores.matchesId.state),s=o&&this.stores.activeMatchStoresById.get(o)?.state,c=s&&s.routeId===i.id&&s.pathname===e.pathname,l;if(c)l=s.params;else{let e=Object.assign(Object.create(null),n);for(let i of t)try{As(i,n,r??{},e)}catch{}l=e}return{matchedRoutes:t,fullPath:i.fullPath,search:a,params:l}}},Ss=class extends Error{},Cs=class extends Error{};function ws(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:`idle`,resolvedLocation:void 0,location:e,matches:[],statusCode:200}}function Ts(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new Ss(`Async validation not supported`);if(n.issues)throw new Ss(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function Es({pathname:e,routesById:t,processedTree:n}){let r=Object.create(null),i=ao(e),a,o,s=Ka(i,n,!0);return s&&(a=s.route,Object.assign(r,s.rawParams),o=Object.assign(Object.create(null),s.parsedParams)),{matchedRoutes:s?.branch||[t.__root__],routeParams:r,foundRoute:a,parsedParams:o}}function Ds({search:e,dest:t,destRoutes:n,_includeValidateSearch:r}){return Os(n)(e,t,r??!1)}function Os(e){let t={dest:null,_includeValidateSearch:!1,middlewares:[]};for(let n of e)`search`in n.options?n.options.search?.middlewares&&t.middlewares.push(...n.options.search.middlewares):(n.options.preSearchFilters||n.options.postSearchFilters)&&t.middlewares.push(({search:e,next:t})=>{let r=e;`preSearchFilters`in n.options&&n.options.preSearchFilters&&(r=n.options.preSearchFilters.reduce((e,t)=>t(e),e));let i=t(r);return`postSearchFilters`in n.options&&n.options.postSearchFilters?n.options.postSearchFilters.reduce((e,t)=>t(e),i):i}),n.options.validateSearch&&t.middlewares.push(({search:e,next:r})=>{let i=r(e);if(!t._includeValidateSearch)return i;try{return{...i,...Ts(n.options.validateSearch,i)??void 0}}catch{return i}});t.middlewares.push(({search:e})=>{let n=t.dest;return n.search?n.search===!0?e:fa(n.search,e):{}});let n=(e,t,r)=>{if(e>=r.length)return t;let i=r[e];return i({search:t,next:t=>n(e+1,t,r)})};return function(e,r,i){return t.dest=r,t._includeValidateSearch=i,n(0,e,t.middlewares)}}function ks(e,t){if(e!==`root`)for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.children)return n.id}return No}function As(e,t,n,r){let i=e.options.params?.parse??e.options.parseParams;if(i)if(e.options.skipRouteOnParseError)for(let e in t)e in n&&(r[e]=n[e]);else{let e=i(r);Object.assign(r,e)}}var js=`Error preloading route! ☝️`,Ms=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=No:this.parentRoute||Ma();let r=n?No:t?.path;r&&r!==`/`&&(r=io(r));let i=t?.id||r,a=n?No:no([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=no([`/`,a]));let o=a===`__root__`?`/`:no([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=ao(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>Po({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},Ns=class extends Ms{constructor(e){super(e)}};function Ps(e){if(typeof document<`u`&&document.querySelector){let t=e.stores.location.state,n=t.state.__hashScrollIntoViewOptions??!0;if(n&&t.hash!==``){let e=document.getElementById(t.hash);e&&e.scrollIntoView(n)}}}var G=r();function Fs(e){let t=e.errorComponent??Ls;return(0,G.jsx)(Is,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?W.createElement(t,{error:n,reset:r}):e.children})}var Is=class extends W.Component{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromProps(e){return{resetKey:e.getResetKey()}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidUpdate(e,t){t.error&&t.resetKey!==this.state.resetKey&&this.reset()}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.resetKey===this.props.getResetKey()?this.state.error:null,reset:()=>{this.reset()}})}};function Ls({error:e}){let[t,n]=W.useState(!1);return(0,G.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,G.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,G.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,G.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,G.jsx)(`div`,{children:(0,G.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,G.jsx)(`code`,{children:e.message}):null})}):null]})}function Rs({children:e,fallback:t=null}){return zs()?(0,G.jsx)(W.Fragment,{children:e}):(0,G.jsx)(W.Fragment,{children:t})}function zs(){return W.useSyncExternalStore(Bs,()=>!0,()=>!1)}function Bs(){return()=>{}}var Vs=W.createContext(null);function Hs(e){return W.useContext(Vs)}var Us=W.createContext(void 0),Ws=W.createContext(void 0),K=(e=>(e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e))(K||{});function Gs({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function Ks(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var qs=[],Js=0,{link:Ys,unlink:Xs,propagate:Zs,checkDirty:Qs,shallowPropagate:$s}=Gs({update(e){return e._update()},notify(e){qs[tc++]=e,e.flags&=~K.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=K.Mutable|K.Dirty,ac(e))}}),ec=0,tc=0,nc,rc=0;function ic(e){try{++rc,e()}finally{--rc||oc()}}function ac(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Xs(n,e)}function oc(){if(!(rc>0)){for(;ec<tc;){let e=qs[ec];qs[ec++]=void 0,e.notify()}ec=0,tc=0}}function sc(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?K.None:K.Mutable,get(){return nc!==void 0&&Ys(i,nc,Js),i._snapshot},subscribe(e){let t=Ks(e),n={current:!1},r=cc(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=nc,o=t?.compare??Object.is;if(n)nc=i,++Js,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=K.Mutable|K.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{nc=a,n&&(i.flags&=~K.RecursedCheck),ac(i)}}};return n?(i.flags=K.Mutable|K.Dirty,i.get=function(){let e=i.flags;if(e&K.Dirty||e&K.Pending&&Qs(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&$s(e)}}else e&K.Pending&&(i.flags=e&~K.Pending);return nc!==void 0&&Ys(i,nc,Js),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Zs(e),$s(e),oc())}},i}function cc(e){let t=()=>{let t=nc;nc=n,++Js,n.depsTail=void 0,n.flags=K.Watching|K.RecursedCheck;try{return e()}finally{nc=t,n.flags&=~K.RecursedCheck,ac(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:K.Watching|K.RecursedCheck,notify(){let e=this.flags;e&K.Dirty||e&K.Pending&&Qs(this.deps,this)?t():this.flags=K.Watching},stop(){this.flags=K.None,this.depsTail=void 0,ac(this)}};return t(),n}var lc=class{constructor(e){this.atom=sc(e)}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(Ks(e))}},uc=class{constructor(e){this.atom=sc(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(Ks(e))}};function dc(e){return typeof e==`function`?new uc(e):new lc(e)}var fc=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),pc=t(((e,t)=>{t.exports=fc()})),mc=t((e=>{var t=n(),r=pc();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),hc=t(((e,t)=>{t.exports=mc()}))();function gc(e,t){return e===t}function _c(e,t,n=gc){let r=(0,W.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,W.useCallback)(()=>e?.get(),[e]);return(0,hc.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var vc={state:void 0,get:()=>void 0,subscribe:()=>()=>{}};function yc(e){let t=Hs(),n=W.useContext(e.from?Ws:Us),r=e.from??n,i=r?e.from?t.stores.getMatchStoreByRouteId(r):t.stores.activeMatchStoresById.get(r):void 0,a=W.useRef(void 0);return _c(i??vc,n=>{if((e.shouldThrow??!0)&&!n&&Ma(),n===void 0)return;let r=e.select?e.select(n):n;if(e.structuralSharing??t.options.defaultStructuralSharing){let e=_a(a.current,r);return a.current=e,e}return r})}function bc(e){return yc({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function xc(e){let{select:t,...n}=e;return yc({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function Sc(e){return yc({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function Cc(e){return yc({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function wc(e){let t=Hs();return W.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function Tc(e){return yc({...e,select:t=>e.select?e.select(t.context):t.context})}var Ec=T();function Dc(e,t){let n=Hs(),r=la(t),{activeProps:i,inactiveProps:a,activeOptions:o,to:s,preload:c,preloadDelay:l,hashScrollIntoView:u,replace:d,startTransition:f,resetScroll:p,viewTransition:m,children:h,target:g,disabled:_,style:v,className:y,onClick:b,onBlur:x,onFocus:S,onMouseEnter:C,onMouseLeave:w,onTouchStart:T,ignoreBlocker:E,params:D,search:O,hash:k,state:A,mask:j,reloadDocument:M,unsafeRelative:N,from:P,_fromLocation:F,...I}=e,L=zs(),R=W.useMemo(()=>e,[n,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),z=_c(n.stores.location,e=>e,(e,t)=>e.href===t.href),B=W.useMemo(()=>{let e={_fromLocation:z,...R};return n.buildLocation(e)},[n,z,R]),V=B.maskedLocation?B.maskedLocation.publicHref:B.publicHref,ee=B.maskedLocation?B.maskedLocation.external:B.external,te=W.useMemo(()=>Ic(V,ee,n.history,_),[_,ee,V,n.history]),H=W.useMemo(()=>{if(te?.external)return Oa(te.href,n.protocolAllowlist)?void 0:te.href;if(!Lc(s)&&!(typeof s!=`string`||s.indexOf(`:`)===-1))try{return new URL(s),Oa(s,n.protocolAllowlist)?void 0:s}catch{}},[s,te,n.protocolAllowlist]),ne=W.useMemo(()=>{if(H)return!1;if(o?.exact){if(!co(z.pathname,B.pathname,n.basepath))return!1}else{let e=so(z.pathname,n.basepath),t=so(B.pathname,n.basepath);if(!(e.startsWith(t)&&(e.length===t.length||e[t.length]===`/`)))return!1}return(o?.includeSearch??!0)&&!Sa(z.search,B.search,{partial:!o?.exact,ignoreUndefined:!o?.explicitUndefined})?!1:o?.includeHash?L&&z.hash===B.hash:!0},[o?.exact,o?.explicitUndefined,o?.includeHash,o?.includeSearch,z,H,L,B.hash,B.pathname,B.search,n.basepath]),re=ne?fa(i,{})??kc:Oc,ie=ne?Oc:fa(a,{})??Oc,ae=[y,re.className,ie.className].filter(Boolean).join(` `),oe=(v||re.style||ie.style)&&{...v,...re.style,...ie.style},[se,ce]=W.useState(!1),le=W.useRef(!1),ue=e.reloadDocument||H?!1:c??n.options.defaultPreload,de=l??n.options.defaultPreloadDelay??0,fe=W.useCallback(()=>{n.preloadRoute({...R,_builtLocation:B}).catch(e=>{console.warn(e),console.warn(js)})},[n,R,B]);ca(r,W.useCallback(e=>{e?.isIntersecting&&fe()},[fe]),Pc,{disabled:!!_||ue!==`viewport`}),W.useEffect(()=>{le.current||!_&&ue===`render`&&(fe(),le.current=!0)},[_,fe,ue]);let pe=e=>{let t=e.currentTarget.getAttribute(`target`),r=g===void 0?t:g;if(!_&&!zc(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0){e.preventDefault(),(0,Ec.flushSync)(()=>{ce(!0)});let t=n.subscribe(`onResolved`,()=>{t(),ce(!1)});n.navigate({...R,replace:d,resetScroll:p,hashScrollIntoView:u,startTransition:f,viewTransition:m,ignoreBlocker:E})}};if(H)return{...I,ref:r,href:H,...h&&{children:h},...g&&{target:g},..._&&{disabled:_},...v&&{style:v},...y&&{className:y},...b&&{onClick:b},...x&&{onBlur:x},...S&&{onFocus:S},...C&&{onMouseEnter:C},...w&&{onMouseLeave:w},...T&&{onTouchStart:T}};let me=e=>{if(_||ue!==`intent`)return;if(!de){fe();return}let t=e.currentTarget;if(Nc.has(t))return;let n=setTimeout(()=>{Nc.delete(t),fe()},de);Nc.set(t,n)},he=e=>{_||ue!==`intent`||fe()},ge=e=>{if(_||!ue||!de)return;let t=e.currentTarget,n=Nc.get(t);n&&(clearTimeout(n),Nc.delete(t))};return{...I,...re,...ie,href:te?.href,ref:r,onClick:Fc([b,pe]),onBlur:Fc([x,ge]),onFocus:Fc([S,me]),onMouseEnter:Fc([C,me]),onMouseLeave:Fc([w,ge]),onTouchStart:Fc([T,he]),disabled:!!_,target:g,...oe&&{style:oe},...ae&&{className:ae},..._&&Ac,...ne&&jc,...L&&se&&Mc}}var Oc={},kc={className:`active`},Ac={role:`link`,"aria-disabled":!0},jc={"data-status":`active`,"aria-current":`page`},Mc={"data-transitioning":`transitioning`},Nc=new WeakMap,Pc={rootMargin:`100px`},Fc=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function Ic(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function Lc(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var Rc=W.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=Dc(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return W.createElement(`a`,t,o)}return W.createElement(n,a,o)});function zc(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var Bc=class extends Ms{constructor(e){super(e),this.useMatch=e=>yc({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>Tc({...e,from:this.id}),this.useSearch=e=>Cc({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>Sc({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>xc({...e,from:this.id}),this.useLoaderData=e=>bc({...e,from:this.id}),this.useNavigate=()=>wc({from:this.fullPath}),this.Link=W.forwardRef((e,t)=>(0,G.jsx)(Rc,{ref:t,from:this.fullPath,...e}))}};function Vc(e){return new Bc(e)}var Hc=class extends Ns{constructor(e){super(e),this.useMatch=e=>yc({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>Tc({...e,from:this.id}),this.useSearch=e=>Cc({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>Sc({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>xc({...e,from:this.id}),this.useLoaderData=e=>bc({...e,from:this.id}),this.useNavigate=()=>wc({from:this.fullPath}),this.Link=W.forwardRef((e,t)=>(0,G.jsx)(Rc,{ref:t,from:this.fullPath,...e}))}};function Uc(e){return new Hc(e)}function Wc(e){let t=Hs(),n=`not-found-${_c(t.stores.location,e=>e.pathname)}-${_c(t.stores.status,e=>e)}`;return(0,G.jsx)(Fs,{getResetKey:()=>n,onCatch:(t,n)=>{if(ho(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(ho(t))return e.fallback?.(t);throw t},children:e.children})}function Gc(){return(0,G.jsx)(`p`,{children:`Not Found`})}function Kc(e){return(0,G.jsx)(G.Fragment,{children:e.children})}function qc(e,t,n){return t.options.notFoundComponent?(0,G.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,G.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,G.jsx)(Gc,{})}var Jc=W.memo(function({matchId:e}){let t=Hs(),n=t.stores.activeMatchStoresById.get(e);n||Ma();let r=_c(t.stores.loadedAt,e=>e),i=_c(n,e=>e);return(0,G.jsx)(Yc,{router:t,matchId:e,resetKey:r,matchState:W.useMemo(()=>{let e=i.routeId,n=t.routesById[e].parentRoute?.id;return{routeId:e,ssr:i.ssr,_displayPending:i._displayPending,parentRouteId:n}},[i._displayPending,i.routeId,i.ssr,t.routesById])})});function Yc({router:e,matchId:t,resetKey:n,matchState:r}){let i=e.routesById[r.routeId],a=i.options.pendingComponent??e.options.defaultPendingComponent,o=a?(0,G.jsx)(a,{}):null,s=i.options.errorComponent??e.options.defaultErrorComponent,c=i.options.onCatch??e.options.defaultOnCatch,l=i.isRoot?i.options.notFoundComponent??e.options.notFoundRoute?.options.component:i.options.notFoundComponent,u=r.ssr===!1||r.ssr===`data-only`,d=(!i.isRoot||i.options.wrapInSuspense||u)&&(i.options.wrapInSuspense??a??(i.options.errorComponent?.preload||u))?W.Suspense:Kc,f=s?Fs:Kc,p=l?Wc:Kc;return(0,G.jsxs)(i.isRoot?i.options.shellComponent??Kc:Kc,{children:[(0,G.jsx)(Us.Provider,{value:t,children:(0,G.jsx)(d,{fallback:o,children:(0,G.jsx)(f,{getResetKey:()=>n,errorComponent:s||Ls,onCatch:(e,t)=>{if(ho(e))throw e.routeId??=r.routeId,e;c?.(e,t)},children:(0,G.jsx)(p,{fallback:e=>{if(e.routeId??=r.routeId,!l||e.routeId&&e.routeId!==r.routeId||!e.routeId&&!i.isRoot)throw e;return W.createElement(l,e)},children:u||r._displayPending?(0,G.jsx)(Rs,{fallback:o,children:(0,G.jsx)(Zc,{matchId:t})}):(0,G.jsx)(Zc,{matchId:t})})})})}),r.parentRouteId===`__root__`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Xc,{resetKey:n}),(e.options.scrollRestoration,null)]}):null]})}function Xc({resetKey:e}){let t=Hs(),n=W.useRef(void 0);return oa(()=>{let e=t.latestLocation.href;(n.current===void 0||n.current!==e)&&(t.emit({type:`onRendered`,...bs(t.stores.location.state,t.stores.resolvedLocation.state)}),n.current=e)},[t.latestLocation.state.__TSR_key,e,t]),null}var Zc=W.memo(function({matchId:e}){let t=Hs(),n=t.stores.activeMatchStoresById.get(e);n||Ma();let r=_c(n,e=>e),i=r.routeId,a=t.routesById[i],o=W.useMemo(()=>{let e=(t.routesById[i].options.remountDeps??t.options.defaultRemountDeps)?.({routeId:i,loaderDeps:r.loaderDeps,params:r._strictParams,search:r._strictSearch});return e?JSON.stringify(e):void 0},[i,r.loaderDeps,r._strictParams,r._strictSearch,t.options.defaultRemountDeps,t.routesById]),s=W.useMemo(()=>{let e=a.options.component??t.options.defaultComponent;return e?(0,G.jsx)(e,{},o):(0,G.jsx)(Qc,{})},[o,a.options.component,t.options.defaultComponent]);if(r._displayPending)throw t.getMatch(r.id)?._nonReactive.displayPendingPromise;if(r._forcePending)throw t.getMatch(r.id)?._nonReactive.minPendingPromise;if(r.status===`pending`){let e=a.options.pendingMinMs??t.options.defaultPendingMinMs;if(e){let n=t.getMatch(r.id);if(n&&!n._nonReactive.minPendingPromise){let t=Ca();n._nonReactive.minPendingPromise=t,setTimeout(()=>{t.resolve(),n._nonReactive.minPendingPromise=void 0},e)}}throw t.getMatch(r.id)?._nonReactive.loadPromise}if(r.status===`notFound`)return ho(r.error)||Ma(),qc(t,a,r.error);if(r.status===`redirected`)throw Fo(r.error)||Ma(),t.getMatch(r.id)?._nonReactive.loadPromise;if(r.status===`error`)throw r.error;return s}),Qc=W.memo(function(){let e=Hs(),t=W.useContext(Us),n,r=!1,i;{let a=t?e.stores.activeMatchStoresById.get(t):void 0;[n,r]=_c(a,e=>[e?.routeId,e?.globalNotFound??!1]),i=_c(e.stores.matchesId,e=>e[e.findIndex(e=>e===t)+1])}let a=n?e.routesById[n]:void 0,o=e.options.defaultPendingComponent?(0,G.jsx)(e.options.defaultPendingComponent,{}):null;if(r)return a||Ma(),qc(e,a,void 0);if(!i)return null;let s=(0,G.jsx)(Jc,{matchId:i});return n===`__root__`?(0,G.jsx)(W.Suspense,{fallback:o,children:s}):s});function $c(){let e=Hs(),t=W.useRef({router:e,mounted:!1}),[n,r]=W.useState(!1),i=_c(e.stores.isLoading,e=>e),a=_c(e.stores.hasPendingMatches,e=>e),o=sa(i),s=i||n||a,c=sa(s),l=i||a,u=sa(l);return e.startTransition=e=>{r(!0),W.startTransition(()=>{e(),r(!1)})},W.useEffect(()=>{let t=e.history.subscribe(e.load),n=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return ao(e.latestLocation.publicHref)!==ao(n.publicHref)&&e.commitLocation({...n,replace:!0}),()=>{t()}},[e,e.history]),oa(()=>{typeof window<`u`&&e.ssr||t.current.router===e&&t.current.mounted||(t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(e){console.error(e)}})())},[e]),oa(()=>{o&&!i&&e.emit({type:`onLoad`,...bs(e.stores.location.state,e.stores.resolvedLocation.state)})},[o,e,i]),oa(()=>{u&&!l&&e.emit({type:`onBeforeRouteMount`,...bs(e.stores.location.state,e.stores.resolvedLocation.state)})},[l,u,e]),oa(()=>{if(c&&!s){let t=bs(e.stores.location.state,e.stores.resolvedLocation.state);e.emit({type:`onResolved`,...t}),ic(()=>{e.stores.status.setState(()=>`idle`),e.stores.resolvedLocation.setState(()=>e.stores.location.state)}),t.hrefChanged&&Ps(e)}},[s,c,e]),null}function el(){let e=Hs(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,n=t?(0,G.jsx)(t,{}):null,r=(0,G.jsxs)(typeof document<`u`&&e.ssr?Kc:W.Suspense,{fallback:n,children:[(0,G.jsx)($c,{}),(0,G.jsx)(tl,{})]});return e.options.InnerWrap?(0,G.jsx)(e.options.InnerWrap,{children:r}):r}function tl(){let e=Hs(),t=_c(e.stores.firstMatchId,e=>e),n=_c(e.stores.loadedAt,e=>e),r=t?(0,G.jsx)(Jc,{matchId:t}):null;return(0,G.jsx)(Us.Provider,{value:t,children:e.options.disableGlobalCatchBoundary?r:(0,G.jsx)(Fs,{getResetKey:()=>n,errorComponent:Ls,onCatch:void 0,children:r})})}var nl=e=>({createMutableStore:dc,createReadonlyStore:dc,batch:ic}),rl=e=>new il(e),il=class extends xs{constructor(e){super(e,nl)}};function al({router:e,children:t,...n}){Object.keys(n).length>0&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,G.jsx)(Vs.Provider,{value:e,children:t});return e.options.Wrap?(0,G.jsx)(e.options.Wrap,{children:r}):r}function ol({router:e,...t}){return(0,G.jsx)(al,{router:e,...t,children:(0,G.jsx)(el,{})})}function sl(e){let t=Hs({warn:e?.router===void 0}),n=e?.router||t,r=(0,W.useRef)(void 0);return _c(n.stores.__store,t=>{if(e?.select){if(e.structuralSharing??n.options.defaultStructuralSharing){let n=_a(r.current,e.select(t));return r.current=n,n}return e.select(t)}return t})}var cl=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ll=new class extends cl{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},ul={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},dl=new class{#e=ul;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function fl(e){setTimeout(e,0)}var pl=typeof window>`u`||`Deno`in globalThis;function ml(){}function hl(e,t){return typeof e==`function`?e(t):e}function gl(e){return typeof e==`number`&&e>=0&&e!==1/0}function _l(e,t){return Math.max(e+(t||0)-Date.now(),0)}function vl(e,t){return typeof e==`function`?e(t):e}function yl(e,t){return typeof e==`function`?e(t):e}function bl(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Sl(o,t.options))return!1}else if(!wl(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function xl(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Cl(t.options.mutationKey)!==Cl(a))return!1}else if(!wl(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Sl(e,t){return(t?.queryKeyHashFn||Cl)(e)}function Cl(e){return JSON.stringify(e,(e,t)=>kl(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function wl(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>wl(e[n],t[n])):!1}var Tl=Object.prototype.hasOwnProperty;function El(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Ol(e)&&Ol(t);if(!r&&!(kl(e)&&kl(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Tl.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=El(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Dl(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Ol(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function kl(e){if(!Al(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Al(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Al(e){return Object.prototype.toString.call(e)===`[object Object]`}function jl(e){return new Promise(t=>{dl.setTimeout(t,e)})}function Ml(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:El(e,t)}function Nl(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Pl(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Fl=Symbol();function Il(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Fl?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ll(e,t){return typeof e==`function`?e(...t):!!e}function Rl(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var zl=(()=>{let e=()=>pl;return{isServer(){return e()},setIsServer(t){e=t}}})();function Bl(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var Vl=fl;function Hl(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Vl,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var q=Hl(),Ul=new class extends cl{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Wl(e){return Math.min(1e3*2**e,3e4)}function Gl(e){return(e??`online`)===`online`?Ul.isOnline():!0}var Kl=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ql(e){let t=!1,n=0,r,i=Bl(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new Kl(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>ll.isFocused()&&(e.networkMode===`always`||Ul.isOnline())&&e.canRun(),u=()=>Gl(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(zl.isServer()?0:3),o=e.retryDelay??Wl,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),jl(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var Jl=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),gl(this.gcTime)&&(this.#e=dl.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(zl.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(dl.clearTimeout(this.#e),this.#e=void 0)}},Yl=class extends Jl{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Ql(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Ql(this.options);e.data!==void 0&&(this.setState(Zl(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=Ml(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(ml).catch(ml):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>yl(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Fl||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>vl(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!_l(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=Il(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=ql({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Kl&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Kl){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Xl(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Zl(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}})(this.state),q.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function Xl(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Gl(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Zl(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Ql(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var $l=class extends cl{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Bl(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),tu(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return nu(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return nu(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof yl(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Dl(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&ru(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||yl(this.options.enabled,this.#t)!==yl(t.enabled,this.#t)||vl(this.options.staleTime,this.#t)!==vl(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||yl(this.options.enabled,this.#t)!==yl(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return au(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(ml)),t}#g(){this.#b();let e=vl(this.options.staleTime,this.#t);if(zl.isServer()||this.#r.isStale||!gl(e))return;let t=_l(this.#r.dataUpdatedAt,e)+1;this.#d=dl.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(zl.isServer()||yl(this.options.enabled,this.#t)===!1||!gl(this.#p)||this.#p===0)&&(this.#f=dl.setInterval(()=>{(this.options.refetchIntervalInBackground||ll.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(dl.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(dl.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&tu(e,t),o=i&&ru(e,n,t,r);(a||o)&&(l={...l,...Xl(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=Ml(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Ml(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:iu(e,t),refetch:this.refetch,promise:this.#o,isEnabled:yl(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=Bl())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Dl(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){q.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function eu(e,t){return yl(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function tu(e,t){return eu(e,t)||e.state.data!==void 0&&nu(e,t,t.refetchOnMount)}function nu(e,t,n){if(yl(t.enabled,e)!==!1&&vl(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&iu(e,t)}return!1}function ru(e,t,n,r){return(e!==t||yl(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&iu(e,n)}function iu(e,t){return yl(t.enabled,e)!==!1&&e.isStaleByTime(vl(t.staleTime,e))}function au(e,t){return!Dl(e.getCurrentResult(),t)}function ou(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Rl(e,()=>t.signal,()=>n=!0)},u=Il(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?Pl:Nl;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?cu:su,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:su(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function su(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function cu(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var lu=class extends Jl{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||uu(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=ql({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),q.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function uu(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var du=class extends cl{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new lu({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=fu(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=fu(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=fu(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=fu(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){q.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>xl(t,e))}findAll(e={}){return this.getAll().filter(t=>xl(e,t))}notify(e){q.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return q.batch(()=>Promise.all(e.map(e=>e.continue().catch(ml))))}};function fu(e){return e.options.scope?.id}var pu=class extends cl{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Sl(r,t),a=this.get(i);return a||(a=new Yl({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){q.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>bl(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>bl(e,t)):t}notify(e){q.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){q.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){q.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},mu=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new pu,this.#t=e.mutationCache||new du,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ll.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Ul.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(vl(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=hl(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return q.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;q.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return q.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=q.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(ml).catch(ml)}invalidateQueries(e,t={}){return q.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=q.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(ml)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(ml)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(vl(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ml).catch(ml)}fetchInfiniteQuery(e){return e.behavior=ou(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ml).catch(ml)}ensureInfiniteQueryData(e){return e.behavior=ou(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Ul.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Cl(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{wl(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Cl(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{wl(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Sl(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Fl&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},hu=W.createContext(void 0),gu=e=>{let t=W.useContext(hu);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},_u=({client:e,children:t})=>(W.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,G.jsx)(hu.Provider,{value:e,children:t})),vu=W.createContext(!1),yu=()=>W.useContext(vu);vu.Provider;function bu(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xu=W.createContext(bu()),Su=()=>W.useContext(xu),Cu=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Ll(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},wu=e=>{W.useEffect(()=>{e.clearReset()},[e])},Tu=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Ll(n,[e.error,r])),Eu=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Du=(e,t)=>e.isLoading&&e.isFetching&&!t,Ou=(e,t)=>e?.suspense&&t.isPending,ku=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Au(e,t,n){let r=yu(),i=Su(),a=gu(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,Eu(o),Cu(o,i,s),wu(i);let c=!a.getQueryCache().get(o.queryHash),[l]=W.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(W.useSyncExternalStore(W.useCallback(e=>{let t=d?l.subscribe(q.batchCalls(e)):ml;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),W.useEffect(()=>{l.setOptions(o)},[o,l]),Ou(o,u))throw ku(o,l,i);if(Tu({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!zl.isServer()&&Du(u,r)&&(c?ku(o,l,i):s?.promise)?.catch(ml).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function ju(e,t){return Au(e,$l,t)}var Mu=E(),Nu={queryKey:[`bundle`],queryFn:async()=>{let e=await fetch(`/api/bundle`);if(!e.ok)throw Error(`Failed to fetch bundle.json`);return e.json()}},Pu=[`go`,`fmo`,`staging`,`integration`,`test1`],Fu=(0,W.createContext)({apiKey:``,userId:``,businessId:``,environment:`go`}),Iu=()=>(0,W.useContext)(Fu),Lu={go:`https://app.go.kizen.com/api`,fmo:`https://app.fmo.kizen.com/api`,staging:`https://staging.kizen.dev/api`,integration:`https://integration.kizen.dev/api`,test1:`https://test1.kizen.dev/api`},Ru={go:`https://go.kizen.com`,fmo:`https://fmo.kizen.com`,staging:`https://v2.staging.kizen.com`,integration:`https://v2.integration.kizen.dev`,test1:`https://test1.kizen.dev`};function zu(){let{apiKey:e,userId:t,businessId:n,environment:r}=Iu(),i=Lu[r];return(0,W.useCallback)((r,a={})=>fetch(`/api/proxy${r}`,{...a,headers:{"x-proxy-target":i,"X-API-KEY":e,"X-USER-ID":t,"X-BUSINESS-ID":n,...a.headers}}),[i,e,t,n])}function Bu(e){let{apiKey:t,userId:n,businessId:r,environment:i}=e;return{queryKey:[`bootstrap`,i,t,n,r],enabled:!!(t&&n&&r),queryFn:async()=>{let e=await fetch(`/api/proxy/auth/bootstrap`,{headers:{"x-proxy-target":Lu[i],"X-API-KEY":t,"X-USER-ID":n,"X-BUSINESS-ID":r}});if(!e.ok)throw Error(`Bootstrap failed: ${String(e.status)} ${e.statusText}`);return e.json()},retry:!1}}function Vu(){let e=gu(),[t,n]=(0,W.useState)([]),[r,i]=(0,W.useState)([]),[a,o]=(0,W.useState)(null);return(0,W.useEffect)(()=>{let t=window.location.protocol===`https:`?`wss:`:`ws:`,r=new WebSocket(`${t}//${window.location.host}`);return r.addEventListener(`message`,t=>{let r;try{r=JSON.parse(t.data)}catch{return}if(r.type===`rebuild`)e.invalidateQueries({queryKey:[`bundle`]});else if(r.type===`open-devtools`)window.electronAPI?.openDevTools();else if(r.type===`log`)n(e=>[...e,r.message]);else if(r.type===`proxy-log`){let e=r.entry??{kind:`info`,message:r.message??``};i(t=>[...t,e])}else o(r.credentials)}),()=>{r.close()}},[e]),{buildLogs:t,proxyLogs:r,serverCredentials:a}}var Hu=`integration:route-change`,Uu=`w-full rounded bg-neutral-800 border border-neutral-700 px-2 py-1 text-[12px] font-mono text-neutral-200 focus:outline-none focus:border-neutral-500`,Wu=`block text-[11px] font-semibold uppercase tracking-widest text-neutral-500 mb-1`;function Gu(e){return e.toTimeString().slice(0,8)}var Ku=()=>{let[e,t]=(0,W.useState)(`/`),[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)([]),c=(0,W.useRef)(null);(0,W.useEffect)(()=>{c.current?.scrollIntoView({behavior:`smooth`})},[o]),(0,W.useEffect)(()=>{let e=e=>{let t=e;s(e=>[...e,{time:new Date,location:t.detail.location}].slice(-50))};return window.addEventListener(Hu,e),()=>{window.removeEventListener(Hu,e)}},[]);let l=()=>{let t=n&&!n.startsWith(`?`)?`?${n}`:n,r=i&&!i.startsWith(`#`)?`#${i}`:i,a={host:window.location.host,origin:window.location.origin,port:window.location.port,protocol:window.location.protocol,pathname:e,search:t,hash:r,href:`${window.location.origin}${e}${t}${r}`};window.dispatchEvent(new CustomEvent(Hu,{detail:{location:a}}))},u=e=>{e.key===`Enter`&&l()};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:Wu,children:`Pathname`}),(0,G.jsx)(`input`,{type:`text`,className:Uu,value:e,onChange:e=>{t(e.target.value)},onKeyDown:u,placeholder:`/client/abc-123/overview`,spellCheck:!1})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:Wu,children:`Search`}),(0,G.jsx)(`input`,{type:`text`,className:Uu,value:n,onChange:e=>{r(e.target.value)},onKeyDown:u,placeholder:`?tab=notes`,spellCheck:!1})]}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:Wu,children:`Hash`}),(0,G.jsx)(`input`,{type:`text`,className:Uu,value:i,onChange:e=>{a(e.target.value)},onKeyDown:u,placeholder:`#section`,spellCheck:!1})]})]}),(0,G.jsx)(`button`,{onClick:l,className:`mt-1 w-full rounded bg-neutral-700 px-3 py-1.5 text-[12px] font-semibold text-neutral-200 hover:bg-neutral-600 active:bg-neutral-500`,children:`Dispatch`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col border-t border-neutral-800 pt-2`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-500`,children:`Event Stream`}),o.length>0&&(0,G.jsx)(`button`,{onClick:()=>{s([])},className:`text-[11px] text-neutral-600 hover:text-neutral-300`,children:`clear`})]}),(0,G.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[o.length===0?(0,G.jsx)(`p`,{className:`text-[12px] text-neutral-600`,children:`No events yet.`}):o.map((e,t)=>(0,G.jsxs)(`div`,{className:`px-2 py-0.5 font-mono text-[11px] leading-5 ${t%2==0?`bg-neutral-900`:`bg-neutral-800/40`}`,children:[(0,G.jsx)(`span`,{className:`text-neutral-600`,children:Gu(e.time)}),(0,G.jsx)(`span`,{className:`ml-2 text-neutral-300`,children:e.location.pathname}),e.location.search&&(0,G.jsx)(`span`,{className:`text-neutral-500`,children:e.location.search}),e.location.hash&&(0,G.jsx)(`span`,{className:`text-neutral-500`,children:e.location.hash})]},t)),(0,G.jsx)(`div`,{ref:c})]})]})]})},qu=`w-full rounded bg-neutral-800 border border-neutral-700 px-2 py-1 text-[12px] font-mono text-neutral-200 focus:outline-none focus:border-neutral-500`,Ju=`block text-[11px] font-semibold uppercase tracking-widest text-neutral-500 mb-1`,Yu=`text-[11px] font-semibold uppercase tracking-widest text-neutral-500`,Xu={log:`text-neutral-400`,info:`text-blue-400`,warn:`text-yellow-400`,error:`text-red-400`};function Zu(e){if(typeof e==`string`)return e;if(e===null)return`null`;if(e===void 0)return`undefined`;try{return JSON.stringify(e)}catch{return`[unserializable]`}}var Qu=({logs:e,height:t})=>{let n=(0,W.useRef)(null);return(0,W.useEffect)(()=>{n.current?.scrollIntoView({behavior:`smooth`})},[e]),(0,G.jsxs)(`div`,{className:`${t} overflow-x-auto overflow-y-auto pb-4`,children:[e.length===0?(0,G.jsx)(`p`,{className:`px-4 text-[12px] text-neutral-600`,children:`No output yet.`}):e.map((e,t)=>(0,G.jsx)(`div`,{className:`whitespace-pre px-4 text-[12px] leading-5 ${Xu[e.level]} ${t%2==0?`bg-neutral-900`:`bg-neutral-800/40`}`,children:e.args.map(Zu).join(` `)},t)),(0,G.jsx)(`div`,{ref:n})]})},$u=({logs:e,height:t})=>{let n=(0,W.useRef)(null);return(0,W.useEffect)(()=>{n.current?.scrollIntoView({behavior:`smooth`})},[e]),(0,G.jsxs)(`div`,{className:`${t} overflow-x-auto overflow-y-auto pb-4`,children:[e.length===0?(0,G.jsx)(`p`,{className:`px-4 text-[12px] text-neutral-600`,children:`No output yet.`}):e.map((e,t)=>(0,G.jsx)(`div`,{className:`whitespace-pre px-4 text-[12px] leading-5 text-neutral-500`,children:e},t)),(0,G.jsx)(`div`,{ref:n})]})};function ed(e){switch(e.toUpperCase()){case`GET`:return`bg-blue-900/60 text-blue-300`;case`POST`:return`bg-green-900/60 text-green-300`;case`PUT`:return`bg-amber-900/60 text-amber-300`;case`PATCH`:return`bg-orange-900/60 text-orange-300`;case`DELETE`:return`bg-red-900/60 text-red-300`;default:return`bg-neutral-800 text-neutral-400`}}function td(e){return e===0?`bg-neutral-800 text-neutral-400`:e<300?`bg-green-900/60 text-green-300`:e<400?`bg-yellow-900/60 text-yellow-300`:e<500?`bg-orange-900/60 text-orange-300`:`bg-red-900/60 text-red-300`}var nd=({logs:e,height:t})=>{let n=(0,W.useRef)(null),[r,i]=(0,W.useState)(null);return(0,W.useEffect)(()=>{n.current?.scrollIntoView({behavior:`smooth`})},[e]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`${t} overflow-x-auto overflow-y-auto pb-4`,children:[e.length===0?(0,G.jsx)(`p`,{className:`px-4 text-[12px] text-neutral-600`,children:`No output yet.`}):e.map((e,t)=>(0,G.jsx)(`div`,{className:`flex items-center gap-1.5 px-3 py-0.5 text-[11px] ${t%2==0?`bg-neutral-900`:`bg-neutral-800/40`}`,children:e.kind===`info`?(0,G.jsx)(`span`,{className:`text-neutral-500`,children:e.message}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`w-12 shrink-0 rounded text-center font-mono font-semibold ${ed(e.method)}`,children:e.method}),(0,G.jsx)(`span`,{className:`w-8 shrink-0 rounded text-center font-mono font-semibold ${td(e.status)}`,children:e.status===0?`ERR`:e.status}),(0,G.jsx)(`span`,{className:`w-14 shrink-0 rounded text-center font-mono font-semibold ${e.fromCache?`bg-violet-900/60 text-violet-300`:`bg-neutral-800 text-neutral-400`}`,children:e.fromCache?`cache`:`network`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate cursor-default font-mono text-neutral-400`,onMouseEnter:t=>{let n=t.currentTarget.getBoundingClientRect();i({text:e.url,x:n.left,y:n.top})},onMouseLeave:()=>i(null),children:e.url})]})},t)),(0,G.jsx)(`div`,{ref:n})]}),r&&(0,G.jsx)(`div`,{className:`pointer-events-none fixed z-50 max-w-xs break-all rounded bg-neutral-700 px-2 py-1 text-[11px] text-neutral-100 shadow-lg`,style:{left:r.x,top:r.y,transform:`translateY(calc(-100% - 4px))`},children:r.text})]})},rd=({onClose:e,buildLogs:t,proxyLogs:n,consoleLogs:r,onClearConsole:i,credentials:a,onCredentialsChange:s})=>{let[c,l]=(0,W.useState)(()=>{let e=localStorage.getItem(`devtools-creds-open`);return e===null?!(a.environment&&a.apiKey&&a.userId&&a.businessId):e!==`false`}),[u,d]=(0,W.useState)(()=>localStorage.getItem(`devtools-routes-open`)!==`false`),[f,p]=(0,W.useState)(()=>localStorage.getItem(`devtools-console-open`)!==`false`),[m,g]=(0,W.useState)(()=>localStorage.getItem(`devtools-proxy-open`)!==`false`),[_,y]=(0,W.useState)(()=>localStorage.getItem(`devtools-build-open`)!==`false`),b=(e,t)=>{t(t=>{let n=!t;return localStorage.setItem(e,String(n)),n})};return(0,G.jsxs)(`aside`,{className:`flex w-104 shrink-0 flex-col border-l border-neutral-800 bg-neutral-900 text-neutral-100`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-800 px-4 py-3`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Dev Tools`}),(0,G.jsx)(`button`,{onClick:e,className:`text-neutral-500 hover:text-neutral-200`,"aria-label":`Close dev tools`,children:(0,G.jsx)(C,{icon:o,size:`sm`})})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col min-h-0`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col border-b border-neutral-800`,children:[(0,G.jsxs)(`button`,{className:`flex items-center justify-between px-4 py-2 hover:bg-neutral-800/50`,onClick:()=>{b(`devtools-creds-open`,l)},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:Yu,children:`Credentials`}),!c&&(0,G.jsx)(`span`,{className:`text-[11px] font-mono text-neutral-400`,children:a.environment})]}),(0,G.jsx)(C,{icon:c?h:v,className:`text-neutral-600`,size:`xs`})]}),c&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 pb-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:Ju,children:`Environment`}),(0,G.jsx)(`select`,{className:qu,value:a.environment,onChange:e=>{s({...a,environment:e.target.value})},children:Pu.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:Ju,children:`API Key`}),(0,G.jsx)(`input`,{type:`password`,className:qu,value:a.apiKey,onChange:e=>{s({...a,apiKey:e.target.value})},placeholder:`x-api-key`,autoComplete:`off`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:Ju,children:`User ID`}),(0,G.jsx)(`input`,{type:`text`,className:qu,value:a.userId,onChange:e=>{s({...a,userId:e.target.value})},placeholder:`x-user-id`,autoComplete:`off`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:Ju,children:`Business ID`}),(0,G.jsx)(`input`,{type:`text`,className:qu,value:a.businessId,onChange:e=>{s({...a,businessId:e.target.value})},placeholder:`x-business-id`,autoComplete:`off`})]})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col border-t border-neutral-800 overflow-hidden`,children:[(0,G.jsxs)(`button`,{className:`flex items-center justify-between px-4 py-2 hover:bg-neutral-800/50`,onClick:()=>{b(`devtools-routes-open`,d)},children:[(0,G.jsx)(`span`,{className:Yu,children:`Routes`}),(0,G.jsx)(C,{icon:u?h:v,className:`text-neutral-600`,size:`xs`})]}),u&&(0,G.jsx)(Ku,{})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col border-t border-neutral-800`,children:[(0,G.jsxs)(`div`,{className:`flex items-center px-4 py-2`,children:[(0,G.jsxs)(`button`,{className:`flex flex-1 items-center gap-2 hover:opacity-70`,onClick:()=>{b(`devtools-console-open`,p)},children:[(0,G.jsx)(`span`,{className:Yu,children:`Console`}),(0,G.jsx)(C,{icon:f?h:v,className:`text-neutral-600`,size:`xs`})]}),f&&r.length>0&&(0,G.jsx)(`button`,{onClick:i,className:`text-[11px] text-neutral-600 hover:text-neutral-300`,children:`clear`})]}),f&&(0,G.jsx)(Qu,{logs:r,height:`min-h-32 max-h-64`})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col min-h-0 border-t border-neutral-800`,children:[(0,G.jsxs)(`div`,{className:`flex items-center px-4 py-2`,children:[(0,G.jsxs)(`button`,{className:`flex flex-1 items-center gap-2 hover:opacity-70`,onClick:()=>{b(`devtools-proxy-open`,g)},children:[(0,G.jsx)(`span`,{className:Yu,children:`Proxy Log`}),(0,G.jsx)(C,{icon:m?h:v,className:`text-neutral-600`,size:`xs`})]}),m&&(0,G.jsx)(`button`,{onClick:()=>{fetch(`/api/proxy-cache/clear`)},className:`text-[11px] text-neutral-600 hover:text-neutral-300`,children:`clear cache`})]}),m&&(0,G.jsx)(nd,{logs:n,height:`flex-1 min-h-0`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col border-t border-neutral-800`,children:[(0,G.jsxs)(`button`,{className:`flex items-center justify-between px-4 py-2 hover:bg-neutral-800/50`,onClick:()=>{b(`devtools-build-open`,y)},children:[(0,G.jsx)(`span`,{className:Yu,children:`Build Log`}),(0,G.jsx)(C,{icon:_?h:v,className:`text-neutral-600`,size:`xs`})]}),_&&(0,G.jsx)($u,{logs:t,height:`max-h-[60px]`})]})]})]})},id=(0,W.createContext)(0),ad=()=>(0,W.useContext)(id),od=(0,W.createContext)(void 0),sd=()=>(0,W.useContext)(od),cd=window.open.bind(window),ld=416,ud={apiKey:``,userId:``,businessId:``,environment:`go`},dd=()=>{let{buildLogs:e,proxyLogs:t,serverCredentials:n}=Vu(),[r,a]=(0,W.useState)([]);(0,W.useEffect)(()=>window.electronAPI?.onConsoleMessage?.(e=>{a(t=>[...t,e])}),[]);let[o,s]=(0,W.useState)(()=>localStorage.getItem(`devtools-sidebar-open`)===`true`),c=()=>{s(e=>{let t=!e;return localStorage.setItem(`devtools-sidebar-open`,String(t)),t})},[l,u]=(0,W.useState)(()=>{try{return{...ud,...JSON.parse(localStorage.getItem(`devtools-credentials`)??`{}`)}}catch{return ud}});(0,W.useEffect)(()=>{fetch(`/api/credentials`).then(e=>e.json()).then(e=>{if(e.apiKey){let t={...ud,...e};u(t),localStorage.setItem(`devtools-credentials`,JSON.stringify(t))}}).catch(()=>{})},[]),(0,W.useEffect)(()=>{if(!n)return;let e={...ud,...n};u(e),localStorage.setItem(`devtools-credentials`,JSON.stringify(e))},[n]);let d=e=>{u(e),localStorage.setItem(`devtools-credentials`,JSON.stringify(e))},{data:f,isLoading:h,isError:g}=ju(Nu),{data:_,isError:v,isLoading:y}=ju(Bu(l)),b=wc(),{location:x}=sl(),S=/^\/([^/]+)\/.+/.exec(x.pathname)?.[1],w=/^\/[^/]+\/([^/]+)$/.exec(x.pathname)?.[1],T=h?`loading`:g?`error`:f?`loaded`:`empty`,E=y?`authenticating`:v?`auth error`:_?`authenticated`:`no auth`,D=h?`bg-neutral-100 text-neutral-400`:g?`bg-red-100 text-red-700`:f?`bg-green-100 text-green-700`:`bg-yellow-100 text-yellow-700`,O=y?`bg-neutral-100 text-neutral-400`:v?`bg-red-100 text-red-700`:_?`bg-green-100 text-green-700`:`bg-yellow-100 text-yellow-700`;return(0,G.jsx)(Fu.Provider,{value:l,children:(0,G.jsx)(id.Provider,{value:o?ld:0,children:(0,G.jsx)(od.Provider,{value:_,children:(0,G.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden font-mono`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-3 border-b border-black/10 bg-white/85 px-5 py-3 backdrop-blur-sm`,children:[(0,G.jsx)(`span`,{className:`text-[13px] font-bold tracking-tight text-neutral-900`,children:`Kizen App Builder`}),f&&f.length>0&&(0,G.jsx)(`select`,{value:S??``,onChange:e=>void b({to:`/$apiName/summary`,params:{apiName:e.target.value}}),className:`rounded border border-black/10 bg-transparent px-2 py-0.5 text-[13px] font-mono text-neutral-700 focus:outline-none`,children:f.map(e=>{let t=e.api_name;return(0,G.jsx)(`option`,{value:t,children:e.name??t},t)})}),w&&S&&(0,G.jsxs)(`select`,{value:w,onChange:e=>void b({to:`/${S}/${e.target.value}`}),className:`rounded border border-black/10 bg-transparent px-2 py-0.5 text-[13px] font-mono text-neutral-700 focus:outline-none`,children:[(0,G.jsx)(`option`,{value:`summary`,children:`Summary`}),(0,G.jsx)(`option`,{value:`sandbox`,children:`Sandbox`}),(0,G.jsx)(`option`,{value:`configuration`,children:`Configuration`}),(0,G.jsx)(`option`,{value:`versions`,children:`Versions`})]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>{window.location.reload()},className:`text-[14px] text-neutral-400 hover:text-neutral-700`,"aria-label":`Refresh page`,children:(0,G.jsx)(C,{icon:m})}),(0,G.jsx)(`button`,{onClick:()=>{cd(Ru[l.environment],`_blank`,`noopener,height=900`)},className:`text-[14px] text-neutral-400 hover:text-neutral-700`,"aria-label":`Toggle dev tools`,children:(0,G.jsx)(C,{icon:p})}),(0,G.jsx)(`button`,{onClick:c,className:`text-[14px] ${o?`text-neutral-700`:`text-neutral-400`} hover:text-neutral-700`,"aria-label":`Toggle dev tools`,children:(0,G.jsx)(C,{icon:i})}),(0,G.jsx)(`span`,{className:`rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide ${D}`,children:T}),(0,G.jsx)(`span`,{className:`rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide ${O}`,children:E})]}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto p-6`,style:{backgroundImage:`
|
|
1
|
+
import{n as e,t}from"./rolldown-runtime-DF2fYuay.js";import{C as n,S as r,_ as i,a,b as o,c as s,d as c,f as l,g as u,h as d,i as f,l as p,m,n as h,o as g,p as _,r as v,s as y,t as b,u as x,v as S,x as C,y as w}from"./fa-core-BU3ZZt7W.js";import{n as T,t as E}from"./react-C90crogl.js";import{$ as D,$i as O,$n as k,$r as A,$t as j,A as M,Ai as N,An as P,Ar as F,At as I,B as L,Bi as R,Bn as z,Br as B,Bt as V,C as ee,Ci as te,Cn as H,Cr as ne,Ct as re,D as ie,Di as ae,Dn as oe,Dr as se,Dt as ce,E as le,Ei as ue,En as de,Er as fe,Et as pe,F as me,Fi as he,Fn as ge,Fr as _e,Ft as ve,G as ye,Gi as be,Gn as xe,Gr as Se,Gt as Ce,H as we,Hi as Te,Hn as Ee,Hr as De,Ht as Oe,I as ke,Ii as Ae,In as je,Ir as Me,It as Ne,J as Pe,Ji as Fe,Jn as Ie,Jr as U,Jt as Le,K as Re,Ki as ze,Kn as Be,Kr as Ve,Kt as He,L as Ue,Li as We,Ln as Ge,Lr as Ke,Lt as qe,M as Je,Mi as Ye,Mn as Xe,Mr as Ze,Mt as Qe,N as $e,Ni as et,Nn as tt,Nr as nt,Nt as rt,O as it,Oi as at,On as ot,Or as st,Ot as ct,P as lt,Pi as ut,Pn as dt,Pr as ft,Pt as pt,Q as mt,Qi as ht,Qn as gt,Qr as _t,Qt as vt,R as yt,Ri as bt,Rn as xt,Rr as St,Rt as Ct,S as wt,Sa as Tt,Si as Et,Sn as Dt,Sr as Ot,St as kt,T as At,Ti as jt,Tn as Mt,Tr as Nt,Tt as Pt,U as Ft,Ui as It,Un as Lt,Ur as Rt,Ut as zt,V as Bt,Vi as Vt,Vn as Ht,Vr as Ut,Vt as Wt,W as Gt,Wi as Kt,Wn as qt,Wr as Jt,Wt as Yt,X as Xt,Xi as Zt,Xn as Qt,Xr as $t,Xt as en,Y as tn,Yi as nn,Yn as rn,Yr as an,Yt as on,Z as sn,Zi as cn,Zn as ln,Zr as un,Zt as dn,_ as fn,_a as pn,_i as mn,_n as hn,_r as gn,_t as _n,a as vn,aa as yn,ai as bn,an as xn,ar as Sn,at as Cn,b as wn,ba as Tn,bi as En,bn as Dn,br as On,bt as kn,c as An,ca as jn,ci as Mn,cn as Nn,cr as Pn,ct as Fn,d as In,da as Ln,di as Rn,dn as zn,dr as Bn,dt as Vn,ea as Hn,ei as Un,en as Wn,er as Gn,et as Kn,f as qn,fa as Jn,fi as Yn,fn as Xn,fr as Zn,ft as Qn,g as $n,ga as er,gi as tr,gn as nr,gr as rr,gt as ir,h as ar,ha as or,hi as sr,hn as cr,hr as lr,ht as ur,i as dr,ia as fr,ii as pr,in as mr,ir as hr,it as gr,j as _r,ji as vr,jn as yr,jr as br,jt as xr,k as Sr,ki as Cr,kn as wr,kr as Tr,kt as Er,l as Dr,la as Or,li as kr,ln as Ar,lr as jr,lt as Mr,m as Nr,ma as Pr,mi as Fr,mn as Ir,mr as Lr,mt as Rr,n as zr,na as Br,ni as Vr,nn as Hr,nr as Ur,nt as Wr,o as Gr,oa as Kr,oi as qr,on as Jr,or as Yr,ot as Xr,p as Zr,pa as Qr,pi as $r,pn as ei,pr as ti,pt as ni,q as ri,qi as ii,qn as ai,qr as oi,qt as si,r as ci,ra as li,ri as ui,rn as di,rr as fi,rt as pi,s as mi,sa as hi,si as gi,sn as _i,sr as vi,st as yi,t as bi,ta as xi,ti as Si,tn as Ci,tr as wi,tt as Ti,u as Ei,ua as Di,ui as Oi,un as ki,ur as Ai,ut as ji,v as Mi,va as Ni,vi as Pi,vn as Fi,vr as Ii,vt as Li,w as Ri,wi as zi,wn as Bi,wr as Vi,wt as Hi,x as Ui,xa as Wi,xi as Gi,xn as Ki,xr as qi,xt as Ji,y as Yi,ya as Xi,yi as Zi,yn as Qi,yr as $i,yt as ea,z as ta,zi as na,zn as ra,zr as ia,zt as aa}from"./fa-pro-icons-D4afj0tU.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var W=e(n(),1);W.use;var oa=typeof window<`u`?W.useLayoutEffect:W.useEffect;function sa(e){let t=W.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function ca(e,t,n={},r={}){W.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function la(e){let t=W.useRef(null);return W.useImperativeHandle(e,()=>t.current,[]),t}function ua(e){return e[e.length-1]}function da(e){return typeof e==`function`}function fa(e,t){return da(e)?e(t):e}var pa=Object.prototype.hasOwnProperty,ma=Object.prototype.propertyIsEnumerable,ha=()=>Object.create(null),ga=(e,t)=>_a(e,t,ha);function _a(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=xa(e)&&xa(i);if(!a&&!(ya(e)&&ya(i)))return i;let o=a?e:va(e);if(!o)return i;let s=a?i:va(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:pa.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=_a(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function va(e){let t=Object.getOwnPropertyNames(e);for(let n of t)if(!ma.call(e,n))return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;let r=t;for(let t of n){if(!ma.call(e,t))return!1;r.push(t)}return r}function ya(e){if(!ba(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ba(n)||!n.hasOwnProperty(`isPrototypeOf`))}function ba(e){return Object.prototype.toString.call(e)===`[object Object]`}function xa(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Sa(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!Sa(e[r],t[r],n))return!1;return!0}if(ya(e)&&ya(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!Sa(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!Sa(e[o],t[o],n)))return!1;return i===a}return!1}function Ca(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function wa(e){return!!(e&&typeof e==`object`&&typeof e.then==`function`)}function Ta(e){return e.replace(/[\x00-\x1f\x7f]/g,``)}function Ea(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return Ta(t)}var Da=[`http:`,`https:`,`mailto:`,`tel:`];function Oa(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function ka(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=Ea(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=Ea(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function Aa(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function ja(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ma(){throw Error(`Invariant failed`)}function Na(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var Pa=4,Fa=5;function Ia(e){let t=e.indexOf(`{`);if(t===-1)return null;let n=e.indexOf(`}`,t);return n===-1||t+1>=e.length?null:[t,n]}function La(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=Ia(a);if(o){let[r,s]=o,c=a.charCodeAt(r+1);if(c===45){if(r+2<a.length&&a.charCodeAt(r+2)===36){let e=r+3,a=s;if(e<a)return n[0]=3,n[1]=t+r,n[2]=t+e,n[3]=t+a,n[4]=t+s+1,n[5]=i,n}}else if(c===36){let a=r+1,o=r+2;return o===s?(n[0]=2,n[1]=t+r,n[2]=t+a,n[3]=t+o,n[4]=t+s+1,n[5]=e.length,n):(n[0]=1,n[1]=t+r,n[2]=t+o,n[3]=t+s,n[4]=t+s+1,n[5]=i,n)}}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function Ra(e,t,n,r,i,a,o){o?.(n);let s=r;{let r=n.fullPath??n.from,o=r.length,c=n.options?.caseSensitive??e,l=!!(n.options?.params?.parse&&n.options?.skipRouteOnParseError?.params);for(;s<o;){let e=La(r,s,t),o,u=s,d=e[5];switch(s=d+1,a++,e[0]){case 0:{let t=r.substring(e[2],e[3]);if(c){let e=i.static?.get(t);if(e)o=e;else{i.static??=new Map;let e=Va(n.fullPath??n.from);e.parent=i,e.depth=a,o=e,i.static.set(t,e)}}else{let e=t.toLowerCase(),r=i.staticInsensitive?.get(e);if(r)o=r;else{i.staticInsensitive??=new Map;let t=Va(n.fullPath??n.from);t.parent=i,t.depth=a,o=t,i.staticInsensitive.set(e,t)}}break}case 1:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.dynamic?.find(e=>!e.skipOnParamError&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=Ha(1,n.fullPath??n.from,f,p,m);o=e,e.depth=a,e.parent=i,i.dynamic??=[],i.dynamic.push(e)}break}case 3:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.optional?.find(e=>!e.skipOnParamError&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=Ha(3,n.fullPath??n.from,f,p,m);o=e,e.parent=i,e.depth=a,i.optional??=[],i.optional.push(e)}break}case 2:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),l=c&&!!(t||s),f=t?l?t:t.toLowerCase():void 0,p=s?l?s:s.toLowerCase():void 0,m=Ha(2,n.fullPath??n.from,l,f,p);o=m,m.parent=i,m.depth=a,i.wildcard??=[],i.wildcard.push(m)}}i=o}if(l&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf(`/`)+1)===95){let e=Va(n.fullPath??n.from);e.kind=Fa,e.parent=i,a++,e.depth=a,i.pathless??=[],i.pathless.push(e),i=e}let u=(n.path||!n.children)&&!n.isRoot;if(u&&r.endsWith(`/`)){let e=Va(n.fullPath??n.from);e.kind=Pa,e.parent=i,a++,e.depth=a,i.index=e,i=e}i.parse=n.options?.params?.parse??null,i.skipOnParamError=l,i.parsingPriority=n.options?.skipRouteOnParseError?.priority??0,u&&!i.route&&(i.route=n,i.fullPath=n.fullPath??n.from)}if(n.children)for(let r of n.children)Ra(e,t,r,s,i,a,o)}function za(e,t){if(e.skipOnParamError&&!t.skipOnParamError)return-1;if(!e.skipOnParamError&&t.skipOnParamError)return 1;if(e.skipOnParamError&&t.skipOnParamError&&(e.parsingPriority||t.parsingPriority))return t.parsingPriority-e.parsingPriority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function Ba(e){if(e.pathless)for(let t of e.pathless)Ba(t);if(e.static)for(let t of e.static.values())Ba(t);if(e.staticInsensitive)for(let t of e.staticInsensitive.values())Ba(t);if(e.dynamic?.length){e.dynamic.sort(za);for(let t of e.dynamic)Ba(t)}if(e.optional?.length){e.optional.sort(za);for(let t of e.optional)Ba(t)}if(e.wildcard?.length){e.wildcard.sort(za);for(let t of e.wildcard)Ba(t)}}function Va(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0}}function Ha(e,t,n,r,i){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,skipOnParamError:!1,parsingPriority:0,caseSensitive:n,prefix:r,suffix:i}}function Ua(e,t){let n=Va(`/`),r=new Uint16Array(6);for(let t of e)Ra(!1,r,t,1,n,0);Ba(n),t.masksTree=n,t.flatCache=Na(1e3)}function Wa(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=Ya(e,t.masksTree);return t.flatCache.set(e,r),r}function Ga(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=Va(`/`),Ra(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),Ya(r,o,n)}function Ka(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=Ya(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=Za(a.route)),t.matchCache.set(r,a),a}function qa(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function Ja(e,t=!1,n){let r=Va(e.fullPath),i=new Uint16Array(6),a={},o={},s=0;return Ra(t,i,e,1,r,0,e=>{if(n?.(e,s),e.id in a&&Ma(),a[e.id]=e,s!==0&&e.path){let t=qa(e.fullPath);(!o[t]||e.fullPath.endsWith(`/`))&&(o[t]=e)}s++}),Ba(r),{processedTree:{segmentTree:r,singleCache:Na(1e3),matchCache:Na(1e3),flatCache:null,masksTree:null},routesById:a,routesByPath:o}}function Ya(e,t,n=!1){let r=e.split(`/`),i=$a(e,r,t,n);if(!i)return null;let[a]=Xa(e,r,i);return{route:i.node.route,rawParams:a,parsedParams:i.parsedParams}}function Xa(e,t,n){let r=Qa(n.node),i=null,a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.segment??0;for(;s<r.length;o++,s++,c++,l++){let u=r[s];if(u.kind===Pa)break;if(u.kind===Fa){l--,o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1){i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0;if(e.charCodeAt(t)===123){let n=u.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=d.substring(t,d.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(d)}}else if(u.kind===3){if(n.skipped&1<<s){o--,c=f-1;continue}i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0,r=u.suffix?.length??0,p=e.substring(t+3,e.length-r-1),m=u.suffix||u.prefix?d.substring(t,d.length-r):d;m&&(a[p]=decodeURIComponent(m))}else if(u.kind===2){let t=u,n=e.substring(f+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,segment:l}]}function Za(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function Qa(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function $a(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!ua(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,depth:1,statics:1,dynamics:0,optionals:0}],c=null,l=null,u=null;for(;s.length;){let n=s.pop(),{node:i,index:d,skipped:f,depth:p,statics:m,dynamics:h,optionals:g}=n,{extract:_,rawParams:v,parsedParams:y}=n;if(i.skipOnParamError){if(!eo(e,t,n))continue;v=n.rawParams,_=n.extract,y=n.parsedParams}r&&i.route&&i.kind!==Pa&&to(l,n)&&(l=n);let b=d===o;if(b&&(i.route&&!a&&to(u,n)&&(u=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let x=b?void 0:t[d],S;if(b&&i.index){let n={node:i.index,index:d,skipped:f,depth:p+1,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y},r=!0;if(i.index.skipOnParamError&&(eo(e,t,n)||(r=!1)),r){if(m===o&&!h&&!g&&!f)return n;to(u,n)&&(u=n)}}if(i.wildcard&&to(c,n))for(let n of i.wildcard){let{prefix:r,suffix:i}=n;if(r&&(b||!(n.caseSensitive?x:S??=x.toLowerCase()).startsWith(r)))continue;if(i){if(b)continue;let e=t.slice(d).join(`/`).slice(-i.length);if((n.caseSensitive?e:e.toLowerCase())!==i)continue}let a={node:n,index:o,skipped:f,depth:p,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y};if(!(n.skipOnParamError&&!eo(e,t,a))){c=a;break}}if(i.optional){let e=f|1<<p,t=p+1;for(let n=i.optional.length-1;n>=0;n--){let r=i.optional[n];s.push({node:r,index:d,skipped:e,depth:t,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b)for(let e=i.optional.length-1;e>=0;e--){let n=i.optional[e],{prefix:r,suffix:a}=n;if(r||a){let e=n.caseSensitive?x:S??=x.toLowerCase();if(r&&!e.startsWith(r)||a&&!e.endsWith(a))continue}s.push({node:n,index:d+1,skipped:f,depth:t,statics:m,dynamics:h,optionals:g+1,extract:_,rawParams:v,parsedParams:y})}}if(!b&&i.dynamic&&x)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?x:S??=x.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:d+1,skipped:f,depth:p+1,statics:m,dynamics:h+1,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b&&i.staticInsensitive){let e=i.staticInsensitive.get(S??=x.toLowerCase());e&&s.push({node:e,index:d+1,skipped:f,depth:p+1,statics:m+1,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(!b&&i.static){let e=i.static.get(x);e&&s.push({node:e,index:d+1,skipped:f,depth:p+1,statics:m+1,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}if(i.pathless){let e=p+1;for(let t=i.pathless.length-1;t>=0;t--){let n=i.pathless[t];s.push({node:n,index:d,skipped:f,depth:e,statics:m,dynamics:h,optionals:g,extract:_,rawParams:v,parsedParams:y})}}}if(u&&c)return to(c,u)?u:c;if(u)return u;if(c)return c;if(r&&l){let n=l.index;for(let e=0;e<l.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return l.rawParams??=Object.create(null),l.rawParams[`**`]=decodeURIComponent(r),l}return null}function eo(e,t,n){try{let[r,i]=Xa(e,t,n);n.rawParams=r,n.extract=i;let a=n.node.parse(r);return n.parsedParams=Object.assign(Object.create(null),n.parsedParams,a),!0}catch{return null}}function to(e,t){return e?t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===Pa)>(e.node.kind===Pa)||t.node.kind===Pa==(e.node.kind===Pa)&&t.depth>e.depth))):!0}function no(e){return ro(e.filter(e=>e!==void 0).join(`/`))}function ro(e){return e.replace(/\/{2,}/g,`/`)}function io(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function ao(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function oo(e){return ao(io(e))}function so(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function co(e,t,n){return so(e,n)===so(t,n)}function lo({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t.startsWith(`/`),a=!i&&t===`.`,o;if(r){o=i?t:a?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(a)s=e.split(`/`);else if(i)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&&ua(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.pop():r===`.`||s.push(r)}}s.length>1&&(ua(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c,l=``;for(let e=0;e<s.length;e++){e>0&&(l+=`/`);let t=s[e];if(!t)continue;c=La(t,0,c);let n=c[0];if(n===0){l+=t;continue}let r=c[5],i=t.substring(0,c[1]),a=t.substring(c[4],r),o=t.substring(c[2],c[3]);n===1?l+=i||a?`${i}{$${o}}${a}`:`$${o}`:n===2?l+=i||a?`${i}{$}${a}`:`$`:l+=`${i}{-$${o}}${a}`}l=ro(l);let u=l||`/`;return o&&r&&r.set(o,u),u}function uo(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=Array.from(t.keys()).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),r=new RegExp(n,`g`);return e=>e.replace(r,e=>t.get(e)??e)}function fo(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split(`/`).map(e=>mo(e,n)).join(`/`):mo(r,n):r}function po({path:e,params:t,decoder:n,...r}){let i=!1,a=Object.create(null);if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:a,isMissingParams:i};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:a,isMissingParams:i};let o=e.length,s=0,c,l=``;for(;s<o;){let r=s;c=La(e,r,c);let o=c[5];if(s=o+1,r===o)continue;let u=c[0];if(u===0){l+=`/`+e.substring(r,o);continue}if(u===2){let s=t._splat;a._splat=s,a[`*`]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o);if(!s){i=!0,(u||d)&&(l+=`/`+u+d);continue}let f=fo(`_splat`,t,n);l+=`/`+u+f+d;continue}if(u===1){let s=e.substring(c[2],c[3]);!i&&!(s in t)&&(i=!0),a[s]=t[s];let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=fo(s,t,n)??`undefined`;l+=`/`+u+f+d;continue}if(u===3){let i=e.substring(c[2],c[3]),s=t[i];if(s==null)continue;a[i]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=fo(i,t,n)??``;l+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(l+=`/`),{usedParams:a,interpolatedPath:l||`/`,isMissingParams:i}}function mo(e,t){let n=encodeURIComponent(e);return t?.(n)??n}function ho(e){return!!e?.isNotFound}function go(){try{return typeof window<`u`&&typeof window.sessionStorage==`object`?window.sessionStorage:void 0}catch{return}}var _o=`tsr-scroll-restoration-v1_3`;function vo(){let e=go();if(!e)return null;let t={};try{let n=JSON.parse(e.getItem(`tsr-scroll-restoration-v1_3`)||`{}`);ya(n)&&(t=n)}catch{}return{get state(){return t},set:e=>{t=fa(e,t)||t},persist:()=>{try{e.setItem(_o,JSON.stringify(t))}catch{}}}}var yo=vo(),bo=e=>e.state.__TSR_key||e.href;function xo(e){let t=[],n;for(;n=e.parentNode;)t.push(`${e.tagName}:nth-child(${Array.prototype.indexOf.call(n.children,e)+1})`),e=n;return`${t.reverse().join(` > `)}`.toLowerCase()}var So=!1,Co=`window`,wo=`data-scroll-restoration-id`;function To(e,t){if(!yo)return;let n=yo;if((t??e.options.scrollRestoration??!1)&&(e.isScrollRestoring=!0),e.isScrollRestorationSetup||!n)return;e.isScrollRestorationSetup=!0,So=!1;let r=e.options.getScrollRestorationKey||bo,i=new Map;window.history.scrollRestoration=`manual`;let a=t=>{if(!(So||!e.isScrollRestoring))if(t.target===document||t.target===window)i.set(Co,{scrollX:window.scrollX||0,scrollY:window.scrollY||0});else{let e=t.target;i.set(e,{scrollX:e.scrollLeft||0,scrollY:e.scrollTop||0})}},o=t=>{if(!e.isScrollRestoring||!t||i.size===0||!n)return;let r=n.state[t]||={};for(let[e,t]of i){let n;if(e===Co)n=Co;else if(e.isConnected){let t=e.getAttribute(wo);n=t?`[${wo}="${t}"]`:xo(e)}n&&(r[n]=t)}};document.addEventListener(`scroll`,a,!0),e.subscribe(`onBeforeLoad`,e=>{o(e.fromLocation?r(e.fromLocation):void 0),i.clear()}),window.addEventListener(`pagehide`,()=>{o(r(e.stores.resolvedLocation.state??e.stores.location.state)),n.persist()}),e.subscribe(`onRendered`,t=>{let a=r(t.toLocation),o=e.options.scrollRestorationBehavior,s=e.options.scrollToTopSelectors;if(i.clear(),!e.resetNextScroll){e.resetNextScroll=!0;return}if(!(typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))){So=!0;try{let t=e.isScrollRestoring?n.state[a]:void 0,r=!1;if(t)for(let e in t){let n=t[e];if(!ya(n))continue;let{scrollX:i,scrollY:a}=n;if(!(!Number.isFinite(i)||!Number.isFinite(a))){if(e===Co)window.scrollTo({top:a,left:i,behavior:o}),r=!0;else if(e){let t;try{t=document.querySelector(e)}catch{continue}t&&(t.scrollLeft=i,t.scrollTop=a,r=!0)}}}if(!r){let t=e.history.location.hash.slice(1);if(t){let e=window.history.state?.__hashScrollIntoViewOptions??!0;if(e){let n=document.getElementById(t);n&&n.scrollIntoView(e)}}else{let e={top:0,left:0,behavior:o};if(window.scrollTo(e),s)for(let t of s){if(t===Co)continue;let n=typeof t==`function`?t():document.querySelector(t);n&&n.scrollTo(e)}}}}finally{So=!1}e.isScrollRestoring&&n.set(e=>(e[a]||={},e))}})}function Eo(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function Do(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function Oo(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=Do(r):Array.isArray(t)?t.push(Do(r)):n[e]=[t,Do(r)]}return n}var ko=jo(JSON.parse),Ao=Mo(JSON.stringify,JSON.parse);function jo(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=Oo(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function Mo(e,t){let n=typeof t==`function`;function r(r){if(typeof r==`object`&&r)try{return e(r)}catch{}else if(n&&typeof r==`string`)try{return t(r),e(r)}catch{}return r}return e=>{let t=Eo(e,r);return t?`?${t}`:``}}var No=`__root__`;function Po(e){if(e.statusCode=e.statusCode||e.code||307,!e._builtLocation&&!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function Fo(e){return e instanceof Response&&!!e.options}function Io(e){return{input:({url:t})=>{for(let n of e)t=Ro(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=zo(e[n],t);return t}}}function Lo(e){let t=oo(e.basepath),n=`/${t}`,r=`${n}/`,i=e.caseSensitive?n:n.toLowerCase(),a=e.caseSensitive?r:r.toLowerCase();return{input:({url:t})=>{let r=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return r===i?t.pathname=`/`:r.startsWith(a)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=no([`/`,t,e.pathname]),e)}}function Ro(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function zo(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function Bo(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i,init:a}=t,o=new Map,s=new Map,c=new Map,l=n(e.status),u=n(e.loadedAt),d=n(e.isLoading),f=n(e.isTransitioning),p=n(e.location),m=n(e.resolvedLocation),h=n(e.statusCode),g=n(e.redirect),_=n([]),v=n([]),y=n([]),b=r(()=>Vo(o,_.state)),x=r(()=>Vo(s,v.state)),S=r(()=>Vo(c,y.state)),C=r(()=>_.state[0]),w=r(()=>_.state.some(e=>o.get(e)?.state.status===`pending`)),T=r(()=>({locationHref:p.state.href,resolvedLocationHref:m.state?.href,status:l.state})),E=r(()=>({status:l.state,loadedAt:u.state,isLoading:d.state,isTransitioning:f.state,matches:b.state,location:p.state,resolvedLocation:m.state,statusCode:h.state,redirect:g.state})),D=Na(64);function O(e){let t=D.get(e);return t||(t=r(()=>{let t=_.state;for(let n of t){let t=o.get(n);if(t&&t.routeId===e)return t.state}}),D.set(e,t)),t}let k={status:l,loadedAt:u,isLoading:d,isTransitioning:f,location:p,resolvedLocation:m,statusCode:h,redirect:g,matchesId:_,pendingMatchesId:v,cachedMatchesId:y,activeMatchesSnapshot:b,pendingMatchesSnapshot:x,cachedMatchesSnapshot:S,firstMatchId:C,hasPendingMatches:w,matchRouteReactivity:T,activeMatchStoresById:o,pendingMatchStoresById:s,cachedMatchStoresById:c,__store:E,getMatchStoreByRouteId:O,setActiveMatches:A,setPendingMatches:j,setCachedMatches:M};A(e.matches),a?.(k);function A(e){Ho(e,o,_,n,i)}function j(e){Ho(e,s,v,n,i)}function M(e){Ho(e,c,y,n,i)}return k}function Vo(e,t){let n=[];for(let r of t){let t=e.get(r);t&&n.push(t.state)}return n}function Ho(e,t,n,r,i){let a=e.map(e=>e.id),o=new Set(a);i(()=>{for(let e of t.keys())o.has(e)||t.delete(e);for(let n of e){let e=t.get(n.id);if(!e){let e=r(n);e.routeId=n.routeId,t.set(n.id,e);continue}e.routeId=n.routeId,e.state!==n&&e.setState(()=>n)}ja(n.state,a)||n.setState(()=>a)})}var Uo=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},Wo=e=>e.stores.matchesId.state.some(t=>e.stores.activeMatchStoresById.get(t)?.state._forcePending),Go=(e,t)=>!!(e.preload&&!e.router.stores.activeMatchStoresById.has(t)),Ko=(e,t,n=!0)=>{let r={...e.router.options.context??{}},i=n?t:t-1;for(let t=0;t<=i;t++){let n=e.matches[t];if(!n)continue;let i=e.router.getMatch(n.id);i&&Object.assign(r,i.__routeContext,i.__beforeLoadContext)}return r},qo=(e,t)=>{if(!e.matches.length)return;let n=t.routeId,r=e.matches.findIndex(t=>t.routeId===e.router.routeTree.id),i=r>=0?r:0,a=n?e.matches.findIndex(e=>e.routeId===n):e.firstBadMatchIndex??e.matches.length-1;a<0&&(a=i);for(let t=a;t>=0;t--){let n=e.matches[t];if(e.router.looseRoutesById[n.routeId].options.notFoundComponent)return t}return n?a:i},Jo=(e,t,n)=>{if(!(!Fo(n)&&!ho(n)))throw Fo(n)&&n.redirectHandled&&!n.options.reloadDocument?n:(t&&(t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0,t._nonReactive.error=n,e.updateMatch(t.id,r=>({...r,status:Fo(n)?`redirected`:r.status===`pending`?`success`:r.status,context:Ko(e,t.index),isFetching:!1,error:n})),ho(n)&&!n.routeId&&(n.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()),Fo(n)&&(e.rendered=!0,n.options._fromLocation=e.location,n.redirectHandled=!0,n=e.router.resolveRedirect(n)),n)},Yo=(e,t)=>{let n=e.router.getMatch(t);return!!(!n||n._nonReactive.dehydrated)},Xo=(e,t,n)=>{let r=Ko(e,n);e.updateMatch(t,e=>({...e,context:r}))},Zo=(e,t,n,r)=>{let{id:i,routeId:a}=e.matches[t],o=e.router.looseRoutesById[a];if(n instanceof Promise)throw n;n.routerCode=r,e.firstBadMatchIndex??=t,Jo(e,e.router.getMatch(i),n);try{o.options.onError?.(n)}catch(t){n=t,Jo(e,e.router.getMatch(i),n)}e.updateMatch(i,e=>(e._nonReactive.beforeLoadPromise?.resolve(),e._nonReactive.beforeLoadPromise=void 0,e._nonReactive.loadPromise?.resolve(),{...e,error:n,status:`error`,isFetching:!1,updatedAt:Date.now(),abortController:new AbortController})),!e.preload&&!Fo(n)&&!ho(n)&&(e.serialError??=n)},Qo=(e,t,n,r)=>{if(r._nonReactive.pendingTimeout!==void 0)return;let i=n.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!Go(e,t)&&(n.options.loader||n.options.beforeLoad||ls(n))&&typeof i==`number`&&i!==1/0&&(n.options.pendingComponent??e.router.options?.defaultPendingComponent)){let t=setTimeout(()=>{Uo(e)},i);r._nonReactive.pendingTimeout=t}},$o=(e,t,n)=>{let r=e.router.getMatch(t);if(!r._nonReactive.beforeLoadPromise&&!r._nonReactive.loaderPromise)return;Qo(e,t,n,r);let i=()=>{let n=e.router.getMatch(t);n.preload&&(n.status===`redirected`||n.status===`notFound`)&&Jo(e,n,n.error)};return r._nonReactive.beforeLoadPromise?r._nonReactive.beforeLoadPromise.then(i):i()},es=(e,t,n,r)=>{let i=e.router.getMatch(t),a=i._nonReactive.loadPromise;i._nonReactive.loadPromise=Ca(()=>{a?.resolve(),a=void 0});let{paramsError:o,searchError:s}=i;o&&Zo(e,n,o,`PARSE_PARAMS`),s&&Zo(e,n,s,`VALIDATE_SEARCH`),Qo(e,t,r,i);let c=new AbortController,l=!1,u=()=>{l||(l=!0,e.updateMatch(t,e=>({...e,isFetching:`beforeLoad`,fetchCount:e.fetchCount+1,abortController:c})))},d=()=>{i._nonReactive.beforeLoadPromise?.resolve(),i._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,e=>({...e,isFetching:!1}))};if(!r.options.beforeLoad){e.router.batch(()=>{u(),d()});return}i._nonReactive.beforeLoadPromise=Ca();let f={...Ko(e,n,!1),...i.__routeContext},{search:p,params:m,cause:h}=i,g=Go(e,t),_={search:p,abortController:c,params:m,preload:g,context:f,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:g?`preload`:h,matches:e.matches,routeId:r.id,...e.router.options.additionalContext},v=r=>{if(r===void 0){e.router.batch(()=>{u(),d()});return}(Fo(r)||ho(r))&&(u(),Zo(e,n,r,`BEFORE_LOAD`)),e.router.batch(()=>{u(),e.updateMatch(t,e=>({...e,__beforeLoadContext:r})),d()})},y;try{if(y=r.options.beforeLoad(_),wa(y))return u(),y.catch(t=>{Zo(e,n,t,`BEFORE_LOAD`)}).then(v)}catch(t){u(),Zo(e,n,t,`BEFORE_LOAD`)}v(y)},ts=(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=e.router.looseRoutesById[r],a=()=>s(),o=()=>es(e,n,t,i),s=()=>{if(Yo(e,n))return;let t=$o(e,n,i);return wa(t)?t.then(o):o()};return a()},ns=(e,t,n)=>{let r=e.router.getMatch(t);if(!r||!n.options.head&&!n.options.scripts&&!n.options.headers)return;let i={ssr:e.router.options.ssr,matches:e.matches,match:r,params:r.params,loaderData:r.loaderData};return Promise.all([n.options.head?.(i),n.options.scripts?.(i),n.options.headers?.(i)]).then(([e,t,n])=>({meta:e?.meta,links:e?.links,headScripts:e?.scripts,headers:n,scripts:t,styles:e?.styles}))},rs=(e,t,n,r,i)=>{let a=t[r-1],{params:o,loaderDeps:s,abortController:c,cause:l}=e.router.getMatch(n),u=Ko(e,r),d=Go(e,n);return{params:o,deps:s,preload:!!d,parentMatchPromise:a,abortController:c,context:u,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),cause:d?`preload`:l,route:i,...e.router.options.additionalContext}},is=async(e,t,n,r,i)=>{try{let a=e.router.getMatch(n);try{cs(i);let o=i.options.loader,s=typeof o==`function`?o:o?.handler,c=s?.(rs(e,t,n,r,i)),l=!!s&&wa(c);if((l||i._lazyPromise||i._componentsPromise||i.options.head||i.options.scripts||i.options.headers||a._nonReactive.minPendingPromise)&&e.updateMatch(n,e=>({...e,isFetching:`loader`})),s){let t=l?await c:c;Jo(e,e.router.getMatch(n),t),t!==void 0&&e.updateMatch(n,e=>({...e,loaderData:t}))}i._lazyPromise&&await i._lazyPromise;let u=a._nonReactive.minPendingPromise;u&&await u,i._componentsPromise&&await i._componentsPromise,e.updateMatch(n,t=>({...t,error:void 0,context:Ko(e,r),status:`success`,isFetching:!1,updatedAt:Date.now()}))}catch(t){let o=t;if(o?.name===`AbortError`){if(a.abortController.signal.aborted){a._nonReactive.loaderPromise?.resolve(),a._nonReactive.loaderPromise=void 0;return}e.updateMatch(n,t=>({...t,status:t.status===`pending`?`success`:t.status,isFetching:!1,context:Ko(e,r)}));return}let s=a._nonReactive.minPendingPromise;s&&await s,ho(t)&&await i.options.notFoundComponent?.preload?.(),Jo(e,e.router.getMatch(n),t);try{i.options.onError?.(t)}catch(t){o=t,Jo(e,e.router.getMatch(n),t)}!Fo(o)&&!ho(o)&&await cs(i,[`errorComponent`]),e.updateMatch(n,t=>({...t,error:o,context:Ko(e,r),status:`error`,isFetching:!1}))}}catch(t){let r=e.router.getMatch(n);r&&(r._nonReactive.loaderPromise=void 0),Jo(e,r,t)}},as=async(e,t,n)=>{async function r(r,a,c,l,d){let f=Date.now()-a.updatedAt,p=r?d.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:d.options.staleTime??e.router.options.defaultStaleTime??0,m=d.options.shouldReload,h=typeof m==`function`?m(rs(e,t,i,n,d)):m,{status:g,invalid:_}=l,v=f>=p&&(!!e.forceStaleReload||l.cause===`enter`||c!==void 0&&c!==l.id);o=g===`success`&&(_||(h??v)),r&&d.options.preload===!1||(o&&!e.sync&&u?(s=!0,(async()=>{try{await is(e,t,i,n,d);let r=e.router.getMatch(i);r._nonReactive.loaderPromise?.resolve(),r._nonReactive.loadPromise?.resolve(),r._nonReactive.loaderPromise=void 0,r._nonReactive.loadPromise=void 0}catch(t){Fo(t)&&await e.router.navigate(t.options)}})()):g!==`success`||o?await is(e,t,i,n,d):Xo(e,i,n))}let{id:i,routeId:a}=e.matches[n],o=!1,s=!1,c=e.router.looseRoutesById[a],l=c.options.loader,u=((typeof l==`function`?void 0:l?.staleReloadMode)??e.router.options.defaultStaleReloadMode)!==`blocking`;if(Yo(e,i)){if(!e.router.getMatch(i))return e.matches[n];Xo(e,i,n)}else{let t=e.router.getMatch(i),o=e.router.stores.matchesId.state[n],s=(o&&e.router.stores.activeMatchStoresById.get(o)||null)?.routeId===a?o:e.router.stores.activeMatchesSnapshot.state.find(e=>e.routeId===a)?.id,l=Go(e,i);if(t._nonReactive.loaderPromise){if(t.status===`success`&&!e.sync&&!t.preload&&u)return t;await t._nonReactive.loaderPromise;let n=e.router.getMatch(i),a=n._nonReactive.error||n.error;a&&Jo(e,n,a),n.status===`pending`&&await r(l,t,s,n,c)}else{let n=l&&!e.router.stores.activeMatchStoresById.has(i),a=e.router.getMatch(i);a._nonReactive.loaderPromise=Ca(),n!==a.preload&&e.updateMatch(i,e=>({...e,preload:n})),await r(l,t,s,a,c)}}let d=e.router.getMatch(i);s||(d._nonReactive.loaderPromise?.resolve(),d._nonReactive.loadPromise?.resolve(),d._nonReactive.loadPromise=void 0),clearTimeout(d._nonReactive.pendingTimeout),d._nonReactive.pendingTimeout=void 0,s||(d._nonReactive.loaderPromise=void 0),d._nonReactive.dehydrated=void 0;let f=s?d.isFetching:!1;return f!==d.isFetching||d.invalid!==!1?(e.updateMatch(i,e=>({...e,isFetching:f,invalid:!1})),e.router.getMatch(i)):d};async function os(e){let t=e,n=[];Wo(t.router)&&Uo(t);let r;for(let e=0;e<t.matches.length;e++){try{let n=ts(t,e);wa(n)&&await n}catch(e){if(Fo(e))throw e;if(ho(e))r=e;else if(!t.preload)throw e;break}if(t.serialError||t.firstBadMatchIndex!=null)break}let i=t.firstBadMatchIndex??t.matches.length,a=r&&!t.preload?qo(t,r):void 0,o=r&&t.preload?0:a===void 0?i:Math.min(a+1,i),s,c;for(let e=0;e<o;e++)n.push(as(t,n,e));try{await Promise.all(n)}catch{let e=await Promise.allSettled(n);for(let t of e){if(t.status!==`rejected`)continue;let e=t.reason;if(Fo(e))throw e;ho(e)?s??=e:c??=e}if(c!==void 0)throw c}let l=s??(r&&!t.preload?r:void 0),u=t.firstBadMatchIndex===void 0?t.matches.length-1:t.firstBadMatchIndex;if(!l&&r&&t.preload)return t.matches;if(l){let e=qo(t,l);e===void 0&&Ma();let n=t.matches[e],r=t.router.looseRoutesById[n.routeId],i=t.router.options?.defaultNotFoundComponent;!r.options.notFoundComponent&&i&&(r.options.notFoundComponent=i),l.routeId=n.routeId;let a=n.routeId===t.router.routeTree.id;t.updateMatch(n.id,e=>({...e,...a?{status:`success`,globalNotFound:!0,error:void 0}:{status:`notFound`,error:l},isFetching:!1})),u=e,await cs(r,[`notFoundComponent`])}else if(!t.preload){let e=t.matches[0];e.globalNotFound||t.router.getMatch(e.id)?.globalNotFound&&t.updateMatch(e.id,e=>({...e,globalNotFound:!1,error:void 0}))}if(t.serialError&&t.firstBadMatchIndex!==void 0){let e=t.router.looseRoutesById[t.matches[t.firstBadMatchIndex].routeId];await cs(e,[`errorComponent`])}for(let e=0;e<=u;e++){let{id:n,routeId:r}=t.matches[e],i=t.router.looseRoutesById[r];try{let e=ns(t,n,i);if(e){let r=await e;t.updateMatch(n,e=>({...e,...r}))}}catch(e){console.error(`Error executing head for route ${r}:`,e)}}let d=Uo(t);if(wa(d)&&await d,l)throw l;if(t.serialError&&!t.preload&&!t.onReady)throw t.serialError;return t.matches}function ss(e,t){let n=t.map(t=>e.options[t]?.preload?.()).filter(Boolean);if(n.length!==0)return Promise.all(n)}function cs(e,t=us){!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(t=>{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0);let n=()=>e._componentsLoaded?void 0:t===us?(()=>{if(e._componentsPromise===void 0){let t=ss(e,us);t?e._componentsPromise=t.then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0}):e._componentsLoaded=!0}return e._componentsPromise})():ss(e,t);return e._lazyPromise?e._lazyPromise.then(n):n()}function ls(e){for(let t of us)if(e.options[t]?.preload)return!0;return!1}var us=[`component`,`errorComponent`,`pendingComponent`,`notFoundComponent`],ds=`__TSR_index`,fs=`popstate`,ps=`beforeunload`;function ms(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=vs(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[ds];i=hs(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[ds];i=hs(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[ds]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function hs(e,t){t||={};let n=ys();return{...t,key:n,__TSR_key:n,[ds]:e}}function gs(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>vs(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=ys();t.history.replaceState({[ds]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_,v=()=>{g&&(C._ignoreSubscribers=!0,(g.isPush?t.history.pushState:t.history.replaceState)(g.state,``,g.href),C._ignoreSubscribers=!1,g=void 0,_=void 0,u=void 0)},y=(e,t,n)=>{let r=s(t);_||(u=l),l=vs(t,n),g={href:r,state:n,isPush:g?.isPush||e===`push`},_||=Promise.resolve().then(()=>v())},b=e=>{l=c(),C.notify({type:e})},x=async()=>{if(f){f=!1;return}let e=c(),n=e.state[ds]-l.state[ds],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),C.notify(u);return}}}l=c(),C.notify(u)},S=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},C=ms({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>y(`push`,e,t),replaceState:(e,t)=>y(`replace`,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:v,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(ps,S,{capture:!0}),t.removeEventListener(fs,x)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(ps,S,{capture:!0}),t.addEventListener(fs,x),t.history.pushState=function(...e){let r=n.apply(t.history,e);return C._ignoreSubscribers||b(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return C._ignoreSubscribers||b(`REPLACE`),n},C}function _s(e){let t=e.replace(/[\x00-\x1f\x7f]/g,``);return t.startsWith(`//`)&&(t=`/`+t.replace(/^\/+/,``)),t}function vs(e,t){let n=_s(e),r=n.indexOf(`#`),i=n.indexOf(`?`),a=ys();return{href:n,pathname:n.substring(0,r>0?i>0?Math.min(r,i):r:i>0?i:n.length),hash:r>-1?n.substring(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t||{[ds]:0,key:a,__TSR_key:a}}}function ys(){return(Math.random()+1).toString(36).substring(7)}function bs(e,t){let n=t,r=e;return{fromLocation:n,toLocation:r,pathChanged:n?.pathname!==r.pathname,hrefChanged:n?.href!==r.href,hashChanged:n?.hash!==r.hash}}var xs=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this.resetNextScroll=!0,this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.isScrollRestoring=!1,this.isScrollRestorationSetup=!1,this.startTransition=e=>e(),this.update=e=>{let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;if(this.options={...t,...e},this.isServer=this.options.isServer??typeof document>`u`,this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=uo(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=gs()),this.origin=this.options.origin,this.origin||(window?.origin&&window.origin!==`null`?this.origin=window.origin:this.origin=`http://localhost`),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;this.resolvePathCache=Na(1e3),e=this.buildRouteTree(),this.setRoutes(e)}if(!this.stores&&this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=Bo(ws(this.latestLocation),e),To(this)}let a=!1,o=this.options.basepath??`/`,s=this.options.rewrite;if(r||n!==o||i!==s){this.basepath=o;let e=[],t=oo(o);t&&t!==`/`&&e.push(Lo({basepath:o})),s&&e.push(s),this.rewrite=e.length===0?void 0:e.length===1?e[0]:Io(e),this.history&&this.updateLatestLocation(),a=!0}a&&this.stores&&this.stores.location.setState(()=>this.latestLocation),typeof window<`u`&&`CSS`in window&&typeof window.CSS?.supports==`function`&&(this.isViewTransitionTypesSupported=window.CSS.supports(`selector(:active-view-transition-type(a)`))},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=Ja(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});return this.options.routeMasks&&Ua(this.options.routeMasks,e.processedTree),e},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{this.subscribers.forEach(t=>{t.eventType===e.type&&t.fn(e)})},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i,state:a})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:ka(e).path,external:!1,searchStr:o,search:ga(t?.search,i),hash:ka(r.slice(1)).path,state:_a(t?.state,a)}}let o=new URL(i,this.origin),s=Ro(this.rewrite,o),c=this.options.parseSearch(s.search),l=this.options.stringifySearch(c);return s.search=l,{href:s.href.replace(s.origin,``),publicHref:i,pathname:ka(s.pathname).path,external:!!this.rewrite&&s.origin!==this.origin,searchStr:l,search:ga(t?.search,c),hash:ka(s.hash.slice(1)).path,state:_a(t?.state,a)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathWithBase=(e,t)=>lo({base:e,to:ro(t),trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>Es({pathname:e,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=e=>{let t=this.getMatch(e);t&&(t.abortController.abort(),clearTimeout(t._nonReactive.pendingTimeout),t._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{this.stores.pendingMatchesId.state.forEach(e=>{this.cancelMatch(e)}),this.stores.matchesId.state.forEach(e=>{if(this.stores.pendingMatchStoresById.has(e))return;let t=this.stores.activeMatchStoresById.get(e)?.state;t&&(t.status===`pending`||t.isFetching===`loader`)&&this.cancelMatch(e)})},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this.pendingBuiltLocation||this.latestLocation,r=this.matchRoutesLightweight(n);t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r.fullPath,a=this.resolvePathWithBase(i,`.`),o=r.search,s=Object.assign(Object.create(null),r.params),c=t.to?this.resolvePathWithBase(a,`${t.to}`):this.resolvePathWithBase(a,`.`),l=t.params===!1||t.params===null?Object.create(null):(t.params??!0)===!0?s:Object.assign(s,fa(t.params,s)),u=this.getMatchedRoutes(c),d=u.matchedRoutes;if((!u.foundRoute||u.foundRoute.path!==`/`&&u.routeParams[`**`])&&this.options.notFoundRoute&&(d=[...d,this.options.notFoundRoute]),Object.keys(l).length>0)for(let e of d){let t=e.options.params?.stringify??e.options.stringifyParams;if(t)try{Object.assign(l,t(l))}catch{}}let f=e.leaveParams?c:ka(po({path:c,params:l,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path,p=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};d.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,Ts(t.options.validateSearch,{...e,...p}))}catch{}}),p=e}p=Ds({search:p,dest:t,destRoutes:d,_includeValidateSearch:e._includeValidateSearch}),p=ga(o,p);let m=this.options.stringifySearch(p),h=t.hash===!0?n.hash:t.hash?fa(t.hash,n.hash):void 0,g=h?`#${h}`:``,_=t.state===!0?n.state:t.state?fa(t.state,n.state):{};_=_a(n.state,_);let v=`${f}${m}${g}`,y,b,x=!1;if(this.rewrite){let e=new URL(v,this.origin),t=zo(this.rewrite,e);y=e.href.replace(e.origin,``),t.origin===this.origin?b=t.pathname+t.search+t.hash:(b=t.href,x=!0)}else y=Aa(v),b=y;return{publicHref:b,href:y,pathname:f,search:p,searchStr:m,state:_,hash:h??``,external:x,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n=Object.create(null);if(this.options.routeMasks){let o=Wa(i.pathname,this.processedTree);if(o){Object.assign(n,o.rawParams);let{from:i,params:s,...c}=o.route,l=s===!1||s===null?Object.create(null):(s??!0)===!0?n:Object.assign(n,fa(s,n));r={from:e.from,...c,params:l},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r=()=>{let e=[`key`,`__TSR_key`,`__TSR_index`,`__hashScrollIntoViewOptions`];e.forEach(e=>{n.state[e]=this.latestLocation.state[e]});let t=Sa(n.state,this.latestLocation.state);return e.forEach(e=>{delete n.state[e]}),t},i=ao(this.latestLocation.href)===ao(n.href),a=this.commitLocationPromise;if(this.commitLocationPromise=Ca(()=>{a?.resolve(),a=void 0}),i&&r())this.load();else{let{maskedLocation:r,hashScrollIntoView:i,...a}=n;r&&(a={...r,state:{...r.state,__tempKey:void 0,__tempLocation:{...a,search:a.searchStr,state:{...a.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(a.unmaskOnReload??this.options.unmaskOnReload??!1)&&(a.state.__tempKey=this.tempLocationKey)),a.state.__hashScrollIntoViewOptions=i??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,this.history[n.replace?`replace`:`push`](a.publicHref,a.state,{ignoreBlocker:t})}return this.resetNextScroll=n.resetScroll??!0,this.history.subscribers.size||this.load(),this.commitLocationPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,href:a,...o}={})=>{if(a){let t=this.history.location.state.__TSR_index,n=vs(a,{__TSR_index:e?t:t+1}),r=new URL(n.pathname,this.origin);o.to=Ro(this.rewrite,r).pathname,o.search=this.options.parseSearch(n.search),o.hash=n.hash.slice(1)}let s=this.buildLocation({...o,_includeValidateSearch:!0});this.pendingBuiltLocation=s;let c=this.commitLocation({...s,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return Promise.resolve().then(()=>{this.pendingBuiltLocation===s&&(this.pendingBuiltLocation=void 0)}),c},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=!1;if(n)try{new URL(`${n}`),a=!0}catch{}if(a&&!t&&(t=!0),t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i});n??=t.publicHref,r??=t.publicHref}let t=!a&&r?r:n;if(Oa(t,this.protocolAllowlist))return Promise.resolve();if(!i.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return Promise.resolve()}return i.replace?window.location.replace(t):window.location.href=t,Promise.resolve()}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.beforeLoad=()=>{this.cancelMatches(),this.updateLatestLocation();let e=this.matchRoutes(this.latestLocation),t=this.stores.cachedMatchesSnapshot.state.filter(t=>!e.some(e=>e.id===t.id));this.batch(()=>{this.stores.status.setState(()=>`pending`),this.stores.statusCode.setState(()=>200),this.stores.isLoading.setState(()=>!0),this.stores.location.setState(()=>this.latestLocation),this.stores.setPendingMatches(e),this.stores.setCachedMatches(t)})},this.load=async e=>{let t,n,r,i=this.stores.resolvedLocation.state??this.stores.location.state;for(r=new Promise(a=>{this.startTransition(async()=>{try{this.beforeLoad();let t=this.latestLocation,n=this.stores.resolvedLocation.state,r=bs(t,n);this.stores.redirect.state||this.emit({type:`onBeforeNavigate`,...r}),this.emit({type:`onBeforeLoad`,...r}),await os({router:this,sync:e?.sync,forceStaleReload:i.href===t.href,matches:this.stores.pendingMatchesSnapshot.state,location:t,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let e=null,t=null,n=null,r=null;this.batch(()=>{let i=this.stores.pendingMatchesSnapshot.state,a=i.length,o=this.stores.activeMatchesSnapshot.state;e=a?o.filter(e=>!this.stores.pendingMatchStoresById.has(e.id)):null;let s=new Set;for(let e of this.stores.pendingMatchStoresById.values())e.routeId&&s.add(e.routeId);let c=new Set;for(let e of this.stores.activeMatchStoresById.values())e.routeId&&c.add(e.routeId);t=a?o.filter(e=>!s.has(e.routeId)):null,n=a?i.filter(e=>!c.has(e.routeId)):null,r=a?i.filter(e=>c.has(e.routeId)):o,this.stores.isLoading.setState(()=>!1),this.stores.loadedAt.setState(()=>Date.now()),a&&(this.stores.setActiveMatches(i),this.stores.setPendingMatches([]),this.stores.setCachedMatches([...this.stores.cachedMatchesSnapshot.state,...e.filter(e=>e.status!==`error`&&e.status!==`notFound`&&e.status!==`redirected`)]),this.clearExpiredCache())});for(let[e,i]of[[t,`onLeave`],[n,`onEnter`],[r,`onStay`]])if(e)for(let t of e)this.looseRoutesById[t.routeId].options[i]?.(t)})})}})}catch(e){Fo(e)?(t=e,this.navigate({...t.options,replace:!0,ignoreBlocker:!0})):ho(e)&&(n=e);let r=t?t.status:n?404:this.stores.activeMatchesSnapshot.state.some(e=>e.status===`error`)?500:200;this.batch(()=>{this.stores.statusCode.setState(()=>r),this.stores.redirect.setState(()=>t)})}this.latestLoadPromise===r&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),a()})}),this.latestLoadPromise=r,await r;this.latestLoadPromise&&r!==this.latestLoadPromise;)await this.latestLoadPromise;let a;this.hasNotFoundMatch()?a=404:this.stores.activeMatchesSnapshot.state.some(e=>e.status===`error`)&&(a=500),a!==void 0&&this.stores.statusCode.setState(()=>a)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document<`u`&&`startViewTransition`in document&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&this.isViewTransitionTypesSupported){let r=this.latestLocation,i=this.stores.resolvedLocation.state,a=typeof t.types==`function`?t.types(bs(r,i)):t.types;if(a===!1){e();return}n={update:e,types:a}}else n=e;document.startViewTransition(n)}else e()},this.updateMatch=(e,t)=>{this.startTransition(()=>{let n=this.stores.pendingMatchStoresById.get(e);if(n){n.setState(t);return}let r=this.stores.activeMatchStoresById.get(e);if(r){r.setState(t);return}let i=this.stores.cachedMatchStoresById.get(e);if(i){let n=t(i.state);n.status===`redirected`?this.stores.cachedMatchStoresById.delete(e)&&this.stores.cachedMatchesId.setState(t=>t.filter(t=>t!==e)):i.setState(()=>n)}})},this.getMatch=e=>this.stores.cachedMatchStoresById.get(e)?.state??this.stores.pendingMatchStoresById.get(e)?.state??this.stores.activeMatchStoresById.get(e)?.state,this.invalidate=e=>{let t=t=>e?.filter?.(t)??!0?{...t,invalid:!0,...e?.forcePending||t.status===`error`||t.status===`notFound`?{status:`pending`,error:void 0}:void 0}:t;return this.batch(()=>{this.stores.setActiveMatches(this.stores.activeMatchesSnapshot.state.map(t)),this.stores.setCachedMatches(this.stores.cachedMatchesSnapshot.state.map(t)),this.stores.setPendingMatches(this.stores.pendingMatchesSnapshot.state.map(t))}),this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.getParsedLocationHref=e=>e.publicHref||`/`,this.resolveRedirect=e=>{let t=e.headers.get(`Location`);if(!e.options.href||e.options._builtLocation){let t=e.options._builtLocation??this.buildLocation(e.options),n=this.getParsedLocationHref(t);e.options.href=n,e.headers.set(`Location`,n)}else if(t)try{let n=new URL(t);if(this.origin&&n.origin===this.origin){let t=n.pathname+n.search+n.hash;e.options.href=t,e.headers.set(`Location`,t)}}catch{}if(e.options.href&&!e.options._builtLocation&&Oa(e.options.href,this.protocolAllowlist))throw Error(`Redirect blocked: unsafe protocol`);return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=e?.filter;t===void 0?this.stores.setCachedMatches([]):this.stores.setCachedMatches(this.stores.cachedMatchesSnapshot.state.filter(e=>!t(e)))},this.clearExpiredCache=()=>{let e=Date.now();this.clearCache({filter:t=>{let n=this.looseRoutesById[t.routeId];if(!n.options.loader)return!0;let r=(t.preload?n.options.preloadGcTime??this.options.defaultPreloadGcTime:n.options.gcTime??this.options.defaultGcTime)??300*1e3;return t.status===`error`?!0:e-t.updatedAt>=r}})},this.loadRouteChunk=cs,this.preloadRoute=async e=>{let t=e._builtLocation??this.buildLocation(e),n=this.matchRoutes(t,{throwOnError:!0,preload:!0,dest:e}),r=new Set([...this.stores.matchesId.state,...this.stores.pendingMatchesId.state]),i=new Set([...r,...this.stores.cachedMatchesId.state]),a=n.filter(e=>!i.has(e.id));if(a.length){let e=this.stores.cachedMatchesSnapshot.state;this.stores.setCachedMatches([...e,...a])}try{return n=await os({router:this,matches:n,location:t,preload:!0,updateMatch:(e,t)=>{r.has(e)?n=n.map(n=>n.id===e?t(n):n):this.updateMatch(e,t)}}),n}catch(e){if(Fo(e))return e.options.reloadDocument?void 0:await this.preloadRoute({...e.options,_fromLocation:t});ho(e)||console.error(e);return}},this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n);if(t?.pending&&this.stores.status.state!==`pending`)return!1;let i=(t?.pending===void 0?!this.stores.isLoading.state:t.pending)?this.latestLocation:this.stores.resolvedLocation.state||this.stores.location.state,a=Ga(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,i.pathname,this.processedTree);return!a||e.params&&!Sa(a.rawParams,e.params,{partial:!0})?!1:t?.includeSearch??!0?Sa(i.search,r.search,{partial:!0})?a.rawParams:!1:a.rawParams},this.hasNotFoundMatch=()=>this.stores.activeMatchesSnapshot.state.some(e=>e.status===`notFound`||e.globalNotFound),this.getStoreConfig=t,this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??Ao,parseSearch:e.parseSearch??ko,protocolAllowlist:e.protocolAllowlist??Da}),typeof document<`u`&&(self.__TSR_ROUTER__=this)}isShell(){return!!this.options.isShell}isPrerendering(){return!!this.options.isPrerendering}get state(){return this.stores.__store.state}setRoutes({routesById:e,routesByPath:t,processedTree:n}){this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)}get looseRoutesById(){return this.routesById}getParentContext(e){return e?.id?e.context??this.options.context??void 0:this.options.context??void 0}matchRoutesInternal(e,t){let n=this.getMatchedRoutes(e.pathname),{foundRoute:r,routeParams:i,parsedParams:a}=n,{matchedRoutes:o}=n,s=!1;(r?r.path!==`/`&&i[`**`]:ao(e.pathname))&&(this.options.notFoundRoute?o=[...o,this.options.notFoundRoute]:s=!0);let c=s?ks(this.options.notFoundMode,o):void 0,l=Array(o.length),u=new Map;for(let e of this.stores.activeMatchStoresById.values())e.routeId&&u.set(e.routeId,e.state);for(let n=0;n<o.length;n++){let r=o[n],s=l[n-1],d,f,p;{let n=s?.search??e.search,i=s?._strictSearch??void 0;try{let e=Ts(r.options.validateSearch,{...n})??void 0;d={...n,...e},f={...i,...e},p=void 0}catch(e){let r=e;if(e instanceof Ss||(r=new Ss(e.message,{cause:e})),t?.throwOnError)throw r;d=n,f={},p=r}}let m=r.options.loaderDeps?.({search:d})??``,h=m?JSON.stringify(m):``,{interpolatedPath:g,usedParams:_}=po({path:r.fullPath,params:i,decoder:this.pathParamsDecoder,server:this.isServer}),v=r.id+g+h,y=this.getMatch(v),b=u.get(r.id),x=y?._strictParams??_,S;if(!y)try{As(r,_,a,x)}catch(e){if(S=ho(e)||Fo(e)?e:new Cs(e.message,{cause:e}),t?.throwOnError)throw S}Object.assign(i,x);let C=b?`stay`:`enter`,w;if(y)w={...y,cause:C,params:b?.params??i,_strictParams:x,search:ga(b?b.search:y.search,d),_strictSearch:f};else{let e=r.options.loader||r.options.beforeLoad||r.lazyFn||ls(r)?`pending`:`success`;w={id:v,ssr:r.options.ssr,index:n,routeId:r.id,params:b?.params??i,_strictParams:x,pathname:g,updatedAt:Date.now(),search:b?ga(b.search,d):d,_strictSearch:f,searchError:void 0,status:e,isFetching:!1,error:void 0,paramsError:S,__routeContext:void 0,_nonReactive:{loadPromise:Ca()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:C,loaderDeps:b?_a(b.loaderDeps,m):m,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:r.options.staticData||{},fullPath:r.fullPath}}t?.preload||(w.globalNotFound=c===r.id),w.searchError=p;let T=this.getParentContext(s);w.context={...T,...w.__routeContext,...w.__beforeLoadContext},l[n]=w}for(let t=0;t<l.length;t++){let n=l[t],r=this.looseRoutesById[n.routeId],a=this.getMatch(n.id),o=u.get(n.routeId);if(n.params=o?ga(o.params,i):i,!a){let i=l[t-1],a=this.getParentContext(i);if(r.options.context){let t={deps:n.loaderDeps,params:n.params,context:a??{},location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:n.cause,abortController:n.abortController,preload:!!n.preload,matches:l,routeId:r.id};n.__routeContext=r.options.context(t)??void 0}n.context={...a,...n.__routeContext,...n.__beforeLoadContext}}}return l}matchRoutesLightweight(e){let{matchedRoutes:t,routeParams:n,parsedParams:r}=this.getMatchedRoutes(e.pathname),i=ua(t),a={...e.search};for(let e of t)try{Object.assign(a,Ts(e.options.validateSearch,a))}catch{}let o=ua(this.stores.matchesId.state),s=o&&this.stores.activeMatchStoresById.get(o)?.state,c=s&&s.routeId===i.id&&s.pathname===e.pathname,l;if(c)l=s.params;else{let e=Object.assign(Object.create(null),n);for(let i of t)try{As(i,n,r??{},e)}catch{}l=e}return{matchedRoutes:t,fullPath:i.fullPath,search:a,params:l}}},Ss=class extends Error{},Cs=class extends Error{};function ws(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:`idle`,resolvedLocation:void 0,location:e,matches:[],statusCode:200}}function Ts(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new Ss(`Async validation not supported`);if(n.issues)throw new Ss(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function Es({pathname:e,routesById:t,processedTree:n}){let r=Object.create(null),i=ao(e),a,o,s=Ka(i,n,!0);return s&&(a=s.route,Object.assign(r,s.rawParams),o=Object.assign(Object.create(null),s.parsedParams)),{matchedRoutes:s?.branch||[t.__root__],routeParams:r,foundRoute:a,parsedParams:o}}function Ds({search:e,dest:t,destRoutes:n,_includeValidateSearch:r}){return Os(n)(e,t,r??!1)}function Os(e){let t={dest:null,_includeValidateSearch:!1,middlewares:[]};for(let n of e)`search`in n.options?n.options.search?.middlewares&&t.middlewares.push(...n.options.search.middlewares):(n.options.preSearchFilters||n.options.postSearchFilters)&&t.middlewares.push(({search:e,next:t})=>{let r=e;`preSearchFilters`in n.options&&n.options.preSearchFilters&&(r=n.options.preSearchFilters.reduce((e,t)=>t(e),e));let i=t(r);return`postSearchFilters`in n.options&&n.options.postSearchFilters?n.options.postSearchFilters.reduce((e,t)=>t(e),i):i}),n.options.validateSearch&&t.middlewares.push(({search:e,next:r})=>{let i=r(e);if(!t._includeValidateSearch)return i;try{return{...i,...Ts(n.options.validateSearch,i)??void 0}}catch{return i}});t.middlewares.push(({search:e})=>{let n=t.dest;return n.search?n.search===!0?e:fa(n.search,e):{}});let n=(e,t,r)=>{if(e>=r.length)return t;let i=r[e];return i({search:t,next:t=>n(e+1,t,r)})};return function(e,r,i){return t.dest=r,t._includeValidateSearch=i,n(0,e,t.middlewares)}}function ks(e,t){if(e!==`root`)for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.children)return n.id}return No}function As(e,t,n,r){let i=e.options.params?.parse??e.options.parseParams;if(i)if(e.options.skipRouteOnParseError)for(let e in t)e in n&&(r[e]=n[e]);else{let e=i(r);Object.assign(r,e)}}var js=`Error preloading route! ☝️`,Ms=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=No:this.parentRoute||Ma();let r=n?No:t?.path;r&&r!==`/`&&(r=io(r));let i=t?.id||r,a=n?No:no([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=no([`/`,a]));let o=a===`__root__`?`/`:no([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=ao(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>Po({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},Ns=class extends Ms{constructor(e){super(e)}};function Ps(e){if(typeof document<`u`&&document.querySelector){let t=e.stores.location.state,n=t.state.__hashScrollIntoViewOptions??!0;if(n&&t.hash!==``){let e=document.getElementById(t.hash);e&&e.scrollIntoView(n)}}}var G=r();function Fs(e){let t=e.errorComponent??Ls;return(0,G.jsx)(Is,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?W.createElement(t,{error:n,reset:r}):e.children})}var Is=class extends W.Component{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromProps(e){return{resetKey:e.getResetKey()}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidUpdate(e,t){t.error&&t.resetKey!==this.state.resetKey&&this.reset()}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.resetKey===this.props.getResetKey()?this.state.error:null,reset:()=>{this.reset()}})}};function Ls({error:e}){let[t,n]=W.useState(!1);return(0,G.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,G.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,G.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,G.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,G.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,G.jsx)(`div`,{children:(0,G.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,G.jsx)(`code`,{children:e.message}):null})}):null]})}function Rs({children:e,fallback:t=null}){return zs()?(0,G.jsx)(W.Fragment,{children:e}):(0,G.jsx)(W.Fragment,{children:t})}function zs(){return W.useSyncExternalStore(Bs,()=>!0,()=>!1)}function Bs(){return()=>{}}var Vs=W.createContext(null);function Hs(e){return W.useContext(Vs)}var Us=W.createContext(void 0),Ws=W.createContext(void 0),K=(e=>(e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e))(K||{});function Gs({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function Ks(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var qs=[],Js=0,{link:Ys,unlink:Xs,propagate:Zs,checkDirty:Qs,shallowPropagate:$s}=Gs({update(e){return e._update()},notify(e){qs[tc++]=e,e.flags&=~K.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=K.Mutable|K.Dirty,ac(e))}}),ec=0,tc=0,nc,rc=0;function ic(e){try{++rc,e()}finally{--rc||oc()}}function ac(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=Xs(n,e)}function oc(){if(!(rc>0)){for(;ec<tc;){let e=qs[ec];qs[ec++]=void 0,e.notify()}ec=0,tc=0}}function sc(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?K.None:K.Mutable,get(){return nc!==void 0&&Ys(i,nc,Js),i._snapshot},subscribe(e){let t=Ks(e),n={current:!1},r=cc(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=nc,o=t?.compare??Object.is;if(n)nc=i,++Js,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=K.Mutable|K.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{nc=a,n&&(i.flags&=~K.RecursedCheck),ac(i)}}};return n?(i.flags=K.Mutable|K.Dirty,i.get=function(){let e=i.flags;if(e&K.Dirty||e&K.Pending&&Qs(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&$s(e)}}else e&K.Pending&&(i.flags=e&~K.Pending);return nc!==void 0&&Ys(i,nc,Js),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(Zs(e),$s(e),oc())}},i}function cc(e){let t=()=>{let t=nc;nc=n,++Js,n.depsTail=void 0,n.flags=K.Watching|K.RecursedCheck;try{return e()}finally{nc=t,n.flags&=~K.RecursedCheck,ac(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:K.Watching|K.RecursedCheck,notify(){let e=this.flags;e&K.Dirty||e&K.Pending&&Qs(this.deps,this)?t():this.flags=K.Watching},stop(){this.flags=K.None,this.depsTail=void 0,ac(this)}};return t(),n}var lc=class{constructor(e){this.atom=sc(e)}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(Ks(e))}},uc=class{constructor(e){this.atom=sc(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(Ks(e))}};function dc(e){return typeof e==`function`?new uc(e):new lc(e)}var fc=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),pc=t(((e,t)=>{t.exports=fc()})),mc=t((e=>{var t=n(),r=pc();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),hc=t(((e,t)=>{t.exports=mc()}))();function gc(e,t){return e===t}function _c(e,t,n=gc){let r=(0,W.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,W.useCallback)(()=>e?.get(),[e]);return(0,hc.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var vc={state:void 0,get:()=>void 0,subscribe:()=>()=>{}};function yc(e){let t=Hs(),n=W.useContext(e.from?Ws:Us),r=e.from??n,i=r?e.from?t.stores.getMatchStoreByRouteId(r):t.stores.activeMatchStoresById.get(r):void 0,a=W.useRef(void 0);return _c(i??vc,n=>{if((e.shouldThrow??!0)&&!n&&Ma(),n===void 0)return;let r=e.select?e.select(n):n;if(e.structuralSharing??t.options.defaultStructuralSharing){let e=_a(a.current,r);return a.current=e,e}return r})}function bc(e){return yc({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function xc(e){let{select:t,...n}=e;return yc({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function Sc(e){return yc({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function Cc(e){return yc({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function wc(e){let t=Hs();return W.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}function Tc(e){return yc({...e,select:t=>e.select?e.select(t.context):t.context})}var Ec=T();function Dc(e,t){let n=Hs(),r=la(t),{activeProps:i,inactiveProps:a,activeOptions:o,to:s,preload:c,preloadDelay:l,hashScrollIntoView:u,replace:d,startTransition:f,resetScroll:p,viewTransition:m,children:h,target:g,disabled:_,style:v,className:y,onClick:b,onBlur:x,onFocus:S,onMouseEnter:C,onMouseLeave:w,onTouchStart:T,ignoreBlocker:E,params:D,search:O,hash:k,state:A,mask:j,reloadDocument:M,unsafeRelative:N,from:P,_fromLocation:F,...I}=e,L=zs(),R=W.useMemo(()=>e,[n,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),z=_c(n.stores.location,e=>e,(e,t)=>e.href===t.href),B=W.useMemo(()=>{let e={_fromLocation:z,...R};return n.buildLocation(e)},[n,z,R]),V=B.maskedLocation?B.maskedLocation.publicHref:B.publicHref,ee=B.maskedLocation?B.maskedLocation.external:B.external,te=W.useMemo(()=>Ic(V,ee,n.history,_),[_,ee,V,n.history]),H=W.useMemo(()=>{if(te?.external)return Oa(te.href,n.protocolAllowlist)?void 0:te.href;if(!Lc(s)&&!(typeof s!=`string`||s.indexOf(`:`)===-1))try{return new URL(s),Oa(s,n.protocolAllowlist)?void 0:s}catch{}},[s,te,n.protocolAllowlist]),ne=W.useMemo(()=>{if(H)return!1;if(o?.exact){if(!co(z.pathname,B.pathname,n.basepath))return!1}else{let e=so(z.pathname,n.basepath),t=so(B.pathname,n.basepath);if(!(e.startsWith(t)&&(e.length===t.length||e[t.length]===`/`)))return!1}return(o?.includeSearch??!0)&&!Sa(z.search,B.search,{partial:!o?.exact,ignoreUndefined:!o?.explicitUndefined})?!1:o?.includeHash?L&&z.hash===B.hash:!0},[o?.exact,o?.explicitUndefined,o?.includeHash,o?.includeSearch,z,H,L,B.hash,B.pathname,B.search,n.basepath]),re=ne?fa(i,{})??kc:Oc,ie=ne?Oc:fa(a,{})??Oc,ae=[y,re.className,ie.className].filter(Boolean).join(` `),oe=(v||re.style||ie.style)&&{...v,...re.style,...ie.style},[se,ce]=W.useState(!1),le=W.useRef(!1),ue=e.reloadDocument||H?!1:c??n.options.defaultPreload,de=l??n.options.defaultPreloadDelay??0,fe=W.useCallback(()=>{n.preloadRoute({...R,_builtLocation:B}).catch(e=>{console.warn(e),console.warn(js)})},[n,R,B]);ca(r,W.useCallback(e=>{e?.isIntersecting&&fe()},[fe]),Pc,{disabled:!!_||ue!==`viewport`}),W.useEffect(()=>{le.current||!_&&ue===`render`&&(fe(),le.current=!0)},[_,fe,ue]);let pe=e=>{let t=e.currentTarget.getAttribute(`target`),r=g===void 0?t:g;if(!_&&!zc(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0){e.preventDefault(),(0,Ec.flushSync)(()=>{ce(!0)});let t=n.subscribe(`onResolved`,()=>{t(),ce(!1)});n.navigate({...R,replace:d,resetScroll:p,hashScrollIntoView:u,startTransition:f,viewTransition:m,ignoreBlocker:E})}};if(H)return{...I,ref:r,href:H,...h&&{children:h},...g&&{target:g},..._&&{disabled:_},...v&&{style:v},...y&&{className:y},...b&&{onClick:b},...x&&{onBlur:x},...S&&{onFocus:S},...C&&{onMouseEnter:C},...w&&{onMouseLeave:w},...T&&{onTouchStart:T}};let me=e=>{if(_||ue!==`intent`)return;if(!de){fe();return}let t=e.currentTarget;if(Nc.has(t))return;let n=setTimeout(()=>{Nc.delete(t),fe()},de);Nc.set(t,n)},he=e=>{_||ue!==`intent`||fe()},ge=e=>{if(_||!ue||!de)return;let t=e.currentTarget,n=Nc.get(t);n&&(clearTimeout(n),Nc.delete(t))};return{...I,...re,...ie,href:te?.href,ref:r,onClick:Fc([b,pe]),onBlur:Fc([x,ge]),onFocus:Fc([S,me]),onMouseEnter:Fc([C,me]),onMouseLeave:Fc([w,ge]),onTouchStart:Fc([T,he]),disabled:!!_,target:g,...oe&&{style:oe},...ae&&{className:ae},..._&&Ac,...ne&&jc,...L&&se&&Mc}}var Oc={},kc={className:`active`},Ac={role:`link`,"aria-disabled":!0},jc={"data-status":`active`,"aria-current":`page`},Mc={"data-transitioning":`transitioning`},Nc=new WeakMap,Pc={rootMargin:`100px`},Fc=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function Ic(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function Lc(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var Rc=W.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=Dc(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return W.createElement(`a`,t,o)}return W.createElement(n,a,o)});function zc(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var Bc=class extends Ms{constructor(e){super(e),this.useMatch=e=>yc({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>Tc({...e,from:this.id}),this.useSearch=e=>Cc({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>Sc({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>xc({...e,from:this.id}),this.useLoaderData=e=>bc({...e,from:this.id}),this.useNavigate=()=>wc({from:this.fullPath}),this.Link=W.forwardRef((e,t)=>(0,G.jsx)(Rc,{ref:t,from:this.fullPath,...e}))}};function Vc(e){return new Bc(e)}var Hc=class extends Ns{constructor(e){super(e),this.useMatch=e=>yc({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>Tc({...e,from:this.id}),this.useSearch=e=>Cc({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>Sc({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>xc({...e,from:this.id}),this.useLoaderData=e=>bc({...e,from:this.id}),this.useNavigate=()=>wc({from:this.fullPath}),this.Link=W.forwardRef((e,t)=>(0,G.jsx)(Rc,{ref:t,from:this.fullPath,...e}))}};function Uc(e){return new Hc(e)}function Wc(e){let t=Hs(),n=`not-found-${_c(t.stores.location,e=>e.pathname)}-${_c(t.stores.status,e=>e)}`;return(0,G.jsx)(Fs,{getResetKey:()=>n,onCatch:(t,n)=>{if(ho(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(ho(t))return e.fallback?.(t);throw t},children:e.children})}function Gc(){return(0,G.jsx)(`p`,{children:`Not Found`})}function Kc(e){return(0,G.jsx)(G.Fragment,{children:e.children})}function qc(e,t,n){return t.options.notFoundComponent?(0,G.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,G.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,G.jsx)(Gc,{})}var Jc=W.memo(function({matchId:e}){let t=Hs(),n=t.stores.activeMatchStoresById.get(e);n||Ma();let r=_c(t.stores.loadedAt,e=>e),i=_c(n,e=>e);return(0,G.jsx)(Yc,{router:t,matchId:e,resetKey:r,matchState:W.useMemo(()=>{let e=i.routeId,n=t.routesById[e].parentRoute?.id;return{routeId:e,ssr:i.ssr,_displayPending:i._displayPending,parentRouteId:n}},[i._displayPending,i.routeId,i.ssr,t.routesById])})});function Yc({router:e,matchId:t,resetKey:n,matchState:r}){let i=e.routesById[r.routeId],a=i.options.pendingComponent??e.options.defaultPendingComponent,o=a?(0,G.jsx)(a,{}):null,s=i.options.errorComponent??e.options.defaultErrorComponent,c=i.options.onCatch??e.options.defaultOnCatch,l=i.isRoot?i.options.notFoundComponent??e.options.notFoundRoute?.options.component:i.options.notFoundComponent,u=r.ssr===!1||r.ssr===`data-only`,d=(!i.isRoot||i.options.wrapInSuspense||u)&&(i.options.wrapInSuspense??a??(i.options.errorComponent?.preload||u))?W.Suspense:Kc,f=s?Fs:Kc,p=l?Wc:Kc;return(0,G.jsxs)(i.isRoot?i.options.shellComponent??Kc:Kc,{children:[(0,G.jsx)(Us.Provider,{value:t,children:(0,G.jsx)(d,{fallback:o,children:(0,G.jsx)(f,{getResetKey:()=>n,errorComponent:s||Ls,onCatch:(e,t)=>{if(ho(e))throw e.routeId??=r.routeId,e;c?.(e,t)},children:(0,G.jsx)(p,{fallback:e=>{if(e.routeId??=r.routeId,!l||e.routeId&&e.routeId!==r.routeId||!e.routeId&&!i.isRoot)throw e;return W.createElement(l,e)},children:u||r._displayPending?(0,G.jsx)(Rs,{fallback:o,children:(0,G.jsx)(Zc,{matchId:t})}):(0,G.jsx)(Zc,{matchId:t})})})})}),r.parentRouteId===`__root__`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Xc,{resetKey:n}),(e.options.scrollRestoration,null)]}):null]})}function Xc({resetKey:e}){let t=Hs(),n=W.useRef(void 0);return oa(()=>{let e=t.latestLocation.href;(n.current===void 0||n.current!==e)&&(t.emit({type:`onRendered`,...bs(t.stores.location.state,t.stores.resolvedLocation.state)}),n.current=e)},[t.latestLocation.state.__TSR_key,e,t]),null}var Zc=W.memo(function({matchId:e}){let t=Hs(),n=t.stores.activeMatchStoresById.get(e);n||Ma();let r=_c(n,e=>e),i=r.routeId,a=t.routesById[i],o=W.useMemo(()=>{let e=(t.routesById[i].options.remountDeps??t.options.defaultRemountDeps)?.({routeId:i,loaderDeps:r.loaderDeps,params:r._strictParams,search:r._strictSearch});return e?JSON.stringify(e):void 0},[i,r.loaderDeps,r._strictParams,r._strictSearch,t.options.defaultRemountDeps,t.routesById]),s=W.useMemo(()=>{let e=a.options.component??t.options.defaultComponent;return e?(0,G.jsx)(e,{},o):(0,G.jsx)(Qc,{})},[o,a.options.component,t.options.defaultComponent]);if(r._displayPending)throw t.getMatch(r.id)?._nonReactive.displayPendingPromise;if(r._forcePending)throw t.getMatch(r.id)?._nonReactive.minPendingPromise;if(r.status===`pending`){let e=a.options.pendingMinMs??t.options.defaultPendingMinMs;if(e){let n=t.getMatch(r.id);if(n&&!n._nonReactive.minPendingPromise){let t=Ca();n._nonReactive.minPendingPromise=t,setTimeout(()=>{t.resolve(),n._nonReactive.minPendingPromise=void 0},e)}}throw t.getMatch(r.id)?._nonReactive.loadPromise}if(r.status===`notFound`)return ho(r.error)||Ma(),qc(t,a,r.error);if(r.status===`redirected`)throw Fo(r.error)||Ma(),t.getMatch(r.id)?._nonReactive.loadPromise;if(r.status===`error`)throw r.error;return s}),Qc=W.memo(function(){let e=Hs(),t=W.useContext(Us),n,r=!1,i;{let a=t?e.stores.activeMatchStoresById.get(t):void 0;[n,r]=_c(a,e=>[e?.routeId,e?.globalNotFound??!1]),i=_c(e.stores.matchesId,e=>e[e.findIndex(e=>e===t)+1])}let a=n?e.routesById[n]:void 0,o=e.options.defaultPendingComponent?(0,G.jsx)(e.options.defaultPendingComponent,{}):null;if(r)return a||Ma(),qc(e,a,void 0);if(!i)return null;let s=(0,G.jsx)(Jc,{matchId:i});return n===`__root__`?(0,G.jsx)(W.Suspense,{fallback:o,children:s}):s});function $c(){let e=Hs(),t=W.useRef({router:e,mounted:!1}),[n,r]=W.useState(!1),i=_c(e.stores.isLoading,e=>e),a=_c(e.stores.hasPendingMatches,e=>e),o=sa(i),s=i||n||a,c=sa(s),l=i||a,u=sa(l);return e.startTransition=e=>{r(!0),W.startTransition(()=>{e(),r(!1)})},W.useEffect(()=>{let t=e.history.subscribe(e.load),n=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return ao(e.latestLocation.publicHref)!==ao(n.publicHref)&&e.commitLocation({...n,replace:!0}),()=>{t()}},[e,e.history]),oa(()=>{typeof window<`u`&&e.ssr||t.current.router===e&&t.current.mounted||(t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(e){console.error(e)}})())},[e]),oa(()=>{o&&!i&&e.emit({type:`onLoad`,...bs(e.stores.location.state,e.stores.resolvedLocation.state)})},[o,e,i]),oa(()=>{u&&!l&&e.emit({type:`onBeforeRouteMount`,...bs(e.stores.location.state,e.stores.resolvedLocation.state)})},[l,u,e]),oa(()=>{if(c&&!s){let t=bs(e.stores.location.state,e.stores.resolvedLocation.state);e.emit({type:`onResolved`,...t}),ic(()=>{e.stores.status.setState(()=>`idle`),e.stores.resolvedLocation.setState(()=>e.stores.location.state)}),t.hrefChanged&&Ps(e)}},[s,c,e]),null}function el(){let e=Hs(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,n=t?(0,G.jsx)(t,{}):null,r=(0,G.jsxs)(typeof document<`u`&&e.ssr?Kc:W.Suspense,{fallback:n,children:[(0,G.jsx)($c,{}),(0,G.jsx)(tl,{})]});return e.options.InnerWrap?(0,G.jsx)(e.options.InnerWrap,{children:r}):r}function tl(){let e=Hs(),t=_c(e.stores.firstMatchId,e=>e),n=_c(e.stores.loadedAt,e=>e),r=t?(0,G.jsx)(Jc,{matchId:t}):null;return(0,G.jsx)(Us.Provider,{value:t,children:e.options.disableGlobalCatchBoundary?r:(0,G.jsx)(Fs,{getResetKey:()=>n,errorComponent:Ls,onCatch:void 0,children:r})})}var nl=e=>({createMutableStore:dc,createReadonlyStore:dc,batch:ic}),rl=e=>new il(e),il=class extends xs{constructor(e){super(e,nl)}};function al({router:e,children:t,...n}){Object.keys(n).length>0&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,G.jsx)(Vs.Provider,{value:e,children:t});return e.options.Wrap?(0,G.jsx)(e.options.Wrap,{children:r}):r}function ol({router:e,...t}){return(0,G.jsx)(al,{router:e,...t,children:(0,G.jsx)(el,{})})}function sl(e){let t=Hs({warn:e?.router===void 0}),n=e?.router||t,r=(0,W.useRef)(void 0);return _c(n.stores.__store,t=>{if(e?.select){if(e.structuralSharing??n.options.defaultStructuralSharing){let n=_a(r.current,e.select(t));return r.current=n,n}return e.select(t)}return t})}var cl=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ll=new class extends cl{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},ul={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},dl=new class{#e=ul;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function fl(e){setTimeout(e,0)}var pl=typeof window>`u`||`Deno`in globalThis;function ml(){}function hl(e,t){return typeof e==`function`?e(t):e}function gl(e){return typeof e==`number`&&e>=0&&e!==1/0}function _l(e,t){return Math.max(e+(t||0)-Date.now(),0)}function vl(e,t){return typeof e==`function`?e(t):e}function yl(e,t){return typeof e==`function`?e(t):e}function bl(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Sl(o,t.options))return!1}else if(!wl(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function xl(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Cl(t.options.mutationKey)!==Cl(a))return!1}else if(!wl(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Sl(e,t){return(t?.queryKeyHashFn||Cl)(e)}function Cl(e){return JSON.stringify(e,(e,t)=>kl(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function wl(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>wl(e[n],t[n])):!1}var Tl=Object.prototype.hasOwnProperty;function El(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Ol(e)&&Ol(t);if(!r&&!(kl(e)&&kl(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Tl.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=El(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Dl(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Ol(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function kl(e){if(!Al(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Al(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Al(e){return Object.prototype.toString.call(e)===`[object Object]`}function jl(e){return new Promise(t=>{dl.setTimeout(t,e)})}function Ml(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:El(e,t)}function Nl(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Pl(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Fl=Symbol();function Il(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Fl?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ll(e,t){return typeof e==`function`?e(...t):!!e}function Rl(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var zl=(()=>{let e=()=>pl;return{isServer(){return e()},setIsServer(t){e=t}}})();function Bl(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var Vl=fl;function Hl(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Vl,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var q=Hl(),Ul=new class extends cl{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Wl(e){return Math.min(1e3*2**e,3e4)}function Gl(e){return(e??`online`)===`online`?Ul.isOnline():!0}var Kl=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ql(e){let t=!1,n=0,r,i=Bl(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new Kl(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>ll.isFocused()&&(e.networkMode===`always`||Ul.isOnline())&&e.canRun(),u=()=>Gl(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(zl.isServer()?0:3),o=e.retryDelay??Wl,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),jl(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var Jl=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),gl(this.gcTime)&&(this.#e=dl.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(zl.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(dl.clearTimeout(this.#e),this.#e=void 0)}},Yl=class extends Jl{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Ql(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Ql(this.options);e.data!==void 0&&(this.setState(Zl(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=Ml(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(ml).catch(ml):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>yl(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Fl||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>vl(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!_l(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=Il(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=ql({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Kl&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Kl){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Xl(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Zl(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}})(this.state),q.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function Xl(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Gl(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Zl(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Ql(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var $l=class extends cl{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Bl(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),tu(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return nu(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return nu(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof yl(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Dl(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&ru(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||yl(this.options.enabled,this.#t)!==yl(t.enabled,this.#t)||vl(this.options.staleTime,this.#t)!==vl(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||yl(this.options.enabled,this.#t)!==yl(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return au(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(ml)),t}#g(){this.#b();let e=vl(this.options.staleTime,this.#t);if(zl.isServer()||this.#r.isStale||!gl(e))return;let t=_l(this.#r.dataUpdatedAt,e)+1;this.#d=dl.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(zl.isServer()||yl(this.options.enabled,this.#t)===!1||!gl(this.#p)||this.#p===0)&&(this.#f=dl.setInterval(()=>{(this.options.refetchIntervalInBackground||ll.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(dl.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(dl.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&tu(e,t),o=i&&ru(e,n,t,r);(a||o)&&(l={...l,...Xl(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=Ml(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Ml(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:iu(e,t),refetch:this.refetch,promise:this.#o,isEnabled:yl(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=Bl())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Dl(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){q.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function eu(e,t){return yl(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function tu(e,t){return eu(e,t)||e.state.data!==void 0&&nu(e,t,t.refetchOnMount)}function nu(e,t,n){if(yl(t.enabled,e)!==!1&&vl(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&iu(e,t)}return!1}function ru(e,t,n,r){return(e!==t||yl(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&iu(e,n)}function iu(e,t){return yl(t.enabled,e)!==!1&&e.isStaleByTime(vl(t.staleTime,e))}function au(e,t){return!Dl(e.getCurrentResult(),t)}function ou(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Rl(e,()=>t.signal,()=>n=!0)},u=Il(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?Pl:Nl;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?cu:su,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:su(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function su(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function cu(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var lu=class extends Jl{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||uu(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=ql({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),q.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function uu(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var du=class extends cl{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new lu({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=fu(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=fu(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=fu(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=fu(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){q.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>xl(t,e))}findAll(e={}){return this.getAll().filter(t=>xl(e,t))}notify(e){q.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return q.batch(()=>Promise.all(e.map(e=>e.continue().catch(ml))))}};function fu(e){return e.options.scope?.id}var pu=class extends cl{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Sl(r,t),a=this.get(i);return a||(a=new Yl({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){q.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>bl(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>bl(e,t)):t}notify(e){q.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){q.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){q.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},mu=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new pu,this.#t=e.mutationCache||new du,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ll.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Ul.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(vl(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=hl(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return q.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;q.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return q.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=q.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(ml).catch(ml)}invalidateQueries(e,t={}){return q.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=q.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(ml)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(ml)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(vl(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ml).catch(ml)}fetchInfiniteQuery(e){return e.behavior=ou(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ml).catch(ml)}ensureInfiniteQueryData(e){return e.behavior=ou(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Ul.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Cl(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{wl(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Cl(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{wl(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Sl(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Fl&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},hu=W.createContext(void 0),gu=e=>{let t=W.useContext(hu);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},_u=({client:e,children:t})=>(W.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,G.jsx)(hu.Provider,{value:e,children:t})),vu=W.createContext(!1),yu=()=>W.useContext(vu);vu.Provider;function bu(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xu=W.createContext(bu()),Su=()=>W.useContext(xu),Cu=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Ll(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},wu=e=>{W.useEffect(()=>{e.clearReset()},[e])},Tu=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Ll(n,[e.error,r])),Eu=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Du=(e,t)=>e.isLoading&&e.isFetching&&!t,Ou=(e,t)=>e?.suspense&&t.isPending,ku=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Au(e,t,n){let r=yu(),i=Su(),a=gu(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,Eu(o),Cu(o,i,s),wu(i);let c=!a.getQueryCache().get(o.queryHash),[l]=W.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(W.useSyncExternalStore(W.useCallback(e=>{let t=d?l.subscribe(q.batchCalls(e)):ml;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),W.useEffect(()=>{l.setOptions(o)},[o,l]),Ou(o,u))throw ku(o,l,i);if(Tu({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!zl.isServer()&&Du(u,r)&&(c?ku(o,l,i):s?.promise)?.catch(ml).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function ju(e,t){return Au(e,$l,t)}var Mu=E(),Nu={queryKey:[`bundle`],queryFn:async()=>{let e=await fetch(`/api/bundle`);if(!e.ok)throw Error(`Failed to fetch bundle.json`);return e.json()}},Pu=[`go`,`fmo`,`staging`,`integration`,`test1`],Fu=(0,W.createContext)({apiKey:``,userId:``,businessId:``,environment:`go`}),Iu=()=>(0,W.useContext)(Fu),Lu={go:`https://app.go.kizen.com/api`,fmo:`https://app.fmo.kizen.com/api`,staging:`https://staging.kizen.dev/api`,integration:`https://integration.kizen.dev/api`,test1:`https://test1.kizen.dev/api`},Ru={go:`https://go.kizen.com`,fmo:`https://fmo.kizen.com`,staging:`https://v2.staging.kizen.com`,integration:`https://v2.integration.kizen.dev`,test1:`https://test1.kizen.dev`};function zu(){let{apiKey:e,userId:t,businessId:n,environment:r}=Iu(),i=Lu[r];return(0,W.useCallback)((r,a={})=>fetch(`/api/proxy${r}`,{...a,headers:{"x-proxy-target":i,"X-API-KEY":e,"X-USER-ID":t,"X-BUSINESS-ID":n,...a.headers}}),[i,e,t,n])}function Bu(e){let{apiKey:t,userId:n,businessId:r,environment:i}=e;return{queryKey:[`bootstrap`,i,t,n,r],enabled:!!(t&&n&&r),queryFn:async()=>{let e=await fetch(`/api/proxy/auth/bootstrap`,{headers:{"x-proxy-target":Lu[i],"X-API-KEY":t,"X-USER-ID":n,"X-BUSINESS-ID":r}});if(!e.ok)throw Error(`Bootstrap failed: ${String(e.status)} ${e.statusText}`);return e.json()},retry:!1}}function Vu(){let e=gu(),[t,n]=(0,W.useState)([]),[r,i]=(0,W.useState)([]),[a,o]=(0,W.useState)(null);return(0,W.useEffect)(()=>{let t=window.location.protocol===`https:`?`wss:`:`ws:`,r=new WebSocket(`${t}//${window.location.host}`);return r.addEventListener(`message`,t=>{let r;try{r=JSON.parse(t.data)}catch{return}if(r.type===`rebuild`)e.invalidateQueries({queryKey:[`bundle`]});else if(r.type===`open-devtools`)window.electronAPI?.openDevTools();else if(r.type===`log`)n(e=>[...e,r.message]);else if(r.type===`proxy-log`){let e=r.entry??{kind:`info`,message:r.message??``};i(t=>[...t,e])}else o(r.credentials)}),()=>{r.close()}},[e]),{buildLogs:t,proxyLogs:r,serverCredentials:a}}var Hu=`integration:route-change`,Uu=`w-full rounded bg-neutral-800 border border-neutral-700 px-2 py-1 text-[12px] font-mono text-neutral-200 focus:outline-none focus:border-neutral-500`,Wu=`block text-[11px] font-semibold uppercase tracking-widest text-neutral-500 mb-1`;function Gu(e){return e.toTimeString().slice(0,8)}var Ku=()=>{let[e,t]=(0,W.useState)(`/`),[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)([]),c=(0,W.useRef)(null);(0,W.useEffect)(()=>{c.current?.scrollIntoView({behavior:`smooth`})},[o]),(0,W.useEffect)(()=>{let e=e=>{let t=e;s(e=>[...e,{time:new Date,location:t.detail.location}].slice(-50))};return window.addEventListener(Hu,e),()=>{window.removeEventListener(Hu,e)}},[]);let l=()=>{let t=n&&!n.startsWith(`?`)?`?${n}`:n,r=i&&!i.startsWith(`#`)?`#${i}`:i,a={host:window.location.host,origin:window.location.origin,port:window.location.port,protocol:window.location.protocol,pathname:e,search:t,hash:r,href:`${window.location.origin}${e}${t}${r}`};window.dispatchEvent(new CustomEvent(Hu,{detail:{location:a}}))},u=e=>{e.key===`Enter`&&l()};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:Wu,children:`Search`}),(0,G.jsx)(`input`,{type:`text`,className:Uu,value:n,onChange:e=>{r(e.target.value)},onKeyDown:u,placeholder:`?tab=notes`,spellCheck:!1})]}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:Wu,children:`Hash`}),(0,G.jsx)(`input`,{type:`text`,className:Uu,value:i,onChange:e=>{a(e.target.value)},onKeyDown:u,placeholder:`#section`,spellCheck:!1})]})]}),(0,G.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:Wu,children:`Pathname`}),(0,G.jsx)(`input`,{type:`text`,className:Uu,value:e,onChange:e=>{t(e.target.value)},onKeyDown:u,placeholder:`/client/abc-123/overview`,spellCheck:!1})]}),(0,G.jsx)(`button`,{onClick:l,className:`rounded bg-neutral-700 px-3 py-1.5 text-[12px] font-semibold text-neutral-200 hover:bg-neutral-600 active:bg-neutral-500`,children:`Dispatch`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col border-t border-neutral-800 pt-2`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-500`,children:`Navigation Event Stream`}),o.length>0&&(0,G.jsx)(`button`,{onClick:()=>{s([])},className:`text-[11px] text-neutral-600 hover:text-neutral-300`,children:`clear`})]}),(0,G.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[o.length===0?(0,G.jsx)(`p`,{className:`text-[12px] text-neutral-600`,children:`No events yet.`}):o.map((e,t)=>(0,G.jsxs)(`div`,{className:`px-2 py-0.5 font-mono text-[11px] leading-5 ${t%2==0?`bg-neutral-900`:`bg-neutral-800/40`}`,children:[(0,G.jsx)(`span`,{className:`text-neutral-600`,children:Gu(e.time)}),(0,G.jsx)(`span`,{className:`ml-2 text-neutral-300`,children:e.location.pathname}),e.location.search&&(0,G.jsx)(`span`,{className:`text-neutral-500`,children:e.location.search}),e.location.hash&&(0,G.jsx)(`span`,{className:`text-neutral-500`,children:e.location.hash})]},t)),(0,G.jsx)(`div`,{ref:c})]})]})]})},qu=`w-full rounded bg-neutral-800 border border-neutral-700 px-2 py-1 text-[12px] font-mono text-neutral-200 focus:outline-none focus:border-neutral-500`,Ju=`block text-[11px] font-semibold uppercase tracking-widest text-neutral-500 mb-1`,Yu=`text-[11px] font-semibold uppercase tracking-widest text-neutral-500`,Xu={log:`text-neutral-400`,info:`text-blue-400`,warn:`text-yellow-400`,error:`text-red-400`};function Zu(e){if(typeof e==`string`)return e;if(e===null)return`null`;if(e===void 0)return`undefined`;try{return JSON.stringify(e)}catch{return`[unserializable]`}}var Qu=({logs:e,height:t})=>{let n=(0,W.useRef)(null);return(0,W.useEffect)(()=>{n.current?.scrollIntoView({behavior:`smooth`})},[e]),(0,G.jsxs)(`div`,{className:`${t} overflow-x-auto overflow-y-auto pb-4`,children:[e.length===0?(0,G.jsx)(`p`,{className:`px-4 text-[12px] text-neutral-600`,children:`No output yet.`}):e.map((e,t)=>(0,G.jsx)(`div`,{className:`whitespace-pre px-4 text-[12px] leading-5 ${Xu[e.level]} ${t%2==0?`bg-neutral-900`:`bg-neutral-800/40`}`,children:e.args.map(Zu).join(` `)},t)),(0,G.jsx)(`div`,{ref:n})]})},$u=({logs:e,height:t})=>{let n=(0,W.useRef)(null);return(0,W.useEffect)(()=>{n.current?.scrollIntoView({behavior:`smooth`})},[e]),(0,G.jsxs)(`div`,{className:`${t} overflow-x-auto overflow-y-auto pb-4`,children:[e.length===0?(0,G.jsx)(`p`,{className:`px-4 text-[12px] text-neutral-600`,children:`No output yet.`}):e.map((e,t)=>(0,G.jsx)(`div`,{className:`whitespace-pre px-4 text-[12px] leading-5 text-neutral-500`,children:e},t)),(0,G.jsx)(`div`,{ref:n})]})};function ed(e){switch(e.toUpperCase()){case`GET`:return`bg-blue-900/60 text-blue-300`;case`POST`:return`bg-green-900/60 text-green-300`;case`PUT`:return`bg-amber-900/60 text-amber-300`;case`PATCH`:return`bg-orange-900/60 text-orange-300`;case`DELETE`:return`bg-red-900/60 text-red-300`;default:return`bg-neutral-800 text-neutral-400`}}function td(e){return e===0?`bg-neutral-800 text-neutral-400`:e<300?`bg-green-900/60 text-green-300`:e<400?`bg-yellow-900/60 text-yellow-300`:e<500?`bg-orange-900/60 text-orange-300`:`bg-red-900/60 text-red-300`}var nd=({logs:e,height:t})=>{let n=(0,W.useRef)(null),[r,i]=(0,W.useState)(null);return(0,W.useEffect)(()=>{n.current?.scrollIntoView({behavior:`smooth`})},[e]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`${t} overflow-x-auto overflow-y-auto pb-4`,children:[e.length===0?(0,G.jsx)(`p`,{className:`px-4 text-[12px] text-neutral-600`,children:`No output yet.`}):e.map((e,t)=>(0,G.jsx)(`div`,{className:`flex items-center gap-1.5 px-3 py-0.5 text-[11px] ${t%2==0?`bg-neutral-900`:`bg-neutral-800/40`}`,children:e.kind===`info`?(0,G.jsx)(`span`,{className:`text-neutral-500`,children:e.message}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`w-12 shrink-0 rounded text-center font-mono font-semibold ${ed(e.method)}`,children:e.method}),(0,G.jsx)(`span`,{className:`w-8 shrink-0 rounded text-center font-mono font-semibold ${td(e.status)}`,children:e.status===0?`ERR`:e.status}),(0,G.jsx)(`span`,{className:`w-14 shrink-0 rounded text-center font-mono font-semibold ${e.fromCache?`bg-violet-900/60 text-violet-300`:`bg-neutral-800 text-neutral-400`}`,children:e.fromCache?`cache`:`network`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate cursor-default font-mono text-neutral-400`,onMouseEnter:t=>{let n=t.currentTarget.getBoundingClientRect();i({text:e.url,x:n.left,y:n.top})},onMouseLeave:()=>{i(null)},children:e.url})]})},t)),(0,G.jsx)(`div`,{ref:n})]}),r&&(0,G.jsx)(`div`,{className:`pointer-events-none fixed z-50 max-w-xs break-all rounded bg-neutral-700 px-2 py-1 text-[11px] text-neutral-100 shadow-lg`,style:{left:r.x,top:r.y,transform:`translateY(calc(-100% - 4px))`},children:r.text})]})},rd=({onClose:e,buildLogs:t,proxyLogs:n,consoleLogs:r,onClearConsole:i,credentials:a,onCredentialsChange:s})=>{let[c,l]=(0,W.useState)(()=>{let e=localStorage.getItem(`devtools-creds-open`);return e===null?!(a.apiKey&&a.userId&&a.businessId):e!==`false`}),[u,d]=(0,W.useState)([]),[f,p]=(0,W.useState)(void 0),m=(0,W.useCallback)(async()=>{try{let e=await fetch(`/api/credential-profiles`);if(!e.ok)return;let t=await e.json();d(t.profiles),p(t.active)}catch{}},[]);(0,W.useEffect)(()=>{m()},[m]);let g=(0,W.useCallback)(async e=>{let t=e===``?void 0:e;try{await fetch(`/api/credentials/switch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profile:t})}),p(t)}catch{}},[]),[_,y]=(0,W.useState)(()=>localStorage.getItem(`devtools-routes-open`)!==`false`),[b,x]=(0,W.useState)(()=>localStorage.getItem(`devtools-console-open`)!==`false`),[S,w]=(0,W.useState)(()=>localStorage.getItem(`devtools-proxy-open`)!==`false`),[T,E]=(0,W.useState)(()=>localStorage.getItem(`devtools-build-open`)!==`false`),D=(e,t)=>{t(t=>{let n=!t;return localStorage.setItem(e,String(n)),n})};return(0,G.jsxs)(`aside`,{className:`flex w-104 shrink-0 flex-col border-l border-neutral-800 bg-neutral-900 text-neutral-100`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-800 px-4 py-3`,children:[(0,G.jsx)(`span`,{className:`text-[12px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Dev Tools`}),(0,G.jsx)(`button`,{onClick:e,className:`text-neutral-500 hover:text-neutral-200`,"aria-label":`Close dev tools`,children:(0,G.jsx)(C,{icon:o,size:`sm`})})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col min-h-0`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col border-b border-neutral-800`,children:[(0,G.jsxs)(`button`,{className:`flex items-center justify-between px-4 py-2 hover:bg-neutral-800/50`,onClick:()=>{D(`devtools-creds-open`,l),m()},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:Yu,children:`Credentials`}),!c&&(0,G.jsx)(`span`,{className:`text-[11px] font-mono text-neutral-400`,children:a.environment})]}),(0,G.jsx)(C,{icon:c?h:v,className:`text-neutral-600`,size:`xs`})]}),c&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 px-4 pb-3`,children:[u.length>1&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:Ju,children:`Profile`}),(0,G.jsx)(`select`,{className:qu,value:f??``,onChange:e=>{g(e.target.value)},children:u.map(e=>(0,G.jsx)(`option`,{value:e.isDefault?``:e.name,children:e.isDefault?`Default`:e.name},e.name))})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:Ju,children:`Environment`}),(0,G.jsx)(`select`,{className:qu,value:a.environment,onChange:e=>{s({...a,environment:e.target.value})},children:Pu.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:Ju,children:`Business ID`}),(0,G.jsx)(`input`,{type:`text`,className:qu,value:a.businessId,onChange:e=>{s({...a,businessId:e.target.value})},placeholder:`x-business-id`,autoComplete:`off`})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:Ju,children:`User ID`}),(0,G.jsx)(`input`,{type:`text`,className:qu,value:a.userId,onChange:e=>{s({...a,userId:e.target.value})},placeholder:`x-user-id`,autoComplete:`off`})]}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:Ju,children:`API Key`}),(0,G.jsx)(`input`,{type:`password`,className:qu,value:a.apiKey,onChange:e=>{s({...a,apiKey:e.target.value})},placeholder:`x-api-key`,autoComplete:`off`})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col border-t border-neutral-800 overflow-hidden`,children:[(0,G.jsxs)(`button`,{className:`flex items-center justify-between px-4 py-2 hover:bg-neutral-800/50`,onClick:()=>{D(`devtools-routes-open`,y)},children:[(0,G.jsx)(`span`,{className:Yu,children:`Routes`}),(0,G.jsx)(C,{icon:_?h:v,className:`text-neutral-600`,size:`xs`})]}),_&&(0,G.jsx)(Ku,{})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col border-t border-neutral-800`,children:[(0,G.jsxs)(`div`,{className:`flex items-center px-4 py-2`,children:[(0,G.jsxs)(`button`,{className:`flex flex-1 items-center gap-2 hover:opacity-70`,onClick:()=>{D(`devtools-console-open`,x)},children:[(0,G.jsx)(`span`,{className:Yu,children:`Console`}),(0,G.jsx)(C,{icon:b?h:v,className:`text-neutral-600`,size:`xs`})]}),b&&r.length>0&&(0,G.jsx)(`button`,{onClick:i,className:`text-[11px] text-neutral-600 hover:text-neutral-300`,children:`clear`})]}),b&&(0,G.jsx)(Qu,{logs:r,height:`min-h-32 max-h-64`})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col min-h-0 border-t border-neutral-800`,children:[(0,G.jsxs)(`div`,{className:`flex items-center px-4 py-2`,children:[(0,G.jsxs)(`button`,{className:`flex flex-1 items-center gap-2 hover:opacity-70`,onClick:()=>{D(`devtools-proxy-open`,w)},children:[(0,G.jsx)(`span`,{className:Yu,children:`Proxy Log`}),(0,G.jsx)(C,{icon:S?h:v,className:`text-neutral-600`,size:`xs`})]}),S&&(0,G.jsx)(`button`,{onClick:()=>{fetch(`/api/proxy-cache/clear`)},className:`text-[11px] text-neutral-600 hover:text-neutral-300`,children:`clear cache`})]}),S&&(0,G.jsx)(nd,{logs:n,height:`flex-1 min-h-0`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col border-t border-neutral-800`,children:[(0,G.jsxs)(`button`,{className:`flex items-center justify-between px-4 py-2 hover:bg-neutral-800/50`,onClick:()=>{D(`devtools-build-open`,E)},children:[(0,G.jsx)(`span`,{className:Yu,children:`Build Log`}),(0,G.jsx)(C,{icon:T?h:v,className:`text-neutral-600`,size:`xs`})]}),T&&(0,G.jsx)($u,{logs:t,height:`max-h-[60px]`})]})]})]})},id=(0,W.createContext)(0),ad=()=>(0,W.useContext)(id),od=(0,W.createContext)(void 0),sd=()=>(0,W.useContext)(od),cd=window.open.bind(window),ld=416,ud={apiKey:``,userId:``,businessId:``,environment:`go`},dd=()=>{let{buildLogs:e,proxyLogs:t,serverCredentials:n}=Vu(),[r,a]=(0,W.useState)([]);(0,W.useEffect)(()=>window.electronAPI?.onConsoleMessage?.(e=>{a(t=>[...t,e])}),[]);let[o,s]=(0,W.useState)(()=>localStorage.getItem(`devtools-sidebar-open`)===`true`),c=()=>{s(e=>{let t=!e;return localStorage.setItem(`devtools-sidebar-open`,String(t)),t})},[l,u]=(0,W.useState)(()=>{try{return{...ud,...JSON.parse(localStorage.getItem(`devtools-credentials`)??`{}`)}}catch{return ud}});(0,W.useEffect)(()=>{fetch(`/api/credentials`).then(e=>e.json()).then(e=>{if(e.apiKey){let t={...ud,...e};u(t),localStorage.setItem(`devtools-credentials`,JSON.stringify(t))}}).catch(()=>{})},[]),(0,W.useEffect)(()=>{if(!n)return;let e={...ud,...n};u(e),localStorage.setItem(`devtools-credentials`,JSON.stringify(e))},[n]);let d=e=>{u(e),localStorage.setItem(`devtools-credentials`,JSON.stringify(e))},{data:f,isLoading:h,isError:g}=ju(Nu),{data:_,isError:v,isLoading:y}=ju(Bu(l)),b=wc(),{location:x}=sl(),S=/^\/([^/]+)\/.+/.exec(x.pathname)?.[1],w=/^\/[^/]+\/([^/]+)$/.exec(x.pathname)?.[1],T=h?`loading`:g?`error`:f?`loaded`:`empty`,E=y?`authenticating`:v?`auth error`:_?`authenticated`:`no auth`,D=h?`bg-neutral-100 text-neutral-400`:g?`bg-red-100 text-red-700`:f?`bg-green-100 text-green-700`:`bg-yellow-100 text-yellow-700`,O=y?`bg-neutral-100 text-neutral-400`:v?`bg-red-100 text-red-700`:_?`bg-green-100 text-green-700`:`bg-yellow-100 text-yellow-700`;return(0,G.jsx)(Fu.Provider,{value:l,children:(0,G.jsx)(id.Provider,{value:o?ld:0,children:(0,G.jsx)(od.Provider,{value:_,children:(0,G.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden font-mono`,children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-3 border-b border-black/10 bg-white/85 px-5 py-3 backdrop-blur-sm`,children:[(0,G.jsx)(`span`,{className:`text-[13px] font-bold tracking-tight text-neutral-900`,children:`Kizen App Builder`}),f&&f.length>0&&(0,G.jsx)(`select`,{value:S??``,onChange:e=>void b({to:`/$apiName/summary`,params:{apiName:e.target.value}}),className:`rounded border border-black/10 bg-transparent px-2 py-0.5 text-[13px] font-mono text-neutral-700 focus:outline-none`,children:f.map(e=>{let t=e.api_name;return(0,G.jsx)(`option`,{value:t,children:e.name??t},t)})}),w&&S&&(0,G.jsxs)(`select`,{value:w,onChange:e=>void b({to:`/${S}/${e.target.value}`}),className:`rounded border border-black/10 bg-transparent px-2 py-0.5 text-[13px] font-mono text-neutral-700 focus:outline-none`,children:[(0,G.jsx)(`option`,{value:`summary`,children:`Summary`}),(0,G.jsx)(`option`,{value:`sandbox`,children:`Sandbox`}),(0,G.jsx)(`option`,{value:`configuration`,children:`Configuration`}),(0,G.jsx)(`option`,{value:`versions`,children:`Versions`})]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`button`,{onClick:()=>{window.location.reload()},className:`text-[14px] text-neutral-400 hover:text-neutral-700`,"aria-label":`Refresh page`,children:(0,G.jsx)(C,{icon:m})}),(0,G.jsx)(`button`,{onClick:()=>{cd(Ru[l.environment],`_blank`,`noopener,height=900`)},className:`text-[14px] text-neutral-400 hover:text-neutral-700`,"aria-label":`Toggle dev tools`,children:(0,G.jsx)(C,{icon:p})}),(0,G.jsx)(`button`,{onClick:c,className:`text-[14px] ${o?`text-neutral-700`:`text-neutral-400`} hover:text-neutral-700`,"aria-label":`Toggle dev tools`,children:(0,G.jsx)(C,{icon:i})}),(0,G.jsx)(`span`,{className:`rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide ${D}`,children:T}),(0,G.jsx)(`span`,{className:`rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide ${O}`,children:E})]}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto p-6`,style:{backgroundImage:`
|
|
2
2
|
linear-gradient(rgba(0,0,0,0.025) 1px, transparent 1px),
|
|
3
3
|
linear-gradient(90deg, rgba(0,0,0,0.025) 1px, transparent 1px)
|
|
4
4
|
`,backgroundSize:`24px 24px`},children:(0,G.jsx)(Qc,{})}),o&&(0,G.jsx)(rd,{onClose:c,buildLogs:e,proxyLogs:t,consoleLogs:r,onClearConsole:()=>{a([])},credentials:l,onCredentialsChange:d})]})]})})})})},J=({children:e,className:t=``})=>(0,G.jsx)(`div`,{className:`rounded-xl bg-white p-5 shadow-sm ${t}`,children:e}),fd=()=>{let{data:e,isLoading:t,isError:n}=ju(Nu),r=wc();return(0,W.useEffect)(()=>{e&&e.length>0&&r({to:`/$apiName/summary`,params:{apiName:e[0]?.api_name}})},[e,r]),t?(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-400`,children:`Fetching bundle.json…`})}):n?(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-red-700`,children:`Could not load bundle.json. Make sure the dev server is running from a plugin directory.`})}):!e||e.length===0?(0,G.jsx)(J,{children:(0,G.jsxs)(`p`,{className:`m-0 text-[13px] text-yellow-700`,children:[`bundle.json is empty. Run`,` `,(0,G.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 py-0.5`,children:`appbuilder build`}),` to generate it.`]})}):null},pd=Tt(),md=Wi(),hd=Tn(),gd=Xi(),_d=Ni(),vd=pn(),yd=er(),bd=or(),xd=Pr(),Sd=Qr(),Cd=Jn(),wd=Ln(),Td=Di(),Ed=Or(),Dd=jn(),Od=hi(),kd=Kr(),Ad=yn(),jd=fr(),Md=li(),Nd=Br(),Pd=xi(),Fd=Hn(),Id=O(),Ld=ht(),Rd=cn(),zd=Zt(),Bd=nn(),Vd=Fe(),Hd=ii(),Ud=ze(),Wd=be(),Gd=Kt(),Kd=It(),qd=Te(),Jd=Vt(),Yd=R(),Xd=na(),Zd=bt(),Qd=We(),$d=Ae(),ef=he(),tf=ut(),nf=et(),rf=Ye(),af=vr(),of=N(),sf=Cr(),cf=at(),lf=ae(),uf=ue(),df=jt(),ff=zi(),pf=te(),mf=Et(),hf=Gi(),gf=En(),_f=Zi(),vf=Pi(),yf=mn(),bf=tr(),xf=sr(),Sf=Fr(),Cf=$r(),wf=Yn(),Tf=Rn(),Ef=Oi(),Df=kr(),Of=Mn(),kf=gi(),Af=qr(),jf=bn(),Mf=pr(),Nf=ui(),Pf=Vr(),Ff=Si(),If=Un(),Lf=A(),Rf=_t(),zf=un(),Bf=$t(),Vf=an(),Hf=U(),Uf=oi(),Wf=Ve(),Gf=Se(),Kf=Jt(),qf=Rt(),Jf=De(),Yf=Ut(),Xf=B(),Zf=ia(),Qf=St(),$f=Ke(),ep=Me(),tp=_e(),np=ft(),rp=nt(),ip=Ze(),ap=br(),op=F(),sp=Tr(),cp=st(),lp=se(),up=fe(),dp=Nt(),fp=Vi(),pp=ne(),mp=Ot(),hp=qi(),gp=On(),_p=$i(),vp=Ii(),yp=gn(),bp=rr(),xp=lr(),Sp=Lr(),Cp=ti(),wp=Zn(),Tp=Bn(),Ep=Ai(),Dp=jr(),Op=Pn(),kp=vi(),Ap=Yr(),jp=Sn(),Mp=hr(),Np=fi(),Pp=Ur(),Fp=wi(),Ip=Gn(),Lp=k(),Rp=gt(),zp=ln(),Bp=Qt(),Vp=rn(),Hp=Ie(),Up=ai(),Wp=Be(),Gp=xe(),Kp=qt(),qp=Lt(),Jp=Ee(),Yp=Ht(),Xp=z(),Zp=ra(),Qp=xt(),$p=Ge(),em=je(),tm=ge(),nm=dt(),rm=tt(),im=Xe(),am=yr(),om=P(),sm=wr(),cm=ot(),lm=oe(),um=de(),dm=Mt(),fm=Bi(),pm=H(),mm=Dt(),hm=Ki(),gm=Dn(),_m=Qi(),vm=Fi(),ym=hn(),bm=nr(),xm=cr(),Sm=Ir(),Cm=ei(),wm=Xn(),Tm=zn(),Em=ki(),Dm=Ar(),Om=Nn(),km=_i(),Am=Jr(),jm=xn(),Mm=mr(),Nm=di(),Pm=Hr(),Fm=Ci(),Im=Wn(),Lm=j(),Rm=vt(),zm=dn(),Bm=en(),Vm=on(),Hm=Le(),Um=si(),Wm=He(),Gm=Ce(),Km=Yt(),qm=zt(),Jm=Oe(),Ym=Wt(),Xm=V(),Zm=aa(),Qm=Ct(),$m=qe(),eh=Ne(),th=ve(),nh=pt(),rh=rt(),ih=Qe(),ah=xr(),oh=I(),sh=Er(),ch=ct(),lh=ce(),uh=pe(),dh=Pt(),fh=Hi(),ph=re(),mh=kt(),hh=Ji(),gh=kn(),_h=ea(),vh=Li(),yh=_n(),bh=ir(),xh=ur(),Sh=Rr(),Ch=ni(),wh=Qn(),Th=Vn(),Eh=ji(),Dh=Mr(),Oh=Fn(),kh=yi(),Ah=Xr(),jh=Cn(),Mh=gr(),Nh=pi(),Ph=Wr(),Fh=Ti(),Ih=Kn(),Lh=D(),Rh=mt(),zh=sn(),Bh=Xt(),Vh=tn(),Hh=Pe(),Uh=ri(),Wh=Re(),Gh=ye(),Kh=Gt(),qh=Ft(),Jh=Bt(),Yh=we(),Xh=L(),Zh=ta(),Qh=yt(),$h=Ue(),eg=ke(),tg=me(),ng=lt(),rg=$e(),ig=Je(),ag=_r(),og=M(),sg=Sr(),cg=it(),lg=ie(),ug=le(),dg=At(),fg=Ri(),pg=ee(),mg=wt(),hg=Ui(),gg=wn(),_g=Yi(),vg=Mi(),yg=fn(),bg=$n(),xg=ar(),Sg=Nr(),Cg=Zr(),wg=qn(),Tg=In(),Eg=Ei(),Dg=Dr(),Og=An(),kg=mi(),Ag=Gr(),jg=vn(),Mg=dr(),Ng=ci(),Pg=zr(),Fg=bi(),Ig=new Set([`kizen-k`,`form-entity`]),Lg={phone:pd.faPhone,envelope:md.faEnvelope,"pen-nib":hd.faPenNib,"calendar-days":gd.faCalendarDays,paperclip:_d.faPaperclip,file:vd.faFile,clipboard:yd.faClipboard,pen:bd.faPen,tag:xd.faTag,book:Sd.faBook,print:Cd.faPrint,"pen-to-square":wd.faPenToSquare,folder:Td.faFolder,"folder-open":Ed.faFolderOpen,thumbtack:Dd.faThumbtack,globe:Od.faGlobe,city:kd.faCity,briefcase:Ad.faBriefcase,compass:jd.faCompass,"address-book":Md.faAddressBook,"business-time":Nd.faBusinessTime,"computer-classic":Pd.faComputerClassic,"pen-fancy":Fd.faPenFancy,"badge-check":Id.faBadgeCheck,"mug-saucer":Ld.faMugSaucer,landmark:Rd.faLandmark,"chart-simple":zd.faChartSimple,envelopes:Bd.faEnvelopes,"diagram-venn":Vd.faDiagramVenn,calendar:Hd.faCalendar,pencil:Ud.faPencil,"phone-volume":Wd.faPhoneVolume,copy:Gd.faCopy,table:Kd.faTable,building:qd.faBuilding,"network-wired":Jd.faNetworkWired,"address-card":Yd.faAddressCard,tags:Xd.faTags,registered:Zd.faRegistered,signature:Qd.faSignature,"phone-office":$d.faPhoneOffice,projector:ef.faProjector,sitemap:tf.faSitemap,marker:nf.faMarker,badge:rf.faBadge,wallet:af.faWallet,copyright:of.faCopyright,bullseye:sf.faBullseye,calculator:cf.faCalculator,certificate:lf.faCertificate,percent:uf.faPercent,eraser:df.faEraser,"file-spreadsheet":ff.faFileSpreadsheet,glasses:pf.faGlasses,industry:mf.faIndustry,vault:hf.faVault,"user-tie-hair-long":gf.faUserTieHairLong,"user-tie-hair":_f.faUserTieHair,"user-hair-mullet":vf.faUserHairMullet,trademark:yf.faTrademark,"timeline-arrow":bf.faTimelineArrow,timeline:xf.faTimeline,"table-tree":Sf.faTableTree,"table-rows":Cf.faTableRows,"table-pivot":wf.faTablePivot,"table-layout":Tf.faTableLayout,"table-columns":Ef.faTableColumns,stapler:Df.faStapler,"square-poll-vertical":Of.faSquarePollVertical,"square-poll-horizontal":kf.faSquarePollHorizontal,"square-phone-flip":Af.faSquarePhoneFlip,"square-phone":jf.faSquarePhone,"square-pen":Mf.faSquarePen,"square-kanban":Nf.faSquareKanban,"square-envelope":Pf.faSquareEnvelope,socks:Ff.faSocks,"slot-machine":If.faSlotMachine,"signature-slash":Lf.faSignatureSlash,"signature-lock":Rf.faSignatureLock,shredder:zf.faShredder,scissors:Bf.faScissors,"scanner-image":Vf.faScannerImage,"scale-unbalanced-flip":Hf.faScaleUnbalancedFlip,"scale-unbalanced":Uf.faScaleUnbalanced,"scale-balanced":Wf.faScaleBalanced,router:Gf.faRouter,"rectangle-pro":Kf.faRectanglePro,"print-slash":qf.faPrintSlash,"print-magnifying-glass":Jf.faPrintMagnifyingGlass,"presentation-screen":Yf.faPresentationScreen,podium:Xf.faPodium,"phone-slash":Zf.faPhoneSlash,"phone-intercom":Qf.faPhoneIntercom,"phone-flip":$f.faPhoneFlip,"person-chalkboard":ep.faPersonChalkboard,"pen-nib-slash":tp.faPenNibSlash,"pen-clip":np.faPenClip,paste:rp.faPaste,"paperclip-vertical":ip.faPaperclipVertical,notebook:ap.faNotebook,"note-sticky":op.faNoteSticky,"money-check-pen":sp.faMoneyCheckPen,"money-check-dollar-pen":cp.faMoneyCheckDollarPen,"magnifying-glass-chart":lp.faMagnifyingGlassChart,"magnifying-glass-arrow-right":up.faMagnifyingGlassArrowRight,"list-tree":dp.faListTree,"list-timeline":fp.faListTimeline,"list-radio":pp.faListRadio,"list-dropdown":mp.faListDropdown,"list-check":hp.faListCheck,"laptop-file":gp.faLaptopFile,"lamp-desk":_p.faLampDesk,keynote:vp.faKeynote,"industry-windows":yp.faIndustryWindows,inboxes:bp.faInboxes,"inbox-full":xp.faInboxFull,"house-laptop":Sp.faHouseLaptop,highlighter:Cp.faHighlighter,folders:wp.faFolders,"folder-xmark":Tp.faFolderXmark,"folder-tree":Ep.faFolderTree,"folder-plus":Dp.faFolderPlus,"folder-minus":Op.faFolderMinus,"folder-arrow-up":kp.faFolderArrowUp,"folder-arrow-down":Ap.faFolderArrowDown,"floppy-disk-circle-xmark":jp.faFloppyDiskCircleXmark,"floppy-disk-circle-arrow-right":Mp.faFloppyDiskCircleArrowRight,"floppy-disk":Np.faFloppyDisk,"file-user":Pp.faFileUser,"file-lines":Fp.faFileLines,"file-circle-plus":Ip.faFileCirclePlus,"file-circle-info":Lp.faFileCircleInfo,"file-chart-pie":Rp.faFileChartPie,"file-chart-column":zp.faFileChartColumn,fax:Bp.faFax,"envelope-open":Vp.faEnvelopeOpen,"envelope-dot":Hp.faEnvelopeDot,"envelope-circle-check":Up.faEnvelopeCircleCheck,"coffee-pot":Wp.faCoffeePot,"cloud-word":Gp.faCloudWord,"clipboard-question":Kp.faClipboardQuestion,"chart-user":qp.faChartUser,"chart-tree-map":Jp.faChartTreeMap,"chart-simple-horizontal":Yp.faChartSimpleHorizontal,"chart-pyramid":Xp.faChartPyramid,"chart-pie-simple":Zp.faChartPieSimple,"chart-pie":Qp.faChartPie,"chart-line-up":$p.faChartLineUp,"chart-line-down":em.faChartLineDown,"chart-line":tm.faChartLine,"cake-candles":nm.faCakeCandles,"cabinet-filing":rm.faCabinetFiling,bullhorn:im.faBullhorn,"briefcase-blank":am.faBriefcaseBlank,"briefcase-arrow-right":om.faBriefcaseArrowRight,"brain-arrow-curved-right":sm.faBrainArrowCurvedRight,"boxes-packing":cm.faBoxesPacking,"box-archive":lm.faBoxArchive,"book-section":um.faBookSection,"bars-staggered":dm.faBarsStaggered,"bars-progress":fm.faBarsProgress,"badge-percent":pm.faBadgePercent,"badge-dollar":mm.faBadgeDollar,"arrows-to-eye":hm.faArrowsToEye,"arrows-to-dot":gm.faArrowsToDot,"arrows-spin":_m.faArrowsSpin,sparkles:vm.faSparkles,megaphone:ym.faMegaphone,"block-question":bm.faBlockQuestion,"lightbulb-slash":xm.faLightbulbSlash,"comments-dollar":Sm.faCommentsDollar,comments:kg.faComments,"bullseye-pointer":Cm.faBullseyePointer,lightbulb:wm.faLightbulb,"user-group-crown":Tm.faUserGroupCrown,"user-crown":Em.faUserCrown,"signal-stream-slash":Dm.faSignalStreamSlash,"signal-stream":Om.faSignalStream,"rectangle-ad":km.faRectangleAd,"ranking-star":Am.faRankingStar,"person-rays":jm.faPersonRays,"people-group":Mm.faPeopleGroup,"messages-dollar":Nm.faMessagesDollar,"message-dollar":Pm.faMessageDollar,"magnifying-glass-location":Fm.faMagnifyingGlassLocation,"magnifying-glass-dollar":Im.faMagnifyingGlassDollar,"lightbulb-on":Lm.faLightbulbOn,"lightbulb-exclamation":Rm.faLightbulbExclamation,"lightbulb-dollar":zm.faLightbulbDollar,"lightbulb-cfl-on":Bm.faLightbulbCflOn,"lightbulb-cfl":Vm.faLightbulbCfl,"hundred-points":Hm.faHundredPoints,"group-arrows-rotate":Um.faGroupArrowsRotate,"gift-card":Wm.faGiftCard,"filter-circle-dollar":Gm.faFilterCircleDollar,"envelopes-bulk":Km.faEnvelopesBulk,"envelope-open-text":qm.faEnvelopeOpenText,"envelope-open-dollar":Jm.faEnvelopeOpenDollar,"comment-dollar":Ym.faCommentDollar,"chart-mixed":Xm.faChartMixed,"bullseye-arrow":Zm.faBullseyeArrow,star:Qm.faStar,heart:$m.faHeart,"camera-retro":eh.faCameraRetro,"truck-fast":th.faTruckFast,bell:nh.faBell,"cart-shopping":rh.faCartShopping,gift:ih.faGift,barcode:ah.faBarcode,bookmark:oh.faBookmark,camera:sh.faCamera,"thumbs-up":ch.faThumbsUp,"thumbs-down":lh.faThumbsDown,key:uh.faKey,truck:dh.faTruck,balloons:fh.faBalloons,handshake:ph.faHandshake,shop:mh.faShop,shirt:hh.faShirt,"bag-shopping":gh.faBagShopping,moped:_h.faMoped,"cart-plus":vh.faCartPlus,"credit-card":yh.faCreditCard,store:bh.faStore,"cash-register":xh.faCashRegister,"booth-curtain":Sh.faBoothCurtain,trophy:Ch.faTrophy,receipt:wh.faReceipt,"truck-container":Th.faTruckContainer,"truck-clock":Eh.faTruckClock,"truck-bolt":Dh.faTruckBolt,"trophy-star":Oh.faTrophyStar,"store-slash":kh.faStoreSlash,"store-lock":Ah.faStoreLock,"star-exclamation":jh.faStarExclamation,"shop-slash":Mh.faShopSlash,"shop-lock":Nh.faShopLock,"rectangle-barcode":Ph.faRectangleBarcode,"person-booth":Fh.faPersonBooth,"nfc-trash":Ih.faNfcTrash,"nfc-symbol":Lh.faNfcSymbol,"nfc-slash":Rh.faNfcSlash,"nfc-signal":zh.faNfcSignal,"nfc-pen":Bh.faNfcPen,"nfc-magnifying-glass":Vh.faNfcMagnifyingGlass,"nfc-lock":Hh.faNfcLock,nfc:Uh.faNfc,"money-check-dollar":Wh.faMoneyCheckDollar,"money-check":Gh.faMoneyCheck,"mobile-signal-out":Kh.faMobileSignalOut,"mobile-signal":qh.faMobileSignal,"hexagon-vertical-nft-slanted":Jh.faHexagonVerticalNftSlanted,"hexagon-vertical-nft":Yh.faHexagonVerticalNft,"hexagon-image":Xh.faHexagonImage,"hand-holding-box":Zh.faHandHoldingBox,gifts:Qh.faGifts,gem:$h.faGem,"credit-card-front":eg.faCreditCardFront,"credit-card-blank":tg.faCreditCardBlank,"cart-xmark":ng.faCartXmark,"cart-shopping-fast":rg.faCartShoppingFast,"cart-minus":ig.faCartMinus,"cart-circle-xmark":ag.faCartCircleXmark,"cart-circle-plus":og.faCartCirclePlus,"cart-circle-exclamation":sg.faCartCircleExclamation,"cart-circle-check":cg.faCartCircleCheck,"cart-circle-arrow-up":lg.faCartCircleArrowUp,"cart-circle-arrow-down":ug.faCartCircleArrowDown,"cart-arrow-up":dg.faCartArrowUp,"cart-arrow-down":fg.faCartArrowDown,"box-open-full":pg.faBoxOpenFull,"basket-shopping-simple":mg.faBasketShoppingSimple,"basket-shopping":hg.faBasketShopping,"barcode-scan":gg.faBarcodeScan,"barcode-read":_g.faBarcodeRead,balloon:vg.faBalloon,"bags-shopping":yg.faBagsShopping,bars:bg.faBars,browser:xg.faBrowser,"chart-bar":Sg.faChartBar,cog:Cg.faCog,database:Eg.faDatabase,"calendar-alt":wg.faCalendarAlt,play:Tg.faPlay,add:Dg.faAdd,"book-alt":Og.faBookAlt,"arrows-to-circle":Ag.faArrowsToCircle,"question-circle":jg.faQuestionCircle,"chevron-down":Mg.faChevronDown,"chevron-up":Ng.faChevronUp,"window-restore":Pg.faWindowRestore,forward:Fg.faForward},Rg=new Set(`phone.envelope.pen-nib.calendar-days.paperclip.file.clipboard.pen.tag.book.print.pen-to-square.folder.folder-open.thumbtack.globe.city.briefcase.compass.address-book.business-time.computer-classic.pen-fancy.badge-check.mug-saucer.landmark.chart-simple.envelopes.diagram-venn.calendar.pencil.phone-volume.copy.table.building.network-wired.address-card.tags.registered.signature.phone-office.projector.sitemap.marker.badge.wallet.copyright.bullseye.calculator.certificate.percent.eraser.file-spreadsheet.glasses.industry.vault.user-tie-hair-long.user-tie-hair.user-hair-mullet.trademark.timeline-arrow.timeline.table-tree.table-rows.table-pivot.table-layout.table-columns.stapler.square-poll-vertical.square-poll-horizontal.square-phone-flip.square-phone.square-pen.square-kanban.square-envelope.socks.slot-machine.signature-slash.signature-lock.shredder.scissors.scanner-image.scale-unbalanced-flip.scale-unbalanced.scale-balanced.router.rectangle-pro.print-slash.print-magnifying-glass.presentation-screen.podium.phone-slash.phone-intercom.phone-flip.person-chalkboard.pen-nib-slash.pen-clip.paste.paperclip-vertical.notebook.note-sticky.money-check-pen.money-check-dollar-pen.magnifying-glass-chart.magnifying-glass-arrow-right.list-tree.list-timeline.list-radio.list-dropdown.list-check.laptop-file.lamp-desk.keynote.industry-windows.inboxes.inbox-full.house-laptop.highlighter.folders.folder-xmark.folder-tree.folder-plus.folder-minus.folder-arrow-up.folder-arrow-down.floppy-disk-circle-xmark.floppy-disk-circle-arrow-right.floppy-disk.file-user.file-lines.file-circle-plus.file-circle-info.file-chart-pie.file-chart-column.fax.envelope-open.envelope-dot.envelope-circle-check.coffee-pot.cloud-word.clipboard-question.chart-user.chart-tree-map.chart-simple-horizontal.chart-pyramid.chart-pie-simple.chart-pie.chart-line-up.chart-line-down.chart-line.cake-candles.cabinet-filing.bullhorn.briefcase-blank.briefcase-arrow-right.brain-arrow-curved-right.boxes-packing.box-archive.book-section.bars-staggered.bars-progress.badge-percent.badge-dollar.arrows-to-eye.arrows-to-dot.arrows-spin.sparkles.megaphone.block-question.lightbulb-slash.comments-dollar.comments.bullseye-pointer.lightbulb.user-group-crown.user-crown.signal-stream-slash.signal-stream.rectangle-ad.ranking-star.person-rays.people-group.messages-dollar.message-dollar.magnifying-glass-location.magnifying-glass-dollar.lightbulb-on.lightbulb-exclamation.lightbulb-dollar.lightbulb-cfl-on.lightbulb-cfl.hundred-points.group-arrows-rotate.gift-card.filter-circle-dollar.envelopes-bulk.envelope-open-text.envelope-open-dollar.comment-dollar.chart-mixed.bullseye-arrow.star.heart.camera-retro.truck-fast.bell.cart-shopping.gift.barcode.bookmark.camera.thumbs-up.thumbs-down.key.truck.balloons.handshake.shop.shirt.bag-shopping.moped.cart-plus.credit-card.store.cash-register.booth-curtain.trophy.receipt.truck-container.truck-clock.truck-bolt.trophy-star.store-slash.store-lock.star-exclamation.shop-slash.shop-lock.rectangle-barcode.person-booth.nfc-trash.nfc-symbol.nfc-slash.nfc-signal.nfc-pen.nfc-magnifying-glass.nfc-lock.nfc.money-check-dollar.money-check.mobile-signal-out.mobile-signal.hexagon-vertical-nft-slanted.hexagon-vertical-nft.hexagon-image.hand-holding-box.gifts.gem.credit-card-front.credit-card-blank.cart-xmark.cart-shopping-fast.cart-minus.cart-circle-xmark.cart-circle-plus.cart-circle-exclamation.cart-circle-check.cart-circle-arrow-up.cart-circle-arrow-down.cart-arrow-up.cart-arrow-down.box-open-full.basket-shopping-simple.basket-shopping.barcode-scan.barcode-read.balloon.bags-shopping.bars.browser.chart-bar.cog.database.calendar-alt.play.kizen-k.add.book-alt.form-entity.arrows-to-circle.question-circle.chevron-down.chevron-up.window-restore.forward`.split(`.`)),zg=[...Rg].sort(),Bg=()=>{let{apiName:e}=Sc({strict:!1}),{data:t,isLoading:n,isError:r}=ju(Nu);if(n)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-400`,children:`Fetching bundle.json…`})});if(r)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-red-700`,children:`Could not load bundle.json.`})});let i=t?.find(t=>t.api_name===e);if(!i)return(0,G.jsx)(J,{children:(0,G.jsxs)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:[`No app found with api_name`,` `,(0,G.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 py-0.5`,children:e}),`.`]})});let{floating_frames:o,data_adornments:c,routable_pages:l,toolbar_items:d,js_action_templates:f,route_scripts:p,object_settings_menu_items:m,automation_action_configs:h,calendar_sources:v}=i.artifacts,x=o.length>0||c.length>0||l.length>0||d.length>0||f.length>0||p.length>0||m.length>0||h.length>0||v.length>0,T=i.setup_assistant?.fields??[],E=i.user_setup_assistant?.fields??[];return(0,G.jsxs)(`div`,{className:`space-y-4 text-[13px]`,children:[(0,G.jsx)(J,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-lg font-bold leading-tight text-neutral-900`,children:i.name}),(0,G.jsx)(`p`,{className:`mt-0.5 font-mono text-[11px] text-neutral-400`,children:i.api_name})]}),i.description&&(0,G.jsx)(`p`,{className:`text-[13px] leading-relaxed text-neutral-600`,children:i.description}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i.version&&(0,G.jsxs)(`span`,{className:`rounded bg-neutral-100 px-2 py-0.5 text-[11px] font-semibold tracking-wide text-neutral-600`,children:[`v`,i.version]}),i.engine&&(0,G.jsxs)(`span`,{className:`rounded bg-blue-50 px-2 py-0.5 text-[11px] font-semibold tracking-wide text-blue-600`,children:[`engine: `,i.engine]}),(0,G.jsx)(`span`,{className:`rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide ${i.published?`bg-green-100 text-green-700`:`bg-neutral-100 text-neutral-500`}`,children:i.published?`published`:`unpublished`}),i.release_environments?.map(e=>(0,G.jsx)(`span`,{className:`rounded bg-violet-50 px-2 py-0.5 text-[11px] font-semibold tracking-wide text-violet-600`,children:e},e)),i.block_loading_for_setup&&(0,G.jsx)(`span`,{className:`rounded bg-amber-100 px-2 py-0.5 text-[11px] font-semibold tracking-wide text-amber-700`,children:`blocks app loading`}),i.developer_business_id&&(typeof i.developer_business_id==`string`?(0,G.jsxs)(`span`,{className:`rounded bg-neutral-100 px-2 py-0.5 font-mono text-[11px] tracking-wide text-neutral-500`,children:[`biz: `,i.developer_business_id]}):Object.entries(i.developer_business_id).map(([e,t])=>(0,G.jsxs)(`span`,{className:`rounded bg-neutral-100 px-2 py-0.5 font-mono text-[11px] tracking-wide text-neutral-500`,children:[`biz (`,e,`): `,t]},e)))]})]})}),x?(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[o.length>0&&(0,G.jsxs)(J,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(C,{icon:w,className:`text-[12px] text-neutral-400`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Floating Frames`}),(0,G.jsx)(`span`,{className:`ml-auto rounded bg-neutral-100 px-1.5 py-0.5 text-[11px] font-semibold text-neutral-500`,children:o.length})]}),(0,G.jsx)(`div`,{className:`divide-y divide-black/5`,children:o.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-neutral-900`,children:e.name}),(0,G.jsx)(`div`,{className:`truncate font-mono text-[11px] text-neutral-400`,children:e.api_name})]}),e.default_position&&(0,G.jsx)(`span`,{className:`shrink-0 rounded bg-neutral-100 px-1.5 py-0.5 text-[10px] text-neutral-500`,children:e.default_position})]},t))})]}),c.length>0&&(0,G.jsxs)(J,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(C,{icon:u,className:`text-[12px] text-neutral-400`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Data Adornments`}),(0,G.jsx)(`span`,{className:`ml-auto rounded bg-neutral-100 px-1.5 py-0.5 text-[11px] font-semibold text-neutral-500`,children:c.length})]}),(0,G.jsx)(`div`,{className:`divide-y divide-black/5`,children:c.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[e.config.color&&(0,G.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.config.color}}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-neutral-900`,children:e.config.tooltip||e.field_type}),(0,G.jsx)(`span`,{className:`shrink-0 rounded bg-neutral-100 px-1.5 py-0.5 font-mono text-[10px] text-neutral-500`,children:e.field_type})]},t))})]}),l.length>0&&(0,G.jsxs)(J,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(C,{icon:y,className:`text-[12px] text-neutral-400`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Routable Pages`}),(0,G.jsx)(`span`,{className:`ml-auto rounded bg-neutral-100 px-1.5 py-0.5 text-[11px] font-semibold text-neutral-500`,children:l.length})]}),(0,G.jsx)(`div`,{className:`divide-y divide-black/5`,children:l.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-neutral-900`,children:e.name}),(0,G.jsx)(`div`,{className:`truncate font-mono text-[11px] text-neutral-400`,children:e.api_name})]}),e.iframe_url&&(0,G.jsx)(`span`,{className:`shrink-0 rounded bg-purple-100 px-1.5 py-0.5 text-[10px] font-semibold text-purple-600`,children:`iframe`})]},t))})]}),d.length>0&&(0,G.jsxs)(J,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(C,{icon:S,className:`text-[12px] text-neutral-400`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Toolbar Items`}),(0,G.jsx)(`span`,{className:`ml-auto rounded bg-neutral-100 px-1.5 py-0.5 text-[11px] font-semibold text-neutral-500`,children:d.length})]}),(0,G.jsx)(`div`,{className:`divide-y divide-black/5`,children:d.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[e.color&&(0,G.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-neutral-900`,children:e.label}),(0,G.jsx)(`div`,{className:`truncate font-mono text-[11px] text-neutral-400`,children:e.api_name})]}),e.icon&&(Lg[e.icon]?(0,G.jsx)(C,{icon:Lg[e.icon],className:`shrink-0 text-[12px] text-neutral-400`}):(0,G.jsx)(`span`,{className:`shrink-0 rounded px-1 font-mono text-[10px] ${Rg.has(e.icon)||Ig.has(e.icon)?`bg-neutral-100 text-neutral-400`:`bg-amber-100 text-amber-600`}`,children:e.icon}))]},t))})]}),f.length>0&&(0,G.jsxs)(J,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(C,{icon:a,className:`text-[12px] text-neutral-400`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`JS Action Templates`}),(0,G.jsx)(`span`,{className:`ml-auto rounded bg-neutral-100 px-1.5 py-0.5 text-[11px] font-semibold text-neutral-500`,children:f.length})]}),(0,G.jsx)(`div`,{className:`divide-y divide-black/5`,children:f.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-neutral-900`,children:e.name}),(0,G.jsx)(`div`,{className:`truncate font-mono text-[11px] text-neutral-400`,children:e.api_name})]}),e.hint_object_name&&(0,G.jsx)(`span`,{className:`shrink-0 rounded bg-neutral-100 px-1.5 py-0.5 text-[10px] text-neutral-500`,children:e.hint_object_name})]},t))})]}),p.length>0&&(0,G.jsxs)(J,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(C,{icon:g,className:`text-[12px] text-neutral-400`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Route Scripts`}),(0,G.jsx)(`span`,{className:`ml-auto rounded bg-neutral-100 px-1.5 py-0.5 text-[11px] font-semibold text-neutral-500`,children:p.length})]}),(0,G.jsx)(`div`,{className:`divide-y divide-black/5`,children:p.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-neutral-900`,children:e.name||e.api_name}),e.name&&(0,G.jsx)(`div`,{className:`truncate font-mono text-[11px] text-neutral-400`,children:e.api_name})]}),e.routes.length>0&&(0,G.jsxs)(`span`,{className:`shrink-0 rounded bg-neutral-100 px-1.5 py-0.5 text-[10px] text-neutral-500`,children:[e.routes.length,` route`,e.routes.length===1?``:`s`]})]},t))})]}),m.length>0&&(0,G.jsxs)(J,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(C,{icon:s,className:`text-[12px] text-neutral-400`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Object Settings`}),(0,G.jsx)(`span`,{className:`ml-auto rounded bg-neutral-100 px-1.5 py-0.5 text-[11px] font-semibold text-neutral-500`,children:m.length})]}),(0,G.jsx)(`div`,{className:`divide-y divide-black/5`,children:m.map((e,t)=>(0,G.jsx)(`div`,{className:`flex items-center gap-2 py-1.5`,children:(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-neutral-900`,children:e.label}),(0,G.jsx)(`div`,{className:`truncate font-mono text-[11px] text-neutral-400`,children:e.api_name})]})},t))})]}),h.length>0&&(0,G.jsxs)(J,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(C,{icon:_,className:`text-[12px] text-neutral-400`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Automation Actions`}),(0,G.jsx)(`span`,{className:`ml-auto rounded bg-neutral-100 px-1.5 py-0.5 text-[11px] font-semibold text-neutral-500`,children:h.length})]}),(0,G.jsx)(`div`,{className:`divide-y divide-black/5`,children:h.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-neutral-900`,children:e.name}),(0,G.jsx)(`div`,{className:`truncate font-mono text-[11px] text-neutral-400`,children:e.action_step_api_name})]}),e.action_type&&(0,G.jsx)(`span`,{className:`shrink-0 rounded bg-blue-50 px-1.5 py-0.5 text-[10px] font-semibold text-blue-600`,children:e.action_type})]},t))})]}),v.length>0&&(0,G.jsxs)(J,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsx)(C,{icon:b,className:`text-[12px] text-neutral-400`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Calendar Sources`}),(0,G.jsx)(`span`,{className:`ml-auto rounded bg-neutral-100 px-1.5 py-0.5 text-[11px] font-semibold text-neutral-500`,children:v.length})]}),(0,G.jsx)(`div`,{className:`divide-y divide-black/5`,children:v.map((e,t)=>(0,G.jsx)(`div`,{className:`flex items-center gap-2 py-1.5`,children:(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-neutral-900`,children:e.name}),(0,G.jsx)(`div`,{className:`truncate font-mono text-[11px] text-neutral-400`,children:e.api_name})]})},t))})]})]}):(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`text-[13px] text-neutral-400`,children:`No plugin assets defined.`})}),(T.length>0||E.length>0)&&(0,G.jsxs)(J,{children:[(0,G.jsx)(`div`,{className:`mb-3 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Setup Assistant`}),T.length>0&&(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-[11px] text-neutral-400`,children:`Admin setup fields`}),(0,G.jsx)(`div`,{className:`divide-y divide-black/5`,children:T.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-neutral-900`,children:e.label??e.key}),(0,G.jsx)(`span`,{className:`shrink-0 rounded bg-neutral-100 px-1.5 py-0.5 font-mono text-[10px] text-neutral-500`,children:e.type})]},t))})]}),E.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-[11px] text-neutral-400`,children:`User setup fields`}),(0,G.jsx)(`div`,{className:`divide-y divide-black/5`,children:E.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-neutral-900`,children:e.label??e.key}),(0,G.jsx)(`span`,{className:`shrink-0 rounded bg-neutral-100 px-1.5 py-0.5 font-mono text-[10px] text-neutral-500`,children:e.type})]},t))})]})]}),i.releaseNotes&&(0,G.jsxs)(J,{children:[(0,G.jsx)(`div`,{className:`mb-3 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:`Release Notes`}),(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-[12px] leading-relaxed text-neutral-700`,children:i.releaseNotes})]}),(0,G.jsx)(J,{children:(0,G.jsxs)(`details`,{children:[(0,G.jsxs)(`summary`,{className:`cursor-pointer select-none text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:[`Icon Reference (`,zg.length,` icons)`]}),(0,G.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1`,children:zg.map(e=>(0,G.jsxs)(`div`,{className:`flex w-32 items-center gap-1.5 rounded px-1.5 py-1 hover:bg-black/5`,title:e,children:[Lg[e]?(0,G.jsx)(C,{icon:Lg[e],className:`w-3.5 shrink-0 text-[13px] text-neutral-500`}):Ig.has(e)?(0,G.jsx)(`span`,{className:`w-3.5 shrink-0 text-center font-mono text-[9px] text-neutral-400`,children:`K`}):null,(0,G.jsx)(`span`,{className:`truncate font-mono text-[10px] text-neutral-500`,children:e})]},e))})]})})]})},Y={QUERY_REQUEST:`query:request`,UI_OUTPUT:`outputui`,IFRAME_OUTPUT:`iframeoutput`,POSTFORMDATA_REQUEST:`postformdata:request`,SETSTATE:`setstate`,DONE:`done`,RUN:`run`,OPEN_WINDOW:`openwindow`,COMMUNICATE:`communicate`,HIDE:`hide`,SHOW:`show`,EXPAND:`expand`,COLLAPSE:`collapse`,HIDE_HEADER:`hideheader`,SHOW_HEADER:`showheader`,OPEN_CREATE_RECORD_MODAL_REQUEST:`opencreaterecordmodal:request`,OPEN_CREATE_RELATED_RECORD_MODAL_REQUEST:`opencreaterelatedrecordmodal:request`,SHOW_TOAST:`showtoast`,CLEAR_TOASTS:`cleartoasts`,REFRESH_TIMELINE:`refreshtimeline`,REFRESH_ENTITY:`refreshentity`,UPLOADFILE_REQUEST:`uploadfile:request`,UPDATE_SESSION_DATA:`updatesessiondata`,INSTALL_THIRD_PARTY_SCRIPT_REQUEST:`installthirdpartyscript:request`,PROMPT_REQUEST:`prompt:request`,DYNAMIC_PROMPT_REQUEST:`dynamicprompt:request`,RELEASE_BLOCKING_SCRIPT:`releaseblockingscript`,AUTHORIZE:`authorize`,COPY_TO_CLIPBOARD:`copytoclipboard`},X={QUERY_RESPONSE:`query:response`,POSTFORMDATA_RESPONSE:`postformdata:response`,ERROR:`error`,UPLOADFILE_RESPONSE:`uploadfile:response`,UPLOADFILE_PROGRESS:`uploadfile:progress`,INSTALL_THIRD_PARTY_SCRIPT_RESPONSE:`installthirdpartyscript:response`,PROMPT_RESPONSE:`prompt:response`,REFRESH_ENTITY_RESPONSE:`refreshentity:response`,CREATE_RECORD_RESPONSE:`createrecord:response`,CREATE_RELATED_RECORD_RESPONSE:`createrelatedrecord:response`},Vg={RUN_FRAME_SCRIPT:`runframescript`,SEND_MESSAGE_TO_FRAME:`sendmessagetoframe`,CALL_THIRD_PARTY_SCRIPT:`callthirdpartyscript`},Hg=`integration:route-change`,Ug=`kizen-route-change`,Wg=`kzn-integration-frame`,Gg=/https:\/\/.*widget\.freshworks\.com\/.*\.js/,Kg=/https:\/\/widget\.intercom\.io\/widget\/[a-z0-9]+/,qg={FRESHWORKS:`freshworks`,INTERCOM:`intercom`},Jg=e=>{if(Gg.test(e))return qg.FRESHWORKS;if(Kg.test(e))return qg.INTERCOM},Yg={[qg.FRESHWORKS]:`FreshworksWidget`,[qg.INTERCOM]:`Intercom`},Xg={[qg.FRESHWORKS]:e=>{window.fwSettings={widget_id:e.widgetId},(function(...e){if(typeof window[Yg[qg.FRESHWORKS]]!=`function`){let t=function(){t.q.push(...e)};t.__kizen_pending=!0,t.q=[],window[Yg[qg.FRESHWORKS]]=t}})()},[qg.INTERCOM]:()=>{(function(){if(typeof window[Yg[qg.INTERCOM]]!=`function`){let e=window,t=function(){t.c(arguments)};t.q=[],t.c=function(e){t.q.push(e)},t.__kizen_pending=!0,e[Yg[qg.INTERCOM]]=t}})()}},Zg={[qg.FRESHWORKS]:()=>window[Yg[qg.FRESHWORKS]]?.__kizen_pending!==!0,[qg.INTERCOM]:()=>window[Yg[qg.INTERCOM]]?.__kizen_pending!==!0},Qg=()=>({host:window.location.host,hash:window.location.hash,href:window.location.href,origin:window.location.origin,pathname:window.location.pathname,search:window.location.search,port:window.location.port,protocol:window.location.protocol}),$g=()=>{let e=new Date().getTime();return typeof performance<`u`&&typeof performance.now==`function`&&(e+=performance.now()),`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,t=>{let n=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(t===`x`?n:n&3|8).toString(16)})};Object.getPrototypeOf(async function(){}).constructor;var e_=e=>`${e?.plugin_api_name??``}-${e?.id??``}-${e?.api_name??``}-${e?.script_id??``}`,t_=Object.create,n_=Object.defineProperty,r_=Object.getOwnPropertyDescriptor,i_=Object.getOwnPropertyNames,a_=Object.getPrototypeOf,o_=Object.prototype.hasOwnProperty,Z=(e,t)=>function(){return t||(0,e[i_(e)[0]])((t={exports:{}}).exports,t),t.exports},s_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of i_(t))!o_.call(e,i)&&i!==n&&n_(e,i,{get:()=>t[i],enumerable:!(r=r_(t,i))||r.enumerable});return e},c_=(e,t,n)=>(n=e==null?{}:t_(a_(e)),s_(t||!e||!e.__esModule?n_(n,`default`,{value:e,enumerable:!0}):n,e)),{entries:l_,setPrototypeOf:u_,isFrozen:d_,getPrototypeOf:f_,getOwnPropertyDescriptor:p_}=Object,{freeze:m_,seal:h_,create:g_}=Object,{apply:__,construct:v_}=typeof Reflect<`u`&&Reflect;m_||=function(e){return e},h_||=function(e){return e},__||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},v_||=function(e){return new e(...[...arguments].slice(1))};var y_=Q(Array.prototype.forEach),b_=Q(Array.prototype.lastIndexOf),x_=Q(Array.prototype.pop),S_=Q(Array.prototype.push),C_=Q(Array.prototype.splice),w_=Q(String.prototype.toLowerCase),T_=Q(String.prototype.toString),E_=Q(String.prototype.match),D_=Q(String.prototype.replace),O_=Q(String.prototype.indexOf),k_=Q(String.prototype.trim),A_=Q(Object.prototype.hasOwnProperty),j_=Q(RegExp.prototype.test),M_=N_(TypeError);function Q(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return __(e,t,n)}}function N_(e){return function(){return v_(e,[...arguments])}}function $(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:w_;u_&&u_(e,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(d_(t)||(t[r]=e),i=e)}e[i]=!0}return e}function P_(e){for(let t=0;t<e.length;t++)A_(e,t)||(e[t]=null);return e}function F_(e){let t=g_(null);for(let[n,r]of l_(e))A_(e,n)&&(Array.isArray(r)?t[n]=P_(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=F_(r):t[n]=r);return t}function I_(e,t){for(;e!==null;){let n=p_(e,t);if(n){if(n.get)return Q(n.get);if(typeof n.value==`function`)return Q(n.value)}e=f_(e)}function n(){return null}return n}var L_=m_(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),R_=m_(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),z_=m_([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),B_=m_([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),V_=m_(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),H_=m_([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),U_=m_([`#text`]),W_=m_(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns.slot`.split(`.`)),G_=m_(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),K_=m_(`accent.accentunder.align.bevelled.close.columnsalign.columnlines.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lspace.lquote.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),q_=m_([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),J_=h_(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Y_=h_(/<%[\w\W]*|[\w\W]*%>/gm),X_=h_(/\$\{[\w\W]*/gm),Z_=h_(/^data-[\-\w.\u00B7-\uFFFF]+$/),Q_=h_(/^aria-[\-\w]+$/),$_=h_(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ev=h_(/^(?:\w+script|data):/i),tv=h_(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),nv=h_(/^html$/i),rv=h_(/^[a-z][.\w]*(-[.\w]+)+$/i),iv=Object.freeze({__proto__:null,ARIA_ATTR:Q_,ATTR_WHITESPACE:tv,CUSTOM_ELEMENT:rv,DATA_ATTR:Z_,DOCTYPE_NAME:nv,ERB_EXPR:Y_,IS_ALLOWED_URI:$_,IS_SCRIPT_OR_DATA:ev,MUSTACHE_EXPR:J_,TMPLIT_EXPR:X_}),av={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},ov=function(){return typeof window>`u`?null:window},sv=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},cv=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function lv(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ov(),t=e=>lv(e);if(t.version=`3.3.3`,t.removed=[],!e||!e.document||e.document.nodeType!==av.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e,r=n,i=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:s,Element:c,NodeFilter:l,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:p}=e,m=c.prototype,h=I_(m,`cloneNode`),g=I_(m,`remove`),_=I_(m,`nextSibling`),v=I_(m,`childNodes`),y=I_(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let b,x=``,{implementation:S,createNodeIterator:C,createDocumentFragment:w,getElementsByTagName:T}=n,{importNode:E}=r,D=cv();t.isSupported=typeof l_==`function`&&typeof y==`function`&&S&&S.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:O,ERB_EXPR:k,TMPLIT_EXPR:A,DATA_ATTR:j,ARIA_ATTR:M,IS_SCRIPT_OR_DATA:N,ATTR_WHITESPACE:P,CUSTOM_ELEMENT:F}=iv,{IS_ALLOWED_URI:I}=iv,L=null,R=$({},[...L_,...R_,...z_,...V_,...U_]),z=null,B=$({},[...W_,...G_,...K_,...q_]),V=Object.seal(g_(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ee=null,te=null,H=Object.seal(g_(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ne=!0,re=!0,ie=!1,ae=!0,oe=!1,se=!0,ce=!1,le=!1,ue=!1,de=!1,fe=!1,pe=!1,me=!0,he=!1,ge=!0,_e=!1,ve={},ye=null,be=$({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),xe=null,Se=$({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ce=null,we=$({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Te=`http://www.w3.org/1998/Math/MathML`,Ee=`http://www.w3.org/2000/svg`,De=`http://www.w3.org/1999/xhtml`,Oe=De,ke=!1,Ae=null,je=$({},[Te,Ee,De],T_),Me=$({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Ne=$({},[`annotation-xml`]),Pe=$({},[`title`,`style`,`font`,`a`,`script`]),Fe=null,Ie=[`application/xhtml+xml`,`text/html`],U=null,Le=null,Re=n.createElement(`form`),ze=function(e){return e instanceof RegExp||e instanceof Function},Be=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Le&&Le===e)){if((!e||typeof e!=`object`)&&(e={}),e=F_(e),Fe=Ie.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,U=Fe===`application/xhtml+xml`?T_:w_,L=A_(e,`ALLOWED_TAGS`)?$({},e.ALLOWED_TAGS,U):R,z=A_(e,`ALLOWED_ATTR`)?$({},e.ALLOWED_ATTR,U):B,Ae=A_(e,`ALLOWED_NAMESPACES`)?$({},e.ALLOWED_NAMESPACES,T_):je,Ce=A_(e,`ADD_URI_SAFE_ATTR`)?$(F_(we),e.ADD_URI_SAFE_ATTR,U):we,xe=A_(e,`ADD_DATA_URI_TAGS`)?$(F_(Se),e.ADD_DATA_URI_TAGS,U):Se,ye=A_(e,`FORBID_CONTENTS`)?$({},e.FORBID_CONTENTS,U):be,ee=A_(e,`FORBID_TAGS`)?$({},e.FORBID_TAGS,U):F_({}),te=A_(e,`FORBID_ATTR`)?$({},e.FORBID_ATTR,U):F_({}),ve=A_(e,`USE_PROFILES`)?e.USE_PROFILES:!1,ne=e.ALLOW_ARIA_ATTR!==!1,re=e.ALLOW_DATA_ATTR!==!1,ie=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ae=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,oe=e.SAFE_FOR_TEMPLATES||!1,se=e.SAFE_FOR_XML!==!1,ce=e.WHOLE_DOCUMENT||!1,de=e.RETURN_DOM||!1,fe=e.RETURN_DOM_FRAGMENT||!1,pe=e.RETURN_TRUSTED_TYPE||!1,ue=e.FORCE_BODY||!1,me=e.SANITIZE_DOM!==!1,he=e.SANITIZE_NAMED_PROPS||!1,ge=e.KEEP_CONTENT!==!1,_e=e.IN_PLACE||!1,I=e.ALLOWED_URI_REGEXP||$_,Oe=e.NAMESPACE||De,Me=e.MATHML_TEXT_INTEGRATION_POINTS||Me,Ne=e.HTML_INTEGRATION_POINTS||Ne,V=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ze(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(V.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ze(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(V.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements==`boolean`&&(V.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),oe&&(re=!1),fe&&(de=!0),ve&&(L=$({},U_),z=g_(null),ve.html===!0&&($(L,L_),$(z,W_)),ve.svg===!0&&($(L,R_),$(z,G_),$(z,q_)),ve.svgFilters===!0&&($(L,z_),$(z,G_),$(z,q_)),ve.mathMl===!0&&($(L,V_),$(z,K_),$(z,q_))),A_(e,`ADD_TAGS`)||(H.tagCheck=null),A_(e,`ADD_ATTR`)||(H.attributeCheck=null),e.ADD_TAGS&&(typeof e.ADD_TAGS==`function`?H.tagCheck=e.ADD_TAGS:(L===R&&(L=F_(L)),$(L,e.ADD_TAGS,U))),e.ADD_ATTR&&(typeof e.ADD_ATTR==`function`?H.attributeCheck=e.ADD_ATTR:(z===B&&(z=F_(z)),$(z,e.ADD_ATTR,U))),e.ADD_URI_SAFE_ATTR&&$(Ce,e.ADD_URI_SAFE_ATTR,U),e.FORBID_CONTENTS&&(ye===be&&(ye=F_(ye)),$(ye,e.FORBID_CONTENTS,U)),e.ADD_FORBID_CONTENTS&&(ye===be&&(ye=F_(ye)),$(ye,e.ADD_FORBID_CONTENTS,U)),ge&&(L[`#text`]=!0),ce&&$(L,[`html`,`head`,`body`]),L.table&&($(L,[`tbody`]),delete ee.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw M_(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw M_(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);b=e.TRUSTED_TYPES_POLICY,x=b.createHTML(``)}else b===void 0&&(b=sv(p,i)),b!==null&&typeof x==`string`&&(x=b.createHTML(``));m_&&m_(e),Le=e}},Ve=$({},[...R_,...z_,...B_]),He=$({},[...V_,...H_]),Ue=function(e){let t=y(e);(!t||!t.tagName)&&(t={namespaceURI:Oe,tagName:`template`});let n=w_(e.tagName),r=w_(t.tagName);return Ae[e.namespaceURI]?e.namespaceURI===Ee?t.namespaceURI===De?n===`svg`:t.namespaceURI===Te?n===`svg`&&(r===`annotation-xml`||Me[r]):!!Ve[n]:e.namespaceURI===Te?t.namespaceURI===De?n===`math`:t.namespaceURI===Ee?n===`math`&&Ne[r]:!!He[n]:e.namespaceURI===De?t.namespaceURI===Ee&&!Ne[r]||t.namespaceURI===Te&&!Me[r]?!1:!He[n]&&(Pe[n]||!Ve[n]):!!(Fe===`application/xhtml+xml`&&Ae[e.namespaceURI]):!1},We=function(e){S_(t.removed,{element:e});try{y(e).removeChild(e)}catch{g(e)}},Ge=function(e,n){try{S_(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{S_(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(de||fe)try{We(n)}catch{}else try{n.setAttribute(e,``)}catch{}},Ke=function(e){let t=null,r=null;if(ue)e=`<remove></remove>`+e;else{let t=E_(e,/^[\r\n\t ]+/);r=t&&t[0]}Fe===`application/xhtml+xml`&&Oe===De&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=b?b.createHTML(e):e;if(Oe===De)try{t=new f().parseFromString(i,Fe)}catch{}if(!t||!t.documentElement){t=S.createDocument(Oe,`template`,null);try{t.documentElement.innerHTML=ke?x:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Oe===De?T.call(t,ce?`html`:`body`)[0]:ce?t.documentElement:a},qe=function(e){return C.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Je=function(e){return e instanceof d&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof u)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},Ye=function(e){return typeof s==`function`&&e instanceof s};function Xe(e,n,r){y_(e,e=>{e.call(t,n,r,Le)})}let Ze=function(e){let n=null;if(Xe(D.beforeSanitizeElements,e,null),Je(e))return We(e),!0;let r=U(e.nodeName);if(Xe(D.uponSanitizeElement,e,{tagName:r,allowedTags:L}),se&&e.hasChildNodes()&&!Ye(e.firstElementChild)&&j_(/<[/\w!]/g,e.innerHTML)&&j_(/<[/\w!]/g,e.textContent)||e.nodeType===av.progressingInstruction||se&&e.nodeType===av.comment&&j_(/<[/\w]/g,e.data))return We(e),!0;if(!(H.tagCheck instanceof Function&&H.tagCheck(r))&&(!L[r]||ee[r])){if(!ee[r]&&$e(r)&&(V.tagNameCheck instanceof RegExp&&j_(V.tagNameCheck,r)||V.tagNameCheck instanceof Function&&V.tagNameCheck(r)))return!1;if(ge&&!ye[r]){let t=y(e)||e.parentNode,n=v(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=h(n[i],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,_(e))}}}return We(e),!0}return e instanceof c&&!Ue(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&j_(/<\/no(script|embed|frames)/i,e.innerHTML)?(We(e),!0):(oe&&e.nodeType===av.text&&(n=e.textContent,y_([O,k,A],e=>{n=D_(n,e,` `)}),e.textContent!==n&&(S_(t.removed,{element:e.cloneNode()}),e.textContent=n)),Xe(D.afterSanitizeElements,e,null),!1)},Qe=function(e,t,r){if(te[t]||me&&(t===`id`||t===`name`)&&(r in n||r in Re))return!1;if(!(re&&!te[t]&&j_(j,t))&&!(ne&&j_(M,t))&&!(H.attributeCheck instanceof Function&&H.attributeCheck(t,e))){if(!z[t]||te[t]){if(!($e(e)&&(V.tagNameCheck instanceof RegExp&&j_(V.tagNameCheck,e)||V.tagNameCheck instanceof Function&&V.tagNameCheck(e))&&(V.attributeNameCheck instanceof RegExp&&j_(V.attributeNameCheck,t)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(t,e))||t===`is`&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&j_(V.tagNameCheck,r)||V.tagNameCheck instanceof Function&&V.tagNameCheck(r))))return!1}else if(!Ce[t]&&!j_(I,D_(r,P,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&O_(r,`data:`)===0&&xe[e])&&!(ie&&!j_(N,D_(r,P,``)))&&r)return!1}return!0},$e=function(e){return e!==`annotation-xml`&&E_(e,F)},et=function(e){Xe(D.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||Je(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:z,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=U(a),l=s,u=a===`value`?l:k_(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,Xe(D.uponSanitizeAttribute,e,r),u=r.attrValue,he&&(c===`id`||c===`name`)&&(Ge(a,e),u=`user-content-`+u),se&&j_(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){Ge(a,e);continue}if(c===`attributename`&&E_(u,`href`)){Ge(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){Ge(a,e);continue}if(!ae&&j_(/\/>/i,u)){Ge(a,e);continue}oe&&y_([O,k,A],e=>{u=D_(u,e,` `)});let d=U(e.nodeName);if(!Qe(d,c,u)){Ge(a,e);continue}if(b&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!o)switch(p.getAttributeType(d,c)){case`TrustedHTML`:u=b.createHTML(u);break;case`TrustedScriptURL`:u=b.createScriptURL(u);break}if(u!==l)try{o?e.setAttributeNS(o,a,u):e.setAttribute(a,u),Je(e)?We(e):x_(t.removed)}catch{Ge(a,e)}}Xe(D.afterSanitizeAttributes,e,null)},tt=function e(t){let n=null,r=qe(t);for(Xe(D.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)Xe(D.uponSanitizeShadowNode,n,null),Ze(n),et(n),n.content instanceof a&&e(n.content);Xe(D.afterSanitizeShadowDOM,t,null)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,c=null,l=null;if(ke=!e,ke&&(e=`<!-->`),typeof e!=`string`&&!Ye(e))if(typeof e.toString==`function`){if(e=e.toString(),typeof e!=`string`)throw M_(`dirty is not a string, aborting`)}else throw M_(`toString is not a function`);if(!t.isSupported)return e;if(le||Be(n),t.removed=[],typeof e==`string`&&(_e=!1),_e){if(e.nodeName){let t=U(e.nodeName);if(!L[t]||ee[t])throw M_(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=Ke(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===av.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!de&&!oe&&!ce&&e.indexOf(`<`)===-1)return b&&pe?b.createHTML(e):e;if(i=Ke(e),!i)return de?null:pe?x:``}i&&ue&&We(i.firstChild);let u=qe(_e?e:i);for(;c=u.nextNode();)Ze(c),et(c),c.content instanceof a&&tt(c.content);if(_e)return e;if(de){if(fe)for(l=w.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(z.shadowroot||z.shadowrootmode)&&(l=E.call(r,l,!0)),l}let d=ce?i.outerHTML:i.innerHTML;return ce&&L[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&j_(nv,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
@@ -14,4 +14,4 @@ import{n as e,t}from"./rolldown-runtime-DF2fYuay.js";import{C as n,S as r,_ as i
|
|
|
14
14
|
@scope {
|
|
15
15
|
${o??``}
|
|
16
16
|
}
|
|
17
|
-
`,sanitizedHtml:s,outputUIRef:i,interactableScriptRef:a}},ab=(e,t,n,r,i={})=>{let a=(0,W.useMemo)(()=>t?.event_scripts??{},[t]),o=(0,W.useCallback)(t=>{if(t.preventDefault(),t.stopPropagation(),!r){let n=t.target.getAttribute(`data-script`);n&&a[n]&&e(a[n],{...i})}},[r,e,a,i]);(0,W.useEffect)(()=>{let e=n?.current;return e&&e.addEventListener(`click`,o),()=>{e&&e.removeEventListener(`click`,o)}},[o,t,n])},ob=(e,t,n)=>{let r=e?.iframe_url,i=e?.script,a=e?.callback,o=e?.args,{showToast:s}=eb(),{t:c}=Zy(),l=(0,W.useRef)(null),[u,{pending:d}]=nb({onError:e=>{s({message:`${c(`Plugin error:`)} ${e?.message??``}`,variant:`failure`})},scriptUIRef:l,plugin:e}),f=(0,W.useMemo)(()=>{let e=new URLSearchParams(t);return{...Object.fromEntries(e),...o}},[t,o]),{outputUIRef:p,scopedCss:m,sanitizedHtml:h,interactableScriptRef:g}=ib(e,f);ab(u,e,l,d);let _=(0,W.useRef)(!1);(0,W.useEffect)(()=>{!r&&!_.current&&i&&!n&&(_.current=!0,u(i,f))},[r,u,i,f,n]);let v=(0,W.useCallback)(e=>{let t=e.data;if(t?.type===`kizen:plugin_callback`){let e=t.query;a&&u(a,e)}},[u,a]);return(0,W.useEffect)(()=>(window.addEventListener(`message`,v),()=>{window.removeEventListener(`message`,v)}),[v]),{scriptUIRef:l,outputUIRef:p,scopedCss:m,sanitizedHtml:h,interactableScriptRef:g,iframeURL:r,pending:d}},sb=(0,W.createContext)(null),cb=({children:e})=>{let[t,n]=(0,W.useState)([]),[r,i]=(0,W.useState)(!1),a=(0,W.useCallback)((e,t)=>{n(n=>{let r=[e,...n.filter(t=>t!==e)];return t?.(r),r})},[]),o=(0,W.useMemo)(()=>[...t].reverse().reduce((e,t,n)=>({...e,[t]:n}),{}),[t]);return(0,W.useEffect)(()=>{let e=new MutationObserver(()=>{document.querySelector(`div[role="dialog"]`)?i(!0):i(!1)});return e.observe(document.body,{childList:!0}),()=>{e.disconnect()}},[]),(0,G.jsx)(sb.Provider,{value:{touchFloatingFrame:a,floatingFrameOffset:o},children:e(r)})},lb=()=>{let e=(0,W.useContext)(sb);if(!e)throw Error(`useFloatingFrame must be used within a FloatingFrameWrapper`);return e},ub=[`^/$`,`^/login*`,`/settings/mine$`,`/settings/others$`,`/create-new-business$`,`^/choose-business*`,`^/inactive-business$`,`^/reset$`,`/welcome$`,`/embed/*`,`/create-new-business$`,`/businessbuilder`],db=[`https://js.stripe.com`],fb=(e,t,n,r)=>e<n?t<r?`top-left`:`top-right`:t<r?`bottom-left`:`bottom-right`,pb=e=>{let{currentWindow:t,pathname:n,id:r,frameHeaderSize:i,defaultPositionGap:a=0,viewportHeight:o=window.innerHeight,hiddenByModal:s,updateEmployeeConfig:c}=e,l=(0,W.useRef)(null),u=(0,W.useRef)(!1),{showToast:d}=eb(),{t:f}=Zy(),{installedPluginAPINamesToIds:p,clientObject:m}=My(),{touchFloatingFrame:h,floatingFrameOffset:g}=lb(),_=g[r]??-1,v=t.minimized_style===`none`,y=t.minimized_style===`circle`||v,b=t.default_position===`bottom-right-fixed`,x=t.default_position===`bottom-left-fixed`,S=b||x,C=t.minimized_config?.icon??`action-drag-handle`,w=t.minimized_config?.color??`blue`,T=(0,W.useMemo)(()=>{let e=n.split(`/`),t=e[1],r=e[2];if(t===`client`)return{objectId:m?.id,entityId:r};if(t===`custom-objects`)return{objectId:r,entityId:e[3]}},[m,n]),E=(0,W.useMemo)(()=>{let e=t.match,r=t.ignore;return!!(e?.length&&!e.some(e=>new RegExp(e).test(n))||ub.concat(r??[]).filter(Boolean).some(e=>{try{return new RegExp(e).test(n)}catch{return!1}}))},[t,n]),D=t.plugin_api_name?p[t.plugin_api_name]:``,[O,k]=(0,W.useState)(()=>t.employee_config?.[r]?.minimized??!1),A=t.script,j=t.type,M=t.args,N=t.message_handler,P=t.width??0,[F,I]=(0,W.useState)(()=>{let e=window.innerHeight;return Math.min(t.height??0,e-i)}),[L,R]=(0,W.useState)(null),z=t.default_position,B=(0,W.useCallback)(e=>{let n=t.employee_config?.[r]?.position;if(!n?.quadrant){let t=window.innerWidth-P,r=window.innerHeight-F-i;if(O&&!e&&(r=window.innerHeight-i),n)try{let e=n;return e.left>t&&(e.left=t),e.top>r&&(e.top=r),e.left<0&&(e.left=a),e.top<0&&(e.top=a),e}catch{}let o=t;return z===`bottom-left`&&(o=a),{left:o,top:r-a}}else if(n.quadrant===`top-left`){let e=n.deltas?.left??0,t=n.deltas?.top??0;return{...n,left:e,top:t}}else if(n.quadrant===`top-right`){let e=window.innerWidth-P-(n.deltas?.right??0),t=n.deltas?.top??0;return{...n,left:e,top:t}}else if(n.quadrant===`bottom-left`){let e=n.deltas?.left??0,t=window.innerHeight-(O?0:F)-(n.deltas?.bottom??0)-i;return{...n,left:e,top:t}}else{let e=window.innerWidth-P-(n.deltas?.right??0),t=window.innerHeight-(O?0:F)-(n.deltas?.bottom??0)-i;return{...n,left:e,top:t}}},[t,r,z,O,P,F,i,a]),V=(0,W.useCallback)(e=>{let t=B(e),n=[`bottom-right`,`bottom-left`].includes(t.quadrant??``)&&O?0:F;return t.left<0?t.left=0:t.left>window.innerWidth-P&&(t.left=window.innerWidth-P),t.top<0?t.top=0:t.top>window.innerHeight-n&&(t.top=window.innerHeight-n),t},[B,P,F,O]);(0,W.useEffect)(()=>{let e=t.height??0;if(e>o){I(o-i);let e=B(!0);e.top=0,R(e)}else I(e)},[t.height,B,o,i]);let[ee,te]=(0,W.useState)(O),[H,ne]=(0,W.useState)(O&&y),re=F*5e-4*1e3,ie=e=>{k(e),e&&y?setTimeout(()=>{ne(e)},re):y&&ne(e),s?setTimeout(()=>{te(e)},re):te(e),(L?.quadrant===`bottom-left`||L?.quadrant===`bottom-right`)&&R(e?e=>e?{...e,top:e.top+F}:null:e=>{if(!e)return null;let t=window.innerHeight,n=e.top>=0&&e.top+F<=t;return{...e,top:n?e.top:e.top-F}}),c?.(r,O,L)({minimized:e})},[ae,{pending:oe,hidden:se,indicator:ce,triggerHidden:le,hideHeader:ue}]=tb({onError:e=>{d({message:`${f(`Plugin error:`)} ${e?.message??``}`,variant:`failure`})},scriptUIRef:l,plugin:t,onChangeMinimized:e=>{ie(e)}}),de=(0,W.useMemo)(()=>ue&&S,[ue,S]),fe=(0,W.useMemo)(()=>{if(!L)return`top`;let{left:e,top:t}=L;return window.innerWidth-(e+P)<40?`left`:t<40?`bottom`:`top`},[L,P]),pe=(0,W.useCallback)(()=>{let e=x?`left`:`right`,n=`${t.plugin_api_name}-${t.api_name}-trigger-${e}`;return document.getElementById(n)},[x,t]),me=(0,W.useCallback)(()=>{if(!S)return;let e=pe();if(!e)return;let t=e.getBoundingClientRect(),n=O?0:F,r=de?0:i,o=t.top-(n+r)-a,s=x?t.left:t.right-P,c=n+r,l=Math.max(0,window.innerWidth-P),u=Math.max(0,window.innerHeight-c);s=Math.min(Math.max(0,s),l),o=Math.min(Math.max(0,o),u),R({left:s,top:o,quadrant:x?`bottom-left`:`bottom-right`,deltas:{top:o,left:s,right:window.innerWidth-(s+P),bottom:window.innerHeight-(o+c)}})},[S,x,F,O,P,de,pe,i,a]);(0,W.useEffect)(()=>{S&&me()},[S,F,O,me]),(0,W.useEffect)(()=>{if(!S)return;me();let e=new ResizeObserver(()=>{me()});return e.observe(document.body),()=>{e.disconnect()}},[S,me]),(0,W.useEffect)(()=>{!u.current&&A&&j===`script`&&!E&&(u.current=!0,ae(A,{...M}))},[ae,A,j,M,E]),(0,W.useEffect)(()=>{let e=e=>{let n=e;if(n?.detail?.recipient?.frame===t.api_name){let e=n.detail;if(e.recipient?.plugin!==t.plugin_api_name)return;e.recipient.script&&t.event_scripts?.[e.recipient.script]&&ae(t.event_scripts[e.recipient.script]??``,{...e.args,...M,...T})}};return window.addEventListener(Cy,e),()=>{window.removeEventListener(Cy,e)}},[t,ae,M,T]);let[he,ge]=(0,W.useState)(!1),_e=(e,t)=>{ge(!1),h(r);let n=window.innerWidth,i=window.innerHeight;if(t.node){let e=t.node.getBoundingClientRect(),a=e.left,o=e.top,s=o+e.height,l=a+e.width,u=o,d=i-s,f=a,p=n-l,m={left:a,right:l,top:o,quadrant:fb(u,f,d,p),deltas:{top:u,bottom:d,left:f,right:p}};R(m),c?.(r,O,L)({position:m})}};(0,W.useEffect)(()=>{let e=()=>{S?me():R(V(!1))};return window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[S,me,V]),ab(ae,t,l,oe,M),(0,W.useEffect)(()=>{let e=e=>{e.source!==window&&N&&!db.includes(e.origin)&&ae(N,{...M,eventData:e.data})};return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e)}},[ae,M,N]);let{outputUIRef:ve,scopedCss:ye,sanitizedHtml:be,interactableScriptRef:xe}=ib(t,{}),Se=ee?se||E||s:se||E,Ce=`floating-window-parent--${r}`,we=`floating-drag-handle--${r}`,Te=`floating-window-content--${r}`,Ee=t.employee_config?.[r]?.position?.quadrant?.split(`-`)[1]===`right`?`right`:`left`;x?Ee=`left`:b&&(Ee=`right`);let De=t.minimized_config?.customIcon,Oe=null;return De?.startsWith(`data:image/`)&&(Oe=({className:e=``})=>(0,G.jsx)(`img`,{src:De,alt:t.title||`Open Frame`,className:`object-cover select-none pointer-events-none ${e}`})),L||R(V(!1)),{circleProps:{id:r,side:Ee,circleIcon:C,CustomIcon:Oe,circleColor:w,onClick:()=>{ie(!O)},hidden:!!(Se||E||v||le)},parentProps:{className:Ce,dragging:he,hidden:Se||H||E||v},draggableProps:{onStop:_e,onStart:()=>{ge(!0)},bounds:`.${Ce}`,handle:`.${we}`,defaultPosition:{x:L?.left??0,y:L?.top??0},position:{x:L?.left??0,y:L?.top??0},disabled:S},floatProps:{pending:oe,width:P,dragging:he,height:F,isCircle:y&&O},contentProps:{className:Te,dragging:he,solid:!0},minimized:O,pending:oe,indicator:ce,hideHeader:de,isFixed:S,isCircle:y,outputUIRef:ve,scopedCss:ye,sanitizedHtml:be,interactableScriptRef:xe,tooltipPosition:fe,currentPluginId:D,setMinimized:ie,dragHandleClassName:we,height:F,script:A,dragging:he,frameOffset:_,scriptUIRef:l}},mb=()=>{(0,W.useEffect)(()=>{let e=null,t=t=>{if(!t.detail?.location)return;let n=sy(t.detail.location);n!==e&&(e=n,document.querySelectorAll(`iframe[id^=${Wg}-]`).forEach(e=>{let n=null;try{n=new URL(e.src,window.location.href).origin}catch(e){ay(`script-runner-logging`)&&console.warn(`Failed to parse iframe src for location change message target origin:`,e),n=null}n&&e.contentWindow?.postMessage({action:Ug,location:t.detail?.location},n)}))};return window.addEventListener(Hg,t),()=>{window.removeEventListener(Hg,t)}},[])},hb=new mu,gb=({children:e})=>(0,W.useContext)(hu)?(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsx)(_u,{client:hb,children:e}),_b=e=>{let{children:t,bootstrapPlugins:n=[],userConfigs:r=[],user:i,teamMember:a,business:o,clientObject:s,onNavigate:c,modal:l,monitoringExceptionHelper:u,showToast:d,clearToasts:f,performRequest:p,appPath:m,hideFramesOnModal:h=!0,createFileId:g,performFileUpload:_,t:v}=e;return mb(),(0,G.jsx)(gb,{children:(0,G.jsx)(jy,{bootstrapPlugins:n,userConfigs:r,user:i,teamMember:a,business:o,clientObject:s,appPath:m,children:({hasFinishedBootstrapping:e,waitingOnRouteScript:n})=>(0,G.jsx)(Xy,{t:v,children:(0,G.jsx)(Py,{children:r=>(0,G.jsx)(Uy,{onNavigate:c,children:(0,G.jsx)(Ly,{...l,children:i=>(0,G.jsx)(By,{monitoringExceptionHelper:u,children:(0,G.jsx)(Oy,{children:(0,G.jsx)(Ty,{children:(0,G.jsx)($y,{showToast:d,clearToasts:f,children:(0,G.jsx)(cb,{children:a=>(0,G.jsx)(Ky,{performRequest:p,createFileId:g,performFileUpload:_,children:t({...i,showLoadingIndicator:r,hasFinishedBootstrapping:e,waitingOnRouteScript:n,hiddenByModal:h?a:!1})})})})})})})})})})})})})},vb=(0,W.createContext)(null),yb=vb.Provider,bb=(e,t)=>{if(e===`custom_object`)return t?.id},xb=(e,t)=>{if(e.type===`custom_object`)return e.allow_multiple?(t?.value??[]).length>0:!!t?.value?.id;if(e.type===`field`)return e.allow_multiple?(t?.value??[]).length>0:!!t?.value?.value;if(e.type===`text`)return!!(t?.value??``).trim();if(e.type===`number`){let e=Number(t?.value);return!!t?.value&&!isNaN(e)}else if(e.type===`select`)return e.allow_multiple?(t?.value??[]).length>0:!!t?.value?.value;else if(e.type===`boolean`)return!!t?.value;return!1},Sb=e=>{let t=(e.fields??[]).filter(e=>e.type===`custom_object`),n=(e.fields??[]).filter(e=>e.type===`container`).flatMap(e=>Sb(e)),r=e.actions?.filter(e=>e.hint_object_name)??[];return[...t,...n,...r.map(e=>({...by(e),match_hint:e.hint_object_name??``}))]},Cb=e=>{let t=(e.fields??[]).filter(e=>e.type===`field`),n=(e.fields??[]).filter(e=>e.type===`container`).flatMap(e=>Cb(e));return[...t,...n]},wb=({children:e,config:t,value:n,onStateChange:r,disabledKeys:i,templateAssociationsByActionApiName:a,getObjectByAPIName:o,getCustomObjectDetails:s})=>{let[c,l]=(0,W.useState)(n??{}),u=(0,W.useMemo)(()=>xy(t),[t]),d=(0,W.useMemo)(()=>u.reduce((e,t)=>({...e,[t.key]:{type:t.type,value:t.default}}),{}),[u]),f=(0,W.useMemo)(()=>{let e={...Object.entries(a??{}).reduce((e,[t,n])=>{let r=`action__${t}`,i=n.map(e=>({id:e.custom_object.id??``,objectName:e.custom_object.object_name??`Unknown Object`}));return i.length>0&&n.length>0&&n[0]&&(e[r]={type:`custom_object`,value:i,config:by(n[0].browser_js_action_template)}),e},{}),...c};return i?.forEach(t=>{e[t]&&(e[t]=void 0)}),e},[c,a,i]),p=(0,W.useRef)(!!n),m=(0,W.useRef)({}),[h,g]=(0,W.useState)(!n),[_,v]=(0,W.useState)({}),[y,b]=(0,W.useState)({}),[x,S]=(0,W.useState)(!1),C=(0,W.useRef)(null),[w,T]=(0,W.useState)({}),[E,D]=(0,W.useState)(!1),[O,k]=(0,W.useState)(!0),A=(0,W.useRef)({}),j=(0,W.useCallback)((e,t)=>{A.current[e]=t},[]),M=(0,W.useCallback)(e=>{typeof e==`function`?l(t=>{let n=e(t);return m.current=n,r?.(n),n}):(m.current=e,l(e),r?.(e)),T({})},[r]),N=(0,W.useCallback)((e,t)=>{if(e.startsWith(`{{`)&&e.endsWith(`}}`)){let n=e.slice(2,-2).trim();return bb(t[n]?.type,t[n]?.value)}return e},[]),P=(0,W.useCallback)(e=>N(e,f),[f,N]),{clientObject:F}=My(),I=(0,W.useCallback)(async e=>e===`client_client`&&F?[{id:F.id,object_name:F.objectName}]:await o(e),[F,o]),L=(0,W.useCallback)(async()=>{let e=Sb(t);for(let t of e){if(!t.match_hint)continue;let e=await I(t.match_hint);if(e?.[0]){let n={id:e[0].id,objectName:e[0].object_name};M(e=>({...e,[t.key]:{type:`custom_object`,value:t.allow_multiple?[n]:n}}))}}},[t,M,I]),R=(0,W.useCallback)(()=>Cb(t),[t]),z=(0,W.useCallback)(async(e,t)=>{let n=R(),r={};for(let i of n){if(!i.object_id)continue;let n=t??N(i.object_id,m.current);if(e&&!i.object_id.includes(e))continue;if(!r[n]&&n)try{r[n]=await s(n)}catch{}let a=r[n];if(a){let e=a.fields.find(e=>e.name===i.match_hint);e&&M(t=>({...t,[i.key]:{type:`field`,value:{value:e.id,label:e.displayName},associatedObject:{id:n,name:a.objectName}}}))}}},[N,R,M,s]),B=(0,W.useCallback)(async e=>{let n=Sb(t).find(t=>t.key===e);if(n?.match_hint){let t=``,r=(await I(n.match_hint))?.[0];r&&(t=r.id,M(t=>({...t,[e]:{type:`custom_object`,value:{id:r.id,objectName:r.object_name}}})),t&&z(void 0,t))}},[t,M,z,I]),V=(0,W.useCallback)(async()=>{await L(),await z(),g(!1)},[L,z]),ee=(0,W.useCallback)(()=>Cb(t),[t]),te=(0,W.useCallback)(e=>z(e),[z]),H=(0,W.useCallback)(()=>{C.current&&=(clearTimeout(C.current),null),C.current=setTimeout(()=>{S(!0)},500)},[]),ne=(0,W.useCallback)(async(e,t)=>{H(),v(e=>({...e,[t]:!0})),D(!0);let n=await gy(e,{...d,...f});return b(e=>(e[t]===!1&&typeof n==`boolean`&&n&&(f[t]||B(t)),{...e,[t]:n})),v(e=>({...e,[t]:!1})),n},[f,H,B,d]);p.current||(p.current=!0,V());let re=(0,W.useCallback)(e=>y[e]===!1,[y]),ie=(0,W.useCallback)(e=>_[e]===!0,[_]),ae=(0,W.useCallback)(e=>{if(w[e])return{message:w[e],showMessage:!0,error:!0}},[w]),oe=(0,W.useMemo)(()=>{let e=(t.fields??[]).filter(e=>e.type===`container`).map(e=>e.when),n=u.map(e=>e.when);return[...e,...n].filter(Boolean)},[t,u]),se=(0,W.useMemo)(()=>u.reduce((e,t)=>(e[t.key]=t,e),{}),[u]),ce=(0,W.useCallback)((e,t,n)=>{t.add(e);let r=se[e];r?.dependencies?.length&&r.dependencies.forEach(e=>{n.has(e)||(n.add(e),ce(e,t,n))})},[se]),le=(0,W.useMemo)(()=>u.map(e=>{let t=new Set,n=e.dependencies??[],r=new Set;return n.forEach(e=>{ce(e,t,r)}),{...e,dependencies:Array.from(t)}}),[u,ce]),ue=(0,W.useCallback)(e=>{le.filter(t=>t.dependencies.length===0?!1:t.dependencies.includes(e)&&t.key!==e).forEach(e=>{A.current[e.key]?.()})},[le]),de=(0,W.useCallback)(async()=>{let e=(await Promise.all(u.map(async e=>e.when?await gy(e.when,{...d,...f})?e:null:e))).filter(Boolean),t=0;for(let n of e)n&&n.required&&!xb(n,f[n.key])?(T(e=>({...e,[n.key]:`This field is required`})),t++):n?.validation_pattern?new RegExp(n.validation_pattern).test(f[n.key]?.value??n.default??``)||(T(e=>({...e,[n.key]:`Value must match the pattern ${n.validation_pattern??``}`})),t++):n&&T(e=>({...e,[n.key]:void 0}));return{isValid:t===0,includedKeys:e.map(e=>e?.key).filter(e=>!!e)}},[f,u,d]);(0,W.useEffect)(()=>{H()},[H]);let fe=Object.values(_).filter(Boolean).length;return!E&&oe.length===0&&D(!0),E&&O&&fe===0&&k(!1),(0,G.jsx)(yb,{value:{state:f,setState:M,interpolateValue:P,getNestedFields:ee,reInferFieldsForObject:te,inferencePending:h,evaluateExpression:ne,shouldHideField:re,shouldDisableField:ie,expressionsIdle:x,getFieldErrorState:ae,validateForm:de,waitingExpressionCount:fe,initialExpressionsPending:O,flattenedFields:u,flattenedFieldsByKey:se,afterFieldChange:ue,registerFieldResetter:j,disabledKeys:i??[]},children:e})},Tb=()=>{let e=(0,W.useContext)(vb);if(!e)throw Error(`useSetupAssistant must be used within a SetupAssistantController`);return e},Eb=36,Db=20,Ob=9e3,kb=({frameId:e,side:t,color:n,zIndex:r,onClick:i,CustomIcon:a})=>{let o=document.getElementById(`${e}-trigger-${t}`);return o?(0,Ec.createPortal)((0,G.jsx)(`button`,{className:`pointer-events-auto flex h-10 w-10 items-center justify-center rounded-full border border-black/10 shadow-lg`,style:{backgroundColor:n,zIndex:r},onClick:i,onPointerDown:e=>{e.stopPropagation()},title:`Open frame`,children:a?(0,G.jsx)(a,{className:`h-6 w-6 rounded-full object-cover`}):(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-white`,children:`▲`})}),o):null},Ab=({frame:e,framesEnabled:t})=>{let n=`${e.plugin_api_name}-${e.api_name}`,r=ad(),[i,a]=(0,W.useState)(window.innerHeight);(0,W.useEffect)(()=>{let e=new ResizeObserver(()=>{a(window.innerHeight)});return e.observe(document.body),()=>{e.disconnect()}},[]);let{circleProps:o,parentProps:s,draggableProps:c,pending:l,indicator:u,outputUIRef:d,scopedCss:f,sanitizedHtml:p,interactableScriptRef:m,hideHeader:h,setMinimized:g,dragHandleClassName:_,isFixed:v,isCircle:y,minimized:b,height:x,dragging:S,frameOffset:C,scriptUIRef:w}=pb({currentWindow:e,pathname:`/sandbox`,id:n,frameHeaderSize:Eb,defaultPositionGap:Db,viewportHeight:i,hiddenByModal:!1}),T=Ob+Math.max(0,C),E=`floating-frame-pos-${n}`,D=(()=>{try{let e=localStorage.getItem(E);return e?JSON.parse(e):null}catch{return null}})(),O=(0,W.useRef)(null),[k,A]=(0,W.useState)(D??c.position),j=(0,W.useRef)(D!==null),M=c.position;(0,W.useEffect)(()=>{j.current||A({x:M.x,y:M.y})},[M.x,M.y]);let N=(0,W.useCallback)(e=>{if(c.disabled||!e.target.closest(`.${_}`))return;e.preventDefault(),c.onStart();let t=e.clientX,n=e.clientY,r=k.x,i=k.y,a=e=>{A({x:r+e.clientX-t,y:i+e.clientY-n})},o=e=>{document.removeEventListener(`pointermove`,a),document.removeEventListener(`pointerup`,o);let s={x:r+e.clientX-t,y:i+e.clientY-n};localStorage.setItem(E,JSON.stringify(s)),j.current=!0,c.onStop(e,{node:O.current})};document.addEventListener(`pointermove`,a),document.addEventListener(`pointerup`,o)},[c,_,k,E]);return(0,G.jsxs)(G.Fragment,{children:[y&&!o.hidden&&(0,G.jsx)(kb,{frameId:n,side:o.side,color:o.circleColor,zIndex:T,onClick:o.onClick,CustomIcon:o.CustomIcon}),(0,G.jsxs)(`div`,{ref:O,className:s.className,style:{position:`fixed`,left:Math.min(k.x,window.innerWidth-r-(e.width??300)),top:k.y,width:e.width??300,zIndex:T,borderRadius:6,overflow:`hidden`,border:`1px solid rgba(0,0,0,0.1)`,boxShadow:`0 4px 20px rgba(0,0,0,0.1)`,backgroundColor:`white`,opacity:s.hidden||!t?0:1,pointerEvents:s.hidden||!t?`none`:`auto`},onPointerDown:N,children:[(l||u===`block`)&&(0,G.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-white/80 font-mono text-[11px] text-neutral-400`,children:`loading…`}),!h&&(0,G.jsxs)(`div`,{className:`flex select-none items-center border-b border-black/8`,style:{height:Eb,backgroundColor:e.header_color??`#fafafa`,color:e.header_text_color??`#1a1a1a`},children:[(0,G.jsxs)(`div`,{className:`${_} flex h-full flex-1 items-center gap-2 overflow-hidden px-3 ${v?``:`cursor-grab active:cursor-grabbing`}`,children:[!v&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] opacity-30`,children:`⠿`}),(0,G.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,children:e.title})]}),(0,G.jsx)(`button`,{className:`flex h-full shrink-0 items-center px-3 font-mono text-[11px] transition-colors hover:bg-black/5`,onClick:()=>{g(!b)},onMouseDown:e=>{e.stopPropagation()},onPointerDown:e=>{e.stopPropagation()},title:b?`Expand`:`Collapse`,children:b?`↑`:`↓`})]}),(0,G.jsxs)(`div`,{style:{height:b?0:x,overflow:`hidden`,transition:`height ${String(x*5e-4)}s ease`},children:[e.type===`script`&&(0,G.jsxs)(`div`,{className:`h-full w-full`,style:{pointerEvents:S||s.hidden||!t?`none`:`auto`},children:[(0,G.jsx)(`div`,{className:`h-full w-full`,ref:w}),(0,G.jsx)(`style`,{children:f})]}),e.type===`html`&&p&&(0,G.jsxs)(`div`,{ref:m,className:`overflow-auto bg-white`,style:{height:x,pointerEvents:S||s.hidden||!t?`none`:`auto`},children:[(0,G.jsx)(`div`,{dangerouslySetInnerHTML:{__html:p}}),(0,G.jsx)(`div`,{ref:d}),(0,G.jsx)(`style`,{children:f})]})]})]})]})},jb=({label:e,value:t,onChange:n,onSelect:r,options:i,loading:a,placeholder:o,disabled:s})=>{let[c,l]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`relative flex flex-col gap-1`,children:[e&&(0,G.jsx)(`label`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-500`,children:e}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(C,{icon:x,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-[10px] text-neutral-400`}),(0,G.jsx)(`input`,{type:`text`,className:`w-full rounded border border-black/10 bg-white py-1.5 pl-7 pr-2.5 font-mono text-[12px] text-neutral-800 focus:border-neutral-400 focus:outline-none disabled:opacity-50`,value:t,placeholder:o,disabled:s,onChange:e=>{n(e.target.value)},onFocus:()=>{l(!0)},onBlur:()=>{l(!1)}})]}),c&&(0,G.jsxs)(`ul`,{className:`absolute left-0 top-full z-10 mt-1 max-h-48 w-full overflow-auto rounded border border-black/10 bg-white shadow-lg`,children:[a&&(0,G.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-neutral-400`,children:`Loading…`}),!a&&i.length===0&&t.length===0&&(0,G.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-neutral-400`,children:`Start typing to search…`}),!a&&i.length===0&&t.length>0&&(0,G.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-neutral-400`,children:`No results`}),!a&&i.map(e=>(0,G.jsx)(`li`,{className:`cursor-pointer px-3 py-2 text-[12px] text-neutral-800 hover:bg-neutral-100`,onMouseDown:e=>{e.preventDefault()},onClick:()=>{r(e.id,e.label),l(!1)},children:e.label},e.id))]})]})},Mb=({action:e,objectId:t,entityId:n,pluginApiName:r,configArgs:i,disabled:a})=>{let[o,{pending:s}]=rb({objectId:t,entityId:n,onError:t=>{console.error(`[js-action] ${e.api_name}:`,t)}}),c={id:e.api_name,api_name:e.api_name,plugin_api_name:r};return(0,G.jsxs)(`button`,{onClick:()=>{o(e.script,i,c)},disabled:a===!0||s,className:`relative flex flex-col items-start rounded border border-black/8 bg-white px-3 py-1.5 text-left transition-colors hover:bg-black/5 disabled:opacity-50`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[12px] text-neutral-800`,children:e.name}),e.hint_object_name&&(0,G.jsxs)(`span`,{className:`font-mono text-[10px] text-neutral-400`,children:[`for: `,e.hint_object_name]}),s&&(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center rounded bg-white/70`,children:(0,G.jsx)(C,{icon:d,spin:!0,className:`text-[11px] text-neutral-400`})})]})},Nb=({actions:e,pluginApiName:t,configArgs:n})=>{let r=zu(),{apiKey:i,businessId:a}=Iu(),[o,s]=(0,W.useState)(()=>{try{let e=localStorage.getItem(`kizen-sandbox:${t}:selectedObject`);return e?JSON.parse(e):null}catch{return null}}),[c,l]=(0,W.useState)(()=>o?.name??``),[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(()=>{try{let e=localStorage.getItem(`kizen-sandbox:${t}:selectedEntity`);return e?JSON.parse(e):null}catch{return null}}),[m,h]=(0,W.useState)(()=>f?.label??``),[g,_]=(0,W.useState)(``),v=(0,W.useRef)(null);(0,W.useEffect)(()=>(v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{d(c)},300),()=>{v.current&&clearTimeout(v.current)}),[c]);let y=(0,W.useRef)(null);(0,W.useEffect)(()=>(y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{_(m)},300),()=>{y.current&&clearTimeout(y.current)}),[m]),(0,W.useEffect)(()=>{o?localStorage.setItem(`kizen-sandbox:${t}:selectedObject`,JSON.stringify(o)):localStorage.removeItem(`kizen-sandbox:${t}:selectedObject`)},[o,t]),(0,W.useEffect)(()=>{f?localStorage.setItem(`kizen-sandbox:${t}:selectedEntity`,JSON.stringify(f)):localStorage.removeItem(`kizen-sandbox:${t}:selectedEntity`)},[f,t]);let b=ju({queryKey:[`custom-objects`,a,u],queryFn:async()=>{let e=new URLSearchParams({page_size:`20`});return u&&e.set(`search`,u),await(await r(`/custom-objects?${e.toString()}`)).json()},enabled:i!==``&&u.length>=1,staleTime:3e4}),x=ju({queryKey:[`entity-records`,o?.id,g],queryFn:async()=>{let e=new URLSearchParams({page_size:`20`});return g&&e.set(`search`,g),await(await r(`/records/${o?.id??``}/search?${e.toString()}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`})).json()},enabled:i!==``&&o!==null,staleTime:3e4}),S=b.data?.results.map(e=>({id:e.id,label:e.object_name}))??[],C=x.data?.results.map(e=>{let t=Object.values(e.fields).find(e=>e.name===`display_name`)?.value,n=typeof t==`string`?t:e.id;return{id:e.id,label:n}})??[];if(!i)return(0,G.jsx)(`p`,{className:`mt-1 text-[12px] text-neutral-400`,children:`Configure API credentials in Dev Tools to use JS action templates.`});let w=o!==null&&f!==null;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 p-2`,children:[(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(`div`,{className:`flex-1`,children:(0,G.jsx)(jb,{label:`Custom Object`,value:c,onChange:e=>{l(e),o&&(s(null),p(null),h(``))},onSelect:(e,t)=>{s({id:e,name:t}),l(t),p(null),h(``)},options:S,loading:b.isFetching,placeholder:`Search custom objects…`})}),(0,G.jsx)(`div`,{className:`flex-1`,children:(0,G.jsx)(jb,{label:`Entity`,value:m,onChange:e=>{h(e),f&&p(null)},onSelect:(e,t)=>{p({id:e,label:t}),h(t)},options:C,loading:x.isFetching,placeholder:`Search entities…`,disabled:o===null})})]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,G.jsx)(Mb,{action:e,objectId:o?.id??``,entityId:f?.id??``,pluginApiName:t,configArgs:n,disabled:!w},e.api_name))},w?`${o.id}-${f.id}`:`no-selection`)]})},Pb=({adornment:e,objectId:t,entityId:n,pluginApiName:r,fieldValue:i,configArgs:a,disabled:o})=>{let[s,{pending:c}]=rb({objectId:t,entityId:n,onError:t=>{console.error(`[data-adornment] ${e.field_type}:`,t)}}),l={id:e.config.tooltip||e.field_type,api_name:e.field_type,plugin_api_name:r};return(0,G.jsxs)(`button`,{onClick:()=>{let r={value:i,fieldId:``,fieldType:e.field_type,objectId:t,entityId:n,...a};s(e.script,r,l)},disabled:o===!0||c,className:`relative flex flex-col items-start rounded border border-black/8 bg-white px-3 py-1.5 text-left transition-colors hover:bg-black/5 disabled:opacity-50`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[12px] text-neutral-800`,children:[e.config.color&&(0,G.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.config.color}}),e.config.tooltip||e.field_type]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-neutral-400`,children:e.field_type}),c&&(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center rounded bg-white/70`,children:(0,G.jsx)(C,{icon:d,spin:!0,className:`text-[11px] text-neutral-400`})})]})},Fb=({adornments:e,pluginApiName:t,configArgs:n})=>{let r=zu(),{apiKey:i,businessId:a}=Iu(),[o,s]=(0,W.useState)(()=>{try{let e=localStorage.getItem(`kizen-sandbox:${t}:selectedObject`);return e?JSON.parse(e):null}catch{return null}}),[c,l]=(0,W.useState)(()=>o?.name??``),[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(()=>{try{let e=localStorage.getItem(`kizen-sandbox:${t}:selectedEntity`);return e?JSON.parse(e):null}catch{return null}}),[m,h]=(0,W.useState)(()=>f?.label??``),[g,_]=(0,W.useState)(``),[v,y]=(0,W.useState)({}),b=(0,W.useRef)(null);(0,W.useEffect)(()=>(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{d(c)},300),()=>{b.current&&clearTimeout(b.current)}),[c]);let x=(0,W.useRef)(null);(0,W.useEffect)(()=>(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{_(m)},300),()=>{x.current&&clearTimeout(x.current)}),[m]),(0,W.useEffect)(()=>{o?localStorage.setItem(`kizen-sandbox:${t}:selectedObject`,JSON.stringify(o)):localStorage.removeItem(`kizen-sandbox:${t}:selectedObject`)},[o,t]),(0,W.useEffect)(()=>{f?localStorage.setItem(`kizen-sandbox:${t}:selectedEntity`,JSON.stringify(f)):localStorage.removeItem(`kizen-sandbox:${t}:selectedEntity`)},[f,t]);let S=ju({queryKey:[`custom-objects`,a,u],queryFn:async()=>{let e=new URLSearchParams({page_size:`20`});return u&&e.set(`search`,u),await(await r(`/custom-objects?${e.toString()}`)).json()},enabled:i!==``&&u.length>=1,staleTime:3e4}),C=ju({queryKey:[`entity-records`,o?.id,g],queryFn:async()=>{let e=new URLSearchParams({page_size:`20`});return g&&e.set(`search`,g),await(await r(`/records/${o?.id??``}/search?${e.toString()}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`})).json()},enabled:i!==``&&o!==null,staleTime:3e4}),w=S.data?.results.map(e=>({id:e.id,label:e.object_name}))??[],T=C.data?.results.map(e=>{let t=Object.values(e.fields).find(e=>e.name===`display_name`)?.value,n=typeof t==`string`?t:e.id;return{id:e.id,label:n}})??[];if(!i)return(0,G.jsx)(`p`,{className:`mt-1 text-[12px] text-neutral-400`,children:`Configure API credentials in Dev Tools to use data adornments.`});let E=o!==null&&f!==null,D=e.reduce((e,t)=>{let n=t.field_type;return e[n]??=[],e[n].push(t),e},{});return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 p-2`,children:[(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(`div`,{className:`flex-1`,children:(0,G.jsx)(jb,{label:`Custom Object`,value:c,onChange:e=>{l(e),o&&(s(null),p(null),h(``))},onSelect:(e,t)=>{s({id:e,name:t}),l(t),p(null),h(``)},options:w,loading:S.isFetching,placeholder:`Search custom objects…`})}),(0,G.jsx)(`div`,{className:`flex-1`,children:(0,G.jsx)(jb,{label:`Entity`,value:m,onChange:e=>{h(e),f&&p(null)},onSelect:(e,t)=>{p({id:e,label:t}),h(t)},options:T,loading:C.isFetching,placeholder:`Search entities…`,disabled:o===null})})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-3`,children:Object.entries(D).map(([e,r])=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:e}),(0,G.jsx)(`input`,{type:`text`,className:`w-full rounded border border-black/10 bg-white px-2.5 py-1.5 font-mono text-[12px] text-neutral-800 focus:border-neutral-400 focus:outline-none`,placeholder:`${e} value…`,value:v[e]??``,onChange:t=>{y(n=>({...n,[e]:t.target.value}))}}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map((r,i)=>(0,G.jsx)(Pb,{adornment:r,objectId:o?.id??``,entityId:f?.id??``,pluginApiName:t,fieldValue:v[e]??``,configArgs:n,disabled:!E},i))})]},e))},E?`${o.id}-${f.id}`:`no-selection`)]})},Ib=({page:e,isActive:t})=>{let{scriptUIRef:n,outputUIRef:r,scopedCss:i,sanitizedHtml:a,interactableScriptRef:o,iframeURL:s,pending:c}=ob(e);return(0,G.jsxs)(`div`,{style:{display:t?`block`:`none`},className:`relative h-full w-full`,children:[c&&(0,G.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-white/80 font-mono text-[11px] text-neutral-400`,children:`loading…`}),e.type===`script`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{ref:n,className:`h-full w-full p-3`}),(0,G.jsx)(`style`,{children:i})]}),e.type===`html`&&(0,G.jsxs)(`div`,{ref:o,className:`overflow-auto p-3`,children:[a&&(0,G.jsx)(`div`,{dangerouslySetInnerHTML:{__html:a}}),(0,G.jsx)(`div`,{ref:r}),(0,G.jsx)(`style`,{children:i})]}),e.type===`iframe`&&s&&(0,G.jsx)(`iframe`,{src:s,className:`h-full w-full border-0`,title:e.name})]})},Lb=`integration:route-change`;function Rb(e,t){return e.find(e=>e.api_name===t||t.endsWith(`${e.plugin_api_name}/${e.api_name}`))}function zb(e){try{let t=new URL(e);return t.hostname===``?t.pathname.split(`/`).filter(Boolean).pop()??e:t.hostname}catch{return e.split(`/`).filter(Boolean).pop()??e}}var Bb=(0,W.forwardRef)(({pages:e},t)=>{let[n,r]=(0,W.useState)(`home`),[i,a]=(0,W.useState)({entries:[``],index:0}),[o,s]=(0,W.useState)([]),[c,l]=(0,W.useState)({}),u=(0,W.useRef)(0),d=i.entries[i.index]??``,f=n===`home`?d:n,p=(0,W.useRef)(!0);(0,W.useEffect)(()=>{if(p.current){p.current=!1;return}let e=`/${f}`;window.dispatchEvent(new CustomEvent(Lb,{detail:{location:{host:window.location.host,origin:window.location.origin,port:window.location.port,protocol:window.location.protocol,pathname:e,search:``,hash:``,href:`${window.location.origin}${e}`}}}))},[f]);let m=n===`home`&&i.index>0,h=n===`home`&&i.index<i.entries.length-1,g=(0,W.useCallback)((t,n)=>{let i=t.replace(/^\/+/,``),o=Rb(e,i);o?(r(o.api_name),l(e=>({...e,[o.api_name]:(e[o.api_name]??0)+1}))):(r(`home`),a(e=>{if(!n?.replace&&e.entries[e.index]===i)return e;if(n?.replace){let t=[...e.entries];return t[e.index]=i,{entries:t,index:e.index}}let t=[...e.entries.slice(0,e.index+1),i];return{entries:t,index:t.length-1}}))},[e]),_=(0,W.useCallback)(t=>{let n=Rb(e,t.replace(/^\/+/,``));if(n){r(n.api_name),l(e=>({...e,[n.api_name]:(e[n.api_name]??0)+1}));return}u.current+=1;let i=`__tab_${String(u.current)}`;s(e=>[...e,{id:i,url:t,title:zb(t)}]),r(i)},[e]),v=(0,W.useCallback)(e=>{s(t=>t.filter(t=>t.id!==e)),n===e&&r(`home`)},[n]);(0,W.useImperativeHandle)(t,()=>({navigate:g,openNewTab:_}),[g,_]);let y=o.find(e=>e.id===n)??null;return(0,G.jsxs)(`div`,{className:`mt-1.5 overflow-hidden rounded border border-black/10 bg-white`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/8 bg-neutral-50 px-3 py-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full bg-red-400/60`}),(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full bg-yellow-400/60`}),(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full bg-green-400/60`})]}),(0,G.jsx)(`button`,{onClick:()=>{a(e=>({...e,index:e.index-1}))},disabled:!m,className:`px-0.5 font-mono text-[15px] leading-none transition-colors ${m?`text-neutral-600 hover:text-neutral-900`:`cursor-default text-neutral-300`}`,children:`‹`}),(0,G.jsx)(`button`,{onClick:()=>{a(e=>({...e,index:e.index+1}))},disabled:!h,className:`px-0.5 font-mono text-[15px] leading-none transition-colors ${h?`text-neutral-600 hover:text-neutral-900`:`cursor-default text-neutral-300`}`,children:`›`}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 truncate rounded border border-black/8 bg-white px-2 py-0.5 font-mono text-[11px] text-neutral-400`,children:y?y.url:`app://sandbox/${f}`})]}),(0,G.jsxs)(`div`,{className:`flex border-b border-black/8 bg-neutral-50`,children:[(0,G.jsx)(`button`,{onClick:()=>{r(`home`)},className:`border-r border-black/8 px-3 py-1.5 font-mono text-[11px] transition-colors ${n===`home`?`bg-white font-medium text-neutral-900`:`text-neutral-500 hover:bg-black/5`}`,children:`home`}),e.map(e=>(0,G.jsxs)(`button`,{onClick:()=>{r(e.api_name)},className:`border-r border-black/8 px-3 py-1.5 font-mono text-[11px] transition-colors ${n===e.api_name?`bg-white font-medium text-neutral-900`:`text-neutral-500 hover:bg-black/5`}`,children:[e.toolbar_icon&&(Lg[e.toolbar_icon]?(0,G.jsx)(C,{icon:Lg[e.toolbar_icon],className:`mr-1 text-[10px] text-neutral-400`}):(0,G.jsx)(`span`,{className:`mr-1 rounded px-1 font-mono text-[9px] ${Rg.has(e.toolbar_icon)||Ig.has(e.toolbar_icon)?`bg-neutral-100 text-neutral-400`:`bg-amber-100 text-amber-600`}`,children:e.toolbar_icon})),e.name]},e.api_name)),o.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center border-r border-black/8 ${n===e.id?`bg-white`:`hover:bg-black/5`}`,children:[(0,G.jsx)(`button`,{onClick:()=>{r(e.id)},className:`py-1.5 pl-3 pr-1 font-mono text-[11px] transition-colors ${n===e.id?`font-medium text-neutral-900`:`text-neutral-500`}`,children:e.title}),(0,G.jsx)(`button`,{onClick:()=>{v(e.id)},className:`px-1.5 py-1.5 font-mono text-[11px] text-neutral-300 transition-colors hover:text-neutral-600`,children:`×`})]},e.id))]}),(0,G.jsxs)(`div`,{className:`min-h-[600px]`,children:[n===`home`&&d===``&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 p-6 font-mono text-[11px]`,children:[(0,G.jsx)(`div`,{className:`text-neutral-400`,children:`app://sandbox/`}),(0,G.jsx)(`div`,{className:`mt-1 text-[13px] font-medium text-neutral-700`,children:`App Homepage`}),(0,G.jsx)(`div`,{className:`text-neutral-400`,children:`This is the index page of your app. Navigate to a routable page using the tabs above.`})]}),n===`home`&&d!==``&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 p-6 font-mono text-[11px]`,children:[(0,G.jsxs)(`div`,{className:`text-neutral-400`,children:[`app://sandbox/`,d]}),(0,G.jsx)(`div`,{className:`mt-1 text-[13px] font-medium text-neutral-500`,children:`Page not found`}),(0,G.jsxs)(`div`,{className:`text-neutral-400`,children:[`No routable page with api_name`,` `,(0,G.jsx)(`code`,{className:`rounded bg-neutral-100 px-1`,children:d}),` is defined in this plugin.`]})]}),e.map(e=>(0,G.jsx)(Ib,{page:e,isActive:n===e.api_name},`${e.api_name}-${String(c[e.api_name]??0)}`)),o.map(e=>(0,G.jsx)(`div`,{style:{display:n===e.id?`block`:`none`},className:`h-full w-full`,children:/^https?:\/\//i.test(e.url)?(0,G.jsx)(`iframe`,{src:e.url,className:`h-full w-full border-0`,title:e.title}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 p-6 font-mono text-[11px]`,children:[(0,G.jsx)(`div`,{className:`text-neutral-400`,children:e.url}),(0,G.jsx)(`div`,{className:`mt-1 text-[13px] font-medium text-neutral-500`,children:`Page not found`}),(0,G.jsxs)(`div`,{className:`text-neutral-400`,children:[`No routable page with path`,` `,(0,G.jsx)(`code`,{className:`rounded bg-neutral-100 px-1`,children:e.url}),` is defined in this plugin.`]})]})},e.id))]})]})});Bb.displayName=`RoutablePageBrowser`;var Vb=({item:e})=>{let[t,{pending:n}]=nb({onError:t=>{console.error(`[toolbar] ${e.api_name}:`,t)},plugin:e});return(0,G.jsxs)(`button`,{onClick:()=>void t(e.script,e.args),disabled:n,className:`relative flex items-center gap-1.5 rounded border border-black/8 bg-white px-3 py-1.5 font-mono text-[12px] text-neutral-800 transition-colors hover:bg-black/5 disabled:opacity-50`,children:[e.color&&(0,G.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),e.icon&&(Lg[e.icon]?(0,G.jsx)(C,{icon:Lg[e.icon],className:`text-[12px] text-neutral-500`}):(0,G.jsx)(`span`,{className:`rounded px-1 font-mono text-[10px] ${Rg.has(e.icon)||Ig.has(e.icon)?`bg-neutral-100 text-neutral-400`:`bg-amber-100 text-amber-600`}`,children:e.icon})),(0,G.jsx)(`span`,{children:e.label}),n&&(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center rounded bg-white/70`,children:(0,G.jsx)(C,{icon:d,spin:!0,className:`text-[11px] text-neutral-400`})})]})},Hb=({item:e,objectId:t,pluginApiName:n,configArgs:r,disabled:i})=>{let[a,{pending:o}]=rb({objectId:t,entityId:``,onError:t=>{console.error(`[object-settings] ${e.api_name}:`,t)}}),s={id:e.api_name,api_name:e.api_name,plugin_api_name:n};return(0,G.jsxs)(`button`,{onClick:()=>{a(e.script,r,s)},disabled:i===!0||o,className:`relative flex flex-col items-start rounded border border-black/8 bg-white px-3 py-1.5 text-left transition-colors hover:bg-black/5 disabled:opacity-50`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[12px] text-neutral-800`,children:e.label}),e.when&&(0,G.jsxs)(`span`,{className:`font-mono text-[10px] text-neutral-400`,children:[`when: `,e.when]}),o&&(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center rounded bg-white/70`,children:(0,G.jsx)(C,{icon:d,spin:!0,className:`text-[11px] text-neutral-400`})})]})},Ub=({items:e,pluginApiName:t,configArgs:n})=>{let r=zu(),{apiKey:i,businessId:a}=Iu(),o=`kizen-sandbox:${t}:objectSettings:selectedObject`,[s,c]=(0,W.useState)(()=>{try{let e=localStorage.getItem(o);return e?JSON.parse(e):null}catch{return null}}),[l,u]=(0,W.useState)(()=>s?.name??``),[d,f]=(0,W.useState)(``),p=(0,W.useRef)(null);(0,W.useEffect)(()=>(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{f(l)},300),()=>{p.current&&clearTimeout(p.current)}),[l]),(0,W.useEffect)(()=>{s?localStorage.setItem(o,JSON.stringify(s)):localStorage.removeItem(o)},[s,o]);let m=ju({queryKey:[`custom-objects`,a,d],queryFn:async()=>{let e=new URLSearchParams({page_size:`20`});return d&&e.set(`search`,d),await(await r(`/custom-objects?${e.toString()}`)).json()},enabled:i!==``&&d.length>=1,staleTime:3e4}),h=m.data?.results.map(e=>({id:e.id,label:e.object_name}))??[];return i?(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 p-2`,children:[(0,G.jsx)(`div`,{className:`w-64`,children:(0,G.jsx)(jb,{label:`Custom Object`,value:l,onChange:e=>{u(e),s&&c(null)},onSelect:(e,t)=>{c({id:e,name:t}),u(t)},options:h,loading:m.isFetching,placeholder:`Search custom objects…`})}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,G.jsx)(Hb,{item:e,objectId:s?.id??``,pluginApiName:t,configArgs:n,disabled:s===null},e.api_name))},s?.id??`no-selection`)]}):(0,G.jsx)(`p`,{className:`mt-1 text-[12px] text-neutral-400`,children:`Configure API credentials in Dev Tools to use object settings menu items.`})},Wb=`h-8 rounded border border-black/10 bg-white px-2.5 font-mono text-[12px] text-neutral-800 focus:border-neutral-400 focus:outline-none w-full`,Gb=`block text-[11px] font-semibold uppercase tracking-widest text-neutral-500 mb-1`,Kb=e=>e===`GET`?`bg-green-50 text-green-700`:e===`DELETE`?`bg-red-50 text-red-700`:e===`POST`?`bg-blue-50 text-blue-700`:`bg-amber-50 text-amber-700`;function qb(e,t){try{let n=localStorage.getItem(`kizen-sandbox:${e}:service:${t}:requestHistory`);return n?JSON.parse(n):[]}catch{return[]}}function Jb(e,t,n,r){let i=n.path===``||n.path.startsWith(`/`)?n.path:`/${n.path}`,a=`${n.method}:${i}`,o=r.filter(e=>`${e.method}:${e.path}`!==a),s=[{...n,path:i,id:String(Date.now())},...o].slice(0,10);try{localStorage.setItem(`kizen-sandbox:${e}:service:${t}:requestHistory`,JSON.stringify(s))}catch{}return s}var Yb=({response:e})=>{let{status:t,elapsedMs:n,contentType:r,body:i}=e,a=t===0?`bg-neutral-100 text-neutral-500`:t<300?`bg-green-50 text-green-700`:t<400?`bg-yellow-50 text-yellow-700`:`bg-red-50 text-red-700`,o=i;if(r.includes(`application/json`))try{o=JSON.stringify(JSON.parse(i),null,2)}catch{}return(0,G.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`rounded px-2 py-0.5 text-[11px] font-semibold ${a}`,children:t===0?`Error`:t}),n>0&&(0,G.jsxs)(`span`,{className:`rounded bg-neutral-100 px-2 py-0.5 text-[11px] text-neutral-500`,children:[n,`ms`]})]}),(0,G.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-black/5 bg-neutral-50 p-3 font-mono text-[11px] leading-relaxed text-neutral-700 whitespace-pre-wrap break-all`,children:o||`(empty response)`})]})},Xb=({headers:e,onChange:t})=>{let n=()=>{t([...e,{id:String(Date.now()),key:``,value:``}])},r=n=>{t(e.filter(e=>e.id!==n))},i=(n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`label`,{className:Gb,children:`Custom Headers`}),e.length>0&&(0,G.jsx)(`div`,{className:`grid grid-cols-[1fr_1fr_auto] gap-1 mb-1`,children:e.map(e=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`input`,{className:Wb,placeholder:`Header name`,value:e.key,onChange:t=>{i(e.id,`key`,t.target.value)}},`${e.id}-key`),(0,G.jsx)(`input`,{className:Wb,placeholder:`Value`,value:e.value,onChange:t=>{i(e.id,`value`,t.target.value)}},`${e.id}-val`),(0,G.jsx)(`button`,{type:`button`,className:`px-1.5 text-neutral-400 hover:text-red-500`,onClick:()=>{r(e.id)},children:(0,G.jsx)(C,{icon:o,className:`text-[11px]`})},`${e.id}-rm`)]}))}),(0,G.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-[11px] text-neutral-400 hover:text-neutral-700 self-start`,onClick:n,children:[(0,G.jsx)(C,{icon:l,className:`text-[10px]`}),`Add header`]})]})},Zb=({service:e,pluginApiName:t})=>{let n=zu(),{environment:r}=Iu(),i=Lu[r],[a,o]=(0,W.useState)(`GET`),[s,l]=(0,W.useState)(``),[u,p]=(0,W.useState)([]),[m,h]=(0,W.useState)(``),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)(()=>qb(t,e.service_name)),[S,w]=(0,W.useState)(!1),T=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!S)return;let e=e=>{T.current&&!T.current.contains(e.target)&&w(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[S]);let E=[`POST`,`PUT`,`PATCH`].includes(a),D=s===``||s.startsWith(`/`)?s:`/${s}`,O=`/external-integrations/proxy/${t}/${e.service_name}${D||`/`}`,k=`${i}${O}`,A=e=>{o(e.method),l(e.path),p(e.headers),h(e.body),w(!1)},j=()=>{localStorage.removeItem(`kizen-sandbox:${t}:service:${e.service_name}:requestHistory`),x([]),w(!1)},M=async()=>{if(!g){x(Jb(t,e.service_name,{method:a,path:s,headers:u,body:m},b)),_(!0),y(null);try{let e=Object.fromEntries(u.filter(e=>e.key.trim()).map(e=>[e.key.trim(),e.value])),t=performance.now(),r=await n(O,{method:a,headers:{...E&&m.trim()?{"Content-Type":`application/json`}:{},...e},...E&&m.trim()?{body:m}:{}}),i=Math.round(performance.now()-t),o=r.headers.get(`content-type`)??``,s=await r.text();y({status:r.status,elapsedMs:i,contentType:o,body:s})}catch(e){y({status:0,elapsedMs:0,contentType:``,body:String(e)})}finally{_(!1)}}};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 shrink-0`,children:[(0,G.jsx)(`label`,{className:Gb,children:`Method`}),(0,G.jsx)(`select`,{className:`h-8 w-28 rounded border border-black/10 bg-white px-2 font-mono text-[12px] text-neutral-800 focus:border-neutral-400 focus:outline-none`,value:a,onChange:e=>{o(e.target.value)},children:[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`].map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{className:`relative flex flex-col gap-1 flex-1 min-w-0`,ref:T,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`label`,{className:Gb,children:`Path`}),b.length>0&&(0,G.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-[11px] text-neutral-400 hover:text-neutral-700`,onClick:()=>{w(e=>!e)},title:`Request history`,children:[(0,G.jsx)(C,{icon:f,className:`text-[10px]`}),(0,G.jsx)(`span`,{children:b.length})]})]}),(0,G.jsx)(`input`,{className:Wb,placeholder:`/path/to/endpoint`,value:s,onChange:e=>{l(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&M()}}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-neutral-400 truncate`,children:k}),S&&b.length>0&&(0,G.jsxs)(`div`,{className:`absolute left-0 top-full z-10 mt-1 w-full rounded border border-black/10 bg-white shadow-lg`,children:[(0,G.jsx)(`ul`,{className:`max-h-48 overflow-auto`,children:b.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-neutral-50`,onMouseDown:e=>{e.preventDefault()},onClick:()=>{A(e)},children:[(0,G.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold ${Kb(e.method)}`,children:e.method}),(0,G.jsx)(`span`,{className:`flex-1 truncate font-mono text-[11px] text-neutral-700`,children:e.path||`/`}),e.headers.filter(e=>e.key.trim()).length>0&&(0,G.jsxs)(`span`,{className:`shrink-0 text-[10px] text-neutral-400`,children:[e.headers.filter(e=>e.key.trim()).length,`h`]}),e.body.trim()&&(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] text-neutral-400`,children:`body`})]})},e.id))}),(0,G.jsx)(`div`,{className:`border-t border-black/5 px-3 py-1.5 text-right`,children:(0,G.jsx)(`button`,{type:`button`,className:`text-[11px] text-neutral-400 hover:text-neutral-700`,onClick:j,children:`clear history`})})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 shrink-0`,children:[(0,G.jsx)(`span`,{className:`invisible ${Gb}`,children:`\xA0`}),(0,G.jsxs)(`button`,{type:`button`,disabled:g,className:`h-8 flex items-center gap-1.5 rounded bg-neutral-800 px-3 text-[12px] font-medium text-white hover:bg-neutral-700 disabled:opacity-50`,onClick:()=>{M()},children:[g?(0,G.jsx)(C,{icon:d,className:`animate-spin text-[11px]`}):(0,G.jsx)(C,{icon:c,className:`text-[11px]`}),`Send`]})]})]}),(0,G.jsx)(Xb,{headers:u,onChange:p}),E&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`label`,{className:Gb,children:`Request Body`}),(0,G.jsx)(`textarea`,{className:`rounded border border-black/10 bg-white px-2.5 py-1.5 font-mono text-[12px] text-neutral-800 focus:border-neutral-400 focus:outline-none w-full resize-y`,rows:5,placeholder:`{"key": "value"}`,value:m,onChange:e=>{h(e.target.value)}})]}),v!==null&&(0,G.jsx)(Yb,{response:v})]})},Qb=e=>e===`oauth`?`rounded bg-blue-50 px-1.5 py-0.5 text-[11px] font-mono text-blue-700`:e===`no_auth`?`rounded bg-neutral-100 px-1.5 py-0.5 text-[11px] font-mono text-neutral-500`:`rounded bg-amber-50 px-1.5 py-0.5 text-[11px] font-mono text-amber-700`,$b=({label:e,children:t})=>(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 text-[12px]`,children:[(0,G.jsx)(`span`,{className:`w-28 shrink-0 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:e}),t]}),ex=({service:e})=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5 pb-4 mb-4 border-b border-black/5`,children:[(0,G.jsxs)($b,{label:`Name`,children:[(0,G.jsx)(`span`,{className:`text-neutral-800 font-medium`,children:e.display_name}),(0,G.jsx)(`span`,{className:`rounded bg-neutral-100 px-1.5 py-0.5 font-mono text-[11px] text-neutral-500`,children:e.service_name})]}),(0,G.jsxs)($b,{label:`Auth`,children:[(0,G.jsx)(`span`,{className:Qb(e.auth_type),children:e.auth_type}),e.auth_level&&(0,G.jsx)(`span`,{className:`text-[11px] text-neutral-400`,children:e.auth_level})]}),(0,G.jsx)($b,{label:`Base URL`,children:(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-600 break-all`,children:e.base_service_url||(0,G.jsx)(`em`,{className:`text-neutral-400`,children:`none`})})}),e.auth_credentials?.scopes&&(0,G.jsx)($b,{label:`Scopes`,children:(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-600 break-all leading-relaxed`,children:e.auth_credentials.scopes})}),e.auth_credentials?.authorize_url&&(0,G.jsx)($b,{label:`Auth URL`,children:(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-600 break-all`,children:e.auth_credentials.authorize_url})}),e.required_entitlement?(0,G.jsx)($b,{label:`Entitlement`,children:(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-500`,children:e.required_entitlement})}):null]}),tx=({services:e,pluginApiName:t})=>{let n=e.map(e=>e),[r,i]=(0,W.useState)(0),a=n[r]??n[0];return a?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`Services`}),(0,G.jsxs)(J,{className:`mt-2 !p-0 overflow-hidden`,children:[(0,G.jsx)(`div`,{className:`flex border-b border-black/10 overflow-x-auto`,children:n.map((e,t)=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>{i(t)},className:`shrink-0 px-4 py-2.5 text-[12px] font-medium border-b-2 transition-colors ${t===r?`border-neutral-800 text-neutral-900`:`border-transparent text-neutral-400 hover:text-neutral-700`}`,children:e.display_name},e.service_name))}),(0,G.jsxs)(`div`,{className:`p-5 flex flex-col gap-4`,children:[(0,G.jsx)(ex,{service:a}),(0,G.jsx)(Zb,{service:a,pluginApiName:t},a.service_name)]})]})]}):null},nx=e=>e.id??e.key??``,rx=(e,t)=>{let n={},r=e=>{let i=nx(e);if(i)if(e.type===`text`)n[i]={value:t[i]??e.defaultValue??``};else if(e.type===`number`){let r=t[i];n[i]={value:r!==void 0&&r!==``?Number(r):e.default??null}}else if(e.type===`boolean`){let r=t[i];n[i]={value:r===void 0?!!e.default:!!r}}else if(e.type===`select`){let r=t[i]??``;n[i]={value:e.options?.find(e=>e.value===r)??(r?{value:r,label:r}:null)}}else if(e.type===`dropdown`){let r=t[i]??e.defaultValue??``;n[i]={value:e.options?.find(e=>e.value===r)??(r?{value:r,label:r}:null)}}else e.type===`container`&&e.fields?.forEach(r)};return e.forEach(r),n},ix=({label:e,required:t,tooltip:n})=>(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] font-medium text-neutral-500`,children:[e,t&&(0,G.jsx)(`span`,{className:`text-red-500`,children:`*`}),n&&(0,G.jsx)(`span`,{className:`cursor-help rounded-full border border-neutral-300 px-1 text-[10px] text-neutral-400`,title:n,children:`i`})]}),ax=({block:e,values:t,onChange:n})=>{let r=nx(e);return e.type===`description`?(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-700`,children:e.content}):e.type===`spacer`?(0,G.jsx)(`div`,{style:{height:e.height??8}}):e.type===`text`?(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(ix,{label:e.label,required:e.required,tooltip:e.tooltip}),(0,G.jsx)(`input`,{type:`text`,value:t[r]??e.defaultValue??``,placeholder:e.placeholder,onChange:e=>{n(r,e.target.value)},className:`rounded border border-black/10 px-2 py-1.5 font-mono text-[12px] focus:outline-none focus:ring-1 focus:ring-neutral-400`})]}):e.type===`number`?(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(ix,{label:e.label,required:e.required,tooltip:e.tooltip}),(0,G.jsx)(`input`,{type:`number`,value:t[r]??``,placeholder:e.placeholder,onChange:e=>{n(r,e.target.value)},className:`rounded border border-black/10 px-2 py-1.5 font-mono text-[12px] focus:outline-none focus:ring-1 focus:ring-neutral-400`})]}):e.type===`boolean`?(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:t[r]===void 0?!!e.default:!!t[r],onChange:e=>{n(r,e.target.checked)},className:`h-3.5 w-3.5 rounded border-black/20 accent-neutral-800`}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-[12px] text-neutral-700`,children:[e.label,e.required&&(0,G.jsx)(`span`,{className:`text-red-500`,children:`*`}),e.tooltip&&(0,G.jsx)(`span`,{className:`cursor-help rounded-full border border-neutral-300 px-1 text-[10px] text-neutral-400`,title:e.tooltip,children:`i`})]})]}):e.type===`select`||e.type===`dropdown`?(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(ix,{label:e.label,required:e.required,tooltip:e.tooltip}),(0,G.jsxs)(`select`,{value:t[r]??e.defaultValue??``,onChange:e=>{n(r,e.target.value)},className:`rounded border border-black/10 bg-white px-2 py-1.5 font-mono text-[12px] focus:outline-none`,children:[(e.placeholder!=null||!e.required)&&(0,G.jsx)(`option`,{value:``,children:e.placeholder??`—`}),(e.options??[]).map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}):e.type===`container`?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:(e.fields??[]).map(e=>(0,G.jsx)(`div`,{style:{width:e.widthPercent===50?`calc(50% - 6px)`:`100%`},children:(0,G.jsx)(ax,{block:e,values:t,onChange:n})},nx(e)||e.type))}):null},ox={small:`max-w-sm`,medium:`max-w-md`,large:`max-w-2xl`},sx=({show:e,config:t,onConfirm:n,onHide:r})=>{let i=t,a=i.content??[],[o,s]=(0,W.useState)({}),c=(0,W.useCallback)((e,t)=>{s(n=>({...n,[e]:t}))},[]),l=()=>{let e=rx(a,o);s({}),n(e)},u=e=>{s({}),r(e)};if(!e)return null;let d=t.confirmButton?.label??`Confirm`,f=t.cancelButton?.label??`Cancel`;return(0,G.jsx)(`div`,{role:`dialog`,className:`fixed inset-0 z-[99999] flex items-start justify-center overflow-y-auto bg-black/30 px-4 py-12`,onClick:()=>{u(`close`)},children:(0,G.jsxs)(`div`,{className:`w-full ${ox[i.size??`medium`]??ox.medium??``} rounded-lg border border-black/10 bg-white font-mono shadow-xl`,onClick:e=>{e.stopPropagation()},children:[t.title&&(0,G.jsx)(`div`,{className:`border-b border-black/8 px-5 py-3`,children:(0,G.jsx)(`span`,{className:`text-[13px] font-semibold text-neutral-900`,children:t.title})}),a.length>0&&(0,G.jsx)(`div`,{className:`max-h-[60vh] space-y-3 overflow-y-auto px-5 py-4`,children:a.map((e,t)=>(0,G.jsx)(ax,{block:e,values:o,onChange:c},nx(e)||`${e.type}-${String(t)}`))}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-black/8 px-5 py-3`,children:[(0,G.jsx)(`button`,{onClick:()=>{u(`button`)},className:`rounded border border-black/10 px-3 py-1.5 text-[12px] text-neutral-600 transition-colors hover:bg-black/5`,children:f}),(0,G.jsx)(`button`,{onClick:l,className:`rounded bg-neutral-900 px-3 py-1.5 text-[12px] text-white transition-colors hover:bg-neutral-700`,children:d})]})]})})},cx=`kizen-plugin-config:`;function lx(e){return`${cx}${e}`}function ux(e){try{let t=localStorage.getItem(lx(e));return t?JSON.parse(t):null}catch{return null}}function dx(e,t,n){let r={__kizen_setup_assistant_values:t,__kizen_clean_config:Sy(n,t)};localStorage.setItem(lx(e),JSON.stringify(r))}function fx(e,t){let n={__kizen_setup_assistant_values:{},__kizen_clean_config:t};localStorage.setItem(lx(e),JSON.stringify(n))}function px(e){localStorage.removeItem(lx(e))}var mx=56,hx=({showingToast:e,browserRef:t})=>{let{apiName:n}=Sc({strict:!1}),r=ad(),[i,a]=(0,W.useState)(()=>localStorage.getItem(`frames-enabled`)===`true`),o=e=>{a(e),localStorage.setItem(`frames-enabled`,String(e))},{data:s,isLoading:c,isError:l}=ju(Nu),u=(0,W.useMemo)(()=>ux(n??``),[n]);if(c)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-400`,children:`Fetching bundle.json…`})});if(l)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-red-700`,children:`Could not load bundle.json.`})});let d=s?.find(e=>e.api_name===n);if(!d)return(0,G.jsx)(J,{children:(0,G.jsxs)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:[`No app found with api_name`,` `,(0,G.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 py-0.5`,children:n}),`.`]})});let f=u?.__kizen_clean_config?{__kizen_clean_config:u.__kizen_clean_config}:{},p=d.artifacts.floating_frames.map(e=>({...e,plugin_api_name:d.api_name,args:f})),m=d.artifacts.toolbar_items.map(e=>({...e,plugin_api_name:d.api_name,args:f})),h=d.artifacts.js_action_templates.map(e=>({...e,plugin_api_name:d.api_name,args:f})),g=d.artifacts.object_settings_menu_items.map(e=>({...e,plugin_api_name:d.api_name,args:f})),_=d.artifacts.data_adornments.map(e=>({...e,plugin_api_name:d.api_name,args:f})),v=d.artifacts.routable_pages.map(e=>({...e,plugin_api_name:d.api_name,args:f})),y=m.length>0||h.length>0||g.length>0||_.length>0;return(0,G.jsxs)(G.Fragment,{children:[e&&(0,G.jsx)(`div`,{className:`fixed top-4 left-1/2 -translate-x-1/2 z-20 rounded px-4 py-2 text-sm font-medium ${{success:`bg-green-100 text-green-700`,error:`bg-red-100 text-red-700`,failure:`bg-red-100 text-red-700`,alert:`bg-amber-100 text-amber-700`}[e.variant??`success`]??`bg-green-100 text-green-700`}`,children:e.message}),(0,G.jsxs)(`div`,{style:{paddingRight:p.length>0?mx:0},children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 xl:flex-row xl:items-start`,children:[y&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 xl:flex-1 xl:min-w-0`,children:[m.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`Toolbar Items`}),(0,G.jsx)(`div`,{children:(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2 p-2`,children:m.map(e=>(0,G.jsx)(Vb,{item:e},e.api_name))})})]}),h.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`JS Action Templates`}),(0,G.jsx)(Nb,{actions:h,pluginApiName:d.api_name,configArgs:f})]}),g.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`Object Settings Menu Items`}),(0,G.jsx)(Ub,{items:g,pluginApiName:d.api_name,configArgs:f})]}),_.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`Data Adornments`}),(0,G.jsx)(Fb,{adornments:_,pluginApiName:d.api_name,configArgs:f})]})]}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`Routable Pages`}),(0,G.jsx)(Bb,{ref:t,pages:v})]})]}),(d.services?.length??0)>0&&(0,G.jsx)(tx,{services:d.services??[],pluginApiName:d.api_name})]}),p.length>0&&(0,G.jsxs)(`div`,{className:`pointer-events-none fixed inset-0`,children:[(0,G.jsxs)(`div`,{className:`absolute inset-y-0 flex w-14 flex-col-reverse items-center gap-2 border-l border-black/8 bg-white/60 pb-4 backdrop-blur-sm`,style:{right:r},children:[p.map(e=>(0,G.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,G.jsx)(`div`,{id:`${e.plugin_api_name}-${e.api_name}-trigger-left`}),(0,G.jsx)(`div`,{id:`${e.plugin_api_name}-${e.api_name}-trigger-right`})]},e.api_name)),(0,G.jsx)(`strong`,{className:`text-[9px] uppercase tracking-widest text-neutral-400`,children:`Frames`}),(0,G.jsxs)(`label`,{className:`flex flex-col items-center gap-0.5 cursor-pointer pointer-events-auto`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`h-3 w-3 cursor-pointer accent-neutral-600`,checked:i,onChange:e=>{o(e.target.checked)}}),(0,G.jsxs)(`span`,{className:`text-[8px] uppercase tracking-widest text-neutral-400 text-center leading-tight`,children:[`enable`,(0,G.jsx)(`br`,{}),`frames`]})]})]}),p.map(e=>(0,G.jsx)(Ab,{frame:e,framesEnabled:i},e.api_name))]})]})},gx=()=>{let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(!1),o=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=window.open;return window.open=e=>(o.current?.openNewTab(String(e??``)),null),()=>{window.open=e}},[]),(0,W.useEffect)(()=>{if(!e)return;let n=setTimeout(()=>{t(null)},5e3);return()=>{clearTimeout(n)}},[e]);let s=sd(),c=zu(),{environment:l}=Iu(),u=Lu[l];return s?(0,G.jsx)(_b,{appPath:u,user:{id:s.team.user,crm_client_id:``},business:s.business,clientObject:s.business.client_object?{id:s.business.client_object.id,objectName:s.business.client_object.object_name}:void 0,teamMember:s.team,onNavigate:(e,t)=>{o.current?.navigate(e,t)},performFileUpload:({file:e,id:t,source:n,businessId:r,publicFile:i})=>(console.log(`File upload requested`,{file:e,id:t,source:n,businessId:r,publicFile:i}),new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{t({url:r.result})},r.onerror=n,r.readAsDataURL(e)})),monitoringExceptionHelper:()=>{},performRequest:async(e,t,n,r)=>{let i=n?.headers,a=r instanceof FormData||r instanceof Blob,o=r!=null&&!a?{"Content-Type":`application/json`,...i}:i,s=await c(t,{method:e.toUpperCase(),...r!=null&&{body:a?r:JSON.stringify(r)},...o!=null&&{headers:o}});return s.status===204||s.headers.get(`content-length`)===`0`?{data:{}}:{data:await s.json()}},modal:{showing:n,show:i,showPrompt:()=>{r(!0),a(!0)},onConfirm:()=>{r(!1),a(!1)},onHide:()=>{r(!1),a(!1)}},showToast:({message:e,variant:n})=>{t({message:e,variant:n??`success`})},clearToasts:()=>{t(null)},children:({showPluginModal:t,derivedModalState:n})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(hx,{showingToast:e,browserRef:o}),(0,G.jsx)(sx,{show:t,config:n.config,onConfirm:n.props.onConfirm,onHide:n.props.onHide})]})}):(0,G.jsx)(C,{icon:d,className:`animate-spin text-neutral-400`,size:`2x`})},_x=({field:e,disabled:t=!1})=>{let{state:n,setState:r,evaluateExpression:i,shouldHideField:a,getFieldErrorState:o,registerFieldResetter:s,afterFieldChange:c,disabledKeys:l}=Tb(),u=n[e.key]?.value??e.default??!1,d=u===!0||u===`true`,f=l.includes(e.key)||t,p=(0,W.useCallback)(t=>{r(n=>({...n,[e.key]:{type:`boolean`,value:t}})),c(e.key)},[e.key,r,c]);if((0,W.useEffect)(()=>{s(e.key,()=>{p(void 0)})},[e.key,s,p]),(0,W.useEffect)(()=>{e.when&&i(e.when,e.key)},[e.when,i,e.key]),a(e.key))return null;let m=o(e.key);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>{p(e.target.checked)},disabled:f,className:`h-3.5 w-3.5 cursor-pointer accent-blue-600`}),(0,G.jsxs)(`span`,{className:`text-[13px] ${f?`text-neutral-400`:`text-neutral-700`}`,children:[e.label,e.required&&(0,G.jsx)(`span`,{className:`text-red-500 ml-0.5`,children:`*`})]}),e.tooltip&&(0,G.jsx)(`span`,{className:`text-[11px] text-neutral-400`,title:e.tooltip,children:`?`})]}),m?.showMessage&&m.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:m.message})]})},vx=({field:e,pluginApiName:t,disabled:n=!1})=>{let{evaluateExpression:r,shouldHideField:i}=Tb(),a=e.columns??1;return(0,W.useEffect)(()=>{e.when&&r(e.when,e.key)},[e.when,r,e.key]),i(e.key)?null:(0,G.jsxs)(`div`,{children:[e.label&&(0,G.jsx)(`h3`,{className:`text-[14px] font-semibold text-neutral-800 mb-3 mt-4`,children:e.label}),(0,G.jsx)(`div`,{className:`gap-4`,style:{display:`grid`,gridTemplateColumns:`repeat(${String(a)}, 1fr)`},children:e.fields?.map(e=>(0,G.jsx)(xx,{field:e,pluginApiName:t,disabled:n},e.key))})]})},yx=({field:e})=>e.label?(0,G.jsxs)(`label`,{className:`text-[12px] font-medium text-neutral-600`,children:[e.label,e.required&&(0,G.jsx)(`span`,{className:`text-red-500 ml-0.5`,children:`*`}),e.tooltip&&(0,G.jsx)(`span`,{className:`ml-1 text-neutral-400 cursor-help`,title:e.tooltip,children:`?`})]}):null,bx={container:vx,custom_object:({field:e,disabled:t=!1})=>{let{state:n,setState:r,getNestedFields:i,reInferFieldsForObject:a,evaluateExpression:o,shouldHideField:s,shouldDisableField:c,getFieldErrorState:l,registerFieldResetter:u,afterFieldChange:d,disabledKeys:f}=Tb(),p=n[e.key]?.value,m=f.includes(e.key)||t,h=c(e.key)||m,[g,_]=(0,W.useState)(p?.objectName??``),[v,y]=(0,W.useState)([]),[b,x]=(0,W.useState)(!1),S=(0,W.useRef)(null),C=zu(),w=(0,W.useCallback)(async e=>{x(!0);try{let t=new URLSearchParams({page_size:`20`});e&&t.set(`search`,e);let n=await(await C(`/custom-objects?${t.toString()}`)).json();y((Array.isArray(n)?n:n.results??[]).map(e=>({id:e.id,label:e.object_name})))}catch{y([])}finally{x(!1)}},[C]),T=(0,W.useCallback)(t=>{_(t),p&&(r(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key))),d(e.key)),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{w(t)},300)},[p,e.key,r,d,w]),E=(0,W.useCallback)((t,n)=>{_(n),r(r=>({...r,[e.key]:{type:`custom_object`,value:{id:t,objectName:n}}}));let o=i().filter(t=>t.object_id?.includes(e.key));for(let e of o)r(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key)));a(e.key),d(e.key)},[e.key,r,i,a,d]);if((0,W.useEffect)(()=>{u(e.key,()=>{r(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key))),_(``)})},[e.key,u,r]),(0,W.useEffect)(()=>{e.when&&o(e.when,e.key)},[e.when,o,e.key]),s(e.key))return null;let D=l(e.key);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(yx,{field:e}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(jb,{value:g,onChange:T,onSelect:E,options:v,loading:b,placeholder:e.placeholder??`Search for an object...`,disabled:h}),p&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{r(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key))),_(``),d(e.key)},disabled:h,className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-neutral-400 hover:text-neutral-600`,"aria-label":`Clear selection`,children:`×`})]}),D?.showMessage&&D.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:D.message})]})},field:({field:e,disabled:t=!1})=>{let{interpolateValue:n,state:r,setState:i,evaluateExpression:a,shouldHideField:o,getFieldErrorState:s,registerFieldResetter:c,afterFieldChange:l,disabledKeys:u}=Tb(),d=u.includes(e.key)||t,f=n(e.object_id??``),[p,m]=(0,W.useState)([]),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(null),x=zu();(0,W.useEffect)(()=>{!f||f===y||o(e.key)||(async()=>{v(!0);try{g((await(await x(`/custom-objects/${f}`)).json()).object_name??``);let e=await(await x(`/custom-objects/${f}/fields`)).json();m((Array.isArray(e)?e:e.results??[]).map(e=>({label:e.display_name,value:e.id}))),b(f)}catch{m([])}finally{v(!1)}})()},[f,y,x,e.key,o]);let S=r[e.key]?.value,C=(0,W.useCallback)(t=>{i(n=>({...n,[e.key]:{type:`field`,value:t,associatedObject:{id:f,name:h}}})),l(e.key)},[e.key,i,f,h,l]);if((0,W.useEffect)(()=>{c(e.key,()=>{i(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key)))})},[e.key,c,i]),(0,W.useEffect)(()=>{e.when&&a(e.when,e.key)},[e.when,a,e.key]),o(e.key))return null;let w=s(e.key),T=!f||d;if(e.allow_multiple){let t=Array.isArray(S)?S:[];return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(yx,{field:e}),(0,G.jsx)(`div`,{className:`rounded border p-2 text-[13px] ${w?.error?`border-red-300`:`border-black/10`} ${T?`bg-neutral-50`:`bg-white`}`,children:_?(0,G.jsx)(`span`,{className:`text-neutral-400 text-[12px]`,children:`Loading fields...`}):f?p.length===0?(0,G.jsx)(`span`,{className:`text-neutral-400 text-[12px]`,children:`No fields available`}):(0,G.jsx)(`div`,{className:`flex flex-col gap-1 max-h-48 overflow-y-auto`,children:p.map(e=>{let n=t.some(t=>t.value===e.value);return(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,disabled:T,onChange:()=>{C(n?t.filter(t=>t.value!==e.value):[...t,e])},className:`h-3 w-3 accent-blue-600`}),(0,G.jsx)(`span`,{className:`text-[12px]`,children:e.label})]},e.value)})}):(0,G.jsx)(`span`,{className:`text-neutral-400 text-[12px]`,children:`Select an object first`})}),w?.showMessage&&w.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:w.message})]})}let E=S&&!Array.isArray(S)?S.value:``;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(yx,{field:e}),_?(0,G.jsx)(`div`,{className:`rounded border border-black/10 px-2 py-1.5 text-[12px] text-neutral-400 bg-neutral-50`,children:`Loading fields...`}):(0,G.jsxs)(`select`,{value:E,onChange:e=>{let t=p.find(t=>t.value===e.target.value);t&&C(t)},disabled:T,className:`rounded border px-2 py-1.5 text-[13px] font-mono focus:outline-none focus:ring-1 ${w?.error?`border-red-300 focus:ring-red-400`:`border-black/10 focus:ring-blue-400`} ${T?`bg-neutral-50 text-neutral-400`:`bg-white`}`,children:[(0,G.jsx)(`option`,{value:``,children:f?`Choose a field`:`Select an object first`}),p.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),w?.showMessage&&w.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:w.message})]})},text:({field:e,disabled:t=!1})=>{let{state:n,setState:r,evaluateExpression:i,shouldHideField:a,getFieldErrorState:o,registerFieldResetter:s,afterFieldChange:c,disabledKeys:l}=Tb(),[u,d]=(0,W.useState)(n[e.key]?.value??e.default??``),f=l.includes(e.key)||t,p=(0,W.useCallback)(t=>{r(n=>({...n,[e.key]:{type:`text`,value:t}})),c(e.key)},[e.key,r,c]);if((0,W.useEffect)(()=>{s(e.key,()=>{d(``),p(``)})},[e.key,s,p]),(0,W.useEffect)(()=>{let e=setTimeout(()=>{p(u)},300);return()=>{clearTimeout(e)}},[u,p]),(0,W.useEffect)(()=>{e.when&&i(e.when,e.key)},[e.when,i,e.key]),a(e.key))return null;let m=o(e.key);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(yx,{field:e}),(0,G.jsx)(`input`,{type:`text`,value:u,onChange:e=>{d(e.target.value)},placeholder:e.placeholder??e.default??`Enter text`,disabled:f,className:`rounded border px-2 py-1.5 text-[13px] font-mono focus:outline-none focus:ring-1 ${m?.error?`border-red-300 focus:ring-red-400`:`border-black/10 focus:ring-blue-400`} ${f?`bg-neutral-50 text-neutral-400`:`bg-white`}`}),m?.showMessage&&m.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:m.message})]})},description:({field:e})=>{let{evaluateExpression:t,shouldHideField:n}=Tb();return(0,W.useEffect)(()=>{e.when&&t(e.when,e.key)},[e.when,t,e.key]),n(e.key)?null:(0,G.jsx)(`div`,{className:`text-[13px] text-neutral-500 leading-relaxed`,children:e.content})},number:({field:e,disabled:t=!1})=>{let{state:n,setState:r,evaluateExpression:i,shouldHideField:a,getFieldErrorState:o,registerFieldResetter:s,afterFieldChange:c,disabledKeys:l}=Tb(),u=n[e.key]?.value??e.default??``,[d,f]=(0,W.useState)(String(u)),p=l.includes(e.key)||t,m=(0,W.useCallback)(t=>{r(n=>({...n,[e.key]:{type:`number`,value:t}})),c(e.key)},[e.key,r,c]);if((0,W.useEffect)(()=>{s(e.key,()=>{f(``),m(``)})},[e.key,s,m]),(0,W.useEffect)(()=>{let e=setTimeout(()=>{m(d)},300);return()=>{clearTimeout(e)}},[d,m]),(0,W.useEffect)(()=>{e.when&&i(e.when,e.key)},[e.when,i,e.key]),a(e.key))return null;let h=o(e.key);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(yx,{field:e}),(0,G.jsx)(`input`,{type:`number`,value:d,onChange:e=>{f(e.target.value)},placeholder:e.placeholder??e.default??`Enter a number`,disabled:p,className:`rounded border px-2 py-1.5 text-[13px] font-mono focus:outline-none focus:ring-1 ${h?.error?`border-red-300 focus:ring-red-400`:`border-black/10 focus:ring-blue-400`} ${p?`bg-neutral-50 text-neutral-400`:`bg-white`}`}),h?.showMessage&&h.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:h.message})]})},select:({field:e,pluginApiName:t,disabled:n=!1})=>{let{state:r,setState:i,evaluateExpression:a,shouldHideField:o,getFieldErrorState:s,inferencePending:c,initialExpressionsPending:l,expressionsIdle:u,afterFieldChange:d,registerFieldResetter:f,disabledKeys:p}=Tb(),m=!c&&!l&&u,[h,g]=(0,W.useState)([]),[_,v]=(0,W.useState)(!1),y=(0,W.useRef)(null),b=!!(e.getFetchUrl??e.optionMapper),x=r[e.key]?.value,S=p.includes(e.key)||n,C=zu(),w=(0,W.useCallback)(t=>{i(n=>({...n,[e.key]:{type:`select`,value:t}})),d(e.key)},[d,e.key,i]);(0,W.useEffect)(()=>{f(e.key,()=>{i(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key)))})},[e.key,f,i]),(0,W.useEffect)(()=>{e.when&&a(e.when,e.key)},[e.when,a,e.key]);let T=(0,W.useMemo)(()=>JSON.stringify(r),[r]);if((0,W.useEffect)(()=>{!b||!m||o(e.key)||y.current===T||(async()=>{v(!0),y.current=T;try{let n={__kizen_state:{value:{...r,pluginApiName:t}}},i;if(e.getFetchUrl){let t=await _y(e.getFetchUrl,n);if(t){let r=e.fetchMethod??`GET`,a={"Content-Type":`application/json`},o=null;if(e.getHeaders&&(a=await yy(e.getHeaders,n)),r===`POST`&&e.getBody){let t=await yy(e.getBody,n);o=JSON.stringify(t)}if(t.startsWith(`/`))i={data:await(await C(t,{method:r,headers:a,...o!=null&&{body:o}})).json()};else{let e=await fetch(t,{method:r,headers:a,...o!=null&&{body:o}});e.ok&&(i=await e.json())}}}if(e.optionMapper){let n=await vy(e.optionMapper,{__kizen_state:{value:{...r,result:i,pluginApiName:t}}});g(structuredClone(n))}else Array.isArray(i)&&g(i)}catch{g([])}finally{v(!1)}})()},[b,m,T,r,e,t,C,o]),o(e.key))return null;let E=s(e.key),D=b?h:e.options??[];if(e.allow_multiple){let t=Array.isArray(x)?x:[];return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(yx,{field:e}),(0,G.jsx)(`div`,{className:`rounded border p-2 text-[13px] ${E?.error?`border-red-300`:`border-black/10`} ${S?`bg-neutral-50`:`bg-white`}`,children:_?(0,G.jsx)(`span`,{className:`text-neutral-400 text-[12px]`,children:`Loading options...`}):D.length===0?(0,G.jsx)(`span`,{className:`text-neutral-400 text-[12px]`,children:`No options available`}):(0,G.jsx)(`div`,{className:`flex flex-col gap-1 max-h-48 overflow-y-auto`,children:D.map(e=>{let n=t.some(t=>t.value===e.value);return(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,disabled:S,onChange:()=>{w(n?t.filter(t=>t.value!==e.value):[...t,e])},className:`h-3 w-3 accent-blue-600`}),(0,G.jsx)(`span`,{className:`text-[12px]`,children:e.label})]},e.value)})})}),E?.showMessage&&E.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:E.message})]})}let O=x&&!Array.isArray(x)?x.value:``;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(yx,{field:e}),_?(0,G.jsx)(`div`,{className:`rounded border border-black/10 px-2 py-1.5 text-[12px] text-neutral-400 bg-neutral-50`,children:`Loading options...`}):(0,G.jsxs)(`select`,{value:O,onChange:e=>{let t=D.find(t=>t.value===e.target.value);t&&w(t)},disabled:S,className:`rounded border px-2 py-1.5 text-[13px] font-mono focus:outline-none focus:ring-1 ${E?.error?`border-red-300 focus:ring-red-400`:`border-black/10 focus:ring-blue-400`} ${S?`bg-neutral-50 text-neutral-400`:`bg-white`}`,children:[(0,G.jsx)(`option`,{value:``,children:e.placeholder??`Choose an option`}),D.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),E?.showMessage&&E.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:E.message})]})},boolean:_x},xx=({field:e,pluginApiName:t,disabled:n=!1})=>{let r=bx[e.type];return(0,G.jsx)(r,{field:e,pluginApiName:t,disabled:n})},Sx=({apiName:e})=>{let t=ux(e),[n,r]=(0,W.useState)(t?.__kizen_clean_config?JSON.stringify(t.__kizen_clean_config,null,2):`{}`),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,G.jsx)(`p`,{className:`text-[13px] text-neutral-500 m-0`,children:`No setup assistant defined. Enter configuration as JSON.`})}),(0,G.jsx)(`textarea`,{value:n,onChange:e=>{r(e.target.value),a(null),s(!1)},spellCheck:!1,className:`w-full min-h-[300px] rounded border p-3 text-[13px] font-mono leading-relaxed focus:outline-none focus:ring-1 ${i?`border-red-300 focus:ring-red-400`:`border-black/10 focus:ring-blue-400`}`}),i&&(0,G.jsxs)(`span`,{className:`text-[12px] text-red-500`,children:[`Parse error: `,i]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>{try{fx(e,JSON.parse(n)),a(null),s(!0),setTimeout(()=>{s(!1)},2e3)}catch(e){a(e instanceof Error?e.message:`Invalid JSON`),s(!1)}},className:`rounded bg-blue-600 px-4 py-1.5 text-[13px] font-medium text-white hover:bg-blue-700 active:bg-blue-800`,children:`Save Configuration`}),(0,G.jsx)(`button`,{onClick:()=>{px(e),r(`{}`),a(null),s(!1)},className:`rounded border border-black/10 px-4 py-1.5 text-[13px] font-medium text-neutral-600 hover:bg-neutral-50 active:bg-neutral-100`,children:`Reset`}),o&&(0,G.jsx)(`span`,{className:`text-[12px] text-green-600 font-medium`,children:`Saved`})]})]})},Cx=({config:e,apiName:t})=>{let n=ux(t)?.__kizen_setup_assistant_values,r=(0,W.useRef)({}),[i,a]=(0,W.useState)(!1),o=zu(),s=(0,W.useCallback)(async e=>{try{let t=await(await o(`/api/custom-objects?filters=${encodeURIComponent(JSON.stringify({api_name:e}))}`)).json();return Array.isArray(t)?t:t.results}catch{return}},[o]),c=(0,W.useCallback)(async e=>{try{let[t,n]=await Promise.all([o(`/api/custom-objects/${e}`),o(`/api/custom-objects/${e}/fields`)]),r=await t.json(),i=await n.json(),a=Array.isArray(i)?i:i.results??[];return{id:e,objectName:r.object_name??``,fields:a.map(e=>({id:e.id,name:e.name,displayName:e.display_name}))}}catch{return{id:e,objectName:``,fields:[]}}},[o]),l=(0,W.useCallback)(e=>{r.current=e},[]);return(0,G.jsx)(wb,{config:e,value:n,onStateChange:l,disabledKeys:[],getObjectByAPIName:s,getCustomObjectDetails:c,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.fields?.map(e=>(0,G.jsx)(xx,{field:e,pluginApiName:t},e.key)),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,G.jsx)(`button`,{onClick:()=>{let n=r.current;dx(t,n,e),a(!0),setTimeout(()=>{a(!1)},2e3)},className:`rounded bg-blue-600 px-4 py-1.5 text-[13px] font-medium text-white hover:bg-blue-700 active:bg-blue-800`,children:`Save Configuration`}),(0,G.jsx)(`button`,{onClick:()=>{px(t),window.location.reload()},className:`rounded border border-black/10 px-4 py-1.5 text-[13px] font-medium text-neutral-600 hover:bg-neutral-50 active:bg-neutral-100`,children:`Reset`}),i&&(0,G.jsx)(`span`,{className:`text-[12px] text-green-600 font-medium`,children:`Saved`})]})]})})},wx=({config:e,apiName:t})=>{let n=sd(),r=zu(),{environment:i}=Iu(),a=Lu[i],[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(!1);return n?(0,G.jsx)(_b,{appPath:a,user:{id:n.team.user,crm_client_id:``},business:n.business,clientObject:n.business.client_object?{id:n.business.client_object.id,objectName:n.business.client_object.object_name}:void 0,teamMember:n.team,onNavigate:()=>{},performFileUpload:()=>Promise.resolve({url:``}),monitoringExceptionHelper:()=>{},performRequest:async(e,t,n,i)=>{let a=n?.headers,o=i instanceof FormData||i instanceof Blob,s=i!=null&&!o?{"Content-Type":`application/json`,...a}:a,c=await r(t,{method:e.toUpperCase(),...i!=null&&{body:o?i:JSON.stringify(i)},...s!=null&&{headers:s}});return c.status===204||c.headers.get(`content-length`)===`0`?{data:{}}:{data:await c.json()}},modal:{showing:o,show:c,showPrompt:()=>{s(!0),l(!0)},onConfirm:()=>{s(!1),l(!1)},onHide:()=>{s(!1),l(!1)}},showToast:()=>{},clearToasts:()=>{},children:()=>(0,G.jsx)(Cx,{config:e,apiName:t})}):(0,G.jsx)(C,{icon:d,className:`animate-spin text-neutral-400`})},Tx=()=>{let{apiName:e}=Sc({strict:!1}),{data:t,isLoading:n,isError:r}=ju(Nu);if(n)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-400`,children:`Fetching bundle.json…`})});if(r)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-red-700`,children:`Could not load bundle.json.`})});let i=t?.find(t=>t.api_name===e);if(!i)return(0,G.jsx)(J,{children:(0,G.jsxs)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:[`No app found with api_name`,` `,(0,G.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 py-0.5`,children:e}),`.`]})});let a=i.base_config?.setup_assistant,o=(a?.fields?.length??0)>0;return(0,G.jsx)(J,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-[15px] font-bold text-neutral-900 m-0`,children:`Configuration`}),(0,G.jsx)(`p`,{className:`text-[12px] text-neutral-400 m-0 mt-1`,children:o?`Configure the setup assistant fields for this plugin app.`:`Enter plugin configuration as JSON.`})]}),o&&a?(0,G.jsx)(wx,{config:a,apiName:e??``}):(0,G.jsx)(Sx,{apiName:e??``})]})})},Ex=()=>{let{apiName:e}=Sc({from:`/$apiName/versions`}),{data:t,isLoading:n,isError:r}=ju(Nu);if(n)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`text-[13px] text-neutral-400`,children:`Loading...`})});if(r||!t)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`text-[13px] text-red-500`,children:`Error loading bundle.`})});let i=t.find(t=>t.api_name===e),a=i?.version??``,o=Array.isArray(i?.allReleaseNotes)?i.allReleaseNotes:[];return o.length===0?(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`text-[13px] text-neutral-400`,children:`No release notes found.`})}):(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:o.map(({version:e,notes:t})=>(0,G.jsxs)(J,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`rounded bg-neutral-100 px-2 py-0.5 text-[11px] font-semibold tracking-wide text-neutral-600`,children:[`v`,e]}),e===a&&(0,G.jsx)(`span`,{className:`rounded bg-green-100 px-2 py-0.5 text-[11px] font-semibold tracking-wide text-green-700`,children:`current`})]}),(0,G.jsx)(`div`,{className:`mb-3 border-t border-black/5`}),(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-[12px] leading-relaxed text-neutral-700`,children:t})]},e))})},Dx=Uc({component:dd}),Ox=Vc({getParentRoute:()=>Dx,path:`/`,component:fd}),kx=Vc({getParentRoute:()=>Dx,path:`/$apiName/summary`,component:Bg}),Ax=Vc({getParentRoute:()=>Dx,path:`/$apiName/sandbox`,component:gx}),jx=Vc({getParentRoute:()=>Dx,path:`/$apiName/configuration`,component:Tx}),Mx=Vc({getParentRoute:()=>Dx,path:`/$apiName/versions`,component:Ex}),Nx=rl({routeTree:Dx.addChildren([Ox,kx,Ax,jx,Mx])}),Px=document.getElementById(`root`),Fx=new mu;if(Px===null)throw Error(`Root element not found`);(0,Mu.createRoot)(Px).render((0,G.jsx)(W.StrictMode,{children:(0,G.jsx)(_u,{client:Fx,children:(0,G.jsx)(ol,{router:Nx})})}));
|
|
17
|
+
`,sanitizedHtml:s,outputUIRef:i,interactableScriptRef:a}},ab=(e,t,n,r,i={})=>{let a=(0,W.useMemo)(()=>t?.event_scripts??{},[t]),o=(0,W.useCallback)(t=>{if(t.preventDefault(),t.stopPropagation(),!r){let n=t.target.getAttribute(`data-script`);n&&a[n]&&e(a[n],{...i})}},[r,e,a,i]);(0,W.useEffect)(()=>{let e=n?.current;return e&&e.addEventListener(`click`,o),()=>{e&&e.removeEventListener(`click`,o)}},[o,t,n])},ob=(e,t,n)=>{let r=e?.iframe_url,i=e?.script,a=e?.callback,o=e?.args,{showToast:s}=eb(),{t:c}=Zy(),l=(0,W.useRef)(null),[u,{pending:d}]=nb({onError:e=>{s({message:`${c(`Plugin error:`)} ${e?.message??``}`,variant:`failure`})},scriptUIRef:l,plugin:e}),f=(0,W.useMemo)(()=>{let e=new URLSearchParams(t);return{...Object.fromEntries(e),...o}},[t,o]),{outputUIRef:p,scopedCss:m,sanitizedHtml:h,interactableScriptRef:g}=ib(e,f);ab(u,e,l,d);let _=(0,W.useRef)(!1);(0,W.useEffect)(()=>{!r&&!_.current&&i&&!n&&(_.current=!0,u(i,f))},[r,u,i,f,n]);let v=(0,W.useCallback)(e=>{let t=e.data;if(t?.type===`kizen:plugin_callback`){let e=t.query;a&&u(a,e)}},[u,a]);return(0,W.useEffect)(()=>(window.addEventListener(`message`,v),()=>{window.removeEventListener(`message`,v)}),[v]),{scriptUIRef:l,outputUIRef:p,scopedCss:m,sanitizedHtml:h,interactableScriptRef:g,iframeURL:r,pending:d}},sb=(0,W.createContext)(null),cb=({children:e})=>{let[t,n]=(0,W.useState)([]),[r,i]=(0,W.useState)(!1),a=(0,W.useCallback)((e,t)=>{n(n=>{let r=[e,...n.filter(t=>t!==e)];return t?.(r),r})},[]),o=(0,W.useMemo)(()=>[...t].reverse().reduce((e,t,n)=>({...e,[t]:n}),{}),[t]);return(0,W.useEffect)(()=>{let e=new MutationObserver(()=>{document.querySelector(`div[role="dialog"]`)?i(!0):i(!1)});return e.observe(document.body,{childList:!0}),()=>{e.disconnect()}},[]),(0,G.jsx)(sb.Provider,{value:{touchFloatingFrame:a,floatingFrameOffset:o},children:e(r)})},lb=()=>{let e=(0,W.useContext)(sb);if(!e)throw Error(`useFloatingFrame must be used within a FloatingFrameWrapper`);return e},ub=[`^/$`,`^/login*`,`/settings/mine$`,`/settings/others$`,`/create-new-business$`,`^/choose-business*`,`^/inactive-business$`,`^/reset$`,`/welcome$`,`/embed/*`,`/create-new-business$`,`/businessbuilder`],db=[`https://js.stripe.com`],fb=(e,t,n,r)=>e<n?t<r?`top-left`:`top-right`:t<r?`bottom-left`:`bottom-right`,pb=e=>{let{currentWindow:t,pathname:n,id:r,frameHeaderSize:i,defaultPositionGap:a=0,viewportHeight:o=window.innerHeight,hiddenByModal:s,updateEmployeeConfig:c}=e,l=(0,W.useRef)(null),u=(0,W.useRef)(!1),{showToast:d}=eb(),{t:f}=Zy(),{installedPluginAPINamesToIds:p,clientObject:m}=My(),{touchFloatingFrame:h,floatingFrameOffset:g}=lb(),_=g[r]??-1,v=t.minimized_style===`none`,y=t.minimized_style===`circle`||v,b=t.default_position===`bottom-right-fixed`,x=t.default_position===`bottom-left-fixed`,S=b||x,C=t.minimized_config?.icon??`action-drag-handle`,w=t.minimized_config?.color??`blue`,T=(0,W.useMemo)(()=>{let e=n.split(`/`),t=e[1],r=e[2];if(t===`client`)return{objectId:m?.id,entityId:r};if(t===`custom-objects`)return{objectId:r,entityId:e[3]}},[m,n]),E=(0,W.useMemo)(()=>{let e=t.match,r=t.ignore;return!!(e?.length&&!e.some(e=>new RegExp(e).test(n))||ub.concat(r??[]).filter(Boolean).some(e=>{try{return new RegExp(e).test(n)}catch{return!1}}))},[t,n]),D=t.plugin_api_name?p[t.plugin_api_name]:``,[O,k]=(0,W.useState)(()=>t.employee_config?.[r]?.minimized??!1),A=t.script,j=t.type,M=t.args,N=t.message_handler,P=t.width??0,[F,I]=(0,W.useState)(()=>{let e=window.innerHeight;return Math.min(t.height??0,e-i)}),[L,R]=(0,W.useState)(null),z=t.default_position,B=(0,W.useCallback)(e=>{let n=t.employee_config?.[r]?.position;if(!n?.quadrant){let t=window.innerWidth-P,r=window.innerHeight-F-i;if(O&&!e&&(r=window.innerHeight-i),n)try{let e=n;return e.left>t&&(e.left=t),e.top>r&&(e.top=r),e.left<0&&(e.left=a),e.top<0&&(e.top=a),e}catch{}let o=t;return z===`bottom-left`&&(o=a),{left:o,top:r-a}}else if(n.quadrant===`top-left`){let e=n.deltas?.left??0,t=n.deltas?.top??0;return{...n,left:e,top:t}}else if(n.quadrant===`top-right`){let e=window.innerWidth-P-(n.deltas?.right??0),t=n.deltas?.top??0;return{...n,left:e,top:t}}else if(n.quadrant===`bottom-left`){let e=n.deltas?.left??0,t=window.innerHeight-(O?0:F)-(n.deltas?.bottom??0)-i;return{...n,left:e,top:t}}else{let e=window.innerWidth-P-(n.deltas?.right??0),t=window.innerHeight-(O?0:F)-(n.deltas?.bottom??0)-i;return{...n,left:e,top:t}}},[t,r,z,O,P,F,i,a]),V=(0,W.useCallback)(e=>{let t=B(e),n=[`bottom-right`,`bottom-left`].includes(t.quadrant??``)&&O?0:F;return t.left<0?t.left=0:t.left>window.innerWidth-P&&(t.left=window.innerWidth-P),t.top<0?t.top=0:t.top>window.innerHeight-n&&(t.top=window.innerHeight-n),t},[B,P,F,O]);(0,W.useEffect)(()=>{let e=t.height??0;if(e>o){I(o-i);let e=B(!0);e.top=0,R(e)}else I(e)},[t.height,B,o,i]);let[ee,te]=(0,W.useState)(O),[H,ne]=(0,W.useState)(O&&y),re=F*5e-4*1e3,ie=e=>{k(e),e&&y?setTimeout(()=>{ne(e)},re):y&&ne(e),s?setTimeout(()=>{te(e)},re):te(e),(L?.quadrant===`bottom-left`||L?.quadrant===`bottom-right`)&&R(e?e=>e?{...e,top:e.top+F}:null:e=>{if(!e)return null;let t=window.innerHeight,n=e.top>=0&&e.top+F<=t;return{...e,top:n?e.top:e.top-F}}),c?.(r,O,L)({minimized:e})},[ae,{pending:oe,hidden:se,indicator:ce,triggerHidden:le,hideHeader:ue}]=tb({onError:e=>{d({message:`${f(`Plugin error:`)} ${e?.message??``}`,variant:`failure`})},scriptUIRef:l,plugin:t,onChangeMinimized:e=>{ie(e)}}),de=(0,W.useMemo)(()=>ue&&S,[ue,S]),fe=(0,W.useMemo)(()=>{if(!L)return`top`;let{left:e,top:t}=L;return window.innerWidth-(e+P)<40?`left`:t<40?`bottom`:`top`},[L,P]),pe=(0,W.useCallback)(()=>{let e=x?`left`:`right`,n=`${t.plugin_api_name}-${t.api_name}-trigger-${e}`;return document.getElementById(n)},[x,t]),me=(0,W.useCallback)(()=>{if(!S)return;let e=pe();if(!e)return;let t=e.getBoundingClientRect(),n=O?0:F,r=de?0:i,o=t.top-(n+r)-a,s=x?t.left:t.right-P,c=n+r,l=Math.max(0,window.innerWidth-P),u=Math.max(0,window.innerHeight-c);s=Math.min(Math.max(0,s),l),o=Math.min(Math.max(0,o),u),R({left:s,top:o,quadrant:x?`bottom-left`:`bottom-right`,deltas:{top:o,left:s,right:window.innerWidth-(s+P),bottom:window.innerHeight-(o+c)}})},[S,x,F,O,P,de,pe,i,a]);(0,W.useEffect)(()=>{S&&me()},[S,F,O,me]),(0,W.useEffect)(()=>{if(!S)return;me();let e=new ResizeObserver(()=>{me()});return e.observe(document.body),()=>{e.disconnect()}},[S,me]),(0,W.useEffect)(()=>{!u.current&&A&&j===`script`&&!E&&(u.current=!0,ae(A,{...M}))},[ae,A,j,M,E]),(0,W.useEffect)(()=>{let e=e=>{let n=e;if(n?.detail?.recipient?.frame===t.api_name){let e=n.detail;if(e.recipient?.plugin!==t.plugin_api_name)return;e.recipient.script&&t.event_scripts?.[e.recipient.script]&&ae(t.event_scripts[e.recipient.script]??``,{...e.args,...M,...T})}};return window.addEventListener(Cy,e),()=>{window.removeEventListener(Cy,e)}},[t,ae,M,T]);let[he,ge]=(0,W.useState)(!1),_e=(e,t)=>{ge(!1),h(r);let n=window.innerWidth,i=window.innerHeight;if(t.node){let e=t.node.getBoundingClientRect(),a=e.left,o=e.top,s=o+e.height,l=a+e.width,u=o,d=i-s,f=a,p=n-l,m={left:a,right:l,top:o,quadrant:fb(u,f,d,p),deltas:{top:u,bottom:d,left:f,right:p}};R(m),c?.(r,O,L)({position:m})}};(0,W.useEffect)(()=>{let e=()=>{S?me():R(V(!1))};return window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[S,me,V]),ab(ae,t,l,oe,M),(0,W.useEffect)(()=>{let e=e=>{e.source!==window&&N&&!db.includes(e.origin)&&ae(N,{...M,eventData:e.data})};return window.addEventListener(`message`,e),()=>{window.removeEventListener(`message`,e)}},[ae,M,N]);let{outputUIRef:ve,scopedCss:ye,sanitizedHtml:be,interactableScriptRef:xe}=ib(t,{}),Se=ee?se||E||s:se||E,Ce=`floating-window-parent--${r}`,we=`floating-drag-handle--${r}`,Te=`floating-window-content--${r}`,Ee=t.employee_config?.[r]?.position?.quadrant?.split(`-`)[1]===`right`?`right`:`left`;x?Ee=`left`:b&&(Ee=`right`);let De=t.minimized_config?.customIcon,Oe=null;return De?.startsWith(`data:image/`)&&(Oe=({className:e=``})=>(0,G.jsx)(`img`,{src:De,alt:t.title||`Open Frame`,className:`object-cover select-none pointer-events-none ${e}`})),L||R(V(!1)),{circleProps:{id:r,side:Ee,circleIcon:C,CustomIcon:Oe,circleColor:w,onClick:()=>{ie(!O)},hidden:!!(Se||E||v||le)},parentProps:{className:Ce,dragging:he,hidden:Se||H||E||v},draggableProps:{onStop:_e,onStart:()=>{ge(!0)},bounds:`.${Ce}`,handle:`.${we}`,defaultPosition:{x:L?.left??0,y:L?.top??0},position:{x:L?.left??0,y:L?.top??0},disabled:S},floatProps:{pending:oe,width:P,dragging:he,height:F,isCircle:y&&O},contentProps:{className:Te,dragging:he,solid:!0},minimized:O,pending:oe,indicator:ce,hideHeader:de,isFixed:S,isCircle:y,outputUIRef:ve,scopedCss:ye,sanitizedHtml:be,interactableScriptRef:xe,tooltipPosition:fe,currentPluginId:D,setMinimized:ie,dragHandleClassName:we,height:F,script:A,dragging:he,frameOffset:_,scriptUIRef:l}},mb=()=>{(0,W.useEffect)(()=>{let e=null,t=t=>{if(!t.detail?.location)return;let n=sy(t.detail.location);n!==e&&(e=n,document.querySelectorAll(`iframe[id^=${Wg}-]`).forEach(e=>{let n=null;try{n=new URL(e.src,window.location.href).origin}catch(e){ay(`script-runner-logging`)&&console.warn(`Failed to parse iframe src for location change message target origin:`,e),n=null}n&&e.contentWindow?.postMessage({action:Ug,location:t.detail?.location},n)}))};return window.addEventListener(Hg,t),()=>{window.removeEventListener(Hg,t)}},[])},hb=new mu,gb=({children:e})=>(0,W.useContext)(hu)?(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsx)(_u,{client:hb,children:e}),_b=e=>{let{children:t,bootstrapPlugins:n=[],userConfigs:r=[],user:i,teamMember:a,business:o,clientObject:s,onNavigate:c,modal:l,monitoringExceptionHelper:u,showToast:d,clearToasts:f,performRequest:p,appPath:m,hideFramesOnModal:h=!0,createFileId:g,performFileUpload:_,t:v}=e;return mb(),(0,G.jsx)(gb,{children:(0,G.jsx)(jy,{bootstrapPlugins:n,userConfigs:r,user:i,teamMember:a,business:o,clientObject:s,appPath:m,children:({hasFinishedBootstrapping:e,waitingOnRouteScript:n})=>(0,G.jsx)(Xy,{t:v,children:(0,G.jsx)(Py,{children:r=>(0,G.jsx)(Uy,{onNavigate:c,children:(0,G.jsx)(Ly,{...l,children:i=>(0,G.jsx)(By,{monitoringExceptionHelper:u,children:(0,G.jsx)(Oy,{children:(0,G.jsx)(Ty,{children:(0,G.jsx)($y,{showToast:d,clearToasts:f,children:(0,G.jsx)(cb,{children:a=>(0,G.jsx)(Ky,{performRequest:p,createFileId:g,performFileUpload:_,children:t({...i,showLoadingIndicator:r,hasFinishedBootstrapping:e,waitingOnRouteScript:n,hiddenByModal:h?a:!1})})})})})})})})})})})})})},vb=(0,W.createContext)(null),yb=vb.Provider,bb=(e,t)=>{if(e===`custom_object`)return t?.id},xb=(e,t)=>{if(e.type===`custom_object`)return e.allow_multiple?(t?.value??[]).length>0:!!t?.value?.id;if(e.type===`field`)return e.allow_multiple?(t?.value??[]).length>0:!!t?.value?.value;if(e.type===`text`)return!!(t?.value??``).trim();if(e.type===`number`){let e=Number(t?.value);return!!t?.value&&!isNaN(e)}else if(e.type===`select`)return e.allow_multiple?(t?.value??[]).length>0:!!t?.value?.value;else if(e.type===`boolean`)return!!t?.value;return!1},Sb=e=>{let t=(e.fields??[]).filter(e=>e.type===`custom_object`),n=(e.fields??[]).filter(e=>e.type===`container`).flatMap(e=>Sb(e)),r=e.actions?.filter(e=>e.hint_object_name)??[];return[...t,...n,...r.map(e=>({...by(e),match_hint:e.hint_object_name??``}))]},Cb=e=>{let t=(e.fields??[]).filter(e=>e.type===`field`),n=(e.fields??[]).filter(e=>e.type===`container`).flatMap(e=>Cb(e));return[...t,...n]},wb=({children:e,config:t,value:n,onStateChange:r,disabledKeys:i,templateAssociationsByActionApiName:a,getObjectByAPIName:o,getCustomObjectDetails:s})=>{let[c,l]=(0,W.useState)(n??{}),u=(0,W.useMemo)(()=>xy(t),[t]),d=(0,W.useMemo)(()=>u.reduce((e,t)=>({...e,[t.key]:{type:t.type,value:t.default}}),{}),[u]),f=(0,W.useMemo)(()=>{let e={...Object.entries(a??{}).reduce((e,[t,n])=>{let r=`action__${t}`,i=n.map(e=>({id:e.custom_object.id??``,objectName:e.custom_object.object_name??`Unknown Object`}));return i.length>0&&n.length>0&&n[0]&&(e[r]={type:`custom_object`,value:i,config:by(n[0].browser_js_action_template)}),e},{}),...c};return i?.forEach(t=>{e[t]&&(e[t]=void 0)}),e},[c,a,i]),p=(0,W.useRef)(!!n),m=(0,W.useRef)({}),[h,g]=(0,W.useState)(!n),[_,v]=(0,W.useState)({}),[y,b]=(0,W.useState)({}),[x,S]=(0,W.useState)(!1),C=(0,W.useRef)(null),[w,T]=(0,W.useState)({}),[E,D]=(0,W.useState)(!1),[O,k]=(0,W.useState)(!0),A=(0,W.useRef)({}),j=(0,W.useCallback)((e,t)=>{A.current[e]=t},[]),M=(0,W.useCallback)(e=>{typeof e==`function`?l(t=>{let n=e(t);return m.current=n,r?.(n),n}):(m.current=e,l(e),r?.(e)),T({})},[r]),N=(0,W.useCallback)((e,t)=>{if(e.startsWith(`{{`)&&e.endsWith(`}}`)){let n=e.slice(2,-2).trim();return bb(t[n]?.type,t[n]?.value)}return e},[]),P=(0,W.useCallback)(e=>N(e,f),[f,N]),{clientObject:F}=My(),I=(0,W.useCallback)(async e=>e===`client_client`&&F?[{id:F.id,object_name:F.objectName}]:await o(e),[F,o]),L=(0,W.useCallback)(async()=>{let e=Sb(t);for(let t of e){if(!t.match_hint)continue;let e=await I(t.match_hint);if(e?.[0]){let n={id:e[0].id,objectName:e[0].object_name};M(e=>({...e,[t.key]:{type:`custom_object`,value:t.allow_multiple?[n]:n}}))}}},[t,M,I]),R=(0,W.useCallback)(()=>Cb(t),[t]),z=(0,W.useCallback)(async(e,t)=>{let n=R(),r={};for(let i of n){if(!i.object_id)continue;let n=t??N(i.object_id,m.current);if(e&&!i.object_id.includes(e))continue;if(!r[n]&&n)try{r[n]=await s(n)}catch{}let a=r[n];if(a){let e=a.fields.find(e=>e.name===i.match_hint);e&&M(t=>({...t,[i.key]:{type:`field`,value:{value:e.id,label:e.displayName},associatedObject:{id:n,name:a.objectName}}}))}}},[N,R,M,s]),B=(0,W.useCallback)(async e=>{let n=Sb(t).find(t=>t.key===e);if(n?.match_hint){let t=``,r=(await I(n.match_hint))?.[0];r&&(t=r.id,M(t=>({...t,[e]:{type:`custom_object`,value:{id:r.id,objectName:r.object_name}}})),t&&z(void 0,t))}},[t,M,z,I]),V=(0,W.useCallback)(async()=>{await L(),await z(),g(!1)},[L,z]),ee=(0,W.useCallback)(()=>Cb(t),[t]),te=(0,W.useCallback)(e=>z(e),[z]),H=(0,W.useCallback)(()=>{C.current&&=(clearTimeout(C.current),null),C.current=setTimeout(()=>{S(!0)},500)},[]),ne=(0,W.useCallback)(async(e,t)=>{H(),v(e=>({...e,[t]:!0})),D(!0);let n=await gy(e,{...d,...f});return b(e=>(e[t]===!1&&typeof n==`boolean`&&n&&(f[t]||B(t)),{...e,[t]:n})),v(e=>({...e,[t]:!1})),n},[f,H,B,d]);p.current||(p.current=!0,V());let re=(0,W.useCallback)(e=>y[e]===!1,[y]),ie=(0,W.useCallback)(e=>_[e]===!0,[_]),ae=(0,W.useCallback)(e=>{if(w[e])return{message:w[e],showMessage:!0,error:!0}},[w]),oe=(0,W.useMemo)(()=>{let e=(t.fields??[]).filter(e=>e.type===`container`).map(e=>e.when),n=u.map(e=>e.when);return[...e,...n].filter(Boolean)},[t,u]),se=(0,W.useMemo)(()=>u.reduce((e,t)=>(e[t.key]=t,e),{}),[u]),ce=(0,W.useCallback)((e,t,n)=>{t.add(e);let r=se[e];r?.dependencies?.length&&r.dependencies.forEach(e=>{n.has(e)||(n.add(e),ce(e,t,n))})},[se]),le=(0,W.useMemo)(()=>u.map(e=>{let t=new Set,n=e.dependencies??[],r=new Set;return n.forEach(e=>{ce(e,t,r)}),{...e,dependencies:Array.from(t)}}),[u,ce]),ue=(0,W.useCallback)(e=>{le.filter(t=>t.dependencies.length===0?!1:t.dependencies.includes(e)&&t.key!==e).forEach(e=>{A.current[e.key]?.()})},[le]),de=(0,W.useCallback)(async()=>{let e=(await Promise.all(u.map(async e=>e.when?await gy(e.when,{...d,...f})?e:null:e))).filter(Boolean),t=0;for(let n of e)n&&n.required&&!xb(n,f[n.key])?(T(e=>({...e,[n.key]:`This field is required`})),t++):n?.validation_pattern?new RegExp(n.validation_pattern).test(f[n.key]?.value??n.default??``)||(T(e=>({...e,[n.key]:`Value must match the pattern ${n.validation_pattern??``}`})),t++):n&&T(e=>({...e,[n.key]:void 0}));return{isValid:t===0,includedKeys:e.map(e=>e?.key).filter(e=>!!e)}},[f,u,d]);(0,W.useEffect)(()=>{H()},[H]);let fe=Object.values(_).filter(Boolean).length;return!E&&oe.length===0&&D(!0),E&&O&&fe===0&&k(!1),(0,G.jsx)(yb,{value:{state:f,setState:M,interpolateValue:P,getNestedFields:ee,reInferFieldsForObject:te,inferencePending:h,evaluateExpression:ne,shouldHideField:re,shouldDisableField:ie,expressionsIdle:x,getFieldErrorState:ae,validateForm:de,waitingExpressionCount:fe,initialExpressionsPending:O,flattenedFields:u,flattenedFieldsByKey:se,afterFieldChange:ue,registerFieldResetter:j,disabledKeys:i??[]},children:e})},Tb=()=>{let e=(0,W.useContext)(vb);if(!e)throw Error(`useSetupAssistant must be used within a SetupAssistantController`);return e},Eb=36,Db=20,Ob=9e3,kb=({frameId:e,side:t,color:n,zIndex:r,onClick:i,CustomIcon:a})=>{let o=document.getElementById(`${e}-trigger-${t}`);return o?(0,Ec.createPortal)((0,G.jsx)(`button`,{className:`pointer-events-auto flex h-10 w-10 items-center justify-center rounded-full border border-black/10 shadow-lg`,style:{backgroundColor:n,zIndex:r},onClick:i,onPointerDown:e=>{e.stopPropagation()},title:`Open frame`,children:a?(0,G.jsx)(a,{className:`h-6 w-6 rounded-full object-cover`}):(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-white`,children:`▲`})}),o):null},Ab=({frame:e,framesEnabled:t})=>{let n=`${e.plugin_api_name}-${e.api_name}`,r=ad(),[i,a]=(0,W.useState)(window.innerHeight);(0,W.useEffect)(()=>{let e=new ResizeObserver(()=>{a(window.innerHeight)});return e.observe(document.body),()=>{e.disconnect()}},[]);let{circleProps:o,parentProps:s,draggableProps:c,pending:l,indicator:u,outputUIRef:d,scopedCss:f,sanitizedHtml:p,interactableScriptRef:m,hideHeader:h,setMinimized:g,dragHandleClassName:_,isFixed:v,isCircle:y,minimized:b,height:x,dragging:S,frameOffset:C,scriptUIRef:w}=pb({currentWindow:e,pathname:`/sandbox`,id:n,frameHeaderSize:Eb,defaultPositionGap:Db,viewportHeight:i,hiddenByModal:!1}),T=Ob+Math.max(0,C),E=`floating-frame-pos-${n}`,D=(()=>{try{let e=localStorage.getItem(E);return e?JSON.parse(e):null}catch{return null}})(),O=(0,W.useRef)(null),[k,A]=(0,W.useState)(D??c.position),j=(0,W.useRef)(D!==null),M=c.position;(0,W.useEffect)(()=>{j.current||A({x:M.x,y:M.y})},[M.x,M.y]);let N=(0,W.useCallback)(e=>{if(c.disabled||!e.target.closest(`.${_}`))return;e.preventDefault(),c.onStart();let t=e.clientX,n=e.clientY,r=k.x,i=k.y,a=e=>{A({x:r+e.clientX-t,y:i+e.clientY-n})},o=e=>{document.removeEventListener(`pointermove`,a),document.removeEventListener(`pointerup`,o);let s={x:r+e.clientX-t,y:i+e.clientY-n};localStorage.setItem(E,JSON.stringify(s)),j.current=!0,c.onStop(e,{node:O.current})};document.addEventListener(`pointermove`,a),document.addEventListener(`pointerup`,o)},[c,_,k,E]);return(0,G.jsxs)(G.Fragment,{children:[y&&!o.hidden&&(0,G.jsx)(kb,{frameId:n,side:o.side,color:o.circleColor,zIndex:T,onClick:o.onClick,CustomIcon:o.CustomIcon}),(0,G.jsxs)(`div`,{ref:O,className:s.className,style:{position:`fixed`,left:Math.min(k.x,window.innerWidth-r-(e.width??300)),top:k.y,width:e.width??300,zIndex:T,borderRadius:6,overflow:`hidden`,border:`1px solid rgba(0,0,0,0.1)`,boxShadow:`0 4px 20px rgba(0,0,0,0.1)`,backgroundColor:`white`,opacity:s.hidden||!t?0:1,pointerEvents:s.hidden||!t?`none`:`auto`},onPointerDown:N,children:[(l||u===`block`)&&(0,G.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-white/80 font-mono text-[11px] text-neutral-400`,children:`loading…`}),!h&&(0,G.jsxs)(`div`,{className:`flex select-none items-center border-b border-black/8`,style:{height:Eb,backgroundColor:e.header_color??`#fafafa`,color:e.header_text_color??`#1a1a1a`},children:[(0,G.jsxs)(`div`,{className:`${_} flex h-full flex-1 items-center gap-2 overflow-hidden px-3 ${v?``:`cursor-grab active:cursor-grabbing`}`,children:[!v&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] opacity-30`,children:`⠿`}),(0,G.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,children:e.title})]}),(0,G.jsx)(`button`,{className:`flex h-full shrink-0 items-center px-3 font-mono text-[11px] transition-colors hover:bg-black/5`,onClick:()=>{g(!b)},onMouseDown:e=>{e.stopPropagation()},onPointerDown:e=>{e.stopPropagation()},title:b?`Expand`:`Collapse`,children:b?`↑`:`↓`})]}),(0,G.jsxs)(`div`,{style:{height:b?0:x,overflow:`hidden`,transition:`height ${String(x*5e-4)}s ease`},children:[e.type===`script`&&(0,G.jsxs)(`div`,{className:`h-full w-full`,style:{pointerEvents:S||s.hidden||!t?`none`:`auto`},children:[(0,G.jsx)(`div`,{className:`h-full w-full`,ref:w}),(0,G.jsx)(`style`,{children:f})]}),e.type===`html`&&p&&(0,G.jsxs)(`div`,{ref:m,className:`overflow-auto bg-white`,style:{height:x,pointerEvents:S||s.hidden||!t?`none`:`auto`},children:[(0,G.jsx)(`div`,{dangerouslySetInnerHTML:{__html:p}}),(0,G.jsx)(`div`,{ref:d}),(0,G.jsx)(`style`,{children:f})]})]})]})]})};function jb(e,t){let n=Object.values(e).find(e=>e.name===t);return typeof n?.value==`string`?n.value:``}function Mb(e,t){if(t){let t=jb(e.fields,`first_name`),n=jb(e.fields,`last_name`),r=jb(e.fields,`email`),i=[t,n].filter(Boolean).join(` `);return i?`${i} (${r})`:r||e.id}let n=Object.values(e.fields).find(e=>e.name===`display_name`);return typeof n?.value==`string`?n.value:e.id}var Nb=({label:e,value:t,onChange:n,onSelect:r,options:i,loading:a,placeholder:o,disabled:s})=>{let[c,l]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`relative flex flex-col gap-1`,children:[e&&(0,G.jsx)(`label`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-500`,children:e}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(C,{icon:x,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-[10px] text-neutral-400`}),(0,G.jsx)(`input`,{type:`text`,className:`w-full rounded border border-black/10 bg-white py-1.5 pl-7 pr-2.5 font-mono text-[12px] text-neutral-800 focus:border-neutral-400 focus:outline-none disabled:opacity-50`,value:t,placeholder:o,disabled:s,onChange:e=>{n(e.target.value)},onFocus:()=>{l(!0)},onBlur:()=>{l(!1)}})]}),c&&(0,G.jsxs)(`ul`,{className:`absolute left-0 top-full z-10 mt-1 max-h-48 w-full overflow-auto rounded border border-black/10 bg-white shadow-lg`,children:[a&&(0,G.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-neutral-400`,children:`Loading…`}),!a&&i.length===0&&t.length===0&&(0,G.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-neutral-400`,children:`Start typing to search…`}),!a&&i.length===0&&t.length>0&&(0,G.jsx)(`li`,{className:`px-3 py-2 text-[12px] text-neutral-400`,children:`No results`}),!a&&i.map(e=>(0,G.jsx)(`li`,{className:`cursor-pointer px-3 py-2 text-[12px] text-neutral-800 hover:bg-neutral-100`,onMouseDown:e=>{e.preventDefault()},onClick:()=>{r(e.id,e.label),l(!1)},children:e.label},e.id))]})]})},Pb=({action:e,objectId:t,entityId:n,pluginApiName:r,configArgs:i,disabled:a})=>{let[o,{pending:s}]=rb({objectId:t,entityId:n,onError:t=>{console.error(`[js-action] ${e.api_name}:`,t)}}),c={id:e.api_name,api_name:e.api_name,plugin_api_name:r};return(0,G.jsxs)(`button`,{onClick:()=>{o(e.script,i,c)},disabled:a===!0||s,className:`relative flex flex-col items-start rounded border border-black/8 bg-white px-3 py-1.5 text-left transition-colors hover:bg-black/5 disabled:opacity-50`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[12px] text-neutral-800`,children:e.name}),e.hint_object_name&&(0,G.jsxs)(`span`,{className:`font-mono text-[10px] text-neutral-400`,children:[`for: `,e.hint_object_name]}),s&&(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center rounded bg-white/70`,children:(0,G.jsx)(C,{icon:d,spin:!0,className:`text-[11px] text-neutral-400`})})]})},Fb=({actions:e,pluginApiName:t,configArgs:n})=>{let r=zu(),{apiKey:i,businessId:a}=Iu(),o=sd(),[s,c]=(0,W.useState)(()=>{try{let e=localStorage.getItem(`kizen-sandbox:${t}:selectedObject`);return e?JSON.parse(e):null}catch{return null}}),[l,u]=(0,W.useState)(()=>s?.name??``),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(()=>{try{let e=localStorage.getItem(`kizen-sandbox:${t}:selectedEntity`);return e?JSON.parse(e):null}catch{return null}}),[h,g]=(0,W.useState)(()=>p?.label??``),[_,v]=(0,W.useState)(``),y=(0,W.useRef)(null);(0,W.useEffect)(()=>(y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{f(l)},300),()=>{y.current&&clearTimeout(y.current)}),[l]);let b=(0,W.useRef)(null);(0,W.useEffect)(()=>(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{v(h)},300),()=>{b.current&&clearTimeout(b.current)}),[h]),(0,W.useEffect)(()=>{s?localStorage.setItem(`kizen-sandbox:${t}:selectedObject`,JSON.stringify(s)):localStorage.removeItem(`kizen-sandbox:${t}:selectedObject`)},[s,t]),(0,W.useEffect)(()=>{p?localStorage.setItem(`kizen-sandbox:${t}:selectedEntity`,JSON.stringify(p)):localStorage.removeItem(`kizen-sandbox:${t}:selectedEntity`)},[p,t]);let x=ju({queryKey:[`custom-objects`,a,d],queryFn:async()=>{let e=new URLSearchParams({page_size:`20`});return d&&e.set(`search`,d),await(await r(`/custom-objects?${e.toString()}`)).json()},enabled:i!==``&&d.length>=1,staleTime:3e4}),S=ju({queryKey:[`entity-records`,s?.id,_],queryFn:async()=>{let e=new URLSearchParams({page_size:`20`});return _&&e.set(`search`,_),await(await r(`/records/${s?.id??``}/search?${e.toString()}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`})).json()},enabled:i!==``&&s!==null,staleTime:3e4}),C=(()=>{let e=x.data?.results.map(e=>({id:e.id,label:e.object_name}))??[],t=o?.business.client_object;return t?.access&&(!d||t.object_name.toLowerCase().includes(d.toLowerCase()))&&e.unshift({id:t.id,label:t.object_name}),e})(),w=s?.id===o?.business.client_object?.id,T=S.data?.results.map(e=>({id:e.id,label:Mb(e,w)}))??[];if(!i)return(0,G.jsx)(`p`,{className:`mt-1 text-[12px] text-neutral-400`,children:`Configure API credentials in Dev Tools to use JS action templates.`});let E=s!==null&&p!==null;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 p-2`,children:[(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(`div`,{className:`flex-1`,children:(0,G.jsx)(Nb,{label:`Custom Object`,value:l,onChange:e=>{u(e),s&&(c(null),m(null),g(``))},onSelect:(e,t)=>{c({id:e,name:t}),u(t),m(null),g(``)},options:C,loading:x.isFetching,placeholder:`Search custom objects…`})}),(0,G.jsx)(`div`,{className:`flex-1`,children:(0,G.jsx)(Nb,{label:`Entity`,value:h,onChange:e=>{g(e),p&&m(null)},onSelect:(e,t)=>{m({id:e,label:t}),g(t)},options:T,loading:S.isFetching,placeholder:`Search entities…`,disabled:s===null})})]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,G.jsx)(Pb,{action:e,objectId:s?.id??``,entityId:p?.id??``,pluginApiName:t,configArgs:n,disabled:!E},e.api_name))},E?`${s.id}-${p.id}`:`no-selection`)]})},Ib=({adornment:e,objectId:t,entityId:n,pluginApiName:r,fieldValue:i,configArgs:a,disabled:o})=>{let[s,{pending:c}]=rb({objectId:t,entityId:n,onError:t=>{console.error(`[data-adornment] ${e.field_type}:`,t)}}),l={id:e.config.tooltip||e.field_type,api_name:e.field_type,plugin_api_name:r};return(0,G.jsxs)(`button`,{onClick:()=>{let r={value:i,fieldId:``,fieldType:e.field_type,objectId:t,entityId:n,...a};s(e.script,r,l)},disabled:o===!0||c,className:`relative flex flex-col items-start rounded border border-black/8 bg-white px-3 py-1.5 text-left transition-colors hover:bg-black/5 disabled:opacity-50`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 font-mono text-[12px] text-neutral-800`,children:[e.config.color&&(0,G.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.config.color}}),e.config.tooltip||e.field_type]}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-neutral-400`,children:e.field_type}),c&&(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center rounded bg-white/70`,children:(0,G.jsx)(C,{icon:d,spin:!0,className:`text-[11px] text-neutral-400`})})]})},Lb=({adornments:e,pluginApiName:t,configArgs:n})=>{let r=zu(),{apiKey:i,businessId:a}=Iu(),o=sd(),[s,c]=(0,W.useState)(()=>{try{let e=localStorage.getItem(`kizen-sandbox:${t}:selectedObject`);return e?JSON.parse(e):null}catch{return null}}),[l,u]=(0,W.useState)(()=>s?.name??``),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(()=>{try{let e=localStorage.getItem(`kizen-sandbox:${t}:selectedEntity`);return e?JSON.parse(e):null}catch{return null}}),[h,g]=(0,W.useState)(()=>p?.label??``),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)({}),x=(0,W.useRef)(null);(0,W.useEffect)(()=>(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{f(l)},300),()=>{x.current&&clearTimeout(x.current)}),[l]);let S=(0,W.useRef)(null);(0,W.useEffect)(()=>(S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{v(h)},300),()=>{S.current&&clearTimeout(S.current)}),[h]),(0,W.useEffect)(()=>{s?localStorage.setItem(`kizen-sandbox:${t}:selectedObject`,JSON.stringify(s)):localStorage.removeItem(`kizen-sandbox:${t}:selectedObject`)},[s,t]),(0,W.useEffect)(()=>{p?localStorage.setItem(`kizen-sandbox:${t}:selectedEntity`,JSON.stringify(p)):localStorage.removeItem(`kizen-sandbox:${t}:selectedEntity`)},[p,t]);let C=ju({queryKey:[`custom-objects`,a,d],queryFn:async()=>{let e=new URLSearchParams({page_size:`20`});return d&&e.set(`search`,d),await(await r(`/custom-objects?${e.toString()}`)).json()},enabled:i!==``&&d.length>=1,staleTime:3e4}),w=ju({queryKey:[`entity-records`,s?.id,_],queryFn:async()=>{let e=new URLSearchParams({page_size:`20`});return _&&e.set(`search`,_),await(await r(`/records/${s?.id??``}/search?${e.toString()}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`})).json()},enabled:i!==``&&s!==null,staleTime:3e4}),T=(()=>{let e=C.data?.results.map(e=>({id:e.id,label:e.object_name}))??[],t=o?.business.client_object;return t?.access&&(!d||t.object_name.toLowerCase().includes(d.toLowerCase()))&&e.unshift({id:t.id,label:t.object_name}),e})(),E=s?.id===o?.business.client_object?.id,D=w.data?.results.map(e=>({id:e.id,label:Mb(e,E)}))??[];if(!i)return(0,G.jsx)(`p`,{className:`mt-1 text-[12px] text-neutral-400`,children:`Configure API credentials in Dev Tools to use data adornments.`});let O=s!==null&&p!==null,k=e.reduce((e,t)=>{let n=t.field_type;return e[n]??=[],e[n].push(t),e},{});return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 p-2`,children:[(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(`div`,{className:`flex-1`,children:(0,G.jsx)(Nb,{label:`Custom Object`,value:l,onChange:e=>{u(e),s&&(c(null),m(null),g(``))},onSelect:(e,t)=>{c({id:e,name:t}),u(t),m(null),g(``)},options:T,loading:C.isFetching,placeholder:`Search custom objects…`})}),(0,G.jsx)(`div`,{className:`flex-1`,children:(0,G.jsx)(Nb,{label:`Entity`,value:h,onChange:e=>{g(e),p&&m(null)},onSelect:(e,t)=>{m({id:e,label:t}),g(t)},options:D,loading:w.isFetching,placeholder:`Search entities…`,disabled:s===null})})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-3`,children:Object.entries(k).map(([e,r])=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:e}),(0,G.jsx)(`input`,{type:`text`,className:`w-full rounded border border-black/10 bg-white px-2.5 py-1.5 font-mono text-[12px] text-neutral-800 focus:border-neutral-400 focus:outline-none`,placeholder:`${e} value…`,value:y[e]??``,onChange:t=>{b(n=>({...n,[e]:t.target.value}))}}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map((r,i)=>(0,G.jsx)(Ib,{adornment:r,objectId:s?.id??``,entityId:p?.id??``,pluginApiName:t,fieldValue:y[e]??``,configArgs:n,disabled:!O},i))})]},e))},O?`${s.id}-${p.id}`:`no-selection`)]})},Rb=({page:e,isActive:t})=>{let{scriptUIRef:n,outputUIRef:r,scopedCss:i,sanitizedHtml:a,interactableScriptRef:o,iframeURL:s,pending:c}=ob(e);return(0,G.jsxs)(`div`,{style:{display:t?`block`:`none`},className:`relative h-full w-full`,children:[c&&(0,G.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-white/80 font-mono text-[11px] text-neutral-400`,children:`loading…`}),e.type===`script`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{ref:n,className:`h-full w-full p-3`}),(0,G.jsx)(`style`,{children:i})]}),e.type===`html`&&(0,G.jsxs)(`div`,{ref:o,className:`overflow-auto p-3`,children:[a&&(0,G.jsx)(`div`,{dangerouslySetInnerHTML:{__html:a}}),(0,G.jsx)(`div`,{ref:r}),(0,G.jsx)(`style`,{children:i})]}),e.type===`iframe`&&s&&(0,G.jsx)(`iframe`,{src:s,className:`h-full w-full border-0`,title:e.name})]})},zb=`integration:route-change`;function Bb(e,t){return e.find(e=>e.api_name===t||t.endsWith(`${e.plugin_api_name}/${e.api_name}`))}function Vb(e){try{let t=new URL(e);return t.hostname===``?t.pathname.split(`/`).filter(Boolean).pop()??e:t.hostname}catch{return e.split(`/`).filter(Boolean).pop()??e}}var Hb=(0,W.forwardRef)(({pages:e},t)=>{let[n,r]=(0,W.useState)(`home`),[i,a]=(0,W.useState)({entries:[``],index:0}),[o,s]=(0,W.useState)([]),[c,l]=(0,W.useState)({}),u=(0,W.useRef)(0),d=i.entries[i.index]??``,f=n===`home`?d:n,p=(0,W.useRef)(!0);(0,W.useEffect)(()=>{if(p.current){p.current=!1;return}let e=`/${f}`;window.dispatchEvent(new CustomEvent(zb,{detail:{location:{host:window.location.host,origin:window.location.origin,port:window.location.port,protocol:window.location.protocol,pathname:e,search:``,hash:``,href:`${window.location.origin}${e}`}}}))},[f]);let m=n===`home`&&i.index>0,h=n===`home`&&i.index<i.entries.length-1,g=(0,W.useCallback)((t,n)=>{let i=t.replace(/^\/+/,``),o=Bb(e,i);o?(r(o.api_name),l(e=>({...e,[o.api_name]:(e[o.api_name]??0)+1}))):(r(`home`),a(e=>{if(!n?.replace&&e.entries[e.index]===i)return e;if(n?.replace){let t=[...e.entries];return t[e.index]=i,{entries:t,index:e.index}}let t=[...e.entries.slice(0,e.index+1),i];return{entries:t,index:t.length-1}}))},[e]),_=(0,W.useCallback)(t=>{let n=Bb(e,t.replace(/^\/+/,``));if(n){r(n.api_name),l(e=>({...e,[n.api_name]:(e[n.api_name]??0)+1}));return}u.current+=1;let i=`__tab_${String(u.current)}`;s(e=>[...e,{id:i,url:t,title:Vb(t)}]),r(i)},[e]),v=(0,W.useCallback)(e=>{s(t=>t.filter(t=>t.id!==e)),n===e&&r(`home`)},[n]);(0,W.useImperativeHandle)(t,()=>({navigate:g,openNewTab:_}),[g,_]);let y=o.find(e=>e.id===n)??null;return(0,G.jsxs)(`div`,{className:`mt-1.5 overflow-hidden rounded border border-black/10 bg-white`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/8 bg-neutral-50 px-3 py-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full bg-red-400/60`}),(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full bg-yellow-400/60`}),(0,G.jsx)(`div`,{className:`h-3 w-3 rounded-full bg-green-400/60`})]}),(0,G.jsx)(`button`,{onClick:()=>{a(e=>({...e,index:e.index-1}))},disabled:!m,className:`px-0.5 font-mono text-[15px] leading-none transition-colors ${m?`text-neutral-600 hover:text-neutral-900`:`cursor-default text-neutral-300`}`,children:`‹`}),(0,G.jsx)(`button`,{onClick:()=>{a(e=>({...e,index:e.index+1}))},disabled:!h,className:`px-0.5 font-mono text-[15px] leading-none transition-colors ${h?`text-neutral-600 hover:text-neutral-900`:`cursor-default text-neutral-300`}`,children:`›`}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 truncate rounded border border-black/8 bg-white px-2 py-0.5 font-mono text-[11px] text-neutral-400`,children:y?y.url:`app://sandbox/${f}`})]}),(0,G.jsxs)(`div`,{className:`flex border-b border-black/8 bg-neutral-50`,children:[(0,G.jsx)(`button`,{onClick:()=>{r(`home`)},className:`border-r border-black/8 px-3 py-1.5 font-mono text-[11px] transition-colors ${n===`home`?`bg-white font-medium text-neutral-900`:`text-neutral-500 hover:bg-black/5`}`,children:`home`}),e.map(e=>(0,G.jsxs)(`button`,{onClick:()=>{r(e.api_name)},className:`border-r border-black/8 px-3 py-1.5 font-mono text-[11px] transition-colors ${n===e.api_name?`bg-white font-medium text-neutral-900`:`text-neutral-500 hover:bg-black/5`}`,children:[e.toolbar_icon&&(Lg[e.toolbar_icon]?(0,G.jsx)(C,{icon:Lg[e.toolbar_icon],className:`mr-1 text-[10px] text-neutral-400`}):(0,G.jsx)(`span`,{className:`mr-1 rounded px-1 font-mono text-[9px] ${Rg.has(e.toolbar_icon)||Ig.has(e.toolbar_icon)?`bg-neutral-100 text-neutral-400`:`bg-amber-100 text-amber-600`}`,children:e.toolbar_icon})),e.name]},e.api_name)),o.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center border-r border-black/8 ${n===e.id?`bg-white`:`hover:bg-black/5`}`,children:[(0,G.jsx)(`button`,{onClick:()=>{r(e.id)},className:`py-1.5 pl-3 pr-1 font-mono text-[11px] transition-colors ${n===e.id?`font-medium text-neutral-900`:`text-neutral-500`}`,children:e.title}),(0,G.jsx)(`button`,{onClick:()=>{v(e.id)},className:`px-1.5 py-1.5 font-mono text-[11px] text-neutral-300 transition-colors hover:text-neutral-600`,children:`×`})]},e.id))]}),(0,G.jsxs)(`div`,{className:`min-h-[600px]`,children:[n===`home`&&d===``&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 p-6 font-mono text-[11px]`,children:[(0,G.jsx)(`div`,{className:`text-neutral-400`,children:`app://sandbox/`}),(0,G.jsx)(`div`,{className:`mt-1 text-[13px] font-medium text-neutral-700`,children:`App Homepage`}),(0,G.jsx)(`div`,{className:`text-neutral-400`,children:`This is the index page of your app. Navigate to a routable page using the tabs above.`})]}),n===`home`&&d!==``&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 p-6 font-mono text-[11px]`,children:[(0,G.jsxs)(`div`,{className:`text-neutral-400`,children:[`app://sandbox/`,d]}),(0,G.jsx)(`div`,{className:`mt-1 text-[13px] font-medium text-neutral-500`,children:`Page not found`}),(0,G.jsxs)(`div`,{className:`text-neutral-400`,children:[`No routable page with api_name`,` `,(0,G.jsx)(`code`,{className:`rounded bg-neutral-100 px-1`,children:d}),` is defined in this plugin.`]})]}),e.map(e=>(0,G.jsx)(Rb,{page:e,isActive:n===e.api_name},`${e.api_name}-${String(c[e.api_name]??0)}`)),o.map(e=>(0,G.jsx)(`div`,{style:{display:n===e.id?`block`:`none`},className:`h-full w-full`,children:/^https?:\/\//i.test(e.url)?(0,G.jsx)(`iframe`,{src:e.url,className:`h-full w-full border-0`,title:e.title}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 p-6 font-mono text-[11px]`,children:[(0,G.jsx)(`div`,{className:`text-neutral-400`,children:e.url}),(0,G.jsx)(`div`,{className:`mt-1 text-[13px] font-medium text-neutral-500`,children:`Page not found`}),(0,G.jsxs)(`div`,{className:`text-neutral-400`,children:[`No routable page with path`,` `,(0,G.jsx)(`code`,{className:`rounded bg-neutral-100 px-1`,children:e.url}),` is defined in this plugin.`]})]})},e.id))]})]})});Hb.displayName=`RoutablePageBrowser`;var Ub=({item:e})=>{let[t,{pending:n}]=nb({onError:t=>{console.error(`[toolbar] ${e.api_name}:`,t)},plugin:e});return(0,G.jsxs)(`button`,{onClick:()=>void t(e.script,e.args),disabled:n,className:`relative flex items-center gap-1.5 rounded border border-black/8 bg-white px-3 py-1.5 font-mono text-[12px] text-neutral-800 transition-colors hover:bg-black/5 disabled:opacity-50`,children:[e.color&&(0,G.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),e.icon&&(Lg[e.icon]?(0,G.jsx)(C,{icon:Lg[e.icon],className:`text-[12px] text-neutral-500`}):(0,G.jsx)(`span`,{className:`rounded px-1 font-mono text-[10px] ${Rg.has(e.icon)||Ig.has(e.icon)?`bg-neutral-100 text-neutral-400`:`bg-amber-100 text-amber-600`}`,children:e.icon})),(0,G.jsx)(`span`,{children:e.label}),n&&(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center rounded bg-white/70`,children:(0,G.jsx)(C,{icon:d,spin:!0,className:`text-[11px] text-neutral-400`})})]})},Wb=({item:e,objectId:t,pluginApiName:n,configArgs:r,disabled:i})=>{let[a,{pending:o}]=rb({objectId:t,entityId:``,onError:t=>{console.error(`[object-settings] ${e.api_name}:`,t)}}),s={id:e.api_name,api_name:e.api_name,plugin_api_name:n};return(0,G.jsxs)(`button`,{onClick:()=>{a(e.script,r,s)},disabled:i===!0||o,className:`relative flex flex-col items-start rounded border border-black/8 bg-white px-3 py-1.5 text-left transition-colors hover:bg-black/5 disabled:opacity-50`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[12px] text-neutral-800`,children:e.label}),e.when&&(0,G.jsxs)(`span`,{className:`font-mono text-[10px] text-neutral-400`,children:[`when: `,e.when]}),o&&(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center rounded bg-white/70`,children:(0,G.jsx)(C,{icon:d,spin:!0,className:`text-[11px] text-neutral-400`})})]})},Gb=({items:e,pluginApiName:t,configArgs:n})=>{let r=zu(),{apiKey:i,businessId:a}=Iu(),o=sd(),s=`kizen-sandbox:${t}:objectSettings:selectedObject`,[c,l]=(0,W.useState)(()=>{try{let e=localStorage.getItem(s);return e?JSON.parse(e):null}catch{return null}}),[u,d]=(0,W.useState)(()=>c?.name??``),[f,p]=(0,W.useState)(``),m=(0,W.useRef)(null);(0,W.useEffect)(()=>(m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{p(u)},300),()=>{m.current&&clearTimeout(m.current)}),[u]),(0,W.useEffect)(()=>{c?localStorage.setItem(s,JSON.stringify(c)):localStorage.removeItem(s)},[c,s]);let h=ju({queryKey:[`custom-objects`,a,f],queryFn:async()=>{let e=new URLSearchParams({page_size:`20`});return f&&e.set(`search`,f),await(await r(`/custom-objects?${e.toString()}`)).json()},enabled:i!==``&&f.length>=1,staleTime:3e4}),g=(()=>{let e=h.data?.results.map(e=>({id:e.id,label:e.object_name}))??[],t=o?.business.client_object;return t?.access&&(!f||t.object_name.toLowerCase().includes(f.toLowerCase()))&&e.unshift({id:t.id,label:t.object_name}),e})();return i?(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 p-2`,children:[(0,G.jsx)(`div`,{className:`w-64`,children:(0,G.jsx)(Nb,{label:`Custom Object`,value:u,onChange:e=>{d(e),c&&l(null)},onSelect:(e,t)=>{l({id:e,name:t}),d(t)},options:g,loading:h.isFetching,placeholder:`Search custom objects…`})}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,G.jsx)(Wb,{item:e,objectId:c?.id??``,pluginApiName:t,configArgs:n,disabled:c===null},e.api_name))},c?.id??`no-selection`)]}):(0,G.jsx)(`p`,{className:`mt-1 text-[12px] text-neutral-400`,children:`Configure API credentials in Dev Tools to use object settings menu items.`})},Kb=`h-8 rounded border border-black/10 bg-white px-2.5 font-mono text-[12px] text-neutral-800 focus:border-neutral-400 focus:outline-none w-full`,qb=`block text-[11px] font-semibold uppercase tracking-widest text-neutral-500 mb-1`,Jb=e=>e===`GET`?`bg-green-50 text-green-700`:e===`DELETE`?`bg-red-50 text-red-700`:e===`POST`?`bg-blue-50 text-blue-700`:`bg-amber-50 text-amber-700`;function Yb(e,t){try{let n=localStorage.getItem(`kizen-sandbox:${e}:service:${t}:requestHistory`);return n?JSON.parse(n):[]}catch{return[]}}function Xb(e,t,n,r){let i=n.path===``||n.path.startsWith(`/`)?n.path:`/${n.path}`,a=`${n.method}:${i}`,o=r.filter(e=>`${e.method}:${e.path}`!==a),s=[{...n,path:i,id:String(Date.now())},...o].slice(0,10);try{localStorage.setItem(`kizen-sandbox:${e}:service:${t}:requestHistory`,JSON.stringify(s))}catch{}return s}var Zb=({response:e})=>{let{status:t,elapsedMs:n,contentType:r,body:i}=e,a=t===0?`bg-neutral-100 text-neutral-500`:t<300?`bg-green-50 text-green-700`:t<400?`bg-yellow-50 text-yellow-700`:`bg-red-50 text-red-700`,o=i;if(r.includes(`application/json`))try{o=JSON.stringify(JSON.parse(i),null,2)}catch{}return(0,G.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`rounded px-2 py-0.5 text-[11px] font-semibold ${a}`,children:t===0?`Error`:t}),n>0&&(0,G.jsxs)(`span`,{className:`rounded bg-neutral-100 px-2 py-0.5 text-[11px] text-neutral-500`,children:[n,`ms`]})]}),(0,G.jsx)(`pre`,{className:`max-h-72 overflow-auto rounded border border-black/5 bg-neutral-50 p-3 font-mono text-[11px] leading-relaxed text-neutral-700 whitespace-pre-wrap break-all`,children:o||`(empty response)`})]})},Qb=({headers:e,onChange:t})=>{let n=()=>{t([...e,{id:String(Date.now()),key:``,value:``}])},r=n=>{t(e.filter(e=>e.id!==n))},i=(n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`label`,{className:qb,children:`Custom Headers`}),e.length>0&&(0,G.jsx)(`div`,{className:`grid grid-cols-[1fr_1fr_auto] gap-1 mb-1`,children:e.map(e=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`input`,{className:Kb,placeholder:`Header name`,value:e.key,onChange:t=>{i(e.id,`key`,t.target.value)}},`${e.id}-key`),(0,G.jsx)(`input`,{className:Kb,placeholder:`Value`,value:e.value,onChange:t=>{i(e.id,`value`,t.target.value)}},`${e.id}-val`),(0,G.jsx)(`button`,{type:`button`,className:`px-1.5 text-neutral-400 hover:text-red-500`,onClick:()=>{r(e.id)},children:(0,G.jsx)(C,{icon:o,className:`text-[11px]`})},`${e.id}-rm`)]}))}),(0,G.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-[11px] text-neutral-400 hover:text-neutral-700 self-start`,onClick:n,children:[(0,G.jsx)(C,{icon:l,className:`text-[10px]`}),`Add header`]})]})},$b=({service:e,pluginApiName:t})=>{let n=zu(),{environment:r}=Iu(),i=Lu[r],[a,o]=(0,W.useState)(`GET`),[s,l]=(0,W.useState)(``),[u,p]=(0,W.useState)([]),[m,h]=(0,W.useState)(``),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)(()=>Yb(t,e.service_name)),[S,w]=(0,W.useState)(!1),T=(0,W.useRef)(null);(0,W.useEffect)(()=>{if(!S)return;let e=e=>{T.current&&!T.current.contains(e.target)&&w(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[S]);let E=[`POST`,`PUT`,`PATCH`].includes(a),D=s===``||s.startsWith(`/`)?s:`/${s}`,O=`/external-integrations/proxy/${t}/${e.service_name}${D||`/`}`,k=`${i}${O}`,A=e=>{o(e.method),l(e.path),p(e.headers),h(e.body),w(!1)},j=()=>{localStorage.removeItem(`kizen-sandbox:${t}:service:${e.service_name}:requestHistory`),x([]),w(!1)},M=async()=>{if(!g){x(Xb(t,e.service_name,{method:a,path:s,headers:u,body:m},b)),_(!0),y(null);try{let e=Object.fromEntries(u.filter(e=>e.key.trim()).map(e=>[e.key.trim(),e.value])),t=performance.now(),r=await n(O,{method:a,headers:{...E&&m.trim()?{"Content-Type":`application/json`}:{},...e},...E&&m.trim()?{body:m}:{}}),i=Math.round(performance.now()-t),o=r.headers.get(`content-type`)??``,s=await r.text();y({status:r.status,elapsedMs:i,contentType:o,body:s})}catch(e){y({status:0,elapsedMs:0,contentType:``,body:String(e)})}finally{_(!1)}}};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 shrink-0`,children:[(0,G.jsx)(`label`,{className:qb,children:`Method`}),(0,G.jsx)(`select`,{className:`h-8 w-28 rounded border border-black/10 bg-white px-2 font-mono text-[12px] text-neutral-800 focus:border-neutral-400 focus:outline-none`,value:a,onChange:e=>{o(e.target.value)},children:[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`].map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsxs)(`div`,{className:`relative flex flex-col gap-1 flex-1 min-w-0`,ref:T,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`label`,{className:qb,children:`Path`}),b.length>0&&(0,G.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-[11px] text-neutral-400 hover:text-neutral-700`,onClick:()=>{w(e=>!e)},title:`Request history`,children:[(0,G.jsx)(C,{icon:f,className:`text-[10px]`}),(0,G.jsx)(`span`,{children:b.length})]})]}),(0,G.jsx)(`input`,{className:Kb,placeholder:`/path/to/endpoint`,value:s,onChange:e=>{l(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&M()}}),(0,G.jsx)(`span`,{className:`font-mono text-[10px] text-neutral-400 truncate`,children:k}),S&&b.length>0&&(0,G.jsxs)(`div`,{className:`absolute left-0 top-full z-10 mt-1 w-full rounded border border-black/10 bg-white shadow-lg`,children:[(0,G.jsx)(`ul`,{className:`max-h-48 overflow-auto`,children:b.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left hover:bg-neutral-50`,onMouseDown:e=>{e.preventDefault()},onClick:()=>{A(e)},children:[(0,G.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold ${Jb(e.method)}`,children:e.method}),(0,G.jsx)(`span`,{className:`flex-1 truncate font-mono text-[11px] text-neutral-700`,children:e.path||`/`}),e.headers.filter(e=>e.key.trim()).length>0&&(0,G.jsxs)(`span`,{className:`shrink-0 text-[10px] text-neutral-400`,children:[e.headers.filter(e=>e.key.trim()).length,`h`]}),e.body.trim()&&(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] text-neutral-400`,children:`body`})]})},e.id))}),(0,G.jsx)(`div`,{className:`border-t border-black/5 px-3 py-1.5 text-right`,children:(0,G.jsx)(`button`,{type:`button`,className:`text-[11px] text-neutral-400 hover:text-neutral-700`,onClick:j,children:`clear history`})})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 shrink-0`,children:[(0,G.jsx)(`span`,{className:`invisible ${qb}`,children:`\xA0`}),(0,G.jsxs)(`button`,{type:`button`,disabled:g,className:`h-8 flex items-center gap-1.5 rounded bg-neutral-800 px-3 text-[12px] font-medium text-white hover:bg-neutral-700 disabled:opacity-50`,onClick:()=>{M()},children:[g?(0,G.jsx)(C,{icon:d,className:`animate-spin text-[11px]`}):(0,G.jsx)(C,{icon:c,className:`text-[11px]`}),`Send`]})]})]}),(0,G.jsx)(Qb,{headers:u,onChange:p}),E&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`label`,{className:qb,children:`Request Body`}),(0,G.jsx)(`textarea`,{className:`rounded border border-black/10 bg-white px-2.5 py-1.5 font-mono text-[12px] text-neutral-800 focus:border-neutral-400 focus:outline-none w-full resize-y`,rows:5,placeholder:`{"key": "value"}`,value:m,onChange:e=>{h(e.target.value)}})]}),v!==null&&(0,G.jsx)(Zb,{response:v})]})},ex=e=>e===`oauth`?`rounded bg-blue-50 px-1.5 py-0.5 text-[11px] font-mono text-blue-700`:e===`no_auth`?`rounded bg-neutral-100 px-1.5 py-0.5 text-[11px] font-mono text-neutral-500`:`rounded bg-amber-50 px-1.5 py-0.5 text-[11px] font-mono text-amber-700`,tx=({label:e,children:t})=>(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 text-[12px]`,children:[(0,G.jsx)(`span`,{className:`w-28 shrink-0 text-[11px] font-semibold uppercase tracking-widest text-neutral-400`,children:e}),t]}),nx=({service:e})=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5 pb-4 mb-4 border-b border-black/5`,children:[(0,G.jsxs)(tx,{label:`Name`,children:[(0,G.jsx)(`span`,{className:`text-neutral-800 font-medium`,children:e.display_name}),(0,G.jsx)(`span`,{className:`rounded bg-neutral-100 px-1.5 py-0.5 font-mono text-[11px] text-neutral-500`,children:e.service_name})]}),(0,G.jsxs)(tx,{label:`Auth`,children:[(0,G.jsx)(`span`,{className:ex(e.auth_type),children:e.auth_type}),e.auth_level&&(0,G.jsx)(`span`,{className:`text-[11px] text-neutral-400`,children:e.auth_level})]}),(0,G.jsx)(tx,{label:`Base URL`,children:(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-600 break-all`,children:e.base_service_url||(0,G.jsx)(`em`,{className:`text-neutral-400`,children:`none`})})}),e.auth_credentials?.scopes&&(0,G.jsx)(tx,{label:`Scopes`,children:(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-600 break-all leading-relaxed`,children:e.auth_credentials.scopes})}),e.auth_credentials?.authorize_url&&(0,G.jsx)(tx,{label:`Auth URL`,children:(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-600 break-all`,children:e.auth_credentials.authorize_url})}),e.required_entitlement?(0,G.jsx)(tx,{label:`Entitlement`,children:(0,G.jsx)(`span`,{className:`font-mono text-[11px] text-neutral-500`,children:e.required_entitlement})}):null]}),rx=({services:e,pluginApiName:t})=>{let n=e.map(e=>e),[r,i]=(0,W.useState)(0),a=n[r]??n[0];return a?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`Services`}),(0,G.jsxs)(J,{className:`mt-2 !p-0 overflow-hidden`,children:[(0,G.jsx)(`div`,{className:`flex border-b border-black/10 overflow-x-auto`,children:n.map((e,t)=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>{i(t)},className:`shrink-0 px-4 py-2.5 text-[12px] font-medium border-b-2 transition-colors ${t===r?`border-neutral-800 text-neutral-900`:`border-transparent text-neutral-400 hover:text-neutral-700`}`,children:e.display_name},e.service_name))}),(0,G.jsxs)(`div`,{className:`p-5 flex flex-col gap-4`,children:[(0,G.jsx)(nx,{service:a}),(0,G.jsx)($b,{service:a,pluginApiName:t},a.service_name)]})]})]}):null},ix=e=>e.id??e.key??``,ax=(e,t)=>{let n={},r=e=>{let i=ix(e);if(i)if(e.type===`text`)n[i]={value:t[i]??e.defaultValue??``};else if(e.type===`number`){let r=t[i];n[i]={value:r!==void 0&&r!==``?Number(r):e.default??null}}else if(e.type===`boolean`){let r=t[i];n[i]={value:r===void 0?!!e.default:!!r}}else if(e.type===`select`){let r=t[i]??``;n[i]={value:e.options?.find(e=>e.value===r)??(r?{value:r,label:r}:null)}}else if(e.type===`dropdown`){let r=t[i]??e.defaultValue??``;n[i]={value:e.options?.find(e=>e.value===r)??(r?{value:r,label:r}:null)}}else e.type===`container`&&e.fields?.forEach(r)};return e.forEach(r),n},ox=({label:e,required:t,tooltip:n})=>(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] font-medium text-neutral-500`,children:[e,t&&(0,G.jsx)(`span`,{className:`text-red-500`,children:`*`}),n&&(0,G.jsx)(`span`,{className:`cursor-help rounded-full border border-neutral-300 px-1 text-[10px] text-neutral-400`,title:n,children:`i`})]}),sx=({block:e,values:t,onChange:n})=>{let r=ix(e);return e.type===`description`?(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-700`,children:e.content}):e.type===`spacer`?(0,G.jsx)(`div`,{style:{height:e.height??8}}):e.type===`text`?(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(ox,{label:e.label,required:e.required,tooltip:e.tooltip}),(0,G.jsx)(`input`,{type:`text`,value:t[r]??e.defaultValue??``,placeholder:e.placeholder,onChange:e=>{n(r,e.target.value)},className:`rounded border border-black/10 px-2 py-1.5 font-mono text-[12px] focus:outline-none focus:ring-1 focus:ring-neutral-400`})]}):e.type===`number`?(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(ox,{label:e.label,required:e.required,tooltip:e.tooltip}),(0,G.jsx)(`input`,{type:`number`,value:t[r]??``,placeholder:e.placeholder,onChange:e=>{n(r,e.target.value)},className:`rounded border border-black/10 px-2 py-1.5 font-mono text-[12px] focus:outline-none focus:ring-1 focus:ring-neutral-400`})]}):e.type===`boolean`?(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:t[r]===void 0?!!e.default:!!t[r],onChange:e=>{n(r,e.target.checked)},className:`h-3.5 w-3.5 rounded border-black/20 accent-neutral-800`}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-[12px] text-neutral-700`,children:[e.label,e.required&&(0,G.jsx)(`span`,{className:`text-red-500`,children:`*`}),e.tooltip&&(0,G.jsx)(`span`,{className:`cursor-help rounded-full border border-neutral-300 px-1 text-[10px] text-neutral-400`,title:e.tooltip,children:`i`})]})]}):e.type===`select`||e.type===`dropdown`?(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(ox,{label:e.label,required:e.required,tooltip:e.tooltip}),(0,G.jsxs)(`select`,{value:t[r]??e.defaultValue??``,onChange:e=>{n(r,e.target.value)},className:`rounded border border-black/10 bg-white px-2 py-1.5 font-mono text-[12px] focus:outline-none`,children:[(e.placeholder!=null||!e.required)&&(0,G.jsx)(`option`,{value:``,children:e.placeholder??`—`}),(e.options??[]).map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}):e.type===`container`?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:(e.fields??[]).map(e=>(0,G.jsx)(`div`,{style:{width:e.widthPercent===50?`calc(50% - 6px)`:`100%`},children:(0,G.jsx)(sx,{block:e,values:t,onChange:n})},ix(e)||e.type))}):null},cx={small:`max-w-sm`,medium:`max-w-md`,large:`max-w-2xl`},lx=({show:e,config:t,onConfirm:n,onHide:r})=>{let i=t,a=i.content??[],[o,s]=(0,W.useState)({}),c=(0,W.useCallback)((e,t)=>{s(n=>({...n,[e]:t}))},[]),l=()=>{let e=ax(a,o);s({}),n(e)},u=e=>{s({}),r(e)};if(!e)return null;let d=t.confirmButton?.label??`Confirm`,f=t.cancelButton?.label??`Cancel`;return(0,G.jsx)(`div`,{role:`dialog`,className:`fixed inset-0 z-[99999] flex items-start justify-center overflow-y-auto bg-black/30 px-4 py-12`,onClick:()=>{u(`close`)},children:(0,G.jsxs)(`div`,{className:`w-full ${cx[i.size??`medium`]??cx.medium??``} rounded-lg border border-black/10 bg-white font-mono shadow-xl`,onClick:e=>{e.stopPropagation()},children:[t.title&&(0,G.jsx)(`div`,{className:`border-b border-black/8 px-5 py-3`,children:(0,G.jsx)(`span`,{className:`text-[13px] font-semibold text-neutral-900`,children:t.title})}),a.length>0&&(0,G.jsx)(`div`,{className:`max-h-[60vh] space-y-3 overflow-y-auto px-5 py-4`,children:a.map((e,t)=>(0,G.jsx)(sx,{block:e,values:o,onChange:c},ix(e)||`${e.type}-${String(t)}`))}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-black/8 px-5 py-3`,children:[(0,G.jsx)(`button`,{onClick:()=>{u(`button`)},className:`rounded border border-black/10 px-3 py-1.5 text-[12px] text-neutral-600 transition-colors hover:bg-black/5`,children:f}),(0,G.jsx)(`button`,{onClick:l,className:`rounded bg-neutral-900 px-3 py-1.5 text-[12px] text-white transition-colors hover:bg-neutral-700`,children:d})]})]})})},ux=`kizen-plugin-config:`;function dx(e){return`${ux}${e}`}function fx(e){try{let t=localStorage.getItem(dx(e));return t?JSON.parse(t):null}catch{return null}}function px(e,t,n){let r={__kizen_setup_assistant_values:t,__kizen_clean_config:Sy(n,t)};localStorage.setItem(dx(e),JSON.stringify(r))}function mx(e,t){let n={__kizen_setup_assistant_values:{},__kizen_clean_config:t};localStorage.setItem(dx(e),JSON.stringify(n))}function hx(e){localStorage.removeItem(dx(e))}var gx=56,_x=({showingToast:e,browserRef:t})=>{let{apiName:n}=Sc({strict:!1}),r=ad(),[i,a]=(0,W.useState)(()=>localStorage.getItem(`frames-enabled`)===`true`),o=e=>{a(e),localStorage.setItem(`frames-enabled`,String(e))},{data:s,isLoading:c,isError:l}=ju(Nu),u=(0,W.useMemo)(()=>fx(n??``),[n]);if(c)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-400`,children:`Fetching bundle.json…`})});if(l)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-red-700`,children:`Could not load bundle.json.`})});let d=s?.find(e=>e.api_name===n);if(!d)return(0,G.jsx)(J,{children:(0,G.jsxs)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:[`No app found with api_name`,` `,(0,G.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 py-0.5`,children:n}),`.`]})});let f=u?.__kizen_clean_config?{__kizen_clean_config:u.__kizen_clean_config}:{},p=d.artifacts.floating_frames.map(e=>({...e,plugin_api_name:d.api_name,args:f})),m=d.artifacts.toolbar_items.map(e=>({...e,plugin_api_name:d.api_name,args:f})),h=d.artifacts.js_action_templates.map(e=>({...e,plugin_api_name:d.api_name,args:f})),g=d.artifacts.object_settings_menu_items.map(e=>({...e,plugin_api_name:d.api_name,args:f})),_=d.artifacts.data_adornments.map(e=>({...e,plugin_api_name:d.api_name,args:f})),v=d.artifacts.routable_pages.map(e=>({...e,plugin_api_name:d.api_name,args:f})),y=m.length>0||h.length>0||g.length>0||_.length>0;return(0,G.jsxs)(G.Fragment,{children:[e&&(0,G.jsx)(`div`,{className:`fixed top-4 left-1/2 -translate-x-1/2 z-20 rounded px-4 py-2 text-sm font-medium ${{success:`bg-green-100 text-green-700`,error:`bg-red-100 text-red-700`,failure:`bg-red-100 text-red-700`,alert:`bg-amber-100 text-amber-700`}[e.variant??`success`]??`bg-green-100 text-green-700`}`,children:e.message}),(0,G.jsxs)(`div`,{style:{paddingRight:p.length>0?gx:0},children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 xl:flex-row xl:items-start`,children:[y&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 xl:flex-1 xl:min-w-0`,children:[m.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`Toolbar Items`}),(0,G.jsx)(`div`,{children:(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2 p-2`,children:m.map(e=>(0,G.jsx)(Ub,{item:e},e.api_name))})})]}),h.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`JS Action Templates`}),(0,G.jsx)(Fb,{actions:h,pluginApiName:d.api_name,configArgs:f})]}),g.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`Object Settings Menu Items`}),(0,G.jsx)(Gb,{items:g,pluginApiName:d.api_name,configArgs:f})]}),_.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`Data Adornments`}),(0,G.jsx)(Lb,{adornments:_,pluginApiName:d.api_name,configArgs:f})]})]}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`strong`,{className:`text-xs`,children:`Routable Pages`}),(0,G.jsx)(Hb,{ref:t,pages:v})]})]}),(d.services?.length??0)>0&&(0,G.jsx)(rx,{services:d.services??[],pluginApiName:d.api_name})]}),p.length>0&&(0,G.jsxs)(`div`,{className:`pointer-events-none fixed inset-0`,children:[(0,G.jsxs)(`div`,{className:`absolute inset-y-0 flex w-14 flex-col-reverse items-center gap-2 border-l border-black/8 bg-white/60 pb-4 backdrop-blur-sm`,style:{right:r},children:[p.map(e=>(0,G.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,G.jsx)(`div`,{id:`${e.plugin_api_name}-${e.api_name}-trigger-left`}),(0,G.jsx)(`div`,{id:`${e.plugin_api_name}-${e.api_name}-trigger-right`})]},e.api_name)),(0,G.jsx)(`strong`,{className:`text-[9px] uppercase tracking-widest text-neutral-400`,children:`Frames`}),(0,G.jsxs)(`label`,{className:`flex flex-col items-center gap-0.5 cursor-pointer pointer-events-auto`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`h-3 w-3 cursor-pointer accent-neutral-600`,checked:i,onChange:e=>{o(e.target.checked)}}),(0,G.jsxs)(`span`,{className:`text-[8px] uppercase tracking-widest text-neutral-400 text-center leading-tight`,children:[`enable`,(0,G.jsx)(`br`,{}),`frames`]})]})]}),p.map(e=>(0,G.jsx)(Ab,{frame:e,framesEnabled:i},e.api_name))]})]})},vx=()=>{let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(!1),o=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=window.open;return window.open=e=>(o.current?.openNewTab(String(e??``)),null),()=>{window.open=e}},[]),(0,W.useEffect)(()=>{if(!e)return;let n=setTimeout(()=>{t(null)},5e3);return()=>{clearTimeout(n)}},[e]);let s=sd(),c=zu(),{environment:l}=Iu(),u=Lu[l];return s?(0,G.jsx)(_b,{appPath:u,user:{id:s.team.user,crm_client_id:``},business:s.business,clientObject:s.business.client_object?{id:s.business.client_object.id,objectName:s.business.client_object.object_name}:void 0,teamMember:s.team,onNavigate:(e,t)=>{o.current?.navigate(e,t)},performFileUpload:({file:e,id:t,source:n,businessId:r,publicFile:i})=>(console.log(`File upload requested`,{file:e,id:t,source:n,businessId:r,publicFile:i}),new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{t({url:r.result})},r.onerror=n,r.readAsDataURL(e)})),monitoringExceptionHelper:()=>{},performRequest:async(e,t,n,r)=>{let i=n?.headers,a=r instanceof FormData||r instanceof Blob,o=r!=null&&!a?{"Content-Type":`application/json`,...i}:i,s=await c(t,{method:e.toUpperCase(),...r!=null&&{body:a?r:JSON.stringify(r)},...o!=null&&{headers:o}});return s.status===204||s.headers.get(`content-length`)===`0`?{data:{}}:{data:await s.json()}},modal:{showing:n,show:i,showPrompt:()=>{r(!0),a(!0)},onConfirm:()=>{r(!1),a(!1)},onHide:()=>{r(!1),a(!1)}},showToast:({message:e,variant:n})=>{t({message:e,variant:n??`success`})},clearToasts:()=>{t(null)},children:({showPluginModal:t,derivedModalState:n})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_x,{showingToast:e,browserRef:o}),(0,G.jsx)(lx,{show:t,config:n.config,onConfirm:n.props.onConfirm,onHide:n.props.onHide})]})}):(0,G.jsx)(C,{icon:d,className:`animate-spin text-neutral-400`,size:`2x`})},yx=({field:e,disabled:t=!1})=>{let{state:n,setState:r,evaluateExpression:i,shouldHideField:a,getFieldErrorState:o,registerFieldResetter:s,afterFieldChange:c,disabledKeys:l}=Tb(),u=n[e.key]?.value??e.default??!1,d=u===!0||u===`true`,f=l.includes(e.key)||t,p=(0,W.useCallback)(t=>{r(n=>({...n,[e.key]:{type:`boolean`,value:t}})),c(e.key)},[e.key,r,c]);if((0,W.useEffect)(()=>{s(e.key,()=>{p(void 0)})},[e.key,s,p]),(0,W.useEffect)(()=>{e.when&&i(e.when,e.key)},[e.when,i,e.key]),a(e.key))return null;let m=o(e.key);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>{p(e.target.checked)},disabled:f,className:`h-3.5 w-3.5 cursor-pointer accent-blue-600`}),(0,G.jsxs)(`span`,{className:`text-[13px] ${f?`text-neutral-400`:`text-neutral-700`}`,children:[e.label,e.required&&(0,G.jsx)(`span`,{className:`text-red-500 ml-0.5`,children:`*`})]}),e.tooltip&&(0,G.jsx)(`span`,{className:`text-[11px] text-neutral-400`,title:e.tooltip,children:`?`})]}),m?.showMessage&&m.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:m.message})]})},bx=({field:e,pluginApiName:t,disabled:n=!1})=>{let{evaluateExpression:r,shouldHideField:i}=Tb(),a=e.columns??1;return(0,W.useEffect)(()=>{e.when&&r(e.when,e.key)},[e.when,r,e.key]),i(e.key)?null:(0,G.jsxs)(`div`,{children:[e.label&&(0,G.jsx)(`h3`,{className:`text-[14px] font-semibold text-neutral-800 mb-3 mt-4`,children:e.label}),(0,G.jsx)(`div`,{className:`gap-4`,style:{display:`grid`,gridTemplateColumns:`repeat(${String(a)}, 1fr)`},children:e.fields?.map(e=>(0,G.jsx)(Cx,{field:e,pluginApiName:t,disabled:n},e.key))})]})},xx=({field:e})=>e.label?(0,G.jsxs)(`label`,{className:`text-[12px] font-medium text-neutral-600`,children:[e.label,e.required&&(0,G.jsx)(`span`,{className:`text-red-500 ml-0.5`,children:`*`}),e.tooltip&&(0,G.jsx)(`span`,{className:`ml-1 text-neutral-400 cursor-help`,title:e.tooltip,children:`?`})]}):null,Sx={container:bx,custom_object:({field:e,disabled:t=!1})=>{let{state:n,setState:r,getNestedFields:i,reInferFieldsForObject:a,evaluateExpression:o,shouldHideField:s,shouldDisableField:c,getFieldErrorState:l,registerFieldResetter:u,afterFieldChange:d,disabledKeys:f}=Tb(),p=n[e.key]?.value,m=f.includes(e.key)||t,h=c(e.key)||m,[g,_]=(0,W.useState)(p?.objectName??``),[v,y]=(0,W.useState)([]),[b,x]=(0,W.useState)(!1),S=(0,W.useRef)(null),C=zu(),w=sd(),T=(0,W.useCallback)(async e=>{x(!0);try{let t=new URLSearchParams({page_size:`20`});e&&t.set(`search`,e);let n=await(await C(`/custom-objects?${t.toString()}`)).json(),r=(Array.isArray(n)?n:n.results??[]).map(e=>({id:e.id,label:e.object_name})),i=w?.business.client_object;i?.access&&(!e||i.object_name.toLowerCase().includes(e.toLowerCase()))&&r.unshift({id:i.id,label:i.object_name}),y(r)}catch{y([])}finally{x(!1)}},[C,w]),E=(0,W.useCallback)(t=>{_(t),p&&(r(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key))),d(e.key)),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{T(t)},300)},[p,e.key,r,d,T]),D=(0,W.useCallback)((t,n)=>{_(n),r(r=>({...r,[e.key]:{type:`custom_object`,value:{id:t,objectName:n}}}));let o=i().filter(t=>t.object_id?.includes(e.key));for(let e of o)r(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key)));a(e.key),d(e.key)},[e.key,r,i,a,d]);if((0,W.useEffect)(()=>{u(e.key,()=>{r(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key))),_(``)})},[e.key,u,r]),(0,W.useEffect)(()=>{e.when&&o(e.when,e.key)},[e.when,o,e.key]),s(e.key))return null;let O=l(e.key);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(xx,{field:e}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(Nb,{value:g,onChange:E,onSelect:D,options:v,loading:b,placeholder:e.placeholder??`Search for an object...`,disabled:h}),p&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>{r(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key))),_(``),d(e.key)},disabled:h,className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-neutral-400 hover:text-neutral-600`,"aria-label":`Clear selection`,children:`×`})]}),O?.showMessage&&O.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:O.message})]})},field:({field:e,disabled:t=!1})=>{let{interpolateValue:n,state:r,setState:i,evaluateExpression:a,shouldHideField:o,getFieldErrorState:s,registerFieldResetter:c,afterFieldChange:l,disabledKeys:u}=Tb(),d=u.includes(e.key)||t,f=n(e.object_id??``),[p,m]=(0,W.useState)([]),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(null),x=zu();(0,W.useEffect)(()=>{!f||f===y||o(e.key)||(async()=>{v(!0);try{g((await(await x(`/custom-objects/${f}`)).json()).object_name??``);let e=await(await x(`/custom-objects/${f}/fields`)).json();m((Array.isArray(e)?e:e.results??[]).map(e=>({label:e.display_name,value:e.id}))),b(f)}catch{m([])}finally{v(!1)}})()},[f,y,x,e.key,o]);let S=r[e.key]?.value,C=(0,W.useCallback)(t=>{i(n=>({...n,[e.key]:{type:`field`,value:t,associatedObject:{id:f,name:h}}})),l(e.key)},[e.key,i,f,h,l]);if((0,W.useEffect)(()=>{c(e.key,()=>{i(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key)))})},[e.key,c,i]),(0,W.useEffect)(()=>{e.when&&a(e.when,e.key)},[e.when,a,e.key]),o(e.key))return null;let w=s(e.key),T=!f||d;if(e.allow_multiple){let t=Array.isArray(S)?S:[];return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(xx,{field:e}),(0,G.jsx)(`div`,{className:`rounded border p-2 text-[13px] ${w?.error?`border-red-300`:`border-black/10`} ${T?`bg-neutral-50`:`bg-white`}`,children:_?(0,G.jsx)(`span`,{className:`text-neutral-400 text-[12px]`,children:`Loading fields...`}):f?p.length===0?(0,G.jsx)(`span`,{className:`text-neutral-400 text-[12px]`,children:`No fields available`}):(0,G.jsx)(`div`,{className:`flex flex-col gap-1 max-h-48 overflow-y-auto`,children:p.map(e=>{let n=t.some(t=>t.value===e.value);return(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,disabled:T,onChange:()=>{C(n?t.filter(t=>t.value!==e.value):[...t,e])},className:`h-3 w-3 accent-blue-600`}),(0,G.jsx)(`span`,{className:`text-[12px]`,children:e.label})]},e.value)})}):(0,G.jsx)(`span`,{className:`text-neutral-400 text-[12px]`,children:`Select an object first`})}),w?.showMessage&&w.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:w.message})]})}let E=S&&!Array.isArray(S)?S.value:``;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(xx,{field:e}),_?(0,G.jsx)(`div`,{className:`w-full rounded border border-black/10 px-2 py-1.5 text-[12px] text-neutral-400 bg-neutral-50`,children:`Loading fields...`}):(0,G.jsxs)(`select`,{value:E,onChange:e=>{let t=p.find(t=>t.value===e.target.value);t&&C(t)},disabled:T,className:`w-full rounded border px-2 py-1.5 text-[13px] font-mono focus:outline-none focus:ring-1 ${w?.error?`border-red-300 focus:ring-red-400`:`border-black/10 focus:ring-blue-400`} ${T?`bg-neutral-50 text-neutral-400`:`bg-white`}`,children:[(0,G.jsx)(`option`,{value:``,children:f?`Choose a field`:`Select an object first`}),p.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),w?.showMessage&&w.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:w.message})]})},text:({field:e,disabled:t=!1})=>{let{state:n,setState:r,evaluateExpression:i,shouldHideField:a,getFieldErrorState:o,registerFieldResetter:s,afterFieldChange:c,disabledKeys:l}=Tb(),[u,d]=(0,W.useState)(n[e.key]?.value??e.default??``),f=l.includes(e.key)||t,p=(0,W.useCallback)(t=>{r(n=>({...n,[e.key]:{type:`text`,value:t}})),c(e.key)},[e.key,r,c]);if((0,W.useEffect)(()=>{s(e.key,()=>{d(``),p(``)})},[e.key,s,p]),(0,W.useEffect)(()=>{let e=setTimeout(()=>{p(u)},300);return()=>{clearTimeout(e)}},[u,p]),(0,W.useEffect)(()=>{e.when&&i(e.when,e.key)},[e.when,i,e.key]),a(e.key))return null;let m=o(e.key);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(xx,{field:e}),(0,G.jsx)(`input`,{type:`text`,value:u,onChange:e=>{d(e.target.value)},placeholder:e.placeholder??e.default??`Enter text`,disabled:f,className:`rounded border px-2 py-1.5 text-[13px] font-mono focus:outline-none focus:ring-1 ${m?.error?`border-red-300 focus:ring-red-400`:`border-black/10 focus:ring-blue-400`} ${f?`bg-neutral-50 text-neutral-400`:`bg-white`}`}),m?.showMessage&&m.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:m.message})]})},description:({field:e})=>{let{evaluateExpression:t,shouldHideField:n}=Tb();return(0,W.useEffect)(()=>{e.when&&t(e.when,e.key)},[e.when,t,e.key]),n(e.key)?null:(0,G.jsx)(`div`,{className:`text-[13px] text-neutral-500 leading-relaxed`,children:e.content})},number:({field:e,disabled:t=!1})=>{let{state:n,setState:r,evaluateExpression:i,shouldHideField:a,getFieldErrorState:o,registerFieldResetter:s,afterFieldChange:c,disabledKeys:l}=Tb(),u=n[e.key]?.value??e.default??``,[d,f]=(0,W.useState)(String(u)),p=l.includes(e.key)||t,m=(0,W.useCallback)(t=>{r(n=>({...n,[e.key]:{type:`number`,value:t}})),c(e.key)},[e.key,r,c]);if((0,W.useEffect)(()=>{s(e.key,()=>{f(``),m(``)})},[e.key,s,m]),(0,W.useEffect)(()=>{let e=setTimeout(()=>{m(d)},300);return()=>{clearTimeout(e)}},[d,m]),(0,W.useEffect)(()=>{e.when&&i(e.when,e.key)},[e.when,i,e.key]),a(e.key))return null;let h=o(e.key);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(xx,{field:e}),(0,G.jsx)(`input`,{type:`number`,value:d,onChange:e=>{f(e.target.value)},placeholder:e.placeholder??e.default??`Enter a number`,disabled:p,className:`rounded border px-2 py-1.5 text-[13px] font-mono focus:outline-none focus:ring-1 ${h?.error?`border-red-300 focus:ring-red-400`:`border-black/10 focus:ring-blue-400`} ${p?`bg-neutral-50 text-neutral-400`:`bg-white`}`}),h?.showMessage&&h.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:h.message})]})},select:({field:e,pluginApiName:t,disabled:n=!1})=>{let{state:r,setState:i,evaluateExpression:a,shouldHideField:o,getFieldErrorState:s,inferencePending:c,initialExpressionsPending:l,expressionsIdle:u,afterFieldChange:d,registerFieldResetter:f,disabledKeys:p}=Tb(),m=!c&&!l&&u,[h,g]=(0,W.useState)([]),[_,v]=(0,W.useState)(!1),y=(0,W.useRef)(null),b=!!(e.getFetchUrl??e.optionMapper),x=r[e.key]?.value,S=p.includes(e.key)||n,C=zu(),w=(0,W.useCallback)(t=>{i(n=>({...n,[e.key]:{type:`select`,value:t}})),d(e.key)},[d,e.key,i]);(0,W.useEffect)(()=>{f(e.key,()=>{i(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key)))})},[e.key,f,i]),(0,W.useEffect)(()=>{e.when&&a(e.when,e.key)},[e.when,a,e.key]);let T=(0,W.useMemo)(()=>JSON.stringify(r),[r]);if((0,W.useEffect)(()=>{!b||!m||o(e.key)||y.current===T||(async()=>{v(!0),y.current=T;try{let n={__kizen_state:{value:{...r,pluginApiName:t}}},i;if(e.getFetchUrl){let t=await _y(e.getFetchUrl,n);if(t){let r=e.fetchMethod??`GET`,a={"Content-Type":`application/json`},o=null;if(e.getHeaders&&(a=await yy(e.getHeaders,n)),r===`POST`&&e.getBody){let t=await yy(e.getBody,n);o=JSON.stringify(t)}if(t.startsWith(`/`))i={data:await(await C(t,{method:r,headers:a,...o!=null&&{body:o}})).json()};else{let e=await fetch(t,{method:r,headers:a,...o!=null&&{body:o}});e.ok&&(i=await e.json())}}}if(e.optionMapper){let n=await vy(e.optionMapper,{__kizen_state:{value:{...r,result:i,pluginApiName:t}}});g(structuredClone(n))}else Array.isArray(i)&&g(i)}catch{g([])}finally{v(!1)}})()},[b,m,T,r,e,t,C,o]),o(e.key))return null;let E=s(e.key),D=b?h:e.options??[];if(e.allow_multiple){let t=Array.isArray(x)?x:[];return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(xx,{field:e}),(0,G.jsx)(`div`,{className:`rounded border p-2 text-[13px] ${E?.error?`border-red-300`:`border-black/10`} ${S?`bg-neutral-50`:`bg-white`}`,children:_?(0,G.jsx)(`span`,{className:`text-neutral-400 text-[12px]`,children:`Loading options...`}):D.length===0?(0,G.jsx)(`span`,{className:`text-neutral-400 text-[12px]`,children:`No options available`}):(0,G.jsx)(`div`,{className:`flex flex-col gap-1 max-h-48 overflow-y-auto`,children:D.map(e=>{let n=t.some(t=>t.value===e.value);return(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,disabled:S,onChange:()=>{w(n?t.filter(t=>t.value!==e.value):[...t,e])},className:`h-3 w-3 accent-blue-600`}),(0,G.jsx)(`span`,{className:`text-[12px]`,children:e.label})]},e.value)})})}),E?.showMessage&&E.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:E.message})]})}let O=x&&!Array.isArray(x)?x.value:``;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(xx,{field:e}),_?(0,G.jsx)(`div`,{className:`w-full rounded border border-black/10 px-2 py-1.5 text-[12px] text-neutral-400 bg-neutral-50`,children:`Loading options...`}):(0,G.jsxs)(`select`,{value:O,onChange:e=>{let t=D.find(t=>t.value===e.target.value);t&&w(t)},disabled:S,className:`w-full rounded border px-2 py-1.5 text-[13px] font-mono focus:outline-none focus:ring-1 ${E?.error?`border-red-300 focus:ring-red-400`:`border-black/10 focus:ring-blue-400`} ${S?`bg-neutral-50 text-neutral-400`:`bg-white`}`,children:[(0,G.jsx)(`option`,{value:``,children:e.placeholder??`Choose an option`}),D.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),E?.showMessage&&E.message&&(0,G.jsx)(`span`,{className:`text-[11px] text-red-500`,children:E.message})]})},boolean:yx},Cx=({field:e,pluginApiName:t,disabled:n=!1})=>{let r=Sx[e.type];return(0,G.jsx)(r,{field:e,pluginApiName:t,disabled:n})},wx=({apiName:e})=>{let t=fx(e),[n,r]=(0,W.useState)(t?.__kizen_clean_config?JSON.stringify(t.__kizen_clean_config,null,2):`{}`),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,G.jsx)(`p`,{className:`text-[13px] text-neutral-500 m-0`,children:`No setup assistant defined. Enter configuration as JSON.`})}),(0,G.jsx)(`textarea`,{value:n,onChange:e=>{r(e.target.value),a(null),s(!1)},spellCheck:!1,className:`w-full min-h-[300px] rounded border p-3 text-[13px] font-mono leading-relaxed focus:outline-none focus:ring-1 ${i?`border-red-300 focus:ring-red-400`:`border-black/10 focus:ring-blue-400`}`}),i&&(0,G.jsxs)(`span`,{className:`text-[12px] text-red-500`,children:[`Parse error: `,i]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>{try{mx(e,JSON.parse(n)),a(null),s(!0),setTimeout(()=>{s(!1)},2e3)}catch(e){a(e instanceof Error?e.message:`Invalid JSON`),s(!1)}},className:`rounded bg-blue-600 px-4 py-1.5 text-[13px] font-medium text-white hover:bg-blue-700 active:bg-blue-800`,children:`Save Configuration`}),(0,G.jsx)(`button`,{onClick:()=>{hx(e),r(`{}`),a(null),s(!1)},className:`rounded border border-black/10 px-4 py-1.5 text-[13px] font-medium text-neutral-600 hover:bg-neutral-50 active:bg-neutral-100`,children:`Reset`}),o&&(0,G.jsx)(`span`,{className:`text-[12px] text-green-600 font-medium`,children:`Saved`})]})]})},Tx=({config:e,apiName:t})=>{let n=fx(t)?.__kizen_setup_assistant_values,r=(0,W.useRef)({}),[i,a]=(0,W.useState)(!1),o=zu(),s=sd(),c=(0,W.useCallback)(async e=>{try{let t=await(await o(`/api/custom-objects?filters=${encodeURIComponent(JSON.stringify({api_name:e}))}`)).json(),n=Array.isArray(t)?t:t.results;if(n&&n.length>0)return n}catch{}let t=s?.business.client_object;if(t?.access&&t.name===e)return[{id:t.id,object_name:t.object_name}]},[o,s]),l=(0,W.useCallback)(async e=>{try{let[t,n]=await Promise.all([o(`/api/custom-objects/${e}`),o(`/api/custom-objects/${e}/fields`)]),r=await t.json(),i=await n.json(),a=Array.isArray(i)?i:i.results??[];return{id:e,objectName:r.object_name??``,fields:a.map(e=>({id:e.id,name:e.name,displayName:e.display_name}))}}catch{return{id:e,objectName:``,fields:[]}}},[o]),u=(0,W.useCallback)(e=>{r.current=e},[]);return(0,G.jsx)(wb,{config:e,value:n,onStateChange:u,disabledKeys:[],getObjectByAPIName:c,getCustomObjectDetails:l,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.fields?.map(e=>(0,G.jsx)(Cx,{field:e,pluginApiName:t},e.key)),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,G.jsx)(`button`,{onClick:()=>{let n=r.current;px(t,n,e),a(!0),setTimeout(()=>{a(!1)},2e3)},className:`rounded bg-blue-600 px-4 py-1.5 text-[13px] font-medium text-white hover:bg-blue-700 active:bg-blue-800`,children:`Save Configuration`}),(0,G.jsx)(`button`,{onClick:()=>{hx(t),window.location.reload()},className:`rounded border border-black/10 px-4 py-1.5 text-[13px] font-medium text-neutral-600 hover:bg-neutral-50 active:bg-neutral-100`,children:`Reset`}),i&&(0,G.jsx)(`span`,{className:`text-[12px] text-green-600 font-medium`,children:`Saved`})]})]})})},Ex=({config:e,apiName:t})=>{let n=sd(),r=zu(),{environment:i}=Iu(),a=Lu[i],[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(!1);return n?(0,G.jsx)(_b,{appPath:a,user:{id:n.team.user,crm_client_id:``},business:n.business,clientObject:n.business.client_object?{id:n.business.client_object.id,objectName:n.business.client_object.object_name}:void 0,teamMember:n.team,onNavigate:()=>{},performFileUpload:()=>Promise.resolve({url:``}),monitoringExceptionHelper:()=>{},performRequest:async(e,t,n,i)=>{let a=n?.headers,o=i instanceof FormData||i instanceof Blob,s=i!=null&&!o?{"Content-Type":`application/json`,...a}:a,c=await r(t,{method:e.toUpperCase(),...i!=null&&{body:o?i:JSON.stringify(i)},...s!=null&&{headers:s}});return c.status===204||c.headers.get(`content-length`)===`0`?{data:{}}:{data:await c.json()}},modal:{showing:o,show:c,showPrompt:()=>{s(!0),l(!0)},onConfirm:()=>{s(!1),l(!1)},onHide:()=>{s(!1),l(!1)}},showToast:()=>{},clearToasts:()=>{},children:()=>(0,G.jsx)(Tx,{config:e,apiName:t})}):(0,G.jsx)(C,{icon:d,className:`animate-spin text-neutral-400`})},Dx=()=>{let{apiName:e}=Sc({strict:!1}),{data:t,isLoading:n,isError:r}=ju(Nu);if(n)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-neutral-400`,children:`Fetching bundle.json…`})});if(r)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`m-0 text-[13px] text-red-700`,children:`Could not load bundle.json.`})});let i=t?.find(t=>t.api_name===e);if(!i)return(0,G.jsx)(J,{children:(0,G.jsxs)(`p`,{className:`m-0 text-[13px] text-neutral-500`,children:[`No app found with api_name`,` `,(0,G.jsx)(`code`,{className:`rounded bg-neutral-100 px-1 py-0.5`,children:e}),`.`]})});let a=i.base_config?.setup_assistant,o=(a?.fields?.length??0)>0;return(0,G.jsx)(J,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-[15px] font-bold text-neutral-900 m-0`,children:`Configuration`}),(0,G.jsx)(`p`,{className:`text-[12px] text-neutral-400 m-0 mt-1`,children:o?`Configure the setup assistant fields for this plugin app.`:`Enter plugin configuration as JSON.`})]}),o&&a?(0,G.jsx)(Ex,{config:a,apiName:e??``}):(0,G.jsx)(wx,{apiName:e??``})]})})},Ox=()=>{let{apiName:e}=Sc({from:`/$apiName/versions`}),{data:t,isLoading:n,isError:r}=ju(Nu);if(n)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`text-[13px] text-neutral-400`,children:`Loading...`})});if(r||!t)return(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`text-[13px] text-red-500`,children:`Error loading bundle.`})});let i=t.find(t=>t.api_name===e),a=i?.version??``,o=Array.isArray(i?.allReleaseNotes)?i.allReleaseNotes:[];return o.length===0?(0,G.jsx)(J,{children:(0,G.jsx)(`p`,{className:`text-[13px] text-neutral-400`,children:`No release notes found.`})}):(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:o.map(({version:e,notes:t})=>(0,G.jsxs)(J,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`rounded bg-neutral-100 px-2 py-0.5 text-[11px] font-semibold tracking-wide text-neutral-600`,children:[`v`,e]}),e===a&&(0,G.jsx)(`span`,{className:`rounded bg-green-100 px-2 py-0.5 text-[11px] font-semibold tracking-wide text-green-700`,children:`current`})]}),(0,G.jsx)(`div`,{className:`mb-3 border-t border-black/5`}),(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-[12px] leading-relaxed text-neutral-700`,children:t})]},e))})},kx=Uc({component:dd}),Ax=Vc({getParentRoute:()=>kx,path:`/`,component:fd}),jx=Vc({getParentRoute:()=>kx,path:`/$apiName/summary`,component:Bg}),Mx=Vc({getParentRoute:()=>kx,path:`/$apiName/sandbox`,component:vx}),Nx=Vc({getParentRoute:()=>kx,path:`/$apiName/configuration`,component:Dx}),Px=Vc({getParentRoute:()=>kx,path:`/$apiName/versions`,component:Ox}),Fx=rl({routeTree:kx.addChildren([Ax,jx,Mx,Nx,Px])}),Ix=document.getElementById(`root`),Lx=new mu;if(Ix===null)throw Error(`Root element not found`);(0,Mu.createRoot)(Ix).render((0,G.jsx)(W.StrictMode,{children:(0,G.jsx)(_u,{client:Lx,children:(0,G.jsx)(ol,{router:Fx})})}));
|