@imgly/plugin-qr-code-web 0.1.0-rc.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.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # IMG.LY CE.SDK Plugin QR Code
2
+
3
+ This plugin introduces QR codes to the CE.SDK editor. It integrates seamlessly with CE.SDK, providing users with an easy-to-use tool to add QR codes to their designs, which can be scanned to visit a URL.
4
+
5
+ ## Installation
6
+
7
+ You can install the plugin via npm or yarn. Use the following commands to install the package:
8
+
9
+ ```
10
+ yarn add @imgly/plugin-qr-code-web
11
+ npm install @imgly/plugin-qr-code-web
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ Adding the plugin to CE.SDK will register panels and components that can be used inside the editor.
17
+
18
+ ```typescript
19
+ import CreativeEditorSDK from '@cesdk/cesdk-js';
20
+ import QrCodePlugin from '@imgly/plugin-qr-code-web';
21
+
22
+ const config = {
23
+ license: '<your-license-here>'
24
+ };
25
+
26
+ const cesdk = await CreativeEditorSDK.create(container, config);
27
+ await cesdk.addDefaultAssetSources(),
28
+ await cesdk.addDemoAssetSources({ sceneMode: 'Design' }),
29
+
30
+ await cesdk.addPlugin(QrCodePlugin());
31
+
32
+ await cesdk.createDesignScene();
33
+ ```
34
+
35
+ ## Configuration
36
+
37
+ ### Adding Dock Component
38
+
39
+ After adding the plugin to CE.SDK, it will register a component that can be
40
+ used inside the dock to create a QR code.
41
+
42
+ ```typescript
43
+ cesdk.ui.setDockOrder([
44
+ ...cesdk.ui.getDockOrder(),
45
+ // The spacer is optional and pushes the QR code generator to the bottom
46
+ 'ly.img.spacer',
47
+ // This will add a button to the dock that opens the QR code generator panel
48
+ 'ly.img.generate-qr.dock'
49
+ ]);
50
+ ```
@@ -0,0 +1,9 @@
1
+ import { type PluginConfiguration } from './plugin';
2
+ declare const Plugin: (pluginConfiguration?: PluginConfiguration) => {
3
+ initialize: (context: import("@cesdk/engine").EnginePluginContext & {
4
+ cesdk?: import("@cesdk/cesdk-js").default | undefined;
5
+ }) => void;
6
+ name: string;
7
+ version: string;
8
+ };
9
+ export default Plugin;
package/dist/index.mjs ADDED
@@ -0,0 +1,39 @@
1
+ var Mt=class{constructor(t,i){this.engine=t,this.key=i}hasData(t){return this.engine.block.isValid(t)&&this.engine.block.hasMetadata(t,this.key)}get(t){if(this.hasData(t))return JSON.parse(this.engine.block.getMetadata(t,this.key))}set(t,i){this.engine.block.setMetadata(t,this.key,JSON.stringify(i))}clear(t){this.engine.block.hasMetadata(t,this.key)&&this.engine.block.removeMetadata(t,this.key)}},V=Mt,_t=typeof global=="object"&&global&&global.Object===Object&&global,yt=_t,Ft=typeof self=="object"&&self&&self.Object===Object&&self,Nt=yt||Ft||Function("return this")(),E=Nt,Ot=E.Symbol,C=Ot,vt=Object.prototype,jt=vt.hasOwnProperty,Dt=vt.toString,j=C?C.toStringTag:void 0;function Bt(t){var i=jt.call(t,j),a=t[j];try{t[j]=void 0;var l=!0}catch{}var c=Dt.call(t);return l&&(i?t[j]=a:delete t[j]),c}var xt=Bt,Tt=Object.prototype,zt=Tt.toString;function Lt(t){return zt.call(t)}var Ut=Lt,Vt="[object Null]",Ht="[object Undefined]",nt=C?C.toStringTag:void 0;function Gt(t){return t==null?t===void 0?Ht:Vt:nt&&nt in Object(t)?xt(t):Ut(t)}var T=Gt;function $t(t){return t!=null&&typeof t=="object"}var Q=$t,jn=Array.isArray;function qt(t){var i=typeof t;return t!=null&&(i=="object"||i=="function")}var mt=qt,Kt="[object AsyncFunction]",Yt="[object Function]",Xt="[object GeneratorFunction]",Zt="[object Proxy]";function Wt(t){if(!mt(t))return!1;var i=T(t);return i==Yt||i==Xt||i==Kt||i==Zt}var Jt=Wt,Qt=E["__core-js_shared__"],q=Qt,it=function(){var t=/[^.]+$/.exec(q&&q.keys&&q.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function te(t){return!!it&&it in t}var ee=te,re=Function.prototype,ne=re.toString;function ie(t){if(t!=null){try{return ne.call(t)}catch{}try{return t+""}catch{}}return""}var R=ie,oe=/[\\^$.*+?()[\]{}|]/g,ae=/^\[object .+?Constructor\]$/,le=Function.prototype,se=Object.prototype,ce=le.toString,ue=se.hasOwnProperty,fe=RegExp("^"+ce.call(ue).replace(oe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function he(t){if(!mt(t)||ee(t))return!1;var i=Jt(t)?fe:ae;return i.test(R(t))}var pe=he;function de(t,i){return t?.[i]}var ge=de;function be(t,i){var a=ge(t,i);return pe(a)?a:void 0}var k=be,ye=k(E,"WeakMap"),Y=ye;function ve(t,i){return t===i||t!==t&&i!==i}var me=ve,Ee=9007199254740991;function Ae(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ee}var we=Ae;var Dn=Object.prototype;var Re="[object Arguments]";function Se(t){return Q(t)&&T(t)==Re}var ot=Se,Et=Object.prototype,Pe=Et.hasOwnProperty,Ie=Et.propertyIsEnumerable,Bn=ot(function(){return arguments}())?ot:function(t){return Q(t)&&Pe.call(t,"callee")&&!Ie.call(t,"callee")};var At=typeof exports=="object"&&exports&&!exports.nodeType&&exports,at=At&&typeof module=="object"&&module&&!module.nodeType&&module,Ce=at&&at.exports===At,lt=Ce?E.Buffer:void 0,xn=lt?lt.isBuffer:void 0;var ke="[object Arguments]",Me="[object Array]",_e="[object Boolean]",Fe="[object Date]",Ne="[object Error]",Oe="[object Function]",je="[object Map]",De="[object Number]",Be="[object Object]",xe="[object RegExp]",Te="[object Set]",ze="[object String]",Le="[object WeakMap]",Ue="[object ArrayBuffer]",Ve="[object DataView]",He="[object Float32Array]",Ge="[object Float64Array]",$e="[object Int8Array]",qe="[object Int16Array]",Ke="[object Int32Array]",Ye="[object Uint8Array]",Xe="[object Uint8ClampedArray]",Ze="[object Uint16Array]",We="[object Uint32Array]",g={};g[He]=g[Ge]=g[$e]=g[qe]=g[Ke]=g[Ye]=g[Xe]=g[Ze]=g[We]=!0;g[ke]=g[Me]=g[Ue]=g[_e]=g[Ve]=g[Fe]=g[Ne]=g[Oe]=g[je]=g[De]=g[Be]=g[xe]=g[Te]=g[ze]=g[Le]=!1;function Je(t){return Q(t)&&we(t.length)&&!!g[T(t)]}var Qe=Je;function tr(t){return function(i){return t(i)}}var er=tr,wt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,D=wt&&typeof module=="object"&&module&&!module.nodeType&&module,rr=D&&D.exports===wt,K=rr&&yt.process,nr=function(){try{var t=D&&D.require&&D.require("util").types;return t||K&&K.binding&&K.binding("util")}catch{}}(),st=nr,ct=st&&st.isTypedArray,Tn=ct?er(ct):Qe;var ir=Object.prototype,zn=ir.hasOwnProperty;function or(t,i){return function(a){return t(i(a))}}var ar=or,Ln=ar(Object.keys,Object);var lr=Object.prototype,Un=lr.hasOwnProperty;var sr=k(Object,"create"),B=sr;function cr(){this.__data__=B?B(null):{},this.size=0}var ur=cr;function fr(t){var i=this.has(t)&&delete this.__data__[t];return this.size-=i?1:0,i}var hr=fr,pr="__lodash_hash_undefined__",dr=Object.prototype,gr=dr.hasOwnProperty;function br(t){var i=this.__data__;if(B){var a=i[t];return a===pr?void 0:a}return gr.call(i,t)?i[t]:void 0}var yr=br,vr=Object.prototype,mr=vr.hasOwnProperty;function Er(t){var i=this.__data__;return B?i[t]!==void 0:mr.call(i,t)}var Ar=Er,wr="__lodash_hash_undefined__";function Rr(t,i){var a=this.__data__;return this.size+=this.has(t)?0:1,a[t]=B&&i===void 0?wr:i,this}var Sr=Rr;function M(t){var i=-1,a=t==null?0:t.length;for(this.clear();++i<a;){var l=t[i];this.set(l[0],l[1])}}M.prototype.clear=ur;M.prototype.delete=hr;M.prototype.get=yr;M.prototype.has=Ar;M.prototype.set=Sr;var ut=M;function Pr(){this.__data__=[],this.size=0}var Ir=Pr;function Cr(t,i){for(var a=t.length;a--;)if(me(t[a][0],i))return a;return-1}var H=Cr,kr=Array.prototype,Mr=kr.splice;function _r(t){var i=this.__data__,a=H(i,t);if(a<0)return!1;var l=i.length-1;return a==l?i.pop():Mr.call(i,a,1),--this.size,!0}var Fr=_r;function Nr(t){var i=this.__data__,a=H(i,t);return a<0?void 0:i[a][1]}var Or=Nr;function jr(t){return H(this.__data__,t)>-1}var Dr=jr;function Br(t,i){var a=this.__data__,l=H(a,t);return l<0?(++this.size,a.push([t,i])):a[l][1]=i,this}var xr=Br;function _(t){var i=-1,a=t==null?0:t.length;for(this.clear();++i<a;){var l=t[i];this.set(l[0],l[1])}}_.prototype.clear=Ir;_.prototype.delete=Fr;_.prototype.get=Or;_.prototype.has=Dr;_.prototype.set=xr;var G=_,Tr=k(E,"Map"),x=Tr;function zr(){this.size=0,this.__data__={hash:new ut,map:new(x||G),string:new ut}}var Lr=zr;function Ur(t){var i=typeof t;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?t!=="__proto__":t===null}var Vr=Ur;function Hr(t,i){var a=t.__data__;return Vr(i)?a[typeof i=="string"?"string":"hash"]:a.map}var $=Hr;function Gr(t){var i=$(this,t).delete(t);return this.size-=i?1:0,i}var $r=Gr;function qr(t){return $(this,t).get(t)}var Kr=qr;function Yr(t){return $(this,t).has(t)}var Xr=Yr;function Zr(t,i){var a=$(this,t),l=a.size;return a.set(t,i),this.size+=a.size==l?0:1,this}var Wr=Zr;function F(t){var i=-1,a=t==null?0:t.length;for(this.clear();++i<a;){var l=t[i];this.set(l[0],l[1])}}F.prototype.clear=Lr;F.prototype.delete=$r;F.prototype.get=Kr;F.prototype.has=Xr;F.prototype.set=Wr;var Rt=F;function Jr(){this.__data__=new G,this.size=0}var Qr=Jr;function tn(t){var i=this.__data__,a=i.delete(t);return this.size=i.size,a}var en=tn;function rn(t){return this.__data__.get(t)}var nn=rn;function on(t){return this.__data__.has(t)}var an=on,ln=200;function sn(t,i){var a=this.__data__;if(a instanceof G){var l=a.__data__;if(!x||l.length<ln-1)return l.push([t,i]),this.size=++a.size,this;a=this.__data__=new Rt(l)}return a.set(t,i),this.size=a.size,this}var cn=sn;function z(t){var i=this.__data__=new G(t);this.size=i.size}z.prototype.clear=Qr;z.prototype.delete=en;z.prototype.get=nn;z.prototype.has=an;z.prototype.set=cn;var un=Object.prototype,Vn=un.propertyIsEnumerable;var fn=k(E,"DataView"),X=fn,hn=k(E,"Promise"),Z=hn,pn=k(E,"Set"),W=pn,ft="[object Map]",dn="[object Object]",ht="[object Promise]",pt="[object Set]",dt="[object WeakMap]",gt="[object DataView]",gn=R(X),bn=R(x),yn=R(Z),vn=R(W),mn=R(Y),I=T;(X&&I(new X(new ArrayBuffer(1)))!=gt||x&&I(new x)!=ft||Z&&I(Z.resolve())!=ht||W&&I(new W)!=pt||Y&&I(new Y)!=dt)&&(I=function(t){var i=T(t),a=i==dn?t.constructor:void 0,l=a?R(a):"";if(l)switch(l){case gn:return gt;case bn:return ft;case yn:return ht;case vn:return pt;case mn:return dt}return i});var Hn=E.Uint8Array;var En="__lodash_hash_undefined__";function An(t){return this.__data__.set(t,En),this}var wn=An;function Rn(t){return this.__data__.has(t)}var Sn=Rn;function J(t){var i=-1,a=t==null?0:t.length;for(this.__data__=new Rt;++i<a;)this.add(t[i])}J.prototype.add=J.prototype.push=wn;J.prototype.has=Sn;var bt=C?C.prototype:void 0,Gn=bt?bt.valueOf:void 0;var Pn=Object.prototype,$n=Pn.hasOwnProperty;var In=Object.prototype,qn=In.hasOwnProperty;var Kn=new RegExp(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,"i"),Cn=new RegExp(/[A-Fa-f0-9]{1}/,"g"),kn=new RegExp(/[A-Fa-f0-9]{2}/,"g"),tt=(t,i=!1)=>{let{r:a,g:l,b:c,a:h}=t,p=Math.round(255*a),e=Math.round(255*l),n=Math.round(255*c),r=Math.round(255*h),o=s=>s.toString(16).padStart(2,"0");return`#${o(p)}${o(e)}${o(n)}${i?o(r):""}`},St=t=>{let i=(a,l,c,h,p)=>({r:parseInt(a,16)/p,g:parseInt(l,16)/p,b:parseInt(c,16)/p,a:h===void 0?1:parseInt(h,16)/p});if(t.startsWith("#")){if(t.length===4||t.length===5){let a=t.match(Cn);if(a){let[l,c,h,p]=a;return i(l,c,h,p,15)}}if(t.length===7||t.length===8){let a=t.match(kn);if(a){let[l,c,h,p]=a;return i(l,c,h,p,255)}}}throw new Error('Invalid hex string! Allowed RGB formats are "#FFF" and "#FFFFFF". Allowed RGBA formats are "#FFFF" and "#FFFFFFFF')};var N;(h=>{class t{constructor(e,n,r,o){this.version=e;this.errorCorrectionLevel=n;this.modules=[];this.isFunction=[];if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let s=[];for(let u=0;u<this.size;u++)s.push(!1);for(let u=0;u<this.size;u++)this.modules.push(s.slice()),this.isFunction.push(s.slice());this.drawFunctionPatterns();let f=this.addEccAndInterleave(r);if(this.drawCodewords(f),o==-1){let u=1e9;for(let b=0;b<8;b++){this.applyMask(b),this.drawFormatBits(b);let d=this.getPenaltyScore();d<u&&(o=b,u=d),this.applyMask(b)}}l(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(e,n){let r=h.QrSegment.makeSegments(e);return t.encodeSegments(r,n)}static encodeBinary(e,n){let r=h.QrSegment.makeBytes(e);return t.encodeSegments([r],n)}static encodeSegments(e,n,r=1,o=40,s=-1,f=!0){if(!(t.MIN_VERSION<=r&&r<=o&&o<=t.MAX_VERSION)||s<-1||s>7)throw new RangeError("Invalid value");let u,b;for(u=r;;u++){let y=t.getNumDataCodewords(u,n)*8,v=c.getTotalBits(e,u);if(v<=y){b=v;break}if(u>=o)throw new RangeError("Data too long")}for(let y of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])f&&b<=t.getNumDataCodewords(u,y)*8&&(n=y);let d=[];for(let y of e){i(y.mode.modeBits,4,d),i(y.numChars,y.mode.numCharCountBits(u),d);for(let v of y.getData())d.push(v)}l(d.length==b);let O=t.getNumDataCodewords(u,n)*8;l(d.length<=O),i(0,Math.min(4,O-d.length),d),i(0,(8-d.length%8)%8,d),l(d.length%8==0);for(let y=236;d.length<O;y^=253)i(y,8,d);let A=[];for(;A.length*8<d.length;)A.push(0);return d.forEach((y,v)=>A[v>>>3]|=y<<7-(v&7)),new t(u,n,A,s)}getModule(e,n){return 0<=e&&e<this.size&&0<=n&&n<this.size&&this.modules[n][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let r=0;r<this.size;r++)this.setFunctionModule(6,r,r%2==0),this.setFunctionModule(r,6,r%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),n=e.length;for(let r=0;r<n;r++)for(let o=0;o<n;o++)r==0&&o==0||r==0&&o==n-1||r==n-1&&o==0||this.drawAlignmentPattern(e[r],e[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let n=this.errorCorrectionLevel.formatBits<<3|e,r=n;for(let s=0;s<10;s++)r=r<<1^(r>>>9)*1335;let o=(n<<10|r)^21522;l(o>>>15==0);for(let s=0;s<=5;s++)this.setFunctionModule(8,s,a(o,s));this.setFunctionModule(8,7,a(o,6)),this.setFunctionModule(8,8,a(o,7)),this.setFunctionModule(7,8,a(o,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,a(o,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,a(o,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,a(o,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let r=0;r<12;r++)e=e<<1^(e>>>11)*7973;let n=this.version<<12|e;l(n>>>18==0);for(let r=0;r<18;r++){let o=a(n,r),s=this.size-11+r%3,f=Math.floor(r/3);this.setFunctionModule(s,f,o),this.setFunctionModule(f,s,o)}}drawFinderPattern(e,n){for(let r=-4;r<=4;r++)for(let o=-4;o<=4;o++){let s=Math.max(Math.abs(o),Math.abs(r)),f=e+o,u=n+r;0<=f&&f<this.size&&0<=u&&u<this.size&&this.setFunctionModule(f,u,s!=2&&s!=4)}}drawAlignmentPattern(e,n){for(let r=-2;r<=2;r++)for(let o=-2;o<=2;o++)this.setFunctionModule(e+o,n+r,Math.max(Math.abs(o),Math.abs(r))!=1)}setFunctionModule(e,n,r){this.modules[n][e]=r,this.isFunction[n][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw new RangeError("Invalid argument");let o=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],s=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],f=Math.floor(t.getNumRawDataModules(n)/8),u=o-f%o,b=Math.floor(f/o),d=[],O=t.reedSolomonComputeDivisor(s);for(let y=0,v=0;y<o;y++){let P=e.slice(v,v+b-s+(y<u?0:1));v+=P.length;let kt=t.reedSolomonComputeRemainder(P,O);y<u&&P.push(0),d.push(P.concat(kt))}let A=[];for(let y=0;y<d[0].length;y++)d.forEach((v,P)=>{(y!=b-s||P>=u)&&A.push(v[y])});return l(A.length==f),A}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let r=this.size-1;r>=1;r-=2){r==6&&(r=5);for(let o=0;o<this.size;o++)for(let s=0;s<2;s++){let f=r-s,b=(r+1&2)==0?this.size-1-o:o;!this.isFunction[b][f]&&n<e.length*8&&(this.modules[b][f]=a(e[n>>>3],7-(n&7)),n++)}}l(n==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let r=0;r<this.size;r++){let o;switch(e){case 0:o=(r+n)%2==0;break;case 1:o=n%2==0;break;case 2:o=r%3==0;break;case 3:o=(r+n)%3==0;break;case 4:o=(Math.floor(r/3)+Math.floor(n/2))%2==0;break;case 5:o=r*n%2+r*n%3==0;break;case 6:o=(r*n%2+r*n%3)%2==0;break;case 7:o=((r+n)%2+r*n%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[n][r]&&o&&(this.modules[n][r]=!this.modules[n][r])}}getPenaltyScore(){let e=0;for(let s=0;s<this.size;s++){let f=!1,u=0,b=[0,0,0,0,0,0,0];for(let d=0;d<this.size;d++)this.modules[s][d]==f?(u++,u==5?e+=t.PENALTY_N1:u>5&&e++):(this.finderPenaltyAddHistory(u,b),f||(e+=this.finderPenaltyCountPatterns(b)*t.PENALTY_N3),f=this.modules[s][d],u=1);e+=this.finderPenaltyTerminateAndCount(f,u,b)*t.PENALTY_N3}for(let s=0;s<this.size;s++){let f=!1,u=0,b=[0,0,0,0,0,0,0];for(let d=0;d<this.size;d++)this.modules[d][s]==f?(u++,u==5?e+=t.PENALTY_N1:u>5&&e++):(this.finderPenaltyAddHistory(u,b),f||(e+=this.finderPenaltyCountPatterns(b)*t.PENALTY_N3),f=this.modules[d][s],u=1);e+=this.finderPenaltyTerminateAndCount(f,u,b)*t.PENALTY_N3}for(let s=0;s<this.size-1;s++)for(let f=0;f<this.size-1;f++){let u=this.modules[s][f];u==this.modules[s][f+1]&&u==this.modules[s+1][f]&&u==this.modules[s+1][f+1]&&(e+=t.PENALTY_N2)}let n=0;for(let s of this.modules)n=s.reduce((f,u)=>f+(u?1:0),n);let r=this.size*this.size,o=Math.ceil(Math.abs(n*20-r*10)/r)-1;return l(0<=o&&o<=9),e+=o*t.PENALTY_N4,l(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,n=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,r=[6];for(let o=this.size-7;r.length<e;o-=n)r.splice(1,0,o);return r}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*e+128)*e+64;if(e>=2){let r=Math.floor(e/7)+2;n-=(25*r-10)*r-55,e>=7&&(n-=36)}return l(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let n=[];for(let o=0;o<e-1;o++)n.push(0);n.push(1);let r=1;for(let o=0;o<e;o++){for(let s=0;s<n.length;s++)n[s]=t.reedSolomonMultiply(n[s],r),s+1<n.length&&(n[s]^=n[s+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(o=>0);for(let o of e){let s=o^r.shift();r.push(0),n.forEach((f,u)=>r[u]^=t.reedSolomonMultiply(f,s))}return r}static reedSolomonMultiply(e,n){if(e>>>8||n>>>8)throw new RangeError("Byte out of range");let r=0;for(let o=7;o>=0;o--)r=r<<1^(r>>>7)*285,r^=(n>>>o&1)*e;return l(r>>>8==0),r}finderPenaltyCountPatterns(e){let n=e[1];l(n<=this.size*3);let r=n>0&&e[2]==n&&e[3]==n*3&&e[4]==n&&e[5]==n;return(r&&e[0]>=n*4&&e[6]>=n?1:0)+(r&&e[6]>=n*4&&e[0]>=n?1:0)}finderPenaltyTerminateAndCount(e,n,r){return e&&(this.finderPenaltyAddHistory(n,r),n=0),n+=this.size,this.finderPenaltyAddHistory(n,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(e,n){n[0]==0&&(e+=this.size),n.pop(),n.unshift(e)}static{this.MIN_VERSION=1}static{this.MAX_VERSION=40}static{this.PENALTY_N1=3}static{this.PENALTY_N2=3}static{this.PENALTY_N3=40}static{this.PENALTY_N4=10}static{this.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]]}static{this.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]]}}h.QrCode=t;function i(p,e,n){if(e<0||e>31||p>>>e)throw new RangeError("Value out of range");for(let r=e-1;r>=0;r--)n.push(p>>>r&1)}function a(p,e){return(p>>>e&1)!=0}function l(p){if(!p)throw new Error("Assertion error")}class c{constructor(e,n,r){this.mode=e;this.numChars=n;this.bitData=r;if(n<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(e){let n=[];for(let r of e)i(r,8,n);return new c(c.Mode.BYTE,e.length,n)}static makeNumeric(e){if(!c.isNumeric(e))throw new RangeError("String contains non-numeric characters");let n=[];for(let r=0;r<e.length;){let o=Math.min(e.length-r,3);i(parseInt(e.substring(r,r+o),10),o*3+1,n),r+=o}return new c(c.Mode.NUMERIC,e.length,n)}static makeAlphanumeric(e){if(!c.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n=[],r;for(r=0;r+2<=e.length;r+=2){let o=c.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r))*45;o+=c.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r+1)),i(o,11,n)}return r<e.length&&i(c.ALPHANUMERIC_CHARSET.indexOf(e.charAt(r)),6,n),new c(c.Mode.ALPHANUMERIC,e.length,n)}static makeSegments(e){return e==""?[]:c.isNumeric(e)?[c.makeNumeric(e)]:c.isAlphanumeric(e)?[c.makeAlphanumeric(e)]:[c.makeBytes(c.toUtf8ByteArray(e))]}static makeEci(e){let n=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)i(e,8,n);else if(e<16384)i(2,2,n),i(e,14,n);else if(e<1e6)i(6,3,n),i(e,21,n);else throw new RangeError("ECI assignment value out of range");return new c(c.Mode.ECI,0,n)}static isNumeric(e){return c.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return c.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,n){let r=0;for(let o of e){let s=o.mode.numCharCountBits(n);if(o.numChars>=1<<s)return 1/0;r+=4+s+o.bitData.length}return r}static toUtf8ByteArray(e){e=encodeURI(e);let n=[];for(let r=0;r<e.length;r++)e.charAt(r)!="%"?n.push(e.charCodeAt(r)):(n.push(parseInt(e.substring(r+1,r+3),16)),r+=2);return n}static{this.NUMERIC_REGEX=/^[0-9]*$/}static{this.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/}static{this.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"}}h.QrSegment=c})(N||={});(i=>{let t;(l=>{class a{constructor(h,p){this.ordinal=h;this.formatBits=p}static{this.LOW=new a(0,1)}static{this.MEDIUM=new a(1,0)}static{this.QUARTILE=new a(2,3)}static{this.HIGH=new a(3,2)}}l.Ecc=a})(t=i.QrCode||={})})(N||={});(i=>{let t;(l=>{class a{constructor(h,p){this.modeBits=h;this.numBitsCharCount=p}static{this.NUMERIC=new a(1,[10,12,14])}static{this.ALPHANUMERIC=new a(2,[9,11,13])}static{this.BYTE=new a(4,[8,16,16])}static{this.KANJI=new a(8,[8,10,12])}static{this.ECI=new a(7,[0,0,0])}numCharCountBits(h){return this.numBitsCharCount[Math.floor((h+7)/17)]}}l.Mode=a})(t=i.QrSegment||={})})(N||={});var et=N;function rt(t,i){let a=et.QrCode.encodeText(t,et.QrCode.Ecc.HIGH),l=Mn(a);return{svg:_n(l,i,a.size),path:l,size:a.size}}function Mn(t){let i=[];for(let a=0;a<t.size;a++)for(let l=0;l<t.size;l++)t.getModule(l,a)&&i.push(`M${l},${a}h1v1h-1z`);return i.join(" ")}function _n(t,i,a){return`<?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 ${a} ${a}" stroke="none">
4
+ <path d="${t}" fill="${i}"/>
5
+ </svg>
6
+ `}var L="@imgly/plugin-qr-code-web",w="//ly.img.panel/generate-qr",m="//ly.img.panel/update-qr",S="qr-code/fill",U="qr-code/shape",It=(t={})=>{let{createdBlockType:i="shape",addCheckboxForCreatedBlockType:a=!1}=t||{};return{initialize({cesdk:l}){l!=null&&(l.ui.addIconSet("@imgly/plugin/qr",`
7
+ <svg>
8
+ <symbol
9
+ fill="none"
10
+ xmlns="http://www.w3.org/2000/svg"
11
+ viewBox="0 0 24 24"
12
+ id="@imgly/plugin/qr"
13
+ >
14
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M3 3H11V11H3V3ZM5 5H9V9H5V5Z" fill="currentColor"/>
15
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M3 13H11V21H3V13ZM5 15H9V19H5V15Z" fill="currentColor"/>
16
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M13 3V11H21V3H13ZM19 5H15V9H19V5Z" fill="currentColor"/>
17
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15 13H13V15H15V17H13V21H17V19H19V21H21V19H19V17H21V13H17V15H15V13ZM17 17H15V19H17V17ZM17 17V15H19V17H17Z" fill="currentColor"/>
18
+ </symbol>
19
+ </svg>
20
+ `),l.setTranslations({en:{[`panel.${w}`]:"Generate QR Code",[`panel.${w}.description`]:"Add a URL, and we'll create a QR code for you to include in your design. People can scan the QR code to visit the URL.",[`panel.${m}`]:"Update QR Code",[`panel.${m}.description`]:"Update the URL, and we'll refresh the QR code. People can scan the updated QR code to visit the new URL.",[`panel.${m}.asShape`]:"As Shape?"}}),["ly.img.replace","ly.img.crop","ly.img.fill","ly.img.adjustment","ly.img.shape.options"].forEach(c=>{l.feature.enable(c,({isPreviousEnable:h,engine:p})=>p.block.findAllSelected().every(n=>p.block.getKind(n)===S)?!1:h())}),l.ui.registerComponent("ly.img.generate-qr.dock",({builder:c})=>{let h=l.ui.isPanelOpen(w);c.Button("ly.img.generate-qr.dock",{label:"QR Code",icon:"@imgly/plugin/qr",isSelected:h,onClick:()=>{h?l.ui.closePanel(w):l.ui.openPanel(w)}})}),l.ui.registerComponent("ly.img.update-qr.canvasMenu",({builder:c,engine:h})=>{let p=h.block.findAllSelected();if(p.length!==1)return;let e=p[0];if(!h.block.isAllowedByScope(e,"fill/change"))return;let r=new V(h,L),o=h.block.getKind(e);!r.hasData(e)&&o!==S&&o!==U||c.Button("ly.img.update-qr.dock",{label:"common.edit",icon:"@imgly/plugin/qr",onClick:()=>{l.ui.openPanel(m)}})}),l.ui.setCanvasMenuOrder(["ly.img.update-qr.canvasMenu",...l.ui.getCanvasMenuOrder()]),l.ui.registerPanel(w,({builder:c,engine:h,state:p})=>{let e=new V(h,L),n=p("url",""),r=p("color",{r:0,g:0,b:0,a:1}),o=p("asShape",i==="shape");c.Section("ly.img.generate-qr.section",{children:()=>{c.Text("ly.img.generate-qr.text",{content:`panel.${w}.description`}),c.TextInput("ly.img.generate-qr.url",{inputLabel:"URL",inputLabelPosition:"top",...n}),c.ColorInput("ly.img.generate-qr.foregroundColor",{label:"Foreground Color",inputLabel:"Color",inputLabelPosition:"top",...r}),c.Button("ly.img.generate-qr.generate",{label:"Generate QR Code",isDisabled:n.value==="",color:"accent",onClick:async()=>{await Nn(l,h,n.value,r.value,e,o.value)!=null&&l.ui.closePanel(w)}}),a&&c.Checkbox("ly.img.generate-qr.asShape",{inputLabel:`panel.${m}.asShape`,...o})}})}),l.engine.block.onSelectionChanged(()=>{let c=l.engine.block.findAllSelected();if(c.length!==1){l.ui.isPanelOpen(m)&&l.ui.closePanel(m);return}let h=c[0],p=l.engine.block.getKind(h);p!==S&&p!==U&&l.ui.isPanelOpen(m)&&l.ui.closePanel(m)}),l.ui.registerPanel(m,({builder:c,engine:h})=>{let p=new V(h,L),e=h.block.findAllSelected();if(e.length!==1){c.Text("ly.img.update-qr.only-one-block",{content:"Please select only one block to update the QR code."});return}let n=e[0],r=h.block.getKind(n);if(r!==S&&r!==U){c.Text("ly.img.update-qr.only-qr-blocks",{content:"Only QR code blocks can be updated."});return}if(!p.hasData(n)){c.Text("ly.img.update-qr.no-metadata",{content:"Invalid QR code block selected. Missing metadata."});return}let{url:o,color:s}=p.get(n);c.Section("ly.img.update-qr.section",{children:()=>{c.Text("ly.img.update-qr.text",{content:`panel.${m}.description`}),c.TextInput("ly.img.update-qr.url",{inputLabel:"URL",inputLabelPosition:"top",value:o,setValue:f=>{p.set(n,{url:f,color:s}),Pt(l,h,n,f,s)}}),r===S&&c.ColorInput("ly.img.generate-qr.foregroundColor",{inputLabel:"common.color",inputLabelPosition:"top",value:St(s),setValue:f=>{let u=Fn(h,f);p.set(n,{url:o,color:u}),Pt(l,h,n,o,u)}})}})}))}}};function Fn(t,i){let a=typeof i=="string",l;if(a)l=i;else{let c=t.editor.convertColorToColorSpace(i,"sRGB");l=tt(c)}return l}async function Nn(t,i,a,l,c,h){let p=i.editor.convertColorToColorSpace(l,"sRGB"),e=tt(p),{path:n,svg:r,size:o}=rt(a,e),s;if(h){if(s=await i.asset.defaultApplyAsset({id:"qr-code",meta:{vectorPath:n,height:o,width:o,shapeType:"//ly.img.ubq/shape/vector_path"},payload:{}}),s!=null){if(i.block.supportsFill(s)){let f=i.block.getFill(s);i.block.getType(f)==="//ly.img.ubq/fill/color"&&i.block.setColor(f,"fill/color/value",p)}Ct(i,s)}}else{let f=`data:text/plain;base64,${btoa(r)}`;s=await i.asset.defaultApplyAsset({id:"qr-code",meta:{kind:S,fillType:"//ly.img.ubq/fill/image",width:o,height:o},payload:{sourceSet:[{uri:f,width:o,height:o}]}})}return s==null?t.ui.showNotification({type:"error",message:"Failed to create QR code block."}):c.set(s,{url:a,color:e}),s}function Pt(t,i,a,l,c){let{path:h,svg:p,size:e}=rt(l,c),n=i.block.getKind(a);if(n===U){if(!i.block.supportsShape(a)){t.ui.showNotification({type:"error",message:"Invalid state with no shape found."});return}let r=i.block.getShape(a);i.block.setString(r,"shape/vector_path/path",h),i.block.setFloat(r,"shape/vector_path/height",e),i.block.setFloat(r,"shape/vector_path/width",e),Ct(i,a)}else if(n===S){if(!i.block.supportsFill(a)){t.ui.showNotification({type:"error",message:"Invalid state with no fill found."});return}let r=i.block.getFill(a),o=`data:text/plain;base64,${btoa(p)}`;i.block.setSourceSet(r,"fill/image/sourceSet",[{uri:o,width:e,height:e}])}}function Ct(t,i){let a=t.block.duplicate(i),l=t.block.getParent(i);if(l!=null){let c=t.block.create("graphic");t.block.setShape(c,t.block.createShape("//ly.img.ubq/shape/rect")),t.block.appendChild(l,c),t.block.setPositionX(c,t.block.getPositionX(i)),t.block.setPositionY(c,t.block.getPositionY(i)),t.block.setWidth(c,t.block.getWidth(i)),t.block.setHeight(c,t.block.getHeight(i));let h=t.block.combine([a,c],"Intersection");t.block.setShape(i,t.block.getShape(h)),t.block.setKind(i,U),t.block.destroy(h)}return i}var On=t=>({name:L,version:"0.1.0-rc.0",...It(t)}),ni=On;export{ni as default};
21
+ /*! Bundled license information:
22
+
23
+ lodash-es/lodash.js:
24
+ (**
25
+ * @license
26
+ * Lodash (Custom Build) <https://lodash.com/>
27
+ * Build: `lodash modularize exports="es" -o ./`
28
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
29
+ * Released under MIT license <https://lodash.com/license>
30
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
31
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
32
+ *)
33
+ */
34
+ /**
35
+ * @license QR Code generator library (TypeScript)
36
+ * Copyright (c) Project Nayuki.
37
+ * SPDX-License-Identifier: MIT
38
+ */
39
+ //# sourceMappingURL=index.mjs.map