@visulima/ono 2.0.11 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ const m={javascript:()=>import("@shikijs/langs/javascript"),typescript:()=>import("@shikijs/langs/typescript"),jsx:()=>import("@shikijs/langs/jsx"),tsx:()=>import("@shikijs/langs/tsx"),json:()=>import("@shikijs/langs/json"),json5:()=>import("@shikijs/langs/json5"),jsonc:()=>import("@shikijs/langs/jsonc"),xml:()=>import("@shikijs/langs/xml"),sql:()=>import("@shikijs/langs/sql"),markdown:()=>import("@shikijs/langs/markdown"),mdx:()=>import("@shikijs/langs/mdx"),html:()=>import("@shikijs/langs/html"),css:()=>import("@shikijs/langs/css"),scss:()=>import("@shikijs/langs/scss"),less:()=>import("@shikijs/langs/less"),sass:()=>import("@shikijs/langs/sass"),stylus:()=>import("@shikijs/langs/stylus"),styl:()=>import("@shikijs/langs/styl"),svelte:()=>import("@shikijs/langs/svelte"),vue:()=>import("@shikijs/langs/vue"),bash:()=>import("@shikijs/langs/bash"),shell:()=>import("@shikijs/langs/shell"),yaml:()=>import("@shikijs/langs/yaml"),toml:()=>import("@shikijs/langs/toml"),python:()=>import("@shikijs/langs/python"),go:()=>import("@shikijs/langs/go"),rust:()=>import("@shikijs/langs/rust"),ruby:()=>import("@shikijs/langs/ruby"),php:()=>import("@shikijs/langs/php"),graphql:()=>import("@shikijs/langs/graphql"),dockerfile:()=>import("@shikijs/langs/dockerfile"),text:()=>Promise.resolve({name:"text",patterns:[],scopeName:"source.text",repository:{}})};let n;const u=async()=>{const[t,r]=await Promise.all([import("shiki/core"),import("shiki/engine/javascript")]),{createHighlighterCore:e}=t,{createJavaScriptRegexEngine:i}=r;return await e({themes:[import("../packem_chunks/min-dark.js"),import("../packem_chunks/min-light.js")],langs:[],engine:i()})},h=async(t,r)=>{if(r==="text")return;const e=r.toLowerCase();if(!(t.getLoadedLanguages?.()??t.getLanguages?.()??[]).includes(e)){const i=m[e];i&&await t.loadLanguage?.(await i())}},x=async(t=[])=>{n||(n=u().catch(o=>{throw n=void 0,o}));const r=await n,e=[],i=[];for(const o of t)typeof o=="string"?e.push(o.toLowerCase()):i.push(o);return await Promise.all([...e.map(o=>h(r,o)),...i.map(o=>r.loadLanguage?.(o))]),r},A="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-check%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Cpath%20d%3D%22M20%206%209%2017l-5-5%22%20%2F%3E%20%3C%2Fsvg%3E",C="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-clipboard%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Crect%20width%3D%228%22%20height%3D%224%22%20x%3D%228%22%20y%3D%222%22%20rx%3D%221%22%20ry%3D%221%22%20%2F%3E%20%3Cpath%20d%3D%22M16%204h2a2%202%200%200%201%202%202v14a2%202%200%200%201-2%202H6a2%202%200%200%201-2-2V6a2%202%200%200%201%202-2h2%22%20%2F%3E%20%3C%2Fsvg%3E";let a;try{const t=await import("isomorphic-dompurify");typeof t.sanitize=="function"&&(a=t.sanitize)}catch{}const p=(t,r)=>{if(a!==void 0)try{return r===void 0?a(t):a(t,r)}catch{return}},d=["http://","https://","/","./","../"],l="#",g={'"':"&quot;","&":"&amp;","'":"&#39;","<":"&lt;",">":"&gt;"},D=/^[\w+/-]+={0,2}$/,s=t=>{if(t==null)return"";if(typeof t=="string")return t.trim();if(typeof t=="object"||Array.isArray(t))try{return JSON.stringify(t).trim()}catch{return""}return String(t).trim()},c=t=>t.replaceAll(/[&<>"']/g,r=>g[r]),w=t=>{const r=s(t);return p(r)??c(r)},E=t=>{const r=s(t);if(!r)return"";const e=p(r);return e===void 0?c(r):e.replaceAll('"',"&quot;").replaceAll("'","&#39;")},y=t=>{const r=s(t);if(!r)return l;const e=p(r)??c(r),i=e.toLowerCase();return d.some(o=>i.startsWith(o))?e.replaceAll('"',"&quot;").replaceAll("'","&#39;"):l},F=t=>{const r=s(t);return r?p(r,{ADD_ATTR:["class","style"]})??w(r):""},f=t=>{const r=s(t);if(r)return D.test(r)?r:void 0},k=(t={})=>{try{return{...t,cspNonce:f(t.cspNonce),openInEditorUrl:t.openInEditorUrl?y(t.openInEditorUrl):void 0}}catch{return{...t,cspNonce:void 0,openInEditorUrl:void 0}}};export{w as a,A as b,x as c,F as d,y as e,f,c as g,k as h,C as l,p,E as s};
@@ -1 +1 @@
1
- import{createRequire as S}from"node:module";import C from"launch-editor-middleware";import{a as $}from"../packem_shared/process-DVasYamT.js";let x;const O=e=>(x??=S(import.meta.url))(e),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,R=e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[s,r]=h.versions.node.split(".").map(Number);if(s>22||s===22&&r>=3||s===20&&r>=16)return h.getBuiltinModule(e)}return O(e)},{realpathSync:w}=R("node:fs"),N=/^[A-Z]:\//i,j=(e="")=>e&&e.replaceAll("\\","/").replace(N,s=>s.toUpperCase()),T=/^[/\\]{2}/,W=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,q=/^[A-Z]:$/i,_=/^\/([A-Z]:)?$/i,E=()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/",v=(e,s)=>{let r="",t=0,n=-1,o=0,c;for(let l=0;l<=e.length;++l){if(l<e.length)c=e[l];else{if(c==="/")break;c="/"}if(c==="/"){if(!(n===l-1||o===1))if(o===2){if(r.length<2||t!==2||!r.endsWith(".")||r.at(-2)!=="."){if(r.length>2){const a=r.lastIndexOf("/");a===-1?(r="",t=0):(r=r.slice(0,a),t=r.length-1-r.lastIndexOf("/")),n=l,o=0;continue}else if(r.length>0){r="",t=0,n=l,o=0;continue}}s&&(r+=r.length>0?"/..":"..",t=2)}else r.length>0?r+=`/${e.slice(n+1,l)}`:r=e.slice(n+1,l),t=l-n-1;n=l,o=0}else c==="."&&o!==-1?++o:o=-1}return r},d=e=>W.test(e),p=function(e){if(e.length===0)return".";e=j(e);const s=T.exec(e),r=d(e),t=e.at(-1)==="/";return e=v(e,!r),e.length===0?r?"/":t?"./":".":(t&&(e+="/"),q.test(e)&&(e+="/"),s?r?`//${e}`:`//./${e}`:r&&!d(e)?`/${e}`:e)},g=function(...e){e=e.map(t=>j(t));let s="",r=!1;for(let t=e.length-1;t>=-1&&!r;t--){const n=t>=0?e[t]:E();!n||n.length===0||(s=`${n}/${s}`,r=d(n))}return s=v(s,!r),r&&!d(s)?`/${s}`:s.length>0?s:"."},P=function(e,s){const r=g(e).replace(_,"$1").split("/"),t=g(s).replace(_,"$1").split("/");if(t[0][1]===":"&&r[0][1]===":"&&r[0]!==t[0])return t.join("/");const n=Math.min(r.length,t.length);let o=0;for(;o<n&&r[o]===t[o];)o+=1;const c=r.length-o;return[...Array.from({length:c}).fill(".."),...t.slice(o)].join("/")},I=/^[\w.+-]+$/,b=e=>{if(typeof e.status=="function"){e.status(400).send("Failed to open editor");return}e.statusCode=400,e.end("Failed to open editor")},A=(e={})=>{const s=async t=>{if((t.method??"GET").toUpperCase()==="POST")return t.body&&typeof t.body=="object"?t.body:new Promise(o=>{try{let c="";const l=()=>{typeof t.removeListener=="function"&&(t.removeListener("data",a),t.removeListener("end",i),t.removeListener("error",f))},a=u=>{c+=String(u),c.length>1e6&&(l(),o({}))},i=()=>{l();try{o(c?JSON.parse(c):{})}catch{o({})}},f=()=>{l(),o({})};t.on("data",a),t.on("end",i),t.on("error",f)}catch{o({})}});const n=new URL(t.url??"","http://localhost");return{column:Number(n.searchParams.get("column")??1),editor:n.searchParams.get("editor")??void 0,file:n.searchParams.get("file")??void 0,line:Number(n.searchParams.get("line")??1)}},r=(t,n,o)=>{if(!t)return;const c=d(t)?t:g(n,t);if(!o)try{const l=w(n),a=w(c),i=p(l),f=p(a),u=$()==="win32"||$()==="darwin",m=u?i.toLowerCase():i,L=u?f.toLowerCase():f,y=P(i,f);if(y.startsWith("..")||d(y)||u&&!L.startsWith(m))return}catch{const l=P(p(n),p(c));if(l.startsWith("..")||d(l))return}return c};return async function(t,n,o){try{const c=await s(t),l=e.projectRoot??process.cwd(),a=r(c.file,l,e.allowOutsideProject??!1);if(!a){b(n);return}const i=c.editor&&I.test(c.editor)?c.editor:void 0,f=C(i,l),u=new URLSearchParams({column:String(c.column??1),file:a,line:String(c.line??1)});if(i&&u.set("editor",i),t.url=`/?${u.toString()}`,typeof o=="function"){f(t,n,o);return}await new Promise(m=>{f(t,n,()=>{m()})})}catch{b(n)}}},B=(e={})=>{const s=A(e);return async(r,t)=>s(r,t)},H=(e={})=>A(e);export{H as createExpressHandler,B as createNodeHttpHandler,A as createOpenInEditorMiddleware};
1
+ import{createRequire as R}from"node:module";import N from"launch-editor-middleware";import{a as _}from"../packem_shared/process-DVasYamT.js";let T;const x=e=>(T??=R(import.meta.url))(e),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,C=e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[o,r]=h.versions.node.split(".").map(Number);if(o>22||o===22&&r>=3||o===20&&r>=16)return h.getBuiltinModule(e)}return x(e)},{realpathSync:w}=C("node:fs"),W=/^[A-Z]:\//i,y=(e="")=>e&&e.replaceAll("\\","/").replace(W,o=>o.toUpperCase()),Z=/^[/\\]{2}/,q=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,L=/^[A-Z]:$/i,b=/^\/([A-Z]:)?$/i,P=/^([A-Z]:)\/$/i,E=()=>{if(typeof process.cwd=="function")try{const e=process.cwd();if(typeof e=="string")return y(e)}catch{}return"/"},S=(e,o)=>{let r="",t=0,n=-1,s=0,c;for(let a=0;a<=e.length;++a){if(a<e.length)c=e[a];else{if(c==="/")break;c="/"}if(c==="/"){if(!(n===a-1||s===1))if(s===2){if(r.length<2||t!==2||!r.endsWith(".")||r.at(-2)!=="."){if(r.length>2){const l=r.lastIndexOf("/");l===-1?(r="",t=0):(r=r.slice(0,l),t=r.length-1-r.lastIndexOf("/")),n=a,s=0;continue}else if(r.length>0){r="",t=0,n=a,s=0;continue}}o&&(r+=r.length>0?"/..":"..",t=2)}else r.length>0?r+=`/${e.slice(n+1,a)}`:r=e.slice(n+1,a),t=a-n-1;n=a,s=0}else c==="."&&s!==-1?++s:s=-1}return r},d=e=>q.test(e),p=function(e){if(e.length===0)return".";e=y(e);const o=Z.exec(e),r=d(e),t=e.at(-1)==="/";return e=S(e,!r),e.length===0?r?"/":t?"./":".":(t&&(e+="/"),L.test(e)&&(e+="/"),o?r?`//${e}`:`//./${e}`:r&&!d(e)?`/${e}`:e)},g=function(...e){e=e.map(t=>y(t));let o="",r=!1;for(let t=e.length-1;t>=-1&&!r;t--){const n=t>=0?e[t]:E();!n||n.length===0||(o=`${n}/${o}`,r=d(n))}return o=S(o,!r),L.test(o)?`${o}/`:r&&!d(o)?`/${o}`:o.length>0?o:"."},j=function(e,o){const r=g(e).replace(b,"$1").replace(P,"$1").split("/"),t=g(o).replace(b,"$1").replace(P,"$1").split("/");if(t[0][1]===":"&&r[0][1]===":"&&r[0]!==t[0])return t.join("/");const n=Math.min(r.length,t.length);let s=0;for(;s<n&&r[s]===t[s];)s+=1;const c=r.length-s;return[...Array.from({length:c}).fill(".."),...t.slice(s)].join("/")},I=/^[\w.+-]+$/,v=e=>{if(typeof e.status=="function"){e.status(400).send("Failed to open editor");return}e.statusCode=400,e.end("Failed to open editor")},A=(e={})=>{const o=async t=>{if((t.method??"GET").toUpperCase()==="POST")return t.body&&typeof t.body=="object"?t.body:new Promise(s=>{try{let c="";const a=()=>{typeof t.removeListener=="function"&&(t.removeListener("data",l),t.removeListener("end",i),t.removeListener("error",f))},l=u=>{c+=String(u),c.length>1e6&&(a(),s({}))},i=()=>{a();try{s(c?JSON.parse(c):{})}catch{s({})}},f=()=>{a(),s({})};t.on("data",l),t.on("end",i),t.on("error",f)}catch{s({})}});const n=new URL(t.url??"","http://localhost");return{column:Number(n.searchParams.get("column")??1),editor:n.searchParams.get("editor")??void 0,file:n.searchParams.get("file")??void 0,line:Number(n.searchParams.get("line")??1)}},r=(t,n,s)=>{if(!t)return;const c=d(t)?t:g(n,t);if(!s)try{const a=w(n),l=w(c),i=p(a),f=p(l),u=_()==="win32"||_()==="darwin",m=u?i.toLowerCase():i,O=u?f.toLowerCase():f,$=j(i,f);if($.startsWith("..")||d($)||u&&!O.startsWith(m))return}catch{const a=j(p(n),p(c));if(a.startsWith("..")||d(a))return}return c};return async function(t,n,s){try{const c=await o(t),a=e.projectRoot??process.cwd(),l=r(c.file,a,e.allowOutsideProject??!1);if(!l){v(n);return}const i=c.editor&&I.test(c.editor)?c.editor:void 0,f=N(i,a),u=new URLSearchParams({column:String(c.column??1),file:l,line:String(c.line??1)});if(i&&u.set("editor",i),t.url=`/?${u.toString()}`,typeof s=="function"){f(t,n,s);return}await new Promise(m=>{f(t,n,()=>{m()})})}catch{v(n)}}},H=(e={})=>{const o=A(e);return async(r,t)=>o(r,t)},F=(e={})=>A(e);export{F as createExpressHandler,H as createNodeHttpHandler,A as createOpenInEditorMiddleware};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/ono",
3
- "version": "2.0.11",
3
+ "version": "2.1.0",
4
4
  "description": "Ono is an error-parsing library that pretty prints JavaScript errors on a web page or the terminal.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -31,11 +31,6 @@
31
31
  "youch"
32
32
  ],
33
33
  "homepage": "https://visulima.com/packages/ono/",
34
- "license": "MIT",
35
- "author": {
36
- "name": "Daniel Bannert",
37
- "email": "d.bannert@anolilab.de"
38
- },
39
34
  "repository": {
40
35
  "type": "git",
41
36
  "url": "https://github.com/visulima/visulima.git",
@@ -51,14 +46,13 @@
51
46
  "url": "https://anolilab.com/support"
52
47
  }
53
48
  ],
54
- "files": [
55
- "dist",
56
- "README.md",
57
- "CHANGELOG.md",
58
- "LICENSE.md"
59
- ],
60
- "type": "module",
49
+ "license": "MIT",
50
+ "author": {
51
+ "name": "Daniel Bannert",
52
+ "email": "d.bannert@anolilab.de"
53
+ },
61
54
  "sideEffects": true,
55
+ "type": "module",
62
56
  "exports": {
63
57
  ".": {
64
58
  "types": "./dist/index.d.ts",
@@ -74,10 +68,12 @@
74
68
  },
75
69
  "./package.json": "./package.json"
76
70
  },
77
- "publishConfig": {
78
- "access": "public",
79
- "provenance": true
80
- },
71
+ "files": [
72
+ "dist",
73
+ "README.md",
74
+ "CHANGELOG.md",
75
+ "LICENSE.md"
76
+ ],
81
77
  "scripts": {
82
78
  "build": "packem build --development",
83
79
  "build:prod": "packem build --production",
@@ -97,11 +93,12 @@
97
93
  "test": "vitest run",
98
94
  "test:coverage": "vitest run --coverage",
99
95
  "test:ui": "vitest --ui --coverage.enabled=true",
100
- "test:watch": "vitest"
96
+ "test:watch": "vitest",
97
+ "test:workerd": "vitest run --config vitest.workerd.config.ts"
101
98
  },
102
99
  "dependencies": {
103
100
  "@shikijs/langs": "catalog:prod",
104
- "@visulima/error": "6.0.0",
101
+ "@visulima/error": "6.1.0",
105
102
  "isomorphic-dompurify": "catalog:prod",
106
103
  "launch-editor-middleware": "catalog:prod",
107
104
  "shiki": "catalog:syntax"
@@ -111,6 +108,7 @@
111
108
  "@anolilab/prettier-config": "catalog:lint",
112
109
  "@anolilab/semantic-release-preset": "catalog:dev",
113
110
  "@arethetypeswrong/cli": "catalog:dev",
111
+ "@cloudflare/vitest-pool-workers": "catalog:test",
114
112
  "@eslint/css": "catalog:lint",
115
113
  "@shikijs/themes": "catalog:dev",
116
114
  "@tailwindcss/forms": "catalog:frontend",
@@ -121,7 +119,7 @@
121
119
  "@types/http-errors": "catalog:types",
122
120
  "@types/node": "catalog:types",
123
121
  "@visulima/packem": "catalog:dev",
124
- "@visulima/path": "3.0.0",
122
+ "@visulima/path": "3.1.0",
125
123
  "@vitest/coverage-v8": "catalog:test",
126
124
  "cssnano": "catalog:dev",
127
125
  "esbuild": "catalog:build",
@@ -143,5 +141,9 @@
143
141
  },
144
142
  "engines": {
145
143
  "node": "^22.14.0 || >=24.10.0"
144
+ },
145
+ "publishConfig": {
146
+ "access": "public",
147
+ "provenance": true
146
148
  }
147
149
  }
@@ -1 +0,0 @@
1
- import{sanitize as n}from"isomorphic-dompurify";const l={javascript:()=>import("@shikijs/langs/javascript"),typescript:()=>import("@shikijs/langs/typescript"),jsx:()=>import("@shikijs/langs/jsx"),tsx:()=>import("@shikijs/langs/tsx"),json:()=>import("@shikijs/langs/json"),json5:()=>import("@shikijs/langs/json5"),jsonc:()=>import("@shikijs/langs/jsonc"),xml:()=>import("@shikijs/langs/xml"),sql:()=>import("@shikijs/langs/sql"),markdown:()=>import("@shikijs/langs/markdown"),mdx:()=>import("@shikijs/langs/mdx"),html:()=>import("@shikijs/langs/html"),css:()=>import("@shikijs/langs/css"),scss:()=>import("@shikijs/langs/scss"),less:()=>import("@shikijs/langs/less"),sass:()=>import("@shikijs/langs/sass"),stylus:()=>import("@shikijs/langs/stylus"),styl:()=>import("@shikijs/langs/styl"),svelte:()=>import("@shikijs/langs/svelte"),vue:()=>import("@shikijs/langs/vue"),bash:()=>import("@shikijs/langs/bash"),shell:()=>import("@shikijs/langs/shell"),yaml:()=>import("@shikijs/langs/yaml"),toml:()=>import("@shikijs/langs/toml"),python:()=>import("@shikijs/langs/python"),go:()=>import("@shikijs/langs/go"),rust:()=>import("@shikijs/langs/rust"),ruby:()=>import("@shikijs/langs/ruby"),php:()=>import("@shikijs/langs/php"),graphql:()=>import("@shikijs/langs/graphql"),dockerfile:()=>import("@shikijs/langs/dockerfile"),text:()=>Promise.resolve({name:"text",patterns:[],scopeName:"source.text",repository:{}})};let a;const m=async()=>{const[t,r]=await Promise.all([import("shiki/core"),import("shiki/engine/javascript")]),{createHighlighterCore:o}=t,{createJavaScriptRegexEngine:e}=r;return await o({themes:[import("../packem_chunks/min-dark.js"),import("../packem_chunks/min-light.js")],langs:[],engine:e()})},u=async(t,r)=>{if(r==="text")return;const o=r.toLowerCase();if(!(t.getLoadedLanguages?.()??t.getLanguages?.()??[]).includes(o)){const e=l[o];e&&await t.loadLanguage?.(await e())}},x=async(t=[])=>{a||(a=m());const r=await a,o=[];for(const e of t)if(typeof e=="string")o.push(e.toLowerCase());else{const s=e.name;s&&o.push(s.toLowerCase())}return await Promise.all(o.map(e=>u(r,e))),r},C="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-check%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Cpath%20d%3D%22M20%206%209%2017l-5-5%22%20%2F%3E%20%3C%2Fsvg%3E",A="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-clipboard%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Crect%20width%3D%228%22%20height%3D%224%22%20x%3D%228%22%20y%3D%222%22%20rx%3D%221%22%20ry%3D%221%22%20%2F%3E%20%3Cpath%20d%3D%22M16%204h2a2%202%200%200%201%202%202v14a2%202%200%200%201-2%202H6a2%202%200%200%201-2-2V6a2%202%200%200%201%202-2h2%22%20%2F%3E%20%3C%2Fsvg%3E",h=["http://","https://","/","./","../"],p="#",g={'"':"&quot;","&":"&amp;","'":"&#39;","<":"&lt;",">":"&gt;"},d=/^[\w+/-]+={0,2}$/,i=t=>{if(t==null)return"";if(typeof t=="string")return t.trim();if(typeof t=="object"||Array.isArray(t))try{return JSON.stringify(t).trim()}catch{return""}return String(t).trim()},c=t=>t.replaceAll(/[&<>"']/g,r=>g[r]),D=t=>{try{return n(i(t))}catch{return c(i(t))}},E=t=>{const r=i(t);if(!r)return"";try{return n(r).replaceAll('"',"&quot;").replaceAll("'","&#39;")}catch{return c(r)}},w=t=>{const r=i(t);if(!r)return p;try{const o=n(r),e=o.toLowerCase();return h.some(s=>e.startsWith(s))?o:p}catch{return p}},F=t=>{const r=i(t);if(!r)return"";try{return n(r,{ADD_ATTR:["class","style"]})}catch{return D(r)}},y=t=>{const r=i(t);if(r)return d.test(r)?r:void 0},k=(t={})=>{try{return{...t,cspNonce:y(t.cspNonce),openInEditorUrl:t.openInEditorUrl?w(t.openInEditorUrl):void 0}}catch{return{...t,cspNonce:void 0,openInEditorUrl:void 0}}};export{D as a,C as b,x as c,F as d,w as e,y as f,k as g,A as l,E as s};