dphelper 4.6.2 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/index.cjs +3 -3
  2. package/index.js +3 -3
  3. package/markdown/ai.md +345 -0
  4. package/markdown/anchor.md +156 -0
  5. package/markdown/array.md +208 -0
  6. package/markdown/audio.md +113 -0
  7. package/markdown/avoid.md +53 -0
  8. package/markdown/biometric.md +338 -0
  9. package/markdown/browser.md +203 -0
  10. package/markdown/check.md +65 -0
  11. package/markdown/color.md +159 -0
  12. package/markdown/compress.md +310 -0
  13. package/markdown/cookie.md +115 -0
  14. package/markdown/coords.md +127 -0
  15. package/markdown/credits.md +56 -0
  16. package/markdown/date.md +260 -0
  17. package/markdown/disable.md +109 -0
  18. package/markdown/dispatch.md +108 -0
  19. package/markdown/element.md +53 -0
  20. package/markdown/event.md +85 -0
  21. package/markdown/fetch.md +122 -0
  22. package/markdown/form.md +302 -0
  23. package/markdown/format.md +122 -0
  24. package/markdown/i18n.md +292 -0
  25. package/markdown/image.md +298 -0
  26. package/markdown/json.md +269 -0
  27. package/markdown/load.md +133 -0
  28. package/markdown/logging.md +99 -0
  29. package/markdown/math.md +172 -0
  30. package/markdown/memory.md +85 -0
  31. package/markdown/navigation.md +152 -0
  32. package/markdown/net.md +60 -0
  33. package/markdown/obj.md +242 -0
  34. package/markdown/path.md +46 -0
  35. package/markdown/promise.md +94 -0
  36. package/markdown/sanitize.md +129 -0
  37. package/markdown/screen.md +78 -0
  38. package/markdown/scrollbar.md +82 -0
  39. package/markdown/security.md +289 -0
  40. package/markdown/shortcut.md +100 -0
  41. package/markdown/socket.md +134 -0
  42. package/markdown/sse.md +120 -0
  43. package/markdown/svg.md +167 -0
  44. package/markdown/sync.md +171 -0
  45. package/markdown/system.md +78 -0
  46. package/markdown/terminal.md +73 -0
  47. package/markdown/text.md +245 -0
  48. package/markdown/timer.md +98 -0
  49. package/markdown/tools.md +111 -0
  50. package/markdown/translators.md +65 -0
  51. package/markdown/trigger.md +99 -0
  52. package/markdown/triggers.md +133 -0
  53. package/markdown/type.md +109 -0
  54. package/markdown/types.md +102 -0
  55. package/markdown/ui.md +45 -0
  56. package/markdown/window.md +211 -0
  57. package/markdown/worker.md +223 -0
  58. package/modules/ai.cjs +1 -1
  59. package/modules/ai.js +1 -1
  60. package/modules/anchor.cjs +1 -1
  61. package/modules/anchor.js +1 -1
  62. package/modules/array.cjs +1 -1
  63. package/modules/array.js +1 -1
  64. package/modules/audio.cjs +1 -1
  65. package/modules/audio.js +1 -1
  66. package/modules/avoid.cjs +1 -1
  67. package/modules/avoid.js +1 -1
  68. package/modules/biometric.cjs +1 -1
  69. package/modules/biometric.js +1 -1
  70. package/modules/browser.cjs +1 -1
  71. package/modules/browser.js +1 -1
  72. package/modules/check.cjs +1 -1
  73. package/modules/check.js +1 -1
  74. package/modules/color.cjs +1 -1
  75. package/modules/color.js +1 -1
  76. package/modules/compress.cjs +1 -1
  77. package/modules/compress.js +1 -1
  78. package/modules/cookie.cjs +1 -1
  79. package/modules/cookie.js +1 -1
  80. package/modules/coords.cjs +1 -1
  81. package/modules/coords.js +1 -1
  82. package/modules/credits.cjs +1 -1
  83. package/modules/credits.js +1 -1
  84. package/modules/date.cjs +1 -1
  85. package/modules/date.js +1 -1
  86. package/modules/disable.cjs +1 -1
  87. package/modules/disable.js +1 -1
  88. package/modules/dispatch.cjs +1 -1
  89. package/modules/dispatch.js +1 -1
  90. package/modules/elements.cjs +1 -1
  91. package/modules/elements.js +1 -1
  92. package/modules/events.cjs +1 -1
  93. package/modules/events.js +1 -1
  94. package/modules/fetch.cjs +1 -1
  95. package/modules/fetch.js +1 -1
  96. package/modules/form.cjs +1 -1
  97. package/modules/form.js +1 -1
  98. package/modules/format.cjs +1 -1
  99. package/modules/format.js +1 -1
  100. package/modules/i18n.cjs +1 -1
  101. package/modules/i18n.js +1 -1
  102. package/modules/image.cjs +1 -1
  103. package/modules/image.js +1 -1
  104. package/modules/json.cjs +1 -1
  105. package/modules/json.js +1 -1
  106. package/modules/load.cjs +1 -1
  107. package/modules/load.js +1 -1
  108. package/modules/logging.cjs +1 -1
  109. package/modules/logging.js +1 -1
  110. package/modules/math.cjs +1 -1
  111. package/modules/math.js +1 -1
  112. package/modules/memory.cjs +1 -1
  113. package/modules/memory.js +1 -1
  114. package/modules/navigation.cjs +1 -1
  115. package/modules/navigation.js +1 -1
  116. package/modules/net.cjs +1 -1
  117. package/modules/net.js +1 -1
  118. package/modules/objects.cjs +1 -1
  119. package/modules/objects.js +1 -1
  120. package/modules/path.cjs +1 -1
  121. package/modules/path.js +1 -1
  122. package/modules/promise.cjs +1 -1
  123. package/modules/promise.js +1 -1
  124. package/modules/sanitize.cjs +1 -1
  125. package/modules/sanitize.js +1 -1
  126. package/modules/screen.cjs +1 -1
  127. package/modules/screen.js +1 -1
  128. package/modules/scrollbar.cjs +1 -1
  129. package/modules/scrollbar.js +1 -1
  130. package/modules/security.cjs +1 -1
  131. package/modules/security.js +1 -1
  132. package/modules/shortcut.cjs +1 -1
  133. package/modules/shortcut.js +1 -1
  134. package/modules/socket.cjs +1 -1
  135. package/modules/socket.js +1 -1
  136. package/modules/sse.cjs +1 -1
  137. package/modules/sse.js +1 -1
  138. package/modules/svg.cjs +1 -1
  139. package/modules/svg.js +1 -1
  140. package/modules/sync.cjs +1 -1
  141. package/modules/sync.js +1 -1
  142. package/modules/system.cjs +1 -1
  143. package/modules/system.js +1 -1
  144. package/modules/text.cjs +1 -1
  145. package/modules/text.js +1 -1
  146. package/modules/timer.cjs +1 -1
  147. package/modules/timer.js +1 -1
  148. package/modules/tools.cjs +1 -1
  149. package/modules/tools.js +1 -1
  150. package/modules/translators.cjs +1 -1
  151. package/modules/translators.js +1 -1
  152. package/modules/triggers.cjs +1 -1
  153. package/modules/triggers.js +1 -1
  154. package/modules/types.cjs +1 -1
  155. package/modules/types.js +1 -1
  156. package/modules/ui.cjs +1 -1
  157. package/modules/ui.js +1 -1
  158. package/modules/window.cjs +1 -1
  159. package/modules/window.js +1 -1
  160. package/modules/worker.cjs +1 -1
  161. package/modules/worker.js +1 -1
  162. package/package.json +3 -1
  163. package/sbom.json +7 -7
package/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var V={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var x={codeName:"dphelper",version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...V},configurable:true,writable:true},version:{value:x.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var P=dphelper;Object.defineProperty(P,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(P,"setDescription",{value:(e,t)=>{Object.defineProperties(P,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(P[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),P.setProps(P,e,{writable:false,configurable:false,enumerable:false}),P._list.scripts.push(e);}});var ue={name:"ai",active:true,subCommand:[{name:"tokenCount",version:"0.0.3",example:"dphelper.ai.tokenCount({ users: [1,2,3] })",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260221",type:"function",active:true,description:"Estimate token count for LLMs. If an object is passed, it uses TOON format for calculation.",env:"both",subCommand:[]},{name:"smartSanitize",version:"0.0.2",example:"dphelper.ai.smartSanitize('My email is test@example.com')",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Remove PII (emails, phones, etc) from text for AI privacy",subCommand:[]},{name:"toon",version:"0.0.1",example:"dphelper.ai.toon({ users: [{id: 1, name: 'Ada'}] })",author:"TOON + Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Convert JSON to TOON format (Token-Oriented Object Notation)",subCommand:[]},{name:"toonToJson",version:"0.0.1",example:"dphelper.ai.toonToJson('users[1]{id,name}:\\n 1,Ada')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Convert TOON format back to JSON/Object",subCommand:[]},{name:"chunker",version:"0.0.1",example:"dphelper.ai.chunker(text, { size: 1000, overlap: 200 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Split long text into chunks for RAG or AI processing.",subCommand:[]},{name:"similarity",version:"0.0.1",example:"dphelper.ai.similarity(vecA, vecB)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Calculate cosine similarity between two embedding vectors.",subCommand:[]},{name:"extractReasoning",version:"0.0.1",example:"dphelper.ai.extractReasoning(aiResponse)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Extract <think> tags or internal reasoning from AI responses.",subCommand:[]},{name:"prompt",version:"0.0.1",example:"dphelper.ai.prompt('Hello {{name}}', { name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Simple prompt template engine with variable injection.",subCommand:[]},{name:"schema",version:"0.0.1",example:"dphelper.ai.schema({ id: 1, name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Generate a TOON-style schema definition for AI instructions.",subCommand:[]},{name:"snapshot",version:"0.0.1",example:"dphelper.ai.snapshot()",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Capture a 'mental snapshot' of the app state (logs/globals) in TOON format for AI debugging.",env:"both",subCommand:[]}]},B=e=>e===null||typeof e!="object",H=e=>e===null?"null":typeof e=="string"?e.includes(",")||e.includes(":")||e.includes('"')||e.includes(`
1
+ 'use strict';var V={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var x={codeName:"dphelper",version:"4.7.0"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...V},configurable:true,writable:true},version:{value:x.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var P=dphelper;Object.defineProperty(P,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(P,"setDescription",{value:(e,t)=>{Object.defineProperties(P,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(P[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),P.setProps(P,e,{writable:false,configurable:false,enumerable:false}),P._list.scripts.push(e);}});var ue={name:"ai",active:true,subCommand:[{name:"tokenCount",version:"0.0.3",example:"dphelper.ai.tokenCount({ users: [1,2,3] })",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260221",type:"function",active:true,description:"Estimate token count for LLMs. If an object is passed, it uses TOON format for calculation.",env:"both",subCommand:[]},{name:"smartSanitize",version:"0.0.2",example:"dphelper.ai.smartSanitize('My email is test@example.com')",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Remove PII (emails, phones, etc) from text for AI privacy",subCommand:[]},{name:"toon",version:"0.0.1",example:"dphelper.ai.toon({ users: [{id: 1, name: 'Ada'}] })",author:"TOON + Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Convert JSON to TOON format (Token-Oriented Object Notation)",subCommand:[]},{name:"toonToJson",version:"0.0.1",example:"dphelper.ai.toonToJson('users[1]{id,name}:\\n 1,Ada')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Convert TOON format back to JSON/Object",subCommand:[]},{name:"chunker",version:"0.0.1",example:"dphelper.ai.chunker(text, { size: 1000, overlap: 200 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Split long text into chunks for RAG or AI processing.",subCommand:[]},{name:"similarity",version:"0.0.1",example:"dphelper.ai.similarity(vecA, vecB)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Calculate cosine similarity between two embedding vectors.",subCommand:[]},{name:"extractReasoning",version:"0.0.1",example:"dphelper.ai.extractReasoning(aiResponse)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Extract <think> tags or internal reasoning from AI responses.",subCommand:[]},{name:"prompt",version:"0.0.1",example:"dphelper.ai.prompt('Hello {{name}}', { name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Simple prompt template engine with variable injection.",subCommand:[]},{name:"schema",version:"0.0.1",example:"dphelper.ai.schema({ id: 1, name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Generate a TOON-style schema definition for AI instructions.",subCommand:[]},{name:"snapshot",version:"0.0.1",example:"dphelper.ai.snapshot()",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Capture a 'mental snapshot' of the app state (logs/globals) in TOON format for AI debugging.",env:"both",subCommand:[]}]},B=e=>e===null||typeof e!="object",H=e=>e===null?"null":typeof e=="string"?e.includes(",")||e.includes(":")||e.includes('"')||e.includes(`
2
2
  `)||e.trim()!==e?`"${e.replace(/"/g,'\\"')}"`:e||'""':String(e),N=(e,t=0)=>{let r=" ".repeat(t);if(B(e))return H(e);if(Array.isArray(e)){if(e.length===0)return "[0]:";let n=e[0];if(!B(n)&&!Array.isArray(n)){let o=Object.keys(n),a=`[${e.length}]{${o.join(",")}}:`;for(let i of e){let s=o.map(l=>H(i[l])).join(",");a+=`
3
3
  ${r} ${s}`;}return a}else return `[${e.length}]: `+e.map(H).join(",")}else return Object.entries(e).map(([n,o])=>{let a=n.includes(" ")||n.includes(":")?`"${n}"`:n;if(!B(o)){let i=N(o,t+1);return i.startsWith("[")?`${a}${i}`:`${a}:
4
4
  ${r}${i}`}return `${a}: ${H(o)}`}).join(`
@@ -129,7 +129,7 @@ ${t(i,`${n} `)}${n}</${a}>
129
129
  left:0;
130
130
  z-index:2
131
131
  `;}if(!e.el&&r){r.style.width="0%";return}try{let n=document.querySelector(".scrollindicator");t.addEventListener("scroll",function(o){n.style.width="0%";let a=Number(this.scrollTop),i=Number(this.scrollHeight-this.clientHeight),s=Math.min(Math.max(a/i*100),100);n.style.width=`${s}%`,n.click();}),t.addEventListener("popstate",o=>{n.style.width=0;});}catch(n){console.error(n);return}},position:{set:e=>{let t=typeof e=="string"?document.querySelector(e):e;if(!t)return;let r=[t.scrollTop,t.scrollLeft];r[0]!=null&&r[1]!=null&&localStorage.setItem(e,JSON.stringify(r));},get:e=>{if(localStorage.getItem(e))try{let t=localStorage.getItem(e),r=typeof e=="string"?document.querySelector(e):e;r&&t&&(r.scrollTop=t[0],r.scrollLeft=t[1]);}catch(t){console.error("Error getting scroll position:",t);}}},smooth:(e,t,r)=>{e===document&&(e=document.scrollingElement||document.documentElement||document.body.parentNode||document.body);let n=false,o=e.scrollTop,a=e===document.body&&document.documentElement?document.documentElement:e,i=c=>{c.preventDefault();let u=s(c);o+=-u*t,o=Math.max(0,Math.min(o,e.scrollHeight-a.clientHeight)),n||l();};e.addEventListener("mousewheel",i,{passive:false}),e.addEventListener("DOMMouseScroll",i,{passive:false});let s=c=>c.detail?c.wheelDelta?c.wheelDelta/c.detail/40*(c.detail>0?1:-1):-c.detail/3:c.wheelDelta/120,l=()=>{n=true;let c=(o-e.scrollTop)/r;e.scrollTop+=c,Math.abs(c)>.5?d(l):n=false;},d=dphelper.window.animationframe();},scrollTo:(e,t,r=0)=>{let n=document.querySelector(e),o=document.querySelector(t);n&&o&&n.scrollTo({top:o.offsetTop-r,behavior:"smooth"});}};dphelper?.setDescription(Pr,kr);var Tr={name:"security",active:true,subCommand:[{name:"uuid",version:"0.0.2",example:"dphelper.security.uuid",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"UUID related commands",subCommand:[{name:"byVal",version:"0.0.2",example:"dphelper.security.uuid.byVal('string')",author:"Dario Passariello",creationDate:"20250101",lastMod:"20250101",type:"function",active:true,description:"Generate a UUID based on a given string",env:"both",subCommand:[]},{name:"v4",version:"0.0.2",example:"dphelper.security.uuid.v4",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"return",active:true,description:"Generate a random UUID v4",env:"both",subCommand:[]},{name:"v5",version:"0.0.2",example:"dphelper.security.uuid.v5",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"return",active:true,description:"Generate a random UUID v5",env:"both",subCommand:[]}]},{name:"hashPass",description:"Generate a crypto digest starting from user and password values (Uses SHA-256, CNSA compliant)",example:"dphelper.security.hashPass(user, password)",version:"0.0.3",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260329",active:true,env:"both",subCommand:[]},{name:"crypt",description:"Encrypt your message using a secret_key in a default format AES",example:"dphelper.security.crypt(data, secret_key, [optional mode])",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"deCrypt",description:"Decrypt your message using a secret_key in a default format AES",example:"dphelper.security.deCrypt(data, secret_key, [optional mode])",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"AES_KeyGen",description:"Generate a key based on the AES algorithm",example:"dphelper.security.AES_KeyGen(secret_key)",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"SHA256_Hex",description:"Generate a SHA256 hash in hexadecimal format",example:"dphelper.security.SHA256_Hex(secret_key)",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20250101",lastMod:"20250101",active:true,env:"both",subCommand:[]},{name:"ulid",description:"Generate ULID code",example:"dphelper.security.ulid()",version:"0.0.2",type:"function",author:"mix",creationDate:"20250212",lastMod:"20250212",active:true,env:"both",subCommand:[]},{name:"fingerprint",description:"Generate a unique browser fingerprint",example:"dphelper.security.fingerprint()",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"saveEncrypted",description:"Save encrypted data to localStorage",example:"dphelper.security.saveEncrypted('key', 'value', 'secret')",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"getEncrypted",description:"Retrieve and decrypt data from localStorage",example:"dphelper.security.getEncrypted('key', 'secret')",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]}]},I=new TextEncoder,Er=new TextDecoder,Ar=e=>{let t=new Uint8Array(e),r="";for(let n=0;n<t.byteLength;n++)r+=String.fromCharCode(t[n]);return btoa(r)},Lr=e=>{let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r.buffer},Or=async e=>{let t=I.encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")},ne=async(e,t)=>{let r=I.encode(t),n=await crypto.subtle.importKey("raw",r,{name:"HMAC",hash:"SHA-256"},false,["sign"]),o=await crypto.subtle.sign("HMAC",n,I.encode(e));return Array.from(new Uint8Array(o)).map(i=>i.toString(16).padStart(2,"0")).join("")},ae=async(e,t,r)=>{let n=await crypto.subtle.importKey("raw",I.encode(e),"PBKDF2",false,["deriveBits","deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:t.buffer,iterations:r,hash:"SHA-256"},n,{name:"AES-GCM",length:256},false,["encrypt","decrypt"])},Rr=async(e,t)=>{let r=crypto.getRandomValues(new Uint8Array(16)),n=crypto.getRandomValues(new Uint8Array(12)),o=await ae(t,new Uint8Array(r.buffer),31e4),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:new Uint8Array(n.buffer)},o,I.encode(e)),i=new Uint8Array(r.length+n.length+a.byteLength);return i.set(r,0),i.set(n,r.length),i.set(new Uint8Array(a),r.length+n.length),Ar(i.buffer)},Ir=async(e,t)=>{try{let r=new Uint8Array(Lr(e)),n=r.slice(0,16),o=r.slice(16,28),a=r.slice(28),i=await ae(t,new Uint8Array(n.buffer),31e4),s=await crypto.subtle.decrypt({name:"AES-GCM",iv:new Uint8Array(o.buffer)},i,a);return Er.decode(s)}catch{return ""}},oe=-1,D=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","M","N","P","Q","R","S","T","V","W","X","Y","Z"],jr={uuid:{byVal:async e=>{if(!e)return console.warn("You need to pass a value to obtain a fixed uuid"),"";let t=await dphelper.security.SHA256_Hex(e);return [t.slice(0,8),t.slice(8,4),`4${t.slice(12,3)}`,`8${t.slice(15,3)}`,t.slice(18,12)].join("-")},v4:"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),v5:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=crypto.getRandomValues(new Uint8Array(1))[0];return (e==="x"?t:t&3|8).toString(16)})},hashPass:async(e,t)=>{if(!e||!t)return console.warn("hashPass: user and password are required"),"";let r=new TextEncoder,n=crypto.getRandomValues(new Uint8Array(16)),o=Array.from(n).map(d=>d.toString(16).padStart(2,"0")).join(""),a=await crypto.subtle.importKey("raw",r.encode(t.toLowerCase()+e.toLowerCase()),{name:"PBKDF2"},false,["deriveBits"]),i=await crypto.subtle.deriveBits({name:"PBKDF2",salt:n.buffer,iterations:31e4,hash:"SHA-256"},a,256),l=Array.from(new Uint8Array(i)).map(d=>d.toString(16).padStart(2,"0")).join("");return o+l},crypt:async(e,t)=>await Rr(e,t),deCrypt:async(e,t)=>await Ir(e,t),AES_KeyGen:async e=>{let t=e||crypto.randomUUID(),r=crypto.getRandomValues(new Uint8Array(16)),n=Array.from(r).map(i=>i.toString(16).padStart(2,"0")).join(""),o=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r.buffer,iterations:31e4,hash:"SHA-256"},await crypto.subtle.importKey("raw",I.encode(t),"PBKDF2",false,["deriveBits"]),512),a=Array.from(new Uint8Array(o));return n+a.map(i=>i.toString(16).padStart(2,"0")).join("")},SHA256_Hex:async e=>Or(e),ulid:()=>{let e=new Uint8Array(16),t=new DataView(e.buffer,0,6),r=new Uint8Array(e.buffer,6,10),n=new Array(26),o=i=>{n[0]=D[i[0]>>5],n[1]=D[i[0]>>0&31];for(let s=0;s<3;s++)n[s*8+2]=D[i[s*5+1]>>3],n[s*8+3]=D[(i[s*5+1]<<2|i[s*5+2]>>6)&31],n[s*8+4]=D[i[s*5+2]>>1&31],n[s*8+5]=D[(i[s*5+2]<<4|i[s*5+3]>>4)&31],n[s*8+6]=D[(i[s*5+3]<<1|i[s*5+4]>>7)&31],n[s*8+7]=D[i[s*5+4]>>2&31],n[s*8+8]=D[(i[s*5+4]<<3|i[s*5+5]>>5)&31],n[s*8+9]=D[i[s*5+5]>>0&31];return n.join("")},a=Date.now();if(a===oe)for(let i=9;i>=0&&!(r[i]!==void 0&&r[i]++<255);i--);else oe=a,t.setUint16(0,a/4294967296|0),t.setUint32(2,a|0),window.crypto.getRandomValues(r);return o(e)},fingerprint:async e=>{let t=e?.requireConsent!==false,r=e?.consent;if(t&&r!==true)return console.warn("dphelper.security.fingerprint: User consent required. Pass { consent: true } to enable."),console.warn("dphelper.security.fingerprint: Fingerprinting is subject to GDPR/CCPA. Ensure privacy policy and user consent."),"";let n=navigator,o=window.screen,a=document.createElement("canvas"),i=a.getContext("2d"),s="dphelper_fingerprint_v1",l="";i&&(a.width=200,a.height=30,i.textBaseline="top",i.font="14px 'Arial'",i.textBaseline="alphabetic",i.fillStyle="#f60",i.fillRect(125,1,62,20),i.fillStyle="#069",i.fillText(s,2,15),i.fillStyle="rgba(102, 204, 0, 0.7)",i.fillText(s,4,17),l=a.toDataURL());let d=[n.userAgent,n.language,o.colorDepth,o.width+"x"+o.height,new Date().getTimezoneOffset(),n.deviceMemory||"unknown",n.hardwareConcurrency||"unknown",l].join("|");return dphelper.security.SHA256_Hex(d)},saveEncrypted:async(e,t,r)=>{if(typeof document>"u"||typeof window>"u"){console.warn("[dphelper] localStorage not available in this environment");return}let n=await dphelper.security.crypt(t,r),o=await ne(n,r);localStorage.setItem(e,JSON.stringify({d:n,h:o,v:"2.0"}));},getEncrypted:async(e,t)=>{let r=localStorage.getItem(e);if(!r)return null;try{let n=JSON.parse(r);if(n&&n.h&&n.d){let o=await ne(n.d,t);return n.h!==o?(console.error(`[dphelper] Security Alert: Data tampering detected for key "${e}"`),null):dphelper.security.deCrypt(n.d,t)}return dphelper.security.deCrypt(r,t)}catch{try{return dphelper.security.deCrypt(r,t)}catch(o){return console.warn(`[dphelper] Persistence Error for key "${e}":`,o),null}}}},Nr=jr;typeof dphelper?.setDescription=="function"&&dphelper.setDescription(Tr,Nr);var $r={name:"shortcut",active:true,subCommand:[{name:"keys",version:"0.0.2",example:"dphelper.shortcut.keys([e, trigger])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Handle keyboard shortcuts.",env:"client",subCommand:[]}]},qr={keys:(e,t)=>{let r=e.which?e.which:e.keyCode;t||(t={data:[{key:"83",ctrl:true,active:true,description:"CTRL+S",function:""},{key:"27",ctrl:false,active:true,description:"ESC",element:"",function:""},{key:"80",ctrl:true,active:true,description:"CTRL+P",element:"",function:"function(){ Print }"}]}),t.data&&t.data.map(n=>(e.ctrlKey||e.metaKey&&n.ctrl===true)&&r===Number.parseInt(n.key)&&n.active===true?(n.element&&n.element.click(),n.function?JSON.stringify(n.function):(e.preventDefault(),null)):null);}};dphelper?.setDescription($r,qr);var w={ws:{}},Hr={name:"socket",active:true,subCommand:[{name:"info",version:"0.0.2",example:"dphelper.socket.info(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Retrieve socket information",env:"client",subCommand:[]},{name:"start",version:"0.0.2",example:"dphelper.socket.start(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Start a socket connection",env:"client",subCommand:[]},{name:"conn",version:"0.0.2",example:"dphelper.socket.conn(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Manage socket connections",env:"client",subCommand:[]},{name:"connect",version:"0.0.2",example:"dphelper.socket.connect(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Connect to a socket",env:"client",subCommand:[]},{name:"open",version:"0.0.2",example:"dphelper.socket.open(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Open a socket connection",env:"client",subCommand:[]},{name:"send",version:"0.0.2",example:"dphelper.socket.send(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Send data through a socket",env:"client",subCommand:[]},{name:"receive",version:"0.0.2",example:"dphelper.socket.receive(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Receive data from a socket",env:"client",subCommand:[]},{name:"keepAlive",version:"0.0.2",example:"dphelper.socket.keepAlive(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Keep the socket connection alive",env:"client",subCommand:[]},{name:"check",version:"0.0.2",example:"dphelper.socket.check()",author:"Dario Passariello",creationDate:"2023-05-27",lastMod:"2023-05-27",type:"function",active:true,description:"Check how many websocket connections are open",env:"client",subCommand:[]},{name:"list",version:"0.0.2",example:"dphelper.socket.list()",author:"Dario Passariello",creationDate:"2023-05-27",lastMod:"2023-05-27",type:"function",active:true,description:"List all websocket connections in real-time",env:"client",subCommand:[]},{name:"close",version:"0.0.1",example:"dphelper.socket.close([name])",author:"Dario Passariello",creationDate:"2026-05-18",lastMod:"2025-05-18",type:"function",active:true,description:"Close websocket connections by name",env:"client",subCommand:[]}]},Ur={info:()=>"Created by Dario Passariello",start:(e,t="general")=>{w.ws={},dphelper.socket.connect(e,t);},conn:(e,t,r,n)=>{if(!(e&&t)){console.debug("please use connect!");return}try{let o;try{o=new URL(t);}catch{if(!t.startsWith("/")&&!t.startsWith("ws")&&!t.startsWith("wss"))o=new URL(t,window.location.origin);else {console.error("Invalid WebSocket URL");return}}if(o.protocol==="ws:"){console.error("Insecure WebSocket protocol 'ws://' - must use 'wss://'");return}n&&o.searchParams.set("token",n);let a=new WebSocket(o.toString());return a.binaryType="blob",a.onmessage=i=>{},[a,e,r]}catch(o){console.error(o);return}},connect:(e,t)=>{e&&dphelper.socket.open(dphelper.security.uuid.v5,e,t);},open:(e,t,r,n)=>{if(e)try{let o=dphelper.socket.conn(e,t,r,n);if(!o)return;w.ws[r]=o,dphelper._list.sockets.indexOf(o[0])===-1&&dphelper._list.sockets.push(o[0]);let a=0,i=5,s=1e3,l=()=>{if(a>=i){console.error(`[dphelper] Socket "${r}" max reconnect attempts (${i}) reached`);return}a++;let m=Math.min(s*Math.pow(2,a),3e4);console.debug(`[dphelper] Reconnecting socket "${r}" in ${m}ms (attempt ${a}/${i})`),setTimeout(()=>{dphelper.socket.open(e,t,r,n);},m);},d=()=>{dphelper.log.reg(`${e} connected`),a=0;},c=m=>{dphelper.log.debug(m.wasClean?"Disconnected":`Connection break: ${m.reason||m.code}`),m.wasClean||l();},u=m=>{dphelper.log?.error(m);};o[0].onopen=d,o[0].onclose=c,o[0].onerror=u,o[0].__dphelper_handlers={origOnOpen:d,origOnClose:c,origOnError:u};}catch(o){console.error(o);}},ping:e=>{if(w.ws[e]?.[1])try{w.ws[e]?.[0]?.send('{"debug":"__ping__"}');}catch(t){console.error(t);}},send:(e,t)=>{if(w.ws[t]?.[1]&&e)try{let r=w.ws[t];if(!r)return;r[0].send(String(e));}catch(r){console.error(r);}},receive:(e,t)=>{if(w.ws[t]?.[1])try{let r=w.ws[t],n=r[0];n.onmessage=o=>{e(o),dphelper.log.reg(o);};}catch(r){console.error(r);}},keepAlive:e=>{try{let t=w.ws[e];if(!t)return;let r=t[0],n=r.__dphelper_handlers;if(!n){console.warn("[dphelper] keepAlive: no stored handlers found for",e);return}let o,a=(c=5e3)=>{o=setTimeout(()=>{dphelper.socket.ping(e);},c);},i=()=>clearTimeout(o),s=()=>{n.origOnOpen?.(),setInterval(a,3e4);},l=c=>{try{Object.values(JSON.parse(c.data))[0]==="__ping__"&&i();}catch(u){console.error(u);}},d=n.origOnMessage;r.onopen=s,r.onmessage=c=>{typeof d=="function"&&d(c),l(c);};}catch(t){console.error(t);}},check:()=>{dphelper._list.sockets=dphelper._list.sockets.filter(e=>e.readyState!==WebSocket.CLOSED);},list:()=>dphelper._list.sockets,close:e=>{try{let t=w.ws[e];if(!t)return;t[0].close();}catch(t){console.error(t);}}};dphelper?.setDescription(Hr,Ur);typeof document<"u"&&dphelper?.socket?.check();var zr={name:"sse",active:true,subCommand:[{name:"open",version:"0.0.2",example:"dphelper.sse.open('/api/stream', { method: 'POST', body: ... })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260513",type:"function",active:true,description:"Advanced Server-Sent Events client with POST and Custom Headers support. HTTPS required. Validates Content-Type before processing.",env:"client",subCommand:[]}]},_r=e=>{try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"?(console.error("[dphelper] Only HTTP/HTTPS protocols allowed for SSE"),!1):!0}catch{return true}},Fr=e=>e?e.includes("text/event-stream")||e.includes("text/plain"):false,Br={open:(e,t={})=>{if(!_r(e))return {on:()=>{},close:()=>{}};let r={message:[],error:[],open:[]},n=new AbortController,o=(i,s)=>{r[i]?.forEach(l=>l(s));};return (async()=>{try{let i=await fetch(e,{...t,signal:n.signal,headers:{Accept:"text/event-stream",...t.headers||{}}});if(!i.ok)throw new Error(`SSE failed: ${i.statusText}`);let s=i.headers.get("Content-Type");if(!Fr(s)){console.error(`[dphelper] SSE: Invalid Content-Type "${s}". Expected text/event-stream.`),n.abort(),o("error",new Error(`Invalid Content-Type: ${s}`));return}o("open",{status:i.status});let l=i.body?.getReader(),d=new TextDecoder;if(!l)return;let c="";for(;;){let{done:u,value:m}=await l.read();if(u)break;c+=d.decode(m,{stream:!0});let h=c.split(`
132
- `);c=h.pop()||"";for(let b of h)if(b.startsWith("data:")){let f=b.replace("data:","").trim();try{(f.includes("[")||f.includes("{"))&&(f=JSON.parse(f));}catch{}o("message",f);}}}catch(i){i.name!=="AbortError"&&o("error",i);}})(),{on:(i,s)=>{r[i]&&r[i].push(s);},close:()=>n.abort()}}};dphelper?.setDescription(zr,Br);var Wr={name:"svg",active:true,subCommand:[{name:"init",version:"0.0.2",example:"dphelper.svg.init(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Initializes an SVG connection between two elements.",env:"client",subCommand:[]},{name:"check",version:"0.0.2",example:"dphelper.svg.check(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Checks if SVG support is available.",env:"client",subCommand:[]},{name:"update",version:"0.0.2",example:"dphelper.svg.update(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Updates the SVG connection between two elements.",env:"client",subCommand:[]},{name:"getCurve",version:"0.0.2",example:"dphelper.svg.getCurve(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the curve of the connection between two points.",env:"client",subCommand:[]},{name:"getIntersection",version:"0.0.2",example:"dphelper.svg.getIntersection(...) ",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the intersection point between two elements.",env:"client",subCommand:[]},{name:"setConnector",version:"0.0.2",example:"dphelper.svg.setConnector(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Sets a connector on an element.",env:"client",subCommand:[]},{name:"removeConnection",version:"0.0.2",example:"dphelper.svg.removeConnection(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Removes an SVG connection from a container.",env:"client",subCommand:[]},{name:"makeScrollable",version:"0.0.2",example:"dphelper.svg.makeScrollable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG container scrollable.",env:"client",subCommand:[]},{name:"makeDraggable",version:"0.0.2",example:"dphelper.svg.makeDraggable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG element draggable.",env:"client",subCommand:[]},{name:"toggle",version:"0.0.2",example:"dphelper.svg.toggle(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Toggles an SVG connection on or off.",env:"client",subCommand:[]},{name:"convert",version:"0.0.2",example:"dphelper.svg.convert([Object])",author:"Dario Passariello",creationDate:"20190101",lastMod:"20240401",type:"function",active:true,description:"Converts an element to SVG.",env:"client",subCommand:[]}]},Gr={init:(e,t,r,n)=>{e.querySelector("svg")&&dphelper.svg.removeConnection(e),t=[dphelper.svg.setConnector(t[0],t[1]),t[1]],r=[dphelper.svg.setConnector(r[0],r[1]),r[1]];let o=e.getBoundingClientRect(),a="http://www.w3.org/2000/svg",i=e.offsetWidth*10,s=e.offsetHeight*10,l=document.createElementNS(a,"svg"),d=`conn_${Math.random().toString(36).substring(2,9)}`;l.setAttribute("xmlns",a),l.dataset.dphelper="svg-connection",l.setAttributeNS(null,"viewBox","0 0 "+i+" "+s),l.setAttributeNS(null,"width",String(i)),l.setAttributeNS(null,"height",String(s)),l.style.display="block";let c=document.createElementNS(a,"rect"),u=t[0].getBoundingClientRect();c.setAttributeNS(null,"x",String(u.left-o.left)),c.setAttributeNS(null,"y",String(u.top-o.top)),c.setAttributeNS(null,"width",String(u.width)),c.setAttributeNS(null,"height",String(u.height)),l.appendChild(c);let m=document.createElementNS(a,"rect");u=r[0].getBoundingClientRect(),m.setAttributeNS(null,"x",String(u.left-o.left)),m.setAttributeNS(null,"y",String(u.top-o.top)),m.setAttributeNS(null,"width",String(u.width)),m.setAttributeNS(null,"height",String(u.height)),l.appendChild(m);let h=document.createElementNS(a,"path");h.setAttributeNS(null,"id",d),h.setAttributeNS(null,"marker-end","url(#head)"),l.appendChild(h),e.appendChild(l),dphelper.svg.update(c,m,h),typeof n=="function"&&n(t,r);},check:()=>!!(document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),update:(e,t,r)=>{let n=Number.parseFloat(e.getAttribute("x")||"0"),o=Number.parseFloat(e.getAttribute("y")||"0"),a=Number.parseFloat(t.getAttribute("x")||"0"),i=Number.parseFloat(t.getAttribute("y")||"0"),s=Number.parseFloat(e.getAttribute("width")||"0")/2,l=Number.parseFloat(e.getAttribute("height")||"0")/2,d=Number.parseFloat(t.getAttribute("width")||"0")/2,c=Number.parseFloat(t.getAttribute("height")||"0")/2,u=n+s,m=o+l,h=a+d,b=i+c,f=h-u,g=b-m,v=dphelper.svg.getIntersection(f,g,u,m,s,l),S=dphelper.svg.getIntersection(-f,-g,h,b,d,c),L=S[0]-v[0],j=dphelper.svg.getCurve(v,S,L);r.setAttributeNS(null,"d","M"+u+","+m+j+h+","+b);},getCurve:(e,t,r)=>{let n=r/2;return " C"+(n+e[0])+","+e[1]+" "+(t[0]-n)+","+t[1]+" "},getIntersection:(e,t,r,n,o,a)=>Math.abs(t/e)<a/o?[r+(e>0?o:-o),n+t*o/Math.abs(e)]:[r+e*a/Math.abs(t),n+(t>0?a:-a)],setConnector:(e,t)=>{let r,n=document.createElement("span");switch(e.style.position="relative",n.style.position="absolute",n.style.width="5px",n.style.height="5px",t){case "top":r={left:"50%",top:"2.5px",marginLeft:"2.5px"};break;case "right":r={top:"50%",right:"2.5px",marginTop:"-2.5px"};break;case "bottom":r={left:"50%",bottom:"-2.5px",marginLeft:"2.5px"};break;case "left":r={top:"50%",left:"-2.5px",marginTop:"-2.5px"};break;default:r={};}return Object.assign(n.style,r),e.appendChild(n),n},removeConnection:e=>{e.querySelectorAll("svg[data-dphelper='svg-connection']").forEach(r=>r.remove());},makeScrollable:(e,t,r,n,o,a)=>{let i=e.getBoundingClientRect(),s=[r,n],l=s.length,d=[o,a],c=[];for(let f=0;f<l;f++){let g=s[f],v=d[f];!g||!v||(c[f]=g.getBoundingClientRect(),v.setAttributeNS(null,"x",String(c[f].left-i.left)),v.setAttributeNS(null,"y",String(c[f].top-i.top)),v.setAttributeNS(null,"width",String(c[f].width)),v.setAttributeNS(null,"height",String(c[f].height)));}let u=e.querySelectorAll("rect"),m=u[0],h=u[1],b=document.getElementById("connection");m&&h&&b&&dphelper.svg.update(m,h,b);},makeDraggable:e=>{let t=e.target;function r(d){let c=t.getScreenCTM();return c?{x:(d.clientX-c.e)/c.a,y:(d.clientY-c.f)/c.d}:{x:0,y:0}}let n=null,o=null,a=d=>{if(n&&o){let c=r(d);n.setAttributeNS(null,"x",String(c.x-o.x)),n.setAttributeNS(null,"y",String(c.y-o.y));let u=document.getElementById("connection");u&&dphelper.svg.update(n,n,u);}},i=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i),n=null,o=null;},s=d=>{d.target.classList.contains("draggable")&&(n=d.target,o=r(d),o.x-=Number.parseFloat(n.getAttributeNS(null,"x")||"0"),o.y-=Number.parseFloat(n.getAttributeNS(null,"y")||"0"),document.addEventListener("mousemove",a),document.addEventListener("mouseup",i));};t.addEventListener("mousedown",s),t.__dphelper_cleanup=()=>{t.removeEventListener("mousedown",s),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i);};let l=new MutationObserver(()=>{document.contains(t)||(t.__dphelper_cleanup&&t.__dphelper_cleanup(),l.disconnect());});l.observe(document.body,{childList:true,subtree:true});},toggle:(e,t,r,n)=>{let o=e.target;if(o.checked&&r&&n){dphelper.cookie.set({name:`${o.id}`,value:1,time:365});let a=()=>{dphelper.svg.makeScrollable(t,document.getElementById("parts-left-body"),r,n,document.querySelector("#parts svg rect"),document.querySelectorAll("#parts svg rect")[1]);};dphelper.svg.init(t,[r,"right"],[n,"left"],(i,s)=>{let l=document.getElementById("parts-left-body");l&&(l.addEventListener("scroll",a),l.__dphelper_scrollHandler=a);});}else {dphelper.svg.removeConnection(t);let a=document.getElementById("parts-left-body");a&&a.__dphelper_scrollHandler&&(a.removeEventListener("scroll",a.__dphelper_scrollHandler),delete a.__dphelper_scrollHandler),a&&a.replaceWith(a.cloneNode(true)),dphelper.cookie.set({name:`${o.id}`,value:0,time:365});}},convert:({children:e,active:t=true,size:r=[1920,1080],fit:n=["100%","100%"],preserveAspectRatio:o="none",style:a=`width:${n[0]}; height:${n[1]}`,zoom:i=1})=>{if(!e)return "Please pass ID of element for SVG conversion";if(t){let s=h=>h.replace(/[<>"'&]/g,""),l=document.querySelector(e);if(!l)return "Element not found";let d=l.cloneNode(true),c="http://www.w3.org/2000/svg",u=document.createElementNS(c,"svg");u.setAttribute("viewBox",`0 0 ${s(String(r[0]))} ${s(String(r[1]))}`),u.setAttribute("preserveAspectRatio",s(o)),u.setAttribute("xmlns",c),u.setAttribute("style",s(a)+"; zoom:"+s(String(i)));let m=document.createElementNS(c,"foreignObject");m.setAttribute("x","0"),m.setAttribute("y","0"),m.setAttribute("width",s(String(n[0]))),m.setAttribute("height",s(String(n[1]))),m.setAttribute("style",s(a)+"; zoom:"+s(String(i))),m.appendChild(d),u.appendChild(m),l.innerHTML="",l.appendChild(u);}}};dphelper?.setDescription(Wr,Gr);typeof document<"u"&&dphelper?.svg?.check();var Jr={name:"sync",active:true,subCommand:[{name:"tab",version:"0.0.2",example:"dphelper.sync.tab('my_channel', (data) => console.debug(data))",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Synchronize data between tabs using BroadcastChannel",env:"client",subCommand:[]},{name:"storageProxy",version:"0.0.2",example:"const proxy = dphelper.sync.storageProxy('user_pref', {theme: 'dark'})",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Create a Proxy object linked to localStorage for auto-sync",env:"client",subCommand:[]},{name:"pulse",version:"0.0.1",example:"dphelper.sync.pulse('chat', (msg) => ...)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Low-latency cross-tab event bus with automatic registration.",env:"client",subCommand:[]}]},Yr={pulse:(e,t)=>{if(typeof BroadcastChannel>"u")return {emit:()=>{},stop:()=>{}};let r=new BroadcastChannel(`pulse_${e}`);return r.onmessage=n=>{if(n.origin===window.location.origin||!n.origin)try{let o=n.data;o&&typeof o=="object"&&!o.__proto__&&!o.constructor&&t(o);}catch(o){console.warn("[dphelper] Invalid message received in pulse:",o);}},{emit:n=>r.postMessage(n),stop:()=>r.close()}},tab:(e,t)=>{if(typeof BroadcastChannel>"u")return {post:()=>{},close:()=>{}};let r=new BroadcastChannel(e);return r.onmessage=n=>{if(n.origin===window.location.origin||!n.origin)try{let o=n.data;o&&typeof o=="object"&&!o.__proto__&&!o.constructor&&t(o);}catch(o){console.warn("[dphelper] Invalid message received in tab:",o);}},{post:n=>r.postMessage(n),close:()=>r.close()}},storageProxy:async(e,t,r)=>{if(typeof localStorage>"u")return t;let n,o=localStorage.getItem(e);if(o)if(r){let i=await dphelper.security.getEncrypted(e,r);n=i?JSON.parse(i):t;}else try{n=JSON.parse(o);}catch{n=t;}else n=t;return new Proxy(n,{set(i,s,l){i[s]=l;let d=JSON.stringify(i);return r?dphelper.security.saveEncrypted(e,d,r):localStorage.setItem(e,d),true}})}};dphelper?.setDescription(Jr,Yr);var Vr={name:"system",active:true,subCommand:[{name:"multiSplit",version:"0.0.2",example:"dphelper.system.multiSplit()",author:"Dario Passariello",creationDate:"20231121",lastMod:"20231121",type:"system",active:true,description:"Run only one time when you load your App ... extend the .split with array as argument (example.split([',', ':', ';', '?', '/'])[0])",env:"both",subCommand:[]}]},Kr={multiSplit:(e,t)=>{if(!e)return [];let r=t[0];if(!r)return [e];let n=e;for(let o=1;o<t.length;++o)n=n.split(t[o]).join(r);return n.split(r)}};dphelper?.setDescription(Vr,Kr);var Zr={name:"text",active:true,subCommand:[{name:"trim",version:"0.0.2",example:"dphelper.text.trim(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Trims the specified characters from the start and end of a string.",env:"both",subCommand:[]},{name:"capitalize",version:"0.0.2",example:"dphelper.text.capitalize(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Capitalizes the first letter of each word in a string.",env:"both",subCommand:[]},{name:"lower",version:"0.0.2",example:"dphelper.text.lower(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to lowercase.",env:"both",subCommand:[]},{name:"upper",version:"0.0.2",example:"dphelper.text.upper(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to uppercase.",env:"both",subCommand:[]},{name:"nl2br",version:"0.0.2",example:"dphelper.text.nl2br(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts newlines in a string to HTML <br> tags.",env:"both",subCommand:[]},{name:"sanitize",version:"0.0.2",example:"dphelper.text.sanitize(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Sanitizes a string by removing HTML tags.",env:"both",subCommand:[]},{name:"camelCase",version:"0.0.2",example:"dphelper.text.camelCase(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to camelCase.",subCommand:[{name:"toSpace",version:"0.0.2",example:"dphelper.text.camelCase.toSpace(...)",type:"function",active:true,description:"Converts camelCase to space-separated words.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"},{name:"toUnderscore",version:"0.0.2",example:"dphelper.text.camelCase.toUnderscore(...)",type:"function",active:true,description:"Converts camelCase to underscore-separated words.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"}]},{name:"fitContainer",version:"0.0.2",example:"dphelper.text.fitContainer([element])",type:"function",active:true,description:"Adjusts the font size of an element to fit its container.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"},{name:"keywords",version:"0.0.2",example:"dphelper.text.keywords([sentence])",type:"function",active:true,description:"Extrapolate keywords from a sentence",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20250601",lastMod:"20250601"},{name:"replaceText",version:"0.0.2",example:"dphelper.text.replaceText([sentence, object])",type:"function",active:true,description:`
132
+ `);c=h.pop()||"";for(let b of h)if(b.startsWith("data:")){let f=b.replace("data:","").trim();try{(f.includes("[")||f.includes("{"))&&(f=JSON.parse(f));}catch{}o("message",f);}}}catch(i){i.name!=="AbortError"&&o("error",i);}})(),{on:(i,s)=>{r[i]&&r[i].push(s);},close:()=>n.abort()}}};dphelper?.setDescription(zr,Br);var Wr={name:"svg",active:true,subCommand:[{name:"init",version:"0.0.2",example:"dphelper.svg.init(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Initializes an SVG connection between two elements.",env:"client",subCommand:[]},{name:"check",version:"0.0.2",example:"dphelper.svg.check(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Checks if SVG support is available.",env:"client",subCommand:[]},{name:"update",version:"0.0.2",example:"dphelper.svg.update(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Updates the SVG connection between two elements.",env:"client",subCommand:[]},{name:"getCurve",version:"0.0.2",example:"dphelper.svg.getCurve(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the curve of the connection between two points.",env:"client",subCommand:[]},{name:"getIntersection",version:"0.0.2",example:"dphelper.svg.getIntersection(...) ",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the intersection point between two elements.",env:"client",subCommand:[]},{name:"setConnector",version:"0.0.2",example:"dphelper.svg.setConnector(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Sets a connector on an element.",env:"client",subCommand:[]},{name:"removeConnection",version:"0.0.2",example:"dphelper.svg.removeConnection(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Removes an SVG connection from a container.",env:"client",subCommand:[]},{name:"makeScrollable",version:"0.0.2",example:"dphelper.svg.makeScrollable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG container scrollable.",env:"client",subCommand:[]},{name:"makeDraggable",version:"0.0.2",example:"dphelper.svg.makeDraggable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG element draggable.",env:"client",subCommand:[]},{name:"toggle",version:"0.0.2",example:"dphelper.svg.toggle(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Toggles an SVG connection on or off.",env:"client",subCommand:[]},{name:"convert",version:"0.0.2",example:"dphelper.svg.convert([Object])",author:"Dario Passariello",creationDate:"20190101",lastMod:"20240401",type:"function",active:true,description:"Converts an element to SVG.",env:"client",subCommand:[]}]},Gr={init:(e,t,r,n)=>{e.querySelector("svg")&&dphelper.svg.removeConnection(e),t=[dphelper.svg.setConnector(t[0],t[1]),t[1]],r=[dphelper.svg.setConnector(r[0],r[1]),r[1]];let o=e.getBoundingClientRect(),a="http://www.w3.org/2000/svg",i=e.offsetWidth*10,s=e.offsetHeight*10,l=document.createElementNS(a,"svg"),d=`conn_${Math.random().toString(36).substring(2,9)}`;l.setAttribute("xmlns",a),l.dataset.dphelper="svg-connection",l.setAttributeNS(null,"viewBox","0 0 "+i+" "+s),l.setAttributeNS(null,"width",String(i)),l.setAttributeNS(null,"height",String(s)),l.style.display="block";let c=document.createElementNS(a,"rect"),u=t[0].getBoundingClientRect();c.setAttributeNS(null,"x",String(u.left-o.left)),c.setAttributeNS(null,"y",String(u.top-o.top)),c.setAttributeNS(null,"width",String(u.width)),c.setAttributeNS(null,"height",String(u.height)),l.appendChild(c);let m=document.createElementNS(a,"rect");u=r[0].getBoundingClientRect(),m.setAttributeNS(null,"x",String(u.left-o.left)),m.setAttributeNS(null,"y",String(u.top-o.top)),m.setAttributeNS(null,"width",String(u.width)),m.setAttributeNS(null,"height",String(u.height)),l.appendChild(m);let h=document.createElementNS(a,"path");h.setAttributeNS(null,"id",d),h.setAttributeNS(null,"marker-end","url(#head)"),l.appendChild(h),e.appendChild(l),dphelper.svg.update(c,m,h),typeof n=="function"&&n(t,r);},check:()=>!!(document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),update:(e,t,r)=>{let n=Number.parseFloat(e.getAttribute("x")||"0"),o=Number.parseFloat(e.getAttribute("y")||"0"),a=Number.parseFloat(t.getAttribute("x")||"0"),i=Number.parseFloat(t.getAttribute("y")||"0"),s=Number.parseFloat(e.getAttribute("width")||"0")/2,l=Number.parseFloat(e.getAttribute("height")||"0")/2,d=Number.parseFloat(t.getAttribute("width")||"0")/2,c=Number.parseFloat(t.getAttribute("height")||"0")/2,u=n+s,m=o+l,h=a+d,b=i+c,f=h-u,g=b-m,v=dphelper.svg.getIntersection(f,g,u,m,s,l),S=dphelper.svg.getIntersection(-f,-g,h,b,d,c),L=S[0]-v[0],j=dphelper.svg.getCurve(v,S,L);r.setAttributeNS(null,"d","M"+u+","+m+j+h+","+b);},getCurve:(e,t,r)=>{let n=r/2;return " C"+(n+e[0])+","+e[1]+" "+(t[0]-n)+","+t[1]+" "},getIntersection:(e,t,r,n,o,a)=>Math.abs(t/e)<a/o?[r+(e>0?o:-o),n+t*o/Math.abs(e)]:[r+e*a/Math.abs(t),n+(t>0?a:-a)],setConnector:(e,t)=>{let r,n=document.createElement("span");switch(e.style.position="relative",n.style.position="absolute",n.style.width="5px",n.style.height="5px",t){case "top":r={left:"50%",top:"2.5px",marginLeft:"2.5px"};break;case "right":r={top:"50%",right:"2.5px",marginTop:"-2.5px"};break;case "bottom":r={left:"50%",bottom:"-2.5px",marginLeft:"2.5px"};break;case "left":r={top:"50%",left:"-2.5px",marginTop:"-2.5px"};break;default:r={};}return Object.assign(n.style,r),e.appendChild(n),n},removeConnection:e=>{e.querySelectorAll("svg[data-dphelper='svg-connection']").forEach(r=>r.remove());},makeScrollable:(e,t,r,n,o,a)=>{let i=e.getBoundingClientRect(),s=[r,n],l=s.length,d=[o,a],c=[];for(let f=0;f<l;f++){let g=s[f],v=d[f];!g||!v||(c[f]=g.getBoundingClientRect(),v.setAttributeNS(null,"x",String(c[f].left-i.left)),v.setAttributeNS(null,"y",String(c[f].top-i.top)),v.setAttributeNS(null,"width",String(c[f].width)),v.setAttributeNS(null,"height",String(c[f].height)));}let u=e.querySelectorAll("rect"),m=u[0],h=u[1],b=document.getElementById("connection");m&&h&&b&&dphelper.svg.update(m,h,b);},makeDraggable:e=>{let t=e.target;function r(d){let c=t.getScreenCTM();return c?{x:(d.clientX-c.e)/c.a,y:(d.clientY-c.f)/c.d}:{x:0,y:0}}let n=null,o=null,a=d=>{if(n&&o){let c=r(d);n.setAttributeNS(null,"x",String(c.x-o.x)),n.setAttributeNS(null,"y",String(c.y-o.y));let u=document.getElementById("connection");u&&dphelper.svg.update(n,n,u);}},i=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i),n=null,o=null;},s=d=>{d.target.classList.contains("draggable")&&(n=d.target,o=r(d),o.x-=Number.parseFloat(n.getAttributeNS(null,"x")||"0"),o.y-=Number.parseFloat(n.getAttributeNS(null,"y")||"0"),document.addEventListener("mousemove",a),document.addEventListener("mouseup",i));};t.addEventListener("mousedown",s),t.__dphelper_cleanup=()=>{t.removeEventListener("mousedown",s),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i);};let l=new MutationObserver(()=>{document.contains(t)||(t.__dphelper_cleanup&&t.__dphelper_cleanup(),l.disconnect());});l.observe(document.body,{childList:true,subtree:true});},toggle:(e,t,r,n)=>{let o=e.target;if(o.checked&&r&&n){dphelper.cookie.set({name:`${o.id}`,value:1,time:365});let a=()=>{dphelper.svg.makeScrollable(t,document.getElementById("parts-left-body"),r,n,document.querySelector("#parts svg rect"),document.querySelectorAll("#parts svg rect")[1]);};dphelper.svg.init(t,[r,"right"],[n,"left"],(i,s)=>{let l=document.getElementById("parts-left-body");l&&(l.addEventListener("scroll",a),l.__dphelper_scrollHandler=a);});}else {dphelper.svg.removeConnection(t);let a=document.getElementById("parts-left-body");a&&a.__dphelper_scrollHandler&&(a.removeEventListener("scroll",a.__dphelper_scrollHandler),delete a.__dphelper_scrollHandler),a&&a.replaceWith(a.cloneNode(true)),dphelper.cookie.set({name:`${o.id}`,value:0,time:365});}},convert:({children:e,active:t=true,size:r=[1920,1080],fit:n=["100%","100%"],preserveAspectRatio:o="none",style:a=`width:${n[0]}; height:${n[1]}`,zoom:i=1})=>{if(!e)return "Please pass ID of element for SVG conversion";if(t){let s=h=>h.replace(/[<>"'&]/g,""),l=document.querySelector(e);if(!l)return "Element not found";let d=l.cloneNode(true),c="http://www.w3.org/2000/svg",u=document.createElementNS(c,"svg");u.setAttribute("viewBox",`0 0 ${s(String(r[0]))} ${s(String(r[1]))}`),u.setAttribute("preserveAspectRatio",s(o)),u.setAttribute("xmlns",c),u.setAttribute("style",s(a)+"; zoom:"+s(String(i)));let m=document.createElementNS(c,"foreignObject");m.setAttribute("x","0"),m.setAttribute("y","0"),m.setAttribute("width",s(String(n[0]))),m.setAttribute("height",s(String(n[1]))),m.setAttribute("style",s(a)+"; zoom:"+s(String(i))),m.appendChild(d),u.appendChild(m),l.innerHTML="",l.appendChild(u);}}};dphelper?.setDescription(Wr,Gr);typeof document<"u"&&dphelper?.svg?.check();var Jr={name:"sync",active:true,subCommand:[{name:"tab",version:"0.0.2",example:"dphelper.sync.tab('my_channel', (data) => console.debug(data))",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Synchronize data between tabs using BroadcastChannel",env:"client",subCommand:[]},{name:"storageProxy",version:"0.0.2",example:"const proxy = dphelper.sync.storageProxy('user_pref', {theme: 'dark'})",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Create a Proxy object linked to localStorage for auto-sync",env:"client",subCommand:[]},{name:"pulse",version:"0.0.1",example:"dphelper.sync.pulse('chat', (msg) => ...)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Low-latency cross-tab event bus with automatic registration.",env:"client",subCommand:[]}]},Yr={pulse:(e,t)=>{if(typeof BroadcastChannel>"u")return {emit:()=>{},stop:()=>{}};let r=new BroadcastChannel(`pulse_${e}`);return r.onmessage=n=>{if(n.origin===window.location.origin||!n.origin)try{let o=n.data;if(o&&typeof o=="object"){let a=Object.getPrototypeOf(o);(a===Object.prototype||a===null)&&t(o);}}catch(o){console.warn("[dphelper] Invalid message received in pulse:",o);}},{emit:n=>r.postMessage(n),stop:()=>r.close()}},tab:(e,t)=>{if(typeof BroadcastChannel>"u")return {post:()=>{},close:()=>{}};let r=new BroadcastChannel(e);return r.onmessage=n=>{if(n.origin===window.location.origin||!n.origin)try{let o=n.data;if(o&&typeof o=="object"){let a=Object.getPrototypeOf(o);(a===Object.prototype||a===null)&&t(o);}}catch(o){console.warn("[dphelper] Invalid message received in tab:",o);}},{post:n=>r.postMessage(n),close:()=>r.close()}},storageProxy:async(e,t,r)=>{if(typeof localStorage>"u")return t;let n,o=localStorage.getItem(e);if(o)if(r){let i=await dphelper.security.getEncrypted(e,r);n=i?JSON.parse(i):t;}else try{n=JSON.parse(o);}catch{n=t;}else n=t;return new Proxy(n,{set(i,s,l){i[s]=l;let d=JSON.stringify(i);return r?dphelper.security.saveEncrypted(e,d,r):localStorage.setItem(e,d),true}})}};dphelper?.setDescription(Jr,Yr);var Vr={name:"system",active:true,subCommand:[{name:"multiSplit",version:"0.0.2",example:"dphelper.system.multiSplit()",author:"Dario Passariello",creationDate:"20231121",lastMod:"20231121",type:"system",active:true,description:"Run only one time when you load your App ... extend the .split with array as argument (example.split([',', ':', ';', '?', '/'])[0])",env:"both",subCommand:[]}]},Kr={multiSplit:(e,t)=>{if(!e)return [];let r=t[0];if(!r)return [e];let n=e;for(let o=1;o<t.length;++o)n=n.split(t[o]).join(r);return n.split(r)}};dphelper?.setDescription(Vr,Kr);var Zr={name:"text",active:true,subCommand:[{name:"trim",version:"0.0.2",example:"dphelper.text.trim(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Trims the specified characters from the start and end of a string.",env:"both",subCommand:[]},{name:"capitalize",version:"0.0.2",example:"dphelper.text.capitalize(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Capitalizes the first letter of each word in a string.",env:"both",subCommand:[]},{name:"lower",version:"0.0.2",example:"dphelper.text.lower(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to lowercase.",env:"both",subCommand:[]},{name:"upper",version:"0.0.2",example:"dphelper.text.upper(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to uppercase.",env:"both",subCommand:[]},{name:"nl2br",version:"0.0.2",example:"dphelper.text.nl2br(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts newlines in a string to HTML <br> tags.",env:"both",subCommand:[]},{name:"sanitize",version:"0.0.2",example:"dphelper.text.sanitize(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Sanitizes a string by removing HTML tags.",env:"both",subCommand:[]},{name:"camelCase",version:"0.0.2",example:"dphelper.text.camelCase(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to camelCase.",subCommand:[{name:"toSpace",version:"0.0.2",example:"dphelper.text.camelCase.toSpace(...)",type:"function",active:true,description:"Converts camelCase to space-separated words.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"},{name:"toUnderscore",version:"0.0.2",example:"dphelper.text.camelCase.toUnderscore(...)",type:"function",active:true,description:"Converts camelCase to underscore-separated words.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"}]},{name:"fitContainer",version:"0.0.2",example:"dphelper.text.fitContainer([element])",type:"function",active:true,description:"Adjusts the font size of an element to fit its container.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"},{name:"keywords",version:"0.0.2",example:"dphelper.text.keywords([sentence])",type:"function",active:true,description:"Extrapolate keywords from a sentence",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20250601",lastMod:"20250601"},{name:"replaceText",version:"0.0.2",example:"dphelper.text.replaceText([sentence, object])",type:"function",active:true,description:`
133
133
  replace all occurrence from sentence using an object as list
134
134
 
135
135
  example:
@@ -155,4 +155,4 @@ ${t(i,`${n} `)}${n}</${a}>
155
155
  top=${u},
156
156
  left=${c}
157
157
  `);onfocus=()=>m?.focus();},onBeforeUnLoad:e=>{let t="You have made some changes which you might want to save.",r=o=>(o.preventDefault(),t),n=e?document.querySelector(e):null;n&&n.addEventListener("input",()=>{n.value!==""?(A=true,addEventListener("beforeunload",r,{capture:true})):(A=false,removeEventListener("beforeunload",r,{capture:true}));}),se===false&&(document.body.addEventListener("click",o=>{let a=o.target;if(a&&a.tagName.toLowerCase()==="img"&&A===true){if(confirm(t)===true){A=false;return}o.preventDefault();}}),se=true),addEventListener("popstate",o=>{if(A===true){if(confirm(t)===true){A=false;return}o.stopImmediatePropagation(),o.preventDefault();return}}),onbeforeunload=o=>{if(A===true)return o.preventDefault(),o.returnValue=t};},purge:(e=document,t=1e4)=>{setTimeout(()=>{if(!e)return;let r=e.attributes;if(r){let n=r.length;for(let o=0;o<n;o+=1){let a=r[o].name;typeof e[a]=="function"&&(e[a]=null),typeof e[a]>"u"&&(e[a]=null);}}if(r=e.childNodes,r){let n=r.length;for(let o=0;o<n;o+=1)dphelper.purge(e.childNodes[o]);}},t);},stopZoomWheel:()=>{addEventListener("wheel",e=>{e.ctrlKey&&e.preventDefault();},{passive:false}),addEventListener("keydown",e=>{let t=dphelper.event.keys(e);["+","-","="].includes(t.key)&&t.ctrl&&e.preventDefault();});},setZoom:(e="html",t=1)=>{t<0&&(t=1);let r=document.querySelector(e);return r&&(r.style.zoom=String(t)),`New zoom value: ${t*100}% (css: ${t})`},getZoom:(e="html")=>{let t=document.querySelector(e);return Number(t?.style.zoom||1)}};dphelper?.setDescription(un,pn);var mn={name:"worker",active:true,subCommand:[{name:"create",version:"0.0.1",example:"dphelper.worker.create('worker.js', { onmessage: (e) => console.log(e.data) })",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Create a new Web Worker from a script URL or inline code",env:"client",subCommand:[]},{name:"createInline",version:"0.0.1",example:"dphelper.worker.createInline('self.onmessage = e => postMessage(e.data * 2)')",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Create a Web Worker from inline JavaScript code",env:"client",subCommand:[]},{name:"post",version:"0.0.1",example:"dphelper.worker.post(worker, { type: 'compute', data: 42 })",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Send a message to a worker",env:"client",subCommand:[]},{name:"terminate",version:"0.0.1",example:"dphelper.worker.terminate(worker)",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Terminate a Web Worker",env:"client",subCommand:[]},{name:"pool",version:"0.0.1",example:"dphelper.worker.pool('worker.js', 4)",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Create a pool of workers for parallel processing",env:"client",subCommand:[]},{name:"poolExec",version:"0.0.1",example:"dphelper.worker.poolExec(pool, tasks)",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Execute tasks across a worker pool",env:"client",subCommand:[]},{name:"importScripts",version:"0.0.1",example:"dphelper.worker.importScripts(worker, ['lib1.js', 'lib2.js'])",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Import external scripts into a worker",env:"client",subCommand:[]},{name:"shared",version:"0.0.1",example:"dphelper.worker.shared('my-shared-buffer')",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Create a SharedWorker for cross-tab communication",env:"client",subCommand:[]}]},le=(e,t={})=>{try{let r=new URL(e);if(!["http:","https:","blob:","data:"].includes(r.protocol))throw new Error(`Invalid protocol: ${r.protocol}`);let n=new Worker(r.href);return t.onmessage&&(n.onmessage=t.onmessage),t.onerror&&(n.onerror=t.onerror),n}catch(r){if(!(typeof e=="string"&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("blob:")&&!e.startsWith("data:")))throw console.error("[dphelper] worker.create: Invalid URL or protocol. Only http, https, blob, data, or relative paths allowed."),new Error("Invalid worker source URL",{cause:r});let o=new Blob([e],{type:"application/javascript"}),a=new Worker(URL.createObjectURL(o));return t.onmessage&&(a.onmessage=t.onmessage),t.onerror&&(a.onerror=t.onerror),a}},hn=(e,t={})=>{let r=new Blob([e],{type:"application/javascript"}),n=URL.createObjectURL(r),o=new Worker(n);return t.onmessage&&(o.onmessage=t.onmessage),t.onerror&&(o.onerror=t.onerror),o.addEventListener("message",()=>{URL.revokeObjectURL(n);}),o.addEventListener("error",()=>{URL.revokeObjectURL(n);}),o},Y=(e,t,r)=>{r?e.postMessage(t,r):e.postMessage(t);},fn=e=>{e.terminate();},gn=(e,t=4)=>{let r=[],n=new Set;for(let a=0;a<t;a++)r.push(le(e));return {workers:r,busy:n,queue:[],size:t}},bn=async(e,t,r=3e4)=>new Promise((n,o)=>{let a=new Array(t.length),i=0,s=false,l=setTimeout(()=>{s=true,o(new Error(`[dphelper] Worker pool execution timed out after ${r}ms`));},r),d=()=>{if(!s)for(;e.queue.length>0&&e.busy.size<e.size;){let{task:u}=e.queue.shift();c(u.index,u.data);}},c=(u,m)=>{if(s)return;let h=e.workers.find(g=>!e.busy.has(g));if(!h)return;e.busy.add(h);let b=g=>{h.removeEventListener("message",b),e.busy.delete(h),a[u]=g.data,i++,i===t.length?(clearTimeout(l),n(a)):d();},f=g=>{h.removeEventListener("error",f),e.busy.delete(h),s=true,clearTimeout(l),o(new Error(`[dphelper] Worker task failed: ${g.message}`));};h.addEventListener("message",b),h.addEventListener("error",f),Y(h,{index:u,data:m});};t.forEach((u,m)=>{e.queue.push({task:{index:m,data:u}});}),d();}),vn=(e,t)=>{t.forEach(i=>{try{let s=new URL(i);if(!["http:","https:","blob:","data:"].includes(s.protocol)){console.error(`[dphelper] Invalid protocol for importScripts: ${s.protocol}`);return}}catch{console.error(`[dphelper] Invalid URL for importScripts: ${i}`);return}});let n=t.map(i=>i.replace(/['\\]/g,"\\$&")).map(i=>`importScripts('${i}');`).join(`
158
- `),o=new Blob([n],{type:"application/javascript"}),a=URL.createObjectURL(o);Y(e,{type:"import",url:a});},yn=(e,t={})=>{try{let r=t.name?{name:t.name}:void 0,n=new SharedWorker(e,r);return t.onmessage&&(n.port.onmessage=t.onmessage),t.onconnect&&(n.port.onmessage=o=>{t.onconnect?.(o),t.onmessage&&t.onmessage(o);}),n}catch(r){console.error("[dphelper] SharedWorker creation failed:",r);return}},Dn={create:le,createInline:hn,post:Y,terminate:fn,pool:gn,poolExec:bn,importScripts:vn,shared:yn};dphelper?.setDescription(mn,Dn);if(typeof window<"u"){let e=setInterval(()=>{dphelper._list||(dphelper._list={sockets:[],scripts:[]});let t=dphelper?.socket?.list(),r=[];t&&(t.map(n=>(r.push(n.url),false)),dphelper._list.sockets=r,r.length>0&&clearInterval(e));},500);}Object.preventExtensions(dphelper);Object.seal(dphelper);
158
+ `),o=new Blob([n],{type:"application/javascript"}),a=URL.createObjectURL(o);Y(e,{type:"import",url:a});},yn=(e,t={})=>{try{let r=t.name?{name:t.name}:void 0,n=new SharedWorker(e,r);return t.onmessage&&(n.port.onmessage=t.onmessage),t.onconnect&&(n.port.onmessage=o=>{t.onconnect?.(o),t.onmessage&&t.onmessage(o);}),n}catch(r){console.error("[dphelper] SharedWorker creation failed:",r);return}},Dn={create:le,createInline:hn,post:Y,terminate:fn,pool:gn,poolExec:bn,importScripts:vn,shared:yn};dphelper?.setDescription(mn,Dn);if(typeof window<"u"){let t=0,r=setInterval(()=>{if(dphelper._list||(dphelper._list={sockets:[],scripts:[]}),t++,t>=20){clearInterval(r);return}let n=dphelper?.socket?.list(),o=[];n&&(n.map(a=>(o.push(a.url),false)),dphelper._list.sockets=o,o.length>0&&clearInterval(r));},500);}Object.preventExtensions(dphelper);Object.seal(dphelper);
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var K={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var C={codeName:"dphelper",version:"4.6.2"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...K},configurable:true,writable:true},version:{value:C.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var k=dphelper;Object.defineProperty(k,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(k,"setDescription",{value:(e,t)=>{Object.defineProperties(k,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(k[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),k.setProps(k,e,{writable:false,configurable:false,enumerable:false}),k._list.scripts.push(e);}});var pe={name:"ai",active:true,subCommand:[{name:"tokenCount",version:"0.0.3",example:"dphelper.ai.tokenCount({ users: [1,2,3] })",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260221",type:"function",active:true,description:"Estimate token count for LLMs. If an object is passed, it uses TOON format for calculation.",env:"both",subCommand:[]},{name:"smartSanitize",version:"0.0.2",example:"dphelper.ai.smartSanitize('My email is test@example.com')",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Remove PII (emails, phones, etc) from text for AI privacy",subCommand:[]},{name:"toon",version:"0.0.1",example:"dphelper.ai.toon({ users: [{id: 1, name: 'Ada'}] })",author:"TOON + Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Convert JSON to TOON format (Token-Oriented Object Notation)",subCommand:[]},{name:"toonToJson",version:"0.0.1",example:"dphelper.ai.toonToJson('users[1]{id,name}:\\n 1,Ada')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Convert TOON format back to JSON/Object",subCommand:[]},{name:"chunker",version:"0.0.1",example:"dphelper.ai.chunker(text, { size: 1000, overlap: 200 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Split long text into chunks for RAG or AI processing.",subCommand:[]},{name:"similarity",version:"0.0.1",example:"dphelper.ai.similarity(vecA, vecB)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Calculate cosine similarity between two embedding vectors.",subCommand:[]},{name:"extractReasoning",version:"0.0.1",example:"dphelper.ai.extractReasoning(aiResponse)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Extract <think> tags or internal reasoning from AI responses.",subCommand:[]},{name:"prompt",version:"0.0.1",example:"dphelper.ai.prompt('Hello {{name}}', { name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Simple prompt template engine with variable injection.",subCommand:[]},{name:"schema",version:"0.0.1",example:"dphelper.ai.schema({ id: 1, name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Generate a TOON-style schema definition for AI instructions.",subCommand:[]},{name:"snapshot",version:"0.0.1",example:"dphelper.ai.snapshot()",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Capture a 'mental snapshot' of the app state (logs/globals) in TOON format for AI debugging.",env:"both",subCommand:[]}]},W=e=>e===null||typeof e!="object",U=e=>e===null?"null":typeof e=="string"?e.includes(",")||e.includes(":")||e.includes('"')||e.includes(`
1
+ var K={info:{title:"List",description:"Complete list of tools"},categories:["3party","system","financial","memory","numbers","time","path","file","forms","ui","other","development"]};var C={codeName:"dphelper",version:"4.7.0"};Object.defineProperty(globalThis,"dphelper",{value:new Proxy({},{}),writable:true,configurable:true,enumerable:false});Object.defineProperties(dphelper,{_list:{value:{scripts:[],sockets:[],...K},configurable:true,writable:true},version:{value:C.version,configurable:true,writable:true},isServer:{value:false,configurable:true,writable:true},isBrowser:{value:true,configurable:true,writable:true}});var k=dphelper;Object.defineProperty(k,"setProps",{value:(e,t,r)=>{Object.defineProperty(e,t.name,r||{writable:false,configurable:false,enumerable:false}),r?.lock&&Object.freeze(e[t.name]);},writable:false,configurable:false,enumerable:false});Object.defineProperty(k,"setDescription",{value:(e,t)=>{Object.defineProperties(k,{[e.name]:{value:t,writable:false,configurable:false,enumerable:false}}),Object.keys(t).map(r=>(Object.defineProperties(k[e.name],{[r]:{writable:false,configurable:false,enumerable:false}}),null)),k.setProps(k,e,{writable:false,configurable:false,enumerable:false}),k._list.scripts.push(e);}});var pe={name:"ai",active:true,subCommand:[{name:"tokenCount",version:"0.0.3",example:"dphelper.ai.tokenCount({ users: [1,2,3] })",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260221",type:"function",active:true,description:"Estimate token count for LLMs. If an object is passed, it uses TOON format for calculation.",env:"both",subCommand:[]},{name:"smartSanitize",version:"0.0.2",example:"dphelper.ai.smartSanitize('My email is test@example.com')",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Remove PII (emails, phones, etc) from text for AI privacy",subCommand:[]},{name:"toon",version:"0.0.1",example:"dphelper.ai.toon({ users: [{id: 1, name: 'Ada'}] })",author:"TOON + Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Convert JSON to TOON format (Token-Oriented Object Notation)",subCommand:[]},{name:"toonToJson",version:"0.0.1",example:"dphelper.ai.toonToJson('users[1]{id,name}:\\n 1,Ada')",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Convert TOON format back to JSON/Object",subCommand:[]},{name:"chunker",version:"0.0.1",example:"dphelper.ai.chunker(text, { size: 1000, overlap: 200 })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Split long text into chunks for RAG or AI processing.",subCommand:[]},{name:"similarity",version:"0.0.1",example:"dphelper.ai.similarity(vecA, vecB)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Calculate cosine similarity between two embedding vectors.",subCommand:[]},{name:"extractReasoning",version:"0.0.1",example:"dphelper.ai.extractReasoning(aiResponse)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Extract <think> tags or internal reasoning from AI responses.",subCommand:[]},{name:"prompt",version:"0.0.1",example:"dphelper.ai.prompt('Hello {{name}}', { name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Simple prompt template engine with variable injection.",subCommand:[]},{name:"schema",version:"0.0.1",example:"dphelper.ai.schema({ id: 1, name: 'Ada' })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Generate a TOON-style schema definition for AI instructions.",subCommand:[]},{name:"snapshot",version:"0.0.1",example:"dphelper.ai.snapshot()",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Capture a 'mental snapshot' of the app state (logs/globals) in TOON format for AI debugging.",env:"both",subCommand:[]}]},W=e=>e===null||typeof e!="object",U=e=>e===null?"null":typeof e=="string"?e.includes(",")||e.includes(":")||e.includes('"')||e.includes(`
2
2
  `)||e.trim()!==e?`"${e.replace(/"/g,'\\"')}"`:e||'""':String(e),$=(e,t=0)=>{let r=" ".repeat(t);if(W(e))return U(e);if(Array.isArray(e)){if(e.length===0)return "[0]:";let n=e[0];if(!W(n)&&!Array.isArray(n)){let o=Object.keys(n),a=`[${e.length}]{${o.join(",")}}:`;for(let i of e){let s=o.map(l=>U(i[l])).join(",");a+=`
3
3
  ${r} ${s}`;}return a}else return `[${e.length}]: `+e.map(U).join(",")}else return Object.entries(e).map(([n,o])=>{let a=n.includes(" ")||n.includes(":")?`"${n}"`:n;if(!W(o)){let i=$(o,t+1);return i.startsWith("[")?`${a}${i}`:`${a}:
4
4
  ${r}${i}`}return `${a}: ${U(o)}`}).join(`
@@ -129,7 +129,7 @@ ${t(i,`${n} `)}${n}</${a}>
129
129
  left:0;
130
130
  z-index:2
131
131
  `;}if(!e.el&&r){r.style.width="0%";return}try{let n=document.querySelector(".scrollindicator");t.addEventListener("scroll",function(o){n.style.width="0%";let a=Number(this.scrollTop),i=Number(this.scrollHeight-this.clientHeight),s=Math.min(Math.max(a/i*100),100);n.style.width=`${s}%`,n.click();}),t.addEventListener("popstate",o=>{n.style.width=0;});}catch(n){console.error(n);return}},position:{set:e=>{let t=typeof e=="string"?document.querySelector(e):e;if(!t)return;let r=[t.scrollTop,t.scrollLeft];r[0]!=null&&r[1]!=null&&localStorage.setItem(e,JSON.stringify(r));},get:e=>{if(localStorage.getItem(e))try{let t=localStorage.getItem(e),r=typeof e=="string"?document.querySelector(e):e;r&&t&&(r.scrollTop=t[0],r.scrollLeft=t[1]);}catch(t){console.error("Error getting scroll position:",t);}}},smooth:(e,t,r)=>{e===document&&(e=document.scrollingElement||document.documentElement||document.body.parentNode||document.body);let n=false,o=e.scrollTop,a=e===document.body&&document.documentElement?document.documentElement:e,i=c=>{c.preventDefault();let u=s(c);o+=-u*t,o=Math.max(0,Math.min(o,e.scrollHeight-a.clientHeight)),n||l();};e.addEventListener("mousewheel",i,{passive:false}),e.addEventListener("DOMMouseScroll",i,{passive:false});let s=c=>c.detail?c.wheelDelta?c.wheelDelta/c.detail/40*(c.detail>0?1:-1):-c.detail/3:c.wheelDelta/120,l=()=>{n=true;let c=(o-e.scrollTop)/r;e.scrollTop+=c,Math.abs(c)>.5?d(l):n=false;},d=dphelper.window.animationframe();},scrollTo:(e,t,r=0)=>{let n=document.querySelector(e),o=document.querySelector(t);n&&o&&n.scrollTo({top:o.offsetTop-r,behavior:"smooth"});}};dphelper?.setDescription(kr,Tr);var Er={name:"security",active:true,subCommand:[{name:"uuid",version:"0.0.2",example:"dphelper.security.uuid",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"UUID related commands",subCommand:[{name:"byVal",version:"0.0.2",example:"dphelper.security.uuid.byVal('string')",author:"Dario Passariello",creationDate:"20250101",lastMod:"20250101",type:"function",active:true,description:"Generate a UUID based on a given string",env:"both",subCommand:[]},{name:"v4",version:"0.0.2",example:"dphelper.security.uuid.v4",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"return",active:true,description:"Generate a random UUID v4",env:"both",subCommand:[]},{name:"v5",version:"0.0.2",example:"dphelper.security.uuid.v5",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"return",active:true,description:"Generate a random UUID v5",env:"both",subCommand:[]}]},{name:"hashPass",description:"Generate a crypto digest starting from user and password values (Uses SHA-256, CNSA compliant)",example:"dphelper.security.hashPass(user, password)",version:"0.0.3",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260329",active:true,env:"both",subCommand:[]},{name:"crypt",description:"Encrypt your message using a secret_key in a default format AES",example:"dphelper.security.crypt(data, secret_key, [optional mode])",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"deCrypt",description:"Decrypt your message using a secret_key in a default format AES",example:"dphelper.security.deCrypt(data, secret_key, [optional mode])",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"AES_KeyGen",description:"Generate a key based on the AES algorithm",example:"dphelper.security.AES_KeyGen(secret_key)",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"SHA256_Hex",description:"Generate a SHA256 hash in hexadecimal format",example:"dphelper.security.SHA256_Hex(secret_key)",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20250101",lastMod:"20250101",active:true,env:"both",subCommand:[]},{name:"ulid",description:"Generate ULID code",example:"dphelper.security.ulid()",version:"0.0.2",type:"function",author:"mix",creationDate:"20250212",lastMod:"20250212",active:true,env:"both",subCommand:[]},{name:"fingerprint",description:"Generate a unique browser fingerprint",example:"dphelper.security.fingerprint()",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"saveEncrypted",description:"Save encrypted data to localStorage",example:"dphelper.security.saveEncrypted('key', 'value', 'secret')",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]},{name:"getEncrypted",description:"Retrieve and decrypt data from localStorage",example:"dphelper.security.getEncrypted('key', 'secret')",version:"0.0.2",type:"function",author:"Dario Passariello",creationDate:"20260220",lastMod:"20260220",active:true,env:"both",subCommand:[]}]},j=new TextEncoder,Ar=new TextDecoder,Lr=e=>{let t=new Uint8Array(e),r="";for(let n=0;n<t.byteLength;n++)r+=String.fromCharCode(t[n]);return btoa(r)},Or=e=>{let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r.buffer},Rr=async e=>{let t=j.encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")},oe=async(e,t)=>{let r=j.encode(t),n=await crypto.subtle.importKey("raw",r,{name:"HMAC",hash:"SHA-256"},false,["sign"]),o=await crypto.subtle.sign("HMAC",n,j.encode(e));return Array.from(new Uint8Array(o)).map(i=>i.toString(16).padStart(2,"0")).join("")},ie=async(e,t,r)=>{let n=await crypto.subtle.importKey("raw",j.encode(e),"PBKDF2",false,["deriveBits","deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:t.buffer,iterations:r,hash:"SHA-256"},n,{name:"AES-GCM",length:256},false,["encrypt","decrypt"])},Ir=async(e,t)=>{let r=crypto.getRandomValues(new Uint8Array(16)),n=crypto.getRandomValues(new Uint8Array(12)),o=await ie(t,new Uint8Array(r.buffer),31e4),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:new Uint8Array(n.buffer)},o,j.encode(e)),i=new Uint8Array(r.length+n.length+a.byteLength);return i.set(r,0),i.set(n,r.length),i.set(new Uint8Array(a),r.length+n.length),Lr(i.buffer)},jr=async(e,t)=>{try{let r=new Uint8Array(Or(e)),n=r.slice(0,16),o=r.slice(16,28),a=r.slice(28),i=await ie(t,new Uint8Array(n.buffer),31e4),s=await crypto.subtle.decrypt({name:"AES-GCM",iv:new Uint8Array(o.buffer)},i,a);return Ar.decode(s)}catch{return ""}},ae=-1,w=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","M","N","P","Q","R","S","T","V","W","X","Y","Z"],Nr={uuid:{byVal:async e=>{if(!e)return console.warn("You need to pass a value to obtain a fixed uuid"),"";let t=await dphelper.security.SHA256_Hex(e);return [t.slice(0,8),t.slice(8,4),`4${t.slice(12,3)}`,`8${t.slice(15,3)}`,t.slice(18,12)].join("-")},v4:"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),v5:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=crypto.getRandomValues(new Uint8Array(1))[0];return (e==="x"?t:t&3|8).toString(16)})},hashPass:async(e,t)=>{if(!e||!t)return console.warn("hashPass: user and password are required"),"";let r=new TextEncoder,n=crypto.getRandomValues(new Uint8Array(16)),o=Array.from(n).map(d=>d.toString(16).padStart(2,"0")).join(""),a=await crypto.subtle.importKey("raw",r.encode(t.toLowerCase()+e.toLowerCase()),{name:"PBKDF2"},false,["deriveBits"]),i=await crypto.subtle.deriveBits({name:"PBKDF2",salt:n.buffer,iterations:31e4,hash:"SHA-256"},a,256),l=Array.from(new Uint8Array(i)).map(d=>d.toString(16).padStart(2,"0")).join("");return o+l},crypt:async(e,t)=>await Ir(e,t),deCrypt:async(e,t)=>await jr(e,t),AES_KeyGen:async e=>{let t=e||crypto.randomUUID(),r=crypto.getRandomValues(new Uint8Array(16)),n=Array.from(r).map(i=>i.toString(16).padStart(2,"0")).join(""),o=await crypto.subtle.deriveBits({name:"PBKDF2",salt:r.buffer,iterations:31e4,hash:"SHA-256"},await crypto.subtle.importKey("raw",j.encode(t),"PBKDF2",false,["deriveBits"]),512),a=Array.from(new Uint8Array(o));return n+a.map(i=>i.toString(16).padStart(2,"0")).join("")},SHA256_Hex:async e=>Rr(e),ulid:()=>{let e=new Uint8Array(16),t=new DataView(e.buffer,0,6),r=new Uint8Array(e.buffer,6,10),n=new Array(26),o=i=>{n[0]=w[i[0]>>5],n[1]=w[i[0]>>0&31];for(let s=0;s<3;s++)n[s*8+2]=w[i[s*5+1]>>3],n[s*8+3]=w[(i[s*5+1]<<2|i[s*5+2]>>6)&31],n[s*8+4]=w[i[s*5+2]>>1&31],n[s*8+5]=w[(i[s*5+2]<<4|i[s*5+3]>>4)&31],n[s*8+6]=w[(i[s*5+3]<<1|i[s*5+4]>>7)&31],n[s*8+7]=w[i[s*5+4]>>2&31],n[s*8+8]=w[(i[s*5+4]<<3|i[s*5+5]>>5)&31],n[s*8+9]=w[i[s*5+5]>>0&31];return n.join("")},a=Date.now();if(a===ae)for(let i=9;i>=0&&!(r[i]!==void 0&&r[i]++<255);i--);else ae=a,t.setUint16(0,a/4294967296|0),t.setUint32(2,a|0),window.crypto.getRandomValues(r);return o(e)},fingerprint:async e=>{let t=e?.requireConsent!==false,r=e?.consent;if(t&&r!==true)return console.warn("dphelper.security.fingerprint: User consent required. Pass { consent: true } to enable."),console.warn("dphelper.security.fingerprint: Fingerprinting is subject to GDPR/CCPA. Ensure privacy policy and user consent."),"";let n=navigator,o=window.screen,a=document.createElement("canvas"),i=a.getContext("2d"),s="dphelper_fingerprint_v1",l="";i&&(a.width=200,a.height=30,i.textBaseline="top",i.font="14px 'Arial'",i.textBaseline="alphabetic",i.fillStyle="#f60",i.fillRect(125,1,62,20),i.fillStyle="#069",i.fillText(s,2,15),i.fillStyle="rgba(102, 204, 0, 0.7)",i.fillText(s,4,17),l=a.toDataURL());let d=[n.userAgent,n.language,o.colorDepth,o.width+"x"+o.height,new Date().getTimezoneOffset(),n.deviceMemory||"unknown",n.hardwareConcurrency||"unknown",l].join("|");return dphelper.security.SHA256_Hex(d)},saveEncrypted:async(e,t,r)=>{if(typeof document>"u"||typeof window>"u"){console.warn("[dphelper] localStorage not available in this environment");return}let n=await dphelper.security.crypt(t,r),o=await oe(n,r);localStorage.setItem(e,JSON.stringify({d:n,h:o,v:"2.0"}));},getEncrypted:async(e,t)=>{let r=localStorage.getItem(e);if(!r)return null;try{let n=JSON.parse(r);if(n&&n.h&&n.d){let o=await oe(n.d,t);return n.h!==o?(console.error(`[dphelper] Security Alert: Data tampering detected for key "${e}"`),null):dphelper.security.deCrypt(n.d,t)}return dphelper.security.deCrypt(r,t)}catch{try{return dphelper.security.deCrypt(r,t)}catch(o){return console.warn(`[dphelper] Persistence Error for key "${e}":`,o),null}}}},$r=Nr;typeof dphelper?.setDescription=="function"&&dphelper.setDescription(Er,$r);var qr={name:"shortcut",active:true,subCommand:[{name:"keys",version:"0.0.2",example:"dphelper.shortcut.keys([e, trigger])",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Handle keyboard shortcuts.",env:"client",subCommand:[]}]},Hr={keys:(e,t)=>{let r=e.which?e.which:e.keyCode;t||(t={data:[{key:"83",ctrl:true,active:true,description:"CTRL+S",function:""},{key:"27",ctrl:false,active:true,description:"ESC",element:"",function:""},{key:"80",ctrl:true,active:true,description:"CTRL+P",element:"",function:"function(){ Print }"}]}),t.data&&t.data.map(n=>(e.ctrlKey||e.metaKey&&n.ctrl===true)&&r===Number.parseInt(n.key)&&n.active===true?(n.element&&n.element.click(),n.function?JSON.stringify(n.function):(e.preventDefault(),null)):null);}};dphelper?.setDescription(qr,Hr);var x={ws:{}},Ur={name:"socket",active:true,subCommand:[{name:"info",version:"0.0.2",example:"dphelper.socket.info(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Retrieve socket information",env:"client",subCommand:[]},{name:"start",version:"0.0.2",example:"dphelper.socket.start(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Start a socket connection",env:"client",subCommand:[]},{name:"conn",version:"0.0.2",example:"dphelper.socket.conn(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Manage socket connections",env:"client",subCommand:[]},{name:"connect",version:"0.0.2",example:"dphelper.socket.connect(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Connect to a socket",env:"client",subCommand:[]},{name:"open",version:"0.0.2",example:"dphelper.socket.open(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Open a socket connection",env:"client",subCommand:[]},{name:"send",version:"0.0.2",example:"dphelper.socket.send(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Send data through a socket",env:"client",subCommand:[]},{name:"receive",version:"0.0.2",example:"dphelper.socket.receive(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Receive data from a socket",env:"client",subCommand:[]},{name:"keepAlive",version:"0.0.2",example:"dphelper.socket.keepAlive(...)",author:"Dario Passariello",creationDate:"2021-01-01",lastMod:"2021-01-01",type:"function",active:true,description:"Keep the socket connection alive",env:"client",subCommand:[]},{name:"check",version:"0.0.2",example:"dphelper.socket.check()",author:"Dario Passariello",creationDate:"2023-05-27",lastMod:"2023-05-27",type:"function",active:true,description:"Check how many websocket connections are open",env:"client",subCommand:[]},{name:"list",version:"0.0.2",example:"dphelper.socket.list()",author:"Dario Passariello",creationDate:"2023-05-27",lastMod:"2023-05-27",type:"function",active:true,description:"List all websocket connections in real-time",env:"client",subCommand:[]},{name:"close",version:"0.0.1",example:"dphelper.socket.close([name])",author:"Dario Passariello",creationDate:"2026-05-18",lastMod:"2025-05-18",type:"function",active:true,description:"Close websocket connections by name",env:"client",subCommand:[]}]},zr={info:()=>"Created by Dario Passariello",start:(e,t="general")=>{x.ws={},dphelper.socket.connect(e,t);},conn:(e,t,r,n)=>{if(!(e&&t)){console.debug("please use connect!");return}try{let o;try{o=new URL(t);}catch{if(!t.startsWith("/")&&!t.startsWith("ws")&&!t.startsWith("wss"))o=new URL(t,window.location.origin);else {console.error("Invalid WebSocket URL");return}}if(o.protocol==="ws:"){console.error("Insecure WebSocket protocol 'ws://' - must use 'wss://'");return}n&&o.searchParams.set("token",n);let a=new WebSocket(o.toString());return a.binaryType="blob",a.onmessage=i=>{},[a,e,r]}catch(o){console.error(o);return}},connect:(e,t)=>{e&&dphelper.socket.open(dphelper.security.uuid.v5,e,t);},open:(e,t,r,n)=>{if(e)try{let o=dphelper.socket.conn(e,t,r,n);if(!o)return;x.ws[r]=o,dphelper._list.sockets.indexOf(o[0])===-1&&dphelper._list.sockets.push(o[0]);let a=0,i=5,s=1e3,l=()=>{if(a>=i){console.error(`[dphelper] Socket "${r}" max reconnect attempts (${i}) reached`);return}a++;let h=Math.min(s*Math.pow(2,a),3e4);console.debug(`[dphelper] Reconnecting socket "${r}" in ${h}ms (attempt ${a}/${i})`),setTimeout(()=>{dphelper.socket.open(e,t,r,n);},h);},d=()=>{dphelper.log.reg(`${e} connected`),a=0;},c=h=>{dphelper.log.debug(h.wasClean?"Disconnected":`Connection break: ${h.reason||h.code}`),h.wasClean||l();},u=h=>{dphelper.log?.error(h);};o[0].onopen=d,o[0].onclose=c,o[0].onerror=u,o[0].__dphelper_handlers={origOnOpen:d,origOnClose:c,origOnError:u};}catch(o){console.error(o);}},ping:e=>{if(x.ws[e]?.[1])try{x.ws[e]?.[0]?.send('{"debug":"__ping__"}');}catch(t){console.error(t);}},send:(e,t)=>{if(x.ws[t]?.[1]&&e)try{let r=x.ws[t];if(!r)return;r[0].send(String(e));}catch(r){console.error(r);}},receive:(e,t)=>{if(x.ws[t]?.[1])try{let r=x.ws[t],n=r[0];n.onmessage=o=>{e(o),dphelper.log.reg(o);};}catch(r){console.error(r);}},keepAlive:e=>{try{let t=x.ws[e];if(!t)return;let r=t[0],n=r.__dphelper_handlers;if(!n){console.warn("[dphelper] keepAlive: no stored handlers found for",e);return}let o,a=(c=5e3)=>{o=setTimeout(()=>{dphelper.socket.ping(e);},c);},i=()=>clearTimeout(o),s=()=>{n.origOnOpen?.(),setInterval(a,3e4);},l=c=>{try{Object.values(JSON.parse(c.data))[0]==="__ping__"&&i();}catch(u){console.error(u);}},d=n.origOnMessage;r.onopen=s,r.onmessage=c=>{typeof d=="function"&&d(c),l(c);};}catch(t){console.error(t);}},check:()=>{dphelper._list.sockets=dphelper._list.sockets.filter(e=>e.readyState!==WebSocket.CLOSED);},list:()=>dphelper._list.sockets,close:e=>{try{let t=x.ws[e];if(!t)return;t[0].close();}catch(t){console.error(t);}}};dphelper?.setDescription(Ur,zr);typeof document<"u"&&dphelper?.socket?.check();var _r={name:"sse",active:true,subCommand:[{name:"open",version:"0.0.2",example:"dphelper.sse.open('/api/stream', { method: 'POST', body: ... })",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260513",type:"function",active:true,description:"Advanced Server-Sent Events client with POST and Custom Headers support. HTTPS required. Validates Content-Type before processing.",env:"client",subCommand:[]}]},Fr=e=>{try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"?(console.error("[dphelper] Only HTTP/HTTPS protocols allowed for SSE"),!1):!0}catch{return true}},Br=e=>e?e.includes("text/event-stream")||e.includes("text/plain"):false,Wr={open:(e,t={})=>{if(!Fr(e))return {on:()=>{},close:()=>{}};let r={message:[],error:[],open:[]},n=new AbortController,o=(i,s)=>{r[i]?.forEach(l=>l(s));};return (async()=>{try{let i=await fetch(e,{...t,signal:n.signal,headers:{Accept:"text/event-stream",...t.headers||{}}});if(!i.ok)throw new Error(`SSE failed: ${i.statusText}`);let s=i.headers.get("Content-Type");if(!Br(s)){console.error(`[dphelper] SSE: Invalid Content-Type "${s}". Expected text/event-stream.`),n.abort(),o("error",new Error(`Invalid Content-Type: ${s}`));return}o("open",{status:i.status});let l=i.body?.getReader(),d=new TextDecoder;if(!l)return;let c="";for(;;){let{done:u,value:h}=await l.read();if(u)break;c+=d.decode(h,{stream:!0});let f=c.split(`
132
- `);c=f.pop()||"";for(let v of f)if(v.startsWith("data:")){let g=v.replace("data:","").trim();try{(g.includes("[")||g.includes("{"))&&(g=JSON.parse(g));}catch{}o("message",g);}}}catch(i){i.name!=="AbortError"&&o("error",i);}})(),{on:(i,s)=>{r[i]&&r[i].push(s);},close:()=>n.abort()}}};dphelper?.setDescription(_r,Wr);var Gr={name:"svg",active:true,subCommand:[{name:"init",version:"0.0.2",example:"dphelper.svg.init(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Initializes an SVG connection between two elements.",env:"client",subCommand:[]},{name:"check",version:"0.0.2",example:"dphelper.svg.check(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Checks if SVG support is available.",env:"client",subCommand:[]},{name:"update",version:"0.0.2",example:"dphelper.svg.update(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Updates the SVG connection between two elements.",env:"client",subCommand:[]},{name:"getCurve",version:"0.0.2",example:"dphelper.svg.getCurve(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the curve of the connection between two points.",env:"client",subCommand:[]},{name:"getIntersection",version:"0.0.2",example:"dphelper.svg.getIntersection(...) ",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the intersection point between two elements.",env:"client",subCommand:[]},{name:"setConnector",version:"0.0.2",example:"dphelper.svg.setConnector(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Sets a connector on an element.",env:"client",subCommand:[]},{name:"removeConnection",version:"0.0.2",example:"dphelper.svg.removeConnection(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Removes an SVG connection from a container.",env:"client",subCommand:[]},{name:"makeScrollable",version:"0.0.2",example:"dphelper.svg.makeScrollable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG container scrollable.",env:"client",subCommand:[]},{name:"makeDraggable",version:"0.0.2",example:"dphelper.svg.makeDraggable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG element draggable.",env:"client",subCommand:[]},{name:"toggle",version:"0.0.2",example:"dphelper.svg.toggle(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Toggles an SVG connection on or off.",env:"client",subCommand:[]},{name:"convert",version:"0.0.2",example:"dphelper.svg.convert([Object])",author:"Dario Passariello",creationDate:"20190101",lastMod:"20240401",type:"function",active:true,description:"Converts an element to SVG.",env:"client",subCommand:[]}]},Jr={init:(e,t,r,n)=>{e.querySelector("svg")&&dphelper.svg.removeConnection(e),t=[dphelper.svg.setConnector(t[0],t[1]),t[1]],r=[dphelper.svg.setConnector(r[0],r[1]),r[1]];let o=e.getBoundingClientRect(),a="http://www.w3.org/2000/svg",i=e.offsetWidth*10,s=e.offsetHeight*10,l=document.createElementNS(a,"svg"),d=`conn_${Math.random().toString(36).substring(2,9)}`;l.setAttribute("xmlns",a),l.dataset.dphelper="svg-connection",l.setAttributeNS(null,"viewBox","0 0 "+i+" "+s),l.setAttributeNS(null,"width",String(i)),l.setAttributeNS(null,"height",String(s)),l.style.display="block";let c=document.createElementNS(a,"rect"),u=t[0].getBoundingClientRect();c.setAttributeNS(null,"x",String(u.left-o.left)),c.setAttributeNS(null,"y",String(u.top-o.top)),c.setAttributeNS(null,"width",String(u.width)),c.setAttributeNS(null,"height",String(u.height)),l.appendChild(c);let h=document.createElementNS(a,"rect");u=r[0].getBoundingClientRect(),h.setAttributeNS(null,"x",String(u.left-o.left)),h.setAttributeNS(null,"y",String(u.top-o.top)),h.setAttributeNS(null,"width",String(u.width)),h.setAttributeNS(null,"height",String(u.height)),l.appendChild(h);let f=document.createElementNS(a,"path");f.setAttributeNS(null,"id",d),f.setAttributeNS(null,"marker-end","url(#head)"),l.appendChild(f),e.appendChild(l),dphelper.svg.update(c,h,f),typeof n=="function"&&n(t,r);},check:()=>!!(document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),update:(e,t,r)=>{let n=Number.parseFloat(e.getAttribute("x")||"0"),o=Number.parseFloat(e.getAttribute("y")||"0"),a=Number.parseFloat(t.getAttribute("x")||"0"),i=Number.parseFloat(t.getAttribute("y")||"0"),s=Number.parseFloat(e.getAttribute("width")||"0")/2,l=Number.parseFloat(e.getAttribute("height")||"0")/2,d=Number.parseFloat(t.getAttribute("width")||"0")/2,c=Number.parseFloat(t.getAttribute("height")||"0")/2,u=n+s,h=o+l,f=a+d,v=i+c,g=f-u,b=v-h,y=dphelper.svg.getIntersection(g,b,u,h,s,l),P=dphelper.svg.getIntersection(-g,-b,f,v,d,c),O=P[0]-y[0],N=dphelper.svg.getCurve(y,P,O);r.setAttributeNS(null,"d","M"+u+","+h+N+f+","+v);},getCurve:(e,t,r)=>{let n=r/2;return " C"+(n+e[0])+","+e[1]+" "+(t[0]-n)+","+t[1]+" "},getIntersection:(e,t,r,n,o,a)=>Math.abs(t/e)<a/o?[r+(e>0?o:-o),n+t*o/Math.abs(e)]:[r+e*a/Math.abs(t),n+(t>0?a:-a)],setConnector:(e,t)=>{let r,n=document.createElement("span");switch(e.style.position="relative",n.style.position="absolute",n.style.width="5px",n.style.height="5px",t){case "top":r={left:"50%",top:"2.5px",marginLeft:"2.5px"};break;case "right":r={top:"50%",right:"2.5px",marginTop:"-2.5px"};break;case "bottom":r={left:"50%",bottom:"-2.5px",marginLeft:"2.5px"};break;case "left":r={top:"50%",left:"-2.5px",marginTop:"-2.5px"};break;default:r={};}return Object.assign(n.style,r),e.appendChild(n),n},removeConnection:e=>{e.querySelectorAll("svg[data-dphelper='svg-connection']").forEach(r=>r.remove());},makeScrollable:(e,t,r,n,o,a)=>{let i=e.getBoundingClientRect(),s=[r,n],l=s.length,d=[o,a],c=[];for(let g=0;g<l;g++){let b=s[g],y=d[g];!b||!y||(c[g]=b.getBoundingClientRect(),y.setAttributeNS(null,"x",String(c[g].left-i.left)),y.setAttributeNS(null,"y",String(c[g].top-i.top)),y.setAttributeNS(null,"width",String(c[g].width)),y.setAttributeNS(null,"height",String(c[g].height)));}let u=e.querySelectorAll("rect"),h=u[0],f=u[1],v=document.getElementById("connection");h&&f&&v&&dphelper.svg.update(h,f,v);},makeDraggable:e=>{let t=e.target;function r(d){let c=t.getScreenCTM();return c?{x:(d.clientX-c.e)/c.a,y:(d.clientY-c.f)/c.d}:{x:0,y:0}}let n=null,o=null,a=d=>{if(n&&o){let c=r(d);n.setAttributeNS(null,"x",String(c.x-o.x)),n.setAttributeNS(null,"y",String(c.y-o.y));let u=document.getElementById("connection");u&&dphelper.svg.update(n,n,u);}},i=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i),n=null,o=null;},s=d=>{d.target.classList.contains("draggable")&&(n=d.target,o=r(d),o.x-=Number.parseFloat(n.getAttributeNS(null,"x")||"0"),o.y-=Number.parseFloat(n.getAttributeNS(null,"y")||"0"),document.addEventListener("mousemove",a),document.addEventListener("mouseup",i));};t.addEventListener("mousedown",s),t.__dphelper_cleanup=()=>{t.removeEventListener("mousedown",s),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i);};let l=new MutationObserver(()=>{document.contains(t)||(t.__dphelper_cleanup&&t.__dphelper_cleanup(),l.disconnect());});l.observe(document.body,{childList:true,subtree:true});},toggle:(e,t,r,n)=>{let o=e.target;if(o.checked&&r&&n){dphelper.cookie.set({name:`${o.id}`,value:1,time:365});let a=()=>{dphelper.svg.makeScrollable(t,document.getElementById("parts-left-body"),r,n,document.querySelector("#parts svg rect"),document.querySelectorAll("#parts svg rect")[1]);};dphelper.svg.init(t,[r,"right"],[n,"left"],(i,s)=>{let l=document.getElementById("parts-left-body");l&&(l.addEventListener("scroll",a),l.__dphelper_scrollHandler=a);});}else {dphelper.svg.removeConnection(t);let a=document.getElementById("parts-left-body");a&&a.__dphelper_scrollHandler&&(a.removeEventListener("scroll",a.__dphelper_scrollHandler),delete a.__dphelper_scrollHandler),a&&a.replaceWith(a.cloneNode(true)),dphelper.cookie.set({name:`${o.id}`,value:0,time:365});}},convert:({children:e,active:t=true,size:r=[1920,1080],fit:n=["100%","100%"],preserveAspectRatio:o="none",style:a=`width:${n[0]}; height:${n[1]}`,zoom:i=1})=>{if(!e)return "Please pass ID of element for SVG conversion";if(t){let s=f=>f.replace(/[<>"'&]/g,""),l=document.querySelector(e);if(!l)return "Element not found";let d=l.cloneNode(true),c="http://www.w3.org/2000/svg",u=document.createElementNS(c,"svg");u.setAttribute("viewBox",`0 0 ${s(String(r[0]))} ${s(String(r[1]))}`),u.setAttribute("preserveAspectRatio",s(o)),u.setAttribute("xmlns",c),u.setAttribute("style",s(a)+"; zoom:"+s(String(i)));let h=document.createElementNS(c,"foreignObject");h.setAttribute("x","0"),h.setAttribute("y","0"),h.setAttribute("width",s(String(n[0]))),h.setAttribute("height",s(String(n[1]))),h.setAttribute("style",s(a)+"; zoom:"+s(String(i))),h.appendChild(d),u.appendChild(h),l.innerHTML="",l.appendChild(u);}}};dphelper?.setDescription(Gr,Jr);typeof document<"u"&&dphelper?.svg?.check();var Yr={name:"sync",active:true,subCommand:[{name:"tab",version:"0.0.2",example:"dphelper.sync.tab('my_channel', (data) => console.debug(data))",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Synchronize data between tabs using BroadcastChannel",env:"client",subCommand:[]},{name:"storageProxy",version:"0.0.2",example:"const proxy = dphelper.sync.storageProxy('user_pref', {theme: 'dark'})",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Create a Proxy object linked to localStorage for auto-sync",env:"client",subCommand:[]},{name:"pulse",version:"0.0.1",example:"dphelper.sync.pulse('chat', (msg) => ...)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Low-latency cross-tab event bus with automatic registration.",env:"client",subCommand:[]}]},Vr={pulse:(e,t)=>{if(typeof BroadcastChannel>"u")return {emit:()=>{},stop:()=>{}};let r=new BroadcastChannel(`pulse_${e}`);return r.onmessage=n=>{if(n.origin===window.location.origin||!n.origin)try{let o=n.data;o&&typeof o=="object"&&!o.__proto__&&!o.constructor&&t(o);}catch(o){console.warn("[dphelper] Invalid message received in pulse:",o);}},{emit:n=>r.postMessage(n),stop:()=>r.close()}},tab:(e,t)=>{if(typeof BroadcastChannel>"u")return {post:()=>{},close:()=>{}};let r=new BroadcastChannel(e);return r.onmessage=n=>{if(n.origin===window.location.origin||!n.origin)try{let o=n.data;o&&typeof o=="object"&&!o.__proto__&&!o.constructor&&t(o);}catch(o){console.warn("[dphelper] Invalid message received in tab:",o);}},{post:n=>r.postMessage(n),close:()=>r.close()}},storageProxy:async(e,t,r)=>{if(typeof localStorage>"u")return t;let n,o=localStorage.getItem(e);if(o)if(r){let i=await dphelper.security.getEncrypted(e,r);n=i?JSON.parse(i):t;}else try{n=JSON.parse(o);}catch{n=t;}else n=t;return new Proxy(n,{set(i,s,l){i[s]=l;let d=JSON.stringify(i);return r?dphelper.security.saveEncrypted(e,d,r):localStorage.setItem(e,d),true}})}};dphelper?.setDescription(Yr,Vr);var Kr={name:"system",active:true,subCommand:[{name:"multiSplit",version:"0.0.2",example:"dphelper.system.multiSplit()",author:"Dario Passariello",creationDate:"20231121",lastMod:"20231121",type:"system",active:true,description:"Run only one time when you load your App ... extend the .split with array as argument (example.split([',', ':', ';', '?', '/'])[0])",env:"both",subCommand:[]}]},Zr={multiSplit:(e,t)=>{if(!e)return [];let r=t[0];if(!r)return [e];let n=e;for(let o=1;o<t.length;++o)n=n.split(t[o]).join(r);return n.split(r)}};dphelper?.setDescription(Kr,Zr);var Xr={name:"text",active:true,subCommand:[{name:"trim",version:"0.0.2",example:"dphelper.text.trim(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Trims the specified characters from the start and end of a string.",env:"both",subCommand:[]},{name:"capitalize",version:"0.0.2",example:"dphelper.text.capitalize(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Capitalizes the first letter of each word in a string.",env:"both",subCommand:[]},{name:"lower",version:"0.0.2",example:"dphelper.text.lower(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to lowercase.",env:"both",subCommand:[]},{name:"upper",version:"0.0.2",example:"dphelper.text.upper(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to uppercase.",env:"both",subCommand:[]},{name:"nl2br",version:"0.0.2",example:"dphelper.text.nl2br(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts newlines in a string to HTML <br> tags.",env:"both",subCommand:[]},{name:"sanitize",version:"0.0.2",example:"dphelper.text.sanitize(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Sanitizes a string by removing HTML tags.",env:"both",subCommand:[]},{name:"camelCase",version:"0.0.2",example:"dphelper.text.camelCase(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to camelCase.",subCommand:[{name:"toSpace",version:"0.0.2",example:"dphelper.text.camelCase.toSpace(...)",type:"function",active:true,description:"Converts camelCase to space-separated words.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"},{name:"toUnderscore",version:"0.0.2",example:"dphelper.text.camelCase.toUnderscore(...)",type:"function",active:true,description:"Converts camelCase to underscore-separated words.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"}]},{name:"fitContainer",version:"0.0.2",example:"dphelper.text.fitContainer([element])",type:"function",active:true,description:"Adjusts the font size of an element to fit its container.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"},{name:"keywords",version:"0.0.2",example:"dphelper.text.keywords([sentence])",type:"function",active:true,description:"Extrapolate keywords from a sentence",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20250601",lastMod:"20250601"},{name:"replaceText",version:"0.0.2",example:"dphelper.text.replaceText([sentence, object])",type:"function",active:true,description:`
132
+ `);c=f.pop()||"";for(let v of f)if(v.startsWith("data:")){let g=v.replace("data:","").trim();try{(g.includes("[")||g.includes("{"))&&(g=JSON.parse(g));}catch{}o("message",g);}}}catch(i){i.name!=="AbortError"&&o("error",i);}})(),{on:(i,s)=>{r[i]&&r[i].push(s);},close:()=>n.abort()}}};dphelper?.setDescription(_r,Wr);var Gr={name:"svg",active:true,subCommand:[{name:"init",version:"0.0.2",example:"dphelper.svg.init(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Initializes an SVG connection between two elements.",env:"client",subCommand:[]},{name:"check",version:"0.0.2",example:"dphelper.svg.check(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Checks if SVG support is available.",env:"client",subCommand:[]},{name:"update",version:"0.0.2",example:"dphelper.svg.update(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Updates the SVG connection between two elements.",env:"client",subCommand:[]},{name:"getCurve",version:"0.0.2",example:"dphelper.svg.getCurve(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the curve of the connection between two points.",env:"client",subCommand:[]},{name:"getIntersection",version:"0.0.2",example:"dphelper.svg.getIntersection(...) ",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Calculates the intersection point between two elements.",env:"client",subCommand:[]},{name:"setConnector",version:"0.0.2",example:"dphelper.svg.setConnector(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Sets a connector on an element.",env:"client",subCommand:[]},{name:"removeConnection",version:"0.0.2",example:"dphelper.svg.removeConnection(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Removes an SVG connection from a container.",env:"client",subCommand:[]},{name:"makeScrollable",version:"0.0.2",example:"dphelper.svg.makeScrollable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG container scrollable.",env:"client",subCommand:[]},{name:"makeDraggable",version:"0.0.2",example:"dphelper.svg.makeDraggable(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Makes an SVG element draggable.",env:"client",subCommand:[]},{name:"toggle",version:"0.0.2",example:"dphelper.svg.toggle(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Toggles an SVG connection on or off.",env:"client",subCommand:[]},{name:"convert",version:"0.0.2",example:"dphelper.svg.convert([Object])",author:"Dario Passariello",creationDate:"20190101",lastMod:"20240401",type:"function",active:true,description:"Converts an element to SVG.",env:"client",subCommand:[]}]},Jr={init:(e,t,r,n)=>{e.querySelector("svg")&&dphelper.svg.removeConnection(e),t=[dphelper.svg.setConnector(t[0],t[1]),t[1]],r=[dphelper.svg.setConnector(r[0],r[1]),r[1]];let o=e.getBoundingClientRect(),a="http://www.w3.org/2000/svg",i=e.offsetWidth*10,s=e.offsetHeight*10,l=document.createElementNS(a,"svg"),d=`conn_${Math.random().toString(36).substring(2,9)}`;l.setAttribute("xmlns",a),l.dataset.dphelper="svg-connection",l.setAttributeNS(null,"viewBox","0 0 "+i+" "+s),l.setAttributeNS(null,"width",String(i)),l.setAttributeNS(null,"height",String(s)),l.style.display="block";let c=document.createElementNS(a,"rect"),u=t[0].getBoundingClientRect();c.setAttributeNS(null,"x",String(u.left-o.left)),c.setAttributeNS(null,"y",String(u.top-o.top)),c.setAttributeNS(null,"width",String(u.width)),c.setAttributeNS(null,"height",String(u.height)),l.appendChild(c);let h=document.createElementNS(a,"rect");u=r[0].getBoundingClientRect(),h.setAttributeNS(null,"x",String(u.left-o.left)),h.setAttributeNS(null,"y",String(u.top-o.top)),h.setAttributeNS(null,"width",String(u.width)),h.setAttributeNS(null,"height",String(u.height)),l.appendChild(h);let f=document.createElementNS(a,"path");f.setAttributeNS(null,"id",d),f.setAttributeNS(null,"marker-end","url(#head)"),l.appendChild(f),e.appendChild(l),dphelper.svg.update(c,h,f),typeof n=="function"&&n(t,r);},check:()=>!!(document.createElementNS&&document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),update:(e,t,r)=>{let n=Number.parseFloat(e.getAttribute("x")||"0"),o=Number.parseFloat(e.getAttribute("y")||"0"),a=Number.parseFloat(t.getAttribute("x")||"0"),i=Number.parseFloat(t.getAttribute("y")||"0"),s=Number.parseFloat(e.getAttribute("width")||"0")/2,l=Number.parseFloat(e.getAttribute("height")||"0")/2,d=Number.parseFloat(t.getAttribute("width")||"0")/2,c=Number.parseFloat(t.getAttribute("height")||"0")/2,u=n+s,h=o+l,f=a+d,v=i+c,g=f-u,b=v-h,y=dphelper.svg.getIntersection(g,b,u,h,s,l),P=dphelper.svg.getIntersection(-g,-b,f,v,d,c),O=P[0]-y[0],N=dphelper.svg.getCurve(y,P,O);r.setAttributeNS(null,"d","M"+u+","+h+N+f+","+v);},getCurve:(e,t,r)=>{let n=r/2;return " C"+(n+e[0])+","+e[1]+" "+(t[0]-n)+","+t[1]+" "},getIntersection:(e,t,r,n,o,a)=>Math.abs(t/e)<a/o?[r+(e>0?o:-o),n+t*o/Math.abs(e)]:[r+e*a/Math.abs(t),n+(t>0?a:-a)],setConnector:(e,t)=>{let r,n=document.createElement("span");switch(e.style.position="relative",n.style.position="absolute",n.style.width="5px",n.style.height="5px",t){case "top":r={left:"50%",top:"2.5px",marginLeft:"2.5px"};break;case "right":r={top:"50%",right:"2.5px",marginTop:"-2.5px"};break;case "bottom":r={left:"50%",bottom:"-2.5px",marginLeft:"2.5px"};break;case "left":r={top:"50%",left:"-2.5px",marginTop:"-2.5px"};break;default:r={};}return Object.assign(n.style,r),e.appendChild(n),n},removeConnection:e=>{e.querySelectorAll("svg[data-dphelper='svg-connection']").forEach(r=>r.remove());},makeScrollable:(e,t,r,n,o,a)=>{let i=e.getBoundingClientRect(),s=[r,n],l=s.length,d=[o,a],c=[];for(let g=0;g<l;g++){let b=s[g],y=d[g];!b||!y||(c[g]=b.getBoundingClientRect(),y.setAttributeNS(null,"x",String(c[g].left-i.left)),y.setAttributeNS(null,"y",String(c[g].top-i.top)),y.setAttributeNS(null,"width",String(c[g].width)),y.setAttributeNS(null,"height",String(c[g].height)));}let u=e.querySelectorAll("rect"),h=u[0],f=u[1],v=document.getElementById("connection");h&&f&&v&&dphelper.svg.update(h,f,v);},makeDraggable:e=>{let t=e.target;function r(d){let c=t.getScreenCTM();return c?{x:(d.clientX-c.e)/c.a,y:(d.clientY-c.f)/c.d}:{x:0,y:0}}let n=null,o=null,a=d=>{if(n&&o){let c=r(d);n.setAttributeNS(null,"x",String(c.x-o.x)),n.setAttributeNS(null,"y",String(c.y-o.y));let u=document.getElementById("connection");u&&dphelper.svg.update(n,n,u);}},i=()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i),n=null,o=null;},s=d=>{d.target.classList.contains("draggable")&&(n=d.target,o=r(d),o.x-=Number.parseFloat(n.getAttributeNS(null,"x")||"0"),o.y-=Number.parseFloat(n.getAttributeNS(null,"y")||"0"),document.addEventListener("mousemove",a),document.addEventListener("mouseup",i));};t.addEventListener("mousedown",s),t.__dphelper_cleanup=()=>{t.removeEventListener("mousedown",s),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i);};let l=new MutationObserver(()=>{document.contains(t)||(t.__dphelper_cleanup&&t.__dphelper_cleanup(),l.disconnect());});l.observe(document.body,{childList:true,subtree:true});},toggle:(e,t,r,n)=>{let o=e.target;if(o.checked&&r&&n){dphelper.cookie.set({name:`${o.id}`,value:1,time:365});let a=()=>{dphelper.svg.makeScrollable(t,document.getElementById("parts-left-body"),r,n,document.querySelector("#parts svg rect"),document.querySelectorAll("#parts svg rect")[1]);};dphelper.svg.init(t,[r,"right"],[n,"left"],(i,s)=>{let l=document.getElementById("parts-left-body");l&&(l.addEventListener("scroll",a),l.__dphelper_scrollHandler=a);});}else {dphelper.svg.removeConnection(t);let a=document.getElementById("parts-left-body");a&&a.__dphelper_scrollHandler&&(a.removeEventListener("scroll",a.__dphelper_scrollHandler),delete a.__dphelper_scrollHandler),a&&a.replaceWith(a.cloneNode(true)),dphelper.cookie.set({name:`${o.id}`,value:0,time:365});}},convert:({children:e,active:t=true,size:r=[1920,1080],fit:n=["100%","100%"],preserveAspectRatio:o="none",style:a=`width:${n[0]}; height:${n[1]}`,zoom:i=1})=>{if(!e)return "Please pass ID of element for SVG conversion";if(t){let s=f=>f.replace(/[<>"'&]/g,""),l=document.querySelector(e);if(!l)return "Element not found";let d=l.cloneNode(true),c="http://www.w3.org/2000/svg",u=document.createElementNS(c,"svg");u.setAttribute("viewBox",`0 0 ${s(String(r[0]))} ${s(String(r[1]))}`),u.setAttribute("preserveAspectRatio",s(o)),u.setAttribute("xmlns",c),u.setAttribute("style",s(a)+"; zoom:"+s(String(i)));let h=document.createElementNS(c,"foreignObject");h.setAttribute("x","0"),h.setAttribute("y","0"),h.setAttribute("width",s(String(n[0]))),h.setAttribute("height",s(String(n[1]))),h.setAttribute("style",s(a)+"; zoom:"+s(String(i))),h.appendChild(d),u.appendChild(h),l.innerHTML="",l.appendChild(u);}}};dphelper?.setDescription(Gr,Jr);typeof document<"u"&&dphelper?.svg?.check();var Yr={name:"sync",active:true,subCommand:[{name:"tab",version:"0.0.2",example:"dphelper.sync.tab('my_channel', (data) => console.debug(data))",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Synchronize data between tabs using BroadcastChannel",env:"client",subCommand:[]},{name:"storageProxy",version:"0.0.2",example:"const proxy = dphelper.sync.storageProxy('user_pref', {theme: 'dark'})",author:"Dario Passariello & Jo",creationDate:"20260220",lastMod:"20260220",type:"function",active:true,description:"Create a Proxy object linked to localStorage for auto-sync",env:"client",subCommand:[]},{name:"pulse",version:"0.0.1",example:"dphelper.sync.pulse('chat', (msg) => ...)",author:"Dario Passariello",creationDate:"20260221",lastMod:"20260221",type:"function",active:true,description:"Low-latency cross-tab event bus with automatic registration.",env:"client",subCommand:[]}]},Vr={pulse:(e,t)=>{if(typeof BroadcastChannel>"u")return {emit:()=>{},stop:()=>{}};let r=new BroadcastChannel(`pulse_${e}`);return r.onmessage=n=>{if(n.origin===window.location.origin||!n.origin)try{let o=n.data;if(o&&typeof o=="object"){let a=Object.getPrototypeOf(o);(a===Object.prototype||a===null)&&t(o);}}catch(o){console.warn("[dphelper] Invalid message received in pulse:",o);}},{emit:n=>r.postMessage(n),stop:()=>r.close()}},tab:(e,t)=>{if(typeof BroadcastChannel>"u")return {post:()=>{},close:()=>{}};let r=new BroadcastChannel(e);return r.onmessage=n=>{if(n.origin===window.location.origin||!n.origin)try{let o=n.data;if(o&&typeof o=="object"){let a=Object.getPrototypeOf(o);(a===Object.prototype||a===null)&&t(o);}}catch(o){console.warn("[dphelper] Invalid message received in tab:",o);}},{post:n=>r.postMessage(n),close:()=>r.close()}},storageProxy:async(e,t,r)=>{if(typeof localStorage>"u")return t;let n,o=localStorage.getItem(e);if(o)if(r){let i=await dphelper.security.getEncrypted(e,r);n=i?JSON.parse(i):t;}else try{n=JSON.parse(o);}catch{n=t;}else n=t;return new Proxy(n,{set(i,s,l){i[s]=l;let d=JSON.stringify(i);return r?dphelper.security.saveEncrypted(e,d,r):localStorage.setItem(e,d),true}})}};dphelper?.setDescription(Yr,Vr);var Kr={name:"system",active:true,subCommand:[{name:"multiSplit",version:"0.0.2",example:"dphelper.system.multiSplit()",author:"Dario Passariello",creationDate:"20231121",lastMod:"20231121",type:"system",active:true,description:"Run only one time when you load your App ... extend the .split with array as argument (example.split([',', ':', ';', '?', '/'])[0])",env:"both",subCommand:[]}]},Zr={multiSplit:(e,t)=>{if(!e)return [];let r=t[0];if(!r)return [e];let n=e;for(let o=1;o<t.length;++o)n=n.split(t[o]).join(r);return n.split(r)}};dphelper?.setDescription(Kr,Zr);var Xr={name:"text",active:true,subCommand:[{name:"trim",version:"0.0.2",example:"dphelper.text.trim(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Trims the specified characters from the start and end of a string.",env:"both",subCommand:[]},{name:"capitalize",version:"0.0.2",example:"dphelper.text.capitalize(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Capitalizes the first letter of each word in a string.",env:"both",subCommand:[]},{name:"lower",version:"0.0.2",example:"dphelper.text.lower(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to lowercase.",env:"both",subCommand:[]},{name:"upper",version:"0.0.2",example:"dphelper.text.upper(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to uppercase.",env:"both",subCommand:[]},{name:"nl2br",version:"0.0.2",example:"dphelper.text.nl2br(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts newlines in a string to HTML <br> tags.",env:"both",subCommand:[]},{name:"sanitize",version:"0.0.2",example:"dphelper.text.sanitize(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Sanitizes a string by removing HTML tags.",env:"both",subCommand:[]},{name:"camelCase",version:"0.0.2",example:"dphelper.text.camelCase(...)",author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220",type:"function",active:true,description:"Converts a string to camelCase.",subCommand:[{name:"toSpace",version:"0.0.2",example:"dphelper.text.camelCase.toSpace(...)",type:"function",active:true,description:"Converts camelCase to space-separated words.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"},{name:"toUnderscore",version:"0.0.2",example:"dphelper.text.camelCase.toUnderscore(...)",type:"function",active:true,description:"Converts camelCase to underscore-separated words.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"}]},{name:"fitContainer",version:"0.0.2",example:"dphelper.text.fitContainer([element])",type:"function",active:true,description:"Adjusts the font size of an element to fit its container.",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20210101",lastMod:"20260220"},{name:"keywords",version:"0.0.2",example:"dphelper.text.keywords([sentence])",type:"function",active:true,description:"Extrapolate keywords from a sentence",env:"both",subCommand:[],author:"Dario Passariello",creationDate:"20250601",lastMod:"20250601"},{name:"replaceText",version:"0.0.2",example:"dphelper.text.replaceText([sentence, object])",type:"function",active:true,description:`
133
133
  replace all occurrence from sentence using an object as list
134
134
 
135
135
  example:
@@ -155,4 +155,4 @@ ${t(i,`${n} `)}${n}</${a}>
155
155
  top=${u},
156
156
  left=${c}
157
157
  `);onfocus=()=>h?.focus();},onBeforeUnLoad:e=>{let t="You have made some changes which you might want to save.",r=o=>(o.preventDefault(),t),n=e?document.querySelector(e):null;n&&n.addEventListener("input",()=>{n.value!==""?(L=true,addEventListener("beforeunload",r,{capture:true})):(L=false,removeEventListener("beforeunload",r,{capture:true}));}),le===false&&(document.body.addEventListener("click",o=>{let a=o.target;if(a&&a.tagName.toLowerCase()==="img"&&L===true){if(confirm(t)===true){L=false;return}o.preventDefault();}}),le=true),addEventListener("popstate",o=>{if(L===true){if(confirm(t)===true){L=false;return}o.stopImmediatePropagation(),o.preventDefault();return}}),onbeforeunload=o=>{if(L===true)return o.preventDefault(),o.returnValue=t};},purge:(e=document,t=1e4)=>{setTimeout(()=>{if(!e)return;let r=e.attributes;if(r){let n=r.length;for(let o=0;o<n;o+=1){let a=r[o].name;typeof e[a]=="function"&&(e[a]=null),typeof e[a]>"u"&&(e[a]=null);}}if(r=e.childNodes,r){let n=r.length;for(let o=0;o<n;o+=1)dphelper.purge(e.childNodes[o]);}},t);},stopZoomWheel:()=>{addEventListener("wheel",e=>{e.ctrlKey&&e.preventDefault();},{passive:false}),addEventListener("keydown",e=>{let t=dphelper.event.keys(e);["+","-","="].includes(t.key)&&t.ctrl&&e.preventDefault();});},setZoom:(e="html",t=1)=>{t<0&&(t=1);let r=document.querySelector(e);return r&&(r.style.zoom=String(t)),`New zoom value: ${t*100}% (css: ${t})`},getZoom:(e="html")=>{let t=document.querySelector(e);return Number(t?.style.zoom||1)}};dphelper?.setDescription(pn,mn);var hn={name:"worker",active:true,subCommand:[{name:"create",version:"0.0.1",example:"dphelper.worker.create('worker.js', { onmessage: (e) => console.log(e.data) })",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Create a new Web Worker from a script URL or inline code",env:"client",subCommand:[]},{name:"createInline",version:"0.0.1",example:"dphelper.worker.createInline('self.onmessage = e => postMessage(e.data * 2)')",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Create a Web Worker from inline JavaScript code",env:"client",subCommand:[]},{name:"post",version:"0.0.1",example:"dphelper.worker.post(worker, { type: 'compute', data: 42 })",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Send a message to a worker",env:"client",subCommand:[]},{name:"terminate",version:"0.0.1",example:"dphelper.worker.terminate(worker)",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Terminate a Web Worker",env:"client",subCommand:[]},{name:"pool",version:"0.0.1",example:"dphelper.worker.pool('worker.js', 4)",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Create a pool of workers for parallel processing",env:"client",subCommand:[]},{name:"poolExec",version:"0.0.1",example:"dphelper.worker.poolExec(pool, tasks)",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Execute tasks across a worker pool",env:"client",subCommand:[]},{name:"importScripts",version:"0.0.1",example:"dphelper.worker.importScripts(worker, ['lib1.js', 'lib2.js'])",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Import external scripts into a worker",env:"client",subCommand:[]},{name:"shared",version:"0.0.1",example:"dphelper.worker.shared('my-shared-buffer')",author:"Dario Passariello",creationDate:"20260313",lastMod:"20260313",type:"function",active:true,description:"Create a SharedWorker for cross-tab communication",env:"client",subCommand:[]}]},ce=(e,t={})=>{try{let r=new URL(e);if(!["http:","https:","blob:","data:"].includes(r.protocol))throw new Error(`Invalid protocol: ${r.protocol}`);let n=new Worker(r.href);return t.onmessage&&(n.onmessage=t.onmessage),t.onerror&&(n.onerror=t.onerror),n}catch(r){if(!(typeof e=="string"&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("blob:")&&!e.startsWith("data:")))throw console.error("[dphelper] worker.create: Invalid URL or protocol. Only http, https, blob, data, or relative paths allowed."),new Error("Invalid worker source URL",{cause:r});let o=new Blob([e],{type:"application/javascript"}),a=new Worker(URL.createObjectURL(o));return t.onmessage&&(a.onmessage=t.onmessage),t.onerror&&(a.onerror=t.onerror),a}},fn=(e,t={})=>{let r=new Blob([e],{type:"application/javascript"}),n=URL.createObjectURL(r),o=new Worker(n);return t.onmessage&&(o.onmessage=t.onmessage),t.onerror&&(o.onerror=t.onerror),o.addEventListener("message",()=>{URL.revokeObjectURL(n);}),o.addEventListener("error",()=>{URL.revokeObjectURL(n);}),o},V=(e,t,r)=>{r?e.postMessage(t,r):e.postMessage(t);},gn=e=>{e.terminate();},bn=(e,t=4)=>{let r=[],n=new Set;for(let a=0;a<t;a++)r.push(ce(e));return {workers:r,busy:n,queue:[],size:t}},vn=async(e,t,r=3e4)=>new Promise((n,o)=>{let a=new Array(t.length),i=0,s=false,l=setTimeout(()=>{s=true,o(new Error(`[dphelper] Worker pool execution timed out after ${r}ms`));},r),d=()=>{if(!s)for(;e.queue.length>0&&e.busy.size<e.size;){let{task:u}=e.queue.shift();c(u.index,u.data);}},c=(u,h)=>{if(s)return;let f=e.workers.find(b=>!e.busy.has(b));if(!f)return;e.busy.add(f);let v=b=>{f.removeEventListener("message",v),e.busy.delete(f),a[u]=b.data,i++,i===t.length?(clearTimeout(l),n(a)):d();},g=b=>{f.removeEventListener("error",g),e.busy.delete(f),s=true,clearTimeout(l),o(new Error(`[dphelper] Worker task failed: ${b.message}`));};f.addEventListener("message",v),f.addEventListener("error",g),V(f,{index:u,data:h});};t.forEach((u,h)=>{e.queue.push({task:{index:h,data:u}});}),d();}),yn=(e,t)=>{t.forEach(i=>{try{let s=new URL(i);if(!["http:","https:","blob:","data:"].includes(s.protocol)){console.error(`[dphelper] Invalid protocol for importScripts: ${s.protocol}`);return}}catch{console.error(`[dphelper] Invalid URL for importScripts: ${i}`);return}});let n=t.map(i=>i.replace(/['\\]/g,"\\$&")).map(i=>`importScripts('${i}');`).join(`
158
- `),o=new Blob([n],{type:"application/javascript"}),a=URL.createObjectURL(o);V(e,{type:"import",url:a});},Dn=(e,t={})=>{try{let r=t.name?{name:t.name}:void 0,n=new SharedWorker(e,r);return t.onmessage&&(n.port.onmessage=t.onmessage),t.onconnect&&(n.port.onmessage=o=>{t.onconnect?.(o),t.onmessage&&t.onmessage(o);}),n}catch(r){console.error("[dphelper] SharedWorker creation failed:",r);return}},wn={create:ce,createInline:fn,post:V,terminate:gn,pool:bn,poolExec:vn,importScripts:yn,shared:Dn};dphelper?.setDescription(hn,wn);if(typeof window<"u"){let e=setInterval(()=>{dphelper._list||(dphelper._list={sockets:[],scripts:[]});let t=dphelper?.socket?.list(),r=[];t&&(t.map(n=>(r.push(n.url),false)),dphelper._list.sockets=r,r.length>0&&clearInterval(e));},500);}Object.preventExtensions(dphelper);Object.seal(dphelper);
158
+ `),o=new Blob([n],{type:"application/javascript"}),a=URL.createObjectURL(o);V(e,{type:"import",url:a});},Dn=(e,t={})=>{try{let r=t.name?{name:t.name}:void 0,n=new SharedWorker(e,r);return t.onmessage&&(n.port.onmessage=t.onmessage),t.onconnect&&(n.port.onmessage=o=>{t.onconnect?.(o),t.onmessage&&t.onmessage(o);}),n}catch(r){console.error("[dphelper] SharedWorker creation failed:",r);return}},wn={create:ce,createInline:fn,post:V,terminate:gn,pool:bn,poolExec:vn,importScripts:yn,shared:Dn};dphelper?.setDescription(hn,wn);if(typeof window<"u"){let t=0,r=setInterval(()=>{if(dphelper._list||(dphelper._list={sockets:[],scripts:[]}),t++,t>=20){clearInterval(r);return}let n=dphelper?.socket?.list(),o=[];n&&(n.map(a=>(o.push(a.url),false)),dphelper._list.sockets=o,o.length>0&&clearInterval(r));},500);}Object.preventExtensions(dphelper);Object.seal(dphelper);