UNPKG

scrivito-pisasales-questionnaire-builder

Version:
82 lines (81 loc) 3.36 kB
import { g as p } from "./idGenerator-CnyWSta9.js"; import { jsx as u } from "react/jsx-runtime"; import { useContext as l, createContext as d } from "react"; const b = (t) => { const s = t.get("filename") || "", e = t.get("format") || "", i = t.get("accessToken") || ""; return { title: s, format: e, token: i }; }, h = (t) => { const s = []; for (const e of t) { const { title: i, token: r } = b(e), a = e.id(), n = c(i), o = { id: a, type: n, title: i, token: r, status: "ready" }; s.push(o); } return s; }, c = (t) => /[.]/.exec(t) && t.split(".").pop() || "", v = (t) => { const s = /* @__PURE__ */ new Map(); for (const e of t) s.set((e.title || "").toLowerCase(), e); return Array.from(s.values()); }, k = (t, s) => { const e = [], i = []; for (const r of t) r.size > s ? i.push(r.name) : e.push(r); return { accepted: e, rejected: i }; }, y = (t, s) => { const e = []; for (const i of s) { const r = (i.name || "").toLowerCase(); t.has(r) || (t.add(r), e.push(i)); } return e; }, z = (t) => t.map((s) => ({ id: `tmp_${p()}`, title: s.name, type: s.type || c(s.name), status: "loading" })), C = (t) => { const s = (t || "").toLowerCase(), e = s.includes(".") && s.split(".").pop() || ""; return e === "pdf" ? "bi-file-earmark-pdf" : /^(png|jpe?g|gif|webp|bmp|svg|tiff?|psd|tga|dds|yuv|thm)$/.test(e) ? "bi-file-earmark-image" : /^(docx?|odt)$/.test(e) ? "bi-file-earmark-word" : /^(xlsx?|ods|csv|tsv)$/.test(e) ? "bi-file-earmark-spreadsheet" : /^(mp3|aif|aiff|iff|m4a|mid|midi|mpa|wav|wma|ogg|flac)$/.test(e) ? "bi-file-earmark-music" : /^(3g2|3gp|asf|avi|flv|m4v|mov|mp4|mpg|mpeg|rm|swf|vob|wmv|mkv|webm)$/.test(e) ? "bi-file-earmark-play" : /^(7z|cbr|deb|gz|rar|zip|zipx|tar|tgz|bz2|xz)$/.test(e) ? "bi-file-earmark-zip" : /^(html?|css|js|jsx|ts|tsx|json|xml|yml|yaml|md|sh|bash|ps1|c|cpp|h|hpp|java|kt|go|rs|php|rb|py|swift|scala|cs|pl)$/.test(e) ? "bi-file-earmark-code" : /^(log|rtf|txt|wps|wpd)$/.test(e) ? "bi-file-earmark-text" : /^(accdb|db|dbf|mdb|pdb|sql|sqlite3?)$/.test(e) ? "bi-database" : "bi-file-earmark"; }, $ = (t) => { if (!t) return { exts: /* @__PURE__ */ new Set(), mimes: [] }; const s = t.split(",").map((r) => r.trim().toLowerCase()).filter(Boolean), e = new Set(s.filter((r) => r.startsWith("."))), i = s.filter((r) => !r.startsWith(".")); return { exts: e, mimes: i }; }, A = (t, s) => { const { exts: e, mimes: i } = s; if (e.size === 0 && i.length === 0) return !0; const r = (t.name || "").toLowerCase(), a = r.includes(".") ? `.${r.split(".").pop()}` : ""; if (a && e.has(a)) return !0; const n = (t.type || "").toLowerCase(); if (n) { for (const o of i) if (o.endsWith("/*")) { const f = o.replace("/*", ""); if (n.startsWith(f)) return !0; } else if (n === o) return !0; } return !1; }, m = d( null ), W = ({ values: t, children: s }) => /* @__PURE__ */ u(m.Provider, { value: t, children: s }), L = () => { const t = l(m); if (!t) throw new Error( "useQuestionnaireWidgetAttributesContext must be used within a QuestionnaireWidgetAttributesProvider" ); return t; }; export { W as Q, z as a, C as b, h as c, y as d, k as f, c as g, A as i, v as m, $ as n, L as u }; //# sourceMappingURL=QuestionnaireWidgetAttributesContext-BG4HHMga.js.map