mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
10 lines
32 KiB
JavaScript
10 lines
32 KiB
JavaScript
var $e=Object.defineProperty;var ge=Object.getOwnPropertySymbols;var Le=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable;var he=(e,t,n)=>t in e?$e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Z=(e,t)=>{for(var n in t||(t={}))Le.call(t,n)&&he(e,n,t[n]);if(ge)for(var n of ge(t))De.call(t,n)&&he(e,n,t[n]);return e};import{t as Ue,_ as P}from"./plugin-vue_export-helper.8f6f5b47.js";const Fe=Vue.defineComponent({name:"magic-ui-component",props:{config:{type:Object,default:()=>({})}},setup(e){var i;const t=(i=Vue.getCurrentInstance())==null?void 0:i.proxy,n=Vue.inject("app");return Vue.provide("hoc",t),{tagName:Vue.computed(()=>`magic-ui-${Ue(e.config.type)}`),style:Vue.computed(()=>n==null?void 0:n.transformStyle(e.config.style)),display:()=>{var o;const r=(o=e.config)==null?void 0:o.display;return typeof r=="function"?r(n):r!==!1}}}});function ze(e,t,n,i,r,o){return e.display()?(Vue.openBlock(),Vue.createBlock(Vue.resolveDynamicComponent(e.tagName),{key:0,id:e.config.id,class:Vue.normalizeClass(`magic-ui-component${e.config.className?` ${e.config.className}`:""}`),style:Vue.normalizeStyle(e.style),config:e.config},null,8,["id","class","style","config"])):Vue.createCommentVNode("v-if",!0)}var we=P(Fe,[["render",ze],["__file","/data/magic/tmagic-editor/packages/ui/src/Component.vue"]]),v=e=>{var r,o;const t=Vue.inject("app"),n=(r=t==null?void 0:t.page)==null?void 0:r.getNode(e.config.id),i=(o=Vue.getCurrentInstance())==null?void 0:o.proxy;return n==null||n.emit("created",i),Vue.onMounted(()=>{n==null||n.emit("mounted",i)}),Vue.onUnmounted(()=>{n==null||n.emit("destroy",i)}),t};const Oe=Vue.defineComponent({name:"magic-ui-page",components:{"magic-ui-component":we},props:{config:{type:Object,default:()=>({})}},setup(e){const t=v(e);return{style:Vue.computed(()=>t==null?void 0:t.transformStyle(e.config.style||{})),refresh(){window.location.reload()}}}}),je=["id"];function He(e,t,n,i,r,o){const s=Vue.resolveComponent("magic-ui-component");return Vue.openBlock(),Vue.createElementBlock("div",{id:`${e.config.id||""}`,class:Vue.normalizeClass(`magic-ui-page magic-ui-container${e.config.className?` ${e.config.className}`:""}`),style:Vue.normalizeStyle(e.style)},[Vue.renderSlot(e.$slots,"default"),(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(e.config.items,u=>(Vue.openBlock(),Vue.createBlock(s,{key:u.id,config:u},null,8,["config"]))),128))],14,je)}var Ke=P(Oe,[["render",He],["__file","/data/magic/tmagic-editor/packages/ui/src/page/src/index.vue"]]),Je=e=>({show:()=>{e.config.style.display="initial"},hide:()=>{e.config.style.display="none"}});const Ye=Vue.defineComponent({name:"magic-ui-container",components:{"magic-ui-component":we},props:{config:{type:Object,default:()=>({})}},setup(e){const t=v(e);return Z({style:Vue.computed(()=>t==null?void 0:t.transformStyle(e.config.style||{})),display:()=>{var i;const n=(i=e.config)==null?void 0:i.display;return typeof n=="function"?n(t):n!==!1}},Je(e))}}),qe=["id"];function Ge(e,t,n,i,r,o){const s=Vue.resolveComponent("magic-ui-component");return e.display()?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,id:`${e.config.id||""}`,class:Vue.normalizeClass(`magic-ui-container${e.config.className?` ${e.config.className}`:""}`),style:Vue.normalizeStyle(e.style)},[Vue.renderSlot(e.$slots,"default"),(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(e.config.items,u=>(Vue.openBlock(),Vue.createBlock(s,{key:u.id,config:u},null,8,["config"]))),128))],14,qe)):Vue.createCommentVNode("v-if",!0)}var Qe=P(Ye,[["render",Ge],["__file","/data/magic/tmagic-editor/packages/ui/src/container/src/Container.vue"]]);const xe=Vue.defineComponent({name:"magic-ui-button",props:{config:{type:Object,default:()=>({})},model:{type:Object,default:()=>({})}},setup(e){var u;v(e);const t=(u=Vue.getCurrentInstance())==null?void 0:u.proxy,n=Vue.reactive([]),i=Vue.computed(()=>[typeof e.config.preAction=="function"?e.config.preAction:()=>!0,...n,typeof e.config.postAction=="function"?e.config.postAction:()=>!0]);function r(c){n.push(c)}async function o(){for(const c of i.value)if(typeof c=="function"&&await c(t,{model:e.model})===!1)break}const s=Vue.computed(()=>{var c,a,l;return{type:"text",text:((c=e.config)==null?void 0:c.text)||"",disabledText:((a=e.config)==null?void 0:a.disabledText)||"",html:((l=e.config)==null?void 0:l.html)||""}});return{pushAction:r,clickHandler:o,textConfig:s}}});function We(e,t,n,i,r,o){const s=Vue.resolveComponent("magic-ui-text");return Vue.openBlock(),Vue.createElementBlock("button",{class:"magic-ui-button",onClick:t[0]||(t[0]=(...u)=>e.clickHandler&&e.clickHandler(...u))},[Vue.renderSlot(e.$slots,"default",{},()=>[Vue.createVNode(s,{config:e.textConfig},null,8,["config"])])])}var Ze=P(xe,[["render",We],["__file","/data/magic/tmagic-editor/packages/ui/src/button/src/index.vue"]]);const Xe=Vue.defineComponent({name:"magic-ui-text",props:{config:{type:Object,default:()=>({})},model:{type:Object,default:()=>({})},vars:{type:Object,default:()=>({})}},setup(e){var r;v(e);const t=(r=Vue.getCurrentInstance())==null?void 0:r.proxy,n=Vue.inject("hoc");return{displayText:Vue.computed(()=>{var u,c;let o=((u=e.config)==null?void 0:u.text)||"";const{vars:s}=e;if((n==null?void 0:n.disabled)&&((c=e.config)==null?void 0:c.disabledText)&&(o=e.config.disabledText),typeof o=="function")return o.bind(t)(t,{model:e.model});if(Object.prototype.toString.call(s)==="[object Object]"){let a=o;return Object.entries(s).forEach(([l,C])=>{a=a.replace(new RegExp(`{{${l}}}`,"g"),C)}),a}return o||""})}},render(){var t,n,i,r;const e=(t=this.config)!=null&&t.multiple?"magic-ui-text":"magic-ui-text magic-ui-text--single-line";return typeof((n=this.$slots)==null?void 0:n.default)=="function"?Vue.h("span",{class:e},[((r=(i=this.$slots)==null?void 0:i.default)==null?void 0:r.call(i))||""]):Vue.h("span",Z({class:e},this.displayText?{innerHTML:this.displayText}:{}))}});var et=P(Xe,[["__file","/data/magic/tmagic-editor/packages/ui/src/text/src/index.vue"]]);const tt=Vue.defineComponent({name:"magic-ui-img",props:{config:{type:Object,default:()=>({})},model:{type:Object,default:()=>({})}},setup(e){return v(e),{clickHandler(){e.config.url&&(window.location.href=e.config.url)}}}}),nt=["src"];function ot(e,t,n,i,r,o){return Vue.openBlock(),Vue.createElementBlock("img",{class:"magic-ui-img",src:e.config.src,onClick:t[0]||(t[0]=(...s)=>e.clickHandler&&e.clickHandler(...s))},null,8,nt)}var rt=P(tt,[["render",ot],["__file","/data/magic/tmagic-editor/packages/ui/src/img/src/index.vue"]]),O={},it=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},Ce={},N={};let ue;const st=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];N.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};N.getSymbolTotalCodewords=function(t){return st[t]};N.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};N.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');ue=t};N.isKanjiModeEnabled=function(){return typeof ue!="undefined"};N.toSJIS=function(t){return ue(t)};var q={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(i){return i&&typeof i.bit!="undefined"&&i.bit>=0&&i.bit<4},e.from=function(i,r){if(e.isValid(i))return i;try{return t(i)}catch{return r}}})(q);function Ee(){this.buffer=[],this.length=0}Ee.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var ct=Ee;function j(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}j.prototype.set=function(e,t,n,i){const r=e*this.size+t;this.data[r]=n,i&&(this.reservedBit[r]=!0)};j.prototype.get=function(e,t){return this.data[e*this.size+t]};j.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};j.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var ut=j,Be={};(function(e){const t=N.getSymbolSize;e.getRowColCoords=function(i){if(i===1)return[];const r=Math.floor(i/7)+2,o=t(i),s=o===145?26:Math.ceil((o-13)/(2*r-2))*2,u=[o-7];for(let c=1;c<r-1;c++)u[c]=u[c-1]-s;return u.push(6),u.reverse()},e.getPositions=function(i){const r=[],o=e.getRowColCoords(i),s=o.length;for(let u=0;u<s;u++)for(let c=0;c<s;c++)u===0&&c===0||u===0&&c===s-1||u===s-1&&c===0||r.push([o[u],o[c]]);return r}})(Be);var be={};const at=N.getSymbolSize,me=7;be.getPositions=function(t){const n=at(t);return[[0,0],[n-me,0],[0,n-me]]};var Ae={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},e.from=function(r){return e.isValid(r)?parseInt(r,10):void 0},e.getPenaltyN1=function(r){const o=r.size;let s=0,u=0,c=0,a=null,l=null;for(let C=0;C<o;C++){u=c=0,a=l=null;for(let m=0;m<o;m++){let f=r.get(C,m);f===a?u++:(u>=5&&(s+=t.N1+(u-5)),a=f,u=1),f=r.get(m,C),f===l?c++:(c>=5&&(s+=t.N1+(c-5)),l=f,c=1)}u>=5&&(s+=t.N1+(u-5)),c>=5&&(s+=t.N1+(c-5))}return s},e.getPenaltyN2=function(r){const o=r.size;let s=0;for(let u=0;u<o-1;u++)for(let c=0;c<o-1;c++){const a=r.get(u,c)+r.get(u,c+1)+r.get(u+1,c)+r.get(u+1,c+1);(a===4||a===0)&&s++}return s*t.N2},e.getPenaltyN3=function(r){const o=r.size;let s=0,u=0,c=0;for(let a=0;a<o;a++){u=c=0;for(let l=0;l<o;l++)u=u<<1&2047|r.get(a,l),l>=10&&(u===1488||u===93)&&s++,c=c<<1&2047|r.get(l,a),l>=10&&(c===1488||c===93)&&s++}return s*t.N3},e.getPenaltyN4=function(r){let o=0;const s=r.data.length;for(let c=0;c<s;c++)o+=r.data[c];return Math.abs(Math.ceil(o*100/s/5)-10)*t.N4};function n(i,r,o){switch(i){case e.Patterns.PATTERN000:return(r+o)%2===0;case e.Patterns.PATTERN001:return r%2===0;case e.Patterns.PATTERN010:return o%3===0;case e.Patterns.PATTERN011:return(r+o)%3===0;case e.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(o/3))%2===0;case e.Patterns.PATTERN101:return r*o%2+r*o%3===0;case e.Patterns.PATTERN110:return(r*o%2+r*o%3)%2===0;case e.Patterns.PATTERN111:return(r*o%3+(r+o)%2)%2===0;default:throw new Error("bad maskPattern:"+i)}}e.applyMask=function(r,o){const s=o.size;for(let u=0;u<s;u++)for(let c=0;c<s;c++)o.isReserved(c,u)||o.xor(c,u,n(r,c,u))},e.getBestMask=function(r,o){const s=Object.keys(e.Patterns).length;let u=0,c=1/0;for(let a=0;a<s;a++){o(a),e.applyMask(a,r);const l=e.getPenaltyN1(r)+e.getPenaltyN2(r)+e.getPenaltyN3(r)+e.getPenaltyN4(r);e.applyMask(a,r),l<c&&(c=l,u=a)}return u}})(Ae);var G={};const M=q,H=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],K=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];G.getBlocksCount=function(t,n){switch(n){case M.L:return H[(t-1)*4+0];case M.M:return H[(t-1)*4+1];case M.Q:return H[(t-1)*4+2];case M.H:return H[(t-1)*4+3];default:return}};G.getTotalCodewordsCount=function(t,n){switch(n){case M.L:return K[(t-1)*4+0];case M.M:return K[(t-1)*4+1];case M.Q:return K[(t-1)*4+2];case M.H:return K[(t-1)*4+3];default:return}};var Ne={},Q={};const F=new Uint8Array(512),J=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)F[n]=t,J[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)F[n]=F[n-255]})();Q.log=function(t){if(t<1)throw new Error("log("+t+")");return J[t]};Q.exp=function(t){return F[t]};Q.mul=function(t,n){return t===0||n===0?0:F[J[t]+J[n]]};(function(e){const t=Q;e.mul=function(i,r){const o=new Uint8Array(i.length+r.length-1);for(let s=0;s<i.length;s++)for(let u=0;u<r.length;u++)o[s+u]^=t.mul(i[s],r[u]);return o},e.mod=function(i,r){let o=new Uint8Array(i);for(;o.length-r.length>=0;){const s=o[0];for(let c=0;c<r.length;c++)o[c]^=t.mul(r[c],s);let u=0;for(;u<o.length&&o[u]===0;)u++;o=o.slice(u)}return o},e.generateECPolynomial=function(i){let r=new Uint8Array([1]);for(let o=0;o<i;o++)r=e.mul(r,new Uint8Array([1,t.exp(o)]));return r}})(Ne);const Te=Ne;function ae(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}ae.prototype.initialize=function(t){this.degree=t,this.genPoly=Te.generateECPolynomial(this.degree)};ae.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const i=Te.mod(n,this.genPoly),r=this.degree-i.length;if(r>0){const o=new Uint8Array(this.degree);return o.set(i,r),o}return i};var lt=ae,_e={},k={},le={};le.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var V={};const Ve="[0-9]+",ft="[A-Z $%*+\\-./:]+";let z="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";z=z.replace(/u/g,"\\u");const dt="(?:(?![A-Z0-9 $%*+\\-./:]|"+z+`)(?:.|[\r
|
|
]))+`;V.KANJI=new RegExp(z,"g");V.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");V.BYTE=new RegExp(dt,"g");V.NUMERIC=new RegExp(Ve,"g");V.ALPHANUMERIC=new RegExp(ft,"g");const gt=new RegExp("^"+z+"$"),ht=new RegExp("^"+Ve+"$"),mt=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");V.testKanji=function(t){return gt.test(t)};V.testNumeric=function(t){return ht.test(t)};V.testAlphanumeric=function(t){return mt.test(t)};(function(e){const t=le,n=V;e.NUMERIC={id:"Numeric",bit:1<<0,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:1<<1,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:1<<2,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:1<<3,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(o,s){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!t.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?o.ccBits[0]:s<27?o.ccBits[1]:o.ccBits[2]},e.getBestModeForData=function(o){return n.testNumeric(o)?e.NUMERIC:n.testAlphanumeric(o)?e.ALPHANUMERIC:n.testKanji(o)?e.KANJI:e.BYTE},e.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},e.isValid=function(o){return o&&o.bit&&o.ccBits};function i(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+r)}}e.from=function(o,s){if(e.isValid(o))return o;try{return i(o)}catch{return s}}})(k);(function(e){const t=N,n=G,i=q,r=k,o=le,s=1<<12|1<<11|1<<10|1<<9|1<<8|1<<5|1<<2|1<<0,u=t.getBCHDigit(s);function c(m,f,y){for(let p=1;p<=40;p++)if(f<=e.getCapacity(p,y,m))return p}function a(m,f){return r.getCharCountIndicator(m,f)+4}function l(m,f){let y=0;return m.forEach(function(p){y+=a(p.mode,f)+p.getBitsLength()}),y}function C(m,f){for(let y=1;y<=40;y++)if(l(m,y)<=e.getCapacity(y,f,r.MIXED))return y}e.from=function(f,y){return o.isValid(f)?parseInt(f,10):y},e.getCapacity=function(f,y,p){if(!o.isValid(f))throw new Error("Invalid QR Code version");typeof p=="undefined"&&(p=r.BYTE);const A=t.getSymbolTotalCodewords(f),h=n.getTotalCodewordsCount(f,y),w=(A-h)*8;if(p===r.MIXED)return w;const g=w-a(p,f);switch(p){case r.NUMERIC:return Math.floor(g/10*3);case r.ALPHANUMERIC:return Math.floor(g/11*2);case r.KANJI:return Math.floor(g/13);case r.BYTE:default:return Math.floor(g/8)}},e.getBestVersionForData=function(f,y){let p;const A=i.from(y,i.M);if(Array.isArray(f)){if(f.length>1)return C(f,A);if(f.length===0)return 1;p=f[0]}else p=f;return c(p.mode,p.getLength(),A)},e.getEncodedBits=function(f){if(!o.isValid(f)||f<7)throw new Error("Invalid QR Code version");let y=f<<12;for(;t.getBCHDigit(y)-u>=0;)y^=s<<t.getBCHDigit(y)-u;return f<<12|y}})(_e);var Ie={};const re=N,Se=1<<10|1<<8|1<<5|1<<4|1<<2|1<<1|1<<0,yt=1<<14|1<<12|1<<10|1<<4|1<<1,ye=re.getBCHDigit(Se);Ie.getEncodedBits=function(t,n){const i=t.bit<<3|n;let r=i<<10;for(;re.getBCHDigit(r)-ye>=0;)r^=Se<<re.getBCHDigit(r)-ye;return(i<<10|r)^yt};var Me={};const pt=k;function R(e){this.mode=pt.NUMERIC,this.data=e.toString()}R.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};R.prototype.getLength=function(){return this.data.length};R.prototype.getBitsLength=function(){return R.getBitsLength(this.data.length)};R.prototype.write=function(t){let n,i,r;for(n=0;n+3<=this.data.length;n+=3)i=this.data.substr(n,3),r=parseInt(i,10),t.put(r,10);const o=this.data.length-n;o>0&&(i=this.data.substr(n),r=parseInt(i,10),t.put(r,o*3+1))};var wt=R;const Ct=k,X=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function $(e){this.mode=Ct.ALPHANUMERIC,this.data=e}$.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};$.prototype.getLength=function(){return this.data.length};$.prototype.getBitsLength=function(){return $.getBitsLength(this.data.length)};$.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let i=X.indexOf(this.data[n])*45;i+=X.indexOf(this.data[n+1]),t.put(i,11)}this.data.length%2&&t.put(X.indexOf(this.data[n]),6)};var Et=$,Bt=function(t){for(var n=[],i=t.length,r=0;r<i;r++){var o=t.charCodeAt(r);if(o>=55296&&o<=56319&&i>r+1){var s=t.charCodeAt(r+1);s>=56320&&s<=57343&&(o=(o-55296)*1024+s-56320+65536,r+=1)}if(o<128){n.push(o);continue}if(o<2048){n.push(o>>6|192),n.push(o&63|128);continue}if(o<55296||o>=57344&&o<65536){n.push(o>>12|224),n.push(o>>6&63|128),n.push(o&63|128);continue}if(o>=65536&&o<=1114111){n.push(o>>18|240),n.push(o>>12&63|128),n.push(o>>6&63|128),n.push(o&63|128);continue}n.push(239,191,189)}return new Uint8Array(n).buffer};const bt=Bt,At=k;function L(e){this.mode=At.BYTE,this.data=new Uint8Array(bt(e))}L.getBitsLength=function(t){return t*8};L.prototype.getLength=function(){return this.data.length};L.prototype.getBitsLength=function(){return L.getBitsLength(this.data.length)};L.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var Nt=L;const Tt=k,_t=N;function D(e){this.mode=Tt.KANJI,this.data=e}D.getBitsLength=function(t){return t*13};D.prototype.getLength=function(){return this.data.length};D.prototype.getBitsLength=function(){return D.getBitsLength(this.data.length)};D.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=_t.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
|
|
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var Vt=D,Pe={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,i,r){var o={},s={};s[i]=0;var u=t.PriorityQueue.make();u.push(i,0);for(var c,a,l,C,m,f,y,p,A;!u.empty();){c=u.pop(),a=c.value,C=c.cost,m=n[a]||{};for(l in m)m.hasOwnProperty(l)&&(f=m[l],y=C+f,p=s[l],A=typeof s[l]=="undefined",(A||p>y)&&(s[l]=y,u.push(l,y),o[l]=a))}if(typeof r!="undefined"&&typeof s[r]=="undefined"){var h=["Could not find a path from ",i," to ",r,"."].join("");throw new Error(h)}return o},extract_shortest_path_from_predecessor_list:function(n,i){for(var r=[],o=i;o;)r.push(o),o=n[o];return r.reverse(),r},find_path:function(n,i,r){var o=t.single_source_shortest_paths(n,i,r);return t.extract_shortest_path_from_predecessor_list(o,r)},PriorityQueue:{make:function(n){var i=t.PriorityQueue,r={},o;n=n||{};for(o in i)i.hasOwnProperty(o)&&(r[o]=i[o]);return r.queue=[],r.sorter=n.sorter||i.default_sorter,r},default_sorter:function(n,i){return n.cost-i.cost},push:function(n,i){var r={value:n,cost:i};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Pe);(function(e){const t=k,n=wt,i=Et,r=Nt,o=Vt,s=V,u=N,c=Pe.exports;function a(h){return unescape(encodeURIComponent(h)).length}function l(h,w,g){const d=[];let E;for(;(E=h.exec(g))!==null;)d.push({data:E[0],index:E.index,mode:w,length:E[0].length});return d}function C(h){const w=l(s.NUMERIC,t.NUMERIC,h),g=l(s.ALPHANUMERIC,t.ALPHANUMERIC,h);let d,E;return u.isKanjiModeEnabled()?(d=l(s.BYTE,t.BYTE,h),E=l(s.KANJI,t.KANJI,h)):(d=l(s.BYTE_KANJI,t.BYTE,h),E=[]),w.concat(g,d,E).sort(function(b,T){return b.index-T.index}).map(function(b){return{data:b.data,mode:b.mode,length:b.length}})}function m(h,w){switch(w){case t.NUMERIC:return n.getBitsLength(h);case t.ALPHANUMERIC:return i.getBitsLength(h);case t.KANJI:return o.getBitsLength(h);case t.BYTE:return r.getBitsLength(h)}}function f(h){return h.reduce(function(w,g){const d=w.length-1>=0?w[w.length-1]:null;return d&&d.mode===g.mode?(w[w.length-1].data+=g.data,w):(w.push(g),w)},[])}function y(h){const w=[];for(let g=0;g<h.length;g++){const d=h[g];switch(d.mode){case t.NUMERIC:w.push([d,{data:d.data,mode:t.ALPHANUMERIC,length:d.length},{data:d.data,mode:t.BYTE,length:d.length}]);break;case t.ALPHANUMERIC:w.push([d,{data:d.data,mode:t.BYTE,length:d.length}]);break;case t.KANJI:w.push([d,{data:d.data,mode:t.BYTE,length:a(d.data)}]);break;case t.BYTE:w.push([{data:d.data,mode:t.BYTE,length:a(d.data)}])}}return w}function p(h,w){const g={},d={start:{}};let E=["start"];for(let B=0;B<h.length;B++){const b=h[B],T=[];for(let S=0;S<b.length;S++){const _=b[S],U=""+B+S;T.push(U),g[U]={node:_,lastCount:0},d[U]={};for(let W=0;W<E.length;W++){const I=E[W];g[I]&&g[I].node.mode===_.mode?(d[I][U]=m(g[I].lastCount+_.length,_.mode)-m(g[I].lastCount,_.mode),g[I].lastCount+=_.length):(g[I]&&(g[I].lastCount=_.length),d[I][U]=m(_.length,_.mode)+4+t.getCharCountIndicator(_.mode,w))}}E=T}for(let B=0;B<E.length;B++)d[E[B]].end=0;return{map:d,table:g}}function A(h,w){let g;const d=t.getBestModeForData(h);if(g=t.from(w,d),g!==t.BYTE&&g.bit<d.bit)throw new Error('"'+h+'" cannot be encoded with mode '+t.toString(g)+`.
|
|
Suggested mode is: `+t.toString(d));switch(g===t.KANJI&&!u.isKanjiModeEnabled()&&(g=t.BYTE),g){case t.NUMERIC:return new n(h);case t.ALPHANUMERIC:return new i(h);case t.KANJI:return new o(h);case t.BYTE:return new r(h)}}e.fromArray=function(w){return w.reduce(function(g,d){return typeof d=="string"?g.push(A(d,null)):d.data&&g.push(A(d.data,d.mode)),g},[])},e.fromString=function(w,g){const d=C(w,u.isKanjiModeEnabled()),E=y(d),B=p(E,g),b=c.find_path(B.map,"start","end"),T=[];for(let S=1;S<b.length-1;S++)T.push(B.table[b[S]].node);return e.fromArray(f(T))},e.rawSplit=function(w){return e.fromArray(C(w,u.isKanjiModeEnabled()))}})(Me);const x=N,ee=q,It=ct,St=ut,Mt=Be,Pt=be,ie=Ae,se=G,kt=lt,Y=_e,vt=Ie,Rt=k,te=Me;function $t(e,t){const n=e.size,i=Pt.getPositions(t);for(let r=0;r<i.length;r++){const o=i[r][0],s=i[r][1];for(let u=-1;u<=7;u++)if(!(o+u<=-1||n<=o+u))for(let c=-1;c<=7;c++)s+c<=-1||n<=s+c||(u>=0&&u<=6&&(c===0||c===6)||c>=0&&c<=6&&(u===0||u===6)||u>=2&&u<=4&&c>=2&&c<=4?e.set(o+u,s+c,!0,!0):e.set(o+u,s+c,!1,!0))}}function Lt(e){const t=e.size;for(let n=8;n<t-8;n++){const i=n%2===0;e.set(n,6,i,!0),e.set(6,n,i,!0)}}function Dt(e,t){const n=Mt.getPositions(t);for(let i=0;i<n.length;i++){const r=n[i][0],o=n[i][1];for(let s=-2;s<=2;s++)for(let u=-2;u<=2;u++)s===-2||s===2||u===-2||u===2||s===0&&u===0?e.set(r+s,o+u,!0,!0):e.set(r+s,o+u,!1,!0)}}function Ut(e,t){const n=e.size,i=Y.getEncodedBits(t);let r,o,s;for(let u=0;u<18;u++)r=Math.floor(u/3),o=u%3+n-8-3,s=(i>>u&1)===1,e.set(r,o,s,!0),e.set(o,r,s,!0)}function ne(e,t,n){const i=e.size,r=vt.getEncodedBits(t,n);let o,s;for(o=0;o<15;o++)s=(r>>o&1)===1,o<6?e.set(o,8,s,!0):o<8?e.set(o+1,8,s,!0):e.set(i-15+o,8,s,!0),o<8?e.set(8,i-o-1,s,!0):o<9?e.set(8,15-o-1+1,s,!0):e.set(8,15-o-1,s,!0);e.set(i-8,8,1,!0)}function Ft(e,t){const n=e.size;let i=-1,r=n-1,o=7,s=0;for(let u=n-1;u>0;u-=2)for(u===6&&u--;;){for(let c=0;c<2;c++)if(!e.isReserved(r,u-c)){let a=!1;s<t.length&&(a=(t[s]>>>o&1)===1),e.set(r,u-c,a),o--,o===-1&&(s++,o=7)}if(r+=i,r<0||n<=r){r-=i,i=-i;break}}}function zt(e,t,n){const i=new It;n.forEach(function(c){i.put(c.mode.bit,4),i.put(c.getLength(),Rt.getCharCountIndicator(c.mode,e)),c.write(i)});const r=x.getSymbolTotalCodewords(e),o=se.getTotalCodewordsCount(e,t),s=(r-o)*8;for(i.getLengthInBits()+4<=s&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(0);const u=(s-i.getLengthInBits())/8;for(let c=0;c<u;c++)i.put(c%2?17:236,8);return Ot(i,e,t)}function Ot(e,t,n){const i=x.getSymbolTotalCodewords(t),r=se.getTotalCodewordsCount(t,n),o=i-r,s=se.getBlocksCount(t,n),u=i%s,c=s-u,a=Math.floor(i/s),l=Math.floor(o/s),C=l+1,m=a-l,f=new kt(m);let y=0;const p=new Array(s),A=new Array(s);let h=0;const w=new Uint8Array(e.buffer);for(let b=0;b<s;b++){const T=b<c?l:C;p[b]=w.slice(y,y+T),A[b]=f.encode(p[b]),y+=T,h=Math.max(h,T)}const g=new Uint8Array(i);let d=0,E,B;for(E=0;E<h;E++)for(B=0;B<s;B++)E<p[B].length&&(g[d++]=p[B][E]);for(E=0;E<m;E++)for(B=0;B<s;B++)g[d++]=A[B][E];return g}function jt(e,t,n,i){let r;if(Array.isArray(e))r=te.fromArray(e);else if(typeof e=="string"){let a=t;if(!a){const l=te.rawSplit(e);a=Y.getBestVersionForData(l,n)}r=te.fromString(e,a||40)}else throw new Error("Invalid data");const o=Y.getBestVersionForData(r,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=o;else if(t<o)throw new Error(`
|
|
The chosen QR Code version cannot contain this amount of data.
|
|
Minimum version required to store current data is: `+o+`.
|
|
`);const s=zt(t,n,r),u=x.getSymbolSize(t),c=new St(u);return $t(c,t),Lt(c),Dt(c,t),ne(c,n,0),t>=7&&Ut(c,t),Ft(c,s),isNaN(i)&&(i=ie.getBestMask(c,ne.bind(null,c,n))),ie.applyMask(i,c),ne(c,n,i),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:i,segments:r}}Ce.create=function(t,n){if(typeof t=="undefined"||t==="")throw new Error("No input text");let i=ee.M,r,o;return typeof n!="undefined"&&(i=ee.from(n.errorCorrectionLevel,ee.M),r=Y.from(n.version),o=ie.from(n.maskPattern),n.toSJISFunc&&x.setToSJISFunction(n.toSJISFunc)),jt(t,r,i,o)};var ke={},fe={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let i=n.slice().replace("#","").split("");if(i.length<3||i.length===5||i.length>8)throw new Error("Invalid hex color: "+n);(i.length===3||i.length===4)&&(i=Array.prototype.concat.apply([],i.map(function(o){return[o,o]}))),i.length===6&&i.push("F","F");const r=parseInt(i.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+i.slice(0,6).join("")}}e.getOptions=function(i){i||(i={}),i.color||(i.color={});const r=typeof i.margin=="undefined"||i.margin===null||i.margin<0?4:i.margin,o=i.width&&i.width>=21?i.width:void 0,s=i.scale||4;return{width:o,scale:o?4:s,margin:r,color:{dark:t(i.color.dark||"#000000ff"),light:t(i.color.light||"#ffffffff")},type:i.type,rendererOpts:i.rendererOpts||{}}},e.getScale=function(i,r){return r.width&&r.width>=i+r.margin*2?r.width/(i+r.margin*2):r.scale},e.getImageWidth=function(i,r){const o=e.getScale(i,r);return Math.floor((i+r.margin*2)*o)},e.qrToImageData=function(i,r,o){const s=r.modules.size,u=r.modules.data,c=e.getScale(s,o),a=Math.floor((s+o.margin*2)*c),l=o.margin*c,C=[o.color.light,o.color.dark];for(let m=0;m<a;m++)for(let f=0;f<a;f++){let y=(m*a+f)*4,p=o.color.light;if(m>=l&&f>=l&&m<a-l&&f<a-l){const A=Math.floor((m-l)/c),h=Math.floor((f-l)/c);p=C[u[A*s+h]?1:0]}i[y++]=p.r,i[y++]=p.g,i[y++]=p.b,i[y]=p.a}}})(fe);(function(e){const t=fe;function n(r,o,s){r.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=s,o.width=s,o.style.height=s+"px",o.style.width=s+"px"}function i(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(o,s,u){let c=u,a=s;typeof c=="undefined"&&(!s||!s.getContext)&&(c=s,s=void 0),s||(a=i()),c=t.getOptions(c);const l=t.getImageWidth(o.modules.size,c),C=a.getContext("2d"),m=C.createImageData(l,l);return t.qrToImageData(m.data,o,c),n(C,a,l),C.putImageData(m,0,0),a},e.renderToDataURL=function(o,s,u){let c=u;typeof c=="undefined"&&(!s||!s.getContext)&&(c=s,s=void 0),c||(c={});const a=e.render(o,s,c),l=c.type||"image/png",C=c.rendererOpts||{};return a.toDataURL(l,C.quality)}})(ke);var ve={};const Ht=fe;function pe(e,t){const n=e.a/255,i=t+'="'+e.hex+'"';return n<1?i+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':i}function oe(e,t,n){let i=e+t;return typeof n!="undefined"&&(i+=" "+n),i}function Kt(e,t,n){let i="",r=0,o=!1,s=0;for(let u=0;u<e.length;u++){const c=Math.floor(u%t),a=Math.floor(u/t);!c&&!o&&(o=!0),e[u]?(s++,u>0&&c>0&&e[u-1]||(i+=o?oe("M",c+n,.5+a+n):oe("m",r,0),r=0,o=!1),c+1<t&&e[u+1]||(i+=oe("h",s),s=0)):r++}return i}ve.render=function(t,n,i){const r=Ht.getOptions(n),o=t.modules.size,s=t.modules.data,u=o+r.margin*2,c=r.color.light.a?"<path "+pe(r.color.light,"fill")+' d="M0 0h'+u+"v"+u+'H0z"/>':"",a="<path "+pe(r.color.dark,"stroke")+' d="'+Kt(s,o,r.margin)+'"/>',l='viewBox="0 0 '+u+" "+u+'"',C=r.width?'width="'+r.width+'" height="'+r.width+'" ':"",m='<svg xmlns="http://www.w3.org/2000/svg" '+C+l+' shape-rendering="crispEdges">'+c+a+`</svg>
|
|
`;return typeof i=="function"&&i(null,m),m};const Jt=it,ce=Ce,Re=ke,Yt=ve;function de(e,t,n,i,r){const o=[].slice.call(arguments,1),s=o.length,u=typeof o[s-1]=="function";if(!u&&!Jt())throw new Error("Callback required as last argument");if(u){if(s<2)throw new Error("Too few arguments provided");s===2?(r=n,n=t,t=i=void 0):s===3&&(t.getContext&&typeof r=="undefined"?(r=i,i=void 0):(r=i,i=n,n=t,t=void 0))}else{if(s<1)throw new Error("Too few arguments provided");return s===1?(n=t,t=i=void 0):s===2&&!t.getContext&&(i=n,n=t,t=void 0),new Promise(function(c,a){try{const l=ce.create(n,i);c(e(l,t,i))}catch(l){a(l)}})}try{const c=ce.create(n,i);r(null,e(c,t,i))}catch(c){r(c)}}O.create=ce.create;O.toCanvas=de.bind(null,Re.render);O.toDataURL=de.bind(null,Re.renderToDataURL);O.toString=de.bind(null,function(e,t,n){return Yt.render(e,n)});const qt=Vue.defineComponent({name:"magic-ui-qrcode",props:{config:{type:Object,default:()=>({})},model:{type:Object,default:()=>({})}},setup(e){v(e);const t=Vue.ref();return Vue.watch(()=>e.config.url,(n="")=>{O.toDataURL(n,(i,r)=>{i&&console.error(i),t.value=r})},{immediate:!0}),{imgUrl:t}}}),Gt=["src"];function Qt(e,t,n,i,r,o){return Vue.openBlock(),Vue.createElementBlock("img",{class:"magic-ui-qrcode",src:e.imgUrl},null,8,Gt)}var xt=P(qt,[["render",Qt],["__file","/data/magic/tmagic-editor/packages/ui/src/qrcode/src/index.vue"]]);const Wt=Vue.defineComponent({name:"magic-ui-overlay",props:{config:{type:Object,default:()=>({})},model:{type:Object,default:()=>({})}},setup(e){var s;const t=Vue.ref(!1),n=v(e),i=(s=n==null?void 0:n.page)==null?void 0:s.getNode(e.config.id),r=()=>{t.value=!0,n&&n.emit("overlay:open",i)},o=()=>{t.value=!1,n&&n.emit("overlay:close",i)};return n==null||n.on("editor:select",(u,c)=>{c.find(a=>a.id===e.config.id)?r():o()}),{visible:t,openOverlay:r,closeOverlay:o}}});function Zt(e,t,n,i,r,o){const s=Vue.resolveComponent("magic-ui-container");return e.visible?(Vue.openBlock(),Vue.createBlock(s,{key:0,class:"magic-ui-overlay",config:{items:e.config.items}},{default:Vue.withCtx(()=>[Vue.renderSlot(e.$slots,"default")]),_:3},8,["config"])):Vue.createCommentVNode("v-if",!0)}var Xt=P(Wt,[["render",Zt],["__file","/data/magic/tmagic-editor/packages/ui/src/overlay/src/index.vue"]]);const en={page:Ke,container:Qe,button:Ze,text:et,img:rt,qrcode:xt,overlay:Xt},tn={},nn={components:en,plugins:tn};window.magicPresetComponents=nn;export{nn as default};
|
|
//# sourceMappingURL=comp-entry.d785a88e.js.map
|