@jhxdev/express 0.1.2 → 0.1.3

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.
Files changed (3) hide show
  1. package/index.cjs +1 -1
  2. package/index.js +1 -1
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var M=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Ee=Object.prototype.hasOwnProperty;var a=(e,o)=>M(e,"name",{value:o,configurable:!0});var we=(e,o)=>{for(var t in o)M(e,t,{get:o[t],enumerable:!0})},je=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of Je(o))!Ee.call(e,r)&&r!==t&&M(e,r,{get:()=>o[r],enumerable:!(n=ve(o,r))||n.enumerable});return e};var qe=e=>je(M({},"__esModule",{value:!0}),e);var Xe={};we(Xe,{applyAttributes:()=>le,attributesToString:()=>L,createJhx:()=>Ne,createJhxComponent:()=>Ie,defaultConfig:()=>Y,htmx:()=>$});module.exports=qe(Xe);var q={onAbort:"hx-on--abort",onAfterOnLoad:"hx-on--after-on-load",onAfterProcessNode:"hx-on--after-process-node",onAfterRequest:"hx-on--after-request",onAfterSettle:"hx-on--after-settle",onAfterSwap:"hx-on--after-swap",onBeforeCleanupElement:"hx-on--before-cleanup-element",onBeforeOnLoad:"hx-on--before-on-load",onBeforeProcessNode:"hx-on--before-process-node",onBeforeRequest:"hx-on--before-request",onBeforeSwap:"hx-on--before-swap",onBeforeSend:"hx-on--before-send",onBeforeTransition:"hx-on--before-transition",onConfigRequest:"hx-on--config-request",onConfirm:"hx-on--confirm",onHistoryCacheError:"hx-on--history-cache-error",onHistoryCacheHit:"hx-on--history-cache-hit",onHistoryCacheMiss:"hx-on--history-cache-miss",onHistoryCacheMissLoadError:"hx-on--history-cache-miss-load-error",onHistoryCacheMissLoad:"hx-on--history-cache-miss-load",onHistoryRestore:"hx-on--history-restore",onBeforeHistorySave:"hx-on--before-history-save",onLoad:"hx-on--load",onNoSSESourceError:"hx-on--no-sse-source-error",onOnLoadError:"hx-on--on-load-error",onOobAfterSwap:"hx-on--oob-after-swap",onOobBeforeSwap:"hx-on--oob-before-swap",onOobErrorNoTarget:"hx-on--oob-error-no-target",onPrompt:"hx-on--prompt",onPushedIntoHistory:"hx-on--pushed-into-history",onReplacedInHistory:"hx-on--replaced-in-history",onResponseError:"hx-on--response-error",onSendAbort:"hx-on--send-abort",onSendError:"hx-on--send-error",onSseError:"hx-on--sse-error",onSseOpen:"hx-on--sse-open",onSwapError:"hx-on--swap-error",onTargetError:"hx-on--target-error",onTimeout:"hx-on--timeout",onValidateUrl:"hx-on--validate-url",onValidationValidate:"hx-on--validation-validate",onValidationFailed:"hx-on--validation-failed",onValidationHalted:"hx-on--validation-halted",onXhrAbort:"hx-on--xhr-abort",onXhrLoadend:"hx-on--xhr-loadend",onXhrLoadstart:"hx-on--xhr-loadstart",onXhrProgress:"hx-on--xhr-progress"};var K={get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch",pushUrl:"hx-push-url",select:"hx-select",selectOob:"hx-select-oob",swap:"hx-swap",swapOob:"hx-swap-oob",target:"hx-target",trigger:"hx-trigger",vals:"hx-vals",boost:"hx-boost",confirm:"hx-confirm",disable:"hx-disable",disabledElt:"hx-disabled-elt",disinherit:"hx-disinherit",encoding:"hx-encoding",ext:"hx-ext",headers:"hx-headers",history:"hx-history",historyElt:"hx-history-elt",include:"hx-include",indicator:"hx-indicator",inherit:"hx-inherit",params:"hx-params",preserve:"hx-preserve",prompt:"hx-prompt",replaceUrl:"hx-replace-url",request:"hx-request",sync:"hx-sync",validate:"hx-validate",vars:"hx-vars",...q};var Z={added:"htmx-added",indicator:"htmx-indicator",request:"htmx-request",settling:"htmx-settling",swapping:"htmx-swapping"};var Q={addedClass:"hx-added",allowEval:!0,allowNestedOobSwaps:!0,allowScriptTags:!0,attributesToSettle:["class","style","width","height"],defaultFocusScroll:!1,defaultSettleDelay:20,defaultSwapDelay:0,defaultSwapStyle:"innerHTML",disableInheritance:!1,disableSelector:"[hx-disable], [data-hx-disable]",getCacheBusterParam:!1,globalViewTransitions:!1,historyCacheSize:10,historyEnabled:!0,historyRestoreAsHxRequest:!0,ignoreTitle:!1,includeIndicatorStyles:!0,indicatorClass:"hx-indicator",inlineScriptNonce:"",inlineStyleNonce:"",methodsThatUseUrlParams:["get","delete"],refreshOnHistoryMiss:!1,requestClass:"htmx-request",responseHandling:[{code:"204",swap:!1},{code:"[23]..",swap:!0},{code:"[45]..",swap:!1,error:!0}],scrollBehavior:"instant",scrollIntoViewOnBoost:!0,selfRequestsOnly:!0,settlingClass:"htmx-settling",swappingClass:"htmx-swapping",timeout:0,triggerSpecsCache:null,withCredentials:!1,wsBinaryType:"blob",wsReconnectDelay:"full-jitter"};var ee={abort:"htmx:abort",afterOnLoad:"htmx:afterOnLoad",afterProcessNode:"htmx:afterProcessNode",afterRequest:"htmx:afterRequest",afterSettle:"htmx:afterSettle",afterSwap:"htmx:afterSwap",beforeCleanupElement:"htmx:beforeCleanupElement",beforeOnLoad:"htmx:beforeOnLoad",beforeProcessNode:"htmx:beforeProcessNode",beforeRequest:"htmx:beforeRequest",beforeSwap:"htmx:beforeSwap",beforeSend:"htmx:beforeSend",beforeTransition:"htmx:beforeTransition",configRequest:"htmx:configRequest",confirm:"htmx:confirm",historyCacheError:"htmx:historyCacheError",historyCacheHit:"htmx:historyCacheHit",historyCacheMiss:"htmx:historyCacheMiss",historyCacheMissLoadError:"htmx:historyCacheMissLoadError",historyCacheMissLoad:"htmx:historyCacheMissLoad",historyRestore:"htmx:historyRestore",beforeHistorySave:"htmx:beforeHistorySave",load:"htmx:load",noSSESourceError:"htmx:noSSESourceError",onLoadError:"htmx:onLoadError",oobAfterSwap:"htmx:oobAfterSwap",oobBeforeSwap:"htmx:oobBeforeSwap",oobErrorNoTarget:"htmx:oobErrorNoTarget",prompt:"htmx:prompt",pushedIntoHistory:"htmx:pushedIntoHistory",replacedInHistory:"htmx:replacedInHistory",responseError:"htmx:responseError",sendAbort:"htmx:sendAbort",sendError:"htmx:sendError",sseError:"htmx:sseError",sseOpen:"htmx:sseOpen",swapError:"htmx:swapError",targetError:"htmx:targetError",timeout:"htmx:timeout",validateUrl:"htmx:validateUrl",validationValidate:"htmx:validation:validate",validationFailed:"htmx:validation:failed",validationHalted:"htmx:validation:halted",xhrAbort:"htmx:xhr:abort",xhrLoadend:"htmx:xhr:loadend",xhrLoadstart:"htmx:xhr:loadstart",xhrProgress:"htmx:xhr:progress"};var te={headSupport:{name:"head-support",version:"2.0.5",npm:"htmx-ext-head-support",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.5",integrity:"sha384-cvMqHzjCJsOHgGuyB3sWXaUSv/Krm0BdzjuI1rtkjCbL1l1oHJx+cHyVRJhyuEz0"}]},htmx1Compat:{name:"htmx-1-compat",version:"2.0.2",npm:"htmx-ext-htmx-1-compat",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-htmx-1-compat@2.0.2",integrity:"sha384-lcvVWaNjF5zPPUeeWmC0OkJ2MLqoWLlkAabuGm+EuMSTfGo5WRyHrNaAp0cJr9Pg"}]},idiomorph:{name:"morph",version:"0.7.4",npm:"idiomorph",cdn:[{url:"https://unpkg.com/idiomorph@0.7.4/dist/idiomorph-ext.min.js",integrity:"sha384-SsScJKzATF/w6suEEdLbgYGsYFLzeKfOA6PY+/C5ZPxOSuA+ARquqtz/BZz9JWU8"}]},preload:{name:"preload",version:"2.1.2",npm:"htmx-ext-preload",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.2",integrity:"sha384-PRIcY6hH1Y5784C76/Y8SqLyTanY9rnI3B8F3+hKZFNED55hsEqMJyqWhp95lgfk"}]},responseTargets:{name:"response-targets",version:"2.0.4",npm:"htmx-ext-response-targets",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.4",integrity:"sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg"}]},sse:{name:"sse",version:"2.2.4",npm:"htmx-ext-sse",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.4",integrity:"sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N"}]},ws:{name:"ws",version:"2.0.4",npm:"htmx-ext-ws",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.4",integrity:"sha384-1RwI/nvUSrMRuNj7hX1+27J8XDdCoSLf0EjEyF69nacuWyiJYoQ/j39RT1mSnd2G"}]}};var re={GET:"hx-get",POST:"hx-post",PUT:"hx-put",DELETE:"hx-delete",PATCH:"hx-patch",get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch"};var oe={boosted:"HX-Boosted",currentUrl:"HX-Current-URL",historyRestoreRequest:"HX-History-Restore-Request",prompt:"HX-Prompt",request:"HX-Request",target:"HX-Target",triggerName:"HX-Trigger-Name",trigger:"HX-Trigger"};var ne={location:"HX-Location",pushUrl:"HX-Push-URL",redirect:"HX-Redirect",refresh:"HX-Refresh",replaceUrl:"HX-Replace-URL",reswap:"HX-Reswap",retarget:"HX-Retarget",reselect:"HX-Reselect",trigger:"HX-Trigger",triggerAfterSettle:"HX-Trigger-After-Settle",triggerAfterSwap:"HX-Trigger-After-Swap"};var se={innerHTML:"innerHTML",outerHTML:"outerHTML",textContent:"textContent",beforeBegin:"beforebegin",afterBegin:"afterbegin",beforeEnd:"beforeend",afterEnd:"afterend",delete:"delete",none:"none"};var ae={drop:"drop",abort:"abort",replace:"replace",queue:"queue",queueAll:"queue all",queueFirst:"queue first",queueLast:"queue last"};var $={attr:K,config:Q,css:Z,event:ee,eventAttr:q,ext:te,method:re,res:ne,req:oe,swap:se,sync:ae};var Ae=a(e=>{let o=/^(?:async\s*)?function\*?\s*(?:[A-z0-9]+)?\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)\s*\{((?:[^}{]+|\{(?:[^}{]+|\{[^}{]*})*})*)}$/s,t=e.match(o);if(t&&t[2])return{fnType:"normal",fullMatch:t[0],paramStr:t[1]??"",bodyStr:`{ ${t[2].trim()} }`};let n=/^(?:async\s*)?(?:\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)|([^\s=()]+))\s*=>\s*(.*)$/s,r=e.match(n);if(r&&r[3]){let s=r[3].trim();return{fnType:"arrow",fullMatch:r[0],paramStr:r[1]??"",bodyStr:s.startsWith("{")&&(s.endsWith("}")||s.endsWith("};"))?s:`{ return ${s} }`}}return null},"matchFunctionString"),Ce=a(e=>{if(!e)return[];let o=[],t=0,n=0,r=0,s=0;for(let i=0;i<e.length;i++){let T=e[i];T==="("?t++:T===")"?t--:T==="{"?n++:T==="}"?n--:T==="["?r++:T==="]"?r--:T===","&&t===0&&n===0&&r===0&&(o.push(e.substring(s,i).trim()),s=i+1)}return o.push(e.substring(s).trim()),o.filter(Boolean)},"splitParams"),A=a(e=>{if(typeof e!="function"||typeof e?.toString!="function")return null;let o=e.toString(),t=Ae(o);return t?{params:Ce(t.paramStr),body:t.bodyStr}:null},"extractFunction");var ie=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let t in e){if(t in q||!t.startsWith("on"))continue;let n=e[t];if(!n)continue;let r=A(n);r&&(o[t.toLowerCase()]=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`)}return o},"convertDomEventAttributes");var P=class e extends Error{static{a(this,"JhxErrorThrowable")}attribute;constructor(o,t){super(o),this.name="JhxError",this.attribute=t.attribute,t.stack&&(this.stack=t.stack),t.cause&&(this.cause=t.cause),Object.setPrototypeOf(this,e.prototype)}};var he=a((e,o)=>typeof o=="string"?`${e}:${o}`:"window"in o?`${e}:window:${o.position}`:"selector"in o?`${e}:${o.selector}:${o.position}`:"","processScrollOrShow"),B=a(e=>{if(!e)return;if(typeof e=="string")return e;let o=[];return e.style&&o.push(String(e.style)),e.swap&&o.push(`swap:${e.swap}`),e.settle&&o.push(`settle:${e.settle}`),typeof e.transition=="boolean"&&o.push(`transition:${e.transition}`),e.scroll&&o.push(he("scroll",e.scroll)),e.show&&o.push(he("show",e.show)),e.ignoreTitle&&o.push("ignoreTitle:true"),typeof e.focusScroll=="boolean"&&o.push(`focus-scroll:${e.focusScroll}`),o.filter(Boolean).join(" ")},"toJhxSwapAttribute");var D=a(e=>{if(!e)return;let o=Array.isArray(e)?e:[e],t=!1,n=o.map(r=>{if(typeof r!="object")return r;if(r.inherit!==void 0){if(!r.inherit)return;t=!0;return}if(r.position==="this"||r.position==="next"||r.position==="previous")return r.position;let s=[];return typeof r?.position=="string"&&s.push(r.position),typeof r.selector=="string"&&s.push(r.selector),s.join(" ")});return t&&n.unshift("inherit"),n.filter(r=>!!r).join(", ")},"toJhxTargetAttribute");var $e=a(e=>{if(e){if(typeof e=="object"){if(e.op==="this"||e.op==="document"||e.op==="window")return e.op;if(typeof e.selector=="string"&&typeof e.op=="string")return`${e.op} ${e.selector}`}return String(e)}},"toJhxFromAttribute"),xe=a(e=>typeof e=="string"?e:(Array.isArray(e)?e:[e]).map(t=>{if(typeof t=="string")return t;if(typeof t=="object"){let n=`${t.event||""}${t.filter?`[${t.filter}]`:""}`,r=[];return t.once===!0&&r.push("once"),t.changed===!0&&r.push("changed"),t.consume===!0&&r.push("consume"),t.delay&&r.push(`delay:${t.delay}`),t.from&&r.push(`from:${$e(t.from)}`),t.target&&r.push(`target:${D(t.target)}`),t.throttle&&r.push(`throttle:${t.throttle}`),t.queue&&r.push(`queue:${t.queue}`),n.concat(n?" ":"",r.join(" "))}return""}).filter(Boolean).join(", "),"toJhxTriggerAttribute");var Pe=["get","post","put","patch","delete","route"],de=a((e,o)=>{let t={};if(!e||typeof e!="object")return t;let n=Pe.find(r=>!!e[r]);if(n)if(n==="route"){let r=e.method?.toLowerCase()||"get";t[`hx-${r}`]=String(e.route)}else t[`hx-${n}`]=String(e[n]);else e.method&&o.logger.warn("[jhx] The 'method' prop must be paired with a 'route' prop to generate a request attribute.");if(e.boost===!0&&(t["hx-boost"]="true"),e.confirm&&(t["hx-confirm"]=e.confirm),e.disable===!0&&(t["hx-disable"]="true"),e.disabledElt){let r=D(e.disabledElt);r&&(t["hx-disabled-elt"]=r)}if(e.disinherit&&(Array.isArray(e.disinherit)?t["hx-disinherit"]=e.disinherit.join(" "):t["hx-disinherit"]=e.disinherit),e.encoding&&(t["hx-encoding"]=e.encoding),e.ext){typeof e.ext=="string"&&(t["hx-ext"]=e.ext);let s=(Array.isArray(e.ext)?e.ext:[e.ext]).map(i=>typeof i=="object"?`${i?.name&&i.ignore===!0?"ignore:":""}${i?.name}`:i).filter(Boolean).join(",");s&&(t["hx-ext"]=s)}if(e.headers)if(typeof e.headers=="object")try{t["hx-headers"]=`${JSON.stringify(e.headers)}`}catch(r){throw o.logger.error("[jhx] Error while parsing the `hx-headers` object."),new P("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-headers",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.headers=="function"){let r=A(e.headers);if(r){let s=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`;t["hx-vals"]=`js:{...${s}}`}}else t["hx-headers"]=e.headers;if(e.history===!1&&(t["hx-history"]="false"),e.historyElt===!0&&(t["hx-history-elt"]="true"),e.indicator)if(typeof e.indicator=="object"){let r=e.indicator.inherit===!0?"inherit, ":"",s=e.indicator.closest===!0?"closest ":"";t["hx-indicator"]=`${r}${s}${e.indicator.selector}`}else t["hx-indicator"]=e.indicator;if(e.include){let r=D(e.include);r&&(t["hx-include"]=r)}if(e.inherit&&(Array.isArray(e.inherit)?t["hx-inherit"]=e.inherit.join(" "):t["hx-inherit"]=e.inherit),e.params&&(typeof e.params=="object"?e.params.include&&Array.isArray(e.params.include)?t["hx-params"]=`${e.params.include.join(",")}`:e.params.exclude&&Array.isArray(e.params.exclude)&&(t["hx-params"]=`not ${e.params.exclude.join(",")}`):t["hx-params"]=e.params),e.preserve===!0&&(t["hx-preserve"]="true"),e.prompt&&(t["hx-prompt"]=e.prompt),e.pushUrl&&(e.pushUrl===!0?t["hx-push-url"]="true":t["hx-push-url"]=e.pushUrl),(e.replaceUrl||e.replaceUrl===!1)&&(typeof e.replaceUrl=="boolean"?t["hx-replace-url"]=e.replaceUrl?"true":"false":t["hx-replace-url"]=e.replaceUrl),e.request)if(typeof e.request=="object")try{t["hx-request"]=`${JSON.stringify(e.request)}`}catch(r){throw new P("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-request",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.request=="function"){let r=A(e.request);if(r){let i=`(({ timeout, credentials, noHeaders }) => ({ timeout, credentials, noHeaders }))(${`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`})`;t["hx-request"]=`js: ${i}`}}else t["hx-request"]=e.request;if(e.select&&(t["hx-select"]=e.select),e.selectOob)if(Array.isArray(e.selectOob))t["hx-select-oob"]=e.selectOob.map(r=>{if(typeof r=="string")return r;if(typeof r=="object"&&r.selector){let s=B(r.swap);return`${r.selector}${s?":"+s:""}`}return""}).filter(Boolean).join(",");else if(typeof e.selectOob=="object"){let r=B(e.selectOob.swap);t["hx-select-oob"]=`${e.selectOob.selector}${r?":"+r:""}`}else t["hx-select-oob"]=e.selectOob;if(e.swap){let r=B(e.swap);r&&(t["hx-swap"]=r)}if(e.swapOob)if(e.swapOob===!0)t["hx-swap-oob"]="true";else if(typeof e.swapOob=="object"){let r=B(e.swapOob.swap);r&&(t["hx-swap-oob"]=`${r}${e.swapOob.selector?":"+e.swapOob.selector:""}`)}else t["hx-swap-oob"]=e.swapOob;if(e.sync&&(typeof e.sync=="object"?e.sync.strategy&&e.sync.tag?t["hx-sync"]=`${e.sync.closest===!0?"closest ":""}${e.sync.tag}:${e.sync.strategy}`:e.sync.strategy&&(t["hx-sync"]=`this:${e.sync.strategy}`):t["hx-sync"]=e.sync),e.target){let r=D(e.target);r&&(t["hx-target"]=r)}if(e.trigger&&(t["hx-trigger"]=xe(e.trigger)),e.validate===!0&&(t["hx-validate"]="true"),e.vars&&(o.logger.warn("[jhx] The `hx-vars` attribute has been deprecated because of XSS vulnerabilities. Recommended to use the `hx-vals` attribute."),t["hx-vars"]=e.vars),e.vals)if(typeof e.vals=="object")try{t["hx-vals"]=`${JSON.stringify(e.vals)}`}catch(r){throw new P("[jhx] Error while parsing 'hx-vals' object",{attribute:"hx-vals",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.vals=="function"){let r=A(e.vals);if(r){let s=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`;t["hx-vals"]=`js:{...${s}}`}}else t["hx-vals"]=e.vals;return t},"convertJhxAttributes");var pe=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let t in q)if(Object.prototype.hasOwnProperty.call(e,t)){let n=q[t],r=e[t];if(!r)continue;let s=A(r);if(!s)continue;o[n]=`((${s.params.join(",")}) => ${s.body})(${s.params.join(",")})`}return o},"convertJhxEventAttributes");var De={'"':"&quot;","<":"&lt;",">":"&gt;"},U=a(e=>String(e).replace(/["<>]/g,o=>De[o]??o),"escapeValue");var L=a((e,o=!0)=>Object.entries(e).map(([t,n])=>typeof n=="object"?`${t}="${JSON.stringify(n)}"`:`${t}="${typeof n=="string"&&o?U(n):n}"`).filter(Boolean).join(" "),"attributesToString");var F={logger:console,stringify:!1,escape:!0};var ue=a(e=>{let o={};for(let[t,n]of Object.entries(e))o[t]=typeof n=="string"?U(n):n;return o},"escapeAttributes");function N(e,o){let t={...F,...o??{}},n={...de(e,t),...pe(e),...ie(e)};return t.stringify===!0?L(n,!!t.escape):t.escape===!0?ue(n):n}a(N,"jhx");var le=a((e,o)=>{for(let[t,n]of Object.entries(o))typeof n=="object"?e.setAttribute(t,JSON.stringify(n)):e.setAttribute(t,String(n))},"applyAttributes");var J=class e extends Error{static{a(this,"JhxServerException")}type;info;method;route;cause;constructor(o,t){super(o),this.name="JhxServerError",this.type=t.type,this.info=t.info||t.cause?.message||o,this.method=t.method,this.route=t.route,this.stack=t.stack,this.cause=t.cause,Object.setPrototypeOf(this,e.prototype)}};var me=require("path");var C=a((e,o="")=>{let t=String(o).startsWith("/")?String(o):`/${o}`,n=e.trim();n=n.startsWith("/")?n:`/${n}`;let r;try{r=decodeURIComponent(n.startsWith(t)?n:`${t}/${n}`)}catch(i){throw new J("jhx: malformed endpoint",{type:"endpoint:malformed",info:i.message,route:n,cause:i})}let s=me.posix.normalize(r.startsWith("/")?r:`/${r}`);return s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1)),{noSlash:s,withSlash:s==="/"?"/":`${s}/`}},"normalizeEndpoint");var I=a((e,o,t)=>{if(t||(t=new Map),!e)return t;for(let n of e){let r=n.method?.trim()?.toUpperCase()??"GET",{noSlash:s,withSlash:i}=C(n.route,o.prefix);if(o.trailingSlash==="no-slash"){let T=`${r}::${s}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),o.onRegistered(r,s),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${s}`)}else if(o.trailingSlash==="slash"){let T=`${r}::${i}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),o.onRegistered(r,i),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${i}`)}else{let T=`${r}::${s}`,R=`${r}::${i}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});if(t.has(R))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),t.set(R,n.handler),o.onRegistered(r,s),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${s}`)}}return t},"addRoutesToMap");var z=require("react"),X=require("react-dom/server");var Oe=a((e,...o)=>(0,z.isValidElement)(e)?(0,X.renderToStaticMarkup)(e):e,"jsxToStatic"),Be=a((e,...o)=>(0,z.isValidElement)(e)?(0,X.renderToString)(e):e,"jsxToString"),ke=a((e,...o)=>e,"noRender"),fe=a(e=>e?typeof e=="function"?e:e==="static"?Oe:e==="string"?Be:ke:null,"getRenderFunction");var Me=["get","post","put","patch","delete","route"],ce=a(e=>{for(let o of Me)if(o in e){let t=e[o];return o==="route"?{method:"GET",route:typeof t=="string"&&t.trim()||null}:{method:o.toUpperCase(),route:typeof t=="string"&&t.trim()||null}}return{method:"GET",route:null}},"getRouteFromProps");var Te=require("crypto");var Re=a(e=>{if(typeof e?.toString!="function")throw new J("jhx: invalid route error",{type:"hash:invalid",info:"Cannot hash function without a 'toString' method"});return(0,Te.createHash)("sha256").update(e.toString()).digest("hex").slice(0,12)},"hashFunction");var W=a(e=>{let o=[];if(!e)return o;for(let t of Array.isArray(e)?e:[e]){if(t.method&&t.method.trim()==="")throw new J("jhx: route validation error",{type:"route:invalid-method",info:`Invalid route method: '${t.method}'`,method:String(t.method)});if(!t.route||t.route?.trim()==="")throw new J("jhx: route validation error",{type:"route:invalid-path",info:`Invalid route endpoint: '${t.route}'`,method:t.method?.toUpperCase()??"GET",route:String(t.route)});if(!t.handler||typeof t.handler!="function")throw new J("jhx: route validation error",{type:"route:invalid-handler",info:`Invalid route handler for '${t.method?.toUpperCase()??"GET"} ${t.route}'`,method:t.method?.toUpperCase()??"GET",route:t.route});o.push({method:t.method?.toUpperCase()??"GET",route:t.route,handler:t.handler})}return o},"validateRoutes");var Ue=a(e=>e.startsWith("hx-")||e in $.attr||e in $.eventAttr||e==="route"||e==="method"||e==="handler","isJhxAttribute"),V=a(e=>a(function(t){let{jhxConfig:n,as:r,children:s,...i}=t,T=r??"div",R={};for(let[b,g]of Object.entries(i))Ue(b)||(R[b]=g);let y={...e(i,{...n,stringify:!1}),...R};return<T{...y}>{s}</T>},"JhxComponent"),"createJhxComponent");var ye=require("react"),ge=require("react-dom/server");var E={...F,contentType:"text/html",debug:!1,middleware:[],onRegistered:a(((e,o)=>{}),"onRegistered"),prefix:"/_jhx",render:a((e,...o)=>(0,ye.isValidElement)(e)?(0,ge.renderToString)(e):e,"render"),renderError:!0,renderMiddleware:!0,renderNotFound:!0,trailingSlash:"both"};var be=a((e,o,t)=>{let n={contentType:e.contentType===!1?!1:e.contentType??E.contentType,debug:e.debug===E.debug,errorHandler:e.errorHandler,middleware:Array.isArray(e.middleware)?e.middleware:e.middleware?[e.middleware]:E.middleware,notFoundHandler:e.notFoundHandler?e.notFoundHandler:o,onRegistered:e.onRegistered??E.onRegistered,logger:e.logger??E.logger,prefix:e.prefix?C(e.prefix).noSlash:E.prefix,render:typeof e.render=="function"?e.render:fe(e.render===void 0?"string":e.render),renderError:typeof e.renderError=="boolean"?e.renderError:E.renderError,renderMiddleware:typeof e.renderMiddleware=="boolean"?e.renderMiddleware:E.renderMiddleware,renderNotFound:typeof e.renderNotFound=="boolean"?e.renderNotFound:E.renderNotFound,stringify:typeof e.stringify=="boolean"?e.stringify:E.stringify,trailingSlash:e.trailingSlash??E.trailingSlash,instanceOptions:e.instanceOptions},r=e.routes?I(W(e.routes),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash}):new Map;t(n,r);function s(i,T){if(typeof i=="object"&&typeof i.handler=="function"){let{method:y,route:b}=ce(i),{noSlash:g,withSlash:S}=C(b||Re(i.handler),n.prefix);if(n.trailingSlash==="no-slash"){let v=`${y}::${g}`;r.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${y} ${g}`),r.set(v,i.handler),n.onRegistered(y,g)),i.method=y,i.route=g}else if(n.trailingSlash==="slash"){let v=`${y}::${S}`;r.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${y} ${S}`),r.set(v,i.handler),n.onRegistered(y,S)),i.method=y,i.route=S}else{let v=`${y}::${g}`,w=`${y}::${S}`;!r.has(v)&&!r.has(w)&&(n.debug&&n.logger.info(`[jhx] Added new route: ${y} ${g}`),r.set(v,i.handler),r.set(w,i.handler),n.onRegistered(y,g)),i.method=y,i.route=g}}let R=T?.stringify??n.stringify,H=i&&typeof i=="object"&&"handler"in i?(({handler:y,...b})=>b)(i):i;return R?N(H,{logger:T?.logger??n.logger,stringify:!0}):N(H,{logger:T?.logger??n.logger,stringify:!1})}return a(s,"jhx"),s.addRoute=i=>{I(W({method:i.method,route:i.route,handler:i.handler}),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},r)},s.addRoutes=i=>{I(W(i),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},r)},s.clearRoutes=()=>{let i=r.size;r.clear(),n.debug&&n.logger.info(`[jhx] Cleared ${i} route${i===1?"":"s"}`)},s.getRoute=(i,T)=>{let R=i.trim().toUpperCase(),{noSlash:H,withSlash:y}=C(T,n.prefix);if(n.trailingSlash==="no-slash"){let b=`${R}::${H}`,g=r.get(b);return g?{method:R,route:H,handler:g}:null}else if(n.trailingSlash==="slash"){let b=r.get(`${R}::${y}`);return b?{method:R,route:y,handler:b}:null}else{let b=r.get(`${R}::${H}`),g=r.get(`${R}::${y}`);if(!b&&!g)return null;let S=T.endsWith("/");return{method:R,route:S?g?y:H:b?H:y,handler:S?g??b:b??g}}},s.getRoutes=()=>Array.from(r.entries()).map(([i,T])=>{let[R,H]=i.split("::");return!R||!H?null:{method:R,route:H,handler:T}}).filter(i=>i!==null),s.hasRoute=(i,T)=>{let{noSlash:R,withSlash:H}=C(T,n.prefix);return r.has(`${i.toUpperCase()}::${R}`)||r.has(`${i.toUpperCase()}::${H}`)},s.removeRoute=(i,T)=>{let R=i.trim().toUpperCase(),{noSlash:H,withSlash:y}=C(T,n.prefix),b;return n.trailingSlash==="no-slash"?b=r.delete(`${R}::${H}`):n.trailingSlash==="slash"?b=r.delete(`${R}::${y}`):(b=r.delete(`${R}::${H}`),b=r.delete(`${R}::${y}`)||b),b&&n.debug?n.logger.info(`[jhx] Removed route: ${R} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?y:`${H} / ${y}`}`):!b&&n.debug&&n.logger.info(`[jhx] Cannot remove unknown route: ${R} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?y:`${H} / ${y}`}`),b},{jhx:s,JhxComponent:V(s)}},"createServerJhx");var He=require("node:stream");var G=a(e=>e!==null&&typeof e=="object"&&typeof e.send=="function"&&typeof e.status=="function"&&typeof e.json=="function"&&"headersSent"in e,"isExpressResponse"),_=a(e=>!!(e&&(e.headersSent===!0||e.finished===!0||e.writableEnded===!0)),"isResponseSent"),Le=a(e=>e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray||e instanceof BigUint64Array||typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)||typeof Buffer<"u"&&e instanceof Buffer,"isArrayBuffer"),Fe=a(e=>e.split("-").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("-"),"capitalize"),k=a((e,o,t)=>{let n=Fe(o);!e.getHeader(n)&&!e.getHeader(o.toLowerCase())&&e.header(n,t)},"ensureHeader"),j=a(async(e,o)=>{if(!(G(o)||_(e))){if(o instanceof Blob){o.type&&k(e,"Content-Type",o.type),o.size>=0&&k(e,"Content-Length",String(o.size));let t=await o.arrayBuffer();e.send(Buffer.from(t));return}o instanceof FormData?k(e,"Content-Type","multipart/form-data"):o instanceof Response||o instanceof ReadableStream||o instanceof He.Stream||Le(o)?k(e,"Content-Type","application/octet-stream"):typeof o=="object"&&o!==null&&k(e,"Content-Type","application/json"),e.send(o)}},"sendPayload");var O=a((e,o)=>_(e)||o===e||G(o),"isResponseHandled");var Y={...E,notFoundHandler:a((e,o)=>{o.status(404).send()},"notFoundHandler")};var Ne=a((e,o={})=>be(o,Y.notFoundHandler,(t,n)=>{e.all(`${t.prefix}{*splat}`,async(r,s,i)=>{let T=r.method.toUpperCase(),R=decodeURIComponent(r.url.split("?")[0]),H=n.get(`${T}::${R}`);if(t.contentType&&s.header("content-type",t.contentType),H){for(let g of t.middleware)try{let S=await g(r,s);if(O(s,S))return await j(s,S);if(S!==void 0){let v=t.render&&t.renderMiddleware?await t.render(S,r,s):S;return await j(s,v)}}catch(S){let v=S;if(t.debug&&t.logger.error(`[jhx] Middleware error from '${T} ${R}': ${S.message}`),t.errorHandler){s.status(500);let w=await t.errorHandler(v,r,s);if(O(s,w))return await j(s,w);let Se=t.render&&t.renderError?await t.render(w,r,s):w;return await j(s,Se)}throw new J("Unexpected jhx middleware error",{type:"middleware:error",info:"Unhandled error while handling middleware or rendering middleware payload",method:T,route:R,cause:v})}try{let g=await H(r,s);if(O(s,g))return await j(s,g);let S=t.render?await t.render(g,r,s):g;return await j(s,S)}catch(g){let S=g;if(t.debug&&t.logger.error(`[jhx] Route error from '${T} ${R}': ${g.message}`),t.errorHandler){s.status(500);let v=await t.errorHandler(S,r,s);if(O(s,v))return await j(s,v);let w=t.render&&t.renderError?await t.render(v,r,s):v;return await j(s,w)}throw new J("Unexpected jhx route error",{type:"handler:error",info:"Unhandled error while handling route or rendering route payload",method:T,route:R,cause:S})}}t.debug&&t.logger.info(`[jhx] Request to unknown route '${T} ${R}' from IP address '${r.ip}'`),s.status(404);let y=await t.notFoundHandler(r,s);if(O(s,y))return;let b=t.render&&t.renderNotFound?await t.render(y,r,s):y;return await j(s,b)})}),"createJhx");var Ie=a(e=>V(e),"createJhxComponent");0&&(module.exports={applyAttributes,attributesToString,createJhx,createJhxComponent,defaultConfig,htmx});
1
+ "use strict";var M=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var i=(e,o)=>M(e,"name",{value:o,configurable:!0});var je=(e,o)=>{for(var t in o)M(e,t,{get:o[t],enumerable:!0})},Ce=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of Ee(o))!we.call(e,r)&&r!==t&&M(e,r,{get:()=>o[r],enumerable:!(n=Je(o,r))||n.enumerable});return e};var Ae=e=>Ce(M({},"__esModule",{value:!0}),e);var We={};je(We,{applyAttributes:()=>fe,attributesToString:()=>L,createJhx:()=>Ie,createJhxComponent:()=>Xe,defaultConfig:()=>Y,htmx:()=>$});module.exports=Ae(We);var C={onAbort:"hx-on--abort",onAfterOnLoad:"hx-on--after-on-load",onAfterProcessNode:"hx-on--after-process-node",onAfterRequest:"hx-on--after-request",onAfterSettle:"hx-on--after-settle",onAfterSwap:"hx-on--after-swap",onBeforeCleanupElement:"hx-on--before-cleanup-element",onBeforeOnLoad:"hx-on--before-on-load",onBeforeProcessNode:"hx-on--before-process-node",onBeforeRequest:"hx-on--before-request",onBeforeSwap:"hx-on--before-swap",onBeforeSend:"hx-on--before-send",onBeforeTransition:"hx-on--before-transition",onConfigRequest:"hx-on--config-request",onConfirm:"hx-on--confirm",onHistoryCacheError:"hx-on--history-cache-error",onHistoryCacheHit:"hx-on--history-cache-hit",onHistoryCacheMiss:"hx-on--history-cache-miss",onHistoryCacheMissLoadError:"hx-on--history-cache-miss-load-error",onHistoryCacheMissLoad:"hx-on--history-cache-miss-load",onHistoryRestore:"hx-on--history-restore",onBeforeHistorySave:"hx-on--before-history-save",onLoad:"hx-on--load",onNoSSESourceError:"hx-on--no-sse-source-error",onOnLoadError:"hx-on--on-load-error",onOobAfterSwap:"hx-on--oob-after-swap",onOobBeforeSwap:"hx-on--oob-before-swap",onOobErrorNoTarget:"hx-on--oob-error-no-target",onPrompt:"hx-on--prompt",onPushedIntoHistory:"hx-on--pushed-into-history",onReplacedInHistory:"hx-on--replaced-in-history",onResponseError:"hx-on--response-error",onSendAbort:"hx-on--send-abort",onSendError:"hx-on--send-error",onSseError:"hx-on--sse-error",onSseOpen:"hx-on--sse-open",onSwapError:"hx-on--swap-error",onTargetError:"hx-on--target-error",onTimeout:"hx-on--timeout",onValidateUrl:"hx-on--validate-url",onValidationValidate:"hx-on--validation-validate",onValidationFailed:"hx-on--validation-failed",onValidationHalted:"hx-on--validation-halted",onXhrAbort:"hx-on--xhr-abort",onXhrLoadend:"hx-on--xhr-loadend",onXhrLoadstart:"hx-on--xhr-loadstart",onXhrProgress:"hx-on--xhr-progress"};var K={get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch",pushUrl:"hx-push-url",select:"hx-select",selectOob:"hx-select-oob",swap:"hx-swap",swapOob:"hx-swap-oob",target:"hx-target",trigger:"hx-trigger",vals:"hx-vals",boost:"hx-boost",confirm:"hx-confirm",disable:"hx-disable",disabledElt:"hx-disabled-elt",disinherit:"hx-disinherit",encoding:"hx-encoding",ext:"hx-ext",headers:"hx-headers",history:"hx-history",historyElt:"hx-history-elt",include:"hx-include",indicator:"hx-indicator",inherit:"hx-inherit",params:"hx-params",preserve:"hx-preserve",prompt:"hx-prompt",replaceUrl:"hx-replace-url",request:"hx-request",sync:"hx-sync",validate:"hx-validate",vars:"hx-vars",...C};var Q={added:"htmx-added",indicator:"htmx-indicator",request:"htmx-request",settling:"htmx-settling",swapping:"htmx-swapping"};var Z={addedClass:"hx-added",allowEval:!0,allowNestedOobSwaps:!0,allowScriptTags:!0,attributesToSettle:["class","style","width","height"],defaultFocusScroll:!1,defaultSettleDelay:20,defaultSwapDelay:0,defaultSwapStyle:"innerHTML",disableInheritance:!1,disableSelector:"[hx-disable], [data-hx-disable]",getCacheBusterParam:!1,globalViewTransitions:!1,historyCacheSize:10,historyEnabled:!0,historyRestoreAsHxRequest:!0,ignoreTitle:!1,includeIndicatorStyles:!0,indicatorClass:"hx-indicator",inlineScriptNonce:"",inlineStyleNonce:"",methodsThatUseUrlParams:["get","delete"],refreshOnHistoryMiss:!1,requestClass:"htmx-request",responseHandling:[{code:"204",swap:!1},{code:"[23]..",swap:!0},{code:"[45]..",swap:!1,error:!0}],scrollBehavior:"instant",scrollIntoViewOnBoost:!0,selfRequestsOnly:!0,settlingClass:"htmx-settling",swappingClass:"htmx-swapping",timeout:0,triggerSpecsCache:null,withCredentials:!1,wsBinaryType:"blob",wsReconnectDelay:"full-jitter"};var ee={abort:"htmx:abort",afterOnLoad:"htmx:afterOnLoad",afterProcessNode:"htmx:afterProcessNode",afterRequest:"htmx:afterRequest",afterSettle:"htmx:afterSettle",afterSwap:"htmx:afterSwap",beforeCleanupElement:"htmx:beforeCleanupElement",beforeOnLoad:"htmx:beforeOnLoad",beforeProcessNode:"htmx:beforeProcessNode",beforeRequest:"htmx:beforeRequest",beforeSwap:"htmx:beforeSwap",beforeSend:"htmx:beforeSend",beforeTransition:"htmx:beforeTransition",configRequest:"htmx:configRequest",confirm:"htmx:confirm",historyCacheError:"htmx:historyCacheError",historyCacheHit:"htmx:historyCacheHit",historyCacheMiss:"htmx:historyCacheMiss",historyCacheMissLoadError:"htmx:historyCacheMissLoadError",historyCacheMissLoad:"htmx:historyCacheMissLoad",historyRestore:"htmx:historyRestore",beforeHistorySave:"htmx:beforeHistorySave",load:"htmx:load",noSSESourceError:"htmx:noSSESourceError",onLoadError:"htmx:onLoadError",oobAfterSwap:"htmx:oobAfterSwap",oobBeforeSwap:"htmx:oobBeforeSwap",oobErrorNoTarget:"htmx:oobErrorNoTarget",prompt:"htmx:prompt",pushedIntoHistory:"htmx:pushedIntoHistory",replacedInHistory:"htmx:replacedInHistory",responseError:"htmx:responseError",sendAbort:"htmx:sendAbort",sendError:"htmx:sendError",sseError:"htmx:sseError",sseOpen:"htmx:sseOpen",swapError:"htmx:swapError",targetError:"htmx:targetError",timeout:"htmx:timeout",validateUrl:"htmx:validateUrl",validationValidate:"htmx:validation:validate",validationFailed:"htmx:validation:failed",validationHalted:"htmx:validation:halted",xhrAbort:"htmx:xhr:abort",xhrLoadend:"htmx:xhr:loadend",xhrLoadstart:"htmx:xhr:loadstart",xhrProgress:"htmx:xhr:progress"};var te={headSupport:{name:"head-support",version:"2.0.5",npm:"htmx-ext-head-support",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.5",integrity:"sha384-cvMqHzjCJsOHgGuyB3sWXaUSv/Krm0BdzjuI1rtkjCbL1l1oHJx+cHyVRJhyuEz0"}]},htmx1Compat:{name:"htmx-1-compat",version:"2.0.2",npm:"htmx-ext-htmx-1-compat",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-htmx-1-compat@2.0.2",integrity:"sha384-lcvVWaNjF5zPPUeeWmC0OkJ2MLqoWLlkAabuGm+EuMSTfGo5WRyHrNaAp0cJr9Pg"}]},idiomorph:{name:"morph",version:"0.7.4",npm:"idiomorph",cdn:[{url:"https://unpkg.com/idiomorph@0.7.4/dist/idiomorph-ext.min.js",integrity:"sha384-SsScJKzATF/w6suEEdLbgYGsYFLzeKfOA6PY+/C5ZPxOSuA+ARquqtz/BZz9JWU8"}]},preload:{name:"preload",version:"2.1.2",npm:"htmx-ext-preload",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.2",integrity:"sha384-PRIcY6hH1Y5784C76/Y8SqLyTanY9rnI3B8F3+hKZFNED55hsEqMJyqWhp95lgfk"}]},responseTargets:{name:"response-targets",version:"2.0.4",npm:"htmx-ext-response-targets",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.4",integrity:"sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg"}]},sse:{name:"sse",version:"2.2.4",npm:"htmx-ext-sse",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.4",integrity:"sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N"}]},ws:{name:"ws",version:"2.0.4",npm:"htmx-ext-ws",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.4",integrity:"sha384-1RwI/nvUSrMRuNj7hX1+27J8XDdCoSLf0EjEyF69nacuWyiJYoQ/j39RT1mSnd2G"}]}};var re={GET:"hx-get",POST:"hx-post",PUT:"hx-put",DELETE:"hx-delete",PATCH:"hx-patch",get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch"};var oe={boosted:"HX-Boosted",currentUrl:"HX-Current-URL",historyRestoreRequest:"HX-History-Restore-Request",prompt:"HX-Prompt",request:"HX-Request",target:"HX-Target",triggerName:"HX-Trigger-Name",trigger:"HX-Trigger"};var ne={location:"HX-Location",pushUrl:"HX-Push-URL",redirect:"HX-Redirect",refresh:"HX-Refresh",replaceUrl:"HX-Replace-URL",reswap:"HX-Reswap",retarget:"HX-Retarget",reselect:"HX-Reselect",trigger:"HX-Trigger",triggerAfterSettle:"HX-Trigger-After-Settle",triggerAfterSwap:"HX-Trigger-After-Swap"};var se={innerHTML:"innerHTML",outerHTML:"outerHTML",textContent:"textContent",beforeBegin:"beforebegin",afterBegin:"afterbegin",beforeEnd:"beforeend",afterEnd:"afterend",delete:"delete",none:"none"};var ae={drop:"drop",abort:"abort",replace:"replace",queue:"queue",queueAll:"queue all",queueFirst:"queue first",queueLast:"queue last"};var $={attr:K,config:Z,css:Q,event:ee,eventAttr:C,ext:te,method:re,res:ne,req:oe,swap:se,sync:ae};var ie=i(e=>{let o=[],t=0;for(;t<e.length;){let n=e[t];if(n==="`"){let r=t;for(t++;t<e.length;)if(e[t]==="\\")t+=2;else if(e[t]==="`"){t++;break}else t++;o.push(e.slice(r,t));continue}if(n==='"'){t++;let r=[],s=!1;for(;t<e.length;)if(e[t]==="\\"){let T=e[t+1];r.push(e[t],T??""),t+=2}else if(e[t]==='"'){t++;break}else e[t]==="$"&&e[t+1]==="{"&&(s=!0),r.push(e[t]),t++;let a=r.join("");if(s){o.push("`");for(let T=0;T<a.length;T++)if(a[T]==="\\"){let g=a[T+1];g==='"'?(o.push('"'),T++):g==="`"?(o.push("\\`"),T++):(o.push(a[T],g??""),T++)}else a[T]==="`"?o.push("\\`"):o.push(a[T]);o.push("`")}else{o.push("'");for(let T=0;T<a.length;T++)if(a[T]==="\\"){let g=a[T+1];g==='"'?(o.push('"'),T++):g==="'"?(o.push("\\'"),T++):(o.push(a[T],g??""),T++)}else a[T]==="'"?o.push("\\'"):o.push(a[T]);o.push("'")}continue}if(n==="'"){let r=t;for(t++;t<e.length;)if(e[t]==="\\")t+=2;else if(e[t]==="'"){t++;break}else t++;o.push(e.slice(r,t));continue}if(n==="/"&&t>0){let r=e.slice(0,t).trimEnd().slice(-1);if(["=","(",",","[","!","&","|",":",";","{","}","?"].includes(r)){let a=t;t++;let T=!1;for(;t<e.length;)if(e[t]==="\\")t+=2;else if(e[t]==="[")T=!0,t++;else if(e[t]==="]")T=!1,t++;else if(e[t]==="/"&&!T){for(t++;t<e.length&&/[gimsuy]/.test(e[t]);)t++;break}else t++;o.push(e.slice(a,t));continue}}o.push(n),t++}return o.join("")},"normalizeStringQuotes");var qe=i(e=>{let o=/^(?:async\s*)?function\*?\s*(?:[A-z0-9]+)?\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)\s*\{((?:[^}{]+|\{(?:[^}{]+|\{[^}{]*})*})*)}$/s,t=e.match(o);if(t&&t[2])return{fnType:"normal",fullMatch:t[0],paramStr:t[1]??"",bodyStr:`{ ${t[2].trim()} }`};let n=/^(?:async\s*)?(?:\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)|([^\s=()]+))\s*=>\s*(.*)$/s,r=e.match(n);if(r&&r[3]){let s=r[3].trim();return{fnType:"arrow",fullMatch:r[0],paramStr:r[1]??"",bodyStr:s.startsWith("{")&&(s.endsWith("}")||s.endsWith("};"))?s:`{ return ${s} }`}}return null},"matchFunctionString"),$e=i(e=>{if(!e)return[];let o=[],t=0,n=0,r=0,s=0;for(let a=0;a<e.length;a++){let T=e[a];T==="("?t++:T===")"?t--:T==="{"?n++:T==="}"?n--:T==="["?r++:T==="]"?r--:T===","&&t===0&&n===0&&r===0&&(o.push(e.substring(s,a).trim()),s=a+1)}return o.push(e.substring(s).trim()),o.filter(Boolean)},"splitParams"),A=i(e=>{if(typeof e!="function"||typeof e?.toString!="function")return null;let o=e.toString().replaceAll("void 0","undefined"),t=qe(o);return t?{params:$e(t.paramStr),body:ie(t.bodyStr)}:null},"extractFunction");var he=i(e=>{let o={};if(!e||typeof e!="object")return o;for(let t in e){if(t in C||!t.startsWith("on"))continue;let n=e[t];if(!n)continue;let r=A(n);r&&(o[t.toLowerCase()]=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`)}return o},"convertDomEventAttributes");var P=class e extends Error{static{i(this,"JhxErrorThrowable")}attribute;constructor(o,t){super(o),this.name="JhxError",this.attribute=t.attribute,t.stack&&(this.stack=t.stack),t.cause&&(this.cause=t.cause),Object.setPrototypeOf(this,e.prototype)}};var xe=i((e,o)=>typeof o=="string"?`${e}:${o}`:"window"in o?`${e}:window:${o.position}`:"selector"in o?`${e}:${o.selector}:${o.position}`:"","processScrollOrShow"),B=i(e=>{if(!e)return;if(typeof e=="string")return e;let o=[];return e.style&&o.push(String(e.style)),e.swap&&o.push(`swap:${e.swap}`),e.settle&&o.push(`settle:${e.settle}`),typeof e.transition=="boolean"&&o.push(`transition:${e.transition}`),e.scroll&&o.push(xe("scroll",e.scroll)),e.show&&o.push(xe("show",e.show)),e.ignoreTitle&&o.push("ignoreTitle:true"),typeof e.focusScroll=="boolean"&&o.push(`focus-scroll:${e.focusScroll}`),o.filter(Boolean).join(" ")},"toJhxSwapAttribute");var D=i(e=>{if(!e)return;let o=Array.isArray(e)?e:[e],t=!1,n=o.map(r=>{if(typeof r!="object")return r;if(r.inherit!==void 0){if(!r.inherit)return;t=!0;return}if(r.position==="this"||r.position==="next"||r.position==="previous")return r.position;let s=[];return typeof r?.position=="string"&&s.push(r.position),typeof r.selector=="string"&&s.push(r.selector),s.join(" ")});return t&&n.unshift("inherit"),n.filter(r=>!!r).join(", ")},"toJhxTargetAttribute");var Pe=i(e=>{if(e){if(typeof e=="object"){if(e.op==="this"||e.op==="document"||e.op==="window")return e.op;if(typeof e.selector=="string"&&typeof e.op=="string")return`${e.op} ${e.selector}`}return String(e)}},"toJhxFromAttribute"),le=i(e=>typeof e=="string"?e:(Array.isArray(e)?e:[e]).map(t=>{if(typeof t=="string")return t;if(typeof t=="object"){let n=`${t.event||""}${t.filter?`[${t.filter}]`:""}`,r=[];return t.once===!0&&r.push("once"),t.changed===!0&&r.push("changed"),t.consume===!0&&r.push("consume"),t.delay&&r.push(`delay:${t.delay}`),t.from&&r.push(`from:${Pe(t.from)}`),t.target&&r.push(`target:${D(t.target)}`),t.throttle&&r.push(`throttle:${t.throttle}`),t.queue&&r.push(`queue:${t.queue}`),n.concat(n?" ":"",r.join(" "))}return""}).filter(Boolean).join(", "),"toJhxTriggerAttribute");var De=["get","post","put","patch","delete","route"],pe=i((e,o)=>{let t={};if(!e||typeof e!="object")return t;let n=De.find(r=>!!e[r]);if(n)if(n==="route"){let r=e.method?.toLowerCase()||"get";t[`hx-${r}`]=String(e.route)}else t[`hx-${n}`]=String(e[n]);else e.method&&o.logger.warn("[jhx] The 'method' prop must be paired with a 'route' prop to generate a request attribute.");if(e.boost===!0&&(t["hx-boost"]="true"),e.confirm&&(t["hx-confirm"]=e.confirm),e.disable===!0&&(t["hx-disable"]="true"),e.disabledElt){let r=D(e.disabledElt);r&&(t["hx-disabled-elt"]=r)}if(e.disinherit&&(Array.isArray(e.disinherit)?t["hx-disinherit"]=e.disinherit.join(" "):t["hx-disinherit"]=e.disinherit),e.encoding&&(t["hx-encoding"]=e.encoding),e.ext){typeof e.ext=="string"&&(t["hx-ext"]=e.ext);let s=(Array.isArray(e.ext)?e.ext:[e.ext]).map(a=>typeof a=="object"?`${a?.name&&a.ignore===!0?"ignore:":""}${a?.name}`:a).filter(Boolean).join(",");s&&(t["hx-ext"]=s)}if(e.headers)if(typeof e.headers=="object")try{t["hx-headers"]=`${JSON.stringify(e.headers)}`}catch(r){throw o.logger.error("[jhx] Error while parsing the `hx-headers` object."),new P("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-headers",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.headers=="function"){let r=A(e.headers);if(r){let s=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`;t["hx-vals"]=`js:{...${s}}`}}else t["hx-headers"]=e.headers;if(e.history===!1&&(t["hx-history"]="false"),e.historyElt===!0&&(t["hx-history-elt"]="true"),e.indicator)if(typeof e.indicator=="object"){let r=e.indicator.inherit===!0?"inherit, ":"",s=e.indicator.closest===!0?"closest ":"";t["hx-indicator"]=`${r}${s}${e.indicator.selector}`}else t["hx-indicator"]=e.indicator;if(e.include){let r=D(e.include);r&&(t["hx-include"]=r)}if(e.inherit&&(Array.isArray(e.inherit)?t["hx-inherit"]=e.inherit.join(" "):t["hx-inherit"]=e.inherit),e.params&&(typeof e.params=="object"?e.params.include&&Array.isArray(e.params.include)?t["hx-params"]=`${e.params.include.join(",")}`:e.params.exclude&&Array.isArray(e.params.exclude)&&(t["hx-params"]=`not ${e.params.exclude.join(",")}`):t["hx-params"]=e.params),e.preserve===!0&&(t["hx-preserve"]="true"),e.prompt&&(t["hx-prompt"]=e.prompt),e.pushUrl&&(e.pushUrl===!0?t["hx-push-url"]="true":t["hx-push-url"]=e.pushUrl),(e.replaceUrl||e.replaceUrl===!1)&&(typeof e.replaceUrl=="boolean"?t["hx-replace-url"]=e.replaceUrl?"true":"false":t["hx-replace-url"]=e.replaceUrl),e.request)if(typeof e.request=="object")try{t["hx-request"]=`${JSON.stringify(e.request)}`}catch(r){throw new P("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-request",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.request=="function"){let r=A(e.request);if(r){let a=`(({ timeout, credentials, noHeaders }) => ({ timeout, credentials, noHeaders }))(${`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`})`;t["hx-request"]=`js: ${a}`}}else t["hx-request"]=e.request;if(e.select&&(t["hx-select"]=e.select),e.selectOob)if(Array.isArray(e.selectOob))t["hx-select-oob"]=e.selectOob.map(r=>{if(typeof r=="string")return r;if(typeof r=="object"&&r.selector){let s=B(r.swap);return`${r.selector}${s?":"+s:""}`}return""}).filter(Boolean).join(",");else if(typeof e.selectOob=="object"){let r=B(e.selectOob.swap);t["hx-select-oob"]=`${e.selectOob.selector}${r?":"+r:""}`}else t["hx-select-oob"]=e.selectOob;if(e.swap){let r=B(e.swap);r&&(t["hx-swap"]=r)}if(e.swapOob)if(e.swapOob===!0)t["hx-swap-oob"]="true";else if(typeof e.swapOob=="object"){let r=B(e.swapOob.swap);r&&(t["hx-swap-oob"]=`${r}${e.swapOob.selector?":"+e.swapOob.selector:""}`)}else t["hx-swap-oob"]=e.swapOob;if(e.sync&&(typeof e.sync=="object"?e.sync.strategy&&e.sync.tag?t["hx-sync"]=`${e.sync.closest===!0?"closest ":""}${e.sync.tag}:${e.sync.strategy}`:e.sync.strategy&&(t["hx-sync"]=`this:${e.sync.strategy}`):t["hx-sync"]=e.sync),e.target){let r=D(e.target);r&&(t["hx-target"]=r)}if(e.trigger&&(t["hx-trigger"]=le(e.trigger)),e.validate===!0&&(t["hx-validate"]="true"),e.vars&&(o.logger.warn("[jhx] The `hx-vars` attribute has been deprecated because of XSS vulnerabilities. Recommended to use the `hx-vals` attribute."),t["hx-vars"]=e.vars),e.vals)if(typeof e.vals=="object")try{t["hx-vals"]=`${JSON.stringify(e.vals)}`}catch(r){throw new P("[jhx] Error while parsing 'hx-vals' object",{attribute:"hx-vals",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.vals=="function"){let r=A(e.vals);if(r){let s=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`;t["hx-vals"]=`js:{...${s}}`}}else t["hx-vals"]=e.vals;return t},"convertJhxAttributes");var de=i(e=>{let o={};if(!e||typeof e!="object")return o;for(let t in C)if(Object.prototype.hasOwnProperty.call(e,t)){let n=C[t],r=e[t];if(!r)continue;let s=A(r);if(!s)continue;o[n]=`((${s.params.join(",")}) => ${s.body})(${s.params.join(",")})`}return o},"convertJhxEventAttributes");var Oe={'"':"&quot;","<":"&lt;",">":"&gt;"},U=i(e=>String(e).replace(/["<>]/g,o=>Oe[o]??o),"escapeValue");var L=i((e,o=!0)=>Object.entries(e).map(([t,n])=>typeof n=="object"?`${t}="${JSON.stringify(n)}"`:`${t}="${typeof n=="string"&&o?U(n):n}"`).filter(Boolean).join(" "),"attributesToString");var N={logger:console,stringify:!1,escape:!0};var ue=i(e=>{let o={};for(let[t,n]of Object.entries(e))o[t]=typeof n=="string"?U(n):n;return o},"escapeAttributes");function F(e,o){let t={...N,...o??{}},n={...pe(e,t),...de(e),...he(e)};return t.stringify===!0?L(n,!!t.escape):t.escape===!0?ue(n):n}i(F,"jhx");var fe=i((e,o)=>{for(let[t,n]of Object.entries(o))typeof n=="object"?e.setAttribute(t,JSON.stringify(n)):e.setAttribute(t,String(n))},"applyAttributes");var J=class e extends Error{static{i(this,"JhxServerException")}type;info;method;route;cause;constructor(o,t){super(o),this.name="JhxServerError",this.type=t.type,this.info=t.info||t.cause?.message||o,this.method=t.method,this.route=t.route,this.stack=t.stack,this.cause=t.cause,Object.setPrototypeOf(this,e.prototype)}};var me=require("path");var q=i((e,o="")=>{let t=String(o).startsWith("/")?String(o):`/${o}`,n=e.trim();n=n.startsWith("/")?n:`/${n}`;let r;try{r=decodeURIComponent(n.startsWith(t)?n:`${t}/${n}`)}catch(a){throw new J("jhx: malformed endpoint",{type:"endpoint:malformed",info:a.message,route:n,cause:a})}let s=me.posix.normalize(r.startsWith("/")?r:`/${r}`);return s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1)),{noSlash:s,withSlash:s==="/"?"/":`${s}/`}},"normalizeEndpoint");var I=i((e,o,t)=>{if(t||(t=new Map),!e)return t;for(let n of e){let r=n.method?.trim()?.toUpperCase()??"GET",{noSlash:s,withSlash:a}=q(n.route,o.prefix);if(o.trailingSlash==="no-slash"){let T=`${r}::${s}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),o.onRegistered(r,s),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${s}`)}else if(o.trailingSlash==="slash"){let T=`${r}::${a}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),o.onRegistered(r,a),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${a}`)}else{let T=`${r}::${s}`,g=`${r}::${a}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});if(t.has(g))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),t.set(g,n.handler),o.onRegistered(r,s),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${s}`)}}return t},"addRoutesToMap");var z=require("react"),X=require("react-dom/server");var Be=i((e,...o)=>(0,z.isValidElement)(e)?(0,X.renderToStaticMarkup)(e):e,"jsxToStatic"),ke=i((e,...o)=>(0,z.isValidElement)(e)?(0,X.renderToString)(e):e,"jsxToString"),Me=i((e,...o)=>e,"noRender"),ce=i(e=>e?typeof e=="function"?e:e==="static"?Be:e==="string"?ke:Me:null,"getRenderFunction");var Ue=["get","post","put","patch","delete","route"],Te=i(e=>{for(let o of Ue)if(o in e){let t=e[o];return o==="route"?{method:"GET",route:typeof t=="string"&&t.trim()||null}:{method:o.toUpperCase(),route:typeof t=="string"&&t.trim()||null}}return{method:"GET",route:null}},"getRouteFromProps");var ge=require("crypto");var Re=i(e=>{if(typeof e?.toString!="function")throw new J("jhx: invalid route error",{type:"hash:invalid",info:"Cannot hash function without a 'toString' method"});return(0,ge.createHash)("sha256").update(e.toString()).digest("hex").slice(0,12)},"hashFunction");var W=i(e=>{let o=[];if(!e)return o;for(let t of Array.isArray(e)?e:[e]){if(t.method&&t.method.trim()==="")throw new J("jhx: route validation error",{type:"route:invalid-method",info:`Invalid route method: '${t.method}'`,method:String(t.method)});if(!t.route||t.route?.trim()==="")throw new J("jhx: route validation error",{type:"route:invalid-path",info:`Invalid route endpoint: '${t.route}'`,method:t.method?.toUpperCase()??"GET",route:String(t.route)});if(!t.handler||typeof t.handler!="function")throw new J("jhx: route validation error",{type:"route:invalid-handler",info:`Invalid route handler for '${t.method?.toUpperCase()??"GET"} ${t.route}'`,method:t.method?.toUpperCase()??"GET",route:t.route});o.push({method:t.method?.toUpperCase()??"GET",route:t.route,handler:t.handler})}return o},"validateRoutes");var Le=i(e=>e.startsWith("hx-")||e in $.attr||e in $.eventAttr||e==="route"||e==="method"||e==="handler","isJhxAttribute"),V=i(e=>i(function(t){let{jhxConfig:n,as:r,children:s,...a}=t,T=r??"div",g={};for(let[b,y]of Object.entries(a))Le(b)||(g[b]=y);let R={...e(a,{...n,stringify:!1}),...g};return<T{...R}>{s}</T>},"JhxComponent"),"createJhxComponent");var ye=require("react"),be=require("react-dom/server");var E={...N,contentType:"text/html",debug:!1,middleware:[],onRegistered:i(((e,o)=>{}),"onRegistered"),prefix:"/_jhx",render:i((e,...o)=>(0,ye.isValidElement)(e)?(0,be.renderToString)(e):e,"render"),renderError:!0,renderMiddleware:!0,renderNotFound:!0,trailingSlash:"both"};var He=i((e,o,t)=>{let n={contentType:e.contentType===!1?!1:e.contentType??E.contentType,debug:e.debug===E.debug,errorHandler:e.errorHandler,middleware:Array.isArray(e.middleware)?e.middleware:e.middleware?[e.middleware]:E.middleware,notFoundHandler:e.notFoundHandler?e.notFoundHandler:o,onRegistered:e.onRegistered??E.onRegistered,logger:e.logger??E.logger,prefix:e.prefix?q(e.prefix).noSlash:E.prefix,render:typeof e.render=="function"?e.render:ce(e.render===void 0?"string":e.render),renderError:typeof e.renderError=="boolean"?e.renderError:E.renderError,renderMiddleware:typeof e.renderMiddleware=="boolean"?e.renderMiddleware:E.renderMiddleware,renderNotFound:typeof e.renderNotFound=="boolean"?e.renderNotFound:E.renderNotFound,stringify:typeof e.stringify=="boolean"?e.stringify:E.stringify,trailingSlash:e.trailingSlash??E.trailingSlash,instanceOptions:e.instanceOptions},r=e.routes?I(W(e.routes),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash}):new Map;t(n,r);function s(a,T){if(typeof a=="object"&&typeof a.handler=="function"){let{method:R,route:b}=Te(a),{noSlash:y,withSlash:S}=q(b||Re(a.handler),n.prefix);if(n.trailingSlash==="no-slash"){let v=`${R}::${y}`;r.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${y}`),r.set(v,a.handler),n.onRegistered(R,y)),a.method=R,a.route=y}else if(n.trailingSlash==="slash"){let v=`${R}::${S}`;r.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${S}`),r.set(v,a.handler),n.onRegistered(R,S)),a.method=R,a.route=S}else{let v=`${R}::${y}`,w=`${R}::${S}`;!r.has(v)&&!r.has(w)&&(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${y}`),r.set(v,a.handler),r.set(w,a.handler),n.onRegistered(R,y)),a.method=R,a.route=y}}let g=T?.stringify??n.stringify,H=a&&typeof a=="object"&&"handler"in a?(({handler:R,...b})=>b)(a):a;return g?F(H,{logger:T?.logger??n.logger,stringify:!0}):F(H,{logger:T?.logger??n.logger,stringify:!1})}return i(s,"jhx"),s.addRoute=a=>{I(W({method:a.method,route:a.route,handler:a.handler}),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},r)},s.addRoutes=a=>{I(W(a),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},r)},s.clearRoutes=()=>{let a=r.size;r.clear(),n.debug&&n.logger.info(`[jhx] Cleared ${a} route${a===1?"":"s"}`)},s.getRoute=(a,T)=>{let g=a.trim().toUpperCase(),{noSlash:H,withSlash:R}=q(T,n.prefix);if(n.trailingSlash==="no-slash"){let b=`${g}::${H}`,y=r.get(b);return y?{method:g,route:H,handler:y}:null}else if(n.trailingSlash==="slash"){let b=r.get(`${g}::${R}`);return b?{method:g,route:R,handler:b}:null}else{let b=r.get(`${g}::${H}`),y=r.get(`${g}::${R}`);if(!b&&!y)return null;let S=T.endsWith("/");return{method:g,route:S?y?R:H:b?H:R,handler:S?y??b:b??y}}},s.getRoutes=()=>Array.from(r.entries()).map(([a,T])=>{let[g,H]=a.split("::");return!g||!H?null:{method:g,route:H,handler:T}}).filter(a=>a!==null),s.hasRoute=(a,T)=>{let{noSlash:g,withSlash:H}=q(T,n.prefix);return r.has(`${a.toUpperCase()}::${g}`)||r.has(`${a.toUpperCase()}::${H}`)},s.removeRoute=(a,T)=>{let g=a.trim().toUpperCase(),{noSlash:H,withSlash:R}=q(T,n.prefix),b;return n.trailingSlash==="no-slash"?b=r.delete(`${g}::${H}`):n.trailingSlash==="slash"?b=r.delete(`${g}::${R}`):(b=r.delete(`${g}::${H}`),b=r.delete(`${g}::${R}`)||b),b&&n.debug?n.logger.info(`[jhx] Removed route: ${g} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?R:`${H} / ${R}`}`):!b&&n.debug&&n.logger.info(`[jhx] Cannot remove unknown route: ${g} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?R:`${H} / ${R}`}`),b},{jhx:s,JhxComponent:V(s)}},"createServerJhx");var Se=require("node:stream");var G=i(e=>e!==null&&typeof e=="object"&&typeof e.send=="function"&&typeof e.status=="function"&&typeof e.json=="function"&&"headersSent"in e,"isExpressResponse"),_=i(e=>!!(e&&(e.headersSent===!0||e.finished===!0||e.writableEnded===!0)),"isResponseSent"),Ne=i(e=>e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray||e instanceof BigUint64Array||typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)||typeof Buffer<"u"&&e instanceof Buffer,"isArrayBuffer"),Fe=i(e=>e.split("-").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("-"),"capitalize"),k=i((e,o,t)=>{let n=Fe(o);!e.getHeader(n)&&!e.getHeader(o.toLowerCase())&&e.header(n,t)},"ensureHeader"),j=i(async(e,o)=>{if(!(G(o)||_(e))){if(o instanceof Blob){o.type&&k(e,"Content-Type",o.type),o.size>=0&&k(e,"Content-Length",String(o.size));let t=await o.arrayBuffer();e.send(Buffer.from(t));return}o instanceof FormData?k(e,"Content-Type","multipart/form-data"):o instanceof Response||o instanceof ReadableStream||o instanceof Se.Stream||Ne(o)?k(e,"Content-Type","application/octet-stream"):typeof o=="object"&&o!==null&&k(e,"Content-Type","application/json"),e.send(o)}},"sendPayload");var O=i((e,o)=>_(e)||o===e||G(o),"isResponseHandled");var Y={...E,notFoundHandler:i((e,o)=>{o.status(404).send()},"notFoundHandler")};var Ie=i((e,o={})=>He(o,Y.notFoundHandler,(t,n)=>{e.all(`${t.prefix}{*splat}`,async(r,s,a)=>{let T=r.method.toUpperCase(),g=decodeURIComponent(r.url.split("?")[0]),H=n.get(`${T}::${g}`);if(t.contentType&&s.header("content-type",t.contentType),H){for(let y of t.middleware)try{let S=await y(r,s);if(O(s,S))return await j(s,S);if(S!==void 0){let v=t.render&&t.renderMiddleware?await t.render(S,r,s):S;return await j(s,v)}}catch(S){let v=S;if(t.debug&&t.logger.error(`[jhx] Middleware error from '${T} ${g}': ${S.message}`),t.errorHandler){s.status(500);let w=await t.errorHandler(v,r,s);if(O(s,w))return await j(s,w);let ve=t.render&&t.renderError?await t.render(w,r,s):w;return await j(s,ve)}throw new J("Unexpected jhx middleware error",{type:"middleware:error",info:"Unhandled error while handling middleware or rendering middleware payload",method:T,route:g,cause:v})}try{let y=await H(r,s);if(O(s,y))return await j(s,y);let S=t.render?await t.render(y,r,s):y;return await j(s,S)}catch(y){let S=y;if(t.debug&&t.logger.error(`[jhx] Route error from '${T} ${g}': ${y.message}`),t.errorHandler){s.status(500);let v=await t.errorHandler(S,r,s);if(O(s,v))return await j(s,v);let w=t.render&&t.renderError?await t.render(v,r,s):v;return await j(s,w)}throw new J("Unexpected jhx route error",{type:"handler:error",info:"Unhandled error while handling route or rendering route payload",method:T,route:g,cause:S})}}t.debug&&t.logger.info(`[jhx] Request to unknown route '${T} ${g}' from IP address '${r.ip}'`),s.status(404);let R=await t.notFoundHandler(r,s);if(O(s,R))return;let b=t.render&&t.renderNotFound?await t.render(R,r,s):R;return await j(s,b)})}),"createJhx");var Xe=i(e=>V(e),"createJhxComponent");0&&(module.exports={applyAttributes,attributesToString,createJhx,createJhxComponent,defaultConfig,htmx});
package/index.js CHANGED
@@ -1 +1 @@
1
- var ce=Object.defineProperty;var a=(e,o)=>ce(e,"name",{value:o,configurable:!0});var q={onAbort:"hx-on--abort",onAfterOnLoad:"hx-on--after-on-load",onAfterProcessNode:"hx-on--after-process-node",onAfterRequest:"hx-on--after-request",onAfterSettle:"hx-on--after-settle",onAfterSwap:"hx-on--after-swap",onBeforeCleanupElement:"hx-on--before-cleanup-element",onBeforeOnLoad:"hx-on--before-on-load",onBeforeProcessNode:"hx-on--before-process-node",onBeforeRequest:"hx-on--before-request",onBeforeSwap:"hx-on--before-swap",onBeforeSend:"hx-on--before-send",onBeforeTransition:"hx-on--before-transition",onConfigRequest:"hx-on--config-request",onConfirm:"hx-on--confirm",onHistoryCacheError:"hx-on--history-cache-error",onHistoryCacheHit:"hx-on--history-cache-hit",onHistoryCacheMiss:"hx-on--history-cache-miss",onHistoryCacheMissLoadError:"hx-on--history-cache-miss-load-error",onHistoryCacheMissLoad:"hx-on--history-cache-miss-load",onHistoryRestore:"hx-on--history-restore",onBeforeHistorySave:"hx-on--before-history-save",onLoad:"hx-on--load",onNoSSESourceError:"hx-on--no-sse-source-error",onOnLoadError:"hx-on--on-load-error",onOobAfterSwap:"hx-on--oob-after-swap",onOobBeforeSwap:"hx-on--oob-before-swap",onOobErrorNoTarget:"hx-on--oob-error-no-target",onPrompt:"hx-on--prompt",onPushedIntoHistory:"hx-on--pushed-into-history",onReplacedInHistory:"hx-on--replaced-in-history",onResponseError:"hx-on--response-error",onSendAbort:"hx-on--send-abort",onSendError:"hx-on--send-error",onSseError:"hx-on--sse-error",onSseOpen:"hx-on--sse-open",onSwapError:"hx-on--swap-error",onTargetError:"hx-on--target-error",onTimeout:"hx-on--timeout",onValidateUrl:"hx-on--validate-url",onValidationValidate:"hx-on--validation-validate",onValidationFailed:"hx-on--validation-failed",onValidationHalted:"hx-on--validation-halted",onXhrAbort:"hx-on--xhr-abort",onXhrLoadend:"hx-on--xhr-loadend",onXhrLoadstart:"hx-on--xhr-loadstart",onXhrProgress:"hx-on--xhr-progress"};var z={get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch",pushUrl:"hx-push-url",select:"hx-select",selectOob:"hx-select-oob",swap:"hx-swap",swapOob:"hx-swap-oob",target:"hx-target",trigger:"hx-trigger",vals:"hx-vals",boost:"hx-boost",confirm:"hx-confirm",disable:"hx-disable",disabledElt:"hx-disabled-elt",disinherit:"hx-disinherit",encoding:"hx-encoding",ext:"hx-ext",headers:"hx-headers",history:"hx-history",historyElt:"hx-history-elt",include:"hx-include",indicator:"hx-indicator",inherit:"hx-inherit",params:"hx-params",preserve:"hx-preserve",prompt:"hx-prompt",replaceUrl:"hx-replace-url",request:"hx-request",sync:"hx-sync",validate:"hx-validate",vars:"hx-vars",...q};var G={added:"htmx-added",indicator:"htmx-indicator",request:"htmx-request",settling:"htmx-settling",swapping:"htmx-swapping"};var _={addedClass:"hx-added",allowEval:!0,allowNestedOobSwaps:!0,allowScriptTags:!0,attributesToSettle:["class","style","width","height"],defaultFocusScroll:!1,defaultSettleDelay:20,defaultSwapDelay:0,defaultSwapStyle:"innerHTML",disableInheritance:!1,disableSelector:"[hx-disable], [data-hx-disable]",getCacheBusterParam:!1,globalViewTransitions:!1,historyCacheSize:10,historyEnabled:!0,historyRestoreAsHxRequest:!0,ignoreTitle:!1,includeIndicatorStyles:!0,indicatorClass:"hx-indicator",inlineScriptNonce:"",inlineStyleNonce:"",methodsThatUseUrlParams:["get","delete"],refreshOnHistoryMiss:!1,requestClass:"htmx-request",responseHandling:[{code:"204",swap:!1},{code:"[23]..",swap:!0},{code:"[45]..",swap:!1,error:!0}],scrollBehavior:"instant",scrollIntoViewOnBoost:!0,selfRequestsOnly:!0,settlingClass:"htmx-settling",swappingClass:"htmx-swapping",timeout:0,triggerSpecsCache:null,withCredentials:!1,wsBinaryType:"blob",wsReconnectDelay:"full-jitter"};var Y={abort:"htmx:abort",afterOnLoad:"htmx:afterOnLoad",afterProcessNode:"htmx:afterProcessNode",afterRequest:"htmx:afterRequest",afterSettle:"htmx:afterSettle",afterSwap:"htmx:afterSwap",beforeCleanupElement:"htmx:beforeCleanupElement",beforeOnLoad:"htmx:beforeOnLoad",beforeProcessNode:"htmx:beforeProcessNode",beforeRequest:"htmx:beforeRequest",beforeSwap:"htmx:beforeSwap",beforeSend:"htmx:beforeSend",beforeTransition:"htmx:beforeTransition",configRequest:"htmx:configRequest",confirm:"htmx:confirm",historyCacheError:"htmx:historyCacheError",historyCacheHit:"htmx:historyCacheHit",historyCacheMiss:"htmx:historyCacheMiss",historyCacheMissLoadError:"htmx:historyCacheMissLoadError",historyCacheMissLoad:"htmx:historyCacheMissLoad",historyRestore:"htmx:historyRestore",beforeHistorySave:"htmx:beforeHistorySave",load:"htmx:load",noSSESourceError:"htmx:noSSESourceError",onLoadError:"htmx:onLoadError",oobAfterSwap:"htmx:oobAfterSwap",oobBeforeSwap:"htmx:oobBeforeSwap",oobErrorNoTarget:"htmx:oobErrorNoTarget",prompt:"htmx:prompt",pushedIntoHistory:"htmx:pushedIntoHistory",replacedInHistory:"htmx:replacedInHistory",responseError:"htmx:responseError",sendAbort:"htmx:sendAbort",sendError:"htmx:sendError",sseError:"htmx:sseError",sseOpen:"htmx:sseOpen",swapError:"htmx:swapError",targetError:"htmx:targetError",timeout:"htmx:timeout",validateUrl:"htmx:validateUrl",validationValidate:"htmx:validation:validate",validationFailed:"htmx:validation:failed",validationHalted:"htmx:validation:halted",xhrAbort:"htmx:xhr:abort",xhrLoadend:"htmx:xhr:loadend",xhrLoadstart:"htmx:xhr:loadstart",xhrProgress:"htmx:xhr:progress"};var K={headSupport:{name:"head-support",version:"2.0.5",npm:"htmx-ext-head-support",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.5",integrity:"sha384-cvMqHzjCJsOHgGuyB3sWXaUSv/Krm0BdzjuI1rtkjCbL1l1oHJx+cHyVRJhyuEz0"}]},htmx1Compat:{name:"htmx-1-compat",version:"2.0.2",npm:"htmx-ext-htmx-1-compat",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-htmx-1-compat@2.0.2",integrity:"sha384-lcvVWaNjF5zPPUeeWmC0OkJ2MLqoWLlkAabuGm+EuMSTfGo5WRyHrNaAp0cJr9Pg"}]},idiomorph:{name:"morph",version:"0.7.4",npm:"idiomorph",cdn:[{url:"https://unpkg.com/idiomorph@0.7.4/dist/idiomorph-ext.min.js",integrity:"sha384-SsScJKzATF/w6suEEdLbgYGsYFLzeKfOA6PY+/C5ZPxOSuA+ARquqtz/BZz9JWU8"}]},preload:{name:"preload",version:"2.1.2",npm:"htmx-ext-preload",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.2",integrity:"sha384-PRIcY6hH1Y5784C76/Y8SqLyTanY9rnI3B8F3+hKZFNED55hsEqMJyqWhp95lgfk"}]},responseTargets:{name:"response-targets",version:"2.0.4",npm:"htmx-ext-response-targets",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.4",integrity:"sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg"}]},sse:{name:"sse",version:"2.2.4",npm:"htmx-ext-sse",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.4",integrity:"sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N"}]},ws:{name:"ws",version:"2.0.4",npm:"htmx-ext-ws",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.4",integrity:"sha384-1RwI/nvUSrMRuNj7hX1+27J8XDdCoSLf0EjEyF69nacuWyiJYoQ/j39RT1mSnd2G"}]}};var Z={GET:"hx-get",POST:"hx-post",PUT:"hx-put",DELETE:"hx-delete",PATCH:"hx-patch",get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch"};var Q={boosted:"HX-Boosted",currentUrl:"HX-Current-URL",historyRestoreRequest:"HX-History-Restore-Request",prompt:"HX-Prompt",request:"HX-Request",target:"HX-Target",triggerName:"HX-Trigger-Name",trigger:"HX-Trigger"};var ee={location:"HX-Location",pushUrl:"HX-Push-URL",redirect:"HX-Redirect",refresh:"HX-Refresh",replaceUrl:"HX-Replace-URL",reswap:"HX-Reswap",retarget:"HX-Retarget",reselect:"HX-Reselect",trigger:"HX-Trigger",triggerAfterSettle:"HX-Trigger-After-Settle",triggerAfterSwap:"HX-Trigger-After-Swap"};var te={innerHTML:"innerHTML",outerHTML:"outerHTML",textContent:"textContent",beforeBegin:"beforebegin",afterBegin:"afterbegin",beforeEnd:"beforeend",afterEnd:"afterend",delete:"delete",none:"none"};var re={drop:"drop",abort:"abort",replace:"replace",queue:"queue",queueAll:"queue all",queueFirst:"queue first",queueLast:"queue last"};var O={attr:z,config:_,css:G,event:Y,eventAttr:q,ext:K,method:Z,res:ee,req:Q,swap:te,sync:re};var Te=a(e=>{let o=/^(?:async\s*)?function\*?\s*(?:[A-z0-9]+)?\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)\s*\{((?:[^}{]+|\{(?:[^}{]+|\{[^}{]*})*})*)}$/s,t=e.match(o);if(t&&t[2])return{fnType:"normal",fullMatch:t[0],paramStr:t[1]??"",bodyStr:`{ ${t[2].trim()} }`};let n=/^(?:async\s*)?(?:\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)|([^\s=()]+))\s*=>\s*(.*)$/s,r=e.match(n);if(r&&r[3]){let s=r[3].trim();return{fnType:"arrow",fullMatch:r[0],paramStr:r[1]??"",bodyStr:s.startsWith("{")&&(s.endsWith("}")||s.endsWith("};"))?s:`{ return ${s} }`}}return null},"matchFunctionString"),Re=a(e=>{if(!e)return[];let o=[],t=0,n=0,r=0,s=0;for(let i=0;i<e.length;i++){let T=e[i];T==="("?t++:T===")"?t--:T==="{"?n++:T==="}"?n--:T==="["?r++:T==="]"?r--:T===","&&t===0&&n===0&&r===0&&(o.push(e.substring(s,i).trim()),s=i+1)}return o.push(e.substring(s).trim()),o.filter(Boolean)},"splitParams"),A=a(e=>{if(typeof e!="function"||typeof e?.toString!="function")return null;let o=e.toString(),t=Te(o);return t?{params:Re(t.paramStr),body:t.bodyStr}:null},"extractFunction");var oe=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let t in e){if(t in q||!t.startsWith("on"))continue;let n=e[t];if(!n)continue;let r=A(n);r&&(o[t.toLowerCase()]=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`)}return o},"convertDomEventAttributes");var $=class e extends Error{static{a(this,"JhxErrorThrowable")}attribute;constructor(o,t){super(o),this.name="JhxError",this.attribute=t.attribute,t.stack&&(this.stack=t.stack),t.cause&&(this.cause=t.cause),Object.setPrototypeOf(this,e.prototype)}};var ne=a((e,o)=>typeof o=="string"?`${e}:${o}`:"window"in o?`${e}:window:${o.position}`:"selector"in o?`${e}:${o.selector}:${o.position}`:"","processScrollOrShow"),B=a(e=>{if(!e)return;if(typeof e=="string")return e;let o=[];return e.style&&o.push(String(e.style)),e.swap&&o.push(`swap:${e.swap}`),e.settle&&o.push(`settle:${e.settle}`),typeof e.transition=="boolean"&&o.push(`transition:${e.transition}`),e.scroll&&o.push(ne("scroll",e.scroll)),e.show&&o.push(ne("show",e.show)),e.ignoreTitle&&o.push("ignoreTitle:true"),typeof e.focusScroll=="boolean"&&o.push(`focus-scroll:${e.focusScroll}`),o.filter(Boolean).join(" ")},"toJhxSwapAttribute");var P=a(e=>{if(!e)return;let o=Array.isArray(e)?e:[e],t=!1,n=o.map(r=>{if(typeof r!="object")return r;if(r.inherit!==void 0){if(!r.inherit)return;t=!0;return}if(r.position==="this"||r.position==="next"||r.position==="previous")return r.position;let s=[];return typeof r?.position=="string"&&s.push(r.position),typeof r.selector=="string"&&s.push(r.selector),s.join(" ")});return t&&n.unshift("inherit"),n.filter(r=>!!r).join(", ")},"toJhxTargetAttribute");var ye=a(e=>{if(e){if(typeof e=="object"){if(e.op==="this"||e.op==="document"||e.op==="window")return e.op;if(typeof e.selector=="string"&&typeof e.op=="string")return`${e.op} ${e.selector}`}return String(e)}},"toJhxFromAttribute"),se=a(e=>typeof e=="string"?e:(Array.isArray(e)?e:[e]).map(t=>{if(typeof t=="string")return t;if(typeof t=="object"){let n=`${t.event||""}${t.filter?`[${t.filter}]`:""}`,r=[];return t.once===!0&&r.push("once"),t.changed===!0&&r.push("changed"),t.consume===!0&&r.push("consume"),t.delay&&r.push(`delay:${t.delay}`),t.from&&r.push(`from:${ye(t.from)}`),t.target&&r.push(`target:${P(t.target)}`),t.throttle&&r.push(`throttle:${t.throttle}`),t.queue&&r.push(`queue:${t.queue}`),n.concat(n?" ":"",r.join(" "))}return""}).filter(Boolean).join(", "),"toJhxTriggerAttribute");var ge=["get","post","put","patch","delete","route"],ae=a((e,o)=>{let t={};if(!e||typeof e!="object")return t;let n=ge.find(r=>!!e[r]);if(n)if(n==="route"){let r=e.method?.toLowerCase()||"get";t[`hx-${r}`]=String(e.route)}else t[`hx-${n}`]=String(e[n]);else e.method&&o.logger.warn("[jhx] The 'method' prop must be paired with a 'route' prop to generate a request attribute.");if(e.boost===!0&&(t["hx-boost"]="true"),e.confirm&&(t["hx-confirm"]=e.confirm),e.disable===!0&&(t["hx-disable"]="true"),e.disabledElt){let r=P(e.disabledElt);r&&(t["hx-disabled-elt"]=r)}if(e.disinherit&&(Array.isArray(e.disinherit)?t["hx-disinherit"]=e.disinherit.join(" "):t["hx-disinherit"]=e.disinherit),e.encoding&&(t["hx-encoding"]=e.encoding),e.ext){typeof e.ext=="string"&&(t["hx-ext"]=e.ext);let s=(Array.isArray(e.ext)?e.ext:[e.ext]).map(i=>typeof i=="object"?`${i?.name&&i.ignore===!0?"ignore:":""}${i?.name}`:i).filter(Boolean).join(",");s&&(t["hx-ext"]=s)}if(e.headers)if(typeof e.headers=="object")try{t["hx-headers"]=`${JSON.stringify(e.headers)}`}catch(r){throw o.logger.error("[jhx] Error while parsing the `hx-headers` object."),new $("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-headers",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.headers=="function"){let r=A(e.headers);if(r){let s=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`;t["hx-vals"]=`js:{...${s}}`}}else t["hx-headers"]=e.headers;if(e.history===!1&&(t["hx-history"]="false"),e.historyElt===!0&&(t["hx-history-elt"]="true"),e.indicator)if(typeof e.indicator=="object"){let r=e.indicator.inherit===!0?"inherit, ":"",s=e.indicator.closest===!0?"closest ":"";t["hx-indicator"]=`${r}${s}${e.indicator.selector}`}else t["hx-indicator"]=e.indicator;if(e.include){let r=P(e.include);r&&(t["hx-include"]=r)}if(e.inherit&&(Array.isArray(e.inherit)?t["hx-inherit"]=e.inherit.join(" "):t["hx-inherit"]=e.inherit),e.params&&(typeof e.params=="object"?e.params.include&&Array.isArray(e.params.include)?t["hx-params"]=`${e.params.include.join(",")}`:e.params.exclude&&Array.isArray(e.params.exclude)&&(t["hx-params"]=`not ${e.params.exclude.join(",")}`):t["hx-params"]=e.params),e.preserve===!0&&(t["hx-preserve"]="true"),e.prompt&&(t["hx-prompt"]=e.prompt),e.pushUrl&&(e.pushUrl===!0?t["hx-push-url"]="true":t["hx-push-url"]=e.pushUrl),(e.replaceUrl||e.replaceUrl===!1)&&(typeof e.replaceUrl=="boolean"?t["hx-replace-url"]=e.replaceUrl?"true":"false":t["hx-replace-url"]=e.replaceUrl),e.request)if(typeof e.request=="object")try{t["hx-request"]=`${JSON.stringify(e.request)}`}catch(r){throw new $("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-request",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.request=="function"){let r=A(e.request);if(r){let i=`(({ timeout, credentials, noHeaders }) => ({ timeout, credentials, noHeaders }))(${`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`})`;t["hx-request"]=`js: ${i}`}}else t["hx-request"]=e.request;if(e.select&&(t["hx-select"]=e.select),e.selectOob)if(Array.isArray(e.selectOob))t["hx-select-oob"]=e.selectOob.map(r=>{if(typeof r=="string")return r;if(typeof r=="object"&&r.selector){let s=B(r.swap);return`${r.selector}${s?":"+s:""}`}return""}).filter(Boolean).join(",");else if(typeof e.selectOob=="object"){let r=B(e.selectOob.swap);t["hx-select-oob"]=`${e.selectOob.selector}${r?":"+r:""}`}else t["hx-select-oob"]=e.selectOob;if(e.swap){let r=B(e.swap);r&&(t["hx-swap"]=r)}if(e.swapOob)if(e.swapOob===!0)t["hx-swap-oob"]="true";else if(typeof e.swapOob=="object"){let r=B(e.swapOob.swap);r&&(t["hx-swap-oob"]=`${r}${e.swapOob.selector?":"+e.swapOob.selector:""}`)}else t["hx-swap-oob"]=e.swapOob;if(e.sync&&(typeof e.sync=="object"?e.sync.strategy&&e.sync.tag?t["hx-sync"]=`${e.sync.closest===!0?"closest ":""}${e.sync.tag}:${e.sync.strategy}`:e.sync.strategy&&(t["hx-sync"]=`this:${e.sync.strategy}`):t["hx-sync"]=e.sync),e.target){let r=P(e.target);r&&(t["hx-target"]=r)}if(e.trigger&&(t["hx-trigger"]=se(e.trigger)),e.validate===!0&&(t["hx-validate"]="true"),e.vars&&(o.logger.warn("[jhx] The `hx-vars` attribute has been deprecated because of XSS vulnerabilities. Recommended to use the `hx-vals` attribute."),t["hx-vars"]=e.vars),e.vals)if(typeof e.vals=="object")try{t["hx-vals"]=`${JSON.stringify(e.vals)}`}catch(r){throw new $("[jhx] Error while parsing 'hx-vals' object",{attribute:"hx-vals",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.vals=="function"){let r=A(e.vals);if(r){let s=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`;t["hx-vals"]=`js:{...${s}}`}}else t["hx-vals"]=e.vals;return t},"convertJhxAttributes");var ie=a(e=>{let o={};if(!e||typeof e!="object")return o;for(let t in q)if(Object.prototype.hasOwnProperty.call(e,t)){let n=q[t],r=e[t];if(!r)continue;let s=A(r);if(!s)continue;o[n]=`((${s.params.join(",")}) => ${s.body})(${s.params.join(",")})`}return o},"convertJhxEventAttributes");var be={'"':"&quot;","<":"&lt;",">":"&gt;"},M=a(e=>String(e).replace(/["<>]/g,o=>be[o]??o),"escapeValue");var X=a((e,o=!0)=>Object.entries(e).map(([t,n])=>typeof n=="object"?`${t}="${JSON.stringify(n)}"`:`${t}="${typeof n=="string"&&o?M(n):n}"`).filter(Boolean).join(" "),"attributesToString");var U={logger:console,stringify:!1,escape:!0};var he=a(e=>{let o={};for(let[t,n]of Object.entries(e))o[t]=typeof n=="string"?M(n):n;return o},"escapeAttributes");function L(e,o){let t={...U,...o??{}},n={...ae(e,t),...ie(e),...oe(e)};return t.stringify===!0?X(n,!!t.escape):t.escape===!0?he(n):n}a(L,"jhx");var He=a((e,o)=>{for(let[t,n]of Object.entries(o))typeof n=="object"?e.setAttribute(t,JSON.stringify(n)):e.setAttribute(t,String(n))},"applyAttributes");var J=class e extends Error{static{a(this,"JhxServerException")}type;info;method;route;cause;constructor(o,t){super(o),this.name="JhxServerError",this.type=t.type,this.info=t.info||t.cause?.message||o,this.method=t.method,this.route=t.route,this.stack=t.stack,this.cause=t.cause,Object.setPrototypeOf(this,e.prototype)}};import{posix as Se}from"path";var C=a((e,o="")=>{let t=String(o).startsWith("/")?String(o):`/${o}`,n=e.trim();n=n.startsWith("/")?n:`/${n}`;let r;try{r=decodeURIComponent(n.startsWith(t)?n:`${t}/${n}`)}catch(i){throw new J("jhx: malformed endpoint",{type:"endpoint:malformed",info:i.message,route:n,cause:i})}let s=Se.normalize(r.startsWith("/")?r:`/${r}`);return s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1)),{noSlash:s,withSlash:s==="/"?"/":`${s}/`}},"normalizeEndpoint");var F=a((e,o,t)=>{if(t||(t=new Map),!e)return t;for(let n of e){let r=n.method?.trim()?.toUpperCase()??"GET",{noSlash:s,withSlash:i}=C(n.route,o.prefix);if(o.trailingSlash==="no-slash"){let T=`${r}::${s}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),o.onRegistered(r,s),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${s}`)}else if(o.trailingSlash==="slash"){let T=`${r}::${i}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),o.onRegistered(r,i),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${i}`)}else{let T=`${r}::${s}`,R=`${r}::${i}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});if(t.has(R))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),t.set(R,n.handler),o.onRegistered(r,s),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${s}`)}}return t},"addRoutesToMap");import{isValidElement as xe}from"react";import{renderToStaticMarkup as ve,renderToString as Je}from"react-dom/server";var Ee=a((e,...o)=>xe(e)?ve(e):e,"jsxToStatic"),we=a((e,...o)=>xe(e)?Je(e):e,"jsxToString"),je=a((e,...o)=>e,"noRender"),de=a(e=>e?typeof e=="function"?e:e==="static"?Ee:e==="string"?we:je:null,"getRenderFunction");var qe=["get","post","put","patch","delete","route"],pe=a(e=>{for(let o of qe)if(o in e){let t=e[o];return o==="route"?{method:"GET",route:typeof t=="string"&&t.trim()||null}:{method:o.toUpperCase(),route:typeof t=="string"&&t.trim()||null}}return{method:"GET",route:null}},"getRouteFromProps");import{createHash as Ae}from"crypto";var ue=a(e=>{if(typeof e?.toString!="function")throw new J("jhx: invalid route error",{type:"hash:invalid",info:"Cannot hash function without a 'toString' method"});return Ae("sha256").update(e.toString()).digest("hex").slice(0,12)},"hashFunction");var N=a(e=>{let o=[];if(!e)return o;for(let t of Array.isArray(e)?e:[e]){if(t.method&&t.method.trim()==="")throw new J("jhx: route validation error",{type:"route:invalid-method",info:`Invalid route method: '${t.method}'`,method:String(t.method)});if(!t.route||t.route?.trim()==="")throw new J("jhx: route validation error",{type:"route:invalid-path",info:`Invalid route endpoint: '${t.route}'`,method:t.method?.toUpperCase()??"GET",route:String(t.route)});if(!t.handler||typeof t.handler!="function")throw new J("jhx: route validation error",{type:"route:invalid-handler",info:`Invalid route handler for '${t.method?.toUpperCase()??"GET"} ${t.route}'`,method:t.method?.toUpperCase()??"GET",route:t.route});o.push({method:t.method?.toUpperCase()??"GET",route:t.route,handler:t.handler})}return o},"validateRoutes");var Ce=a(e=>e.startsWith("hx-")||e in O.attr||e in O.eventAttr||e==="route"||e==="method"||e==="handler","isJhxAttribute"),I=a(e=>a(function(t){let{jhxConfig:n,as:r,children:s,...i}=t,T=r??"div",R={};for(let[b,g]of Object.entries(i))Ce(b)||(R[b]=g);let y={...e(i,{...n,stringify:!1}),...R};return<T{...y}>{s}</T>},"JhxComponent"),"createJhxComponent");import{isValidElement as $e}from"react";import{renderToString as Pe}from"react-dom/server";var E={...U,contentType:"text/html",debug:!1,middleware:[],onRegistered:a(((e,o)=>{}),"onRegistered"),prefix:"/_jhx",render:a((e,...o)=>$e(e)?Pe(e):e,"render"),renderError:!0,renderMiddleware:!0,renderNotFound:!0,trailingSlash:"both"};var le=a((e,o,t)=>{let n={contentType:e.contentType===!1?!1:e.contentType??E.contentType,debug:e.debug===E.debug,errorHandler:e.errorHandler,middleware:Array.isArray(e.middleware)?e.middleware:e.middleware?[e.middleware]:E.middleware,notFoundHandler:e.notFoundHandler?e.notFoundHandler:o,onRegistered:e.onRegistered??E.onRegistered,logger:e.logger??E.logger,prefix:e.prefix?C(e.prefix).noSlash:E.prefix,render:typeof e.render=="function"?e.render:de(e.render===void 0?"string":e.render),renderError:typeof e.renderError=="boolean"?e.renderError:E.renderError,renderMiddleware:typeof e.renderMiddleware=="boolean"?e.renderMiddleware:E.renderMiddleware,renderNotFound:typeof e.renderNotFound=="boolean"?e.renderNotFound:E.renderNotFound,stringify:typeof e.stringify=="boolean"?e.stringify:E.stringify,trailingSlash:e.trailingSlash??E.trailingSlash,instanceOptions:e.instanceOptions},r=e.routes?F(N(e.routes),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash}):new Map;t(n,r);function s(i,T){if(typeof i=="object"&&typeof i.handler=="function"){let{method:y,route:b}=pe(i),{noSlash:g,withSlash:S}=C(b||ue(i.handler),n.prefix);if(n.trailingSlash==="no-slash"){let v=`${y}::${g}`;r.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${y} ${g}`),r.set(v,i.handler),n.onRegistered(y,g)),i.method=y,i.route=g}else if(n.trailingSlash==="slash"){let v=`${y}::${S}`;r.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${y} ${S}`),r.set(v,i.handler),n.onRegistered(y,S)),i.method=y,i.route=S}else{let v=`${y}::${g}`,w=`${y}::${S}`;!r.has(v)&&!r.has(w)&&(n.debug&&n.logger.info(`[jhx] Added new route: ${y} ${g}`),r.set(v,i.handler),r.set(w,i.handler),n.onRegistered(y,g)),i.method=y,i.route=g}}let R=T?.stringify??n.stringify,H=i&&typeof i=="object"&&"handler"in i?(({handler:y,...b})=>b)(i):i;return R?L(H,{logger:T?.logger??n.logger,stringify:!0}):L(H,{logger:T?.logger??n.logger,stringify:!1})}return a(s,"jhx"),s.addRoute=i=>{F(N({method:i.method,route:i.route,handler:i.handler}),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},r)},s.addRoutes=i=>{F(N(i),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},r)},s.clearRoutes=()=>{let i=r.size;r.clear(),n.debug&&n.logger.info(`[jhx] Cleared ${i} route${i===1?"":"s"}`)},s.getRoute=(i,T)=>{let R=i.trim().toUpperCase(),{noSlash:H,withSlash:y}=C(T,n.prefix);if(n.trailingSlash==="no-slash"){let b=`${R}::${H}`,g=r.get(b);return g?{method:R,route:H,handler:g}:null}else if(n.trailingSlash==="slash"){let b=r.get(`${R}::${y}`);return b?{method:R,route:y,handler:b}:null}else{let b=r.get(`${R}::${H}`),g=r.get(`${R}::${y}`);if(!b&&!g)return null;let S=T.endsWith("/");return{method:R,route:S?g?y:H:b?H:y,handler:S?g??b:b??g}}},s.getRoutes=()=>Array.from(r.entries()).map(([i,T])=>{let[R,H]=i.split("::");return!R||!H?null:{method:R,route:H,handler:T}}).filter(i=>i!==null),s.hasRoute=(i,T)=>{let{noSlash:R,withSlash:H}=C(T,n.prefix);return r.has(`${i.toUpperCase()}::${R}`)||r.has(`${i.toUpperCase()}::${H}`)},s.removeRoute=(i,T)=>{let R=i.trim().toUpperCase(),{noSlash:H,withSlash:y}=C(T,n.prefix),b;return n.trailingSlash==="no-slash"?b=r.delete(`${R}::${H}`):n.trailingSlash==="slash"?b=r.delete(`${R}::${y}`):(b=r.delete(`${R}::${H}`),b=r.delete(`${R}::${y}`)||b),b&&n.debug?n.logger.info(`[jhx] Removed route: ${R} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?y:`${H} / ${y}`}`):!b&&n.debug&&n.logger.info(`[jhx] Cannot remove unknown route: ${R} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?y:`${H} / ${y}`}`),b},{jhx:s,JhxComponent:I(s)}},"createServerJhx");import{Stream as De}from"node:stream";var W=a(e=>e!==null&&typeof e=="object"&&typeof e.send=="function"&&typeof e.status=="function"&&typeof e.json=="function"&&"headersSent"in e,"isExpressResponse"),V=a(e=>!!(e&&(e.headersSent===!0||e.finished===!0||e.writableEnded===!0)),"isResponseSent"),Oe=a(e=>e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray||e instanceof BigUint64Array||typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)||typeof Buffer<"u"&&e instanceof Buffer,"isArrayBuffer"),Be=a(e=>e.split("-").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("-"),"capitalize"),k=a((e,o,t)=>{let n=Be(o);!e.getHeader(n)&&!e.getHeader(o.toLowerCase())&&e.header(n,t)},"ensureHeader"),j=a(async(e,o)=>{if(!(W(o)||V(e))){if(o instanceof Blob){o.type&&k(e,"Content-Type",o.type),o.size>=0&&k(e,"Content-Length",String(o.size));let t=await o.arrayBuffer();e.send(Buffer.from(t));return}o instanceof FormData?k(e,"Content-Type","multipart/form-data"):o instanceof Response||o instanceof ReadableStream||o instanceof De||Oe(o)?k(e,"Content-Type","application/octet-stream"):typeof o=="object"&&o!==null&&k(e,"Content-Type","application/json"),e.send(o)}},"sendPayload");var D=a((e,o)=>V(e)||o===e||W(o),"isResponseHandled");var me={...E,notFoundHandler:a((e,o)=>{o.status(404).send()},"notFoundHandler")};var ps=a((e,o={})=>le(o,me.notFoundHandler,(t,n)=>{e.all(`${t.prefix}{*splat}`,async(r,s,i)=>{let T=r.method.toUpperCase(),R=decodeURIComponent(r.url.split("?")[0]),H=n.get(`${T}::${R}`);if(t.contentType&&s.header("content-type",t.contentType),H){for(let g of t.middleware)try{let S=await g(r,s);if(D(s,S))return await j(s,S);if(S!==void 0){let v=t.render&&t.renderMiddleware?await t.render(S,r,s):S;return await j(s,v)}}catch(S){let v=S;if(t.debug&&t.logger.error(`[jhx] Middleware error from '${T} ${R}': ${S.message}`),t.errorHandler){s.status(500);let w=await t.errorHandler(v,r,s);if(D(s,w))return await j(s,w);let fe=t.render&&t.renderError?await t.render(w,r,s):w;return await j(s,fe)}throw new J("Unexpected jhx middleware error",{type:"middleware:error",info:"Unhandled error while handling middleware or rendering middleware payload",method:T,route:R,cause:v})}try{let g=await H(r,s);if(D(s,g))return await j(s,g);let S=t.render?await t.render(g,r,s):g;return await j(s,S)}catch(g){let S=g;if(t.debug&&t.logger.error(`[jhx] Route error from '${T} ${R}': ${g.message}`),t.errorHandler){s.status(500);let v=await t.errorHandler(S,r,s);if(D(s,v))return await j(s,v);let w=t.render&&t.renderError?await t.render(v,r,s):v;return await j(s,w)}throw new J("Unexpected jhx route error",{type:"handler:error",info:"Unhandled error while handling route or rendering route payload",method:T,route:R,cause:S})}}t.debug&&t.logger.info(`[jhx] Request to unknown route '${T} ${R}' from IP address '${r.ip}'`),s.status(404);let y=await t.notFoundHandler(r,s);if(D(s,y))return;let b=t.render&&t.renderNotFound?await t.render(y,r,s):y;return await j(s,b)})}),"createJhx");var fs=a(e=>I(e),"createJhxComponent");export{He as applyAttributes,X as attributesToString,ps as createJhx,fs as createJhxComponent,me as defaultConfig,O as htmx};
1
+ var Te=Object.defineProperty;var i=(e,o)=>Te(e,"name",{value:o,configurable:!0});var C={onAbort:"hx-on--abort",onAfterOnLoad:"hx-on--after-on-load",onAfterProcessNode:"hx-on--after-process-node",onAfterRequest:"hx-on--after-request",onAfterSettle:"hx-on--after-settle",onAfterSwap:"hx-on--after-swap",onBeforeCleanupElement:"hx-on--before-cleanup-element",onBeforeOnLoad:"hx-on--before-on-load",onBeforeProcessNode:"hx-on--before-process-node",onBeforeRequest:"hx-on--before-request",onBeforeSwap:"hx-on--before-swap",onBeforeSend:"hx-on--before-send",onBeforeTransition:"hx-on--before-transition",onConfigRequest:"hx-on--config-request",onConfirm:"hx-on--confirm",onHistoryCacheError:"hx-on--history-cache-error",onHistoryCacheHit:"hx-on--history-cache-hit",onHistoryCacheMiss:"hx-on--history-cache-miss",onHistoryCacheMissLoadError:"hx-on--history-cache-miss-load-error",onHistoryCacheMissLoad:"hx-on--history-cache-miss-load",onHistoryRestore:"hx-on--history-restore",onBeforeHistorySave:"hx-on--before-history-save",onLoad:"hx-on--load",onNoSSESourceError:"hx-on--no-sse-source-error",onOnLoadError:"hx-on--on-load-error",onOobAfterSwap:"hx-on--oob-after-swap",onOobBeforeSwap:"hx-on--oob-before-swap",onOobErrorNoTarget:"hx-on--oob-error-no-target",onPrompt:"hx-on--prompt",onPushedIntoHistory:"hx-on--pushed-into-history",onReplacedInHistory:"hx-on--replaced-in-history",onResponseError:"hx-on--response-error",onSendAbort:"hx-on--send-abort",onSendError:"hx-on--send-error",onSseError:"hx-on--sse-error",onSseOpen:"hx-on--sse-open",onSwapError:"hx-on--swap-error",onTargetError:"hx-on--target-error",onTimeout:"hx-on--timeout",onValidateUrl:"hx-on--validate-url",onValidationValidate:"hx-on--validation-validate",onValidationFailed:"hx-on--validation-failed",onValidationHalted:"hx-on--validation-halted",onXhrAbort:"hx-on--xhr-abort",onXhrLoadend:"hx-on--xhr-loadend",onXhrLoadstart:"hx-on--xhr-loadstart",onXhrProgress:"hx-on--xhr-progress"};var z={get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch",pushUrl:"hx-push-url",select:"hx-select",selectOob:"hx-select-oob",swap:"hx-swap",swapOob:"hx-swap-oob",target:"hx-target",trigger:"hx-trigger",vals:"hx-vals",boost:"hx-boost",confirm:"hx-confirm",disable:"hx-disable",disabledElt:"hx-disabled-elt",disinherit:"hx-disinherit",encoding:"hx-encoding",ext:"hx-ext",headers:"hx-headers",history:"hx-history",historyElt:"hx-history-elt",include:"hx-include",indicator:"hx-indicator",inherit:"hx-inherit",params:"hx-params",preserve:"hx-preserve",prompt:"hx-prompt",replaceUrl:"hx-replace-url",request:"hx-request",sync:"hx-sync",validate:"hx-validate",vars:"hx-vars",...C};var G={added:"htmx-added",indicator:"htmx-indicator",request:"htmx-request",settling:"htmx-settling",swapping:"htmx-swapping"};var _={addedClass:"hx-added",allowEval:!0,allowNestedOobSwaps:!0,allowScriptTags:!0,attributesToSettle:["class","style","width","height"],defaultFocusScroll:!1,defaultSettleDelay:20,defaultSwapDelay:0,defaultSwapStyle:"innerHTML",disableInheritance:!1,disableSelector:"[hx-disable], [data-hx-disable]",getCacheBusterParam:!1,globalViewTransitions:!1,historyCacheSize:10,historyEnabled:!0,historyRestoreAsHxRequest:!0,ignoreTitle:!1,includeIndicatorStyles:!0,indicatorClass:"hx-indicator",inlineScriptNonce:"",inlineStyleNonce:"",methodsThatUseUrlParams:["get","delete"],refreshOnHistoryMiss:!1,requestClass:"htmx-request",responseHandling:[{code:"204",swap:!1},{code:"[23]..",swap:!0},{code:"[45]..",swap:!1,error:!0}],scrollBehavior:"instant",scrollIntoViewOnBoost:!0,selfRequestsOnly:!0,settlingClass:"htmx-settling",swappingClass:"htmx-swapping",timeout:0,triggerSpecsCache:null,withCredentials:!1,wsBinaryType:"blob",wsReconnectDelay:"full-jitter"};var Y={abort:"htmx:abort",afterOnLoad:"htmx:afterOnLoad",afterProcessNode:"htmx:afterProcessNode",afterRequest:"htmx:afterRequest",afterSettle:"htmx:afterSettle",afterSwap:"htmx:afterSwap",beforeCleanupElement:"htmx:beforeCleanupElement",beforeOnLoad:"htmx:beforeOnLoad",beforeProcessNode:"htmx:beforeProcessNode",beforeRequest:"htmx:beforeRequest",beforeSwap:"htmx:beforeSwap",beforeSend:"htmx:beforeSend",beforeTransition:"htmx:beforeTransition",configRequest:"htmx:configRequest",confirm:"htmx:confirm",historyCacheError:"htmx:historyCacheError",historyCacheHit:"htmx:historyCacheHit",historyCacheMiss:"htmx:historyCacheMiss",historyCacheMissLoadError:"htmx:historyCacheMissLoadError",historyCacheMissLoad:"htmx:historyCacheMissLoad",historyRestore:"htmx:historyRestore",beforeHistorySave:"htmx:beforeHistorySave",load:"htmx:load",noSSESourceError:"htmx:noSSESourceError",onLoadError:"htmx:onLoadError",oobAfterSwap:"htmx:oobAfterSwap",oobBeforeSwap:"htmx:oobBeforeSwap",oobErrorNoTarget:"htmx:oobErrorNoTarget",prompt:"htmx:prompt",pushedIntoHistory:"htmx:pushedIntoHistory",replacedInHistory:"htmx:replacedInHistory",responseError:"htmx:responseError",sendAbort:"htmx:sendAbort",sendError:"htmx:sendError",sseError:"htmx:sseError",sseOpen:"htmx:sseOpen",swapError:"htmx:swapError",targetError:"htmx:targetError",timeout:"htmx:timeout",validateUrl:"htmx:validateUrl",validationValidate:"htmx:validation:validate",validationFailed:"htmx:validation:failed",validationHalted:"htmx:validation:halted",xhrAbort:"htmx:xhr:abort",xhrLoadend:"htmx:xhr:loadend",xhrLoadstart:"htmx:xhr:loadstart",xhrProgress:"htmx:xhr:progress"};var K={headSupport:{name:"head-support",version:"2.0.5",npm:"htmx-ext-head-support",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.5",integrity:"sha384-cvMqHzjCJsOHgGuyB3sWXaUSv/Krm0BdzjuI1rtkjCbL1l1oHJx+cHyVRJhyuEz0"}]},htmx1Compat:{name:"htmx-1-compat",version:"2.0.2",npm:"htmx-ext-htmx-1-compat",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-htmx-1-compat@2.0.2",integrity:"sha384-lcvVWaNjF5zPPUeeWmC0OkJ2MLqoWLlkAabuGm+EuMSTfGo5WRyHrNaAp0cJr9Pg"}]},idiomorph:{name:"morph",version:"0.7.4",npm:"idiomorph",cdn:[{url:"https://unpkg.com/idiomorph@0.7.4/dist/idiomorph-ext.min.js",integrity:"sha384-SsScJKzATF/w6suEEdLbgYGsYFLzeKfOA6PY+/C5ZPxOSuA+ARquqtz/BZz9JWU8"}]},preload:{name:"preload",version:"2.1.2",npm:"htmx-ext-preload",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.2",integrity:"sha384-PRIcY6hH1Y5784C76/Y8SqLyTanY9rnI3B8F3+hKZFNED55hsEqMJyqWhp95lgfk"}]},responseTargets:{name:"response-targets",version:"2.0.4",npm:"htmx-ext-response-targets",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-response-targets@2.0.4",integrity:"sha384-T41oglUPvXLGBVyRdZsVRxNWnOOqCynaPubjUVjxhsjFTKrFJGEMm3/0KGmNQ+Pg"}]},sse:{name:"sse",version:"2.2.4",npm:"htmx-ext-sse",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-sse@2.2.4",integrity:"sha384-A986SAtodyH8eg8x8irJnYUk7i9inVQqYigD6qZ9evobksGNIXfeFvDwLSHcp31N"}]},ws:{name:"ws",version:"2.0.4",npm:"htmx-ext-ws",cdn:[{url:"https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.4",integrity:"sha384-1RwI/nvUSrMRuNj7hX1+27J8XDdCoSLf0EjEyF69nacuWyiJYoQ/j39RT1mSnd2G"}]}};var Q={GET:"hx-get",POST:"hx-post",PUT:"hx-put",DELETE:"hx-delete",PATCH:"hx-patch",get:"hx-get",post:"hx-post",put:"hx-put",delete:"hx-delete",patch:"hx-patch"};var Z={boosted:"HX-Boosted",currentUrl:"HX-Current-URL",historyRestoreRequest:"HX-History-Restore-Request",prompt:"HX-Prompt",request:"HX-Request",target:"HX-Target",triggerName:"HX-Trigger-Name",trigger:"HX-Trigger"};var ee={location:"HX-Location",pushUrl:"HX-Push-URL",redirect:"HX-Redirect",refresh:"HX-Refresh",replaceUrl:"HX-Replace-URL",reswap:"HX-Reswap",retarget:"HX-Retarget",reselect:"HX-Reselect",trigger:"HX-Trigger",triggerAfterSettle:"HX-Trigger-After-Settle",triggerAfterSwap:"HX-Trigger-After-Swap"};var te={innerHTML:"innerHTML",outerHTML:"outerHTML",textContent:"textContent",beforeBegin:"beforebegin",afterBegin:"afterbegin",beforeEnd:"beforeend",afterEnd:"afterend",delete:"delete",none:"none"};var re={drop:"drop",abort:"abort",replace:"replace",queue:"queue",queueAll:"queue all",queueFirst:"queue first",queueLast:"queue last"};var O={attr:z,config:_,css:G,event:Y,eventAttr:C,ext:K,method:Q,res:ee,req:Z,swap:te,sync:re};var oe=i(e=>{let o=[],t=0;for(;t<e.length;){let n=e[t];if(n==="`"){let r=t;for(t++;t<e.length;)if(e[t]==="\\")t+=2;else if(e[t]==="`"){t++;break}else t++;o.push(e.slice(r,t));continue}if(n==='"'){t++;let r=[],s=!1;for(;t<e.length;)if(e[t]==="\\"){let T=e[t+1];r.push(e[t],T??""),t+=2}else if(e[t]==='"'){t++;break}else e[t]==="$"&&e[t+1]==="{"&&(s=!0),r.push(e[t]),t++;let a=r.join("");if(s){o.push("`");for(let T=0;T<a.length;T++)if(a[T]==="\\"){let g=a[T+1];g==='"'?(o.push('"'),T++):g==="`"?(o.push("\\`"),T++):(o.push(a[T],g??""),T++)}else a[T]==="`"?o.push("\\`"):o.push(a[T]);o.push("`")}else{o.push("'");for(let T=0;T<a.length;T++)if(a[T]==="\\"){let g=a[T+1];g==='"'?(o.push('"'),T++):g==="'"?(o.push("\\'"),T++):(o.push(a[T],g??""),T++)}else a[T]==="'"?o.push("\\'"):o.push(a[T]);o.push("'")}continue}if(n==="'"){let r=t;for(t++;t<e.length;)if(e[t]==="\\")t+=2;else if(e[t]==="'"){t++;break}else t++;o.push(e.slice(r,t));continue}if(n==="/"&&t>0){let r=e.slice(0,t).trimEnd().slice(-1);if(["=","(",",","[","!","&","|",":",";","{","}","?"].includes(r)){let a=t;t++;let T=!1;for(;t<e.length;)if(e[t]==="\\")t+=2;else if(e[t]==="[")T=!0,t++;else if(e[t]==="]")T=!1,t++;else if(e[t]==="/"&&!T){for(t++;t<e.length&&/[gimsuy]/.test(e[t]);)t++;break}else t++;o.push(e.slice(a,t));continue}}o.push(n),t++}return o.join("")},"normalizeStringQuotes");var ge=i(e=>{let o=/^(?:async\s*)?function\*?\s*(?:[A-z0-9]+)?\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)\s*\{((?:[^}{]+|\{(?:[^}{]+|\{[^}{]*})*})*)}$/s,t=e.match(o);if(t&&t[2])return{fnType:"normal",fullMatch:t[0],paramStr:t[1]??"",bodyStr:`{ ${t[2].trim()} }`};let n=/^(?:async\s*)?(?:\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)|([^\s=()]+))\s*=>\s*(.*)$/s,r=e.match(n);if(r&&r[3]){let s=r[3].trim();return{fnType:"arrow",fullMatch:r[0],paramStr:r[1]??"",bodyStr:s.startsWith("{")&&(s.endsWith("}")||s.endsWith("};"))?s:`{ return ${s} }`}}return null},"matchFunctionString"),Re=i(e=>{if(!e)return[];let o=[],t=0,n=0,r=0,s=0;for(let a=0;a<e.length;a++){let T=e[a];T==="("?t++:T===")"?t--:T==="{"?n++:T==="}"?n--:T==="["?r++:T==="]"?r--:T===","&&t===0&&n===0&&r===0&&(o.push(e.substring(s,a).trim()),s=a+1)}return o.push(e.substring(s).trim()),o.filter(Boolean)},"splitParams"),A=i(e=>{if(typeof e!="function"||typeof e?.toString!="function")return null;let o=e.toString().replaceAll("void 0","undefined"),t=ge(o);return t?{params:Re(t.paramStr),body:oe(t.bodyStr)}:null},"extractFunction");var ne=i(e=>{let o={};if(!e||typeof e!="object")return o;for(let t in e){if(t in C||!t.startsWith("on"))continue;let n=e[t];if(!n)continue;let r=A(n);r&&(o[t.toLowerCase()]=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`)}return o},"convertDomEventAttributes");var $=class e extends Error{static{i(this,"JhxErrorThrowable")}attribute;constructor(o,t){super(o),this.name="JhxError",this.attribute=t.attribute,t.stack&&(this.stack=t.stack),t.cause&&(this.cause=t.cause),Object.setPrototypeOf(this,e.prototype)}};var se=i((e,o)=>typeof o=="string"?`${e}:${o}`:"window"in o?`${e}:window:${o.position}`:"selector"in o?`${e}:${o.selector}:${o.position}`:"","processScrollOrShow"),B=i(e=>{if(!e)return;if(typeof e=="string")return e;let o=[];return e.style&&o.push(String(e.style)),e.swap&&o.push(`swap:${e.swap}`),e.settle&&o.push(`settle:${e.settle}`),typeof e.transition=="boolean"&&o.push(`transition:${e.transition}`),e.scroll&&o.push(se("scroll",e.scroll)),e.show&&o.push(se("show",e.show)),e.ignoreTitle&&o.push("ignoreTitle:true"),typeof e.focusScroll=="boolean"&&o.push(`focus-scroll:${e.focusScroll}`),o.filter(Boolean).join(" ")},"toJhxSwapAttribute");var P=i(e=>{if(!e)return;let o=Array.isArray(e)?e:[e],t=!1,n=o.map(r=>{if(typeof r!="object")return r;if(r.inherit!==void 0){if(!r.inherit)return;t=!0;return}if(r.position==="this"||r.position==="next"||r.position==="previous")return r.position;let s=[];return typeof r?.position=="string"&&s.push(r.position),typeof r.selector=="string"&&s.push(r.selector),s.join(" ")});return t&&n.unshift("inherit"),n.filter(r=>!!r).join(", ")},"toJhxTargetAttribute");var ye=i(e=>{if(e){if(typeof e=="object"){if(e.op==="this"||e.op==="document"||e.op==="window")return e.op;if(typeof e.selector=="string"&&typeof e.op=="string")return`${e.op} ${e.selector}`}return String(e)}},"toJhxFromAttribute"),ae=i(e=>typeof e=="string"?e:(Array.isArray(e)?e:[e]).map(t=>{if(typeof t=="string")return t;if(typeof t=="object"){let n=`${t.event||""}${t.filter?`[${t.filter}]`:""}`,r=[];return t.once===!0&&r.push("once"),t.changed===!0&&r.push("changed"),t.consume===!0&&r.push("consume"),t.delay&&r.push(`delay:${t.delay}`),t.from&&r.push(`from:${ye(t.from)}`),t.target&&r.push(`target:${P(t.target)}`),t.throttle&&r.push(`throttle:${t.throttle}`),t.queue&&r.push(`queue:${t.queue}`),n.concat(n?" ":"",r.join(" "))}return""}).filter(Boolean).join(", "),"toJhxTriggerAttribute");var be=["get","post","put","patch","delete","route"],ie=i((e,o)=>{let t={};if(!e||typeof e!="object")return t;let n=be.find(r=>!!e[r]);if(n)if(n==="route"){let r=e.method?.toLowerCase()||"get";t[`hx-${r}`]=String(e.route)}else t[`hx-${n}`]=String(e[n]);else e.method&&o.logger.warn("[jhx] The 'method' prop must be paired with a 'route' prop to generate a request attribute.");if(e.boost===!0&&(t["hx-boost"]="true"),e.confirm&&(t["hx-confirm"]=e.confirm),e.disable===!0&&(t["hx-disable"]="true"),e.disabledElt){let r=P(e.disabledElt);r&&(t["hx-disabled-elt"]=r)}if(e.disinherit&&(Array.isArray(e.disinherit)?t["hx-disinherit"]=e.disinherit.join(" "):t["hx-disinherit"]=e.disinherit),e.encoding&&(t["hx-encoding"]=e.encoding),e.ext){typeof e.ext=="string"&&(t["hx-ext"]=e.ext);let s=(Array.isArray(e.ext)?e.ext:[e.ext]).map(a=>typeof a=="object"?`${a?.name&&a.ignore===!0?"ignore:":""}${a?.name}`:a).filter(Boolean).join(",");s&&(t["hx-ext"]=s)}if(e.headers)if(typeof e.headers=="object")try{t["hx-headers"]=`${JSON.stringify(e.headers)}`}catch(r){throw o.logger.error("[jhx] Error while parsing the `hx-headers` object."),new $("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-headers",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.headers=="function"){let r=A(e.headers);if(r){let s=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`;t["hx-vals"]=`js:{...${s}}`}}else t["hx-headers"]=e.headers;if(e.history===!1&&(t["hx-history"]="false"),e.historyElt===!0&&(t["hx-history-elt"]="true"),e.indicator)if(typeof e.indicator=="object"){let r=e.indicator.inherit===!0?"inherit, ":"",s=e.indicator.closest===!0?"closest ":"";t["hx-indicator"]=`${r}${s}${e.indicator.selector}`}else t["hx-indicator"]=e.indicator;if(e.include){let r=P(e.include);r&&(t["hx-include"]=r)}if(e.inherit&&(Array.isArray(e.inherit)?t["hx-inherit"]=e.inherit.join(" "):t["hx-inherit"]=e.inherit),e.params&&(typeof e.params=="object"?e.params.include&&Array.isArray(e.params.include)?t["hx-params"]=`${e.params.include.join(",")}`:e.params.exclude&&Array.isArray(e.params.exclude)&&(t["hx-params"]=`not ${e.params.exclude.join(",")}`):t["hx-params"]=e.params),e.preserve===!0&&(t["hx-preserve"]="true"),e.prompt&&(t["hx-prompt"]=e.prompt),e.pushUrl&&(e.pushUrl===!0?t["hx-push-url"]="true":t["hx-push-url"]=e.pushUrl),(e.replaceUrl||e.replaceUrl===!1)&&(typeof e.replaceUrl=="boolean"?t["hx-replace-url"]=e.replaceUrl?"true":"false":t["hx-replace-url"]=e.replaceUrl),e.request)if(typeof e.request=="object")try{t["hx-request"]=`${JSON.stringify(e.request)}`}catch(r){throw new $("[jhx] Error while parsing 'hx-request' object",{attribute:"hx-request",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.request=="function"){let r=A(e.request);if(r){let a=`(({ timeout, credentials, noHeaders }) => ({ timeout, credentials, noHeaders }))(${`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`})`;t["hx-request"]=`js: ${a}`}}else t["hx-request"]=e.request;if(e.select&&(t["hx-select"]=e.select),e.selectOob)if(Array.isArray(e.selectOob))t["hx-select-oob"]=e.selectOob.map(r=>{if(typeof r=="string")return r;if(typeof r=="object"&&r.selector){let s=B(r.swap);return`${r.selector}${s?":"+s:""}`}return""}).filter(Boolean).join(",");else if(typeof e.selectOob=="object"){let r=B(e.selectOob.swap);t["hx-select-oob"]=`${e.selectOob.selector}${r?":"+r:""}`}else t["hx-select-oob"]=e.selectOob;if(e.swap){let r=B(e.swap);r&&(t["hx-swap"]=r)}if(e.swapOob)if(e.swapOob===!0)t["hx-swap-oob"]="true";else if(typeof e.swapOob=="object"){let r=B(e.swapOob.swap);r&&(t["hx-swap-oob"]=`${r}${e.swapOob.selector?":"+e.swapOob.selector:""}`)}else t["hx-swap-oob"]=e.swapOob;if(e.sync&&(typeof e.sync=="object"?e.sync.strategy&&e.sync.tag?t["hx-sync"]=`${e.sync.closest===!0?"closest ":""}${e.sync.tag}:${e.sync.strategy}`:e.sync.strategy&&(t["hx-sync"]=`this:${e.sync.strategy}`):t["hx-sync"]=e.sync),e.target){let r=P(e.target);r&&(t["hx-target"]=r)}if(e.trigger&&(t["hx-trigger"]=ae(e.trigger)),e.validate===!0&&(t["hx-validate"]="true"),e.vars&&(o.logger.warn("[jhx] The `hx-vars` attribute has been deprecated because of XSS vulnerabilities. Recommended to use the `hx-vals` attribute."),t["hx-vars"]=e.vars),e.vals)if(typeof e.vals=="object")try{t["hx-vals"]=`${JSON.stringify(e.vals)}`}catch(r){throw new $("[jhx] Error while parsing 'hx-vals' object",{attribute:"hx-vals",cause:r,stack:r instanceof Error&&typeof r.stack=="string"?r.stack:void 0})}else if(typeof e.vals=="function"){let r=A(e.vals);if(r){let s=`((${r.params.join(",")}) => ${r.body})(${r.params.join(",")})`;t["hx-vals"]=`js:{...${s}}`}}else t["hx-vals"]=e.vals;return t},"convertJhxAttributes");var he=i(e=>{let o={};if(!e||typeof e!="object")return o;for(let t in C)if(Object.prototype.hasOwnProperty.call(e,t)){let n=C[t],r=e[t];if(!r)continue;let s=A(r);if(!s)continue;o[n]=`((${s.params.join(",")}) => ${s.body})(${s.params.join(",")})`}return o},"convertJhxEventAttributes");var He={'"':"&quot;","<":"&lt;",">":"&gt;"},M=i(e=>String(e).replace(/["<>]/g,o=>He[o]??o),"escapeValue");var X=i((e,o=!0)=>Object.entries(e).map(([t,n])=>typeof n=="object"?`${t}="${JSON.stringify(n)}"`:`${t}="${typeof n=="string"&&o?M(n):n}"`).filter(Boolean).join(" "),"attributesToString");var U={logger:console,stringify:!1,escape:!0};var xe=i(e=>{let o={};for(let[t,n]of Object.entries(e))o[t]=typeof n=="string"?M(n):n;return o},"escapeAttributes");function L(e,o){let t={...U,...o??{}},n={...ie(e,t),...he(e),...ne(e)};return t.stringify===!0?X(n,!!t.escape):t.escape===!0?xe(n):n}i(L,"jhx");var Se=i((e,o)=>{for(let[t,n]of Object.entries(o))typeof n=="object"?e.setAttribute(t,JSON.stringify(n)):e.setAttribute(t,String(n))},"applyAttributes");var J=class e extends Error{static{i(this,"JhxServerException")}type;info;method;route;cause;constructor(o,t){super(o),this.name="JhxServerError",this.type=t.type,this.info=t.info||t.cause?.message||o,this.method=t.method,this.route=t.route,this.stack=t.stack,this.cause=t.cause,Object.setPrototypeOf(this,e.prototype)}};import{posix as ve}from"path";var q=i((e,o="")=>{let t=String(o).startsWith("/")?String(o):`/${o}`,n=e.trim();n=n.startsWith("/")?n:`/${n}`;let r;try{r=decodeURIComponent(n.startsWith(t)?n:`${t}/${n}`)}catch(a){throw new J("jhx: malformed endpoint",{type:"endpoint:malformed",info:a.message,route:n,cause:a})}let s=ve.normalize(r.startsWith("/")?r:`/${r}`);return s.length>1&&s.endsWith("/")&&(s=s.slice(0,-1)),{noSlash:s,withSlash:s==="/"?"/":`${s}/`}},"normalizeEndpoint");var N=i((e,o,t)=>{if(t||(t=new Map),!e)return t;for(let n of e){let r=n.method?.trim()?.toUpperCase()??"GET",{noSlash:s,withSlash:a}=q(n.route,o.prefix);if(o.trailingSlash==="no-slash"){let T=`${r}::${s}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),o.onRegistered(r,s),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${s}`)}else if(o.trailingSlash==="slash"){let T=`${r}::${a}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),o.onRegistered(r,a),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${a}`)}else{let T=`${r}::${s}`,g=`${r}::${a}`;if(t.has(T))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});if(t.has(g))throw new J("jhx: routing error",{type:"route:duplicate",info:`Cannot add duplicate route: ${r} '${s}'`,method:r,route:s});t.set(T,n.handler),t.set(g,n.handler),o.onRegistered(r,s),o.debug&&o.logger.info(`[jhx] Added new route: ${r} ${s}`)}}return t},"addRoutesToMap");import{isValidElement as le}from"react";import{renderToStaticMarkup as Je,renderToString as Ee}from"react-dom/server";var we=i((e,...o)=>le(e)?Je(e):e,"jsxToStatic"),je=i((e,...o)=>le(e)?Ee(e):e,"jsxToString"),Ce=i((e,...o)=>e,"noRender"),pe=i(e=>e?typeof e=="function"?e:e==="static"?we:e==="string"?je:Ce:null,"getRenderFunction");var Ae=["get","post","put","patch","delete","route"],de=i(e=>{for(let o of Ae)if(o in e){let t=e[o];return o==="route"?{method:"GET",route:typeof t=="string"&&t.trim()||null}:{method:o.toUpperCase(),route:typeof t=="string"&&t.trim()||null}}return{method:"GET",route:null}},"getRouteFromProps");import{createHash as qe}from"crypto";var ue=i(e=>{if(typeof e?.toString!="function")throw new J("jhx: invalid route error",{type:"hash:invalid",info:"Cannot hash function without a 'toString' method"});return qe("sha256").update(e.toString()).digest("hex").slice(0,12)},"hashFunction");var F=i(e=>{let o=[];if(!e)return o;for(let t of Array.isArray(e)?e:[e]){if(t.method&&t.method.trim()==="")throw new J("jhx: route validation error",{type:"route:invalid-method",info:`Invalid route method: '${t.method}'`,method:String(t.method)});if(!t.route||t.route?.trim()==="")throw new J("jhx: route validation error",{type:"route:invalid-path",info:`Invalid route endpoint: '${t.route}'`,method:t.method?.toUpperCase()??"GET",route:String(t.route)});if(!t.handler||typeof t.handler!="function")throw new J("jhx: route validation error",{type:"route:invalid-handler",info:`Invalid route handler for '${t.method?.toUpperCase()??"GET"} ${t.route}'`,method:t.method?.toUpperCase()??"GET",route:t.route});o.push({method:t.method?.toUpperCase()??"GET",route:t.route,handler:t.handler})}return o},"validateRoutes");var $e=i(e=>e.startsWith("hx-")||e in O.attr||e in O.eventAttr||e==="route"||e==="method"||e==="handler","isJhxAttribute"),I=i(e=>i(function(t){let{jhxConfig:n,as:r,children:s,...a}=t,T=r??"div",g={};for(let[b,y]of Object.entries(a))$e(b)||(g[b]=y);let R={...e(a,{...n,stringify:!1}),...g};return<T{...R}>{s}</T>},"JhxComponent"),"createJhxComponent");import{isValidElement as Pe}from"react";import{renderToString as De}from"react-dom/server";var E={...U,contentType:"text/html",debug:!1,middleware:[],onRegistered:i(((e,o)=>{}),"onRegistered"),prefix:"/_jhx",render:i((e,...o)=>Pe(e)?De(e):e,"render"),renderError:!0,renderMiddleware:!0,renderNotFound:!0,trailingSlash:"both"};var fe=i((e,o,t)=>{let n={contentType:e.contentType===!1?!1:e.contentType??E.contentType,debug:e.debug===E.debug,errorHandler:e.errorHandler,middleware:Array.isArray(e.middleware)?e.middleware:e.middleware?[e.middleware]:E.middleware,notFoundHandler:e.notFoundHandler?e.notFoundHandler:o,onRegistered:e.onRegistered??E.onRegistered,logger:e.logger??E.logger,prefix:e.prefix?q(e.prefix).noSlash:E.prefix,render:typeof e.render=="function"?e.render:pe(e.render===void 0?"string":e.render),renderError:typeof e.renderError=="boolean"?e.renderError:E.renderError,renderMiddleware:typeof e.renderMiddleware=="boolean"?e.renderMiddleware:E.renderMiddleware,renderNotFound:typeof e.renderNotFound=="boolean"?e.renderNotFound:E.renderNotFound,stringify:typeof e.stringify=="boolean"?e.stringify:E.stringify,trailingSlash:e.trailingSlash??E.trailingSlash,instanceOptions:e.instanceOptions},r=e.routes?N(F(e.routes),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash}):new Map;t(n,r);function s(a,T){if(typeof a=="object"&&typeof a.handler=="function"){let{method:R,route:b}=de(a),{noSlash:y,withSlash:S}=q(b||ue(a.handler),n.prefix);if(n.trailingSlash==="no-slash"){let v=`${R}::${y}`;r.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${y}`),r.set(v,a.handler),n.onRegistered(R,y)),a.method=R,a.route=y}else if(n.trailingSlash==="slash"){let v=`${R}::${S}`;r.has(v)||(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${S}`),r.set(v,a.handler),n.onRegistered(R,S)),a.method=R,a.route=S}else{let v=`${R}::${y}`,w=`${R}::${S}`;!r.has(v)&&!r.has(w)&&(n.debug&&n.logger.info(`[jhx] Added new route: ${R} ${y}`),r.set(v,a.handler),r.set(w,a.handler),n.onRegistered(R,y)),a.method=R,a.route=y}}let g=T?.stringify??n.stringify,H=a&&typeof a=="object"&&"handler"in a?(({handler:R,...b})=>b)(a):a;return g?L(H,{logger:T?.logger??n.logger,stringify:!0}):L(H,{logger:T?.logger??n.logger,stringify:!1})}return i(s,"jhx"),s.addRoute=a=>{N(F({method:a.method,route:a.route,handler:a.handler}),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},r)},s.addRoutes=a=>{N(F(a),{debug:n.debug,logger:n.logger,onRegistered:n.onRegistered,prefix:n.prefix,trailingSlash:n.trailingSlash},r)},s.clearRoutes=()=>{let a=r.size;r.clear(),n.debug&&n.logger.info(`[jhx] Cleared ${a} route${a===1?"":"s"}`)},s.getRoute=(a,T)=>{let g=a.trim().toUpperCase(),{noSlash:H,withSlash:R}=q(T,n.prefix);if(n.trailingSlash==="no-slash"){let b=`${g}::${H}`,y=r.get(b);return y?{method:g,route:H,handler:y}:null}else if(n.trailingSlash==="slash"){let b=r.get(`${g}::${R}`);return b?{method:g,route:R,handler:b}:null}else{let b=r.get(`${g}::${H}`),y=r.get(`${g}::${R}`);if(!b&&!y)return null;let S=T.endsWith("/");return{method:g,route:S?y?R:H:b?H:R,handler:S?y??b:b??y}}},s.getRoutes=()=>Array.from(r.entries()).map(([a,T])=>{let[g,H]=a.split("::");return!g||!H?null:{method:g,route:H,handler:T}}).filter(a=>a!==null),s.hasRoute=(a,T)=>{let{noSlash:g,withSlash:H}=q(T,n.prefix);return r.has(`${a.toUpperCase()}::${g}`)||r.has(`${a.toUpperCase()}::${H}`)},s.removeRoute=(a,T)=>{let g=a.trim().toUpperCase(),{noSlash:H,withSlash:R}=q(T,n.prefix),b;return n.trailingSlash==="no-slash"?b=r.delete(`${g}::${H}`):n.trailingSlash==="slash"?b=r.delete(`${g}::${R}`):(b=r.delete(`${g}::${H}`),b=r.delete(`${g}::${R}`)||b),b&&n.debug?n.logger.info(`[jhx] Removed route: ${g} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?R:`${H} / ${R}`}`):!b&&n.debug&&n.logger.info(`[jhx] Cannot remove unknown route: ${g} ${n.trailingSlash==="no-slash"?H:n.trailingSlash==="slash"?R:`${H} / ${R}`}`),b},{jhx:s,JhxComponent:I(s)}},"createServerJhx");import{Stream as Oe}from"node:stream";var W=i(e=>e!==null&&typeof e=="object"&&typeof e.send=="function"&&typeof e.status=="function"&&typeof e.json=="function"&&"headersSent"in e,"isExpressResponse"),V=i(e=>!!(e&&(e.headersSent===!0||e.finished===!0||e.writableEnded===!0)),"isResponseSent"),Be=i(e=>e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray||e instanceof BigUint64Array||typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)||typeof Buffer<"u"&&e instanceof Buffer,"isArrayBuffer"),ke=i(e=>e.split("-").map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("-"),"capitalize"),k=i((e,o,t)=>{let n=ke(o);!e.getHeader(n)&&!e.getHeader(o.toLowerCase())&&e.header(n,t)},"ensureHeader"),j=i(async(e,o)=>{if(!(W(o)||V(e))){if(o instanceof Blob){o.type&&k(e,"Content-Type",o.type),o.size>=0&&k(e,"Content-Length",String(o.size));let t=await o.arrayBuffer();e.send(Buffer.from(t));return}o instanceof FormData?k(e,"Content-Type","multipart/form-data"):o instanceof Response||o instanceof ReadableStream||o instanceof Oe||Be(o)?k(e,"Content-Type","application/octet-stream"):typeof o=="object"&&o!==null&&k(e,"Content-Type","application/json"),e.send(o)}},"sendPayload");var D=i((e,o)=>V(e)||o===e||W(o),"isResponseHandled");var me={...E,notFoundHandler:i((e,o)=>{o.status(404).send()},"notFoundHandler")};var ms=i((e,o={})=>fe(o,me.notFoundHandler,(t,n)=>{e.all(`${t.prefix}{*splat}`,async(r,s,a)=>{let T=r.method.toUpperCase(),g=decodeURIComponent(r.url.split("?")[0]),H=n.get(`${T}::${g}`);if(t.contentType&&s.header("content-type",t.contentType),H){for(let y of t.middleware)try{let S=await y(r,s);if(D(s,S))return await j(s,S);if(S!==void 0){let v=t.render&&t.renderMiddleware?await t.render(S,r,s):S;return await j(s,v)}}catch(S){let v=S;if(t.debug&&t.logger.error(`[jhx] Middleware error from '${T} ${g}': ${S.message}`),t.errorHandler){s.status(500);let w=await t.errorHandler(v,r,s);if(D(s,w))return await j(s,w);let ce=t.render&&t.renderError?await t.render(w,r,s):w;return await j(s,ce)}throw new J("Unexpected jhx middleware error",{type:"middleware:error",info:"Unhandled error while handling middleware or rendering middleware payload",method:T,route:g,cause:v})}try{let y=await H(r,s);if(D(s,y))return await j(s,y);let S=t.render?await t.render(y,r,s):y;return await j(s,S)}catch(y){let S=y;if(t.debug&&t.logger.error(`[jhx] Route error from '${T} ${g}': ${y.message}`),t.errorHandler){s.status(500);let v=await t.errorHandler(S,r,s);if(D(s,v))return await j(s,v);let w=t.render&&t.renderError?await t.render(v,r,s):v;return await j(s,w)}throw new J("Unexpected jhx route error",{type:"handler:error",info:"Unhandled error while handling route or rendering route payload",method:T,route:g,cause:S})}}t.debug&&t.logger.info(`[jhx] Request to unknown route '${T} ${g}' from IP address '${r.ip}'`),s.status(404);let R=await t.notFoundHandler(r,s);if(D(s,R))return;let b=t.render&&t.renderNotFound?await t.render(R,r,s):R;return await j(s,b)})}),"createJhx");var Rs=i(e=>I(e),"createJhxComponent");export{Se as applyAttributes,X as attributesToString,ms as createJhx,Rs as createJhxComponent,me as defaultConfig,O as htmx};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jhxdev/express",
3
3
  "description": "HTMX helper with type-safe attribute mapping with inline Express route declaration. Converts props into `hx-*` attributes for templating.",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "author": "nick-hio",
6
6
  "homepage": "https://github.com/nick-hio/jhx/tree/main/packages/express#readme",
7
7
  "repository": {
@@ -42,7 +42,7 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "jhx": "^0.1.4"
45
+ "jhx": "^0.1.5"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "express": "^5",